Refs #99 -- Improve support for currencies with less than 2 decimal places (#783)

* Refs #99 -- Fix stripe support for zero-decimal currencies

* Add new money formatting method

* Force decimal places in many places

* Locale-aware currency rendering

* Fix currencies in more places

* More currency fixes
This commit is contained in:
Raphael Michel
2018-02-26 10:46:07 +01:00
committed by GitHub
parent 29e22a0c6c
commit 3c3e59e932
49 changed files with 467 additions and 211 deletions

View File

@@ -2,6 +2,7 @@
{% load i18n %}
{% load bootstrap3 %}
{% load eventurl %}
{% load money %}
{% load safelink %}
{% load eventsignal %}
{% block title %}
@@ -257,7 +258,7 @@
</div>
<div class="col-md-3 col-xs-6 price">
{% if event.settings.display_net_prices %}
<strong>{{ event.currency }} {{ line.net_price|floatformat:2 }}</strong>
<strong>{{ line.net_price|money:event.currency }}</strong>
{% if line.tax_rate %}
<br />
<small>
@@ -267,7 +268,7 @@
</small>
{% endif %}
{% else %}
<strong>{{ event.currency }} {{ line.price|floatformat:2 }}</strong>
<strong>{{ line.price|money:event.currency }}</strong>
{% if line.tax_rate and line.price %}
<br />
<small>
@@ -291,7 +292,7 @@
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{% if event.settings.display_net_prices %}
<strong>{{ event.currency }} {{ fee.net_value|floatformat:2 }}</strong>
<strong>{{ fee.net_value|money:event.currency }}</strong>
{% if fee.tax_rate %}
<br/>
<small>
@@ -301,7 +302,7 @@
</small>
{% endif %}
{% else %}
<strong>{{ event.currency }} {{ fee.value|floatformat:2 }}</strong>
<strong>{{ fee.value|money:event.currency }}</strong>
{% if fee.tax_rate %}
<br/>
<small>
@@ -321,7 +322,7 @@
<strong>{% trans "Net total" %}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{{ event.currency }} {{ items.net_total|floatformat:2 }}
{{ items.net_total|money:event.currency }}
</div>
<div class="clearfix"></div>
</div>
@@ -330,7 +331,7 @@
<strong>{% trans "Taxes" %}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{{ event.currency }} {{ items.tax_total|floatformat:2 }}
{{ items.tax_total|money:event.currency }}
</div>
<div class="clearfix"></div>
</div>
@@ -340,7 +341,7 @@
<strong>{% trans "Total" %}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
<strong>{{ event.currency }} {{ items.total|floatformat:2 }}</strong>
<strong>{{ items.total|money:event.currency }}</strong>
</div>
<div class="clearfix"></div>
</div>

View File

@@ -2,6 +2,7 @@
{% load i18n %}
{% load eventurl %}
{% load urlreplace %}
{% load money %}
{% load bootstrap3 %}
{% block title %}{% trans "Orders" %}{% endblock %}
{% block content %}
@@ -114,7 +115,7 @@
{% endif %}
</td>
<td>{{ o.datetime|date:"SHORT_DATETIME_FORMAT" }}</td>
<td class="text-right">{{ o.total|floatformat:2 }} {{ request.event.currency }}</td>
<td class="text-right">{{ o.total|money:request.event.currency }}</td>
<td class="text-right">{{ o.pcnt }}</td>
<td class="text-right">{% include "pretixcontrol/orders/fragment_order_status.html" with order=o %}</td>
</tr>

View File

