update test
This commit is contained in:
@@ -19,7 +19,7 @@ def pos_organizations_sharing_information(
|
|||||||
pos sharing organizations' information,
|
pos sharing organizations' information,
|
||||||
device have multiple organizations (sub_accounts) for sharing money
|
device have multiple organizations (sub_accounts) for sharing money
|
||||||
"""
|
"""
|
||||||
stake_holders = device.stake_holders.select_related('broker', 'organization').filter(default=False)
|
stake_holders = device.stake_holders.select_related('broker', 'organization').filter()
|
||||||
|
|
||||||
sharing_information_list = []
|
sharing_information_list = []
|
||||||
for item in stake_holders:
|
for item in stake_holders:
|
||||||
@@ -42,7 +42,7 @@ def pos_organizations_sharing_information(
|
|||||||
# # 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,
|
||||||
"default_account": item.default
|
"default_account": item.default
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -54,18 +54,14 @@ def pos_organizations_sharing_information(
|
|||||||
quota_distribution=distribution
|
quota_distribution=distribution
|
||||||
)
|
)
|
||||||
sharing_information_list.append({
|
sharing_information_list.append({
|
||||||
"organization_name": owner_org.parent_organization.name,
|
"organization_name": owner_org.name,
|
||||||
"bank_account": {
|
"bank_account": {
|
||||||
"credit_card": owner_org.parent_organization.bank_information.first().card,
|
"credit_card": owner_org.bank_information.first().card,
|
||||||
"sheba": owner_org.parent_organization.bank_information.first().sheba,
|
"sheba": owner_org.bank_information.first().sheba,
|
||||||
"account": owner_org.parent_organization.bank_information.first().account,
|
"account": owner_org.bank_information.first().account,
|
||||||
} if owner_org.parent_organization.bank_information.exists() else {},
|
} if owner_org.bank_information.exists() else {},
|
||||||
# "amount": quota.pricing_items.get(name='base_price').value if quota.pricing_items.filter(
|
"amount": agc_share_amount.first().share_amount if agc_share_amount else None,
|
||||||
# name='base_price'
|
"agency": True,
|
||||||
# ) else None,
|
|
||||||
# "agency_amount": agc_share_amount.first().share_amount if agc_share_amount else None,
|
|
||||||
"amount": 5000,
|
|
||||||
"agency_amount": 2000,
|
|
||||||
"default_account": True
|
"default_account": True
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ from rest_framework.response import Response
|
|||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from common.tools import CustomOperations
|
from common.tools import CustomOperations
|
||||||
from common.helpers import generate_code
|
from common.helpers import generate_code
|
||||||
|
from apps.product.models import Broker
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
@@ -228,17 +229,19 @@ class DeviceAssignmentViewSet(SoftDeleteMixin, viewsets.ModelViewSet):
|
|||||||
assignment.device.save()
|
assignment.device.save()
|
||||||
|
|
||||||
# set organization having pos status
|
# set organization having pos status
|
||||||
if assignment.client.organization:
|
client_org = assignment.client.organization
|
||||||
assignment.client.organization.has_pos = True
|
if client_org:
|
||||||
assignment.client.organization.save()
|
client_org.has_pos = True
|
||||||
|
client_org.save()
|
||||||
|
|
||||||
# after pos device assignment, must set owner
|
# after pos device assignment, must set owner
|
||||||
# as default stake holder
|
# as default stake holder
|
||||||
pos_models.StakeHolders.objects.create(
|
pos_models.StakeHolders.objects.create(
|
||||||
assignment=assignment,
|
assignment=assignment,
|
||||||
device=assignment.device,
|
device=assignment.device,
|
||||||
organization=assignment.client.organization,
|
organization=client_org,
|
||||||
default=True
|
default=True,
|
||||||
|
broker=Broker.objects.get(organization_type=client_org.type)
|
||||||
)
|
)
|
||||||
|
|
||||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||||
|
|||||||
Reference in New Issue
Block a user