fix - stakeholders agc share amount and brokers
This commit is contained in:
@@ -22,51 +22,61 @@ def pos_organizations_sharing_information(
|
|||||||
|
|
||||||
sharing_information_list = []
|
sharing_information_list = []
|
||||||
for item in stake_holders:
|
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
|
if item.broker and not owner_org.type.key == 'AGC': # if stakeholder is not an agency, it is a broker
|
||||||
sharing_information_list.append({
|
sharing_information_list.append({
|
||||||
"organization_name": item.organization.name,
|
"organization_name": item.organization.name,
|
||||||
"bank_account": {
|
"bank_account": {
|
||||||
"credit_card": item.organization.bank_information.first().card,
|
"credit_card": item.organization.bank_information.first().card,
|
||||||
"sheba": item.organization.bank_information.first().sheba,
|
"sheba": item.organization.bank_information.first().sheba,
|
||||||
"account": item.organization.bank_information.first().account,
|
"account": item.organization.bank_information.first().account,
|
||||||
} if item.organization.bank_information.exists() else {},
|
} if item.organization.bank_information.exists() else {},
|
||||||
"broker": item.broker.name if item.broker else None,
|
"broker": item.broker.name if item.broker else None,
|
||||||
"amount": quota.broker_values.filter(
|
"amount": quota.broker_values.filter(
|
||||||
broker=item.broker
|
broker=item.broker
|
||||||
).first().value if quota and item.broker else None,
|
).first().value if quota and item.broker else None,
|
||||||
|
|
||||||
# """
|
# """
|
||||||
# if we will need to get agencies share amount, we can use this bellow code
|
# 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
|
# # item.holders_share_amount.filter(quota_distribution=distribution).first().share_amount
|
||||||
# # if item.holders_share_amount.filter(quota_distribution=distribution).exists() else None
|
# # if item.holders_share_amount.filter(quota_distribution=distribution).exists() else None
|
||||||
# """
|
# """
|
||||||
"agency": False,
|
"agency": False,
|
||||||
"default_account": item.default
|
"default_account": item.default
|
||||||
})
|
})
|
||||||
# else:
|
elif owner_org.type.key == 'AGC':
|
||||||
# sharing_information_list.append({
|
agc_stake_holder = owner_org.pos_stake_holders.filter(
|
||||||
# "organization_name": "تعاونی دامداران فامنین",
|
holders_share_amount__quota_distribution=distribution
|
||||||
# "bank_account": {
|
).first()
|
||||||
# "credit_card": "2222222222222222",
|
stake_holders = agc_stake_holder.device.stake_holders.select_related(
|
||||||
# "sheba": "666666666666666666",
|
'broker', 'organization'
|
||||||
# "account": "4444444444444444444444",
|
).filter()
|
||||||
# },
|
for item in stake_holders:
|
||||||
# "broker": "تعاونی",
|
if item.broker: # if stakeholder is not an agency, it is a broker
|
||||||
# "amount": 1600,
|
sharing_information_list.append({
|
||||||
#
|
"organization_name": item.organization.name,
|
||||||
# # """
|
"bank_account": {
|
||||||
# # if we will need to get agencies share amount, we can use this bellow code
|
"credit_card": item.organization.bank_information.first().card,
|
||||||
# #
|
"sheba": item.organization.bank_information.first().sheba,
|
||||||
# # # item.holders_share_amount.filter(quota_distribution=distribution).first().share_amount
|
"account": item.organization.bank_information.first().account,
|
||||||
# # # if item.holders_share_amount.filter(quota_distribution=distribution).exists() else None
|
} if item.organization.bank_information.exists() else {},
|
||||||
# # """
|
"broker": item.broker.name if item.broker else None,
|
||||||
# "agency": False,
|
"amount": quota.broker_values.filter(
|
||||||
# "default_account": True
|
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
|
||||||
|
})
|
||||||
|
|
||||||
# if device owner is an agency organization
|
|
||||||
print(sharing_information_list)
|
print(sharing_information_list)
|
||||||
|
# if device owner is an agency organization
|
||||||
if owner_org.type.key == 'AGC':
|
if owner_org.type.key == 'AGC':
|
||||||
sharing_information_list = agency_organization_pos_info(
|
sharing_information_list = agency_organization_pos_info(
|
||||||
agency=owner_org,
|
agency=owner_org,
|
||||||
@@ -90,14 +100,15 @@ def agency_organization_pos_info(
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# get agency share amount
|
# get agency share amount
|
||||||
agc_share_amount = (agency.pos_stake_holders.filter(
|
agc_share_amount = agency.pos_stake_holders.filter(
|
||||||
device=device,
|
holders_share_amount__quota_distribution=distribution
|
||||||
))
|
)
|
||||||
# .holders_share_amount.filter(
|
|
||||||
# quota_distribution=distribution
|
agc_share_amount = agc_share_amount.first().holders_share_amount.filter(
|
||||||
# ))
|
quota_distribution=distribution
|
||||||
print(agc_share_amount, device)
|
) if agc_share_amount.exists() else None
|
||||||
agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount else None
|
|
||||||
|
agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount.exists() else None
|
||||||
|
|
||||||
# calculate agency parent share amount
|
# calculate agency parent share amount
|
||||||
agc_parent_amount = next((item for item in pos_sharing_list if item.get('default_account')), None)
|
agc_parent_amount = next((item for item in pos_sharing_list if item.get('default_account')), None)
|
||||||
|
|||||||
Reference in New Issue
Block a user