From 27fdad326d7c488f1e1110becb0dd53de02c70e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Wed, 5 Nov 2025 14:38:51 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/inherit_yuthon_property.py | 1 +
.../wizard/property_reconciliation_wizard.py | 31 ++++++++++++-------
.../property_reconciliation_wizard_views.xml | 1 +
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 0031e9cdd..a7b500e3e 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -517,6 +517,7 @@ class PropertyBankStatements(models.Model):
"default_bank_id": self.id,
"default_bank_branch": self.bank_branch,
"default_account": record.name,
+ "default_contract_ids": [(6, 0, self.contract_ids.ids)],
"default_actual_total": record.original_amount,
"default_reconciliation_line_ids": all_vals, # 租金,应收日期排序、管理费、电、水、押金
'default_amount_reconciled': self.no_amount,
diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
index 885f1ad61..781c434d1 100644
--- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py
+++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
@@ -18,6 +18,7 @@ class PropertyReconciliationWizard(models.Model):
lessee_ids = fields.Many2many('property.tenant.information', string='承租方')
name_account = fields.Char( string='对方户名')
account = fields.Char(string='账号')
+ contract_ids = fields.Many2many('property.lease.contract', string='合同')
amount_been_reconciled = fields.Float(string='已对金额', store=True)
amount_water_been = fields.Float(string='已对流水金额', store=True)
amount_water = fields.Float(string='未对流水金额', store=True)
@@ -68,16 +69,27 @@ class PropertyReconciliationWizard(models.Model):
)
wizard.penalty = penalty_total
+ @api.onchange('contract_ids')
+ def onchange_contract_ids(self):
+ for rec in self:
+ current_contract_ids = rec.contract_ids.ids
+ to_delete = []
+ for line in rec.reconciliation_line_ids:
+ line_contract_id = line.contract_id.id
+ if line_contract_id not in current_contract_ids:
+ to_delete.append((2, line.id, 0))
+ rec.reconciliation_line_ids = to_delete
+
@api.onchange('actual_total')
- def _onchange_reconciliation_line_ids(self):
+ def compute_reconciliation_line_ids(self):
new_lines = []
# 违约金生成
- for contract_id in self.bank_id.contract_ids:
+ for contract_id in self.contract_ids:
contract_penalties = []
if not contract_id.lease_ids:
continue
receivable_penalties = self.env['property.accounts.receivable'].search([
- ('contract_id', '=', contract_id.id),
+ ('contract_id', '=', contract_id.id.origin),
('is_reconciliation', '=', False),
('is_invalid', '=', False),
('management_type_id.name', '=', '违约金')
@@ -96,7 +108,7 @@ class PropertyReconciliationWizard(models.Model):
first_day_of_last_month = (start_time.replace(day=1) - relativedelta(months=1))
last_day_of_last_month = start_time.replace(day=1) - relativedelta(days=1)
contract_receivables = self.env['property.accounts.receivable'].search([
- ('contract_id', '=', contract_id.id),
+ ('contract_id', '=', contract_id.id.origin),
('is_reconciliation', '=', False),
('is_invalid', '=', False),
('due_date', '>=', first_day_of_last_month.strftime('%Y-%m-%d')),
@@ -125,12 +137,12 @@ class PropertyReconciliationWizard(models.Model):
# 提取合同违约金记录的年月并比较
(fields.Date.from_string(p['due_date']).year,
fields.Date.from_string(p['due_date']).month) == actual_year_month
- and p['contract_id'] == contract_id.id
+ and p['contract_id'] == contract_id.id
for p in contract_penalties
)
if not exists:
contract_penalties.append({
- 'contract_id': contract_id.id,
+ 'contract_id': contract_id.id,
'rent_month': 0,
'due_date': self.actual_date,
'rent': penalty_amount,
@@ -142,7 +154,7 @@ class PropertyReconciliationWizard(models.Model):
# 查找应收是否有未交全的租金
unpaid_rent_recs = self.env['property.accounts.receivable'].search([
('management_type_id.name', '=', '租金'),
- ('contract_id', '=', contract_id.id),
+ ('contract_id', '=', contract_id.id.origin),
('is_invalid', '=', False),
('submitted', '!=', 0),
('payout_date', '!=', None),
@@ -587,7 +599,4 @@ class PropertyReconciliationLine(models.Model):
line.remake = f'交{due_date_str},欠{round(line.rent - line.amount, 2)}'
elif (due_month < actual_month and due_year == actual_year) or (due_year < actual_year):
if line.rent >= line.amount:
- line.remake = f'{actual_date_str}补{due_date_str},欠{round(line.rent - line.amount, 2)}'
-
-
-
+ line.remake = f'{actual_date_str}补{due_date_str},欠{round(line.rent - line.amount, 2)}'
\ No newline at end of file
diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml
index 995458d0c..38a4a6afe 100644
--- a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml
+++ b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml
@@ -39,6 +39,7 @@
+