mirror of
https://github.com/pretix/pretix.git
synced 2025-12-05 21:32:28 +00:00
TaxRules: Add internal_name and keep_gross_if_rate_changes (#2422)
Co-authored-by: ser8phin <eva.wolkwitz@gmx.de>
This commit is contained in:
@@ -16,15 +16,22 @@ Field Type Description
|
||||
===================================== ========================== =======================================================
|
||||
id integer Internal ID of the tax rule
|
||||
name multi-lingual string The tax rules' name
|
||||
internal_name string An optional name that is only used in the backend
|
||||
rate decimal (string) Tax rate in percent
|
||||
price_includes_tax boolean If ``true`` (default), tax is assumed to be included in
|
||||
the specified product price
|
||||
eu_reverse_charge boolean If ``true``, EU reverse charge rules are applied
|
||||
home_country string Merchant country (required for reverse charge), can be
|
||||
``null`` or empty string
|
||||
keep_gross_if_rate_changes boolean If ``true``, changes of the tax rate based on custom
|
||||
rules keep the gross price constant (default is ``false``)
|
||||
===================================== ========================== =======================================================
|
||||
|
||||
|
||||
.. versionchanged:: 4.6
|
||||
|
||||
The ``internal_name`` and ``keep_gross_if_rate_changes`` attributes have been added.
|
||||
|
||||
Endpoints
|
||||
---------
|
||||
|
||||
@@ -56,9 +63,11 @@ Endpoints
|
||||
{
|
||||
"id": 1,
|
||||
"name": {"en": "VAT"},
|
||||
"internal_name": "VAT",
|
||||
"rate": "19.00",
|
||||
"price_includes_tax": true,
|
||||
"eu_reverse_charge": false,
|
||||
"keep_gross_if_rate_changes": false,
|
||||
"home_country": "DE"
|
||||
}
|
||||
]
|
||||
@@ -94,9 +103,11 @@ Endpoints
|
||||
{
|
||||
"id": 1,
|
||||
"name": {"en": "VAT"},
|
||||
"internal_name": "VAT",
|
||||
"rate": "19.00",
|
||||
"price_includes_tax": true,
|
||||
"eu_reverse_charge": false,
|
||||
"keep_gross_if_rate_changes": false,
|
||||
"home_country": "DE"
|
||||
}
|
||||
|
||||
@@ -140,9 +151,11 @@ Endpoints
|
||||
{
|
||||
"id": 1,
|
||||
"name": {"en": "VAT"},
|
||||
"internal_name": "VAT",
|
||||
"rate": "19.00",
|
||||
"price_includes_tax": true,
|
||||
"eu_reverse_charge": false,
|
||||
"keep_gross_if_rate_changes": false,
|
||||
"home_country": "DE"
|
||||
}
|
||||
|
||||
@@ -185,9 +198,11 @@ Endpoints
|
||||
{
|
||||
"id": 1,
|
||||
"name": {"en": "VAT"},
|
||||
"internal_name": "VAT",
|
||||
"rate": "20.00",
|
||||
"price_includes_tax": true,
|
||||
"eu_reverse_charge": false,
|
||||
"keep_gross_if_rate_changes": false,
|
||||
"home_country": "DE"
|
||||
}
|
||||
|
||||
|
||||
@@ -637,7 +637,7 @@ class SubEventSerializer(I18nAwareModelSerializer):
|
||||
class TaxRuleSerializer(CountryFieldMixin, I18nAwareModelSerializer):
|
||||
class Meta:
|
||||
model = TaxRule
|
||||
fields = ('id', 'name', 'rate', 'price_includes_tax', 'eu_reverse_charge', 'home_country')
|
||||
fields = ('id', 'name', 'rate', 'price_includes_tax', 'eu_reverse_charge', 'home_country', 'internal_name', 'keep_gross_if_rate_changes')
|
||||
|
||||
|
||||
class EventSettingsSerializer(SettingsSerializer):
|
||||
|
||||
23
src/pretix/base/migrations/0207_auto_20220119_1427.py
Normal file
23
src/pretix/base/migrations/0207_auto_20220119_1427.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.2.4 on 2022-01-19 14:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pretixbase', '0206_customer_phone'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='taxrule',
|
||||
name='internal_name',
|
||||
field=models.CharField(max_length=190, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='taxrule',
|
||||
name='keep_gross_if_rate_changes',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -81,6 +81,15 @@ class TaxedPrice:
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
def __eq__(self, other):
|
||||
return (
|
||||
self.gross == other.gross and
|
||||
self.net == other.net and
|
||||
self.tax == other.tax and
|
||||
self.rate == other.rate and
|
||||
self.name == other.name
|
||||
)
|
||||
|
||||
|
||||
TAXED_ZERO = TaxedPrice(
|
||||
gross=Decimal('0.00'),
|
||||
@@ -127,8 +136,13 @@ def cc_to_vat_prefix(country_code):
|
||||
|
||||
class TaxRule(LoggedModel):
|
||||
event = models.ForeignKey('Event', related_name='tax_rules', on_delete=models.CASCADE)
|
||||
internal_name = models.CharField(
|
||||
verbose_name=_('Internal name'),
|
||||
max_length=190,
|
||||
null=True, blank=True,
|
||||
)
|
||||
name = I18nCharField(
|
||||
verbose_name=_('Name'),
|
||||
verbose_name=_('Official name'),
|
||||
help_text=_('Should be short, e.g. "VAT"'),
|
||||
max_length=190,
|
||||
)
|
||||
@@ -141,6 +155,10 @@ class TaxRule(LoggedModel):
|
||||
verbose_name=_("The configured product prices include the tax amount"),
|
||||
default=True,
|
||||
)
|
||||
keep_gross_if_rate_changes = models.BooleanField(
|
||||
verbose_name=_("Keep gross amount constant if the tax rate changes based on the invoice address"),
|
||||
default=False,
|
||||
)
|
||||
eu_reverse_charge = models.BooleanField(
|
||||
verbose_name=_("Use EU reverse charge taxation rules"),
|
||||
default=False,
|
||||
@@ -198,6 +216,8 @@ class TaxRule(LoggedModel):
|
||||
s = _('plus {rate}% {name}').format(rate=self.rate, name=self.name)
|
||||
if self.eu_reverse_charge:
|
||||
s += ' ({})'.format(_('reverse charge enabled'))
|
||||
if self.internal_name:
|
||||
return f'{self.internal_name} ({s})'
|
||||
return str(s)
|
||||
|
||||
@property
|
||||
@@ -228,13 +248,19 @@ class TaxRule(LoggedModel):
|
||||
rate = override_tax_rate
|
||||
elif invoice_address:
|
||||
adjust_rate = self.tax_rate_for(invoice_address)
|
||||
if (adjust_rate == gross_price_is_tax_rate or force_fixed_gross_price) and base_price_is == 'gross':
|
||||
if (adjust_rate == gross_price_is_tax_rate or force_fixed_gross_price or self.keep_gross_if_rate_changes) and base_price_is == 'gross':
|
||||
rate = adjust_rate
|
||||
elif adjust_rate != rate:
|
||||
normal_price = self.tax(base_price, base_price_is, currency, subtract_from_gross=subtract_from_gross)
|
||||
base_price = normal_price.net
|
||||
base_price_is = 'net'
|
||||
subtract_from_gross = Decimal('0.00')
|
||||
if self.keep_gross_if_rate_changes:
|
||||
normal_price = self.tax(base_price, base_price_is, currency, subtract_from_gross=subtract_from_gross)
|
||||
base_price = normal_price.gross
|
||||
base_price_is = 'gross'
|
||||
subtract_from_gross = Decimal('0.00')
|
||||
else:
|
||||
normal_price = self.tax(base_price, base_price_is, currency, subtract_from_gross=subtract_from_gross)
|
||||
base_price = normal_price.net
|
||||
base_price_is = 'net'
|
||||
subtract_from_gross = Decimal('0.00')
|
||||
rate = adjust_rate
|
||||
|
||||
if rate == Decimal('0.00'):
|
||||
|
||||
@@ -426,10 +426,10 @@ class CartManager:
|
||||
if not cp.includes_tax:
|
||||
price = self._get_price(cp.item, cp.variation, cp.voucher, cp.price, cp.subevent,
|
||||
cp_is_net=True, bundled_sum=bundled_sum)
|
||||
price = TaxedPrice(net=price.net, gross=price.net, rate=0, tax=0, name='')
|
||||
price = TaxedPrice(net=price.net, gross=price.net, rate=Decimal('0'), tax=Decimal('0'), name='')
|
||||
pbv = self._get_price(cp.item, cp.variation, None, cp.price, cp.subevent,
|
||||
cp_is_net=True, bundled_sum=bundled_sum)
|
||||
pbv = TaxedPrice(net=pbv.net, gross=pbv.net, rate=0, tax=0, name='')
|
||||
pbv = TaxedPrice(net=pbv.net, gross=pbv.net, rate=Decimal('0'), tax=Decimal('0'), name='')
|
||||
else:
|
||||
price = self._get_price(cp.item, cp.variation, cp.voucher, cp.price, cp.subevent,
|
||||
bundled_sum=bundled_sum)
|
||||
@@ -1106,10 +1106,11 @@ def update_tax_rates(event: Event, cart_id: str, invoice_address: InvoiceAddress
|
||||
rate = pos.item.tax_rule.tax_rate_for(invoice_address)
|
||||
|
||||
if pos.tax_rate != rate:
|
||||
current_net = pos.price - pos.tax_value
|
||||
new_gross = pos.item.tax(current_net, base_price_is='net', invoice_address=invoice_address).gross
|
||||
totaldiff += new_gross - pos.price
|
||||
pos.price = new_gross
|
||||
if not pos.item.tax_rule.keep_gross_if_rate_changes:
|
||||
current_net = pos.price - pos.tax_value
|
||||
new_gross = pos.item.tax(current_net, base_price_is='net', invoice_address=invoice_address).gross
|
||||
totaldiff += new_gross - pos.price
|
||||
pos.price = new_gross
|
||||
pos.includes_tax = rate != Decimal('0.00')
|
||||
pos.override_tax_rate = rate
|
||||
pos.save(update_fields=['price', 'includes_tax', 'override_tax_rate'])
|
||||
|
||||
@@ -700,7 +700,7 @@ def _check_positions(event: Event, now_dt: datetime, positions: List[CartPositio
|
||||
invoice_address=address, force_custom_price=True, max_discount=max_discount)
|
||||
changed_prices[cp.pk] = bprice
|
||||
else:
|
||||
bundled_sum = 0
|
||||
bundled_sum = Decimal('0.00')
|
||||
if not cp.addon_to_id:
|
||||
for bundledp in cp.addons.all():
|
||||
if bundledp.is_bundled:
|
||||
|
||||
@@ -1249,7 +1249,7 @@ TaxRuleLineFormSet = formset_factory(
|
||||
class TaxRuleForm(I18nModelForm):
|
||||
class Meta:
|
||||
model = TaxRule
|
||||
fields = ['name', 'rate', 'price_includes_tax', 'eu_reverse_charge', 'home_country']
|
||||
fields = ['name', 'rate', 'price_includes_tax', 'eu_reverse_charge', 'home_country', 'internal_name', 'keep_gross_if_rate_changes']
|
||||
|
||||
|
||||
class WidgetCodeForm(forms.Form):
|
||||
|
||||
@@ -452,7 +452,7 @@ class OrderPositionChangeForm(forms.Form):
|
||||
|
||||
@staticmethod
|
||||
def taxrule_label_from_instance(obj):
|
||||
return f"{obj.name} ({obj.rate} %)"
|
||||
return f"{obj.internal_name or obj.name} ({obj.rate} %)"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
instance = kwargs.pop('instance')
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<fieldset>
|
||||
<legend>{% trans "General" %}</legend>
|
||||
{% bootstrap_field form.name layout="control" %}
|
||||
{% bootstrap_field form.internal_name layout="control" %}
|
||||
{% bootstrap_field form.rate addon_after="%" layout="control" %}
|
||||
{% bootstrap_field form.price_includes_tax layout="control" %}
|
||||
</fieldset>
|
||||
@@ -39,6 +40,7 @@
|
||||
</div>
|
||||
{% bootstrap_field form.eu_reverse_charge layout="control" %}
|
||||
{% bootstrap_field form.home_country layout="control" %}
|
||||
{% bootstrap_field form.keep_gross_if_rate_changes layout="control" %}
|
||||
<h3>{% trans "Custom taxation rules" %}</h3>
|
||||
<div class="alert alert-warning">
|
||||
{% blocktrans trimmed %}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<tr>
|
||||
<td>
|
||||
<strong><a href="{% url "control:event.settings.tax.edit" organizer=request.event.organizer.slug event=request.event.slug rule=tr.id %}">
|
||||
{{ tr.name }}
|
||||
{{ tr.internal_name|default:tr.name }}
|
||||
</a></strong>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -145,7 +145,12 @@
|
||||
<strong>{% trans "Tax rule" %}</strong>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
{{ position.tax_rule.name }} ({{ position.tax_rule.rate }} %)
|
||||
{% if position.tax_rule.internal_name %}
|
||||
{{ position.tax_rule.internal_name }}
|
||||
{% else %}
|
||||
{{ position.tax_rule.name }}
|
||||
{% endif %}
|
||||
({{ position.tax_rule.rate }} %)
|
||||
</div>
|
||||
<div class="col-sm-4 field-container">
|
||||
{% bootstrap_field position.form.tax_rule layout='inline' %}
|
||||
|
||||
@@ -27,6 +27,8 @@ from django_scopes import scopes_disabled
|
||||
from pretix.base.models import TaxRule
|
||||
|
||||
TEST_TAXRULE_RES = {
|
||||
'internal_name': None,
|
||||
'keep_gross_if_rate_changes': False,
|
||||
'name': {'en': 'VAT'},
|
||||
'rate': '19.00',
|
||||
'price_includes_tax': True,
|
||||
|
||||
@@ -26,6 +26,7 @@ import pytest
|
||||
from django.utils.timezone import now
|
||||
from django_countries.fields import Country
|
||||
|
||||
from pretix.base.decimal import round_decimal
|
||||
from pretix.base.models import Event, InvoiceAddress, Organizer
|
||||
from pretix.base.models.items import SubEventItem, SubEventItemVariation
|
||||
from pretix.base.services.pricing import get_price
|
||||
@@ -379,3 +380,77 @@ def test_country_specific_rule_gross_based(item):
|
||||
country=Country('BE')
|
||||
)
|
||||
assert get_price(item, invoice_address=ia).gross == Decimal('168.06')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_country_specific_rule_net_based_but_keep_gross_if_rate_changes(item):
|
||||
item.default_price = Decimal('100.00')
|
||||
item.tax_rule = item.event.tax_rules.create(
|
||||
rate=Decimal('19.00'), price_includes_tax=False, keep_gross_if_rate_changes=True,
|
||||
custom_rules=json.dumps([
|
||||
{'country': 'BE', 'address_type': '', 'action': 'vat', 'rate': '100.00'}
|
||||
])
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True, vat_id="EU1234", vat_id_validated=True,
|
||||
country=Country('BE')
|
||||
)
|
||||
p = get_price(item, invoice_address=ia)
|
||||
assert p.gross == Decimal('119.00')
|
||||
assert p.rate == Decimal('100.00')
|
||||
assert p.tax == Decimal('59.50')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_country_specific_rule_net_based_subtract_bundled(item):
|
||||
item.default_price = Decimal('100.00')
|
||||
item.tax_rule = item.event.tax_rules.create(
|
||||
rate=Decimal('19.00'), price_includes_tax=False,
|
||||
custom_rules=json.dumps([
|
||||
{'country': 'BE', 'address_type': '', 'action': 'vat', 'rate': '100.00'}
|
||||
])
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True, vat_id="EU1234", vat_id_validated=True,
|
||||
country=Country('BE')
|
||||
)
|
||||
assert get_price(item, invoice_address=ia, bundled_sum=Decimal('20.00')).gross == (
|
||||
round_decimal((Decimal('119.00') - Decimal('20.00')) / Decimal('1.19')) * Decimal('2')
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_country_specific_rule_gross_based_subtract_bundled(item):
|
||||
item.default_price = Decimal('100.00')
|
||||
item.tax_rule = item.event.tax_rules.create(
|
||||
rate=Decimal('19.00'), price_includes_tax=True,
|
||||
custom_rules=json.dumps([
|
||||
{'country': 'BE', 'address_type': '', 'action': 'vat', 'rate': '100.00'}
|
||||
])
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True, vat_id="EU1234", vat_id_validated=True,
|
||||
country=Country('BE')
|
||||
)
|
||||
assert get_price(item, invoice_address=ia, bundled_sum=Decimal('20.00')).gross == (
|
||||
round_decimal((Decimal('100.00') - Decimal('20.00')) / Decimal('1.19')) * Decimal('2')
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_country_specific_rule_net_based_but_keep_gross_if_rate_changes_subtract_bundled(item):
|
||||
item.default_price = Decimal('100.00')
|
||||
item.tax_rule = item.event.tax_rules.create(
|
||||
rate=Decimal('19.00'), price_includes_tax=False, keep_gross_if_rate_changes=True,
|
||||
custom_rules=json.dumps([
|
||||
{'country': 'BE', 'address_type': '', 'action': 'vat', 'rate': '100.00'}
|
||||
])
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True, vat_id="EU1234", vat_id_validated=True,
|
||||
country=Country('BE')
|
||||
)
|
||||
p = get_price(item, invoice_address=ia, bundled_sum=Decimal('20.00'))
|
||||
assert p.gross == Decimal('99.00')
|
||||
assert p.rate == Decimal('100.00')
|
||||
assert p.tax == Decimal('49.50')
|
||||
|
||||
@@ -28,6 +28,7 @@ from django_countries.fields import Country
|
||||
from django_scopes import scope
|
||||
|
||||
from pretix.base.models import Event, InvoiceAddress, Organizer, TaxRule
|
||||
from pretix.base.models.tax import TaxedPrice
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -88,6 +89,13 @@ def test_reverse_charge_no_country(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -103,6 +111,13 @@ def test_reverse_charge_individual_same_country(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -118,6 +133,13 @@ def test_reverse_charge_individual_eu(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -133,6 +155,13 @@ def test_reverse_charge_individual_3rdc(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -148,6 +177,13 @@ def test_reverse_charge_business_same_country(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -163,6 +199,13 @@ def test_reverse_charge_business_eu(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -178,6 +221,13 @@ def test_reverse_charge_business_3rdc(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -195,6 +245,13 @@ def test_reverse_charge_valid_vat_id_business_same_country(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -212,6 +269,13 @@ def test_reverse_charge_valid_vat_id_business_eu(event):
|
||||
assert tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -229,6 +293,13 @@ def test_reverse_charge_valid_vat_id_business_3rdc(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -246,6 +317,13 @@ def test_reverse_charge_disabled(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -266,6 +344,13 @@ def test_custom_rules_override(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -287,6 +372,13 @@ def test_custom_rules_in_order(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -305,6 +397,13 @@ def test_custom_rules_any_country(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -329,6 +428,13 @@ def test_custom_rules_eu_country(event):
|
||||
)
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -347,6 +453,14 @@ def test_custom_rules_specific_country(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
ia = InvoiceAddress(
|
||||
is_business=True,
|
||||
country=Country('DE')
|
||||
@@ -354,6 +468,13 @@ def test_custom_rules_specific_country(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -372,6 +493,14 @@ def test_custom_rules_individual(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
ia = InvoiceAddress(
|
||||
is_business=True,
|
||||
country=Country('DE')
|
||||
@@ -379,6 +508,13 @@ def test_custom_rules_individual(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -397,6 +533,14 @@ def test_custom_rules_business(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
ia = InvoiceAddress(
|
||||
is_business=False,
|
||||
country=Country('DE')
|
||||
@@ -404,6 +548,13 @@ def test_custom_rules_business(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -422,6 +573,14 @@ def test_custom_rules_vat_id(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
ia = InvoiceAddress(
|
||||
is_business=True,
|
||||
country=Country('DE'),
|
||||
@@ -431,6 +590,13 @@ def test_custom_rules_vat_id(event):
|
||||
assert tr.is_reverse_charge(ia)
|
||||
assert not tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('0.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('100.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('0.00'),
|
||||
rate=Decimal('0.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -449,6 +615,13 @@ def test_custom_rules_country_rate(event):
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True,
|
||||
country=Country('DE'),
|
||||
@@ -458,3 +631,79 @@ def test_custom_rules_country_rate(event):
|
||||
assert tr.tax_rate_for(ia) == Decimal('100.00')
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('200.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('100.00'),
|
||||
rate=Decimal('100.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_custom_rules_country_rate_keep_gross_if_rate_changes(event):
|
||||
tr = TaxRule(
|
||||
event=event,
|
||||
rate=Decimal('10.00'), price_includes_tax=False,
|
||||
keep_gross_if_rate_changes=True,
|
||||
custom_rules=json.dumps([
|
||||
{'country': 'EU', 'address_type': 'business_vat_id', 'action': 'vat', 'rate': '100.00'},
|
||||
])
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True,
|
||||
country=Country('DE')
|
||||
)
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax_rate_for(ia) == Decimal('10.00')
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('100.00'),
|
||||
tax=Decimal('10.00'),
|
||||
rate=Decimal('10.00'),
|
||||
name='',
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True,
|
||||
country=Country('DE'),
|
||||
vat_id='DE1234',
|
||||
vat_id_validated=True
|
||||
)
|
||||
assert tr.tax_rate_for(ia) == Decimal('100.00')
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia) == TaxedPrice(
|
||||
gross=Decimal('110.00'),
|
||||
net=Decimal('55.00'),
|
||||
tax=Decimal('55.00'),
|
||||
rate=Decimal('100.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_custom_rules_country_rate_subtract_from_gross(event):
|
||||
tr = TaxRule(
|
||||
event=event,
|
||||
rate=Decimal('10.00'), price_includes_tax=False,
|
||||
custom_rules=json.dumps([
|
||||
{'country': 'EU', 'address_type': 'business_vat_id', 'action': 'vat', 'rate': '100.00'},
|
||||
])
|
||||
)
|
||||
ia = InvoiceAddress(
|
||||
is_business=True,
|
||||
country=Country('DE'),
|
||||
vat_id='DE1234',
|
||||
vat_id_validated=True
|
||||
)
|
||||
assert tr.tax_rate_for(ia) == Decimal('100.00')
|
||||
assert not tr.is_reverse_charge(ia)
|
||||
assert tr._tax_applicable(ia)
|
||||
assert tr.tax(Decimal('100.00'), invoice_address=ia, subtract_from_gross=Decimal('20.00')) == TaxedPrice(
|
||||
gross=Decimal('163.64'), # ((100 * 1.1) - 20) / (1 + 10%) * (1 + 100%)
|
||||
net=Decimal('81.82'),
|
||||
tax=Decimal('81.82'),
|
||||
rate=Decimal('100.00'),
|
||||
name='',
|
||||
)
|
||||
|
||||
@@ -3518,6 +3518,39 @@ class CartBundleTest(CartTestMixin, TestCase):
|
||||
assert a.tax_rate == Decimal('0.00')
|
||||
assert not a.includes_tax
|
||||
|
||||
@classscope(attr='orga')
|
||||
def test_reverse_charge_bundled_add_keep_gross_price(self):
|
||||
ia = InvoiceAddress.objects.create(
|
||||
is_business=True, vat_id='ATU1234567', vat_id_validated=True,
|
||||
country=Country('AT')
|
||||
)
|
||||
tr19 = self.event.tax_rules.create(name='VAT', rate=Decimal('19.00'))
|
||||
tr7 = self.event.tax_rules.create(name='VAT', rate=Decimal('7.00'), eu_reverse_charge=True, home_country=Country('DE'),
|
||||
keep_gross_if_rate_changes=True)
|
||||
self.ticket.tax_rule = tr19
|
||||
self.ticket.save()
|
||||
self.trans.tax_rule = tr7
|
||||
self.trans.save()
|
||||
|
||||
self.cm.invoice_address = ia
|
||||
self.cm.add_new_items([
|
||||
{
|
||||
'item': self.ticket.pk,
|
||||
'variation': None,
|
||||
'count': 1
|
||||
}
|
||||
])
|
||||
self.cm.commit()
|
||||
|
||||
cp = CartPosition.objects.filter(addon_to__isnull=True).get()
|
||||
a = CartPosition.objects.filter(addon_to__isnull=False).get()
|
||||
assert cp.price == Decimal('21.50')
|
||||
assert cp.tax_rate == Decimal('19.00')
|
||||
assert cp.includes_tax
|
||||
assert a.price == Decimal('1.50')
|
||||
assert a.tax_rate == Decimal('0.00')
|
||||
assert not a.includes_tax
|
||||
|
||||
@classscope(attr='orga')
|
||||
def test_reverse_charge_bundled_add(self):
|
||||
ia = InvoiceAddress.objects.create(
|
||||
|
||||
@@ -351,6 +351,42 @@ class CheckoutTestCase(BaseCheckoutTestCase, TestCase):
|
||||
ia = InvoiceAddress.objects.get(pk=self.client.session['carts'][self.session_key].get('invoice_address'))
|
||||
assert not ia.vat_id_validated
|
||||
|
||||
def test_reverse_charge_keep_gross(self):
|
||||
self.tr19.eu_reverse_charge = True
|
||||
self.tr19.keep_gross_if_rate_changes = True
|
||||
self.tr19.home_country = Country('DE')
|
||||
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)
|
||||
)
|
||||
|
||||
with mock.patch('vat_moss.id.validate') as mock_validate:
|
||||
mock_validate.return_value = ('AT', 'AT123456', 'Foo')
|
||||
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': 'AT',
|
||||
'vat_id': 'AT123456',
|
||||
'email': 'admin@localhost'
|
||||
}, follow=True)
|
||||
|
||||
cr1.refresh_from_db()
|
||||
assert cr1.price == Decimal('23.00')
|
||||
assert cr1.tax_rate == Decimal('0.00')
|
||||
assert cr1.tax_value == Decimal('0.00')
|
||||
|
||||
with scopes_disabled():
|
||||
ia = InvoiceAddress.objects.get(pk=self.client.session['carts'][self.session_key].get('invoice_address'))
|
||||
assert ia.vat_id_validated
|
||||
|
||||
def test_custom_tax_rules(self):
|
||||
self.tr19.custom_rules = json.dumps([
|
||||
{'country': 'AT', 'address_type': 'business_vat_id', 'action': 'reverse'},
|
||||
@@ -585,6 +621,72 @@ class CheckoutTestCase(BaseCheckoutTestCase, TestCase):
|
||||
cr = CartPosition.objects.get(cart_id=self.session_key)
|
||||
assert cr.price == Decimal('21.26')
|
||||
|
||||
def test_free_price_net_price_reverse_charge_keep_gross(self):
|
||||
# This is an end-to-end test of a very confusing case in which the event is set to
|
||||
# "show net prices" but the tax rate is set to "keep gross if rate changes" in
|
||||
# combination of free prices.
|
||||
# This means the user will be greeted with a display price of "23 EUR + VAT". If they
|
||||
# then adjust the price to pay more, e.g. "40 EUR", it will be interpreted as a net
|
||||
# value (since the event is set to shown net values). The cart position is therefore
|
||||
# created with a gross price of 47.60 EUR. Then, the user enters their invoice address, which
|
||||
# triggers reverse charge. The tax is now removed, but since the tax rule is set to
|
||||
# keep the gross price the same, the user will still need to pay 47.60 EUR (incl 0% VAT),
|
||||
# instead of the 40 EUR the maybe wanted in the first place.
|
||||
# While confusing, this behaviour is technically correct and the correct answer to anyone
|
||||
# complaining about this is "do not turn display_net_prices and keep_gross_if_rate_changes
|
||||
# on at the same time" (display_net_prices only makes sense if you're targeting a B2B
|
||||
# audience in which case keep_gross_if_rate_changes is useless or even harmful).
|
||||
self.event.settings.display_net_prices = True
|
||||
self.ticket.free_price = True
|
||||
self.ticket.save()
|
||||
self.tr19.eu_reverse_charge = True
|
||||
self.tr19.keep_gross_if_rate_changes = True
|
||||
self.tr19.price_includes_tax = False
|
||||
self.tr19.home_country = Country('DE')
|
||||
self.tr19.save()
|
||||
self.event.settings.invoice_address_vatid = True
|
||||
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'price_%d' % self.ticket.id: '40.00',
|
||||
}, follow=True)
|
||||
self.assertRedirects(response, '/%s/%s/?require_cookie=true' % (self.orga.slug, self.event.slug),
|
||||
target_status_code=200)
|
||||
|
||||
with scopes_disabled():
|
||||
cr1 = CartPosition.objects.get()
|
||||
assert cr1.price == Decimal('47.60')
|
||||
assert cr1.tax_rate == Decimal('19.00')
|
||||
|
||||
with mock.patch('vat_moss.id.validate') as mock_validate:
|
||||
mock_validate.return_value = ('AT', 'AT123456', 'Foo')
|
||||
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': 'AT',
|
||||
'vat_id': 'AT123456',
|
||||
'email': 'admin@localhost'
|
||||
}, follow=True)
|
||||
|
||||
cr1.refresh_from_db()
|
||||
assert cr1.price == Decimal('47.60')
|
||||
assert cr1.tax_rate == Decimal('0.00')
|
||||
|
||||
self._set_session('payment', 'banktransfer')
|
||||
|
||||
response = self.client.post('/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), follow=True)
|
||||
doc = BeautifulSoup(response.content.decode(), "lxml")
|
||||
self.assertEqual(len(doc.select(".thank-you")), 1)
|
||||
with scopes_disabled():
|
||||
op = OrderPosition.objects.get()
|
||||
self.assertEqual(op.price, Decimal('47.60'))
|
||||
self.assertEqual(op.tax_value, Decimal('0.00'))
|
||||
self.assertEqual(op.tax_rate, Decimal('0.00'))
|
||||
|
||||
def test_question_file_upload(self):
|
||||
with scopes_disabled():
|
||||
q1 = Question.objects.create(
|
||||
@@ -1876,6 +1978,46 @@ class CheckoutTestCase(BaseCheckoutTestCase, TestCase):
|
||||
cr1 = CartPosition.objects.get(id=cr1.id)
|
||||
self.assertEqual(cr1.price, round_decimal(Decimal('24.00') / Decimal('1.19')))
|
||||
|
||||
def test_confirm_price_changed_reverse_charge_keep_gross(self):
|
||||
self._enable_reverse_charge()
|
||||
self.tr19.keep_gross_if_rate_changes = True
|
||||
self.tr19.save()
|
||||
self.ticket.default_price = 24
|
||||
self.ticket.save()
|
||||
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._set_session('payment', 'banktransfer')
|
||||
|
||||
response = self.client.post('/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), follow=True)
|
||||
doc = BeautifulSoup(response.content.decode(), "lxml")
|
||||
self.assertEqual(len(doc.select(".alert-danger")), 1)
|
||||
with scopes_disabled():
|
||||
cr1 = CartPosition.objects.get(id=cr1.id)
|
||||
self.assertEqual(cr1.price, Decimal('24.00'))
|
||||
|
||||
def test_confirm_price_not_changed_reverse_charge_keep_gross(self):
|
||||
self._enable_reverse_charge()
|
||||
self.tr19.keep_gross_if_rate_changes = True
|
||||
self.tr19.save()
|
||||
with scopes_disabled():
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
price=23, expires=now() - timedelta(minutes=10)
|
||||
)
|
||||
self._set_session('payment', 'banktransfer')
|
||||
|
||||
response = self.client.post('/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), follow=True)
|
||||
doc = BeautifulSoup(response.content.decode(), "lxml")
|
||||
self.assertEqual(len(doc.select(".thank-you")), 1)
|
||||
with scopes_disabled():
|
||||
op = OrderPosition.objects.get()
|
||||
self.assertEqual(op.price, Decimal('23.00'))
|
||||
self.assertEqual(op.tax_value, Decimal('0.00'))
|
||||
self.assertEqual(op.tax_rate, Decimal('0.00'))
|
||||
|
||||
def test_confirm_price_changed(self):
|
||||
self.ticket.default_price = 24
|
||||
self.ticket.save()
|
||||
|
||||
Reference in New Issue
Block a user