Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use prices module to display prices in payments views
Marcin Gębalad37dddd3ada2
diff --git a/saleor/dashboard/payments/views.py b/saleor/dashboard/payments/views.pyindex 17fe600d45..99e7d61b42 100644--- a/saleor/dashboard/payments/views.py+++ b/saleor/dashboard/payments/views.py@@ -1,6 +1,7 @@import jsonfrom django.views.generic import ListView, DetailViewfrom payments.models import PAYMENT_STATUS_CHOICES+from prices import Pricefrom ..views import FilterByStatusMixinfrom ...order.models import Payment@@ -15,6 +16,14 @@ class PaymentList(FilterByStatusMixin, ListView):status_order = ['waiting', 'input', 'preauth', 'confirmed', 'refunded','rejected', 'error']+ def get_context_data(self, **kwargs):+ ctx = super(PaymentList, self).get_context_data(**kwargs)+ for payment in ctx['payments']:+ payment.total = Price(payment.total, currency=payment.currency)+ payment.captured_amount = Price(payment.captured_amount,+ currency=payment.currency)+ return ctx+def get_queryset(self):qs = super(PaymentList, self).get_queryset()return qs.order_by('-created')@@ -25,6 +34,13 @@ class PaymentDetails(DetailView):template_name = 'dashboard/payments/detail.html'context_object_name = 'payment'+ def get_object(self, queryset=None):+ obj = super(PaymentDetails, self).get_object(queryset)+ currency = obj.currency+ obj.total = Price(obj.total, currency=currency)+ obj.captured_amount = Price(obj.captured_amount, currency=currency)+ return obj+def get_context_data(self, **kwargs):ctx = super(PaymentDetails, self).get_context_data(**kwargs)extra_data = self.get_object().extra_datadiff --git a/saleor/dashboard/templates/dashboard/payments/detail.html b/saleor/dashboard/templates/dashboard/payments/detail.htmlindex 93bf9f3447..78bac2881c 100644--- a/saleor/dashboard/templates/dashboard/payments/detail.html+++ b/saleor/dashboard/templates/dashboard/payments/detail.html@@ -18,8 +18,8 @@<div class="panel-body"><p>Status: {% render_status payment.status payment.get_status_display %}</p><p>Fraud status: {% render_status payment.fraud_status payment.get_fraud_status_display %}</p>- <p>Amount: {{ payment.total }} {{ payment.currency }}</p>- <p>Captured amount: {{ payment.captured_amount }} {{ payment.currency }}</p>+ <p>Amount: {% gross payment.total %}</p>+ <p>Captured amount: {% gross payment.captured_amount %}</p><p>Gateway: {{ payment.variant }}</p><p>Transaction id: {{ payment.transaction_id }}</p><p>Payment date: {{ payment.created }}</p>diff --git a/saleor/dashboard/templates/dashboard/payments/list.html b/saleor/dashboard/templates/dashboard/payments/list.htmlindex 6e2e8208a3..5b66738fc0 100644--- a/saleor/dashboard/templates/dashboard/payments/list.html+++ b/saleor/dashboard/templates/dashboard/payments/list.html@@ -31,11 +31,9 @@<td>{{ payment.variant }}</td><th>{{ payment.created }}</th><td>{{ payment.order.user|default:"Anonymous" }}</td>- <td>{{ payment.total }}</td>+ <td>{% gross payment.total %}</td><td>{% render_status payment.status payment.get_status_display %}</td>- <td>- {{ payment.captured_amount }}- </td>+ <td>{% gross payment.captured_amount %}</td></tr>{% endfor %}</tbody>