|
|
|
@@ -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)}'
|