mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Fix negative prices in bundles when tax rate is 0 (#4513)
This commit is contained in:
@@ -306,8 +306,11 @@ class TaxRule(LoggedModel):
|
|||||||
|
|
||||||
if rate == Decimal('0.00'):
|
if rate == Decimal('0.00'):
|
||||||
return TaxedPrice(
|
return TaxedPrice(
|
||||||
net=base_price - subtract_from_gross, gross=base_price - subtract_from_gross, tax=Decimal('0.00'),
|
net=max(Decimal('0.00'), base_price - subtract_from_gross),
|
||||||
rate=rate, name=self.name
|
gross=max(Decimal('0.00'), base_price - subtract_from_gross),
|
||||||
|
tax=Decimal('0.00'),
|
||||||
|
rate=rate,
|
||||||
|
name=self.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
if base_price_is == 'auto':
|
if base_price_is == 'auto':
|
||||||
|
|||||||
@@ -3654,6 +3654,31 @@ class CartBundleTest(CartTestMixin, TestCase):
|
|||||||
assert cp.price == Decimal('0.00')
|
assert cp.price == Decimal('0.00')
|
||||||
assert b.price == Decimal('1.50')
|
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')
|
@classscope(attr='orga')
|
||||||
def test_voucher_apply_affect_bundled(self):
|
def test_voucher_apply_affect_bundled(self):
|
||||||
cp = CartPosition.objects.create(
|
cp = CartPosition.objects.create(
|
||||||
|
|||||||
Reference in New Issue
Block a user