mirror of
https://github.com/pretix/pretix.git
synced 2026-08-28 13:34:40 +00:00
Fix price calculation of included add-ons in expired carts
This commit is contained in:
@@ -453,12 +453,15 @@ class CartManager:
|
|||||||
if cp.is_bundled:
|
if cp.is_bundled:
|
||||||
bundle = cp.addon_to.item.bundles.filter(bundled_item=cp.item, bundled_variation=cp.variation).first()
|
bundle = cp.addon_to.item.bundles.filter(bundled_item=cp.item, bundled_variation=cp.variation).first()
|
||||||
if bundle:
|
if bundle:
|
||||||
listed_price = bundle.designated_price or 0
|
listed_price = bundle.designated_price or Decimal('0.00')
|
||||||
else:
|
else:
|
||||||
listed_price = cp.price
|
listed_price = cp.price
|
||||||
price_after_voucher = listed_price
|
price_after_voucher = listed_price
|
||||||
else:
|
else:
|
||||||
listed_price = get_listed_price(cp.item, cp.variation, cp.subevent)
|
if cp.addon_to_id and is_included_for_free(cp.item, cp.addon_to):
|
||||||
|
listed_price = Decimal('0.00')
|
||||||
|
else:
|
||||||
|
listed_price = get_listed_price(cp.item, cp.variation, cp.subevent)
|
||||||
if cp.voucher:
|
if cp.voucher:
|
||||||
price_after_voucher = cp.voucher.calculate_price(listed_price)
|
price_after_voucher = cp.voucher.calculate_price(listed_price)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -2380,6 +2380,25 @@ class CartAddonTest(CartTestMixin, TestCase):
|
|||||||
assert cp2.item == self.workshop1
|
assert cp2.item == self.workshop1
|
||||||
assert cp2.price == 0
|
assert cp2.price == 0
|
||||||
|
|
||||||
|
@classscope(attr='orga')
|
||||||
|
def test_extend_included_addon(self):
|
||||||
|
self.addon1.price_included = True
|
||||||
|
self.addon1.save()
|
||||||
|
cp1 = CartPosition.objects.create(
|
||||||
|
expires=now() - timedelta(minutes=10), item=self.ticket, price=Decimal('23.00'),
|
||||||
|
event=self.event, cart_id=self.session_key
|
||||||
|
)
|
||||||
|
cp2 = CartPosition.objects.create(
|
||||||
|
expires=now() - timedelta(minutes=10), item=self.workshop1, price=Decimal('0.00'),
|
||||||
|
event=self.event, cart_id=self.session_key, addon_to=cp1
|
||||||
|
)
|
||||||
|
self.cm.extend_expired_positions()
|
||||||
|
self.cm.commit()
|
||||||
|
cp2.refresh_from_db()
|
||||||
|
assert cp2.expires > now()
|
||||||
|
assert cp2.item == self.workshop1
|
||||||
|
assert cp2.price == 0
|
||||||
|
|
||||||
@classscope(attr='orga')
|
@classscope(attr='orga')
|
||||||
def test_cart_addon_remove_parent(self):
|
def test_cart_addon_remove_parent(self):
|
||||||
self.addon1.price_included = True
|
self.addon1.price_included = True
|
||||||
|
|||||||
Reference in New Issue
Block a user