0001-lingo-display-amount_paid-in-invoice-listing-40364.patch
combo/apps/lingo/models.py | ||
---|---|---|
688 | 688 |
ctx.update({ |
689 | 689 |
'items': items, |
690 | 690 |
'with_payment_limit_date': any(i.payment_limit_date for i in items), |
691 |
'with_amount_paid': any(getattr(i, 'amount_paid', None) for i in items), |
|
691 | 692 |
}) |
692 | 693 |
return ctx |
693 | 694 |
combo/apps/lingo/templates/lingo/combo/items.html | ||
---|---|---|
12 | 12 |
<th class="invoice-creation-date">{% trans "Issue date" %}</th> |
13 | 13 |
{% if with_payment_limit_date %}<th class="invoice-payment-limit-date">{% trans "Payment limit date" %}</th>{% endif %} |
14 | 14 |
<th class="invoice-amount">{% trans "Amount" %}</th> |
15 |
{% if with_amount_paid %} |
|
16 |
<th class="invoice-amount-paid">{% trans "Amount already paid" %}</th> |
|
17 |
{% endif %} |
|
15 | 18 |
<td></td> |
16 | 19 |
</tr> |
17 | 20 |
</thead> |
... | ... | |
22 | 25 |
<td class="invoice-subject">{{ item.subject }}</td> |
23 | 26 |
<td class="invoice-creation-date">{{ item.creation_date|date:"SHORT_DATE_FORMAT" }}</td> |
24 | 27 |
{% if with_payment_limit_date %}<td class="invoice-payment-limit-date">{{ item.payment_limit_date|date:"SHORT_DATE_FORMAT" }}</td>{% endif %} |
28 |
{% if with_amount_paid %} |
|
29 |
<td class="invoice-amount amount">{% if item.amount %}{% blocktrans with amount=item.amount|floatformat:"2" %} |
|
30 |
{{ amount }}€ |
|
31 |
{% endblocktrans %}{% endif %} |
|
32 |
</td> |
|
33 |
<td class="invoice-amount-paid amount">{% if item.amount_paid %}{% blocktrans with amount=item.amount_paid|floatformat:"2" %} |
|
34 |
{{ amount }}€ |
|
35 |
{% endblocktrans %}{% endif %} |
|
36 |
</td> |
|
37 |
{% else %} |
|
25 | 38 |
<td class="invoice-amount amount">{% blocktrans with amount=item.total_amount|floatformat:"2" %} |
26 | 39 |
{{ amount }}€ |
27 | 40 |
{% endblocktrans %} |
28 | 41 |
</td> |
42 |
{% endif %} |
|
29 | 43 |
{% if item.regie.is_remote %} |
30 | 44 |
<td> |
31 | 45 |
<a href="{% url 'view-item' regie_id=item.regie.pk item_crypto_id=item.crypto_id %}?page={{ cell.page.pk }}" rel="popup" class="icon-view">{% trans "View" %} |
tests/test_lingo_remote_regie.py | ||
---|---|---|
163 | 163 |
mock_response.json.return_value = ws_invoices |
164 | 164 |
mock_send.return_value = mock_response |
165 | 165 |
content = cell.render(context) |
166 |
assert 'F-2016-One' in content |
|
167 |
assert '123.45' in content |
|
168 | 166 |
assert 'class="invoice-payment-limit-date"' not in content |
169 | 167 | |
168 |
# invoice with amount_paid |
|
169 |
invoices = copy.deepcopy(INVOICES) |
|
170 |
invoices[0]['amount'] = '100.00' |
|
171 |
invoices[0]['amount_paid'] = '23.45' |
|
172 |
ws_invoices = {'err': 0, 'data': invoices} |
|
173 |
mock_response = mock.Mock(status_code=200, content=json.dumps(ws_invoices)) |
|
174 |
mock_response.json.return_value = ws_invoices |
|
175 |
mock_send.return_value = mock_response |
|
176 |
content = cell.render(context) |
|
177 |
assert '100.00' in content |
|
178 |
assert '23.45' in content |
|
179 |
assert 'class="invoice-amount-paid"' in content |
|
180 | ||
181 |
# invoice with zero amount_paid |
|
182 |
invoices = copy.deepcopy(INVOICES) |
|
183 |
invoices[0]['amount'] = '123.45' |
|
184 |
invoices[0]['amount_paid'] = '0.00' |
|
185 |
ws_invoices = {'err': 0, 'data': invoices} |
|
186 |
mock_response = mock.Mock(status_code=200, content=json.dumps(ws_invoices)) |
|
187 |
mock_response.json.return_value = ws_invoices |
|
188 |
mock_send.return_value = mock_response |
|
189 |
content = cell.render(context) |
|
190 |
assert '123.45' in content |
|
191 |
assert 'class="invoice-amount-paid"' not in content |
|
192 | ||
170 | 193 |
# check if regie webservice has been correctly called |
171 | 194 |
assert mock_send.call_args[0][0].method == 'GET' |
172 | 195 |
url = mock_send.call_args[0][0].url |
173 |
- |