Fix setting a voucher price to 0

This commit is contained in:
Raphael Michel
2016-12-07 11:31:37 +01:00
parent 1785178532
commit 7154d3f510
2 changed files with 5 additions and 1 deletions

View File

@@ -234,7 +234,7 @@ class Voucher(LoggedModel):
certain percentage. If the voucher does not modify the price, the certain percentage. If the voucher does not modify the price, the
original price will be returned. original price will be returned.
""" """
if self.value: if self.value is not None:
if self.price_mode == 'set': if self.price_mode == 'set':
return self.value return self.value
elif self.price_mode == 'subtract': elif self.price_mode == 'subtract':

View File

@@ -421,6 +421,10 @@ class VoucherTestCase(BaseQuotaTestCase):
v = Voucher.objects.create(event=self.event, price_mode='set', value=Decimal('10.00')) v = Voucher.objects.create(event=self.event, price_mode='set', value=Decimal('10.00'))
v.calculate_price(Decimal('23.42')) == 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): def test_calculate_price_subtract(self):
v = Voucher.objects.create(event=self.event, price_mode='subtract', value=Decimal('10.00')) v = Voucher.objects.create(event=self.event, price_mode='subtract', value=Decimal('10.00'))
v.calculate_price(Decimal('23.42')) == Decimal('13.42') v.calculate_price(Decimal('23.42')) == Decimal('13.42')