After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 520547 - Invoice totals not calculated correctly for pretax discounts
Invoice totals not calculated correctly for pretax discounts
Status: RESOLVED OBSOLETE
Product: GnuCash
Classification: Other
Component: Business
unspecified
Other All
: Normal normal
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2008-03-05 17:15 UTC by Roman Bertle
Modified: 2018-06-29 22:01 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Roman Bertle 2008-03-05 17:15:16 UTC
There are three ways to treat a discount regarding taxes in invoices, depending on how discount_how is set: PRETAX, SAMETIME and POSTTAX. A little example:
Lets consider an invoice with 10 items, the price is $100, which gives
as raw amount $1000. Further lets assume that the tax is 10%, and that
the given price is without taxes (taxincluded is 0). The discount shall
be $10, which means that the discount_type is VALUE. Depending on
discount_how, we get:

* For PRETAX, the discount of $10 is subtracted from the raw amount,
  which yields a net amount of $990. The 10% tax is $99, and we get a
  gross amount of $1089. This is the way Gnucash does it.

* For SAMETIME, the discount and the taxes are calculated independently
  from the raw amount. The net amount is $990 after subtracting the $10
  discount, but the 10% tax is taken from $1000, which is $100 taxes.
  The gross amount is $1090, and again Gnucash does it this way.

* Now for POSTTAX, IMHO, first should be calculated the gross amount
  without discount, which is $1000, plus 10% of $1000, i.e. $1100. Now
  we subtract the discount of $10, and we get the final gross amount
  $1090. Finally to get the correct net amount, we invert the equation
  gross = (1+perc/100) * net, and get net = gross / (1+0.1), which is
  $990.91, and the tax is $99.09. But Gnucash does not work this way, it
  gives the same result as for SAMETIME !

For SAMETIME, in the end the paid tax is not 10% of the net amount. This can be
o.k., e.g. for a discount which cannot be taxed.
But for POSTTAX, I expect the tax rate to be 10%. For example, if one
gives a customer a $10 discount for the paid gross amount, which would be normally $1100, he should pay $1090, and the money I get should be $990.91, because only this way 10% taxes are paid from the amount actually paid.

In the gnucash code, file src/business/business-core/gncEntry.c, line 988, for POSTTAX the discount is calcated correctly from amount_gross (after_tax), but then it is subtracted simply from amount_net (pretax). Instead it should be IMHO subtracted from after_tax, and a new pretax should be calculated by subtracting the taxes, which are newly calculated from the corrected after_tax.

Best Regards, Roman
Comment 1 Geert Janssens 2010-08-26 14:23:23 UTC
Hmm, I have studied your proposal for a while, but as I see it, you are mistaken. In your posttax example you calculate the tax, then the discount and then the tax again ! This doesn't sound like post tax anymore, since you change the tax after you have calculated the discount.

IMO the only difference between a SAMETIME and a POSTTAX discount is which value is used as a basis to calculate taxes and discounts. Your example is unfortunate since you chose an absolute value for the discount instead of a percentage. Because of this the difference between sametime and posstax disapperas.

Doing the same math with a discount of 1% instead of a fixed 10$ gives these results:
Pretax:
Raw amount = 1000$
Discount = 1% of raw amount = 10$
Net amount = raw amount - discount = 990$
Tax = 10% of net amount = 99$
Gross amount = Net amount + Tax = 1089$

Sametime:
Raw amount = 1000$
Discount = 1% of raw amount = 10$
Net amount = raw amount - discount = 990$
Tax = 10% of raw amount = 100$
Gross amount = Net amount + Tax = 1090$

Posttax:
Raw amount = 1000$
Tax = 10% of raw amount = 100$
Discount = 1% of raw amount + tax = 11$
Net amount = Raw amount - discount = 989$
Gross amount = Net amount + Tax = 1089$

As you can see, in case of a discount percentage, Sametime and Posttax are not the same.

