Merge pull request !10195 from 李鹏宇/dev
This commit is contained in:
@@ -191,24 +191,27 @@ class ReceivableFlowReport(models.Model):
|
||||
for ppl in pay_lines:
|
||||
_logger.info(f" - penalty.pay.line ID: {ppl.id}, management_type_id: {ppl.management_type_id}, management_type_id.id: {ppl.management_type_id.id if ppl.management_type_id else None}, amount: {ppl.amount}, date: {ppl.date}")
|
||||
|
||||
# 违约金收款金额:使用你提到的方法计算
|
||||
if penalty_type:
|
||||
collected = sum(pay_line.amount for pay_line in pay_lines
|
||||
if pay_line.management_type_id == penalty_type)
|
||||
else:
|
||||
collected = 0.0
|
||||
# 违约金收款:兼容不同公司/多条“违约金”管理类型,按名称兜底过滤
|
||||
penalty_pay_lines = [
|
||||
l for l in pay_lines
|
||||
if (
|
||||
(penalty_type and l.management_type_id == penalty_type)
|
||||
or (l.management_type_id and l.management_type_id.name == '违约金')
|
||||
)
|
||||
]
|
||||
collected = sum(l.amount for l in penalty_pay_lines)
|
||||
total_penalty_collected = round(collected, 2)
|
||||
|
||||
# 违约金收款时间:类型为“违约金”的最新收款日期
|
||||
|
||||
# 违约金收款时间:取最新收款日期
|
||||
penalty_payment_date = None
|
||||
if penalty_type:
|
||||
penalty_pay_collected = [
|
||||
l for l in pay_lines
|
||||
if l.management_type_id == penalty_type and l.date
|
||||
]
|
||||
latest_penalty_pay = sorted(penalty_pay_collected, key=lambda l: l.date, reverse=True)
|
||||
if penalty_pay_lines:
|
||||
latest_penalty_pay = sorted(
|
||||
[l for l in penalty_pay_lines if l.date],
|
||||
key=lambda l: l.date,
|
||||
reverse=True,
|
||||
)
|
||||
penalty_payment_date = latest_penalty_pay[0].date if latest_penalty_pay else None
|
||||
|
||||
|
||||
_logger.info(f"total_penalty_collected: {total_penalty_collected}, penalty_payment_date: {penalty_payment_date}")
|
||||
|
||||
# 复用 _onchange_calculation_date 逻辑计算违约金时间区间、逆期天数、违约金
|
||||
|
||||
Reference in New Issue
Block a user