fix - distribution validation
This commit is contained in:
@@ -82,8 +82,12 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
raise APIException("وزن وارد شده کمتر از وزن ورودی به انبار است", code=403) # noqa
|
||||
|
||||
# if weight is more than distribution remaining weight
|
||||
if amount > self.instance.remaining_weight + self.instance.weight:
|
||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||
if not self.instance.parent_distribution:
|
||||
if amount + total > self.instance.quota.quota_weight:
|
||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||
else:
|
||||
if amount + total > self.instance.parent_distribution.weight:
|
||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user