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>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2020-02-17 14:58:02 +01:00 committed by Martin Renvoize
parent 7d66e67bd1
commit c8718bd4af
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 1 additions and 1 deletions

View File

@ -241,7 +241,7 @@ unless( defined $invoice->{closedate} ) {
my $biblionumber = $line{'biblionumber'};
my $biblio = Koha::Biblios->find( $biblionumber );
my $countbiblio = $biblio->active_orders->count;
my $countbiblio = $biblio ? $biblio->active_orders->count : 0;
my $ordernumber = $line{'ordernumber'};
my $order_object = Koha::Acquisition::Orders->find($ordernumber);
my $cnt_subscriptions = $biblio ? $biblio->subscriptions->count: 0;