Taxes not properly calculated for Canada via draftOrderCalculate

Highlighted
Shopify Partner
8 0 0

I found an issue with draftOrderCalculate and Canada taxes. After updating to new Canadian taxes according to this article https://help.shopify.com/en/manual/taxes/canada/canada-tax-migrate on this store https://ocu-lysenko.myshopify.com/ (it's development store), I try to calculate taxes with next request. IMPORTANT: I send variant in quantity 2

 

POST http://ocu-lysenko.myshopify.com:443/admin/api/2020-04/graphql.json

Data: {"query":"mutation draftOrderCalculate($input: DraftOrderInput!) {\n  draftOrderCalculate(input: $input)\n  {\n    userErrors {\n      field\n      message\n    }\n    calculatedDraftOrder {\n      totalTax shippingLine { taxLines { rate ratePercentage title priceSet { shopMoney { amount currencyCode } } } } taxLines { rate ratePercentage title priceSet { shopMoney { amount currencyCode } } } customer { id firstName lastName email acceptsMarketing } availableShippingRates { handle price { amount currencyCode } title }\n    }\n  }\n}\n\n","variables":{"input":{"lineItems":[{"variantId":"gid://shopify/ProductVariant/32476683763791","quantity":2,"appliedDiscount":null}],"shippingAddress":{"firstName":"Test","lastName":"Test","address1":"street1","address2":null,"phone":"+380671234567","city":"city","countryCode":"CA","provinceCode":"QC","zip":"G1C6H2"},"billingAddress":{"firstName":"Google","lastName":"test","address1":"street1","address2":null,"phone":"+380671234567","city":"city","countryCode":"CA","provinceCode":"QC","zip":"G1C6H2"},"tags":"OCU DRAFT ORDER","email":"email@example.com"}}}

 

and got response:

 

