{"action":"created","issue":{"url":"https://api.github.com/repos/woothemes/woocommerce/issues/9921","labels_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9921/labels{/name}","comments_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9921/comments","events_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9921/events","html_url":"https://github.com/woothemes/woocommerce/pull/9921","id":124379071,"number":9921,"title":"VAT exempt and “TAX enabled” handling in back end and Orders API","user":{"login":"peterrath","id":16391244,"avatar_url":"https://avatars.githubusercontent.com/u/16391244?v=3","gravatar_id":"","url":"https://api.github.com/users/peterrath","html_url":"https://github.com/peterrath","followers_url":"https://api.github.com/users/peterrath/followers","following_url":"https://api.github.com/users/peterrath/following{/other_user}","gists_url":"https://api.github.com/users/peterrath/gists{/gist_id}","starred_url":"https://api.github.com/users/peterrath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterrath/subscriptions","organizations_url":"https://api.github.com/users/peterrath/orgs","repos_url":"https://api.github.com/users/peterrath/repos","events_url":"https://api.github.com/users/peterrath/events{/privacy}","received_events_url":"https://api.github.com/users/peterrath/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/woothemes/woocommerce/milestones/51","html_url":"https://github.com/woothemes/woocommerce/milestones/2.6","labels_url":"https://api.github.com/repos/woothemes/woocommerce/milestones/51/labels","id":1425734,"number":51,"title":"2.6","description":"","creator":{"login":"mikejolley","id":90977,"avatar_url":"https://avatars.githubusercontent.com/u/90977?v=3","gravatar_id":"","url":"https://api.github.com/users/mikejolley","html_url":"https://github.com/mikejolley","followers_url":"https://api.github.com/users/mikejolley/followers","following_url":"https://api.github.com/users/mikejolley/following{/other_user}","gists_url":"https://api.github.com/users/mikejolley/gists{/gist_id}","starred_url":"https://api.github.com/users/mikejolley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikejolley/subscriptions","organizations_url":"https://api.github.com/users/mikejolley/orgs","repos_url":"https://api.github.com/users/mikejolley/repos","events_url":"https://api.github.com/users/mikejolley/events{/privacy}","received_events_url":"https://api.github.com/users/mikejolley/received_events","type":"User","site_admin":false},"open_issues":25,"closed_issues":2,"state":"open","created_at":"2015-11-23T18:25:09Z","updated_at":"2016-01-04T11:40:41Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-12-30T17:46:13Z","updated_at":"2016-01-04T23:05:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/woothemes/woocommerce/pulls/9921","html_url":"https://github.com/woothemes/woocommerce/pull/9921","diff_url":"https://github.com/woothemes/woocommerce/pull/9921.diff","patch_url":"https://github.com/woothemes/woocommerce/pull/9921.patch"},"body":"It is about two related problems about VAT handling: \r\n1. vat exemption cannot be handled completely (in back-end, API), and \r\n2. tax enabled / disabled status is not fully handled (in back-end)\r\n\r\n1. We realized these issues when tried to use WooCommerce EU VAT Number plugin of WooThemes, which cannot calculate the right taxes on the back-end. There is a ticket about this issue: #368338. According to the answer of support team, we would develop an alternative solution using existing filters of WC, but WooCommerce core does not completely support the above mentioned functions.\r\n2. Another related problem that tax enabled / disabled option is not handled right, when use \"Calculate Taxes\" button in back end. If some tax rates are set, but tax is disabled (tax enabled option is off), taxes are calculated and saved (but not shown), even though \"tax enabled\" option is off. After re-enabling taxes, the order totals will be shown. So an order that has not got displayed tax, later has displayed tax.\r\n\r\nBase of the solution:\r\nIn front-end “is_vat_exempt” data controls if VAT has to be calculated or not. WooCommerce EU VAT Number plugin uses this on front-end:\r\nclass-wc-cart.php  calculate_totals()\r\nif ( WC()->customer->is_vat_exempt() ) {\r\n\t$this->remove_taxes();\r\n}\r\nWC Back-end and Orders API do not handle vat_exempt status at this moment.\r\n\r\nSolution:\r\nclass-wc-ajax.php calc_line_taxes() - front end\r\nApply an additional condition for checking if tax is enabled and there is not vat exempt. If this is true, then calculate taxes on front-end, otherwise not.\r\nTAX exempt can be set by a new woocommerce_ajax_calc_line_taxes_is_vat_exempt filter.\r\n(This condition is similar to the if statement of abstract-wc-order.php->calculate_totals() function.)\r\n\r\nclass-wc-api-orders.php create_order( $data ) - Orders API\r\nAt this moment we cannot find a way how to create an order using the Orders API with tax exempt status. An additional “is_vat_exempt” API field can be used for this reason. If this field is set and true then VAT is not calculated.\r\n\r\nThanks in advance."},"comment":{"url":"https://api.github.com/repos/woothemes/woocommerce/issues/comments/168839504","html_url":"https://github.com/woothemes/woocommerce/pull/9921#issuecomment-168839504","issue_url":"https://api.github.com/repos/woothemes/woocommerce/issues/9921","id":168839504,"user":{"login":"peterrath","id":16391244,"avatar_url":"https://avatars.githubusercontent.com/u/16391244?v=3","gravatar_id":"","url":"https://api.github.com/users/peterrath","html_url":"https://github.com/peterrath","followers_url":"https://api.github.com/users/peterrath/followers","following_url":"https://api.github.com/users/peterrath/following{/other_user}","gists_url":"https://api.github.com/users/peterrath/gists{/gist_id}","starred_url":"https://api.github.com/users/peterrath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterrath/subscriptions","organizations_url":"https://api.github.com/users/peterrath/orgs","repos_url":"https://api.github.com/users/peterrath/repos","events_url":"https://api.github.com/users/peterrath/events{/privacy}","received_events_url":"https://api.github.com/users/peterrath/received_events","type":"User","site_admin":false},"created_at":"2016-01-04T23:05:06Z","updated_at":"2016-01-04T23:05:06Z","body":"1. Sorry for disagree with you, but this is a real problem for us, there is a lot of situation when an VAT exempt order which was created on front end should be modified and recalculated. E.g. you would like to give the customer a special price by modifying the line item price of the order. Or if a customer ask over phone to add a new product to his order. \r\nNormally in these cases the tax has to be recalculated by using calculate taxes button. If the shop administrator accidentally press this button in case of a VAT exempt order, then a wrong order will be generated with none zero tax. Applying the simple modification that we suggested in class-wc-ajax.php this problem can be eliminated, end using WooThemes \"WooCommerce EU VAT Number plugin\" can handle this situation well on back-end. \r\nSorry to write it again, I just want to explain the situation when it causes problem for us. It is really important for me to find a solution, because we use back end heavily, and have to apply EU VAT without any problem.\r\n\r\n2. The API solution that you have suggested requires that the data be saved as a post meta before this: https://github.com/woothemes/woocommerce/blob/master/includes/abstracts/abstract-wc-order.php#L626 \r\nThis requires an additional customization of the API, because these data is not saved now. So this will be a little bit complicated than a single additional if condition.\r\n\r\nAt this moment WC do not save these data in front-end, just use them in memory variables. If API require to save it, it will be a different solution than in front-end.\r\nThe solution that I suggested does not require saving (similarly to front-end), it uses $data parameter of create_order on the fly. I think this or other solution that does not require saving fits better to the existing front-end vat exempt handling.\r\nI suggest to consider this.\r\n\r\nThanks!"}}