{"action":"created","issue":{"url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4140","repository_url":"https://api.github.com/repos/reactioncommerce/reaction","labels_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4140/labels{/name}","comments_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4140/comments","events_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4140/events","html_url":"https://github.com/reactioncommerce/reaction/pull/4140","id":310818392,"node_id":"MDExOlB1bGxSZXF1ZXN0MTc5MDg0ODQ5","number":4140,"title":"Fix 4089: Taxcloud with marketplace setup.","user":{"login":"Akarshit","id":7762605,"node_id":"MDQ6VXNlcjc3NjI2MDU=","avatar_url":"https://avatars0.githubusercontent.com/u/7762605?v=4","gravatar_id":"","url":"https://api.github.com/users/Akarshit","html_url":"https://github.com/Akarshit","followers_url":"https://api.github.com/users/Akarshit/followers","following_url":"https://api.github.com/users/Akarshit/following{/other_user}","gists_url":"https://api.github.com/users/Akarshit/gists{/gist_id}","starred_url":"https://api.github.com/users/Akarshit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Akarshit/subscriptions","organizations_url":"https://api.github.com/users/Akarshit/orgs","repos_url":"https://api.github.com/users/Akarshit/repos","events_url":"https://api.github.com/users/Akarshit/events{/privacy}","received_events_url":"https://api.github.com/users/Akarshit/received_events","type":"User","site_admin":false},"labels":[{"id":863777895,"node_id":"MDU6TGFiZWw4NjM3Nzc4OTU=","url":"https://api.github.com/repos/reactioncommerce/reaction/labels/integrations","name":"integrations","color":"0f95dd","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2018-04-03T12:36:50Z","updated_at":"2018-07-02T12:05:48Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/4140","html_url":"https://github.com/reactioncommerce/reaction/pull/4140","diff_url":"https://github.com/reactioncommerce/reaction/pull/4140.diff","patch_url":"https://github.com/reactioncommerce/reaction/pull/4140.patch"},"body":"Resolves #4089  \r\nImpact: **minor**  \r\nType: **feature**\r\n\r\n## Issue\r\n1. Tax calculation in TaxCloud didn't support marketplace setup. It was using the address of the primary shop as origin.\r\n2. Tax calculation was not working because, the tax calculation was happening in async, during which the default value of tax(0) was being used.\r\n3. TaxCloud needs pincode in form of `{ Zip5: \"12345\", Zip4: \"1234\" }`, but we were sending it the pincode we had from the user.\r\n4. Tax rate was not stored per shop(as this was not ready for marketplace.)\r\n5. Taxcodes were not being fetched from TaxCloud's API. The job doing this was commented out. Also the tax-cloud API is now changed.\r\n\r\n## Solution\r\n1. A API call is made per shop, with all the items of the shop that were bought. So origin address changes with every shop's API call. Hence marketplace is supported\r\n2. Tax calculation happens in sync.\r\n3. This was not a major issue. To fix this used a regex to split the pincode and passed that to the API call.\r\n4. Tax rate is stored per shop. But should we do this? Shouldn't it be per item?\r\n5. Restored the job that fetches the taxcode and modified that code to reconcile the fetched taxcode with `TaxCode` schema.\r\n6. Modified the code to reconcile with the new taxcloud API for tax-codes.\r\n\r\n**Also I have removed the code which used to set `tax` to 0 by default. Because this was resetting the `tax` to 0, whenever cart was updated.** I have looked into the side-effects and couldn't spot any. But it would be better if someone can also think on this once.\r\n\r\n## Breaking changes\r\nNone\r\n\r\n## Testing\r\n\r\n### MarketPlace Setup\r\n1. Login as admin(A), enable TaxCloud.\r\n2. Invite a marketplace user(M).\r\n3. Login as M and create a product, publish it.\r\n4. Enable TaxCloud.\r\n5. Set up your shop's address.\r\n6. Add the product you created, and a product from the primary shop(Reaction Example Product) to the cart. \r\n7. Go to checkout screen. See the tax are being calculated correctly.\r\n8. Buy the products.\r\n9. Change either of the shop's address.\r\n10. Again repeat the above steps.\r\n11. See that the tax calculated is different.\r\n12. Try checkout with different pincodes format(1234-12345, 12345, 123456789), see that all of them work.\r\n13. Place the orders and see that tax is mentioned on the summary screen.\r\n1. Enter wrong credentials for tax-cloud and save\r\n1. Now add a product to the cart and checkout with it.\r\n1. Go to the orders in the Action Bar. Notice it is marked with a red dot and is labelled `Tax not calculated`.\r\n\r\n### Fetching of tax rates\r\n1. Enable tax-cloud.\r\n2. Rates will be updated hourly.\r\n3. To see this, go to PDP and edit product, select the title and go to Tax field. \r\n4. The dropdown for tax-codes should now be populated with the fetched tax codes."},"comment":{"url":"https://api.github.com/repos/reactioncommerce/reaction/issues/comments/401782590","html_url":"https://github.com/reactioncommerce/reaction/pull/4140#issuecomment-401782590","issue_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/4140","id":401782590,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTc4MjU5MA==","user":{"login":"zenweasel","id":72819,"node_id":"MDQ6VXNlcjcyODE5","avatar_url":"https://avatars1.githubusercontent.com/u/72819?v=4","gravatar_id":"","url":"https://api.github.com/users/zenweasel","html_url":"https://github.com/zenweasel","followers_url":"https://api.github.com/users/zenweasel/followers","following_url":"https://api.github.com/users/zenweasel/following{/other_user}","gists_url":"https://api.github.com/users/zenweasel/gists{/gist_id}","starred_url":"https://api.github.com/users/zenweasel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenweasel/subscriptions","organizations_url":"https://api.github.com/users/zenweasel/orgs","repos_url":"https://api.github.com/users/zenweasel/repos","events_url":"https://api.github.com/users/zenweasel/events{/privacy}","received_events_url":"https://api.github.com/users/zenweasel/received_events","type":"User","site_admin":false},"created_at":"2018-07-02T12:05:48Z","updated_at":"2018-07-02T12:05:48Z","author_association":"MEMBER","body":"Also, taxes are absolutely supposed to show in detail view "}}
{"actor":{"display_login":"zenweasel"}}