added new invoice fields, improved invoice templates (#1258)

This commit is contained in:
Kevin Papst
2019-11-18 12:01:26 +01:00
committed by GitHub
parent 2287c9951c
commit 47bd8b0ce7
50 changed files with 1530 additions and 1222 deletions

View File

@@ -10,56 +10,66 @@
</div>
</div>
<div class="row invoice-info">
<div class="col-sm-4 invoice-col">
<div class="row">
<div class="col-sm-5">
{{ '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 }}:
{{ model.template.vatId }}
{% endif %}
</address>
</div>
<div class="col-sm-4 invoice-col">
<div class="col-sm-2"></div>
<div class="col-sm-5">
{% set customerPhone = model.customer.phone|default(model.customer.mobile) %}
{{ 'invoice.to'|trans }}
<address contenteditable="true">
<strong>{{ model.customer.company|default(model.customer.name) }}</strong><br>
{{ model.customer.address|nl2br }}
{% if model.customer.phone is not empty %}
{% if model.customer.vatId is not empty %}
<br>
{{ 'label.phone'|trans }}: {{ model.customer.phone }}
{{ 'label.vat_id'|trans }}: {{ model.customer.vatId }}
{% endif %}
{% if model.customer.email is not empty %}
<br>
{{ 'label.email'|trans }}: {{ model.customer.email }}
{% endif %}
</address>
</div>
<div class="col-sm-4 invoice-col">
<p contenteditable="true">
<b>{{ 'invoice.number'|trans }}: {{ model.numberGenerator.invoiceNumber }}</b>
</p>
<p contenteditable="true">
<b>{{ 'invoice.due_days'|trans }}:</b> {{ model.dueDate|date_short }}
{% if model.customer.number is not empty %}
<br><b>{{ 'label.number'|trans }}:</b> {{ model.customer.number }}
<br>
{{ 'label.number'|trans }}: {{ model.customer.number }}
{% endif %}
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
<br><b>{{ 'label.orderNumber'|trans }}:</b> {{ model.query.project.orderNumber }}
<br>
{{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }}
{% endif %}
</p>
</address>
</div>
</div>
<div class="row">
<div class="col-sm-5">
<p contenteditable="true">
<strong>{{ 'invoice.number'|trans }}:</strong>
{{ model.numberGenerator.invoiceNumber }}
<br>
<strong>{{ 'invoice.due_days'|trans }}:</strong>
{{ model.dueDate|date_short }}
</p>
</div>
<div class="col-sm-7"></div>
</div>
<div class="row invoice-items">
<div class="col-xs-12 table-responsive">
<table class="table table-striped">
<table class="table">
<thead>
<tr>
<th>{{ 'label.date'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
<th>{{ 'label.unit_price'|trans }}</th>
<th>{{ 'label.hours'|trans }}</th>
<th>{{ 'label.total_rate'|trans }}</th>
<th class="text-center">{{ 'label.hours'|trans }}</th>
<th class="text-right">{{ 'label.total_rate'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -74,7 +84,7 @@
{% set rate = app.user.getPreferenceValue('hourly_rate') %}
{% endif %}
<tr>
<td>{{ entry.begin|date_short }}</td>
<td nowrap class="text-nowrap">{{ entry.begin|date_short }}</td>
<td contenteditable="true">
{% if entry.description is not empty %}
{{ entry.description|nl2br }}
@@ -82,48 +92,56 @@
{{ entry.activity.name }} / {{ entry.project.name }}
{% endif %}
</td>
<td contenteditable="true">{{ rate|money(model.calculator.currency) }}</td>
<td>{{ duration }}</td>
<td>{{ entry.rate|money(model.calculator.currency) }}</td>
<td nowrap class="text-nowrap" contenteditable="true">{{ rate|money(model.calculator.currency) }}</td>
<td nowrap class="text-nowrap text-center">{{ duration }}</td>
<td nowrap class="text-nowrap text-right">{{ entry.rate|money(model.calculator.currency) }}</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right">
{{ 'invoice.subtotal'|trans }}
</td>
<td class="text-right">{{ model.calculator.subtotal|money(model.calculator.currency) }}</td>
</tr>
<tr>
<td colspan="4" class="text-right">
{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)
</td>
<td class="text-right">{{ model.calculator.tax|money(model.calculator.currency) }}</td>
</tr>
<tr>
<td colspan="4" class="text-right">
<strong>{{ 'invoice.total'|trans }}</strong>
</td>
<td class="text-right">
<strong>{{ model.calculator.total|money(model.calculator.currency) }}</strong>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="col-xs-12">
{% if model.template.paymentTerms is not empty %}
<p class="lead">{{ 'label.payment_terms'|trans }}</p>
<p class="text-muted well well-sm no-shadow" contenteditable="true">
{{ model.template.paymentTerms|trim|nl2br }}
<p contenteditable="true" class="paymentTerms">
{{ model.template.paymentTerms|nl2br|md2html }}
</p>
{% endif %}
</div>
<div class="col-xs-6">
<p class="lead" contenteditable="true">{{ 'invoice.due_days'|trans }} {{ model.dueDate|date_short }}</p>
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<th style="width:50%">{{ 'invoice.subtotal'|trans }}</th>
<td>{{ model.calculator.subtotal|money(model.calculator.currency) }}</td>
</tr>
<tr>
<th>{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)</th>
<td>{{ model.calculator.tax|money(model.calculator.currency) }}</td>
</tr>
<tr>
<th>{{ 'invoice.total'|trans }}</th>
<td>{{ model.calculator.total|money(model.calculator.currency) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<footer class="footer">
<p>
<strong>{{ 'label.address'|trans }}</strong>: {{ model.template.address|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<br>
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>: {{ model.template.paymentDetails|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
<br>
<strong>{{ 'label.contact'|trans }}</strong>: {{ model.template.contact|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
</p>
</footer>
{% endblock %}

View File

@@ -1,2 +0,0 @@
start_date,start_timestamp,end_date,end_timestamp,duration,username,description,rate,amount,total
${entry.begin},${entry.begin_timestamp},${entry.end},${entry.end_timestamp},${entry.duration},${entry.user_name},${entry.description},${entry.rate},${entry.amount},${entry.total}
1 start_date start_timestamp end_date end_timestamp duration username description rate amount total
2 ${entry.begin} ${entry.begin_timestamp} ${entry.end} ${entry.end_timestamp} ${entry.duration} ${entry.user_name} ${entry.description} ${entry.rate} ${entry.amount} ${entry.total}

View File

@@ -4,30 +4,18 @@
{% block invoice %}
{# You can overwrite these settings in your config/packages/local.yaml under the key "twig.globals.company" #}
{% set company = company|default({
name: 'Kimai Inc.',
homepage: 'www.kimai.org',
email: 'kimai@example.com',
phone: '0123-4567890',
tax_number: 'YourTaxNumber',
signature: '/build/images/signature.png',
address: 'Kimai Inc.
Example road 42
D 12345 City
',
bank_account: '
Kimai Inc.
IBAN: DE00 0000 0000 0000 0000 00
BIC: XXXXXXXX (a bank name)
'
}) %}
{% set signature = null %}
{# You can overwrite these settings in your config/packages/local.yaml under the key "twig.globals.company" - previously '/build/images/signature.png' #}
{% set company = company|default({signature: null}) %}
{% if company.signature is defined and company.signature is not empty %}
{% set signature = company.signature %}
{% endif %}
<div class="row" id="freelancer-invoice" style="page:invoiceFreelancer;">
<div class="row" id="freelancer-invoice">
<div class="col-xs-12">
<header>
<address>
<p contenteditable="true">{{ model.template.address }}</p>
<p contenteditable="true">{{ model.template.address|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}</p>
</address>
</header>
<article class="address">
@@ -36,6 +24,10 @@
<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 }}: {{ model.customer.vatId }}
{% endif %}
</p>
</address>
<table class="meta">
@@ -59,6 +51,14 @@
</td>
</tr>
{% endif %}
{% if model.template.vatId is not empty %}
<tr>
<th>{{ 'label.vat_id'|trans }}:</th>
<td>
{{ model.template.vatId }}
</td>
</tr>
{% endif %}
</table>
</article>
<article>
@@ -118,44 +118,44 @@
</table>
</article>
{% if model.template.paymentTerms is not empty %}
<article class="footer">
<article class="paymentTerms">
<p contenteditable="true">
{{ model.template.paymentTerms|trim|nl2br }}
{{ model.template.paymentTerms|nl2br|md2html }}
</p>
{% if company.signature is defined %}
<img src="{{ company.signature }}">
{% if signature is not empty %}
<img src="{{ signature }}">
{% endif %}
</article>
{% endif %}
<footer>
<table>
<thead>
<tr>
<th>{{ 'label.address'|trans }}</th>
<th>{{ 'label.invoice_bank_account'|trans }}</th>
<th>{{ 'label.contact'|trans }}</th>
</tr>
</thead>
<tbody>
<tr>
<td contenteditable="true">
{{ company.address|nl2br }}
{{ 'label.invoice_tax_number'|trans }} {{ company.tax_number }}
</td>
<td contenteditable="true">
{{ company.bank_account|nl2br }}
</td>
<td contenteditable="true">
{{ company.phone }}
<br/>
{{ company.email }}
<br/>
{{ company.homepage }}
</td>
</tr>
</tbody>
</table>
<footer class="footer">
<div class="row">
<div class="col-sm-4" contenteditable="true">
<p>
<strong>{{ 'label.address'|trans }}</strong>
</p>
<p>
{{ model.template.address|nl2br }}
</p>
</div>
<div class="col-sm-4 text-center" contenteditable="true">
<p>
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>
</p>
<p>
{{ model.template.paymentDetails|nl2br }}
</p>
</div>
<div class="col-sm-4 text-right" contenteditable="true">
<p>
<strong>{{ 'label.contact'|trans }}</strong>
</p>
<p>
{{ model.template.contact|nl2br }}
</p>
</div>
</div>
</footer>
</div>
</div>
{% endblock %}

View File

@@ -52,7 +52,7 @@
</div>
</div>
<div class="row">
<div class="row invoice-items">
<div class="col-xs-12 table-responsive">
<table class="table table-striped">
<thead>
@@ -97,22 +97,21 @@
</div>
</div>
<div class="row" style="padding: 60px 0">
<div class="row">
<div class="col-xs-12">
{% if model.template.paymentTerms is not empty %}
<p class="lead">{{ 'label.payment_terms'|trans }}</p>
<p class="text-muted well well-sm no-shadow" contenteditable="true">
<p class="text-muted well well-sm no-shadow" contenteditable="true" style="margin-bottom: 100px">
{{ model.template.paymentTerms|trim|nl2br }}
</p>
{% endif %}
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<th style="width:50%;padding-bottom: 60px">{{ 'invoice.signature_user'|trans }}</th>
<th style="padding-bottom: 60px">{{ 'invoice.signature_user'|trans }}</th>
</tr>
<tr>
<th>{{ 'invoice.signature_customer'|trans }}</th>

View File

@@ -3,9 +3,54 @@
{% block page_title %}{{ 'admin_invoice_template.title'|trans }}{% endblock %}
{% block main %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
{% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
{% set formOptions = {
'title': template.name|default('create'|trans),
'form': form,
'back': path('admin_invoice_template')
}) }}
} %}
{% embed formEditTemplate with formOptions %}
{% block form_body %}
{{ form_row(form.name) }}
{{ form_row(form.title) }}
<div class="row">
<div class="col-md-6">
{{ form_row(form.company) }}
</div>
<div class="col-md-6">
{{ form_row(form.vatId) }}
</div>
</div>
<div class="row">
<div class="col-md-6">
{{ form_row(form.address) }}
</div>
<div class="col-md-6">
{{ form_row(form.contact) }}
</div>
</div>
<div class="row">
<div class="col-md-6">
{{ form_row(form.paymentTerms) }}
</div>
<div class="col-md-6">
{{ form_row(form.paymentDetails) }}
</div>
</div>
<div class="row">
<div class="col-md-6">
{{ form_row(form.dueDays) }}
</div>
<div class="col-md-6">
{{ form_row(form.vat) }}
</div>
</div>
{{ form_row(form.renderer) }}
{{ form_row(form.calculator) }}
{{ form_row(form.numberGenerator) }}
{{ form_widget(form) }}
{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -21,7 +21,7 @@
{% set tableName = 'invoice_template' %}
{{ tables.data_table_header(tableName, columns) }}
{{ tables.datatable_header(tableName, columns, null, {'reload': 'kimai.invoiceTemplateUpdate'}) }}
{% for entry in entries %}
<tr class="modal-ajax-form open-edit" data-href="{{ path('admin_invoice_template_edit', {'id' : entry.id}) }}">