mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
New data model for default tax rule and new options for cancellation fees (#4962)
* New data model for default tax rule * Remove misleading empty label when field is not optional * Allow to split cancellation fee * Fix API and tests * Update migration * Update src/tests/api/test_taxrules.py Co-authored-by: luelista <weller@rami.io> * Update src/tests/api/test_taxrules.py Co-authored-by: luelista <weller@rami.io> * Review note * Update src/pretix/base/models/tax.py Co-authored-by: luelista <weller@rami.io> * Flip API behaviour for default * Fix failing tests * Fix failing test * Split migration --------- Co-authored-by: luelista <weller@rami.io>
This commit is contained in:
@@ -31,6 +31,7 @@ TEST_TAXRULE_RES = {
|
||||
'keep_gross_if_rate_changes': False,
|
||||
'name': {'en': 'VAT'},
|
||||
'rate': '19.00',
|
||||
'default': True,
|
||||
'code': 'S/standard',
|
||||
'price_includes_tax': True,
|
||||
'eu_reverse_charge': False,
|
||||
@@ -80,6 +81,45 @@ def test_rule_create(token_client, organizer, event):
|
||||
assert str(rule.home_country) == "DE"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_rule_create_auto_default(token_client, organizer, event):
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/taxrules/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
"name": {"en": "VAT", "de": "MwSt"},
|
||||
"rate": "19.00",
|
||||
"price_includes_tax": True,
|
||||
"eu_reverse_charge": False,
|
||||
"home_country": "DE",
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
rule = TaxRule.objects.get(pk=resp.data['id'])
|
||||
assert rule.default
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_rule_create_only_one_default(token_client, taxrule, organizer, event):
|
||||
assert taxrule.default
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/taxrules/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
"name": {"en": "VAT", "de": "MwSt"},
|
||||
"rate": "19.00",
|
||||
"price_includes_tax": True,
|
||||
"eu_reverse_charge": False,
|
||||
"home_country": "DE",
|
||||
"default": True,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
|
||||
taxrule.refresh_from_db()
|
||||
assert not taxrule.default
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_rule_update(token_client, organizer, event, taxrule):
|
||||
resp = token_client.patch(
|
||||
|
||||
Reference in New Issue
Block a user