invoicing: display accounting code on lines (#89025)

This commit is contained in:
Lauréline Guérin 2024-04-10 15:01:49 +02:00 committed by Lauréline Guérin
parent aee44cae40
commit ed15da7a2a
11 changed files with 67 additions and 54 deletions

View File

@ -2,12 +2,13 @@
{% for line in object_list %}
{% ifchanged line.user_external_id %}
<tr class="line" data-related-invoicing-element-id="{{ credit.pk }}">
<th colspan="6" class="user">
<th colspan="7" class="user">
{{ line.user_name }}
</th>
</tr>
<tr class="line" data-related-invoicing-element-id="{{ credit.pk }}">
<td colspan="2">{% trans "Description" %}</td>
<td class="accounting-code">{% trans "Accounting code" %}</td>
<td class="amount">{% trans "Amount" %}</td>
<td class="quantity">{% trans "Quantity" %}</td>
<td class="amount">{% trans "Subtotal" %}</td>
@ -17,7 +18,7 @@
{% ifchanged line.user_external_id line.activity_label %}
{% if line.activity_label or not forloop.first %}
<tr class="line" data-related-invoicing-element-id="{{ credit.pk }}">
<td colspan="6" class="activity">{{ line.activity_label|default:"&nbsp;" }}</td>
<td colspan="7" class="activity">{{ line.activity_label|default:"&nbsp;" }}</td>
</tr>
{% endif %}
{% endifchanged %}
@ -28,6 +29,9 @@
<td class="details">
{{ line.description }}
</td>
<td class="accounting-code">
{{ line.accounting_code }}
</td>
<td class="amount">
{% blocktrans with amount=line.unit_amount|floatformat:"2" %}{{ amount }}€{% endblocktrans %}
</td>
@ -41,13 +45,13 @@
</tr>
{% endfor %}
<tr class="line" data-related-invoicing-element-id="{{ credit.pk }}">
<th colspan="6" class="assignments">
<th colspan="7" class="assignments">
{% trans "Assignments" %}
</th>
</tr>
<tr class="line" data-related-invoicing-element-id="{{ credit.pk }}">
<td class="payment-num">{% trans "Payment" context 'payment' %}</td>
<td colspan="3">{% trans "Date" context 'payment' %}</td>
<td colspan="4">{% trans "Date" context 'payment' %}</td>
<td class="amount" colspan="2">{% trans "Amount" %}</td>
</tr>
{% for assignment in credit.creditassignment_set.all %}
@ -56,19 +60,19 @@
<td>
<a href="{% url 'lingo-manager-invoicing-regie-payment-list' regie_pk=regie.pk %}?number={{ assignment.payment.formatted_number }}">{{ assignment.payment.formatted_number }}</a>
</td>
<td colspan="3">
<td colspan="4">
{{ assignment.payment.created_at|date:"DATETIME_FORMAT" }}
</td>
{% elif assignment.invoice %}
<td>
<i>{% trans "Pending..." %}</i>
</td>
<td colspan="3"></td>
<td colspan="4"></td>
{% else %}
<td>
<a href="{% url 'lingo-manager-invoicing-regie-refund-list' regie_pk=regie.pk %}?number={{ assignment.refund.formatted_number }}">{{ assignment.refund.formatted_number }} ({% trans "Refund" %})</a>
</td>
<td colspan="3">
<td colspan="4">
{{ assignment.refund.created_at|date:"DATETIME_FORMAT" }}
</td>
{% endif %}
@ -78,7 +82,7 @@
</tr>
{% empty %}
<tr class="line" data-related-invoicing-element-id="{{ credit.pk }}">
<td colspan="6" class="no-payments">
<td colspan="7" class="no-payments">
{% trans "No assignments for this credit" %}
</td>
</tr>
@ -86,7 +90,7 @@
{% if credit.assigned_amount %}
<tr class="line {% if not credit.remaining_amount%}last-line{% endif %}" data-related-invoicing-element-id="{{ credit.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Assigned amount:" %} {% blocktrans with amount=credit.assigned_amount|floatformat:"2" %}{{ amount }}€{% endblocktrans %}</i>
</td>
</tr>
@ -94,7 +98,7 @@
{% if credit.remaining_amount %}
<tr class="line last-line" data-related-invoicing-element-id="{{ credit.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Remaining amount to assign:" %} {% blocktrans with amount=credit.remaining_amount|floatformat:"2" %}{{ amount }}€{% endblocktrans %}</i>
</td>
</tr>

