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

Update default decimal places #6098

Merged
merged 21 commits into from Sep 9, 2020
Merged

Conversation

IKarbowiak
Copy link
Member

@IKarbowiak IKarbowiak commented Sep 3, 2020

Changing currency caused errors when running Saleor.

  • Set DEFAULT_DECIMAL_PLACES to 3, which should be enough for all currencies (https://en.wikipedia.org/wiki/ISO_4217).
  • Create mutations for changing decimal_places in DecimalFields
  • Update Money ObjectType - return amount with the number of decimal places corresponding to a given currency
  • Create PositiveDecimal that contains validation - prevent for creating an item with a negative value
  • Add price amount validation - check if the price amount does not have more decimal places than the given currency allows

⚠️
Require frontend changes

Resolves #5360

Impact

  • New migrations
  • New/Updated API fields or mutations
  • Deprecated API fields or mutations
  • Removed API types, fields, or mutations
  • Documentation needs to be updated

Pull Request Checklist

  • Privileged queries and mutations are guarded by proper permission checks
  • Database queries are optimized and the number of queries is constant
  • Database migration files are up to date
  • The changes are tested
  • GraphQL schema and type definitions are up to date
  • Changes are mentioned in the changelog

@IKarbowiak IKarbowiak self-assigned this Sep 3, 2020
@codecov
Copy link

codecov bot commented Sep 3, 2020

Codecov Report

Merging #6098 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6098      +/-   ##
==========================================
+ Coverage   91.78%   91.80%   +0.02%     
==========================================
  Files         389      389              
  Lines       25554    25621      +67     
  Branches     2410     2407       -3     
==========================================
+ Hits        23454    23521      +67     
- Misses       1515     1516       +1     
+ Partials      585      584       -1     
Impacted Files Coverage Δ
saleor/tests/fixtures.py 95.28% <ø> (ø)
saleor/graphql/core/scalars.py 82.02% <100.00%> (+1.53%) ⬆️
saleor/graphql/core/types/money.py 100.00% <100.00%> (ø)
saleor/graphql/core/validators.py 100.00% <100.00%> (ø)
saleor/graphql/discount/mutations.py 98.61% <100.00%> (+0.03%) ⬆️
saleor/graphql/giftcard/mutations.py 98.92% <100.00%> (+0.07%) ⬆️
saleor/graphql/order/mutations/draft_orders.py 95.29% <100.00%> (ø)
saleor/graphql/order/mutations/orders.py 95.57% <100.00%> (ø)
saleor/graphql/payment/mutations.py 95.48% <100.00%> (ø)
saleor/graphql/product/bulk_mutations/products.py 97.54% <100.00%> (+0.05%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efc27eb...6b5bf47. Read the comment docs.

@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 3, 2020 13:16 Failure
@IKarbowiak IKarbowiak marked this pull request as draft September 3, 2020 13:31
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 4, 2020 05:44 Failure
@db-queries
Copy link

db-queries bot commented Sep 4, 2020

Here is the report for 6b5bf47 (mirumee/saleor @ update-default-decimal-places)
Base comparison is efc27eb.

**Found 1 differences!** (click me)

# saleor.graphql.accountbenchmark account
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  delete staff members                                       	         32	         32	              0
  query staff user                                           	         20	         20	              4
  staff create                                               	         22	         22	              4
  staff update groups and permissions                        	         33	         33	              5

# saleor.graphql.accountbenchmark permission group
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  permission group create                                    	         19	         19	              2
  permission group delete                                    	         20	         20	              3
  permission group query                                     	          7	          7	              0
  permission group update                                    	         33	         33	              1
  permission group update remove users with manage staff     	         27	         27	              3

# saleor.graphql.checkoutbenchmark checkout mutations
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  add billing address to checkout                            	         72	         72	             42
  add shipping to checkout                                   	         50	         50	             19
  checkout email update                                      	         41	         41	             21
  checkout payment charge                                    	         38	         38	             10
  checkout shipping address update                           	         58	         58	             19
  checkout voucher code                                      	         85	         85	             53
- complete checkout                                          	        118	        119	             25
  create checkout                                            	        130	        130	             64
  update checkout lines                                      	        114	        114	             54

# saleor.graphql.checkoutbenchmark homepage
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  user checkout details                                      	         51	         51	             27

# saleor.graphql.menubenchmark homepage
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  retrieve main menu                                         	          5	          5	              0
  retrieve secondary menu                                    	          5	          5	              0

# saleor.graphql.orderbenchmark order
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  user order details                                         	         17	         17	              3

# saleor.graphql.productbenchmark category
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  category view                                              	         18	         18	              1

# saleor.graphql.productbenchmark collection
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  collection view                                            	         17	         17	              0

# saleor.graphql.productbenchmark homepage
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  featured products list                                     	         14	         14	              0
  retrieve product list                                      	          5	          5	              0

# saleor.graphql.productbenchmark product
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  product details                                            	         16	         16	              0
  retrieve product attributes                                	          7	          7	              0

# saleor.graphql.productbenchmark variant
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  product variant bulk create                                	         47	         47	              2
  retrieve variant list                                      	         18	         18	              2

# saleor.graphql.productbenchmark variant stocks
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  product variants stocks create                             	         22	         22	              5
  product variants stocks delete                             	         19	         19	              5
  product variants stocks update                             	         27	         27	              5

# saleor.graphql.producttest product sorting attributes
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  sort product not having attribute data                     	         20	         20	              0

# saleor.graphql.shopbenchmark homepage
  test name                                                  	left count 	right count	duplicate count
  -----------------------------------------------------------	-----------	-----------	---------------
  retrieve shop                                              	          2	          2	              0

@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 4, 2020 10:06 Failure
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 4, 2020 10:51 Failure
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 4, 2020 11:09 Failure
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 4, 2020 11:15 Failure
@IKarbowiak IKarbowiak marked this pull request as ready for review September 4, 2020 11:46
@IKarbowiak IKarbowiak requested a review from a team September 4, 2020 11:48
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 4, 2020 11:54 Failure
saleor/graphql/core/scalars.py Outdated Show resolved Hide resolved
saleor/graphql/core/validators.py Outdated Show resolved Hide resolved
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 7, 2020 07:03 Failure
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 7, 2020 09:28 Failure
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 7, 2020 09:49 Failure
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 7, 2020 10:22 Failure
Copy link
Member

@maarcingebala maarcingebala left a comment

Choose a reason for hiding this comment

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

Looks really good!

@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 8, 2020 13:30 Failure
@github-actions github-actions bot had a problem deploying to update-default-decimal-places September 9, 2020 09:15 Failure
@maarcingebala maarcingebala merged commit 38c395e into master Sep 9, 2020
@maarcingebala maarcingebala deleted the update-default-decimal-places branch September 9, 2020 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Products cannot be updated in currencies that do not use decimal
6 participants