Skip to content

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

Allow updating gift card balance with 0 amount

IKarbowiak232ed6a0d0c7
diff --git a/saleor/graphql/giftcard/mutations.py b/saleor/graphql/giftcard/mutations.py
index 58edb9993d..0042f99cf4 100644
--- a/saleor/graphql/giftcard/mutations.py
+++ b/saleor/graphql/giftcard/mutations.py
@@ -254,7 +254,7 @@ class GiftCardUpdate(GiftCardCreate):
def clean_balance(cleaned_input, instance):
amount = cleaned_input.pop("balance_amount", None)
- if not amount:
+ if amount is None:
return
currency = instance.currency
diff --git a/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py b/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py
index a4e5da23ac..00e2b8b0bd 100644
--- a/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py
+++ b/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py
@@ -1,6 +1,7 @@
from datetime import date, timedelta
import graphene
+import pytest
from .....giftcard import GiftCardEvents
from .....giftcard.error_codes import GiftCardErrorCode
@@ -341,7 +342,9 @@ def test_update_gift_card_by_customer(api_client, customer_user, gift_card):
assert_no_permission(response)
[email protected]("initial_balance", [100.0, 0.0])
def test_update_gift_card_balance(
+ initial_balance,
staff_api_client,
gift_card,
permission_manage_gift_card,
@@ -352,7 +355,6 @@ def test_update_gift_card_balance(
old_initial_balance = float(gift_card.initial_balance.amount)
old_current_balance = float(gift_card.current_balance.amount)
- initial_balance = 100.0
currency = gift_card.currency
variables = {
"id": graphene.Node.to_global_id("GiftCard", gift_card.pk),