Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change filed type to choice field of tax rate in product #3478

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ All notable, unreleased changes to this project will be documented in this file.
- Support sorting products by update date - #3470 by @jxltom
- Draft order should be able to clear its shipping method - #3472 by @fowczarek
- Prefetch payment and payment transaction to optimize db queries - #3455 by @jxltom
- Change filed type to choice field of tax rate in product - #3478 by @fowczarek
1 change: 1 addition & 0 deletions saleor/graphql/product/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class Product(CountableDjangoObjectType):
Money,
description=dedent("""The product's base price (without any discounts
applied)."""))
tax_rate = TaxRateType(description='A type of tax rate.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The a type of... is sounding weird to me.
What do you think of: The tax rate type. ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp @maarcingebala just merged it 😆

attributes = graphene.List(
graphene.NonNull(SelectedAttribute), required=True,
description='List of attributes assigned to this product.')
Expand Down
2 changes: 1 addition & 1 deletion saleor/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ type Product implements Node {
attributes: [SelectedAttribute!]!
updatedAt: DateTime
chargeTaxes: Boolean!
taxRate: String!
taxRate: TaxRateType
weight: Weight
variants: [ProductVariant]
images: [ProductImage]
Expand Down
18 changes: 18 additions & 0 deletions saleor/product/migrations/0081_auto_20181218_0024.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion saleor/product/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class Product(SeoModel):
updated_at = models.DateTimeField(auto_now=True, null=True)
charge_taxes = models.BooleanField(default=True)
tax_rate = models.CharField(
max_length=128, default=DEFAULT_TAX_RATE_NAME, blank=True)
max_length=128, default=DEFAULT_TAX_RATE_NAME, blank=True,
choices=TaxRateType.CHOICES)
weight = MeasurementField(
measurement=Weight, unit_choices=WeightUnits.CHOICES,
blank=True, null=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def test_create_product(
assert data['product']['description'] == product_description
assert data['product']['isPublished'] == product_is_published
assert data['product']['chargeTaxes'] == product_charge_taxes
assert data['product']['taxRate'] == product_tax_rate.lower()
assert data['product']['taxRate'] == product_tax_rate
assert data['product']['productType']['name'] == product_type.name
assert data['product']['category']['name'] == category.name
values = (
Expand Down Expand Up @@ -563,7 +563,7 @@ def test_update_product(
assert data['product']['description'] == product_description
assert data['product']['isPublished'] == product_isPublished
assert data['product']['chargeTaxes'] == product_chargeTaxes
assert data['product']['taxRate'] == product_taxRate.lower()
assert data['product']['taxRate'] == product_taxRate
assert not data['product']['category']['name'] == category.name


Expand Down