Bug 14172 - Acq: Orders without items missing from 'Spent' list
Summary: Acq: Orders without items missing from 'Spent' list
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Katrin Fischer
QA Contact: Jonathan Druart
: 12459 (view as bug list)
Depends on:
Reported: 2015-05-08 10:06 UTC by Katrin Fischer
Modified: 2016-06-21 21:38 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:

Bug 14172: Acq: Orders without items missing from 'spent' list (2.00 KB, patch)
2015-05-15 10:23 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 14172: Acq: Orders without items missing from 'spent' list (2.09 KB, patch)
2015-05-18 11:13 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 14172: Acq: Orders without items missing from 'spent' list (2.11 KB, patch)
2015-05-18 12:09 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2015-05-08 10:06:13 UTC
In the acquisition module the spent and ordered amounts are linked to separate pages which show the records and freight costs that build up to the amount seen in the table.

The page showing the ordered records appearst to be always correct, but there are problems with the spent page. At the moment, the problem always seems to occur for the 'serials' fund in each library (subscription order workflow?)

The list is missing records in this case and the total is incorrect and not matching the value shown on the acq start page.

We see this behaviour in several databases using acquisitons + serials with
Comment 1 Katrin Fischer 2015-05-08 10:36:55 UTC
Hm, the problem seems to be that there is an entry in aqorders_items, but the corresponding item has since been deleted.
Comment 2 Katrin Fischer 2015-05-08 15:31:10 UTC
The big problem is the 'missing' item, independent of the existence of an entry in aqorders.items. As this is a very normal thing for serial orders (no items, but a subscription instead) we need to make the SQL query for the spent page more flexible to include those as well.

Haven't succeeded there so far, but maybe someone else wants to give it a try.
Comment 3 Katrin Fischer 2015-05-15 10:06:12 UTC
*** Bug 12459 has been marked as a duplicate of this bug. ***
Comment 4 Katrin Fischer 2015-05-15 10:23:46 UTC Comment hidden (obsolete)
Comment 5 Martin Persson 2015-05-16 15:13:16 UTC
I have tried the patch, it applied cleanly to current master. I have tested the subscription aquisition bug and can confirm both the bug and that the patch fixes that particular issue. I have not yet tested the 'Delete Item' bug.
Comment 6 Marcel de Rooy 2015-05-18 11:13:05 UTC Comment hidden (obsolete)
Comment 7 Marcel de Rooy 2015-05-18 11:13:25 UTC
Signing off with the following notes: 

On page spent.pl I see typo: Sub total
A total of 52 euro is not listed as 52,00 although the items are listed as 12,00 and 40,00
The total of the shipping costs is not mentioned on the first form. But is included in the final total of the spent page.
The removed item number is still in the aqorders_items table.
The fact that an order number is corresponding with an item, is not intuitively clear. (Probably, the main cause is that an order is actually an order line.) A comment in the code where you join aqorders_items on ordernumber might be helpful.
Comment 8 Jonathan Druart 2015-05-18 12:09:40 UTC
Created attachment 39280 [details] [review]
Bug 14172: Acq: Orders without items missing from 'spent' list

If the item for an order had been deleted since or there was never
an item created for the order (subscription orders) those records
where missing from the "Spent" page in acquisitions.

Patch corrects the SQL to list the correct records.

To test:
- Create different orders for one fund and receive them
  - normal order with a few items
  - subscription order (no item)
  - normal order with an item, delete the item after receiving
  - include some freight cost in one of the invoices
- Compare the amount spent shown on the acq start page
  with the amount shown at the end of the 'spent' page
- Without the patch, the amounts don't match and not all
  received titles are listed
- With the patch, amounts should match and list shoudl be complete

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 9 Tomás Cohen Arazi 2015-05-18 14:25:30 UTC
Patch pushed to master.

Thanks Katrina!
Comment 10 Chris Cormack 2015-05-18 21:56:19 UTC
Pushed to 3.18.x will be in 3.18.7