Do not allow vouchers to create negative prices

This commit is contained in:
Raphael Michel
2017-08-07 10:31:25 +02:00
parent e4ab27a292
commit e858edd85c
2 changed files with 13 additions and 1 deletions

View File

@@ -251,7 +251,7 @@ class Voucher(LoggedModel):
if self.price_mode == 'set':
return self.value
elif self.price_mode == 'subtract':
return original_price - self.value
return max(original_price - self.value, Decimal('0.00'))
elif self.price_mode == 'percent':
return round_decimal(original_price * (Decimal('100.00') - self.value) / Decimal('100.00'))
return original_price