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 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)
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] mock_braintree.Transaction.search.return_value = [m1, m2]
self.client.login(username="[email protected]", password="password") self.client.login(username="[email protected]", password="password")


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

@ -82,4 +82,7 @@
margin-top: 20px; 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>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>
<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> <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" %}
${{ tx.amount }}
{% elif tx.currency_iso_code == "EUR" %}
€{{ tx.amount }}
{% if tx.type == "credit" %}
-{{ tx.amount }} {{ tx.currency_iso_code }}
{% 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%}


Loading…
Cancel
Save