Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix decimal fields
akjanik4ad5ee024d4f
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex 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.pyindex 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.pyindex 4a4a250427..93c9533e04 100644--- a/saleor/graphql/discount/mutations.py+++ b/saleor/graphql/discount/mutations.py@@ -6,20 +6,22 @@ from ..core.types import Decimalclass 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.pyindex 44f47b1376..10bebb4a58 100644--- a/saleor/graphql/product/mutations.py+++ b/saleor/graphql/product/mutations.py@@ -1,10 +1,12 @@import graphenefrom graphene.types import InputObjectTypefrom graphql_jwt.decorators import permission_required+from graphene_file_upload import Uploadfrom ...product import modelsfrom ..core.mutations import BaseMutation, ModelDeleteMutation, ModelMutation+from ..core.types import Decimal, Moneyfrom ..utils import get_attributes_dict_from_list, get_node, get_nodesfrom .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.pyindex 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 = Falseproduct_chargeTaxes = Trueproduct_taxRate = 'standard'- product_price = 22+ product_price = "22.33"# Default attribute defined in product_type fixturecolor_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 = Falseproduct_chargeTaxes = Trueproduct_taxRate = 'standard'- product_price = 33+ product_price = "33.12"variables = json.dumps({'productId': product_id,