Bug 14172

Summary: Acq: Orders without items missing from 'Spent' list
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: AcquisitionsAssignee: Katrin Fischer <katrin.fischer>
Status: CLOSED FIXED QA Contact: Jonathan Druart <jonathan.druart>
Severity: major    
Priority: P5 - low CC: chris, jonathan.druart, m.de.rooy, marjorie.barry-vila, nengard, tomascohen, xarragon
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9987
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 14172: Acq: Orders without items missing from 'spent' list
Bug 14172: Acq: Orders without items missing from 'spent' list
Bug 14172: Acq: Orders without items missing from 'spent' list

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 3.18.5.1.
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 (tcohen) 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