quota stat by organization - v1
This commit is contained in:
@@ -87,9 +87,6 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
if not self.instance.parent_distribution:
|
||||
if amount + total > self.instance.quota.quota_weight:
|
||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||
# else:
|
||||
# if amount > self.instance.parent_distribution.remaining_weight:
|
||||
# raise QuotaWeightException()
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@@ -10,8 +10,15 @@ class QuotaSerializer(serializers.ModelSerializer):
|
||||
model = product_models.Quota
|
||||
fields = '__all__'
|
||||
|
||||
def to_representation(self, instance):
|
||||
def to_representation(self, instance: product_models.Quota):
|
||||
representation = super().to_representation(instance)
|
||||
|
||||
# change quota weight by organization received weight
|
||||
if self.context['org']:
|
||||
quota_weight_by_org = instance.quota_amount_by_org(self.context['org'])
|
||||
if quota_weight_by_org:
|
||||
representation['quota_weight'] = quota_weight_by_org
|
||||
|
||||
if isinstance(instance, product_models.Quota):
|
||||
if instance.sale_unit:
|
||||
representation['sale_unit'] = product_serializers.SaleUnitSerializer(
|
||||
|
||||
Reference in New Issue
Block a user