This commit is contained in:
李鹏宇
2026-03-20 20:12:00 +08:00
parent 41c69299a5
commit a3ec4e39f4
@@ -67,26 +67,23 @@ class DepositMonthReceivedReport(models.Model):
rows = []
total_amount = 0.0
idx = 1
processed_receivable_ids = set()
for line in modify_lines:
if not line.receivable_id:
continue
receivable_id = line.receivable_id.id
if receivable_id in processed_receivable_ids:
continue
processed_receivable_ids.add(receivable_id)
rec = line.receivable_id
wizards = self.env['penalty.line.wizard'].search(
[('receivable_id', '=', receivable_id)]
)
for wizard in wizards:
for pay in wizard.pay_line_ids:
if not pay.date:
continue
if period_start <= pay.date <= period_end:
amount = round(pay.amount, 2)
if not wizards:
# 如果没有关联的wizard,尝试直接从line获取信息
if line.delivered1 and (line.receivable_id.payout_date or line.create_date):
# 使用payout_date作为收款日期,如果没有则使用create_date
payment_date = line.receivable_id.payout_date or line.create_date.date()
if period_start <= payment_date <= period_end:
amount = round(line.delivered1, 2)
total_amount += amount
rows.append({
"序号": idx,
@@ -105,7 +102,7 @@ class DepositMonthReceivedReport(models.Model):
'id': rec.lessee_id.id,
'display_name': rec.lessee_id.name,
} if rec.lessee_id else "",
"收款日期": pay.date.strftime("%Y-%m-%d"),
"收款日期": payment_date.strftime("%Y-%m-%d"),
"金额": amount,
"所属公司": rec.company_id.name if rec.company_id else "",
"管理员": {
@@ -115,6 +112,41 @@ class DepositMonthReceivedReport(models.Model):
} if rec.admin_id else "",
})
idx += 1
else:
for wizard in wizards:
for pay in wizard.pay_line_ids:
if not pay.date:
continue
if period_start <= pay.date <= period_end:
amount = round(pay.amount, 2)
total_amount += amount
rows.append({
"序号": idx,
"合同编号": {
'model': 'property.lease.contract',
'id': rec.contract_id.id,
'display_name': rec.contract_id.contract_code,
} if rec.contract_id else "",
"物业名称": {
'model': 'yuthon.property',
'id': rec.contract_id.lease_ids[0].address_id.id,
'display_name': rec.property_name,
} if rec.contract_id and rec.contract_id.lease_ids and rec.contract_id.lease_ids[0].address_id else rec.property_name or "",
"承租方名称": {
'model': 'property.tenant.information',
'id': rec.lessee_id.id,
'display_name': rec.lessee_id.name,
} if rec.lessee_id else "",
"收款日期": pay.date.strftime("%Y-%m-%d"),
"金额": amount,
"所属公司": rec.company_id.name if rec.company_id else "",
"管理员": {
'model': 'res.users',
'id': rec.admin_id.id,
'display_name': rec.admin_id.name,
} if rec.admin_id else "",
})
idx += 1
stats = [
{'name': '记录总数', 'amount': len(rows)},