Merge branch 'main' of https://github.com/MNPC-IR/Rasaddam_Backend into development
This commit is contained in:
@@ -44,9 +44,30 @@ def pos_organizations_sharing_information(
|
||||
"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
|
||||
if owner_org.type.name == 'AGC':
|
||||
print(sharing_information_list)
|
||||
if owner_org.type.key == 'AGC':
|
||||
sharing_information_list = agency_organization_pos_info(
|
||||
agency=owner_org,
|
||||
pos_sharing_list=sharing_information_list,
|
||||
@@ -74,6 +95,7 @@ def agency_organization_pos_info(
|
||||
).first().holders_share_amount.filter(
|
||||
quota_distribution=distribution
|
||||
)
|
||||
|
||||
agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount else None
|
||||
|
||||
# calculate agency parent share amount
|
||||
@@ -94,6 +116,7 @@ def agency_organization_pos_info(
|
||||
})
|
||||
|
||||
return pos_sharing_list
|
||||
return None
|
||||
|
||||
|
||||
def get_organization_by_stake_holder(id: int = None, stake_holder: StakeHolders = None) -> typing.Any:
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
from apps.product.pos.api.v1.serializers import quota_distribution_serializers as distribution_serializers
|
||||
from apps.pos_device.mixins.pos_device_mixin import POSDeviceMixin
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.core.pagination import CustomPageNumberPagination
|
||||
from apps.warehouse.services.services import can_buy_from_inventory
|
||||
from common.helpers import get_organization_by_user
|
||||
from django.db import transaction
|
||||
from rest_framework import status
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import APIException
|
||||
from apps.product import models as product_models
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework import viewsets, filters
|
||||
|
||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||
from apps.core.pagination import CustomPageNumberPagination
|
||||
from apps.herd.models import Rancher
|
||||
from rest_framework import status
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
from apps.pos_device.mixins.pos_device_mixin import POSDeviceMixin
|
||||
from apps.product import models as product_models
|
||||
from apps.product.pos.api.v1.serializers import quota_distribution_serializers as distribution_serializers
|
||||
from apps.warehouse.services.services import can_buy_from_inventory
|
||||
|
||||
|
||||
def trash(queryset, pk): # noqa
|
||||
@@ -102,6 +101,7 @@ class QuotaDistributionViewSet(viewsets.ModelViewSet, DynamicSearchMixin, POSDev
|
||||
can_buy_from_inventory(rancher.first(), distribution=distribution) & rancher.exists()
|
||||
)
|
||||
]
|
||||
print(device)
|
||||
|
||||
# paginate & response
|
||||
page = self.paginate_queryset(available_distributions) # noqa
|
||||
|
||||
@@ -65,7 +65,10 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
if total + amount > quota.quota_weight:
|
||||
raise QuotaWeightException()
|
||||
else:
|
||||
if parent_distribution.weight + amount > parent_distribution.weight:
|
||||
children_total = parent_distribution.children.all().aggregate(
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
if children_total + amount > parent_distribution.weight:
|
||||
raise QuotaWeightException()
|
||||
|
||||
if self.instance:
|
||||
|
||||
1886
logs/django_requests.log
Normal file
1886
logs/django_requests.log
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user