{"action":"created","issue":{"url":"https://api.github.com/repos/iZettle/izettle-toolbox/issues/219","repository_url":"https://api.github.com/repos/iZettle/izettle-toolbox","labels_url":"https://api.github.com/repos/iZettle/izettle-toolbox/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/iZettle/izettle-toolbox/issues/219/comments","events_url":"https://api.github.com/repos/iZettle/izettle-toolbox/issues/219/events","html_url":"https://github.com/iZettle/izettle-toolbox/pull/219","id":218954940,"number":219,"title":"Adds support for getting the amount of VAT per unit of a line","user":{"login":"olsson","id":2767569,"avatar_url":"https://avatars0.githubusercontent.com/u/2767569?v=3","gravatar_id":"","url":"https://api.github.com/users/olsson","html_url":"https://github.com/olsson","followers_url":"https://api.github.com/users/olsson/followers","following_url":"https://api.github.com/users/olsson/following{/other_user}","gists_url":"https://api.github.com/users/olsson/gists{/gist_id}","starred_url":"https://api.github.com/users/olsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olsson/subscriptions","organizations_url":"https://api.github.com/users/olsson/orgs","repos_url":"https://api.github.com/users/olsson/repos","events_url":"https://api.github.com/users/olsson/events{/privacy}","received_events_url":"https://api.github.com/users/olsson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"MrShish","id":108077,"avatar_url":"https://avatars3.githubusercontent.com/u/108077?v=3","gravatar_id":"","url":"https://api.github.com/users/MrShish","html_url":"https://github.com/MrShish","followers_url":"https://api.github.com/users/MrShish/followers","following_url":"https://api.github.com/users/MrShish/following{/other_user}","gists_url":"https://api.github.com/users/MrShish/gists{/gist_id}","starred_url":"https://api.github.com/users/MrShish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrShish/subscriptions","organizations_url":"https://api.github.com/users/MrShish/orgs","repos_url":"https://api.github.com/users/MrShish/repos","events_url":"https://api.github.com/users/MrShish/events{/privacy}","received_events_url":"https://api.github.com/users/MrShish/received_events","type":"User","site_admin":false},"assignees":[{"login":"MrShish","id":108077,"avatar_url":"https://avatars3.githubusercontent.com/u/108077?v=3","gravatar_id":"","url":"https://api.github.com/users/MrShish","html_url":"https://github.com/MrShish","followers_url":"https://api.github.com/users/MrShish/followers","following_url":"https://api.github.com/users/MrShish/following{/other_user}","gists_url":"https://api.github.com/users/MrShish/gists{/gist_id}","starred_url":"https://api.github.com/users/MrShish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrShish/subscriptions","organizations_url":"https://api.github.com/users/MrShish/orgs","repos_url":"https://api.github.com/users/MrShish/repos","events_url":"https://api.github.com/users/MrShish/events{/privacy}","received_events_url":"https://api.github.com/users/MrShish/received_events","type":"User","site_admin":false},{"login":"adamvoncorswant","id":1142587,"avatar_url":"https://avatars1.githubusercontent.com/u/1142587?v=3","gravatar_id":"","url":"https://api.github.com/users/adamvoncorswant","html_url":"https://github.com/adamvoncorswant","followers_url":"https://api.github.com/users/adamvoncorswant/followers","following_url":"https://api.github.com/users/adamvoncorswant/following{/other_user}","gists_url":"https://api.github.com/users/adamvoncorswant/gists{/gist_id}","starred_url":"https://api.github.com/users/adamvoncorswant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamvoncorswant/subscriptions","organizations_url":"https://api.github.com/users/adamvoncorswant/orgs","repos_url":"https://api.github.com/users/adamvoncorswant/repos","events_url":"https://api.github.com/users/adamvoncorswant/events{/privacy}","received_events_url":"https://api.github.com/users/adamvoncorswant/received_events","type":"User","site_admin":false},{"login":"martinfridh","id":16650823,"avatar_url":"https://avatars3.githubusercontent.com/u/16650823?v=3","gravatar_id":"","url":"https://api.github.com/users/martinfridh","html_url":"https://github.com/martinfridh","followers_url":"https://api.github.com/users/martinfridh/followers","following_url":"https://api.github.com/users/martinfridh/following{/other_user}","gists_url":"https://api.github.com/users/martinfridh/gists{/gist_id}","starred_url":"https://api.github.com/users/martinfridh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinfridh/subscriptions","organizations_url":"https://api.github.com/users/martinfridh/orgs","repos_url":"https://api.github.com/users/martinfridh/repos","events_url":"https://api.github.com/users/martinfridh/events{/privacy}","received_events_url":"https://api.github.com/users/martinfridh/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2017-04-03T14:38:49Z","updated_at":"2017-04-04T07:57:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/iZettle/izettle-toolbox/pulls/219","html_url":"https://github.com/iZettle/izettle-toolbox/pull/219","diff_url":"https://github.com/iZettle/izettle-toolbox/pull/219.diff","patch_url":"https://github.com/iZettle/izettle-toolbox/pull/219.patch"},"body":"### Background\r\nIn the UK, we must, [according to law](https://www.gov.uk/vat-record-keeping/vat-invoices), list the price per item excluding VAT on invoices. The cart library today supports listing price per _line_ and price per _cart_ excluding VAT. But this is not enough for the UK. \r\n\r\n### What does this PR change?\r\nThis PR adds a field to the `ItemLine` class called `unitVat`. `CartUtils.buildItemLines` is modified to also put the VAT amount per unit in the line. I consider this to be the most backwards-compatible way to accomplish this.\r\n\r\n### Could this be done in a better way?\r\nYes, absolutely! \r\nWe could modify `Item` to add a default method:\r\n```java\r\n/**\r\n * Returns the VAT amount per item\r\n * @return\r\n */\r\ndefault long getUnitVat() {\r\n    return CartUtils.calculateVatFromAmount(getUnitPrice(), getVatPercentage());\r\n}\r\n```\r\nBut we can't do this right now, because it would break Android support."},"comment":{"url":"https://api.github.com/repos/iZettle/izettle-toolbox/issues/comments/291423561","html_url":"https://github.com/iZettle/izettle-toolbox/pull/219#issuecomment-291423561","issue_url":"https://api.github.com/repos/iZettle/izettle-toolbox/issues/219","id":291423561,"user":{"login":"olsson","id":2767569,"avatar_url":"https://avatars0.githubusercontent.com/u/2767569?v=3","gravatar_id":"","url":"https://api.github.com/users/olsson","html_url":"https://github.com/olsson","followers_url":"https://api.github.com/users/olsson/followers","following_url":"https://api.github.com/users/olsson/following{/other_user}","gists_url":"https://api.github.com/users/olsson/gists{/gist_id}","starred_url":"https://api.github.com/users/olsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olsson/subscriptions","organizations_url":"https://api.github.com/users/olsson/orgs","repos_url":"https://api.github.com/users/olsson/repos","events_url":"https://api.github.com/users/olsson/events{/privacy}","received_events_url":"https://api.github.com/users/olsson/received_events","type":"User","site_admin":false},"created_at":"2017-04-04T07:57:38Z","updated_at":"2017-04-04T07:57:38Z","body":"@adamvoncorswant UK (B2B) invoices present everything excluding VAT, except the total line. \r\n\r\nIf a company with a VAT number sends an invoice to another company, we should not show any VAT per item or per line. The only places we show VAT is at the bottom: total VAT amount and total including VAT. We do not need to show the actual unit VAT amount, but instead the unit price excluding VAT.  This is what we interpret to be the \"price per item excluding VAT.\"\r\n\r\nI chose to implement this as `getUnitVat()` to follow the existing pattern of getting the amount of VAT, not the adjusted unit price.  The invoice service will use the Cart library to deduct the `unitVat` from the `unitPrice` when rendering the invoice."}}
{"actor":{"display_login":"olsson"}}