forked from CGM_Public/pretix_original
Fix setting a voucher price to 0
This commit is contained in:
@@ -234,7 +234,7 @@ class Voucher(LoggedModel):
|
||||
certain percentage. If the voucher does not modify the price, the
|
||||
original price will be returned.
|
||||
"""
|
||||
if self.value:
|
||||
if self.value is not None:
|
||||
if self.price_mode == 'set':
|
||||
return self.value
|
||||
elif self.price_mode == 'subtract':
|
||||
|
||||
@@ -421,6 +421,10 @@ class VoucherTestCase(BaseQuotaTestCase):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='set', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('10.00')
|
||||
|
||||
def test_calculate_price_set_zero(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='set', value=Decimal('0.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('0.00')
|
||||
|
||||
def test_calculate_price_subtract(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='subtract', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('13.42')
|
||||
|
||||
Reference in New Issue
Block a user