summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-04-24 13:54:41 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-04-24 13:54:41 +0700
commit9441cb7145af70b1e5a4175c9e15b076bab3fdf0 (patch)
tree27d4013f64efe6ed9ed38c241150aeb7a96618d6
parent68c7f85b0bf7b8eb85f5bbffcfe2bbc8a38b7e4e (diff)
Fix voucher greater than total
-rw-r--r--indoteknik_custom/models/voucher.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py
index 588e9ac5..66f763e0 100644
--- a/indoteknik_custom/models/voucher.py
+++ b/indoteknik_custom/models/voucher.py
@@ -153,7 +153,7 @@ class Voucher(models.Model):
discount_all = total['all'] * decimal_discount
result['all'] = min(discount_all, self.max_discount_amount) if self.max_discount_amount > 0 else discount_all
else:
- result['all'] = self.discount_amount
+ result['all'] = min(self.discount_amount, total['all'])
return result
@@ -169,7 +169,7 @@ class Voucher(models.Model):
discount_brand = total_brand * decimal_discount
discount_brand = min(discount_brand, line.max_discount_amount) if line.max_discount_amount > 0 else discount_brand
else:
- discount_brand = line.discount_amount
+ discount_brand = min(line.discount_amount, total_brand)
result['brand'][manufacture_id] = round(discount_brand, 2)
result['all'] += discount_brand