{"action":"created","issue":{"url":"https://api.github.com/repos/YetiForceCompany/YetiForceCRM/issues/3092","repository_url":"https://api.github.com/repos/YetiForceCompany/YetiForceCRM","labels_url":"https://api.github.com/repos/YetiForceCompany/YetiForceCRM/issues/3092/labels{/name}","comments_url":"https://api.github.com/repos/YetiForceCompany/YetiForceCRM/issues/3092/comments","events_url":"https://api.github.com/repos/YetiForceCompany/YetiForceCRM/issues/3092/events","html_url":"https://github.com/YetiForceCompany/YetiForceCRM/issues/3092","id":158638549,"number":3092,"title":"[Type::Bug] [Type::Enhancement] Incorrect calculation of Totals and taxes in Invoice module.","user":{"login":"dextras","id":7486027,"avatar_url":"https://avatars.githubusercontent.com/u/7486027?v=3","gravatar_id":"","url":"https://api.github.com/users/dextras","html_url":"https://github.com/dextras","followers_url":"https://api.github.com/users/dextras/followers","following_url":"https://api.github.com/users/dextras/following{/other_user}","gists_url":"https://api.github.com/users/dextras/gists{/gist_id}","starred_url":"https://api.github.com/users/dextras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dextras/subscriptions","organizations_url":"https://api.github.com/users/dextras/orgs","repos_url":"https://api.github.com/users/dextras/repos","events_url":"https://api.github.com/users/dextras/events{/privacy}","received_events_url":"https://api.github.com/users/dextras/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-06-06T09:42:48Z","updated_at":"2016-06-10T15:29:57Z","closed_at":null,"body":"It is somehow related to the issue which I closed recently:  #3086. The problem remains but it is a little different.\r\n\r\nSimilarly as in #3086 : If you add many products to the invoice (I've got a list of 40), then add a discount of some sort (e.g. 15%). Then add tax of some sort (e.g. 8%). As a result you receive:\r\n\r\n1) Two different Tax summations in your Invoice:\r\n- Sum at the end of the list of products.\r\n- Sum in the Table tax summary.\r\n\r\n2) When you calculate the Total after tax (invoice brutto) assuming the tax given in the Table tax summary (sum of netto after discount + tax from the table), it will not give you the total after tax.\r\n\r\nThis problem is visible when you want to create PDF template for Invoice. There are two fields: which might be of interest (in polish version):\r\n- Netto - gives you the sum of the netto(before tax and **before discount**) prices from the products given in the table,\r\n- Brutto - gives you the sum of the brutto(after discount and tax) prices from the products given in the table,\r\n\r\nFrom those two you are unable to create proper invoice template and as a result you are forced to create your own special pdf functions. This is what i did at least. It works but I used an ugly hack to do it :)\r\n\r\nAnyway how it should be done to meet general needs:\r\nIn the Invoice module when creating PDF template we should have several fields available:\r\n- total netto before discount (total before discount and before taxes - current \"netto\")\r\n- total netto after discount (total after discount - currently not available)\r\n- total brutto (after discount after taxes - current \"brutto\")\r\n- total tax\r\n\r\n\"total netto after discount\",\"total tax\" and \"total brutto\"should be calculated in one of the ways according to the additional \"switch\"(from netto/from brutto/sum of unit) available in the Invoice module:\r\n1) from netto:\r\n\r\n- netto (per tax type) = sum of **netto** from the products table(per tax type); \r\n- total tax = sum[(sum of **netto** from the products table(per tax type)) x (tax type %)] - in the same way as the \"Table TaxSummary\" is calculated but with the rounding mentioned in #3086;\r\n- total brutto = netto + tax;\r\n\r\n2) from brutto:\r\n\r\n- brutto = sum of sum of **brutto** from the products table(per tax type); \r\n- tax = sum[(sum of **brutto** from the products table(per tax type) x (tax type %) / ( 1+ (tax type %))]\r\n- netto = brutto - tax;\r\n\r\n3) sum of unit :\r\n- brutto = sum of **brutto** from the products table(per tax type);\r\n- tax = sum of **tax** from the products table(per tax type);\r\n- netto = sum of **netto** from the products table(per tax type);\r\n\r\nIn each case the rounding should be done on a table row level before doing any summation.\r\n\r\n[Here](https://drive.google.com/file/d/0B8wnn8AG8T3XVl9xOWZyaS1ROTA/view?usp=sharing) you will find an example in Excel of how I see all three methods of calculating taxes.\r\n\r\nsource: http://ksiegowosc.infor.pl/podatki/vat/faktura/697566,Metody-obliczania-kwoty-VAT-podawanej-na-fakturze.html (in Polish)"},"comment":{"url":"https://api.github.com/repos/YetiForceCompany/YetiForceCRM/issues/comments/225214835","html_url":"https://github.com/YetiForceCompany/YetiForceCRM/issues/3092#issuecomment-225214835","issue_url":"https://api.github.com/repos/YetiForceCompany/YetiForceCRM/issues/3092","id":225214835,"user":{"login":"mykljohn","id":11919990,"avatar_url":"https://avatars.githubusercontent.com/u/11919990?v=3","gravatar_id":"","url":"https://api.github.com/users/mykljohn","html_url":"https://github.com/mykljohn","followers_url":"https://api.github.com/users/mykljohn/followers","following_url":"https://api.github.com/users/mykljohn/following{/other_user}","gists_url":"https://api.github.com/users/mykljohn/gists{/gist_id}","starred_url":"https://api.github.com/users/mykljohn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mykljohn/subscriptions","organizations_url":"https://api.github.com/users/mykljohn/orgs","repos_url":"https://api.github.com/users/mykljohn/repos","events_url":"https://api.github.com/users/mykljohn/events{/privacy}","received_events_url":"https://api.github.com/users/mykljohn/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T15:29:57Z","updated_at":"2016-06-10T15:29:57Z","body":"thanks, I was just wondering if you had gotten it working.  I will pursue your suggestion."}}
{"actor":{"display_login":"mykljohn"}}