Compare commits

...

1 Commits

Author SHA1 Message Date
Raphael Michel
c9692283df Fix negative prices in bundles when tax rate is 0 2024-10-08 17:13:22 +02:00
2 changed files with 30 additions and 2 deletions

View File

@@ -306,8 +306,11 @@ class TaxRule(LoggedModel):
if rate == Decimal('0.00'):
return TaxedPrice(
net=base_price - subtract_from_gross, gross=base_price - subtract_from_gross, tax=Decimal('0.00'),
rate=rate, name=self.name
net=max(Decimal('0.00'), base_price - subtract_from_gross),
gross=max(Decimal('0.00'), base_price - subtract_from_gross),
tax=Decimal('0.00'),
rate=rate,
name=self.name,
)
if base_price_is == 'auto':

View File

@@ -3654,6 +3654,31 @@ class CartBundleTest(CartTestMixin, TestCase):
assert cp.price == Decimal('0.00')
assert b.price == Decimal('1.50')
@classscope(attr='orga')
def test_voucher_apply_multiple_reduce_beyond_designated_price_no_tax_rules(self):
self.ticket.tax_rule = None
self.ticket.save()
self.trans.tax_rule = None
self.trans.save()
cp = CartPosition.objects.create(
event=self.event, cart_id=self.session_key, item=self.ticket,
price=21.5, expires=now() + timedelta(minutes=10)
)
b = CartPosition.objects.create(
event=self.event, cart_id=self.session_key, item=self.trans, addon_to=cp,
price=1.5, expires=now() + timedelta(minutes=10), is_bundled=True
)
v = Voucher.objects.create(
event=self.event, price_mode='set', value=Decimal('0.00'), max_usages=100
)
self.cm.apply_voucher(v.code)
self.cm.commit()
cp.refresh_from_db()
b.refresh_from_db()
assert cp.price == Decimal('0.00')
assert b.price == Decimal('1.50')
@classscope(attr='orga')
def test_voucher_apply_affect_bundled(self):
cp = CartPosition.objects.create(