Skip to content

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

Fix decimal fields

akjanik4ad5ee024d4f
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.py
index c75a88cede..0b39717345 100644
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@ -201,7 +201,7 @@ class Query(graphene.ObjectType):
def resolve_product_type(self, info, id):
return get_node(info, id, only_type=ProductType)
- def resolve_product_types(self, info):
+ def resolve_product_types(self, info, **kwargs):
return resolve_product_types()
@permission_required('discount.view_sale')
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index 99c031c7ea..865121745a 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -234,10 +234,8 @@ class ModelMutation(BaseMutation):
instance = cls._meta.model()
cleaned_input = cls.clean_input(info, instance, input, errors)
- import ipdb; ipdb.set_trace()
instance = cls.construct_instance(instance, cleaned_input)
cls.clean_instance(instance, errors)
- import ipdb; ipdb.set_trace()
if errors:
return cls(errors=errors)
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.py
index 4a4a250427..93c9533e04 100644
--- a/saleor/graphql/discount/mutations.py
+++ b/saleor/graphql/discount/mutations.py
@@ -6,20 +6,22 @@ from ..core.types import Decimal
class VoucherInput(graphene.InputObjectType):
- type = graphene.String(description='Voucher type.')
+ type = graphene.String(
+ description='Voucher type: product, category shipping or value.')
name = graphene.String(description='Voucher name.')
code = graphene.String(decription='Code to use the voucher.')
start_date = graphene.types.datetime.DateTime(
description='Start date of the voucher in ISO 8601 format.')
end_date = graphene.types.datetime.DateTime(
description='End date of the voucher in ISO 8601 format.')
- discount_value_type = graphene.String(description='Fixed or percentage.')
+ discount_value_type = graphene.String(
+ description='Choices: fixed or percentage.')
discount_value = Decimal(description='Value of the voucher.')
product = graphene.ID(description='Product related to the discount.')
category = graphene.ID(description='Category related to the discount.')
apply_to = graphene.String(
- description='Single item or all matching products.')
- limit = graphene.Float(description='Limit value of the discount.')
+ description='Single item (one) or all matching products (all).')
+ limit = Decimal(description='Limit value of the discount.')
class VoucherCreate(ModelMutation):
diff --git a/saleor/graphql/product/mutations.py b/saleor/graphql/product/mutations.py
index 44f47b1376..10bebb4a58 100644
--- a/saleor/graphql/product/mutations.py
+++ b/saleor/graphql/product/mutations.py
@@ -1,10 +1,12 @@
import graphene
from graphene.types import InputObjectType
from graphql_jwt.decorators import permission_required
+
from graphene_file_upload import Upload
from ...product import models
from ..core.mutations import BaseMutation, ModelDeleteMutation, ModelMutation
+from ..core.types import Decimal, Money
from ..utils import get_attributes_dict_from_list, get_node, get_nodes
from .types import Collection, Product
@@ -172,7 +174,6 @@ class AttributeValueInput(InputObjectType):
value = graphene.String(
required=True, description='Value of an attribute.')
-
class ProductInput(graphene.InputObjectType):
attributes = graphene.List(AttributeValueInput)
available_on = graphene.String()
@@ -183,7 +184,7 @@ class ProductInput(graphene.InputObjectType):
is_featured = graphene.Boolean()
name = graphene.String()
product_type = graphene.ID()
- price = graphene.Float()
+ price = Decimal()
tax_rate = graphene.String()
diff --git a/tests/api/test_product.py b/tests/api/test_product.py
index 5ba9e72665..bb0761a373 100644
--- a/tests/api/test_product.py
+++ b/tests/api/test_product.py
@@ -357,7 +357,7 @@ def test_create_product(
$isFeatured: Boolean!,
$chargeTaxes: Boolean!,
$taxRate: String!,
- $price: Float!,
+ $price: Decimal!,
$attributes: [AttributeValueInput!]) {
productCreate(
input: {
@@ -415,7 +415,7 @@ def test_create_product(
product_isFeatured = False
product_chargeTaxes = True
product_taxRate = 'standard'
- product_price = 22
+ product_price = "22.33"
# Default attribute defined in product_type fixture
color_attr = product_type.product_attributes.get(name='Color')
@@ -476,7 +476,7 @@ def test_update_product(
$isFeatured: Boolean!,
$chargeTaxes: Boolean!,
$taxRate: String!,
- $price: Float!,
+ $price: Decimal!,
$attributes: [AttributeValueInput!]) {
productUpdate(
id: $productId,
@@ -532,7 +532,7 @@ def test_update_product(
product_isFeatured = False
product_chargeTaxes = True
product_taxRate = 'standard'
- product_price = 33
+ product_price = "33.12"
variables = json.dumps({
'productId': product_id,