From 080e44f7ba2d3c5016060fdd19f4c559d671e2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 4 Jun 2019 23:38:21 +0300 Subject: [PATCH] Show refunded transactions correctly in the billing history. --- hc/payments/tests/test_billing_history.py | 5 +++-- static/css/billing.css | 3 +++ templates/payments/billing_history.html | 17 ++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/hc/payments/tests/test_billing_history.py b/hc/payments/tests/test_billing_history.py index 8ca67150..16391785 100644 --- a/hc/payments/tests/test_billing_history.py +++ b/hc/payments/tests/test_billing_history.py @@ -1,5 +1,6 @@ from mock import Mock, patch +from django.utils.timezone import now from hc.payments.models import Subscription from hc.test import BaseTestCase @@ -15,8 +16,8 @@ class BillingHistoryTestCase(BaseTestCase): @patch("hc.payments.models.braintree") def test_it_works(self, mock_braintree): - m1 = Mock(id="abc123", amount=123) - m2 = Mock(id="def456", amount=456) + m1 = Mock(id="abc123", amount=123, created_at=now()) + m2 = Mock(id="def456", amount=456, created_at=now()) mock_braintree.Transaction.search.return_value = [m1, m2] self.client.login(username="alice@example.org", password="password") diff --git a/static/css/billing.css b/static/css/billing.css index d1816b1d..ec834e4e 100644 --- a/static/css/billing.css +++ b/static/css/billing.css @@ -82,4 +82,7 @@ margin-top: 20px; } +.text-muted code { + color: #777; +} diff --git a/templates/payments/billing_history.html b/templates/payments/billing_history.html index 2ae78c4d..8e31b7f0 100644 --- a/templates/payments/billing_history.html +++ b/templates/payments/billing_history.html @@ -4,12 +4,13 @@ Date Payment Method Amount + Type Status {% for tx in transactions %} - - {{ tx.created_at }} + + {{ tx.created_at|date:"N j, Y" }} {% if tx.payment_instrument_type == "paypal_account" %} Paypal from {{ tx.paypal.payer_email }} @@ -20,17 +21,19 @@ {% endif %} - {% if tx.currency_iso_code == "USD" %} - ${{ tx.amount }} - {% elif tx.currency_iso_code == "EUR" %} - €{{ tx.amount }} + {% if tx.type == "credit" %} + -{{ tx.amount }} {{ tx.currency_iso_code }} {% else %} - {{ tx.currency_iso_code }} {{ tx.amount }} + {{ tx.amount }} {{ tx.currency_iso_code }} {% endif %} + {{ tx.type|capfirst }} {{ tx.status }} + {% if tx.type == "credit" %} + {% else %} PDF Invoice + {% endif %} {% endfor%}