Skip to content

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

Fix incorrect number of decimal places for gift cards (#10706)

Iga Karbowiak49c7fbe5c27f
diff --git a/saleor/giftcard/notifications.py b/saleor/giftcard/notifications.py
index a5e2cbb99f..a2eb734ed0 100644
--- a/saleor/giftcard/notifications.py
+++ b/saleor/giftcard/notifications.py
@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING
from ..account.notifications import get_default_user_payload
from ..core.notification.utils import get_site_context
from ..core.notify_events import NotifyEventType
+from ..core.prices import quantize_price
from ..graphql.core.utils import to_global_id_or_none
if TYPE_CHECKING:
@@ -41,6 +42,6 @@ def get_default_gift_card_payload(gift_card: "GiftCard"):
return {
"id": to_global_id_or_none(gift_card),
"code": gift_card.code,
- "balance": gift_card.current_balance_amount,
+ "balance": quantize_price(gift_card.current_balance_amount, gift_card.currency),
"currency": gift_card.currency,
}
diff --git a/saleor/giftcard/tests/test_notifications.py b/saleor/giftcard/tests/test_notifications.py
index d0dc198926..e6f1b7bbdf 100644
--- a/saleor/giftcard/tests/test_notifications.py
+++ b/saleor/giftcard/tests/test_notifications.py
@@ -35,7 +35,12 @@ def test_send_gift_card_notification(
)
expected_payload = {
- "gift_card": get_default_gift_card_payload(gift_card),
+ "gift_card": {
+ "id": to_global_id_or_none(gift_card),
+ "code": gift_card.code,
+ "balance": round(gift_card.current_balance_amount, 2),
+ "currency": gift_card.currency,
+ },
"user": get_default_user_payload(customer_user) if customer_user else None,
"requester_user_id": to_global_id_or_none(staff_user),
"requester_app_id": None,