From 00aac80d5af7f458499dc6b593204271afabd46d 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, 10 Dec 2025 18:44:11 +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 --- yuthon_report/models/ledger_report.py | 35 +++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/yuthon_report/models/ledger_report.py b/yuthon_report/models/ledger_report.py index 55886b9e9..62ca04882 100644 --- a/yuthon_report/models/ledger_report.py +++ b/yuthon_report/models/ledger_report.py @@ -34,6 +34,7 @@ class YuthonProperty(models.Model): properties = self.search(domain, limit=100) result = [] + if partner_id: admin_properties = self.env['yuthon.property'].search([ ('precinct_id', '=', partner_id), @@ -43,20 +44,41 @@ class YuthonProperty(models.Model): prop.rent_area for prop in admin_properties if prop.property_state == 'on_rent' and prop.rent_area ) - # 统计管理员下所有空置面积 total_vacant_area = sum( prop.rent_area for prop in admin_properties if prop.property_state == 'vacant' and prop.rent_area ) - if total_rentable_area > 0: rental_rate = round(((total_rentable_area - total_vacant_area) / total_rentable_area) * 100, 2) - else: - rental_rate = 0.0 + admin_contracts = self.env['property.lease.contract'].search([ + ('precinct_id', '=', partner_id), + ('contact_state', '=', 'ing') + ]) + + if admin_contracts: + receivable_domain = [ + ('contract_id', 'in', admin_contracts.ids), + ] + if params.get("date_end"): + date_end = datetime.datetime.fromisoformat(params.get("date_end")).date() + receivable_domain.append(('due_date', '<=', date_end)) + receivable_records = self.env['property.accounts.receivable'].search(receivable_domain) + if receivable_records: + total_delivered = sum(rec.delivered1 for rec in receivable_records) # 已交金额 + total_amount = sum(rec.original_amount for rec in receivable_records) # 当期金额 + if total_amount > 0: + collection_rate = round((total_delivered / total_amount) * 100, 2) + else: + collection_rate = 0.0 + else: + collection_rate = 0.0 + else: + collection_rate = 0.0 else: rental_rate = 0.0 + collection_rate = 0.0 for p in properties: if params.get("date_end"): @@ -67,7 +89,6 @@ class YuthonProperty(models.Model): ) else: valid_info = p.manage_information_ids[-1] - management_area = valid_info.management_area if valid_info else 0 rent_area = valid_info.rent_area if valid_info else 0 lease_id = self.env['property.lease.contract.line'].search([ @@ -92,8 +113,8 @@ class YuthonProperty(models.Model): "管理面积": management_area or 0.0, "可租面积": rent_area or 0.0, "已租面积": leased_area or 0.0, - "出租率": rental_rate or "", - "收费率": p.precinct_id.name if (p.precinct_id) else "", + "出租率": rental_rate , + "收费率": collection_rate, "所属公司": contract_id.lessor_id.referred if contract_id else "", "租赁状态": "在租" if p.property_state == 'on_rent' else "空置" if p.property_state == 'vacant' else "", "合同编号": contract_id.contract_code if contract_id else "",