Show refunded transactions correctly in the billing history.

This commit is contained in:
Pēteris Caune 2019-06-04 23:38:21 +03:00
parent 3c0b9834e9
commit 080e44f7ba
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
3 changed files with 16 additions and 9 deletions

View File

@ -1,5 +1,6 @@
from mock import Mock, patch from mock import Mock, patch
from django.utils.timezone import now
from hc.payments.models import Subscription from hc.payments.models import Subscription
from hc.test import BaseTestCase from hc.test import BaseTestCase
@ -15,8 +16,8 @@ class BillingHistoryTestCase(BaseTestCase):
@patch("hc.payments.models.braintree") @patch("hc.payments.models.braintree")
def test_it_works(self, mock_braintree): def test_it_works(self, mock_braintree):
m1 = Mock(id="abc123", amount=123) m1 = Mock(id="abc123", amount=123, created_at=now())
m2 = Mock(id="def456", amount=456) m2 = Mock(id="def456", amount=456, created_at=now())
mock_braintree.Transaction.search.return_value = [m1, m2] mock_braintree.Transaction.search.return_value = [m1, m2]
self.client.login(username="alice@example.org", password="password") self.client.login(username="alice@example.org", password="password")

View File

@ -82,4 +82,7 @@
margin-top: 20px; margin-top: 20px;
} }
.text-muted code {
color: #777;
}

View File

@ -4,12 +4,13 @@
<th>Date</th> <th>Date</th>
<th>Payment Method</th> <th>Payment Method</th>
<th>Amount</th> <th>Amount</th>
<th>Type</th>
<th>Status</th> <th>Status</th>
<th></th> <th></th>
</tr> </tr>
{% for tx in transactions %} {% for tx in transactions %}
<tr> <tr {% if tx.type == "credit" %}class="text-muted"{% endif %}>
<td>{{ tx.created_at }}</td> <td title="{{ tx.created_at }}">{{ tx.created_at|date:"N j, Y" }}</td>
<td> <td>
{% if tx.payment_instrument_type == "paypal_account" %} {% if tx.payment_instrument_type == "paypal_account" %}
Paypal from {{ tx.paypal.payer_email }} Paypal from {{ tx.paypal.payer_email }}
@ -20,17 +21,19 @@
{% endif %} {% endif %}
</td> </td>
<td> <td>
{% if tx.currency_iso_code == "USD" %} {% if tx.type == "credit" %}
${{ tx.amount }} -{{ tx.amount }} {{ tx.currency_iso_code }}
{% elif tx.currency_iso_code == "EUR" %}
€{{ tx.amount }}
{% else %} {% else %}
{{ tx.currency_iso_code }} {{ tx.amount }} {{ tx.amount }} {{ tx.currency_iso_code }}
{% endif %} {% endif %}
</td> </td>
<td>{{ tx.type|capfirst }}</td>
<td><code>{{ tx.status }}</code></td> <td><code>{{ tx.status }}</code></td>
<td> <td>
{% if tx.type == "credit" %}
{% else %}
<a href="{% url 'hc-invoice-pdf' tx.id %}">PDF Invoice</a> <a href="{% url 'hc-invoice-pdf' tx.id %}">PDF Invoice</a>
{% endif %}
</td> </td>
</tr> </tr>
{% endfor%} {% endfor%}