fix - agency distribution show detail on pos device - v1

This commit is contained in:
2025-12-16 16:44:11 +03:30
parent d6a30705b5
commit 1ef808dc82

View File

@@ -80,13 +80,15 @@ def pos_organizations_sharing_information(
# if device owner is an agency organization
if owner_org.type.key == 'AGC':
sharing_information_list = agency_organization_pos_info(
sharing_information_list_agency = agency_organization_pos_info(
agency=owner_org,
pos_sharing_list=sharing_information_list,
device=device,
distribution=distribution,
quota_stat=quota_stat
)
if sharing_information_list_agency:
return sharing_information_list_agency
return sharing_information_list
@@ -112,26 +114,28 @@ def agency_organization_pos_info(
org_quota_stat=quota_stat
) if agc_share_amount.exists() else None
agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount.exists() else None
agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount else None
# calculate agency parent share amount
agc_parent_amount = next((item for item in pos_sharing_list if item.get('default_account')), None)
if agc_parent_amount and agc_share_amount:
agc_parent_amount['amount'] = agc_parent_amount['amount'] - agc_share_amount
if agc_share_amount:
# calculate agency parent share amount
agc_parent_amount = next((item for item in pos_sharing_list if item.get('default_account')), None)
if agc_parent_amount and agc_share_amount:
agc_parent_amount['amount'] = agc_parent_amount['amount'] - agc_share_amount
pos_sharing_list.append({
"organization_name": agency.name,
"bank_account": {
"credit_card": agency.bank_information.first().card,
"sheba": "IR" + agency.bank_information.first().sheba,
"account": agency.bank_information.first().account,
} if agency.bank_information.exists() else {},
"amount": agc_share_amount,
"agency": True,
"default_account": True
})
pos_sharing_list.append({
"organization_name": agency.name,
"bank_account": {
"credit_card": agency.bank_information.first().card,
"sheba": "IR" + agency.bank_information.first().sheba,
"account": agency.bank_information.first().account,
} if agency.bank_information.exists() else {},
"amount": agc_share_amount,
"agency": True,
"default_account": True
})
return pos_sharing_list
return pos_sharing_list
return None
return None