View File

@ -30,7 +30,7 @@
<table class="main pk-compact-table invoicing-element-list">
{% for credit in object_list %}
<tr class="credit untoggled" data-invoicing-element-id="{{ credit.pk }}" data-invoicing-element-lines-url="{% url 'lingo-manager-invoicing-regie-credit-line-list' regie_pk=regie.pk credit_pk=credit.pk %}">
<td colspan="5">
<td colspan="6">
{% if credit.remaining_amount > 0 and credit.assigned_amount > 0 %}
<span class="meta meta-warning">{% trans "Partially assigned" %}</span>
{% elif credit.remaining_amount == 0 %}

View File

@ -1,39 +1,39 @@
{% load i18n %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Demat:" %} {{ invoice.payer_demat|yesno }}</i>
</td>
</tr>
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Direct debit:" %} {{ invoice.direct_debit|yesno }}</i>
</td>
</tr>
{% if not pool.draft %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Publication date:" %} {{ invoice.date_publication|date:"d/m/Y" }}</i>
</td>
</tr>
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Payment deadline:" %} {{ invoice.date_payment_deadline|date:"d/m/Y" }}</i>
</td>
</tr>
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Due date:" %} {{ invoice.date_due|date:"d/m/Y" }}</i>
</td>
</tr>
{% if invoice.date_debit %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Debit date:" %} {{ invoice.date_debit|date:"d/m/Y" }}</i>
</td>
</tr>
@ -45,7 +45,7 @@
{% endif %}
{% ifchanged line.user_external_id %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<th colspan="6" class="user">
<th colspan="7" class="user">
{% if line.pool %}
<a href="{{ journal_url }}?user_external_id={{ line.user_external_id }}">{{ line.user_name }}</a>
{% else %}
@ -55,6 +55,7 @@
</tr>
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2">{% trans "Description" %}</td>
<td class="accounting-code">{% trans "Accounting code" %}</td>
<td class="amount">{% trans "Amount" %}</td>
<td class="quantity">{% trans "Quantity" %}</td>
<td class="amount">{% trans "Subtotal" %}</td>
@ -64,7 +65,7 @@
{% ifchanged line.user_external_id line.activity_label %}
{% if line.activity_label or not forloop.first %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="6" class="activity">{{ line.activity_label|default:"&nbsp;" }}</td>
<td colspan="7" class="activity">{{ line.activity_label|default:"&nbsp;" }}</td>
</tr>
{% endif %}
{% endifchanged %}
@ -88,6 +89,9 @@
{% endif %}
</small>
</td>
<td class="accounting-code">
{{ line.accounting_code }}
</td>
<td class="amount">
{% blocktrans with amount=line.unit_amount|floatformat:"2" %}{{ amount }}€{% endblocktrans %}
</td>
@ -105,14 +109,14 @@
</tr>
{% if not pool.draft and line.total_amount %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}-{{ line.pk }}" style="display: none;">
<th colspan="6" class="payments">
<th colspan="7" class="payments">
{% trans "Payments" %}
</th>
</tr>
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}-{{ line.pk }}" style="display: none;">
<td class="payment-num">{% trans "Payment" context 'payment' %}</td>
<td>{% trans "Date" context 'payment' %}</td>
<td colspan="2">{% trans "Type" context 'payment' %}</td>
<td colspan="3">{% trans "Type" context 'payment' %}</td>
<td class="amount" colspan="2">{% trans "Amount" %}</td>
</tr>
{% for invoice_line_payment in line.invoicelinepayment_set.all %}
@ -123,7 +127,7 @@
<td>
{{ invoice_line_payment.payment.created_at|date:"DATETIME_FORMAT" }}
</td>
<td colspan="2">
<td colspan="3">
{{ invoice_line_payment.payment.payment_type.label }}
</td>
<td class="amount" colspan="2">
@ -132,7 +136,7 @@
</tr>
{% empty %}
<tr class="line payment" data-related-invoicing-element-id="{{ invoice.pk }}-{{ line.pk }}" style="display: none;">
<td colspan="6" class="no-payments">
<td colspan="7" class="no-payments">
{% trans "No payments for this line" %}
</td>
</tr>
@ -141,14 +145,14 @@
{% endfor %}
{% if not pool.draft %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<th colspan="6" class="payments">
<th colspan="7" class="payments">
{% trans "Payments" %}
</th>
</tr>
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td class="payment-num">{% trans "Payment" context 'payment' %}</td>
<td>{% trans "Date" context 'payment' %}</td>
<td colspan="2">{% trans "Type" context 'payment' %}</td>
<td colspan="3">{% trans "Type" context 'payment' %}</td>
<td class="amount" colspan="2">{% trans "Amount" %}</td>
</tr>
{% for invoice_payment in invoice.get_invoice_payments %}
@ -159,7 +163,7 @@
<td>
{{ invoice_payment.payment.created_at|date:"DATETIME_FORMAT" }}
</td>
<td colspan="2">
<td colspan="3">
{{ invoice_payment.payment.payment_type.label }}
</td>
<td class="amount" colspan="2">
@ -168,7 +172,7 @@
</tr>
{% empty %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="6" class="no-payments">
<td colspan="7" class="no-payments">
{% trans "No payments for this invoice" %}
</td>
</tr>
@ -176,7 +180,7 @@
{% if invoice.paid_amount %}
<tr class="line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Paid amount:" %} {% blocktrans with amount=invoice.paid_amount|floatformat:"2" %}{{ amount }}€{% endblocktrans %}</i>
</td>
</tr>
@ -184,14 +188,14 @@
{% if invoice.remaining_amount %}
<tr class="line last-line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Remaining amount:" %} {% blocktrans with amount=invoice.remaining_amount|floatformat:"2" %}{{ amount }}€{% endblocktrans %}</i>
</td>
</tr>
{% else %}
<tr class="line last-line" data-related-invoicing-element-id="{{ invoice.pk }}">
<td colspan="2"></td>
<td class="invoice-details" colspan="4">
<td class="invoice-details" colspan="5">
<i>{% trans "Payments certificate:" %} <a href="{% url 'lingo-manager-invoicing-regie-invoice-payments-pdf' regie_pk=regie.pk invoice_pk=invoice.pk %}">{% trans "download" %}</a></i>
</td>
</tr>

View File

@ -34,7 +34,7 @@
<table class="main pk-compact-table invoicing-element-list">
{% for invoice in object_list %}
<tr class="invoice untoggled" data-invoicing-element-id="{{ invoice.pk }}" data-invoicing-element-lines-url="{% url 'lingo-manager-invoicing-regie-invoice-line-list' regie_pk=regie.pk invoice_pk=invoice.pk %}">
<td colspan="5">
<td colspan="6">
{% if invoice.remaining_amount > 0 and invoice.paid_amount > 0 %}
<span class="meta meta-warning">{% trans "Partially paid" %}</span>
{% elif invoice.remaining_amount == 0 %}

View File

@ -27,6 +27,7 @@
{{ line.quantity }}
{% endif %}
</td>
<td>{{ line.accounting_code }}</td>
<td>{{ line.user_name }} ({{ line.user_external_id }})</td>
<td>
{{ line.payer_name }} ({{ line.payer_external_id }})

View File

@ -51,7 +51,7 @@
<table class="main pk-compact-table invoicing-element-list">
{% for invoice in object_list %}
<tr class="invoice untoggled" data-invoicing-element-id="{{ invoice.pk }}" data-invoicing-element-lines-url="{% url 'lingo-manager-invoicing-invoice-line-list' regie_pk=regie.pk pk=object.pk pool_pk=pool.pk invoice_pk=invoice.pk %}">
<td colspan="5">
<td colspan="6">
{% if pool.draft %}
{% blocktrans with invoice_number=invoice.formatted_number number=invoice.pk cdate=invoice.created_at|date:'d/m/Y' payer_id=invoice.payer_external_id payer_name=invoice.payer_name amount=invoice.total_amount %}Invoice <a href="{{ journal_url }}?invoice_id={{ number }}">{{ invoice_number }}</a> dated {{ cdate }} addressed to <a href="{{ journal_url }}?payer_external_id={{ payer_id }}">{{ payer_name }}</a>, amount {{ amount }}€{% endblocktrans %}
{% else %}

View File

@ -49,6 +49,7 @@
<th>{% trans "Event" %}</th>
<th>{% trans "Amount" %}</th>
<th>{% trans "Quantity" %}</th>
<th>{% trans "Accounting code" %}</th>
<th>{% trans "User" %}</th>
<th>{% trans "Payer" %}</th>
<th>{% trans "Status" %}</th>

View File

@ -131,8 +131,8 @@ table.invoicing-element-list {
padding-bottom: 2em;
}
td {
&.quantity, &.amount, &.payment-num {
width: 10em;
&.quantity, &.amount, &.payment-num, &.accounting-code {
width: 8em;
}
&.with-togglable {
width: 2em;

View File

@ -1427,6 +1427,7 @@ def test_detail_pool_invoices(app, admin_user, draft):
unit_amount=1,
pool=pool,
label='Event A',
accounting_code='424242',
user_external_id='user:1',
user_first_name='User1',
user_last_name='Name1',
@ -1604,12 +1605,12 @@ def test_detail_pool_invoices(app, admin_user, draft):
'Demat: yes',
'Direct debit: no',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event A\nFoo! Thu01, Fri02, Sat03\n1.00€\n1.2\n1.20€',
'Event A\nFoo! Thu01, Fri02, Sat03\n424242\n1.00€\n1.2\n1.20€',
'Event A\nPresence Sun04, Mon05\n3.00€\n1\n3.00€',
'User2 Name2',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda B',
'Event B\nFoo! Thu01, Fri02, Sat03\n2.00€\n1\n2.00€',
]
@ -1635,9 +1636,9 @@ def test_detail_pool_invoices(app, admin_user, draft):
'Payment deadline: 31/10/2022',
'Due date: 31/10/2022',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event A\nFoo! Thu01, Fri02, Sat03\n1.00€\n1.2\n1.20€',
'Event A\nFoo! Thu01, Fri02, Sat03\n424242\n1.00€\n1.2\n1.20€',
'Payments',
'Payment\nDate\nType\nAmount',
'R%02d-%s-0000001\n%s\nCash\n1.00€'
@ -1651,7 +1652,7 @@ def test_detail_pool_invoices(app, admin_user, draft):
'Payment\nDate\nType\nAmount',
'No payments for this line',
'User2 Name2',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda B',
'Event B\nFoo! Thu01, Fri02, Sat03\n2.00€\n1\n2.00€',
'Payments',
@ -1723,7 +1724,7 @@ def test_detail_pool_invoices(app, admin_user, draft):
'Demat: no',
'Direct debit: no',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event AA\n1.00€\n1\n1.00€',
]
@ -1742,7 +1743,7 @@ def test_detail_pool_invoices(app, admin_user, draft):
'Payment deadline: 31/10/2022',
'Due date: 31/10/2022',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event AA\n1.00€\n1\n1.00€',
'Payments',
@ -1814,7 +1815,7 @@ def test_detail_pool_invoices(app, admin_user, draft):
'Demat: no',
'Direct debit: no',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Event A\n1.00€\n1\n1.00€',
]
else:
@ -1826,7 +1827,7 @@ def test_detail_pool_invoices(app, admin_user, draft):
'Payment deadline: 31/10/2022',
'Due date: 31/10/2022',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Event A\n1.00€\n1\n1.00€',
'Payments',
'Payment\nDate\nType\nAmount',

View File

@ -70,6 +70,7 @@ def test_regie_credits(app, admin_user):
unit_amount=1,
label='Event A',
description='A description',
accounting_code='424242',
user_external_id='user:1',
user_first_name='User1',
user_last_name='Name1',
@ -192,12 +193,12 @@ def test_regie_credits(app, admin_user):
assert len(lines_resp.pyquery('tr')) == 14
assert [PyQuery(tr).text() for tr in lines_resp.pyquery('tr')] == [
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event A\nA description\n1.00€\n1.2\n1.20€',
'Event A\nA description\n424242\n1.00€\n1.2\n1.20€',
'Event A\n3.00€\n1\n3.00€',
'User2 Name2',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda B',
'Event B\n2.00€\n1\n2.00€',
'Assignments',
@ -249,7 +250,7 @@ def test_regie_credits(app, admin_user):
assert len(lines_resp.pyquery('tr')) == 9
assert [PyQuery(tr).text() for tr in lines_resp.pyquery('tr')] == [
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event AA\n1.00€\n1\n1.00€',
'Assignments',
@ -279,7 +280,7 @@ def test_regie_credits(app, admin_user):
assert len(lines_resp.pyquery('tr')) == 7
assert [PyQuery(tr).text() for tr in lines_resp.pyquery('tr')] == [
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Event A\n1.00€\n1\n1.00€',
'Assignments',
'Payment\nDate\nAmount',

View File

@ -128,6 +128,7 @@ def test_regie_invoices(app, admin_user, orphan):
unit_amount=1,
pool=pool1 if not orphan else None,
label='Event A',
accounting_code='424242',
user_external_id='user:1',
user_first_name='User1',
user_last_name='Name1',
@ -334,9 +335,9 @@ def test_regie_invoices(app, admin_user, orphan):
'Payment deadline: 31/10/2022',
'Due date: 31/10/2022',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event A\nFoo! Thu01, Fri02, Sat03\n1.00€\n1.2\n1.20€',
'Event A\nFoo! Thu01, Fri02, Sat03\n424242\n1.00€\n1.2\n1.20€',
'Payments',
'Payment\nDate\nType\nAmount',
'R%02d-%s-0000001\n%s\nCash\n1.00€'
@ -350,7 +351,7 @@ def test_regie_invoices(app, admin_user, orphan):
'Payment\nDate\nType\nAmount',
'No payments for this line',
'User2 Name2',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda B',
'Event B\nFoo! Thu01, Fri02, Sat03\n2.00€\n1\n2.00€',
'Payments',
@ -431,7 +432,7 @@ def test_regie_invoices(app, admin_user, orphan):
'Due date: 31/10/2022',
'Debit date: 15/11/2022',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Agenda A',
'Event AA\n1.00€\n1\n1.00€',
'Payments',
@ -554,7 +555,7 @@ def test_regie_invoices(app, admin_user, orphan):
'Due date: 31/10/2022',
'Debit date: 15/11/2022',
'User1 Name1',
'Description\nAmount\nQuantity\nSubtotal',
'Description\nAccounting code\nAmount\nQuantity\nSubtotal',
'Event A\n1.00€\n1\n1.00€',
'Payments',
'Payment\nDate\nType\nAmount',