Browse Source

Show refunded transactions correctly in the billing history.

pull/272/head
Pēteris Caune 6 years ago
parent
commit
080e44f7ba
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 16 additions and 9 deletions
  1. +3
    -2
      hc/payments/tests/test_billing_history.py
  2. +3
    -0
      static/css/billing.css
  3. +10
    -7
      templates/payments/billing_history.html

+ 3
- 2
hc/payments/tests/test_billing_history.py View File

@ -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="[email protected]", password="password")


+ 3
- 0
static/css/billing.css View File

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

+ 10
- 7
templates/payments/billing_history.html View File

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


Loading…
Cancel
Save