Bug 10613 - Gst is not calculated correctly on the invoice page
Summary: Gst is not calculated correctly on the invoice page
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
: 11681 (view as bug list)
Depends on: 11755
Blocks: 12274
  Show dependency treegraph
 
Reported: 2013-07-19 09:43 UTC by Jonathan Druart
Modified: 2014-12-07 20:07 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 10613: The gst rate is not correctly calculated on the invoice page. (14.02 KB, patch)
2013-07-19 09:48 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10613: FIX typo supplierid vs booksellerid (925 bytes, patch)
2013-10-25 11:54 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10613: The gst rate is not correctly calculated on the invoice page. (14.32 KB, patch)
2014-03-06 10:08 UTC, Jacek Ablewicz
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10613: FIX typo supplierid vs booksellerid (992 bytes, patch)
2014-03-06 10:09 UTC, Jacek Ablewicz
Details | Diff | Splinter Review
Bug 10613: FIX QA issues (1.43 KB, patch)
2014-03-24 09:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10613: The gst rate is not correctly calculated on the invoice page. (14.38 KB, patch)
2014-03-24 16:00 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10613: FIX typo supplierid vs booksellerid (979 bytes, patch)
2014-03-24 16:00 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10613: FIX QA issues (974 bytes, patch)
2014-03-24 16:00 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10613: FIX QA issues (1.00 KB, patch)
2014-03-25 10:56 UTC, Jacek Ablewicz
Details | Diff | Splinter Review
[PASSED QA] Bug 10613: The gst rate is not correctly calculated on the invoice page. (14.44 KB, patch)
2014-04-09 16:52 UTC, Katrin Fischer
Details | Diff | Splinter Review
[PASSED QA] Bug 10613: FIX typo supplierid vs booksellerid (1.02 KB, patch)
2014-04-09 16:53 UTC, Katrin Fischer
Details | Diff | Splinter Review
[PASSED QA] Bug 10613: FIX QA issues (2.81 KB, patch)
2014-04-09 16:53 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2013-07-19 09:43:09 UTC
The gst used is the gst defined at the supplier level. We should use the gst defined at the order level (if exists).
Comment 1 Jonathan Druart 2013-07-19 09:48:27 UTC Comment hidden (obsolete)
Comment 2 I'm just a bot 2013-09-29 05:32:07 UTC
Patch applied cleanly, go forth and signoff
Comment 3 Mathieu Saby 2013-10-02 07:26:21 UTC
Hi
I did not test yet, but I noticed some months ago that invoices seem to use ecost, while they should use the real unit cost (MT11242).
Could you say me if this bug is also changing this behavior?

M. Saby
Comment 4 Jonathan Druart 2013-10-02 08:10:25 UTC
(In reply to mathieu saby from comment #3)
> Hi
> I did not test yet, but I noticed some months ago that invoices seem to use
> ecost, while they should use the real unit cost (MT11242).
> Could you say me if this bug is also changing this behavior?

I don't remember.
Comment 5 Mathieu Saby 2013-10-02 08:20:32 UTC
Well, I will test and describe what I see.

Mathieu
Comment 6 Mathieu Saby 2013-10-02 08:47:16 UTC
I made 2 tests. 
I think some points need to be fixed, or maybe I am not well understanding the price management in Koha


first test with "yes" (list price) and "yes" (invoiced price) for the 2 prefs of the vendor.

10 euros
discount 10%
tax rate : 5,5%

on receipt page:
- ecost : 9 euros
- actual price : 9 euros

on invoice, before clicking on "finish receiving" :
- ecost : 9 euros
- actual price : 9 euros
- total tax inc : 9 euros
=> OK

on invoice, after clicking on "finish receiving" :
- est. : 9 euros
- total tax inc : 9.48 euros
=> KO

================
2d test with "yes" and "no" for the 2 prefs of the vendor.

10 euros
discount 10%
tax rate : 5,5%

on receipt page:
- ecost : 9,48 euros
- actual price : 8.53 euros
=> KO. Ecost should be 9 euros. Probably not linked with your patch.

on invoice, before clicking on "finish receiving" :
- ecost : 8.53 euros
- actual price : 8.53 euros
- Total tax inc. : 9.00	euros
=> KO. Why adding the tax on the "Total tax inc."? We don't pay tax for this vendor.

on invoice, after clicking on "finish receiving" :
- est. : 9 euros
- total tax inc : 9.48 euros
=> KO

=> Failed QA : 
* for "yes" and "no" (2d test) : the "total tax inc." amount should be 8.53, because we don't add tax for this vendor (if I understand well price management)

* after the reception is finished, the table for "invoice details"
- does not give me the actual price
- still add tax even when it is not needed



I note an other bug, probably in master : 
with "yes" / "no" preference (list price includes tax and invoiced does not include tax), the Replacement price on receipt page is bad (9.48 euros, while it should be 9 euros)

Mathieu
Comment 7 Mathieu Saby 2013-10-02 08:48:32 UTC
AHHH
Sorry
In fact your patch did not apply well on my VM!
So I tested the current master ;-)

