From 1ef808dc8228eb1b47022eff15231aedafe8f6b0 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Tue, 16 Dec 2025 16:44:11 +0330 Subject: [PATCH] fix - agency distribution show detail on pos device - v1 --- apps/pos_device/services/services.py | 40 +++++++++++++++------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/apps/pos_device/services/services.py b/apps/pos_device/services/services.py index 09e014a..e2fae84 100644 --- a/apps/pos_device/services/services.py +++ b/apps/pos_device/services/services.py @@ -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