fix - tarnsaction validation of pre sale & free sale / calculate weight in rancher statistic by rancher activity
This commit is contained in:
@@ -252,15 +252,16 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer):
|
||||
if 'quota_distribution' in item.keys():
|
||||
distribution = QuotaDistribution.objects.get(id=item.get('quota_distribution'))
|
||||
|
||||
# if quota has not been in sale time
|
||||
if not distribution.quota.is_in_sale_licence_time():
|
||||
raise QuotaSaleTimeException()
|
||||
total_sale_weight = distribution.sale_items.aggregate(
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
if not distribution.pre_sale and not distribution.free_sale:
|
||||
# if quota has not been in sale time
|
||||
if not distribution.quota.is_in_sale_licence_time():
|
||||
raise QuotaSaleTimeException()
|
||||
total_sale_weight = distribution.sale_items.aggregate(
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
|
||||
if total_sale_weight + item.get('weight') > distribution.weight:
|
||||
raise DistributionWeightException()
|
||||
if total_sale_weight + item.get('weight') > distribution.weight:
|
||||
raise DistributionWeightException()
|
||||
|
||||
return attrs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user