remove organization assignment logic in device and services modules
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
from apps.product.web.api.v1.serializers.quota_distribution_serializers import QuotaDistributionSerializer
|
||||
from apps.authentication.api.v1.serializers.serializer import BankAccountSerializer
|
||||
from apps.pos_device.web.api.v1.serilaizers import client as client_serializer
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from apps.pos_device import models as pos_models
|
||||
from rest_framework.exceptions import APIException
|
||||
|
||||
from apps.authentication.api.v1.serializers.serializer import BankAccountSerializer
|
||||
from apps.pos_device import exceptions as pos_exceptions
|
||||
from rest_framework import status
|
||||
from apps.pos_device import models as pos_models
|
||||
from apps.pos_device.web.api.v1.serilaizers import client as client_serializer
|
||||
from apps.product.web.api.v1.serializers.quota_distribution_serializers import QuotaDistributionSerializer
|
||||
|
||||
|
||||
class ProviderCompanySerializer(ModelSerializer):
|
||||
@@ -99,6 +98,18 @@ class StakeHolderShareAmountSerializer(ModelSerializer):
|
||||
model = pos_models.StakeHolderShareAmount
|
||||
fields = '__all__'
|
||||
|
||||
def validate(self, attrs):
|
||||
stakeholders = attrs['stakeholders']
|
||||
|
||||
# check organization has pos device
|
||||
assigned_organization = pos_models.Organization.objects.get(
|
||||
id=attrs['distribution'].assigned_organization
|
||||
)
|
||||
if not assigned_organization.has_pos:
|
||||
raise pos_exceptions.OrganizationDeviceNotAssigned()
|
||||
|
||||
return attrs
|
||||
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user