Backend UX: Hide advanced tax rule settings

This commit is contained in:
Raphael Michel
2018-03-26 10:15:36 +02:00
parent 12b5e21314
commit 28a628ec93
2 changed files with 96 additions and 76 deletions

View File

@@ -125,6 +125,10 @@ class TaxRule(LoggedModel):
s += ' ({})'.format(_('reverse charge enabled')) s += ' ({})'.format(_('reverse charge enabled'))
return str(s) return str(s)
@property
def has_custom_rules(self):
return self.custom_rules and self.custom_rules != '[]'
def tax(self, base_price, base_price_is='auto'): def tax(self, base_price, base_price_is='auto'):
if self.rate == Decimal('0.00'): if self.rate == Decimal('0.00'):
return TaxedPrice( return TaxedPrice(

View File

@@ -20,85 +20,101 @@
{% bootstrap_form_errors form %} {% bootstrap_form_errors form %}
{% bootstrap_field form.name layout="control" %} {% bootstrap_field form.name layout="control" %}
{% bootstrap_field form.rate addon_after="%" layout="control" %} {% bootstrap_field form.rate addon_after="%" layout="control" %}
<legend>{% trans "Advanced settings" %}</legend>
<div class="alert alert-warning">
<span class="fa fa-fw fa-legal fa-4x pull-left"></span>
{% blocktrans trimmed with docs="https://docs.pretix.eu/en/latest/user/events/taxes.html" %}
These settings are intended for advanced users. See the <a href="{{ docs }}">documentation</a>
for more information. Note that we are not responsible for the correct handling
of taxes in your ticket shop. If in doubt, please contact a lawyer or tax consultant.
{% endblocktrans %}
<div class="clearfix"></div>
</div>
{% bootstrap_field form.price_includes_tax layout="control" %}
{% bootstrap_field form.eu_reverse_charge layout="control" %}
{% bootstrap_field form.home_country layout="control" %}
<legend>{% trans "Custom taxation rules" %}</legend>
<div class="alert alert-warning">
<span class="fa fa-fw fa-exclamation-circle fa-4x pull-left"></span>
{% blocktrans trimmed %}
These settings are intended for professional users with very specific taxation situations.
If you create any rule here, the reverse charge settings above will be ignored. The rules will be
checked in order and once the first rule matches the order, it will be used and all further rules will
be ignored. If no rule matches, tax will be charged.
{% endblocktrans %}
<div class="clearfix"></div>
</div>
<div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}"> <div class="panel panel-default">
{{ formset.management_form }} <div class="panel-heading">
{% bootstrap_formset_errors formset %} <h4 class="panel-title">
<div data-formset-body> <a data-toggle="collapse" href="#advanced">
{% for form in formset %} <strong>{% trans "Advanced settings" %}</strong>
{% bootstrap_form_errors form %} <i class="fa fa-angle-down collapse-indicator"></i>
<div class="row" data-formset-form> </a>
<div class="sr-only"> </h4>
{{ form.id }}
{% bootstrap_field form.DELETE form_group_class="" layout="inline" %}
</div>
<div class="col-sm-4">
{% bootstrap_field form.country layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field form.address_type layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-2 text-right">
<button type="button" class="btn btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
</div>
{% endfor %}
</div> </div>
<script type="form-template" data-formset-empty-form> <div id="advanced" class="panel-collapse collapsed {% if rule.eu_reverse_charge or rule.has_custom_rules or form.errors %}in{% endif %}">
{% escapescript %} <div class="panel-body">
<div class="row" data-formset-form> <legend>{% trans "Advanced settings" %}</legend>
<div class="sr-only"> <div class="alert alert-warning">
{{ form.id }} <span class="fa fa-fw fa-legal fa-4x pull-left"></span>
{% bootstrap_field formset.empty_form.DELETE form_group_class="" layout="inline" %} {% blocktrans trimmed with docs="https://docs.pretix.eu/en/latest/user/events/taxes.html" %}
</div> These settings are intended for advanced users. See the
<div class="col-sm-4"> <a href="{{ docs }}">documentation</a>
{% bootstrap_field formset.empty_form.country layout='inline' form_group_class="" %} for more information. Note that we are not responsible for the correct handling
</div> of taxes in your ticket shop. If in doubt, please contact a lawyer or tax consultant.
<div class="col-sm-3"> {% endblocktrans %}
{% bootstrap_field formset.empty_form.address_type layout='inline' form_group_class="" %} <div class="clearfix"></div>
</div>
<div class="col-sm-3">
{% bootstrap_field formset.empty_form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-2 text-right">
<button type="button" class="btn btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
</div> </div>
{% endescapescript %} {% bootstrap_field form.price_includes_tax layout="control" %}
</script> {% bootstrap_field form.eu_reverse_charge layout="control" %}
<p> {% bootstrap_field form.home_country layout="control" %}
<button type="button" class="btn btn-default" data-formset-add> <legend>{% trans "Custom taxation rules" %}</legend>
<i class="fa fa-plus"></i> {% trans "Add a new rule" %}</button> <div class="alert alert-warning">
</p> <span class="fa fa-fw fa-exclamation-circle fa-4x pull-left"></span>
{% blocktrans trimmed %}
These settings are intended for professional users with very specific taxation situations.
If you create any rule here, the reverse charge settings above will be ignored. The rules will be
checked in order and once the first rule matches the order, it will be used and all further rules will
be ignored. If no rule matches, tax will be charged.
{% endblocktrans %}
<div class="clearfix"></div>
</div>
<div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}">
{{ formset.management_form }}
{% bootstrap_formset_errors formset %}
<div data-formset-body>
{% for form in formset %}
{% bootstrap_form_errors form %}
<div class="row" data-formset-form>
<div class="sr-only">
{{ form.id }}
{% bootstrap_field form.DELETE form_group_class="" layout="inline" %}
</div>
<div class="col-sm-4">
{% bootstrap_field form.country layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field form.address_type layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-2 text-right">
<button type="button" class="btn btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
</div>
{% endfor %}
</div>
<script type="form-template" data-formset-empty-form>
{% escapescript %}
<div class="row" data-formset-form>
<div class="sr-only">
{{ form.id }}
{% bootstrap_field formset.empty_form.DELETE form_group_class="" layout="inline" %}
</div>
<div class="col-sm-4">
{% bootstrap_field formset.empty_form.country layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field formset.empty_form.address_type layout='inline' form_group_class="" %}
</div>
<div class="col-sm-3">
{% bootstrap_field formset.empty_form.action layout='inline' form_group_class="" %}
</div>
<div class="col-sm-2 text-right">
<button type="button" class="btn btn-danger" data-formset-delete-button>
<i class="fa fa-trash"></i></button>
</div>
</div>
{% endescapescript %}
</script>
<p>
<button type="button" class="btn btn-default" data-formset-add>
<i class="fa fa-plus"></i> {% trans "Add a new rule" %}</button>
</p>
</div>
</div>
</div>
</div> </div>