mirumee / prices

Python price handling for humans.
Other
268 stars 39 forks source link

Issue if fixed_discount #33

Closed gdoumenc closed 5 years ago

gdoumenc commented 5 years ago

There is a calculation issue in fixed_discount : the discount is not the same on net and gross to respect the tax on TaxedMoney

patrys commented 5 years ago

Please explain what you mean by that.

gdoumenc commented 5 years ago

Consider VAT of 20%, then G =N1.2 If you remove D from net N, the value of net will be N-D then G will be (N-D)1.2=G-D*1.2 not G-D. So on TaxedMoney you should used "taxed" discount value. I thing adding from_gross=False as key paramater for fixed_discount is a good idea... Hope I'm right...

patrys commented 5 years ago

If you want to discount the price before taxes, you can apply the discount before applying the tax. In many European countries, it is illegal to give discounts on the tax (as it that case it would be the government giving you a discount and not the seller).

gdoumenc commented 5 years ago

The issue is not on legal aspect, but the fact that if you have a TaxedMoney which is good, and then if you apply your fixed_discount function, then your TaxedMoney becomes wrong.. That's the issue.

patrys commented 5 years ago

It is not wrong unless you provide a use case where it's wrong, the whole point of the current implementation is not to modify the tax amount (as opposed to tax rate).

gdoumenc commented 5 years ago

Sorry but the tax rate should be same not the tax amount with or without discount you have to pay 20% of VAT... If I pay a product 100€ HT,meaning I have to pay 120€ TTC (20% in France) So my cart total is Moneytaxed (100, 120). I have a fixed discount of 20€ (from_gross case), meaning I have to pay 100€ TTC. My cart total should be MoneyTaxed(83.33, 100) and not MoneyTaxed(80, 100). If I have a fixed_discount of 20€ HT (from_net case), meaning I have to pay 80€ HT. My cart total should be MoneyTaxed(80, 96) and not MoneyTaxed(80, 100).

patrys commented 5 years ago

You already have a method to achieve that. Apply the discount before applying taxes. Discounting post-tax does not modify the tax amount to solve the case I mentioned earlier (in some countries it's illegal to discount the amount of tax as it's taking the money away from the government so you calculate taxes from the undiscounted value).