Handling discount and taxes, help needed!

Of course, InvoicePlane-it is the Italian fork.

What I mean is that we are prob. going to anticipate these fixes into 1.5.10, and they are going to be used and tested.

So whenever works for 1.6.0 will start, it can be a base for 1.6.0 for the international version. Just that.
I can make a second PR for the 1.6.0 branch myself when I finish on the other end.

1 Like

I’ve merged master on branch v1.6.0, and added both before and after-tax calculation based on a switch in settings. I’ve noticed there was a switch already there called ‘default_invoice_tax_rate_placement’ connected apparently to nothing, and I’ve used it for this.

To a first comparison, the numbers should be ok for both cases, we need to check the total invoice numbers, that are still wrong. Let’s go by steps. I don’t want to push too much stuff all at once.
I’ll make another commit fixing the total.

In the meantime,
lets’ all check the numbers together and make sure we all agree they are correct.

I’ve made a couple of invoices to check the calculation, but I don’t use the “after-tax” day-by-day, so please do a test and check.

1 Like

Got finally around to fixing totals, now they are correct.

I’ve made tests using the following scenarios:

Case 1:

Item price: 100 euro
Item discount: 10 euro
Item tax: 19% VAT

Before-Tax:

subprice: 90 euro
tax amount: 17.10 euro
discount: 10 euro
total: 107.10 euro

After-Tax:

subprice: 91.59 euro
tax amount: 17.41 euro
discount: 10 euro
total: 109 euro

Case 2:

Item price: 105 euro
Item quantity: 2
Item discount: 12 + 5% euro
Item tax: 19% VAT

Before-Tax:

subprice: 175.50 euro
tax amount: 33.34 euro
discount: 34.50 euro
total: 208.84 euro

After-Tax:

subprice: 168.84 euro
tax amount: 32.08 euro
discount: 48.98 euro
total 200.92 euro

To me it’s correct, consider merging in 1.6.0 when someone can.

1 Like

Befor merging I would like to publish a Test-Release for v1.6.0 made of your Fork (LINK) to give the community the opportunity to test it and to give some feedback.

Therefor I just build a “TaxTestv1.6.0” release which is just for testing purposes and should not be installed on any productive System, but on Testing/Dev System.

I have not tested it yet but will do so soon.
Here is the Test-Release:

Identifier Value
name: TaxTestv1.6.0.zip
md5: 0eb0db1a3ba5779a52dcbd99bdfbe5fb
sha256: b0c2ff61f5d5e8b1754e367e3f9b4d1389080f118424220c5895cbecc1a3a12a
size: 13.801 MiB
dl file (com): https://dl.invoiceplane.com/TaxTestv1.6.0.zip
txt sums (com): https://dl.invoiceplane.com/TaxTestv1.6.0.zip.txt
dl file (org): https://dl.invoiceplane.org/TaxTestv1.6.0.zip
txt sums (org): https://dl.invoiceplane.org/TaxTestv1.6.0.zip.txt

NOTE: This TestBuild is probably just PHP 7.0-7.2 compatible, so pls do not test with PHP 7.3 or PHP 7.4 yet

Pls report after testing if everything was like expected or not.
Have fun testing!

@Luca_Pellizzari
thank for the screenshot, i now understan and thanks to Martin and you for solving this in 1.6.
regards Jan

1 Like

@Martin_Anonym, I have tested and found 4 issues:

first: it is really good we have 2 options for VAT tax, this is a valuable feature!
there are some small calculation problems, that occur mainly because of this separation.

ISSUE 1

Invoiceplane has item tax and invoice tax.

item tax can be used when we have 2 or more VAT tax rates (eg. in NL 9% and 21%)
we can use the item tax to add separate tax rates: item tax

product 1 qty=1 price=100 discount=10% item tax=9% total 90
product 2 qty=1 price=100 discount=€50 item tax=21% total 50
===================================
subtotal=140

item tax 9%= 8.10
item tax 21%= 10.50
invoice tax=

discount= 20% PROBLEM!: now invoice tax must change accordingly,
			but which VAT rate?
total= 
paid=
balance=

This is important:
therefore we must disable discount and invoice tax in total column when using item tax.
and disable item tax when using invoice tax (1 VAT tax rate)

This applies to VAT tax for all countries and tax laws:
there cannot be another tax.

So before tax, after tax, invoice tax, item tax is confusing as hell, but its basically the same.
therefore we must use on or the other; disabling the fields would be a solution.

see screenshot issue_1.png


ISSUE 2

in product rows:

when adding only item tax and discount % ;it is calculated correctly, when adding discount amount it is not calculated correctly.

see screenshot issue_2.png


ISSUE 3

In totals column:

  • when adding discount % or amount from totals column, the invoice tax is NOT changed.
    But it should. Discount is on price not on VAT.

VAT plays never a role in any discount or price, its always applied after, for your governments wallet.

see screenshots issue_3.png, issue_3-1.png


ISSUE 4

in totals column:

when adding ONLY invoice tax and discount % it is calculated correctly, discount amount is NOT calculated correctly.

when there is no invoice tax, both discount % and discount amount are not calculated at all.

see screenshot issue_4.png, issue_4-1.png

@bob thanks for your valuable feedback.
Pls have a look here: LINK
As this is the official Pull Request and may contribute your Code-Change here.

I also added a comment to the PR and let @Luca_Pellizzari know that there are some issues/questions and may he clarifies how this exactly should work, or if this behaviour is a bug or a feature.

great martin thanks for your swift reaction. will also invest some time this week to contribute

@Luca_Pellizzari @bob
thanks for your work and for testing!

Anytime you need a new Test-Build pls tell me. We have optimized some Backend-Tasks to be able to generate Test-Builds much faster and much more frequently to support people which are supporting the project with Test-Builds.