From 9ed7625024f05813c7a96203399f57e7f94b3b51 Mon Sep 17 00:00:00 2001 From: ljmwkx <1340053001@qq.com> Date: Thu, 9 Jan 2025 14:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/property_lease_contract.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 9dc038443..2d5f22639 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -352,17 +352,17 @@ class PropertyLeaseContract(models.Model): record.write({'breakdown_ids': [(5, 0, 0)]}) start_date = record.term_start_time end_date = record.term_end_time + relativedelta(days=1) - record.do_generate_details_core(start_date, end_date) + record.do_generate_details_core(True, start_date, end_date) # 计算首年租金 first_year_end_date = start_date + relativedelta(months=12) if first_year_end_date > end_date: first_year_end_date = end_date - all_period_rent = record.do_generate_details_core(start_date, first_year_end_date) + all_period_rent = record.do_generate_details_core(False, start_date, first_year_end_date) record.first_year_rent = all_period_rent - def do_generate_details_core(self, start_date, end_date): + def do_generate_details_core(self, write_db=False, start_date, end_date): all_period_rent = 0 monthly_amount = self.total_area * self.unit_price @@ -507,22 +507,22 @@ class PropertyLeaseContract(models.Model): "period_rent": period_rent, } all_period_rent += period_rent + if write_db: + # 是否免租期 月 + if free_start_dict: + self.sudo().write({'breakdown_ids': [(0, 0, free_start_dict)]}) - # 是否免租期 月 - if free_start_dict: - self.sudo().write({'breakdown_ids': [(0, 0, free_start_dict)]}) + # 是否免租期 日 + if free_start_day_dict: + self.sudo().write({'breakdown_ids': [(0, 0, free_start_day_dict)]}) - # 是否免租期 日 - if free_start_day_dict: - self.sudo().write({'breakdown_ids': [(0, 0, free_start_day_dict)]}) + # 开始统计月份阶段金额 + for k, v in monthly_amount_new_dict.items(): + self.sudo().write({'breakdown_ids': [(0, 0, v)]}) - # 开始统计月份阶段金额 - for k, v in monthly_amount_new_dict.items(): - self.sudo().write({'breakdown_ids': [(0, 0, v)]}) - - # 最后有不足月的单独计算 - if monthly_amount_last_dict: - self.sudo().write({'breakdown_ids': [(0, 0, monthly_amount_last_dict)]}) + # 最后有不足月的单独计算 + if monthly_amount_last_dict: + self.sudo().write({'breakdown_ids': [(0, 0, monthly_amount_last_dict)]}) return all_period_rent