But I am not an accountant, so I can't authoritatively decide on this. Can you point us at some reference literature regarding this ?
Comment 2 Roman Bertle 2010-08-29 17:14:53 UTC
(In reply to comment #1)
> Hmm, I have studied your proposal for a while, but as I see it, you are
> mistaken. In your posttax example you calculate the tax, then the discount and
> then the tax again ! This doesn't sound like post tax anymore, since you
> change the tax after you have calculated the discount.

Well, this is because we have two pairs or raw/gross amounts, one pair before, and one pair after the discount. If we have a discount, the tax should be lower compared to the case where we have no discount, because the amount is smaller.

You can see this also from your PRETAX example, where the tax is also changed:
Raw_amount = 1000$
The original tax would be 100$. And after subtracting the discount, we have
a new tax:
 Tax = 10% of net amount = 99$.

This can also be seen if we set taxincluded=1. Here we start for the PRETAX
case with
 gross_amount = 1100$
 tax_without_discount = raw_amount * (0.1 / (1+0.1) = 100$
 net_amount_without_discount =  gross_amount - tax_without_discount = 1000$
And proceed as in your Pretax example, starting with a raw discount of 1000$
and, taking into account the discount, we use a new tax of 99$.
 
> IMO the only difference between a SAMETIME and a POSTTAX discount is which
> value is used as a basis to calculate taxes and discounts. Your example is
> unfortunate since you chose an absolute value for the discount instead of a
> percentage. Because of this the difference between sametime and posstax
> disapperas.

In your example, the difference between pretax and posttax disappears, you
get always 1089$. And I think the correct calculation for an 1% POSTTAX discount
should read:

Raw amount = 1000$
Tax_if_we_have_no_discount = 10% of raw amount = 100$
Gross_amount_without_discount = raw_amount + tax_if_we_have_no_discount = 1100$
Discount = 1% of gross_amount_without_discount = 11$
Gross_amount_with_discount = gross_amount_without_discount - discount = 1089$
Tax_with_discount = gross_amount_with_discount * (0.1 / (1+0.1) = 99$
Net_amount_with_discount = Gross_amount_with_discount - Tax_with_discount =
  Gross_amount_with_discount / (1+0.1) =  990$

In my calculation, the net amount is 990$, the tax is 10% of 990$, which is 99$,
and the gross amount is 1089$, with is 99% of the original gross amount. In
your calculation, the gross amount is also 1089$, but you pay 100$ to the tax
authority, and keep 989$ for yourself. IMO this is wrong. If I get from a
customer 1089$, I should keep 990$ for myself, and give only 99$ to the tax
authority, because 10% of 990$ is 99$.
Be aware that this is the same result as for PRETAX, as it should be in my
opinion, because it is the same to give 1% discount to the net amount as to
give it to the gross amount.

> But I am not an accountant, so I can't authoritatively decide on this. Can you
> point us at some reference literature regarding this ?

I am not an accountant, too. But I think it should be possible in GnuCash to
give an absolute or percent discount of the original gross amount to a
customer, and recalculate the tax from the new gross amount. Only this way,
in my example, 10% of my new net amount are paid as tax.

Maybe POSTTAX is used for another purpose. In this case, it would be useful
to have a new REFER_DISCOUNT_TO_GROSS_AMOUNT option, which works as i have
described. But I am still in doubt if the current POSTTAX implementation is useful, and think it should be calculated as I propose.

Best Regards, Roman
Comment 3 Geert Janssens 2010-08-30 12:52:55 UTC
(In reply to comment #2)
> Well, this is because we have two pairs or raw/gross amounts, one pair before,
> and one pair after the discount. If we have a discount, the tax should be lower
> compared to the case where we have no discount, because the amount is smaller.
> 
Actually I think that in not what posttax means. As I understand it, posttax means that the discount will not influence the tax, so the tax should remain unchanged with or without discount.

> You can see this also from your PRETAX example, where the tax is also changed:
> Raw_amount = 1000$
> The original tax would be 100$. And after subtracting the discount, we have
> a new tax:
>  Tax = 10% of net amount = 99$.
> 
That is because discount is calculated BEFORE tax is calculated. In that case, tax is indeed influenced by the discount.

> This can also be seen if we set taxincluded=1. Here we start for the PRETAX
> case with
>  gross_amount = 1100$
>  tax_without_discount = raw_amount * (0.1 / (1+0.1) = 100$
>  net_amount_without_discount =  gross_amount - tax_without_discount = 1000$
> And proceed as in your Pretax example, starting with a raw discount of 1000$
> and, taking into account the discount, we use a new tax of 99$.
> 
I didn't mention this in my first reply as I considered this a separate issue, but I think the PRETAX calculation with tax included is actually wrong. If tax is included then the amount*price the user enters is equivalent of net + discount + tax. Yet GnuCash does the calculation as if discount has no influence on the tax value (net + tax), so it actually does a sametime calculation here instead of a proper pretax calculation.

> > IMO the only difference between a SAMETIME and a POSTTAX discount is which
> > value is used as a basis to calculate taxes and discounts. Your example is
> > unfortunate since you chose an absolute value for the discount instead of a
> > percentage. Because of this the difference between sametime and posttax
> > disappears.
> 
> In your example, the difference between pretax and posttax disappears, you
> get always 1089$.
No pretax and posttax results are not the same. Only the total is the same, but both have different net and tax values. It's in fact your way of calculating that results in exactly the same pre- and posttax values.

> And I think the correct calculation for an 1% POSTTAX
> discount should read:
> 
> Raw amount = 1000$
> Tax_if_we_have_no_discount = 10% of raw amount = 100$
> Gross_amount_without_discount = raw_amount + tax_if_we_have_no_discount = 1100$
> Discount = 1% of gross_amount_without_discount = 11$
> Gross_amount_with_discount = gross_amount_without_discount - discount = 1089$
> Tax_with_discount = gross_amount_with_discount * (0.1 / (1+0.1) = 99$
> Net_amount_with_discount = Gross_amount_with_discount - Tax_with_discount =
>   Gross_amount_with_discount / (1+0.1) =  990$
> 
> In my calculation, the net amount is 990$, the tax is 10% of 990$, which is
> 99$,
> and the gross amount is 1089$, with is 99% of the original gross amount. In
> your calculation, the gross amount is also 1089$, but you pay 100$ to the tax
> authority, and keep 989$ for yourself. IMO this is wrong. If I get from a
> customer 1089$, I should keep 990$ for myself, and give only 99$ to the tax
> authority, because 10% of 990$ is 99$.
> Be aware that this is the same result as for PRETAX, as it should be in my
> opinion, because it is the same to give 1% discount to the net amount as to
> give it to the gross amount.
> 
That's exactly my point. You ARE doing a pretax calculation (albeit with a detour). Your tax value is influenced by the discount. In a posttax calculation, your tax amount should not be influenced by the discount. That's why there are separate pretax and posttax options.

I'll take your original example here also:
> Now for POSTTAX, IMHO, first should be calculated the gross amount
> without discount, which is $1000, plus 10% of $1000, i.e. $1100. Now
> we subtract the discount of $10, and we get the final gross amount
> $1090. Finally to get the correct net amount, we invert the equation
> gross = (1+perc/100) * net, and get net = gross / (1+0.1), which is
> $990.91, and the tax is $99.09. But Gnucash does not work this way, it
> gives the same result as for SAMETIME !
So as you calculate it:
Gross amount without discount = $1100
Net amount after discount = 990.91
Tax amount = 99.09
Which give a gross amount after discount of $1090
I quickly verified this as the result you would get for a 
* pretax calculation on a
* raw amount of 1100$
* with tax included = true
* and the corrected calculation I wrote about above.

So actually we're more or less talking about the same thing, but using a different name.

What is difficult with your calculation is that the user has to enter a price without tax and a discount with tax included. GnuCash wasn't designed for that. The user either enters both price and discount as tax included or both price and discount as not tax included.

If you want a way to enter a mixed form, you indeed have to start by calculating a posttax-like gross amount to get price and tax in the same reference frame (being with tax included) and continue with a (properly fixed) pretax calculation for the actual net and tax values.

> > But I am not an accountant, so I can't authoritatively decide on this. Can you
> > point us at some reference literature regarding this ?
> 
Reference literature or an accountant's advice would still be useful here though.

To conclude, I do agree one of the tax/discount calculations is not correct, but I think it's the pretax/tax-included variant. Fixing that option would get it very close to your request, except that it requires you to enter the price as tax included, since GnuCash doesn't allow value and discount to be in different tax reference frames.
Comment 4 Geert Janssens 2018-05-24 18:36:03 UTC
I have changed the bug title to reflect what I believe is the core issue here.
Comment 5 Roman Bertle 2018-06-27 15:11:00 UTC
Hello,

I do think now that all amounts are calculated correctly, but that the documentation is bad or missing, and that an additional important way to calculate discounts and taxes is needed.


Analysis of the situation
=========================

1. Taxes and discount are always calculated starting from the net amount. For
   tax_included = 1, gross values are entered into gnucash, but the net amount
   calculated by gnucash is used to infer taxes and discounts.

2. For PRETAX, first the net value is lowered by the discounts. The tax is
   calculated from the lower value. This is in my opinion the standard case. The
   tax is lowest for PRETAX.

3. For SAMETAX and POSTTAX, the tax is calculated from the net value before
   taking into account the discount. This could be e.g. useful if the state
   sets fixed prices for items, and demands that the tax should be calculated
   from these prices, even if the vendor demands a lower price from the
   customer.

4. SAMETAX and POSTTAX differ only for discount-percent, not for discount-value.
   For SAMETAX, the amount the customer pays, including taxes, is lowered by the
   discount percentage applied to the net value without taxes. For POSTTAX, this
   amount is lowered by the discount percentage applied to the gross value with
   taxes.

5. There is missing a way to give the customer a discount-value applied to the
   gross amount including taxes, using the PRETAX method. This way the
   government still gets its tax-percent of the amount actually payed, and the
   customer pays exactly discount-value less than he would have payed without
   discount. To this end I have proposed a REFER_DISCOUNT_TO_GROSS_AMOUNT above.

Things to do
============

IMHO points 1. to 4. of my analysis should be put somehow into the documentation, and point 5. should be implemented. Unfortunately, I do not use gnucash for invoices any more, and lack motivation.
Comment 6 John Ralls 2018-06-29 22:01:44 UTC
GnuCash bug tracking has moved to a new Bugzilla host. The new URL for this bug is https://bugs.gnucash.org/show_bug.cgi?id=520547. Please continue processing the bug there and please update any external references or bookmarks.