Allow tax rules to trigger approval requirement (#2409)

This commit is contained in:
Raphael Michel
2022-01-10 14:10:51 +01:00
committed by GitHub
parent 7a4db8ea23
commit 70a5c76d79
7 changed files with 50 additions and 7 deletions

View File

@@ -448,6 +448,38 @@ class CheckoutTestCase(BaseCheckoutTestCase, TestCase):
cr1.refresh_from_db()
assert cr1.price == Decimal('19.33')
def test_custom_tax_rules_require_approval(self):
self.tr19.custom_rules = json.dumps([
{'country': 'AT', 'address_type': 'business_vat_id', 'action': 'reverse'},
{'country': 'ZZ', 'address_type': '', 'action': 'require_approval'},
])
self.tr19.save()
self.event.settings.invoice_address_vatid = True
with scopes_disabled():
cr1 = CartPosition.objects.create(
event=self.event, cart_id=self.session_key, item=self.ticket,
price=23, expires=now() + timedelta(minutes=10)
)
self.client.post('/%s/%s/checkout/questions/' % (self.orga.slug, self.event.slug), {
'is_business': 'business',
'company': 'Foo',
'name': 'Bar',
'street': 'Baz',
'zipcode': '12345',
'city': 'Here',
'country': 'DE',
'email': 'admin@localhost'
}, follow=True)
self.client.post('/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), follow=True)
with scopes_disabled():
assert not CartPosition.objects.filter(pk=cr1.pk).exists()
o = Order.objects.last()
assert o.require_approval
assert o.positions.first().tax_rate == Decimal('19.00')
def _test_country_taxing(self):
self._enable_country_specific_taxing()