From c3b2389df364c831c2ae9c6a1eaa3a36aa2d4be5 Mon Sep 17 00:00:00 2001
From: ljmwkx <1340053001@qq.com>
Date: Thu, 19 Dec 2024 17:51:17 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E8=B4=B9=E7=94=A8=20=E8=AE=A1=E7=AE=97?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/property_lease_contract.py | 264 +++++++-----------
.../views/property_lease_contract.xml | 4 +
2 files changed, 103 insertions(+), 165 deletions(-)
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index 140cad350..9b7d23621 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -49,6 +49,10 @@ class PropertyLeaseContract(models.Model):
cycle_mode = fields.Selection([('fixed','合同月'), ('floating','自然月')],string='周期方式')
expected_reminders = fields.Char(string="逾期提醒")
increment_method = fields.Selection([('percentage','百分比'),('increment_price','递增单价'),('increment_amount','递增金额')], string='每月递增')
+
+ first_years_begin = fields.Integer(string="第几年开始")
+ increments_every_few_years = fields.Integer(string="每几年递增")
+
increment_percentage = fields.Float(string="递增百分比")
increment_price = fields.Float(string="递增单价")
increment_amount = fields.Float(string="递增金额")
@@ -114,7 +118,7 @@ class PropertyLeaseContract(models.Model):
def action_generate_rental_charges(self):
"""
- 生成租金明细
+ 生成租金费用明细
:return:
"""
for record in self:
@@ -123,64 +127,53 @@ class PropertyLeaseContract(models.Model):
if not record.term_end_time:
raise UserError(_("请填写租期结束时间!"))
self.sudo().env["property.rent.list"].search([("contract_id", "=", record.id)]).unlink()
- # 按照月度计算明细
- if record.cycle_dict == "monthly":
- months = 1
- elif record.cycle_dict == "quarter":
- months = 3
- elif record.cycle_dict == "half":
- months = 6
- elif record.cycle_dict == "year":
- months = 12
- else:
- raise UserError(_("请填写付款方式!"))
- # unit_price = fields.Float(string="单价")
- # monthly_amount = fields.Float(string="月租金")
- # start_data = fields.Date(string="开始日期")
- # end_data = fields.Date(string="结束日期")
- # month_number = fields.Integer(string="期间月数")
- # period_rent = fields.Float(string="期间租金")"""
start_date = record.term_start_time
end_date = record.term_end_time
- # 先按照年分组
- divided_year_segments = self.divide_time_range_fixed(start_date, end_date, 12)
- index = 0 # 第几年
- period_rent = 0 # 月租金
- unit_price = 0 # 单价
- for segment_year in divided_year_segments:
+ first_years_begin = record.first_years_begin if record.first_years_begin else 0
+ increments_every_few_years = record.increments_every_few_years
+ period_rent = record.total_area * record.unit_price # 月租金
+ unit_price = record.unit_price # 单价
+ # 先计算免租期
+ first_index = 0 # 第几递增周期年
+ increments_start = start_date # 递增开始
+ all_period_rent = 0
+ # 第几年不递增
+ if first_years_begin:
+ divided_year_segments = self.divide_time_range_fixed(start_date, end_date, 12)
+ for segment_year in divided_year_segments:
+ first_index += 1
+ if first_years_begin and first_index > first_years_begin:
+ increments_start = segment_year[0]
+ break
+ all_period_rent += period_rent * 12 * first_years_begin
+
+ # 开始递增
+ divided_increments_segments = self.divide_time_range_fixed(increments_start, end_date, increments_every_few_years * 12)
+ index = 0 # 第几递增周期年
+ for increments_year in divided_increments_segments:
index += 1
"""
increment_percentage = fields.Float(string="递增百分比")
increment_price = fields.Float(string="递增单价")
increment_amount = fields.Float(string="递增金额")
"""
- if index > 1:
- if record.increment_price:
- unit_price = unit_price + record.increment_price
- if record.increment_percentage:
- period_rent = record.total_area * unit_price * record.increment_percentage
- if record.increment_amount:
- period_rent = period_rent + record.increment_amount
- else:
- period_rent = record.total_area * record.unit_price
- unit_price = record.unit_price
- divided_time_segments = self.divide_time_range_fixed(segment_year[0], segment_year[1], months)
- # if record.cycle_mode == "fixed":
- # # 按照月份、季度、年份进行分组
- # divided_time_segments = self.divide_time_range_fixed(segment_year[0], segment_year[1], months)
- # elif record.cycle_mode == "floating":
- # # 按照月份、季度、年份进行分组
- # divided_time_segments = self.divide_time_range_floating(segment_year[0], segment_year[1], months)
- # else:
- # raise UserError(_("请填写周期方式!"))
- for segment in divided_time_segments:
- self.sudo().env["property.rent.list"].create({
- "contract_id": record.id,
- "contract_code": record.code,
- "due_date": segment[0],
- "original_amount": period_rent * months,
- })
+ if record.increment_price:
+ unit_price = unit_price + record.increment_price
+ if record.increment_percentage:
+ period_rent = record.total_area * unit_price * record.increment_percentage
+ unit_price = period_rent / record.total_area
+ if record.increment_amount:
+ period_rent = period_rent + record.increment_amount
+ unit_price = period_rent / record.total_area
+ all_period_rent += period_rent * 12 * increments_every_few_years
+
+ self.sudo().env["property.rent.list"].create({
+ "contract_id": record.id,
+ "contract_code": record.code,
+ "due_date": start_date,
+ "original_amount": all_period_rent,
+ })
def action_generate_administrative_expenses(self):
"""
@@ -193,72 +186,18 @@ class PropertyLeaseContract(models.Model):
if not record.term_end_time:
raise UserError(_("请填写租期结束时间!"))
self.sudo().env["property.management.list"].search([("contract_id", "=", record.id)]).unlink()
- # 按照月度计算明细
- if record.cycle_dict == "monthly":
- months = 1
- elif record.cycle_dict == "quarter":
- months = 3
- elif record.cycle_dict == "half":
- months = 6
- elif record.cycle_dict == "year":
- months = 12
- else:
- raise UserError(_("请填写付款方式!"))
- # unit_price = fields.Float(string="单价")
- # monthly_amount = fields.Float(string="月租金")
- # start_data = fields.Date(string="开始日期")
- # end_data = fields.Date(string="结束日期")
- # month_number = fields.Integer(string="期间月数")
- # period_rent = fields.Float(string="期间租金")"""
start_date = record.term_start_time
end_date = record.term_end_time
- # 先按照年分组
- divided_year_segments = self.divide_time_range_fixed(start_date, end_date, 12)
- index = 0 # 第几年
- for segment_year in divided_year_segments:
- index += 1
- """
- increment_percentage = fields.Float(string="递增百分比")
- increment_price = fields.Float(string="递增单价")
- increment_amount = fields.Float(string="递增金额")
- """
- divided_time_segments = self.divide_time_range_fixed(segment_year[0], segment_year[1], months)
- # if record.cycle_mode == "fixed":
- # # 按照月份、季度、年份进行分组
- # divided_time_segments = self.divide_time_range_fixed(segment_year[0], segment_year[1], months)
- # elif record.cycle_mode == "floating":
- # # 按照月份、季度、年份进行分组
- # divided_time_segments = self.divide_time_range_floating(segment_year[0], segment_year[1], months)
- # else:
- # raise UserError(_("请填写周期方式!"))
- for segment in divided_time_segments:
- """
- contract_code = fields.Char(string='合同编号', required=True)
- property_id = fields.Many2one('yuthon.property', string='物业')
- lessee_id = fields.Many2one('yuthon.property.lessee', string='承租方')
- due_date = fields.Date(string='应收日期')
- year = fields.Char(string='所属年')
- month = fields.Char(string='所属月')
- management_fee_standard = fields.Float(string='管理费标准')
- original_amount = fields.Float(string='原金额')
- reduction_amount = fields.Float(string='减免金额')
- remarks = fields.Text(string='备注')
- is_cancel = fields.Boolean(string='是否作废')
- is_red = fields.Boolean(string='是否红冲')
- red_date = fields.Date(string='红冲日期')
- charge_status = fields.Selection([('not_paid', '未收'), ('paid', '已收')], string='收费状态')
- is_invoice = fields.Boolean(string='是否开票')
- is_suspend = fields.Boolean(string='是否挂起')
- create_time = fields.Datetime(string='创建时间')
- last_update_time = fields.Datetime(string='最后修改时间')
- """
- self.sudo().env["property.management.list"].create({
- "contract_id": record.id,
- "contract_code": record.code,
- "due_date": segment[0],
- "original_amount": record.total_area * record.management_fee * months,
- })
+ delta = relativedelta(end_date, start_date)
+ months = delta.years * 12 + delta.months
+ self.sudo().env["property.management.list"].create({
+ "contract_id": record.id,
+ "contract_code": record.code,
+ "due_date": start_date,
+ "original_amount": record.total_area * record.management_fee * months,
+ })
+
def action_generate_details(self):
"""
@@ -274,67 +213,62 @@ class PropertyLeaseContract(models.Model):
if not record.term_end_time:
raise UserError(_("请填写租期结束时间!"))
self.sudo().env["property.rent.breakdown.line"].search([("breakdown_id", "=", record.id)]).unlink()
- # 按照月度计算明细
- if record.cycle_dict == "monthly":
- months = 1
- elif record.cycle_dict == "quarter":
- months = 3
- elif record.cycle_dict == "half":
- months = 6
- elif record.cycle_dict == "year":
- months = 12
- else:
- raise UserError(_("请填写付款方式!"))
- # unit_price = fields.Float(string="单价")
- # monthly_amount = fields.Float(string="月租金")
- # start_data = fields.Date(string="开始日期")
- # end_data = fields.Date(string="结束日期")
- # month_number = fields.Integer(string="期间月数")
- # period_rent = fields.Float(string="期间租金")"""
start_date = record.term_start_time
end_date = record.term_end_time
- # 先按照年分组
- divided_year_segments = self.divide_time_range_fixed(start_date, end_date, 12)
- index = 0 # 第几年
- period_rent = 0 # 月租金
- unit_price = 0 # 单价
- for segment_year in divided_year_segments:
+ first_years_begin = record.first_years_begin if record.first_years_begin else 0
+ increments_every_few_years = record.increments_every_few_years
+
+ period_rent = record.total_area * record.unit_price # 月租金
+ unit_price = record.unit_price # 单价
+
+ # 先计算免租期
+ first_index = 0 # 第几递增周期年
+ increments_start = start_date # 递增开始
+ # 第几年不递增
+ if first_years_begin:
+ divided_year_segments = self.divide_time_range_fixed(start_date, end_date, 12)
+ for segment_year in divided_year_segments:
+ first_index += 1
+ if first_years_begin and first_index > first_years_begin:
+ increments_start = segment_year[0]
+ break
+ self.sudo().env["property.rent.breakdown.line"].create({
+ "unit_price": unit_price,
+ "monthly_amount": period_rent,
+ "breakdown_id": record.id,
+ "start_data": start_date,
+ "end_data": increments_start,
+ "month_number": 12 * first_years_begin,
+ "period_rent": period_rent * 12 * first_years_begin,
+ })
+ # 开始递增
+ divided_increments_segments = self.divide_time_range_fixed(increments_start, end_date, increments_every_few_years*12)
+ index = 0 # 第几递增周期年
+ for increments_year in divided_increments_segments:
index += 1
"""
increment_percentage = fields.Float(string="递增百分比")
increment_price = fields.Float(string="递增单价")
increment_amount = fields.Float(string="递增金额")
"""
- if index > 1:
- if record.increment_price:
- unit_price = unit_price + record.increment_price
- if record.increment_percentage:
- period_rent = record.total_area * unit_price * record.increment_percentage
- if record.increment_amount:
- period_rent = period_rent + record.increment_amount
- else:
- period_rent = record.total_area * record.unit_price
- unit_price = record.unit_price
- divided_time_segments = self.divide_time_range_fixed(segment_year[0], segment_year[1], months)
- # if record.cycle_mode == "fixed":
- # # 按照月份、季度、年份进行分组
- # divided_time_segments = self.divide_time_range_fixed(segment_year[0], segment_year[1], months)
- # elif record.cycle_mode == "floating":
- # # 按照月份、季度、年份进行分组
- # divided_time_segments = self.divide_time_range_floating(segment_year[0], segment_year[1], months)
- # else:
- # raise UserError(_("请填写周期方式!"))
- for segment in divided_time_segments:
- self.sudo().env["property.rent.breakdown.line"].create({
- "unit_price": unit_price,
- "monthly_amount": period_rent,
- "breakdown_id": record.id,
- "start_data": segment[0],
- "end_data": segment[1],
- "month_number": months,
- "period_rent": period_rent * months,
- })
+ if record.increment_price:
+ unit_price = unit_price + record.increment_price
+ if record.increment_percentage:
+ period_rent = record.total_area * unit_price * record.increment_percentage
+ unit_price = period_rent / record.total_area
+ if record.increment_amount:
+ period_rent = period_rent + record.increment_amount
+ unit_price = period_rent / record.total_area
+ self.sudo().env["property.rent.breakdown.line"].create({
+ "unit_price": unit_price,
+ "monthly_amount": period_rent,
+ "breakdown_id": record.id,
+ "start_data": increments_year[0],
+ "end_data": increments_year[1],
+ "month_number": 12 * increments_every_few_years,
+ "period_rent": period_rent * 12 * increments_every_few_years,
+ })
class PropertyLeaseContractLine(models.Model):
_name = 'property.lease.contract.line'
diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml
index 5e36446df..2ed458388 100644
--- a/yuthon_property_approval/views/property_lease_contract.xml
+++ b/yuthon_property_approval/views/property_lease_contract.xml
@@ -67,6 +67,10 @@
+
+
+
+
From cda126b8a60f3a04e1e844efb00fe4f327f7ba28 Mon Sep 17 00:00:00 2001
From: ljmwkx <1340053001@qq.com>
Date: Thu, 19 Dec 2024 19:42:34 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=20=E5=AE=A1=E6=89=B9=E6=B5=81=20=E5=AE=8C?=
=?UTF-8?q?=E5=96=84=E5=88=A4=E6=96=AD=E9=9A=90=E8=97=8F=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E6=9D=A1=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../templates/soong_workflow_templates.xml | 2 +-
.../models/property_lease_contract.py | 144 +++++++++++-------
.../views/property_lease_contract.xml | 6 +-
3 files changed, 90 insertions(+), 62 deletions(-)
diff --git a/soong_workflow/templates/soong_workflow_templates.xml b/soong_workflow/templates/soong_workflow_templates.xml
index fcaba63a2..5db88ec77 100644
--- a/soong_workflow/templates/soong_workflow_templates.xml
+++ b/soong_workflow/templates/soong_workflow_templates.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index 9b7d23621..18eaf3edf 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -146,27 +146,36 @@ class PropertyLeaseContract(models.Model):
if first_years_begin and first_index > first_years_begin:
increments_start = segment_year[0]
break
- all_period_rent += period_rent * 12 * first_years_begin
+ delta = relativedelta(increments_start, start_date)
+ months = delta.years * 12 + delta.months
+ all_period_rent += period_rent * months
- # 开始递增
- divided_increments_segments = self.divide_time_range_fixed(increments_start, end_date, increments_every_few_years * 12)
- index = 0 # 第几递增周期年
- for increments_year in divided_increments_segments:
- index += 1
- """
- increment_percentage = fields.Float(string="递增百分比")
- increment_price = fields.Float(string="递增单价")
- increment_amount = fields.Float(string="递增金额")
- """
- if record.increment_price:
- unit_price = unit_price + record.increment_price
- if record.increment_percentage:
- period_rent = record.total_area * unit_price * record.increment_percentage
- unit_price = period_rent / record.total_area
- if record.increment_amount:
- period_rent = period_rent + record.increment_amount
- unit_price = period_rent / record.total_area
- all_period_rent += period_rent * 12 * increments_every_few_years
+ if not increments_every_few_years:
+ delta = relativedelta(end_date, increments_start)
+ months = delta.years * 12 + delta.months
+ all_period_rent += period_rent * months
+ else:
+ # 开始递增
+ divided_increments_segments = self.divide_time_range_fixed(increments_start, end_date, increments_every_few_years * 12)
+ index = 0 # 第几递增周期年
+ for increments_year in divided_increments_segments:
+ index += 1
+ """
+ increment_percentage = fields.Float(string="递增百分比")
+ increment_price = fields.Float(string="递增单价")
+ increment_amount = fields.Float(string="递增金额")
+ """
+ delta = relativedelta(increments_year[1], increments_year[0])
+ months = delta.years * 12 + delta.months
+ if record.increment_price:
+ unit_price = unit_price + record.increment_price
+ if record.increment_percentage:
+ period_rent = record.total_area * unit_price * record.increment_percentage
+ unit_price = period_rent / record.total_area
+ if record.increment_amount:
+ period_rent = period_rent + record.increment_amount
+ unit_price = period_rent / record.total_area
+ all_period_rent += period_rent * months
self.sudo().env["property.rent.list"].create({
"contract_id": record.id,
@@ -226,49 +235,68 @@ class PropertyLeaseContract(models.Model):
first_index = 0 # 第几递增周期年
increments_start = start_date # 递增开始
# 第几年不递增
- if first_years_begin:
- divided_year_segments = self.divide_time_range_fixed(start_date, end_date, 12)
- for segment_year in divided_year_segments:
- first_index += 1
- if first_years_begin and first_index > first_years_begin:
- increments_start = segment_year[0]
- break
+ if not increments_every_few_years:
+ delta = relativedelta(end_date, increments_start)
+ months = delta.years * 12 + delta.months
self.sudo().env["property.rent.breakdown.line"].create({
"unit_price": unit_price,
"monthly_amount": period_rent,
"breakdown_id": record.id,
- "start_data": start_date,
- "end_data": increments_start,
- "month_number": 12 * first_years_begin,
- "period_rent": period_rent * 12 * first_years_begin,
- })
- # 开始递增
- divided_increments_segments = self.divide_time_range_fixed(increments_start, end_date, increments_every_few_years*12)
- index = 0 # 第几递增周期年
- for increments_year in divided_increments_segments:
- index += 1
- """
- increment_percentage = fields.Float(string="递增百分比")
- increment_price = fields.Float(string="递增单价")
- increment_amount = fields.Float(string="递增金额")
- """
- if record.increment_price:
- unit_price = unit_price + record.increment_price
- if record.increment_percentage:
- period_rent = record.total_area * unit_price * record.increment_percentage
- unit_price = period_rent / record.total_area
- if record.increment_amount:
- period_rent = period_rent + record.increment_amount
- unit_price = period_rent / record.total_area
- self.sudo().env["property.rent.breakdown.line"].create({
- "unit_price": unit_price,
- "monthly_amount": period_rent,
- "breakdown_id": record.id,
- "start_data": increments_year[0],
- "end_data": increments_year[1],
- "month_number": 12 * increments_every_few_years,
- "period_rent": period_rent * 12 * increments_every_few_years,
+ "start_data": increments_start,
+ "end_data": end_date,
+ "month_number": months,
+ "period_rent": period_rent * months,
})
+ else:
+ if first_years_begin:
+ divided_year_segments = self.divide_time_range_fixed(start_date, end_date, 12)
+ for segment_year in divided_year_segments:
+ first_index += 1
+ if first_years_begin and first_index > first_years_begin:
+ increments_start = segment_year[0]
+ break
+ delta = relativedelta(increments_start, start_date)
+ months = delta.years * 12 + delta.months
+ self.sudo().env["property.rent.breakdown.line"].create({
+ "unit_price": unit_price,
+ "monthly_amount": period_rent,
+ "breakdown_id": record.id,
+ "start_data": start_date,
+ "end_data": increments_start,
+ "month_number": months,
+ "period_rent": period_rent * months,
+ })
+
+ # 开始递增
+ divided_increments_segments = self.divide_time_range_fixed(increments_start, end_date, increments_every_few_years*12)
+ index = 0 # 第几递增周期年
+ for increments_year in divided_increments_segments:
+ index += 1
+ """
+ increment_percentage = fields.Float(string="递增百分比")
+ increment_price = fields.Float(string="递增单价")
+ increment_amount = fields.Float(string="递增金额")
+ """
+ if record.increment_price:
+ unit_price = unit_price + record.increment_price
+ if record.increment_percentage:
+ period_rent = record.total_area * unit_price * record.increment_percentage
+ unit_price = period_rent / record.total_area
+ if record.increment_amount:
+ period_rent = period_rent + record.increment_amount
+ unit_price = period_rent / record.total_area
+
+ delta = relativedelta(increments_year[1], increments_year[0])
+ months = delta.years * 12 + delta.months
+ self.sudo().env["property.rent.breakdown.line"].create({
+ "unit_price": unit_price,
+ "monthly_amount": period_rent,
+ "breakdown_id": record.id,
+ "start_data": increments_year[0],
+ "end_data": increments_year[1],
+ "month_number": months,
+ "period_rent": period_rent * months,
+ })
class PropertyLeaseContractLine(models.Model):
_name = 'property.lease.contract.line'
diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml
index 2ed458388..a1dfa9031 100644
--- a/yuthon_property_approval/views/property_lease_contract.xml
+++ b/yuthon_property_approval/views/property_lease_contract.xml
@@ -17,8 +17,8 @@
-
+
From 8691075b2bf39b15e693980fc340bafe42af9bba Mon Sep 17 00:00:00 2001
From: ljmwkx <1340053001@qq.com>
Date: Thu, 19 Dec 2024 19:45:13 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=20=E5=AE=A1=E6=89=B9=E6=B5=81=20=E5=AE=8C?=
=?UTF-8?q?=E5=96=84=E5=88=A4=E6=96=AD=E9=9A=90=E8=97=8F=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E6=9D=A1=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
soong_workflow/templates/soong_workflow_templates.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/soong_workflow/templates/soong_workflow_templates.xml b/soong_workflow/templates/soong_workflow_templates.xml
index 5db88ec77..fcaba63a2 100644
--- a/soong_workflow/templates/soong_workflow_templates.xml
+++ b/soong_workflow/templates/soong_workflow_templates.xml
@@ -3,7 +3,7 @@
-
+