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

Refactor checkout tax interface in plugins #9749

Merged

Conversation

fowczarek
Copy link
Member

@fowczarek fowczarek commented May 12, 2022

I want to merge this change because of refactoring the checkout tax interface in plugins.

  1. Drop the concept of undiscounted_price, price_with_sale, and price_with_discounts instead of that taxes should be calculated on the final price.
  2. Refactor SyncTax input interface to be consistent with description from [RFC] Add support for calculating taxes in Saleor Apps #9526

⚠️
This PR is to feature branch not to main.
Migrations will be refacotred in #9526.

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

@fowczarek fowczarek self-assigned this May 12, 2022
@fowczarek fowczarek force-pushed the refactor-checkout-tax-internal-interface branch 2 times, most recently from 9bff51e to 3014fa1 Compare May 12, 2022 11:22
@db-queries
Copy link

db-queries bot commented May 12, 2022

Here is the report for 2a76b00 (saleor:refactor-checkout-tax-internal-interface)
Missing base report (3634de0). The results couldn't be compared.

No differences were found.

# saleor.graphql.accountbenchmark account
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  addresses for federation query count                                    	          9	          9	              2
  customers query                                                         	         48	         48	              0
  delete staff members                                                    	         35	         35	              0
  query staff user                                                        	         18	         18	              3
  staff create                                                            	         23	         23	              3
  staff update groups and permissions                                     	         35	         35	              5
  users for federation query count                                        	          8	          8	              3

# saleor.graphql.accountbenchmark permission group
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  groups for federation query count                                       	          5	          5	              2
  permission group create                                                 	         21	         21	              2
  permission group delete                                                 	         22	         22	              3
  permission group query                                                  	          7	          7	              0
  permission group update                                                 	         35	         35	              1
  permission group update remove users with manage staff                  	         29	         29	              3

# saleor.graphql.appbenchmarks app extensions
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  app extensions                                                          	         15	         15	              0
  app extensions with filter[filter0]                                     	         14	         14	              0
  app extensions with filter[filter1]                                     	         10	         10	              0
  app extensions with filter[filter2]                                     	         14	         14	              0
  app extensions with filter[filter3]                                     	         10	         10	              0

# saleor.graphql.appbenchmarks apps
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  apps for federation query count                                         	          9	          9	              3

# saleor.graphql.attributebenchmark attribute
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  attribute translation                                                   	          6	          6	              0
  attribute value translation                                             	         26	         26	              0
  query attribute                                                         	          6	          6	              0
  query attributes                                                        	          8	          8	              0

# saleor.graphql.checkoutbenchmark checkout mutations
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  add billing address to checkout                                         	         54	         54	              5
  add checkout lines                                                      	         55	         55	              4
  add checkout lines with external shipping                               	        132	        132	             40
  add checkout lines with reservations                                    	        116	        116	             31
  add delivery to checkout                                                	         59	         59	              8
  add shipping to checkout                                                	         61	         61	              8
  checkout email update                                                   	         27	         27	              0
  checkout payment charge                                                 	         36	         36	             12
  checkout shipping address update                                        	         63	         63	              8
  checkout voucher code                                                   	         64	         64	              8
  complete checkout                                                       	        137	        137	             21
  complete checkout preorder                                              	        155	        155	             33
  complete checkout with digital line                                     	        197	        197	             47
  complete checkout with out of stock webhook                             	        139	        139	             21
  complete checkout with single line                                      	        139	        139	             21
  create checkout                                                         	         70	         70	             10
  create checkout for cc                                                  	         65	         65	              8
  create checkout with reservations                                       	        121	        121	             20
  customer complete checkout                                              	        152	        152	             25
  customer complete checkout for cc                                       	        155	        155	             28
  update checkout lines                                                   	         47	         47	              4
  update checkout lines with reservations                                 	        120	        120	             40

# saleor.graphql.checkoutbenchmark homepage
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  user checkout details                                                   	         37	         37	              1
  user checkout details with tax app                                      	         35	         35	              0

# saleor.graphql.discountbenchmark sales
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  sales query with channel slug                                           	         19	         19	              0
  sales query withot channel slug                                         	         18	         18	              0

# saleor.graphql.discountbenchmark vouchers
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  vouchers query with channel slug                                        	         19	         19	              0
  vouchers query withot channel slug                                      	         18	         18	              0

# saleor.graphql.giftcardbenchmark gift card mutations
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  create never expiry gift card                                           	         28	         28	              4
  gift card bulk activate by staff                                        	         16	         16	              3
  update gift card                                                        	         36	         36	              4

# saleor.graphql.giftcardbenchmark gift card queries
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  filter gift cards by products                                           	         14	         14	              3
  filter gift cards by tags                                               	         12	         12	              3
  filter gift cards by used by user                                       	         13	         13	              3
  query gift card details                                                 	         14	         14	              3
  query gift cards                                                        	         12	         12	              3

# saleor.graphql.orderbenchmark fulfillment refund and return products
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  fulfillment refund products order lines                                 	         55	         55	              2
  fulfillment return products order lines                                 	        100	        100	             11

# saleor.graphql.orderbenchmark order
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  staff multiple draft orders                                             	        609	        609	            471
  staff multiple orders                                                   	        159	        159	             86
  staff order details                                                     	         45	         45	              8
  user order details                                                      	         43	         43	              9

# saleor.graphql.orderbenchmark order fulfill
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  order fulfill                                                           	         19	         19	              3
  order fulfill with gift cards                                           	         19	         19	              3

