Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix send invoice logic and linked unit tests (#7872)

Dawid Matuszczyk10889526d151
diff --git a/saleor/graphql/invoice/tests/test_send_invoice_notification.py b/saleor/graphql/invoice/tests/test_send_invoice_notification.py
index db199b79e1..7b1eac1d99 100644
--- a/saleor/graphql/invoice/tests/test_send_invoice_notification.py
+++ b/saleor/graphql/invoice/tests/test_send_invoice_notification.py
@@ -46,7 +46,11 @@ def test_invoice_send_notification_by_user(
"site_name": "mirumee.com",
}
- mock_notify.assert_called_once_with(NotifyEventType.INVOICE_READY, expected_payload)
+ mock_notify.assert_called_once_with(
+ NotifyEventType.INVOICE_READY,
+ expected_payload,
+ channel_slug=invoice.order.channel.slug,
+ )
assert not content["data"]["invoiceSendNotification"]["errors"]
@@ -73,7 +77,11 @@ def test_invoice_send_notification_by_app(
"site_name": "mirumee.com",
}
- mock_notify.assert_called_once_with(NotifyEventType.INVOICE_READY, expected_payload)
+ mock_notify.assert_called_once_with(
+ NotifyEventType.INVOICE_READY,
+ expected_payload,
+ channel_slug=invoice.order.channel.slug,
+ )
assert not content["data"]["invoiceSendNotification"]["errors"]
diff --git a/saleor/invoice/notifications.py b/saleor/invoice/notifications.py
index 206d74e834..afe4545c72 100644
--- a/saleor/invoice/notifications.py
+++ b/saleor/invoice/notifications.py
@@ -33,5 +33,11 @@ def send_invoice(
"requester_app_id": app.id if app else None,
**get_site_context(),
}
- manager.notify(NotifyEventType.INVOICE_READY, payload) # type: ignore
+
+ channel_slug = None
+ if invoice.order and invoice.order.channel:
+ channel_slug = invoice.order.channel.slug
+ manager.notify(
+ NotifyEventType.INVOICE_READY, payload, channel_slug=channel_slug
+ ) # type: ignore
manager.invoice_sent(invoice, invoice.order.get_customer_email()) # type: ignore