remove bank account when remove org

This commit is contained in:
2025-11-05 12:33:53 +03:30
parent 82e004166b
commit 1942042a2b
3 changed files with 61 additions and 48 deletions

View File

@@ -22,48 +22,48 @@ def pos_organizations_sharing_information(
sharing_information_list = []
for item in stake_holders:
if item.broker and not owner_org.type.name == 'AGC': # if stakeholder is not an agency, it is a broker
sharing_information_list.append({
"organization_name": item.organization.name,
"bank_account": {
"credit_card": item.organization.bank_information.first().card,
"sheba": item.organization.bank_information.first().sheba,
"account": item.organization.bank_information.first().account,
} if item.organization.bank_information.exists() else {},
"broker": item.broker.name if item.broker else None,
"amount": quota.broker_values.filter(
broker=item.broker
).first().value if quota and item.broker else None,
# if item.broker and not owner_org.type.name == 'AGC': # if stakeholder is not an agency, it is a broker
sharing_information_list.append({
"organization_name": item.organization.name,
"bank_account": {
"credit_card": item.organization.bank_information.first().card,
"sheba": item.organization.bank_information.first().sheba,
"account": item.organization.bank_information.first().account,
} if item.organization.bank_information.exists() else {},
"broker": item.broker.name if item.broker else None,
"amount": quota.broker_values.filter(
broker=item.broker
).first().value if quota and item.broker else None,
# """
# if we will need to get agencies share amount, we can use this bellow code
#
# # item.holders_share_amount.filter(quota_distribution=distribution).first().share_amount
# # if item.holders_share_amount.filter(quota_distribution=distribution).exists() else None
# """
"agency": False,
"default_account": item.default
})
else:
sharing_information_list.append({
"organization_name": "تعاونی دامداران فامنین",
"bank_account": {
"credit_card": "2222222222222222",
"sheba": "666666666666666666",
"account": "4444444444444444444444",
},
"broker": "تعاونی",
"amount": 1600,
# """
# if we will need to get agencies share amount, we can use this bellow code
#
# # item.holders_share_amount.filter(quota_distribution=distribution).first().share_amount
# # if item.holders_share_amount.filter(quota_distribution=distribution).exists() else None
# """
"agency": False,
"default_account": True
})
# """
# if we will need to get agencies share amount, we can use this bellow code
#
# # item.holders_share_amount.filter(quota_distribution=distribution).first().share_amount
# # if item.holders_share_amount.filter(quota_distribution=distribution).exists() else None
# """
"agency": False,
"default_account": item.default
})
# else:
# sharing_information_list.append({
# "organization_name": "تعاونی دامداران فامنین",
# "bank_account": {
# "credit_card": "2222222222222222",
# "sheba": "666666666666666666",
# "account": "4444444444444444444444",
# },
# "broker": "تعاونی",
# "amount": 1600,
#
# # """
# # if we will need to get agencies share amount, we can use this bellow code
# #
# # # item.holders_share_amount.filter(quota_distribution=distribution).first().share_amount
# # # if item.holders_share_amount.filter(quota_distribution=distribution).exists() else None
# # """
# "agency": False,
# "default_account": True
# })
# if device owner is an agency organization
print(sharing_information_list)
@@ -90,12 +90,13 @@ def agency_organization_pos_info(
"""
# get agency share amount
agc_share_amount = agency.pos_stake_holders.filter(
agc_share_amount = (agency.pos_stake_holders.filter(
device=device,
).first().holders_share_amount.filter(
quota_distribution=distribution
)
))
# .holders_share_amount.filter(
# quota_distribution=distribution
# ))
print(agc_share_amount, device)
agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount else None
# calculate agency parent share amount