# saleor.graphql.pagebenchmark page type
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  page types for federation query count                                   	          3	          3	              0
  query page type                                                         	         18	         18	              6
  query page types                                                        	         25	         25	             12

# saleor.graphql.productbenchmark category
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  categories children                                                     	          3	          3	              0
  categories for federation query count                                   	          3	          3	              0
  category delete                                                         	         86	         86	             16
  category view                                                           	         26	         26	              1

# saleor.graphql.productbenchmark collection
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  collection add products                                                 	         36	         36	              6
  collection bulk delete                                                  	         47	         47	              8
  collection view                                                         	          6	          6	              0
  collections for federation query count                                  	          7	          7	              2
  create collection                                                       	         36	         36	              5
  delete collection                                                       	         39	         39	              7
  remove products from collection                                         	         33	         33	              6
  retrieve collection channel listings                                    	          5	          5	              0

# saleor.graphql.productbenchmark homepage
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  report product sales                                                    	         10	         10	              3
  retrieve product list                                                   	          4	          4	              0

# saleor.graphql.productbenchmark product
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  filter products by attributes                                           	          9	          9	              0
  filter products by boolean attributes                                   	         19	         19	              0
  filter products by gift card                                            	         11	         11	              1
  filter products by numeric attributes                                   	         18	         18	              0
  product create                                                          	         73	         73	              8
  product details                                                         	         33	         33	              0
  product translations                                                    	          5	          5	              0
  products for federation query count                                     	          6	          6	              2
  products media for federation query count                               	          3	          3	              0
  products types for federation query count                               	          2	          2	              0
  retrieve channel listings                                               	         17	         17	              0
  retrieve product attributes                                             	          9	          9	              0
  retrieve product images                                                 	          4	          4	              0
  retrieve product media                                                  	          4	          4	              0
  retrive products with product types and attributes                      	          7	          7	              0
  update product                                                          	         51	         51	             11

# saleor.graphql.productbenchmark product variant channel listing update
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  variant channel listing update                                          	         45	         45	              3

# saleor.graphql.productbenchmark variant
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  product variant bulk create                                             	         66	         66	              3
  product variant create                                                  	         80	         80	              5
  products variants for federation query count                            	          6	          6	              2
  retrieve variant list                                                   	         28	         28	              2
  update product variant                                                  	         78	         78	              9

# saleor.graphql.productbenchmark variant stocks
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  product variants stocks create                                          	         26	         26	              4
  product variants stocks create with single webhook called               	         25	         25	              4
  product variants stocks delete                                          	         27	         27	              4
  product variants stocks delete with out of stock webhook many calls     	         23	         23	              3
  product variants stocks update                                          	         28	         28	              4
  query product variants stocks                                           	         10	         10	              0

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

# saleor.graphql.shippingbenchmark shipping methods
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  vouchers query with channel slug                                        	          9	          9	              0
  vouchers query without channel slug                                     	          9	          9	              0

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

# saleor.graphql.warehousebenchmark stocks
  test name                                                               	left count 	right count	duplicate count
  ------------------------------------------------------------------------	-----------	-----------	---------------
  stocks query                                                            	          5	          5	              0

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #9749 (2a76b00) into taxes-by-sync-webhooks (3634de0) will decrease coverage by 0.00%.
The diff coverage is 98.38%.

@@                    Coverage Diff                     @@
##           taxes-by-sync-webhooks    #9749      +/-   ##
==========================================================
- Coverage                   93.15%   93.14%   -0.01%     
==========================================================
  Files                         559      558       -1     
  Lines                       44852    44751     -101     
  Branches                     7541     7526      -15     
==========================================================
- Hits                        41780    41685      -95     
+ Misses                       1999     1994       -5     
+ Partials                     1073     1072       -1     
Impacted Files Coverage Δ
saleor/checkout/tests/conftest.py 100.00% <ø> (ø)
saleor/checkout/utils.py 94.15% <ø> (ø)
saleor/graphql/checkout/types.py 96.89% <ø> (ø)
saleor/payment/gateways/adyen/utils/common.py 92.62% <ø> (ø)
saleor/plugins/base_plugin.py 95.51% <ø> (-0.02%) ⬇️
saleor/webhook/serializers.py 83.05% <ø> (ø)
saleor/plugins/vatlayer/plugin.py 82.20% <75.00%> (-0.30%) ⬇️
saleor/checkout/base_calculations.py 93.22% <100.00%> (-0.90%) ⬇️
saleor/checkout/calculations.py 98.90% <100.00%> (-0.02%) ⬇️
saleor/checkout/complete_checkout.py 87.87% <100.00%> (ø)
... and 11 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 3634de0...2a76b00. Read the comment docs.

@fowczarek fowczarek requested review from a team and korycins May 12, 2022 12:06
@fowczarek fowczarek requested a review from a team May 12, 2022 13:23
@fowczarek fowczarek force-pushed the refactor-checkout-tax-internal-interface branch from 3014fa1 to 2a76b00 Compare May 12, 2022 13:48
@korycins korycins requested a review from a team May 12, 2022 14:00
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.

We should remember about updating Avatax Excise plugin.

@fowczarek
Copy link
Member Author

@maarcingebala it's to feature branch. Avatax Excise plugin will be updated at the end of refactoring of the tax interface.

@fowczarek fowczarek merged commit 0b25401 into taxes-by-sync-webhooks May 23, 2022
@fowczarek fowczarek deleted the refactor-checkout-tax-internal-interface branch May 23, 2022 08:06
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.

None yet

4 participants