invoices: unified money, number and date formats and fully respect configured language (#1814)

This commit is contained in:
Kevin Papst
2020-07-10 15:09:52 +02:00
committed by GitHub
parent 19e4ebf88c
commit 32c1e3258e
67 changed files with 1593 additions and 2335 deletions

View File

@@ -22,7 +22,7 @@
{{ model.template.title }}
</td>
<td class="date">
{{ 'label.date'|trans({}, 'messages', language) }}: {{ model.invoiceDate|date_short }}
{{ 'label.date'|trans }}: {{ model.invoiceDate|date_short }}
</td>
</tr>
</table>
@@ -32,10 +32,10 @@
<table class="footer">
<tr>
<td>
<strong>{{ 'label.contact'|trans({}, 'messages', language) }}</strong>:
<strong>{{ 'label.contact'|trans }}</strong>:
{{ model.template.contact|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<br>
<strong>{{ 'label.invoice_bank_account'|trans({}, 'messages', language) }}</strong>:
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>:
{{ model.template.paymentDetails|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
</td>
<td align="right">
@@ -50,33 +50,33 @@ mpdf-->
<table class="addresses">
<tr>
<td width="60%">
{{ 'invoice.to'|trans({}, 'messages', language) }}
{{ 'invoice.to'|trans }}
<br>
<strong>{{ model.customer.company|default(model.customer.name) }}</strong>
<br>
{{ model.customer.address|nl2br }}
{% if model.customer.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans({}, 'messages', language) }}: {{ model.customer.vatId }}
{{ 'label.vat_id'|trans }}: {{ model.customer.vatId }}
{% endif %}
{% if model.customer.number is not empty %}
<br>
{{ 'label.number'|trans({}, 'messages', language) }}: {{ model.customer.number }}
{{ 'label.number'|trans }}: {{ model.customer.number }}
{% endif %}
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<br>
{{ 'label.orderNumber'|trans({}, 'messages', language) }}: {{ model.query.project.orderNumber }}
{{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }}
{% endif %}
</td>
<td>
{{ 'invoice.from'|trans({}, 'messages', language) }}
{{ 'invoice.from'|trans }}
<br>
<strong>{{ model.template.company }}</strong>
<br>
{{ model.template.address|trim|nl2br }}
{% if model.template.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans({}, 'messages', language) }}:
{{ 'label.vat_id'|trans }}:
{{ model.template.vatId }}
{% endif %}
</td>
@@ -84,22 +84,22 @@ mpdf-->
</table>
<p>
<strong>{{ 'invoice.number'|trans({}, 'messages', language) }}:</strong>
<strong>{{ 'invoice.number'|trans }}:</strong>
{{ model.invoiceNumber }}
<br>
<strong>{{ 'invoice.due_days'|trans({}, 'messages', language) }}:</strong>
<strong>{{ 'invoice.due_days'|trans }}:</strong>
{{ model.dueDate|date_short }}
</p>
<table class="items">
<thead>
<tr>
<th class="first">{{ 'label.date'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.description'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.unit_price'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.amount'|trans({}, 'messages', language) }}</th>
<th class="last text-right">{{ 'label.total_rate'|trans({}, 'messages', language) }}</th>
<th class="first">{{ 'label.date'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
<th class="text-right">{{ 'label.unit_price'|trans }}</th>
<th class="text-right">{{ 'label.amount'|trans }}</th>
<th class="last text-right">{{ 'label.total_rate'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -129,19 +129,19 @@ mpdf-->
<tfoot>
<tr>
<td colspan="4" class="text-right">
{{ 'invoice.subtotal'|trans({}, 'messages', language) }}
{{ 'invoice.subtotal'|trans }}
</td>
<td class="last text-right">{{ model.calculator.subtotal|money(currency) }}</td>
</tr>
<tr>
<td colspan="4" class="text-right">
{{ 'invoice.tax'|trans({}, 'messages', language) }} ({{ model.calculator.vat }}%)
{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)
</td>
<td class="last text-right">{{ model.calculator.tax|money(currency) }}</td>
</tr>
<tr>
<td colspan="4" class="text-right text-nowrap">
<strong>{{ 'invoice.total'|trans({}, 'messages', language) }}</strong>
<strong>{{ 'invoice.total'|trans }}</strong>
</td>
<td class="last text-right">
<strong>{{ model.calculator.total|money(currency) }}</strong>

View File

@@ -1,48 +1,46 @@
{% extends 'invoice/layout.html.twig' %}
{% set fallback = app.request is not null ? app.request.locale : 'en' %}
{% set language = model.template.language|default(fallback) %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set currency = model.currency %}
{% block invoice %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set currency = model.currency %}
<div class="row">
<div class="col-xs-12">
<h2 class="page-header">
<span contenteditable="true">{{ model.template.title }}</span>
<small class="pull-right">{{ 'label.date'|trans({}, 'messages', language) }}: {{ model.invoiceDate|date_short }}</small>
<small class="pull-right">{{ 'label.date'|trans }}: {{ model.invoiceDate|date_short }}</small>
</h2>
</div>
</div>
<div class="row">
<div class="col-sm-5">
{{ 'invoice.to'|trans({}, 'messages', language) }}
{{ 'invoice.to'|trans }}
<address contenteditable="true">
<strong>{{ model.customer.company|default(model.customer.name) }}</strong><br>
{{ model.customer.address|nl2br }}
{% if model.customer.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans({}, 'messages', language) }}: {{ model.customer.vatId }}
{{ 'label.vat_id'|trans }}: {{ model.customer.vatId }}
{% endif %}
{% if model.customer.number is not empty %}
<br>
{{ 'label.number'|trans({}, 'messages', language) }}: {{ model.customer.number }}
{{ 'label.number'|trans }}: {{ model.customer.number }}
{% endif %}
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<br>
{{ 'label.orderNumber'|trans({}, 'messages', language) }}: {{ model.query.project.orderNumber }}
{{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }}
{% endif %}
</address>
</div>
<div class="col-sm-2"></div>
<div class="col-sm-5">
{{ 'invoice.from'|trans({}, 'messages', language) }}
{{ 'invoice.from'|trans }}
<address contenteditable="true">
<strong>{{ model.template.company }}</strong><br>
{{ model.template.address|trim|nl2br }}
{% if model.template.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans({}, 'messages', language) }}:
{{ 'label.vat_id'|trans }}:
{{ model.template.vatId }}
{% endif %}
</address>
@@ -52,11 +50,11 @@
<div class="row">
<div class="col-sm-5">
<p contenteditable="true">
<strong>{{ 'invoice.number'|trans({}, 'messages', language) }}:</strong>
<strong>{{ 'invoice.number'|trans }}:</strong>
{{ model.invoiceNumber }}
<br>
<strong>{{ 'invoice.due_days'|trans({}, 'messages', language) }}:</strong>
<strong>{{ 'invoice.due_days'|trans }}:</strong>
{{ model.dueDate|date_short }}
</p>
</div>
@@ -68,11 +66,11 @@
<table class="table">
<thead>
<tr>
<th>{{ 'label.date'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.description'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.unit_price'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.amount'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.total_rate'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.date'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
<th class="text-right">{{ 'label.unit_price'|trans }}</th>
<th class="text-right">{{ 'label.amount'|trans }}</th>
<th class="text-right">{{ 'label.total_rate'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -102,19 +100,19 @@
<tfoot>
<tr>
<td colspan="4" class="text-right">
{{ 'invoice.subtotal'|trans({}, 'messages', language) }}
{{ 'invoice.subtotal'|trans }}
</td>
<td class="text-right">{{ model.calculator.subtotal|money(currency) }}</td>
</tr>
<tr>
<td colspan="4" class="text-right">
{{ 'invoice.tax'|trans({}, 'messages', language) }} ({{ model.calculator.vat }}%)
{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)
</td>
<td class="text-right">{{ model.calculator.tax|money(currency) }}</td>
</tr>
<tr>
<td colspan="4" class="text-right text-nowrap">
<strong>{{ 'invoice.total'|trans({}, 'messages', language) }}</strong>
<strong>{{ 'invoice.total'|trans }}</strong>
</td>
<td class="text-right">
<strong>{{ model.calculator.total|money(currency) }}</strong>
@@ -137,12 +135,11 @@
<footer class="footer">
<p>
<strong>{{ 'label.address'|trans({}, 'messages', language) }}</strong>: {{ model.template.company }} &ndash; {{ model.template.address|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<strong>{{ 'label.address'|trans }}</strong>: {{ model.template.company }} &ndash; {{ model.template.address|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<br>
<strong>{{ 'label.invoice_bank_account'|trans({}, 'messages', language) }}</strong>: {{ model.template.paymentDetails|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>: {{ model.template.paymentDetails|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<br>
<strong>{{ 'label.contact'|trans({}, 'messages', language) }}</strong>: {{ model.template.contact|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<strong>{{ 'label.contact'|trans }}</strong>: {{ model.template.contact|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
</p>
</footer>
{% endblock %}

View File

@@ -1,11 +1,9 @@
{% import "macros/widgets.html.twig" as widgets %}
{% extends 'invoice/layout.html.twig' %}
{% set fallback = app.request is not null ? app.request.locale : 'en' %}
{% set language = model.template.language|default(fallback) %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set currency = model.currency %}
{% block invoice %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set currency = model.currency %}
<div class="row" id="freelancer-invoice">
<div class="col-xs-12">
<header>
@@ -14,33 +12,33 @@
</address>
</header>
<article class="address">
<h1>{{ 'invoice.to'|trans({}, 'messages', language) }}</h1>
<h1>{{ 'invoice.to'|trans }}</h1>
<address>
<p>
<strong>{{ model.customer.company|default(model.customer.name) }}</strong><br>
{{ model.customer.address|nl2br }}
{% if model.customer.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans({}, 'messages', language) }}: {{ model.customer.vatId }}
{{ 'label.vat_id'|trans }}: {{ model.customer.vatId }}
{% endif %}
</p>
</address>
<table class="meta">
<tr>
<th>{{ 'label.date'|trans({}, 'messages', language) }}:</th>
<th>{{ 'label.date'|trans }}:</th>
<td contenteditable="true">{{ model.invoiceDate|date_short }}</td>
</tr>
<tr>
<th>{{ 'invoice.service_date'|trans({}, 'messages', language) }}:</th>
<td><span contenteditable="true">{{ model.query.end|month_name|trans({}, 'messages', language) }} {{ model.query.end|date('Y') }}</span></td>
<th>{{ 'invoice.service_date'|trans }}:</th>
<td><span contenteditable="true">{{ model.query.end|month_name }} {{ model.query.end|date('Y') }}</span></td>
</tr>
<tr>
<th>{{ 'invoice.number'|trans({}, 'messages', language) }}:</th>
<th>{{ 'invoice.number'|trans }}:</th>
<td>{{ model.invoiceNumber }}</td>
</tr>
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<tr>
<th>{{ 'label.orderNumber'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.orderNumber'|trans }}</th>
<td contenteditable="true">
{{ model.query.project.orderNumber }}
</td>
@@ -48,7 +46,7 @@
{% endif %}
{% if model.template.vatId is not empty %}
<tr>
<th>{{ 'label.vat_id'|trans({}, 'messages', language) }}:</th>
<th>{{ 'label.vat_id'|trans }}:</th>
<td>
{{ model.template.vatId }}
</td>
@@ -61,10 +59,10 @@
<table class="inventory">
<thead>
<tr>
<th>{{ 'label.description'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.unit_price'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.amount'|trans({}, 'messages', language) }}</th>
<th class="text-right">{{ 'label.total_rate'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.description'|trans }}</th>
<th class="text-right">{{ 'label.unit_price'|trans }}</th>
<th class="text-right">{{ 'label.amount'|trans }}</th>
<th class="text-right">{{ 'label.total_rate'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -94,15 +92,15 @@
</table>
<table class="balance">
<tr>
<th>{{ 'invoice.subtotal'|trans({}, 'messages', language) }}</th>
<th>{{ 'invoice.subtotal'|trans }}</th>
<td>{{ model.calculator.subtotal|money(currency) }}</td>
</tr>
<tr>
<th>{{ 'invoice.tax'|trans({}, 'messages', language) }} ({{ model.calculator.vat }}%)</th>
<th>{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)</th>
<td>{{ model.calculator.tax|money(currency) }}</td>
</tr>
<tr>
<th class="total">{{ 'invoice.total'|trans({}, 'messages', language) }}</th>
<th class="total">{{ 'invoice.total'|trans }}</th>
<td class="total">{{ model.calculator.total|money(currency) }}</td>
</tr>
</table>
@@ -118,7 +116,7 @@
<div class="row">
<div class="col-sm-4" contenteditable="true">
<p>
<strong>{{ 'label.address'|trans({}, 'messages', language) }}</strong>
<strong>{{ 'label.address'|trans }}</strong>
</p>
<p>
{{ model.template.company }}<br>
@@ -127,7 +125,7 @@
</div>
<div class="col-sm-4 text-center" contenteditable="true">
<p>
<strong>{{ 'label.invoice_bank_account'|trans({}, 'messages', language) }}</strong>
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>
</p>
<p>
{{ model.template.paymentDetails|nl2br }}
@@ -135,7 +133,7 @@
</div>
<div class="col-sm-4 text-right" contenteditable="true">
<p>
<strong>{{ 'label.contact'|trans({}, 'messages', language) }}</strong>
<strong>{{ 'label.contact'|trans }}</strong>
</p>
<p>
{{ model.template.contact|nl2br }}

View File

@@ -1,10 +1,8 @@
{% import "macros/widgets.html.twig" as widgets %}
{% extends 'invoice/layout.html.twig' %}
{% set fallback = app.request is not null ? app.request.locale : 'en' %}
{% set language = model.template.language|default(fallback) %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% block invoice %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
<div class="row">
<div class="col-xs-12">
<h2 class="page-header">
@@ -17,7 +15,7 @@
<div class="col-xs-12">
<table class="table no-border table-condensed">
<tr>
<th>{{ 'invoice.from'|trans({}, 'messages', language) }}</th>
<th>{{ 'invoice.from'|trans }}</th>
<td contenteditable="true">
{% if model.query.user is not empty %}
{{ widgets.username(model.query.user) }}
@@ -27,17 +25,17 @@
</td>
</tr>
<tr>
<th>{{ 'label.date'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.date'|trans }}</th>
<td contenteditable="true">
{% if model.query.begin|date('m') != model.query.end|date('m') or model.query.begin|date('Y') != model.query.end|date('Y') %}
{{ model.query.begin|date_short }} - {{ model.query.end|date_short }}
{% else %}
{{ model.query.end|month_name|trans({}, 'messages', language) }} {{ model.query.end|date('Y') }}
{{ model.query.end|month_name }} {{ model.query.end|date('Y') }}
{% endif %}
</td>
</tr>
<tr>
<th>{{ 'label.customer'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.customer'|trans }}</th>
<td contenteditable="true">
{% if model.customer.number is not empty %}[{{ model.customer.number }}]{% endif %}
{{ model.customer.name }}{% if model.customer.contact is not empty %} / {{ model.customer.contact }}{% endif %}
@@ -45,7 +43,7 @@
</tr>
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<tr>
<th>{{ 'label.orderNumber'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.orderNumber'|trans }}</th>
<td contenteditable="true">
{{ model.query.project.orderNumber }}
</td>
@@ -60,12 +58,12 @@
<table class="table table-striped">
<thead>
<tr>
<th>{{ 'label.date'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.date'|trans }}</th>
{% if model.query.user is empty %}
<th>{{ 'label.user'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.user'|trans }}</th>
{% endif %}
<th>{{ 'label.activity'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.hours'|trans({}, 'messages', language) }}</th>
<th>{{ 'label.activity'|trans }}</th>
<th>{{ 'label.hours'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -92,7 +90,7 @@
{% if model.query.user is empty %}
<th></th>
{% endif %}
<th>{{ 'invoice.total_working_time'|trans({}, 'messages', language) }}</th>
<th>{{ 'invoice.total_working_time'|trans }}</th>
<th class="text-nowrap">{{ model.calculator.timeWorked|duration(isDecimal) }}</th>
</tr>
</tfoot>
@@ -103,7 +101,7 @@
<div class="row">
<div class="col-xs-12">
{% if model.template.paymentTerms is not empty %}
<p class="lead">{{ 'label.payment_terms'|trans({}, 'messages', language) }}</p>
<p class="lead">{{ 'label.payment_terms'|trans }}</p>
<p class="text-muted well well-sm no-shadow" contenteditable="true" style="margin-bottom: 100px">
{{ model.template.paymentTerms|trim|nl2br }}
@@ -114,10 +112,10 @@
<table class="table">
<tbody>
<tr>
<th style="padding-bottom: 60px">{{ 'invoice.signature_user'|trans({}, 'messages', language) }}</th>
<th style="padding-bottom: 60px">{{ 'invoice.signature_user'|trans }}</th>
</tr>
<tr>
<th>{{ 'invoice.signature_customer'|trans({}, 'messages', language) }}</th>
<th>{{ 'invoice.signature_customer'|trans }}</th>
</tr>
</tbody>
</table>