Mathieu
Comment 8 Mathieu Saby 2013-10-02 10:42:05 UTC
(my previous test was made on master, and I made a confusion between receipt page and invoiced page, so forget it)

I tested with your patch
for all test, a basket with 1 book
- list price (the one I entered) : 10 eur
- tax : vat = 5,5%
- discount = 10%

I have made a complete acq workflow and found some weird things. Most of all are are not related with your patch. Only the 4th step of each test (invoice page) is directly related with it.
I made 4 full tests for all the possible vendor setting. 

My conclusion is : the more I test, the less I understand price management in Koha, and the documentation about it is too poor, so I cannot be sure, but I think your patch was not working well for test 1,2,3.
I also think there are some other bugs in baskets and receipt pages on current master.

So all that I can do is Fail QA for the moment.

If I misunderstood price management, please correct me. If there are bugs to be fixed in basket and receipt page, I would like to know it (And I would also DREAM of a page on the wiki or on Koha documentation that explain precisely what Koha is supposed to do with prices and taxes..., or maybe a kind of UT for prices, but I don't know how it could be possible)

Mathieu

test 1 : 
vendor no (list price) / no (invoiced price).  The list price entered by the librarian does NOT include tax, and the library does NOT pay tax

basket :
- RRP tax exc. : 10
- RRP tax inc. : 10.55
- ecost price tax exc. : 9
- ecost price tax inc. : 9.49
=> maybe KO, but out of the scope of this bug : if the library does not pay tax, the total ecost price tax inc. should probably be the same as the total price tax exc. Or the column "ecost tax inc." should be hidden if it means nothing in this configuration.

receipt page :
- replacement : 10
- budgeted : 9
- actual cost : 9
=> maybe KO, but out of the scope (I suppose replacement price should be tax included in remplacement cost)

receipt page (after reception, table "already received") :
- est cost : 9
- actual cost : 9
- total : 9
- Total tax inc. : 9.49
=> KO for "Total tax inc. : 9.49", Should be "9", but out of the scope of this bug

invoice page :
- actual cost tax ecl : 9
- actual cost tax incl : 9.49
=> KO : we don't pay tax for this vendor, so actual cost tax incl should be "9"

=========
test 2:
vendor yes  (list price) / yes  (invoiced price).  The list price entered by the librarian does include tax, and the library does pay tax

basket :
- RRP tax exc. : 9.48
- RRP tax inc. : 10
- total price tax exc. : 8.53
- total price tax inc. : 9
=> OK

receipt page :
- replacement : 10
- budgeted : 9
- actual cost : 9
=> OK

receipt page (after reception, table "already received") :
- est cost : 9
- actual cost : 9
- total : 9
- Total tax inc. : 9
=> OK

invoice page :
- actual cost tax ecl : 9
- actual cost tax incl : 9.49
=> KO : we should have "8.53" and "9"

======
Test 3:
vendor yes  (list price) / no  (invoiced price). The list price entered by the librarian does include tax, and the library does NOT pay tax

basket :
- RRP tax exc. : 9.48
- RRP tax inc. : 10
- total price tax exc. : 8.53
- total price tax inc. : 9
=> maybe KO but out of the scope of the bug : If the library does not pay tax, ecost tax inc. should be the same as tax exc. and the 2 equal 8.53 ? Or the column should be hidden

receipt page :
- replacement : 9.48
- budgeted : 8.53
- actual cost : 8.53
=> maybe KO : replacement price must be tax inc. (I suppose so, if the aim is to know the public price of the book to get it paid back by a reader who had lost it). 

receipt page (after reception, table "already received") :
- est cost : 8.53
- actual cost : 8.53
- total : 8.53
- Total tax inc. : 9
=> KO. Total tax inc. should be "8.53" as we pay no tax

invoice page :
- actual cost tax ecl : 9
- actual cost tax incl : 9.49
=> KO : we should have "8.53" in both column

======
test 4:
vendor no  (list price) / yes  (invoiced price).  The list price entered by the librarian does NOT include tax, and the library does pay tax

basket :
- RRP tax exc. : 10
- RRP tax inc. : 10.55
- total price tax exc. : 9
- total price tax inc. : 9.49
=> OK

receipt page :
- replacement : 10.55
- budgeted : 9.49
- actual cost : 9.49
=> OK

receipt page (after reception, table "already received") :
- est cost : 9.49
- actual cost : 9.49
- total : 9.49
- Total tax inc. (bottom of table) : 9.49
=> OK

invoice page :
- actual cost tax ecl : 9
- actual cost tax incl : 9.49
=> OK
Comment 9 Jonathan Druart 2013-10-25 11:54:25 UTC Comment hidden (obsolete)
Comment 10 I'm just a bot 2013-11-07 08:22:43 UTC
Patch applied cleanly

testing 2 commit(s) (applied to 5fa6168 'Bug 11204: make pendingreserves use d')

 [1;32mOK[0m	acqui/invoice.pl
 [1;32mOK[0m	koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt
Comment 11 Mathieu Saby 2013-11-09 15:33:09 UTC
It is not working well, and most of all, improving the display of rrp and ecost price on invoices is maybe a loss of time.

The prices that we MUST have on invoice page are the prices based on unitcost, aka the real cost of the item, entered at receipt stage.
Other prices (rrp/ecost could be displayed but they are not needed)

What we absolutely need in library is: 
- unitprice HT
- tax on unitprice HT
- unitprice TTC
- quantity
- unitprice TTC * quantity
with clear labels on header of table to show at first glance is a price is with or without tax


Here are my tests :

1st test : 

with no/no parameters, and an order for a  book costing 100 euros in vendor's catalog (so 100 euros without tax), invoice gives me this :

RRP : 100
Est : 90
Total : 90
=> OK if RRP and Est are without taxes
=> KO if RRP and Est are WITH taxes

in the bottom of the invoice table, I read that :

Total tax exc.	100.00	 	1	90.00	 
Tax (5.50%)	5.50	 	 	5.50	 
Total tax inc. (EUR)	105.50	 	1	105.50	 
Total + shipment cost (EUR)	 	 	1	105.50	 

As we don't pay taxes, the taxes should not be displayed here.

2d test :
with yes/yes parameters, and an order for a  book costing 100 euros in vendor's catalog (so 100 euros including tax), invoice gives me this :


Invoice details
RRP	Est.	Qty.	Total
100     90      1       90
We don't know if RRP and Est are with or without tax
=> OK if RRP and Est. are WITH tax
=> KO if RRP and Est. are WITHOUT tax

in the bottom of the invoice table, I read that :

Total tax exc.	94.79	 	1	94.79	 
Tax (5.50%)	5.21	 	 	5.21	 
Total tax inc. (EUR)	100.00	 	1	90.00	 
Total + shipment cost (EUR)	 	 	1	90.00	 

The total tax. exc. and the tax are the values calculated on public price (rrp).
That's not good, Most of time, we don't need them at all. It could be displayed, but only as an indication, and with clear mention that it is based on RRP price.
What we need here is the ecost price without tax.

Mathieu
Comment 12 Jacek Ablewicz 2014-02-03 09:39:27 UTC
(In reply to mathieu saby from comment #11)
> It is not working well, and most of all, improving the display of rrp and
> ecost price on invoices is maybe a loss of time.
> 

Mathieu, are you sure your last test was with the patches correctly applied?

From what I see, patched version is calculating & displaying unitcost (aka actual cost) on invoice page, just like it should - and there is an clear indication stating if given column is with, or without tax.

We are currently testing those patches; so far with the good results
for listincgst/invoiceincgst both yes/yes && no/no.

Less usual combinations (no/yes, yes/no) might be a different story - I believe invoice.pl may need an additional small change like that:

185c185
>     if ( $bookseller->{'invoiceincgst'} ) {
---
<     if ( $bookseller->{'listincgst'} ) {

to behave properly for "no/yes" and "yes/no" (???).

Anyway, handling prices for yes/no and no/yes combinations are apparently even more problematic in other places (like parcel.pl, basket.pl, .. - price calculations/display/column labeling etc. are not always working correctly in those other scripts - depending on the circumstances). I'm wondering if anyone is actually using such unusual combinations IRL?
Comment 13 Mathieu Saby 2014-02-16 23:52:30 UTC
Hi
I won't have time to test this patch again. Maybe I did a mistake.
So, if your tests are fine, you can change status to Signed Off.

Mathieu
Comment 14 Jonathan Druart 2014-03-05 09:17:41 UTC
Back to needs signoff.
Comment 15 Jacek Ablewicz 2014-03-05 14:38:09 UTC
(In reply to Jacek Ablewicz from comment #12)

> Less usual combinations (no/yes, yes/no) might be a different story - I
> believe invoice.pl may need an additional small change like that:
> 
> 185c185
> >     if ( $bookseller->{'invoiceincgst'} ) {
> ---
> <     if ( $bookseller->{'listincgst'} ) {
> 
> to behave properly for "no/yes" and "yes/no" (???).

Previously we tried to test it (in 3.14 and master, with above small change included, and without it), still getting some rather weird results for "no/yes" and "yes/no" settings.. Getting bug 11755 into account (which explains at least some of this "weirdness"), question is - how should this bug be retested before sign-off: with 11755 applied first, or maybe not?
Comment 16 Jonathan Druart 2014-03-05 14:40:01 UTC
(In reply to Jacek Ablewicz from comment #15)
> how should this
> bug be retested before sign-off: with 11755 applied first, or maybe not?

Yes, of course.
Comment 17 Jacek Ablewicz 2014-03-05 21:57:24 UTC
(In reply to Jonathan Druart from comment #16)
> (In reply to Jacek Ablewicz from comment #15)
> > how should this
> > bug be retested before sign-off: with 11755 applied first, or maybe not?
> 
> Yes, of course.

I did some Q&D tests with 11755 applied (figuratively speaking - right now, 11755 apparently does not apply for current master? - for testing purposes I just altered C3/Acquisition.pm manually).
So far, so good: 11755 patch seems to be f*ing golden - prices w/ & wo/ tax now being handled properly on the invoice page, for all "yes/yes", "no/no", "yes/no" and "no/yes" listpriceincgst/invoiceincgst setting combinations.
Comment 18 Jonathan Druart 2014-03-06 08:44:13 UTC
(In reply to Jacek Ablewicz from comment #17)
> I did some Q&D tests with 11755 applied (figuratively speaking - right now,
> 11755 apparently does not apply for current master? - for testing purposes I
> just altered C3/Acquisition.pm manually).

I rebased it.
Comment 19 Jonathan Druart 2014-03-06 08:47:29 UTC
(In reply to Jacek Ablewicz from comment #17)
> So far, so good: 11755 patch seems to be f*ing golden - prices w/ & wo/ tax
> now being handled properly on the invoice page, for all "yes/yes", "no/no",
> "yes/no" and "no/yes" listpriceincgst/invoiceincgst setting combinations.

Great!
May you sign it off then? :)
Comment 20 Jacek Ablewicz 2014-03-06 10:08:37 UTC Comment hidden (obsolete)
Comment 21 Jacek Ablewicz 2014-03-06 10:09:16 UTC Comment hidden (obsolete)
Comment 22 Katrin Fischer 2014-03-22 09:38:51 UTC
My feeling is, that we need to centralize the code doing all the calculations in acq, as the tax calculation has proven to be an endless source of pain and confusion. That said... going to QA this and hoping for an improvement :)
Comment 23 Katrin Fischer 2014-03-22 09:45:43 UTC
Looking at this a bit more, I think I might have found a small mistake. With both patches applied: 

In acqui/invoice.pl:

103 my $bookseller = GetBookSellerFromId($details->{booksellerid});
151 suppliername     => $details->{'suppliername'},

Jonathan, could you check please? There is no "Need Feedback" status, so setting "Failed QA".
Comment 24 Katrin Fischer 2014-03-22 09:48:01 UTC
Hm also: 

 FAIL	acqui/invoice.pl
   OK	  pod
   OK	  forbidden patterns
   FAIL	  valid
		Useless use of private variable in void context 
   OK	  critic
Comment 25 Jacek Ablewicz 2014-03-22 11:39:44 UTC
(In reply to Katrin Fischer from comment #23)

> 151 suppliername     => $details->{'suppliername'},

IMO this part is fine (GetInvoiceDetails() does return 'suppliername' and it seems to work like intended, at least for me), but this one:

    152 supplierid       => $details->{'supplierid'},

is indeed not; as a result, link via "Vendor: " name is leading to nowhere. Which I should've spotted before signing-off :(.
Comment 26 Katrin Fischer 2014-03-22 12:54:13 UTC
Hi Jacek, thx for checking :)
Comment 27 Jonathan Druart 2014-03-24 09:16:39 UTC Comment hidden (obsolete)
Comment 28 Jonathan Druart 2014-03-24 09:18:33 UTC
(In reply to Katrin Fischer from comment #24)
>  FAIL	acqui/invoice.pl
>    FAIL	  valid
> 		Useless use of private variable in void context 


(In reply to Jacek Ablewicz from comment #25)
>     152 supplierid       => $details->{'supplierid'},
> 
> is indeed not; as a result, link via "Vendor: " name is leading to nowhere.
> Which I should've spotted before signing-off :(.

Good catches!
Fixed.
Comment 29 Jacek Ablewicz 2014-03-24 15:14:26 UTC
(In reply to Jonathan Druart from comment #28)

> >    FAIL	  valid
> > 		Useless use of private variable in void context 

IMO

   126: my %row = %{ $order, $line };

was actually a little better ;), being equivalent of:

   my %row = %$line;

and it tested just fine in that form ("Useles use: " warning aside). Looks like merging %$line with %order is 100% redundant (%$line is allways the superset of %$order).

> >     152 supplierid       => $details->{'supplierid'},
> Fixed.

Not fully yet - vendor link still doesn't work; there is no 'supplierid' key in $details->{}, we have 'booksellerid' instead.
Comment 30 Jonathan Druart 2014-03-24 16:00:35 UTC Comment hidden (obsolete)
Comment 31 Jonathan Druart 2014-03-24 16:00:43 UTC Comment hidden (obsolete)
Comment 32 Jonathan Druart 2014-03-24 16:00:50 UTC Comment hidden (obsolete)
Comment 33 Jonathan Druart 2014-03-24 16:03:41 UTC
(In reply to Jacek Ablewicz from comment #29)
> and it tested just fine in that form ("Useles use: " warning aside). Looks
> like merging %$line with %order is 100% redundant (%$line is allways the
> superset of %$order).

Yes, you are right, sorry for that.

> 
> > >     152 supplierid       => $details->{'supplierid'},
> > Fixed.
> 
> Not fully yet - vendor link still doesn't work; there is no 'supplierid' key
> in $details->{}, we have 'booksellerid' instead.

I amended the first patch, which introduced this mistake.

Thanks Jacek for your vigilance!

The last patch needs a signoff.
Comment 34 Jacek Ablewicz 2014-03-25 10:56:16 UTC Comment hidden (obsolete)
Comment 35 Jacek Ablewicz 2014-03-25 11:07:05 UTC
Btw, the patches don't have [SIGNED-OFF] added in headers (I signed off the 3rd one without it too, for the sake of consistency). I don't know if this is really important or not - if yes, I'll try to re-sign-off all 3 patches.
Comment 36 Katrin Fischer 2014-03-25 11:24:15 UTC
Hi Jacek, it's not a problem as long as the status is correct "Signed off" it will show up in our searches :)
Comment 37 Katrin Fischer 2014-03-25 22:40:23 UTC
Working on this again... it IS confusing, will need some more time for testing.
Comment 38 Katrin Fischer 2014-03-27 06:39:44 UTC
*** Bug 11681 has been marked as a duplicate of this bug. ***
Comment 39 Katrin Fischer 2014-03-31 20:30:14 UTC
Ok, this gives me a headache :( Can I get a consolidated test plan?
Comment 40 Jonathan Druart 2014-04-01 11:25:02 UTC
(In reply to Katrin Fischer from comment #39)
> Ok, this gives me a headache :( Can I get a consolidated test plan?

A test plan could be:
0) Add a value in the gist pref (0.1 or 0.25 or something else easy).
1)
  a) Create a supplier "10613 0 0" with
    List item price includes tax: No
    Invoice item price includes tax: No
  b) Create a supplier "10613 0 1" with
    List item price includes tax: No
    Invoice item price includes tax: Yes
  c) Create a supplier "10613 1 0" with
    List item price includes tax: Yes
    Invoice item price includes tax: No
  d) Create a supplier "10613 1 1" with
    List item price includes tax: Yes
    Invoice item price includes tax: Yes
2) Create a basket for each supplier
3) Create 1+ order(s) with 1+ item(s) for each basket with a discount and a gst value.
4) Close the baskets
5) Receive the items
6) Go on acqui/invoice.pl?invoiceid=XX acqui/basket.pl?basketno=YY for each basket/invoice, click on the "Show all details" checkbox and verify that the values are the same.
Comment 41 Katrin Fischer 2014-04-09 10:19:55 UTC
Hi Jonathan, thx for the test plan, I am back on testing this now.
Comment 42 Katrin Fischer 2014-04-09 16:52:35 UTC
Created attachment 26924 [details] [review]
[PASSED QA] Bug 10613: The gst rate is not correctly calculated on the invoice page.

Test plan:
Defined a gst rate on creating an order, receive it and check that all
prices are correctly calculated.
/!\ Behavior change function of supplier parameters (Include/Don't
include tax for list prices and invoice prices)

Notes: patch tested with Bug 11755 applied first; confirmed that:
- price calculations are correct for all combinations of
  listincgst/invoiceincgst settings in the vendor record
- unitprice (aka "Actual cost") is taken into account on the
  invoice page instead of rrp/ecost, like it should.

Amended patch: Don't change the supplierid/booksellerid parameter.

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 43 Katrin Fischer 2014-04-09 16:53:28 UTC
Created attachment 26925 [details] [review]
[PASSED QA] Bug 10613: FIX typo supplierid vs booksellerid

GetInvoiceDetails returns a hashref with a key named booksellerid, not
supplierid.
The bookseller was not retrieved from the DB and the listincgst value
was always false.

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Comment 44 Katrin Fischer 2014-04-09 16:53:57 UTC
Created attachment 26926 [details] [review]
[PASSED QA] Bug 10613: FIX QA issues

This patch fixes the following QA issue:

 FAIL    acqui/invoice.pl
   FAIL      valid
        Useless use of private variable in void context

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Patch passes all tests and QA script. Specifically checked
the t/db_depenedent/Acq* tests.

A test plan could be:
0) Add a value in the gist pref (0.1 or 0.25 or something else easy).
1)
  a) Create a supplier "10613 0 0" with
    List item price includes tax: No
    Invoice item price includes tax: No
    Tax: 10%
  b) Create a supplier "10613 0 1" with
    List item price includes tax: No
    Invoice item price includes tax: Yes
    Tax: 10%
  c) Create a supplier "10613 1 0" with
    List item price includes tax: Yes
    Invoice item price includes tax: No
    Tax: 10%
  d) Create a supplier "10613 1 1" with
    List item price includes tax: Yes
    Invoice item price includes tax: Yes
    Tax: 10%
2) Create a basket for each supplier
  a) 00 List price: 10.00 (11.00 with 10% taxes)
  b) 01 List price: 10.00 (11.00 with 10% taxes)
  c) 10 List price: 10.00 (9.09 without taxes)
  d) 11 List price: 10.00 (9.09 without taxes)
  Note: Information on the basket page is shown correctly.
  If you look at the list of ordered items for the fund,
  the list price is used.
3) Create 1+ order(s) with 1+ item(s) for each basket with
   a discount and a gst value.
4) Close the baskets
5) Receive the items
   Left actual price as suggested:
   a) 00 Actual cost: 10.00
   b) 01 Actual cost: 11.00
   c) 10 Actual cost:  9.09
   d) 11 Actual cost: 10.00
   Calculations on the invoice page now all appear to be correct.
   Note: When you take a look at the 'ordered' list for the fund,
   the actual price is used as entered.
6) Go on acqui/invoice.pl?invoiceid=XX acqui/basket.pl?basketno=YY for
   each basket/invoice, click on the "Show all details" checkbox
   and verify that the values are all correct.

Calculations are exactly the same for tax registered yes and no.
Comment 45 Galen Charlton 2014-05-04 19:30:10 UTC
Pushed to master.  Thanks, Jonathan!