0001-lingo-display-amount_paid-if-provided-40170.patch
combo/apps/lingo/models.py | ||
---|---|---|
80 | 80 |
display_id=data.get('display_id'), |
81 | 81 |
total_amount=data.get('total_amount'), |
82 | 82 |
amount=data.get('amount'), |
83 |
amount_paid=data.get('amount_paid'), |
|
83 | 84 |
subject=data.get('label'), |
84 | 85 |
has_pdf=data.get('has_pdf'), |
85 | 86 |
online_payment=data.get('online_payment'), |
... | ... | |
410 | 411 |
payment_date = None |
411 | 412 | |
412 | 413 |
def __init__(self, id, regie, creation_date, payment_limit_date, |
413 |
total_amount, amount, display_id, subject, has_pdf, |
|
414 |
total_amount, amount, amount_paid, display_id, subject, has_pdf,
|
|
414 | 415 |
online_payment, paid, payment_date, no_online_payment_reason): |
415 | 416 |
self.id = id |
416 | 417 |
self.regie = regie |
... | ... | |
418 | 419 |
self.payment_limit_date = dateparse.parse_date(payment_limit_date) |
419 | 420 |
self.total_amount = Decimal(total_amount) |
420 | 421 |
self.amount = Decimal(amount) |
422 |
if amount_paid: |
|
423 |
self.amount_paid = Decimal(amount_paid) |
|
421 | 424 |
self.display_id = display_id or self.id |
422 | 425 |
self.subject = subject |
423 | 426 |
self.has_pdf = has_pdf |
combo/apps/lingo/templates/lingo/combo/item.html | ||
---|---|---|
27 | 27 |
{% endblocktrans %} |
28 | 28 |
</div> |
29 | 29 |
{% endif %} |
30 |
{% if item.amount_paid %} |
|
31 |
<div class="amount_paid"> |
|
32 |
{% blocktrans with amount=item.amount_paid|floatformat:"2" %} |
|
33 |
Amount already paid: <span class="amount">{{ amount }}€</span> |
|
34 |
{% endblocktrans %} |
|
35 |
</div> |
|
36 |
{% endif %} |
|
30 | 37 |
<div class="issued">{% trans "Issue date:" %} <span class="timestamp">{{ item.creation_date|date:"SHORT_DATE_FORMAT" }}</span></div> |
31 | 38 |
{% if item.payment_limit_date %} |
32 | 39 |
<div class="invoice-payment-limit-date">{% trans "Payment due date:" %} |
tests/test_lingo_remote_regie.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 | |
3 |
import copy |
|
3 | 4 |
import json |
4 | 5 |
import pytest |
5 | 6 |
import mock |
... | ... | |
178 | 179 |
def test_anonymous_successful_item_payment(mock_get, mock_pay_invoice, app, remote_regie): |
179 | 180 |
assert remote_regie.is_remote() == True |
180 | 181 |
encrypt_id = aes_hex_encrypt(settings.SECRET_KEY, 'F201601') |
182 |
# invoice with amount_paid |
|
183 |
invoices = copy.deepcopy(INVOICES) |
|
184 |
invoices[0]['amount'] = '100.00' |
|
185 |
invoices[0]['amount_paid'] = '23.45' |
|
186 |
mock_json = mock.Mock() |
|
187 |
mock_json.json.return_value = {'err': 0, 'data': invoices[0]} |
|
188 |
mock_get.return_value = mock_json |
|
189 |
mock_pay_invoice.return_value = mock.Mock(status_code=200) |
|
190 |
resp = app.get('/lingo/item/%s/%s/' % (remote_regie.id, encrypt_id)) |
|
191 |
assert 'Total amount: <span class="amount">123.45€</span>' in resp.text |
|
192 |
assert 'Amount to pay: <span class="amount">100.00€</span>' in resp.text |
|
193 |
assert 'Amount already paid: <span class="amount">23.45€</span>' in resp.text |
|
194 | ||
195 |
# invoice without amount_paid |
|
181 | 196 |
mock_json = mock.Mock() |
182 | 197 |
mock_json.json.return_value = {'err': 0, 'data': INVOICES[0]} |
183 | 198 |
mock_get.return_value = mock_json |
184 | 199 |
mock_pay_invoice.return_value = mock.Mock(status_code=200) |
185 | 200 |
resp = app.get('/lingo/item/%s/%s/' % (remote_regie.id, encrypt_id)) |
201 |
assert 'Total amount: <span class="amount">123.45€</span>' in resp.text |
|
202 |
assert 'Amount to pay: <span class="amount">123.45€</span>' in resp.text |
|
203 |
assert 'Amount already paid>' not in resp.text |
|
204 | ||
186 | 205 |
form = resp.form |
187 | 206 | |
188 | 207 |
assert 'email' in form.fields |
189 |
- |