添加功能
This commit is contained in:
@@ -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 "",
|
||||
|
||||
Reference in New Issue
Block a user