forked from CGM_Public/pretix_original
Fixed #23 -- Tax handling for payment fees
This commit is contained in:
26
src/pretix/base/migrations/0011_auto_20160311_2052.py
Normal file
26
src/pretix/base/migrations/0011_auto_20160311_2052.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.2 on 2016-03-11 20:52
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pretixbase', '0010_orderposition_secret'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='order',
|
||||
name='payment_fee_tax_rate',
|
||||
field=models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='Payment method fee tax rate'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='order',
|
||||
name='payment_fee_tax_value',
|
||||
field=models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='Payment method fee tax'),
|
||||
),
|
||||
]
|
||||
@@ -123,6 +123,14 @@ class Order(LoggedModel):
|
||||
decimal_places=2, max_digits=10,
|
||||
default=0, verbose_name=_("Payment method fee")
|
||||
)
|
||||
payment_fee_tax_rate = models.DecimalField(
|
||||
decimal_places=2, max_digits=10,
|
||||
verbose_name=_("Payment method fee tax rate")
|
||||
)
|
||||
payment_fee_tax_value = models.DecimalField(
|
||||
decimal_places=2, max_digits=10,
|
||||
default=0, verbose_name=_("Payment method fee tax")
|
||||
)
|
||||
payment_info = models.TextField(
|
||||
verbose_name=_("Payment information"),
|
||||
null=True, blank=True
|
||||
@@ -157,8 +165,18 @@ class Order(LoggedModel):
|
||||
self.assign_code()
|
||||
if not self.datetime:
|
||||
self.datetime = now()
|
||||
if self.payment_fee_tax_rate is None:
|
||||
self._calculate_tax()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def _calculate_tax(self):
|
||||
self.payment_fee_tax_rate = self.event.settings.get('tax_rate_default')
|
||||
if self.payment_fee_tax_rate:
|
||||
self.payment_fee_tax_value = round_decimal(
|
||||
self.payment_fee * (1 - 100 / (100 + self.payment_fee_tax_rate)))
|
||||
else:
|
||||
self.payment_fee_tax_value = Decimal('0.00')
|
||||
|
||||
def assign_code(self):
|
||||
charset = list('ABCDEFGHKLMNPQRSTUVWXYZ23456789')
|
||||
while True:
|
||||
|
||||
@@ -57,6 +57,10 @@ DEFAULTS = {
|
||||
'default': 'True',
|
||||
'type': bool
|
||||
},
|
||||
'tax_rate_default': {
|
||||
'default': '0.00',
|
||||
'type': decimal.Decimal
|
||||
},
|
||||
'show_items_outside_presale_period': {
|
||||
'default': 'True',
|
||||
'type': bool
|
||||
|
||||
@@ -108,6 +108,11 @@ class EventSettingsForm(SettingsForm):
|
||||
"answers to questions."),
|
||||
required=False
|
||||
)
|
||||
tax_rate_default = forms.DecimalField(
|
||||
label=_('Tax rate for payment fees'),
|
||||
help_text=_("The tax rate that applies for additional fees you configured for single payment methods "
|
||||
"(in percent)."),
|
||||
)
|
||||
timezone = forms.ChoiceField(
|
||||
choices=((a, a) for a in common_timezones),
|
||||
label=_("Default timezone"),
|
||||
|
||||
@@ -36,14 +36,18 @@
|
||||
{% bootstrap_field sform.last_order_modification_date layout="horizontal" %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Order process settings" %}</legend>
|
||||
<legend>{% trans "Orders" %}</legend>
|
||||
{% bootstrap_field sform.reservation_time layout="horizontal" %}
|
||||
{% bootstrap_field sform.max_items_per_order layout="horizontal" %}
|
||||
{% bootstrap_field sform.attendee_names_asked layout="horizontal" %}
|
||||
{% bootstrap_field sform.attendee_names_required layout="horizontal" %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Invoicing" %}</legend>
|
||||
{% bootstrap_field sform.invoice_address_asked layout="horizontal" %}
|
||||
{% bootstrap_field sform.invoice_address_required layout="horizontal" %}
|
||||
{% bootstrap_field sform.invoice_address_vatid layout="horizontal" %}
|
||||
{% bootstrap_field sform.tax_rate_default layout="horizontal" %}
|
||||
</fieldset>
|
||||
<div class="form-group submit-group">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
|
||||
@@ -134,13 +134,18 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if items.payment_fee %}
|
||||
{# TODO: Tax rate? #}
|
||||
<div class="row-fluid product-row">
|
||||
<div class="col-md-4 col-xs-6">
|
||||
<strong>{% trans "Payment method fee" %}</strong>
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
|
||||
<strong>{{ event.currency }} {{ items.payment_fee|floatformat:2 }}</strong>
|
||||
{% if order.payment_fee_tax_rate %}
|
||||
<br/>
|
||||
<small>{% blocktrans trimmed with rate=order.payment_fee_tax_rate %}
|
||||
incl. {{ rate }}% taxes
|
||||
{% endblocktrans %}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
@@ -76,6 +76,12 @@
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
|
||||
<strong>{{ event.currency }} {{ cart.payment_fee|floatformat:2 }}</strong>
|
||||
{% if event.settings.tax_rate_default %}
|
||||
<br/>
|
||||
<small>{% blocktrans trimmed with rate=event.settings.tax_rate_default %}
|
||||
incl. {{ rate }}% taxes
|
||||
{% endblocktrans %}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user