添加功能
This commit is contained in:
@@ -92,14 +92,8 @@ class PropertyReconciliationWizard(models.Model):
|
||||
# 计算违约天数和违约金
|
||||
late_days = (fields.Date.from_string(self.actual_date) - next_month_first).days + 1
|
||||
# 找到符合月份的租金
|
||||
matching_breakdown = next((
|
||||
breakdown for breakdown in contract_id.breakdown_ids
|
||||
if breakdown.start_data <= self.actual_date <= breakdown.end_data
|
||||
),
|
||||
None
|
||||
)
|
||||
penalty_amount = late_days * round(
|
||||
matching_breakdown.monthly_amount * float(contract_id.percentage_liquidated_damages.name), 2
|
||||
contract_receivables.submitted * float(contract_id.percentage_liquidated_damages.name), 2
|
||||
)
|
||||
start_date_str = fields.Date.to_string(next_month_first)
|
||||
end_date_str = self.actual_date
|
||||
@@ -133,22 +127,23 @@ class PropertyReconciliationWizard(models.Model):
|
||||
('payout_date', '!=', None),
|
||||
])
|
||||
if unpaid_rent_recs:
|
||||
first_day = (unpaid_rent_recs.payout_date + timedelta(days=1))
|
||||
last_month_rent = unpaid_rent_recs.submitted
|
||||
penalty_days = self.actual_date - first_day
|
||||
penalty_amount = (penalty_days.days + 1) * round(
|
||||
last_month_rent * float(contract_id.percentage_liquidated_damages.name), 2
|
||||
) if contract_id else 0.0
|
||||
if penalty_amount > 0:
|
||||
new_lines.append((0, 0, {
|
||||
'contract_id': contract_id.id if contract_id else None,
|
||||
'rent_month': 0,
|
||||
'due_date': fields.Date.to_string(first_day),
|
||||
'rent': penalty_amount,
|
||||
'amount': 0,
|
||||
'collection_type': 'penalty',
|
||||
'remake': f'违约金({fields.Date.to_string(first_day)}至{fields.Date.to_string(self.actual_date)},共{penalty_days.days + 1}天)',
|
||||
}))
|
||||
if (unpaid_rent_recs.payout_date + relativedelta(months=1)).month != self.actual_date.month:
|
||||
first_day = (unpaid_rent_recs.payout_date + timedelta(days=1))
|
||||
last_month_rent = unpaid_rent_recs.submitted
|
||||
penalty_days = self.actual_date - first_day
|
||||
penalty_amount = (penalty_days.days + 1) * round(
|
||||
last_month_rent * float(contract_id.percentage_liquidated_damages.name), 2
|
||||
) if contract_id else 0.0
|
||||
if penalty_amount > 0:
|
||||
new_lines.append((0, 0, {
|
||||
'contract_id': contract_id.id if contract_id else None,
|
||||
'rent_month': 0,
|
||||
'due_date': fields.Date.to_string(first_day),
|
||||
'rent': penalty_amount,
|
||||
'amount': 0,
|
||||
'collection_type': 'penalty',
|
||||
'remake': f'违约金({fields.Date.to_string(first_day)}至{fields.Date.to_string(self.actual_date)},共{penalty_days.days + 1}天)',
|
||||
}))
|
||||
|
||||
# 3. 添加到总列表
|
||||
for vals in contract_penalties:
|
||||
@@ -386,6 +381,11 @@ class PropertyReconciliationWizard(models.Model):
|
||||
'reconciliation_time': fields.Datetime.now(),
|
||||
'receivable_log': f'当前登录人{rec.env.user.name}于{fields.Datetime.now()}对户名为{rec.bank_id.name_account}进行对账操作,对账应收金额为{rec.receivable_total},实际金额为{rec.actual_total}'
|
||||
})
|
||||
self.env['receivable.modify.line'].create({
|
||||
'bank_id': rec.bank_id.id,
|
||||
'receivable_id': receivable.id,
|
||||
'amount': line.amount,
|
||||
})
|
||||
management_type_id = self.env['yuthon.management.type'].search([('name', '=', '违约金')])
|
||||
if line.collection_type == 'penalty':
|
||||
# 用备注的的开始日期和结束日期
|
||||
@@ -424,7 +424,11 @@ class PropertyReconciliationWizard(models.Model):
|
||||
'remark': line.remake,
|
||||
'reconciliation_time': fields.Datetime.now(),
|
||||
})
|
||||
|
||||
self.env['receivable.modify.line'].create({
|
||||
'bank_id': rec.bank_id.id,
|
||||
'receivable_id': receivable_id.id,
|
||||
'amount': 0,
|
||||
})
|
||||
else:
|
||||
existing_record.write({
|
||||
'delivered1': existing_record.delivered1 + line.amount,
|
||||
@@ -436,6 +440,11 @@ class PropertyReconciliationWizard(models.Model):
|
||||
'is_write': True if line.amount != 0 else None,
|
||||
'reconciliation_time': fields.Datetime.now(),
|
||||
})
|
||||
self.env['receivable.modify.line'].create({
|
||||
'bank_id': rec.bank_id.id,
|
||||
'receivable_id': existing_record.id,
|
||||
'amount': existing_record.delivered1 + line.amount,
|
||||
})
|
||||
|
||||
# 计算已对账和未对账金额
|
||||
rec.amount_been_reconciled += line.amount
|
||||
|
||||
Reference in New Issue
Block a user