Fix #1001 -- Add product bundles (#1041)

* Data model + Editor

* Cart and order management

* Rebase migrations

* Fix typos, add tests on cart handling

* Add tests for checkout and quotas

* Add API endpoints

* Validation of settings

* Front page tax display

* Voucher handling

* Widget foo

* Show correct net pricing

* Front page tests

* reverse charge foo

* Allow to require bundling

* Fix test failure on postgres
This commit is contained in:
Raphael Michel
2019-03-22 14:48:48 +00:00
committed by GitHub
parent c4b18a4c81
commit 90f881c48e
34 changed files with 2747 additions and 153 deletions

View File

@@ -312,6 +312,64 @@ class ItemDisplayTest(EventTestMixin, SoupTest):
self.assertIn("Black", doc.select("section:nth-of-type(1) div.variation")[1].text)
self.assertIn("12.00", doc.select("section:nth-of-type(1) div.variation")[1].text)
def test_require_bundling(self):
q = Quota.objects.create(event=self.event, name='Quota', size=2)
item = Item.objects.create(event=self.event, name='Early-bird ticket', default_price=12)
q.items.add(item)
q2 = Quota.objects.create(event=self.event, name='Quota', size=2)
item2 = Item.objects.create(event=self.event, name='Dinner', default_price=12, require_bundling=True)
q2.items.add(item2)
item.bundles.create(bundled_item=item2, designated_price=2, count=1)
doc = self.get_doc('/%s/%s/' % (self.orga.slug, self.event.slug))
self.assertEqual(1, len(doc.select(".availability-box")))
def test_bundle_sold_out(self):
q = Quota.objects.create(event=self.event, name='Quota', size=2)
item = Item.objects.create(event=self.event, name='Early-bird ticket', default_price=12)
q.items.add(item)
q2 = Quota.objects.create(event=self.event, name='Quota', size=0)
item2 = Item.objects.create(event=self.event, name='Dinner', default_price=12, position=10)
q2.items.add(item2)
item.bundles.create(bundled_item=item2, designated_price=2, count=1)
doc = self.get_doc('/%s/%s/' % (self.orga.slug, self.event.slug))
self.assertIn("Early-bird", doc.select("section:nth-of-type(1) div:nth-of-type(1)")[0].text)
self.assertIn("SOLD OUT", doc.select("section:nth-of-type(1)")[0].text)
def test_bundle_mixed_tax_rate(self):
tr19 = self.event.tax_rules.create(rate=Decimal('19.00'))
tr7 = self.event.tax_rules.create(rate=Decimal('7.00'))
q = Quota.objects.create(event=self.event, name='Quota', size=2)
item = Item.objects.create(event=self.event, name='Early-bird ticket', default_price=12, tax_rule=tr19)
q.items.add(item)
q2 = Quota.objects.create(event=self.event, name='Quota', size=0)
item2 = Item.objects.create(event=self.event, name='Dinner', default_price=12, tax_rule=tr7, position=10)
q2.items.add(item2)
item.bundles.create(bundled_item=item2, designated_price=2, count=1)
doc = self.get_doc('/%s/%s/' % (self.orga.slug, self.event.slug))
self.assertIn("Early-bird", doc.select("section:nth-of-type(1) div:nth-of-type(1)")[0].text)
self.assertIn("12.00", doc.select("section:nth-of-type(1) div.price")[0].text)
self.assertIn("incl. taxes", doc.select("section:nth-of-type(1) div.price")[0].text)
def test_bundle_mixed_tax_rate_show_net(self):
self.event.settings.display_net_prices = True
tr19 = self.event.tax_rules.create(rate=Decimal('19.00'))
tr7 = self.event.tax_rules.create(rate=Decimal('7.00'))
q = Quota.objects.create(event=self.event, name='Quota', size=2)
item = Item.objects.create(event=self.event, name='Early-bird ticket', default_price=12, tax_rule=tr19)
q.items.add(item)
q2 = Quota.objects.create(event=self.event, name='Quota', size=0)
item2 = Item.objects.create(event=self.event, name='Dinner', default_price=12, tax_rule=tr7, position=10)
q2.items.add(item2)
item.bundles.create(bundled_item=item2, designated_price=2, count=1)
doc = self.get_doc('/%s/%s/' % (self.orga.slug, self.event.slug))
self.assertIn("Early-bird", doc.select("section:nth-of-type(1) div:nth-of-type(1)")[0].text)
self.assertIn("10.27", doc.select("section:nth-of-type(1) div.price")[0].text)
self.assertIn("plus taxes", doc.select("section:nth-of-type(1) div.price")[0].text)
class VoucherRedeemItemDisplayTest(EventTestMixin, SoupTest):
def setUp(self):