fix distributoion creation bug
This commit is contained in:
@@ -56,17 +56,17 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
|
||||
if total + amount > quota.quota_weight:
|
||||
raise QuotaWeightException()
|
||||
|
||||
# total warehouse inventory entry
|
||||
total_entry = self.instance.inventory_entry.aggregate(
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
|
||||
# if inventory entry weight is bigger than distribute weight in edit distribution
|
||||
if total_entry > self.instance.weight:
|
||||
raise APIException("وزن وارد شده کمتر از وزن ورودی به انبار است", code=403) # noqa
|
||||
|
||||
# if weight is more than distribution remaining weight
|
||||
if self.instance:
|
||||
# total warehouse inventory entry
|
||||
total_entry = self.instance.inventory_entry.aggregate(
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
|
||||
# if inventory entry weight is bigger than distribute weight in edit distribution
|
||||
if total_entry > self.instance.weight:
|
||||
raise APIException("وزن وارد شده کمتر از وزن ورودی به انبار است", code=403) # noqa
|
||||
|
||||
# if weight is more than distribution remaining weight
|
||||
if self.instance.weight > self.instance.remaining_weight:
|
||||
raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa
|
||||
|
||||
|
||||
Reference in New Issue
Block a user