@@ -50,12 +50,12 @@
{% if tup.0 %}
<tr class="category">
<th>{{ tup.0.name }}</th>
<th>{{ tup.0.num_canceled|togglesum }}</th>
<th>{{ tup.0.num_refunded|togglesum }}</th>
<th>{{ tup.0.num_expired|togglesum }}</th>
<th>{{ tup.0.num_pending|togglesum }}</th>
<th>{{ tup.0.num_paid|togglesum }}</th>
<th>{{ tup.0.num_total|togglesum }}</th>
<th>{{ tup.0.num_canceled|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num_refunded|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num_expired|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num_pending|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num_paid|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num_total|togglesum:request.event.currency }}</th>
</tr>
{% endif %}
{% for item in tup.1 %}
@@ -63,43 +63,43 @@
<td>{{ item.name }}</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=c&amp;provider={{ item.provider }}">
{{ item.num_canceled|togglesum }}
{{ item.num_canceled|togglesum:request.event.currency }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=r&amp;provider={{ item.provider }}">
{{ item.num_refunded|togglesum }}
{{ item.num_refunded|togglesum:request.event.currency }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=e&amp;provider={{ item.provider }}">
{{ item.num_expired|togglesum }}
{{ item.num_expired|togglesum:request.event.currency }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=n&amp;provider={{ item.provider }}">
{{ item.num_pending|togglesum }}
{{ item.num_pending|togglesum:request.event.currency }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=p&amp;provider={{ item.provider }}">
{{ item.num_paid|togglesum }}
{{ item.num_paid|togglesum:request.event.currency }}
</a>
</td>
<td>
{{ item.num_total|togglesum }}
{{ item.num_total|togglesum:request.event.currency }}
</td>
</tr>
{% if item.has_variations %}
{% for var in item.all_variations %}
<tr class="variation {% if tup.0 %}categorized{% endif %}">
<td>{{ var }}</td>
<td>{{ var.num_canceled|togglesum }}</td>
<td>{{ var.num_refunded|togglesum }}</td>
<td>{{ var.num_expired|togglesum }}</td>
<td>{{ var.num_pending|togglesum }}</td>
<td>{{ var.num_paid|togglesum }}</td>
<td>{{ var.num_total|togglesum }}</td>
<td>{{ var.num_canceled|togglesum:request.event.currency }}</td>
<td>{{ var.num_refunded|togglesum:request.event.currency }}</td>
<td>{{ var.num_expired|togglesum:request.event.currency }}</td>
<td>{{ var.num_pending|togglesum:request.event.currency }}</td>
<td>{{ var.num_paid|togglesum:request.event.currency }}</td>
<td>{{ var.num_total|togglesum:request.event.currency }}</td>
</tr>
{% endfor %}
{% endif %}
@@ -109,12 +109,12 @@
<tfoot>
<tr class="total">
<th>{% trans "Total" %}</th>
<th>{{ total.num_canceled|togglesum }}</th>
<th>{{ total.num_refunded|togglesum }}</th>
<th>{{ total.num_expired|togglesum }}</th>
<th>{{ total.num_pending|togglesum }}</th>
<th>{{ total.num_paid|togglesum }}</th>
<th>{{ total.num_total|togglesum }}</th>
<th>{{ total.num_canceled|togglesum:request.event.currency }}</th>
<th>{{ total.num_refunded|togglesum:request.event.currency }}</th>
<th>{{ total.num_expired|togglesum:request.event.currency }}</th>
<th>{{ total.num_pending|togglesum:request.event.currency }}</th>
<th>{{ total.num_paid|togglesum:request.event.currency }}</th>
<th>{{ total.num_total|togglesum:request.event.currency }}</th>
</tr>
</tfoot>
</table>

View File

@@ -2,6 +2,7 @@
{% load i18n %}
{% load eventurl %}
{% load urlreplace %}
{% load money %}
{% load bootstrap3 %}
{% block title %}{% trans "Order search" %}{% endblock %}
{% block content %}
@@ -70,7 +71,7 @@
{% endif %}
</td>
<td>{{ o.datetime|date:"SHORT_DATETIME_FORMAT" }}</td>
<td class="text-right">{{ o.total|floatformat:2 }} {{ o.event.currency }}</td>
<td class="text-right">{{ o.total|money:o.event.currency }}</td>
<td class="text-right">{% include "pretixcontrol/orders/fragment_order_status.html" with order=o %}</td>
</tr>
{% empty %}

View File

@@ -120,7 +120,7 @@
<fieldset>
<legend>{% trans "Item prices" %}</legend>
{% for f in itemvar_forms %}
{% bootstrap_field f.price layout="control" %}
{% bootstrap_field f.price addon_after=request.event.currency layout="control" %}
{% endfor %}
</fieldset>
<fieldset>

View File

@@ -1,6 +1,7 @@
{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load eventurl %}
{% load money %}
{% load urlreplace %}
{% block title %}{% trans "Waiting list" %}{% endblock %}
{% block content %}
@@ -65,9 +66,9 @@
{% trans "Sales estimate" %}
</div>
<div class="panel-body">
{% blocktrans trimmed with amount=estimate|default:0|floatformat:2 currency=request.event.currency %}
{% blocktrans trimmed with amount=estimate|default:0|money:request.event.currency %}
If you can make enough room at your event to fit all the persons on the waiting list in, you
could sell tickets worth an additional <strong>{{ amount }} {{ currency }}</strong>.
could sell tickets worth an additional <strong>{{ amount }}</strong>.
{% endblocktrans %}
</div>
</div>