diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index c95dad895..29f2665bc 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -217,10 +217,10 @@ class PropertyRentalWizard(models.Model): "due_date": start_date }) - def process_rent_record(self, record, rent_id, date_field_year_month, days, period_month=0, multiplier=1, is_year=0): + def process_rent_record(self, record, rent_id, date_field_year_month, multiplier=1): """封装处理租金逻辑,增加 multiplier 参数用于乘法""" if rent_id.start_data: - start_date_adj = rent_id.start_data + relativedelta(months=period_month) + start_date_adj = rent_id.start_data start_year_month = start_date_adj.strftime('%Y-%m') end_year_month = rent_id.end_data.strftime('%Y-%m') start_day = start_date_adj.day @@ -251,39 +251,17 @@ class PropertyRentalWizard(models.Model): # 获取当月第一天和最后一天 first_day = datetime.strptime(date_field_year_month, '%Y-%m').date() last_day = first_day + relativedelta(months=1) - relativedelta(days=1) + next_month_first_day = first_day + relativedelta(months=1) records = self.env['property.lease.contract'].search([ - ('actual_start_time', '<=', last_day), + ('actual_start_time', '<', next_month_first_day), ('actual_end_time', '>=', first_day), ]) - filtered_records = [ - rec for rec in records - if not ( - rec.cycle_mode == 'fixed_monthly' - # 条件2:实际开始日期的日是1号 - and getattr(rec.actual_start_time, 'day', None) != 1 - # 条件3:实际结束日期的年月等于目标年月 - and getattr(rec.actual_end_time, 'year', None) == year - and getattr(rec.actual_end_time, 'month', None) == month - ) - ] - for record in filtered_records: - date_data = { - 'five': 5, - 'fifteen': 15, - 'twentyfive': 25 - } - days = date_data.get(record.date_of_payment, 0) - period_month = record.rent_free_period_month if record.rent_free_period_month else 0 # 免租期 - - #判断是否年 - is_year = 0 - if record.cycle_dict == 'year': - is_year = 1 + for record in records: # 获取租金乘数(1 表示按月,3 表示季租金,6 表示半年租金,年后面赋值) multiplier = self.get_multiplier(record.cycle_dict) for rent_id in record.breakdown_ids: - self.process_rent_record(record, rent_id, date_field_year_month, days, period_month, multiplier, is_year) + self.process_rent_record(record, rent_id, date_field_year_month, multiplier) self.create_deposit_list(record) # 生成水电费列表 self.create_water_fee_list(record, first_day, last_day)