{"data":{"draftOrderCalculate":{"userErrors":[],"calculatedDraftOrder":{"totalTax":"0.15","shippingLine":null,"taxLines":[{"rate":0.05,"ratePercentage":5.0,"title":"GST","priceSet":{"shopMoney":{"amount":"0.05","currencyCode":"USD"}}},{"rate":0.09975,"ratePercentage":9.975,"title":"QST","priceSet":{"shopMoney":{"amount":"0.1","currencyCode":"USD"}}}],"customer":{"id":"gid:\/\/shopify\/Customer\/2561218510927","firstName":"Test","lastName":"Test","email":"email@example.com","acceptsMarketing":true},"availableShippingRates":[{"handle":"shopify-Free%20Shipping-0.00","price":{"amount":"0.0","currencyCode":"USD"},"title":"Free Shipping"}]}}},"extensions":{"cost":{"requestedQueryCost":17,"actualQueryCost":16,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":984,"restoreRate":50.0}}}}

 

But, when I'm sending the same request, BUT with TWO line items of the same variant in quantity 1 for each one, I got next:

POST http://ocu-lysenko.myshopify.com:443/admin/api/2020-04/graphql.json

Data: {"query":"mutation draftOrderCalculate($input: DraftOrderInput!) {\n  draftOrderCalculate(input: $input)\n  {\n    userErrors {\n      field\n      message\n    }\n    calculatedDraftOrder {\n      totalTax shippingLine { taxLines { rate ratePercentage title priceSet { shopMoney { amount currencyCode } } } } taxLines { rate ratePercentage title priceSet { shopMoney { amount currencyCode } } } availableShippingRates { handle price { amount currencyCode } title }\n    }\n  }\n}\n\n","variables":{"input":{"lineItems":[{"variantId":"gid://shopify/ProductVariant/32476683763791","quantity":1,"appliedDiscount":null},{"variantId":"gid://shopify/ProductVariant/32476683763791","quantity":1,"appliedDiscount":null}],"shippingAddress":{"firstName":"Test","lastName":"Test","address1":"street1","address2":null,"phone":"+380671234567","city":"city","countryCode":"CA","provinceCode":"QC","zip":"G1C6H2"},"billingAddress":{"firstName":"Test","lastName":"Test","address1":"street1","address2":null,"phone":"+380671234567","city":"city","countryCode":"CA","provinceCode":"QC","zip":"G1C6H2"},"tags":"OCU DRAFT ORDER","email":"email@example.com","shippingLine":{"title":"Free Shipping","price":"0.0"}}}}

Response:

{"data":{"draftOrderCalculate":{"userErrors":[],"calculatedDraftOrder":{"totalTax":"0.32","shippingLine":{"taxLines":[]},"taxLines":[{"rate":0.05,"ratePercentage":5.0,"title":"GST","priceSet":{"shopMoney":{"amount":"0.12","currencyCode":"USD"}}},{"rate":0.09975,"ratePercentage":9.975,"title":"QST","priceSet":{"shopMoney":{"amount":"0.2","currencyCode":"USD"}}}],"availableShippingRates":[{"handle":"shopify-Free%20Shipping-0.00","price":{"amount":"0.0","currencyCode":"USD"},"title":"Free Shipping"}]}}},"extensions":{"cost":{"requestedQueryCost":16,"actualQueryCost":16,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":984,"restoreRate":50.0}}}}

So, as you can see for the first example we have "totalTax":"0.15" and and for the second one "totalTax":"0.32", for the same variant in the same quantity

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
644 78 141

Hey @alex_gonor,

I just tested this but wasn't able to replicate. Can you please provide the X-Request-ID value from the response headers of your call? I'll use this to check our logs and hopefully find more details there.

As well, I recommend adding the line items to your CalculatedDraftOrder response so you can be sure both items were actually added to the order.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

Highlighted
Shopify Partner
8 0 0

Thank you for responding @_JB . So, this is X-Request-ID with line items in response:

Quantity 2:

x-request-id: 9cccb4a5-87bf-4396-9c8f-8be697d7a684
{"draftOrderCalculate"=>
{"userErrors"=>[],
"calculatedDraftOrder"=>
{"totalTax"=>"0.15",
"shippingLine"=>nil,
"taxLines"=>
[{"rate"=>0.05, "ratePercentage"=>5.0, "title"=>"GST", "priceSet"=>{"shopMoney"=>{"amount"=>"0.05", "currencyCode"=>"USD"}}},
{"rate"=>0.09975, "ratePercentage"=>9.975, "title"=>"QST", "priceSet"=>{"shopMoney"=>{"amount"=>"0.1", "currencyCode"=>"USD"}}}],
"customer"=>{"id"=>"gid://shopify/Customer/3317476720719", "firstName"=>"test", "lastName"=>"test", "email"=>"email@example.com", "acceptsMarketing"=>false},
"availableShippingRates"=>[{"handle"=>"shopify-Free%20Shipping-0.00", "price"=>{"amount"=>"0.0", "currencyCode"=>"USD"}, "title"=>"Free Shipping"}],
"lineItems"=>[{"quantity"=>2, "variant"=>{"id"=>"gid://shopify/ProductVariant/32476683763791", "title"=>"blue"}, "variantTitle"=>"blue"}]}}}

 

Quantity 1 + 1:

x-request-id: ed12ab94-eb3f-439b-999e-a6c92d071588
{"draftOrderCalculate"=>
{"userErrors"=>[],
"calculatedDraftOrder"=>
{"totalTax"=>"0.32",
"shippingLine"=>nil,
"taxLines"=>
[{"rate"=>0.05, "ratePercentage"=>5.0, "title"=>"GST", "priceSet"=>{"shopMoney"=>{"amount"=>"0.12", "currencyCode"=>"USD"}}},
{"rate"=>0.09975, "ratePercentage"=>9.975, "title"=>"QST", "priceSet"=>{"shopMoney"=>{"amount"=>"0.2", "currencyCode"=>"USD"}}}],
"customer"=>{"id"=>"gid://shopify/Customer/3317476720719", "firstName"=>"test", "lastName"=>"test", "email"=>"email@example.com", "acceptsMarketing"=>false},
"availableShippingRates"=>[{"handle"=>"shopify-Free%20Shipping-0.00", "price"=>{"amount"=>"0.0", "currencyCode"=>"USD"}, "title"=>"Free Shipping"}],
"lineItems"=>
[{"quantity"=>1, "variant"=>{"id"=>"gid://shopify/ProductVariant/32476683763791", "title"=>"blue"}, "variantTitle"=>"blue"},
{"quantity"=>1, "variant"=>{"id"=>"gid://shopify/ProductVariant/32476683763791", "title"=>"blue"}, "variantTitle"=>"blue"}]}}}

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
644 78 141

Hey @alex_gonor,

Do you mind if I do some tests on your dev store? The logs aren't telling me much and I'm still not able to replicate elsewhere.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
8 0 0

Hey, @_JB yes of course you can test it on my developer store. Do you need anything from me?

0 Likes
Highlighted
Shopify Partner
8 0 0

Hey, @_JB any updates on this?

0 Likes