From 9441cb7145af70b1e5a4175c9e15b076bab3fdf0 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 24 Apr 2024 13:54:41 +0700 Subject: Fix voucher greater than total --- indoteknik_custom/models/voucher.py | 4 ++-- 1 file 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 -- cgit v1.2.3