Bug 24672

Summary: Error on receiving orders when there is an order with a deleted record
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: AcquisitionsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Tomás Cohen Arazi <tomascohen>
Severity: major    
Priority: P5 - low CC: 1joynelson, jonathan.druart, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00
Bug Depends on: 24430    
Bug Blocks:    
Attachments: Bug 24672: (bug 24430 follow-up) Do not get active orders on deleted biblio record
Bug 24672: (bug 24430 follow-up) Do not get active orders on deleted biblio record

Description Katrin Fischer 2020-02-14 23:05:02 UTC
When trying to receive orders after entering the invoice id this error is displayed:

Can't call method "active_orders" on an undefined value at /home/vagrant/kohaclone/acqui/parcel.pl line 244
Comment 1 Katrin Fischer 2020-02-14 23:08:14 UTC
Not sure if it's related, but I have a basket with 2 unreceived deleted records (it's not good, but can happen)
Comment 2 Katrin Fischer 2020-02-14 23:10:35 UTC
It appears to be related - reopening the closed basket (taking the orders out of the list of orders to receive that way) makes the error go away.
Comment 3 Jonathan Druart 2020-02-17 13:57:54 UTC
Caused by
  commit f31993d126ed97fdc80605931f41ed29b1dac5d1
  Bug 24430: Remove CountBiblioInOrders and its traces
Comment 4 Jonathan Druart 2020-02-17 14:01:03 UTC
Created attachment 99090 [details] [review]
Bug 24672: (bug 24430 follow-up) Do not get active orders on deleted biblio record

On bug 24430 we replaced the call to CountBiblioInOrders with
Koha::Biblio->active_orders
In case the bibliographic record is deleted, the count must be set to 0.

This prevent the app to crash with:
Can't call method "active_orders" on an undefined value at
/home/vagrant/kohaclone/acqui/parcel.pl line 244

Test plan:
Create 2+ orders
Receive one, delete it, delete the bibliographic record
Receive the order one
=> Without this patch, on the parcel page you should get the error
=> With this patch applied you must be allowed to finish the receive
Comment 5 Tomás Cohen Arazi 2020-03-24 05:02:20 UTC
Created attachment 101502 [details] [review]
Bug 24672: (bug 24430 follow-up) Do not get active orders on deleted biblio record

On bug 24430 we replaced the call to CountBiblioInOrders with
Koha::Biblio->active_orders
In case the bibliographic record is deleted, the count must be set to 0.

This prevent the app to crash with:
Can't call method "active_orders" on an undefined value at
/home/vagrant/kohaclone/acqui/parcel.pl line 244

Test plan:
Create 2+ orders
Receive one, delete it, delete the bibliographic record
Receive the order one
=> Without this patch, on the parcel page you should get the error
=> With this patch applied you must be allowed to finish the receive

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 6 Tomás Cohen Arazi 2020-03-24 05:03:11 UTC
I was about to submit the same patch and found you filed it, Katrin. Thanks for the patch Jonathan.
Comment 7 Martin Renvoize 2020-03-24 09:30:14 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 8 Joy Nelson 2020-04-03 21:35:14 UTC
not backported to 19.11.x due to dependencies