Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update order refunded email
IKarbowiak99041211cf9e
diff --git a/saleor/order/actions.py b/saleor/order/actions.pyindex 9992d78485..ee56ab47eb 100644--- a/saleor/order/actions.py+++ b/saleor/order/actions.py@@ -99,7 +99,7 @@ def order_refunded()get_plugins_manager().order_updated(order)- send_order_refunded_confirmation(order, user)+ send_order_refunded_confirmation(order, user, amount, payment.currency)def order_voided(order: "Order", user: "User", payment: "Payment"):diff --git a/saleor/order/emails.py b/saleor/order/emails.pyindex 6487b8f492..fc2e592a9c 100644--- a/saleor/order/emails.py+++ b/saleor/order/emails.py@@ -12,6 +12,8 @@ from . import eventsfrom .models import Fulfillment, Orderif TYPE_CHECKING:+ from decimal import Decimal+from ..account.models import UserCONFIRM_ORDER_TEMPLATE = "order/confirm_order"@@ -154,21 +156,25 @@ def send_order_canceled_confirmation(order: "Order", user: Optional["User"]):@app.task-def send_order_canceled(order_pk):+def send_order_canceled(order_pk: int):"""Send order cancel email."""email_data = collect_data_for_email(order_pk, ORDER_CANCEl_TEMPLATE)send_templated_mail(**email_data)-def send_order_refunded_confirmation(order: "Order", user: Optional["User"]):- send_order_refunded.delay(order.pk)+def send_order_refunded_confirmation(+ order: "Order", user: Optional["User"], amount: "Decimal", currency: str+):+ send_order_refunded.delay(order.pk, amount, currency)events.email_sent_event(order=order, user=user, email_type=events.OrderEventsEmails.ORDER_REFUND)@app.task-def send_order_refunded(order_pk):+def send_order_refunded(order_pk: int, amount: "Decimal", currency: str):"""Send order refund email."""email_data = collect_data_for_email(order_pk, ORDER_REFUND_TEMPLATE)+ context = email_data["context"]+ context.update({"amount": amount, "currency": currency})send_templated_mail(**email_data)diff --git a/saleor/order/tests/test_emails.py b/saleor/order/tests/test_emails.pyindex ff8f52ad1d..a1947e4d25 100644--- a/saleor/order/tests/test_emails.py+++ b/saleor/order/tests/test_emails.py@@ -311,12 +311,14 @@ def test_send_email_order_canceled(mocked_templated_email, order, site_settings)def test_send_email_order_refunded(mocked_templated_email, order, site_settings):# giventemplate = emails.ORDER_REFUND_TEMPLATE+ amount = order.total.gross.amount# when- emails.send_order_refunded(order.pk)+ emails.send_order_refunded(order.pk, amount, order.currency)# thenemail_data = emails.collect_data_for_email(order.pk, template)+ email_data["context"].update({"amount": amount, "currency": order.currency})recipients = [order.get_customer_email()]expected_call_kwargs = {"context": email_data["context"],diff --git a/saleor/order/tests/test_order_actions.py b/saleor/order/tests/test_order_actions.pyindex 4d0cee27b5..cea446f927 100644--- a/saleor/order/tests/test_order_actions.py+++ b/saleor/order/tests/test_order_actions.py@@ -211,15 +211,18 @@ def test_order_refunded(payment = Payment.objects.create(gateway="mirumee.payments.dummy", is_active=True, checkout=checkout_with_item)+ amount = order.total.gross.amount# when- order_refunded(order, order.user, order.total.gross.amount, payment)+ order_refunded(order, order.user, amount, payment)# thenorder_event = order.events.last()assert order_event.type == OrderEvents.PAYMENT_REFUNDED- send_order_refunded_confirmation_mock.assert_called_once_with(order, order.user)+ send_order_refunded_confirmation_mock.assert_called_once_with(+ order, order.user, amount, payment.currency+ )def test_fulfill_order_line(order_with_lines):diff --git a/templates/templated_email/compiled/order_refund.html b/templates/templated_email/compiled/order_refund.htmlindex f661546b49..786bd9e835 100644--- a/templates/templated_email/compiled/order_refund.html+++ b/templates/templated_email/compiled/order_refund.html@@ -104,7 +104,7 @@<td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">{% blocktrans trimmed context "Order refund e-mail text" %}- Your order has been refunded.+ A payment of {{ amount }} {{ currency }} has been refunded for your order.{% endblocktrans %}</div></td>diff --git a/templates/templated_email/order/order_refund.email b/templates/templated_email/order/order_refund.emailindex 118956a4af..0debd10955 100644--- a/templates/templated_email/order/order_refund.email+++ b/templates/templated_email/order/order_refund.email@@ -9,7 +9,7 @@{% block plain %}{% include 'templated_email/shared/_header.email' %}{% blocktrans context "Order refund e-mail text" %}-Your order has been refunded.+A payment of {{ amount }} {{ currency }} has been refunded for your order.{% endblocktrans %}{% include 'templated_email/shared/_footer.email' %}diff --git a/templates/templated_email/source/order_refund.mjml b/templates/templated_email/source/order_refund.mjmlindex 0c69a97f1d..e3e75bb028 100644--- a/templates/templated_email/source/order_refund.mjml+++ b/templates/templated_email/source/order_refund.mjml@@ -14,7 +14,7 @@</mj-text><mj-text>{% blocktrans trimmed context "Order refund e-mail text" %}- Your order has been refunded.+ A payment of {{ amount }} {{ currency }} has been refunded for your order.{% endblocktrans %}</mj-text></mj-column>