Bug 31649: Fix acquisition basket CSV export if biblio does not exist
authorFridolin Somers <fridolin.somers@biblibre.com>
Thu, 29 Sep 2022 06:33:26 +0000 (20:33 -1000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 11 Oct 2022 13:00:12 +0000 (10:00 -0300)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
C4/Acquisition.pm

index bbd0168..960902c 100644 (file)
@@ -321,20 +321,23 @@ sub GetBasketAsCSV {
     else {
         foreach my $order (@orders) {
             my $biblio = Koha::Biblios->find( $order->{biblionumber} );
-            my $biblioitem = $biblio->biblioitem;
+            my $biblioitem;
+            if ($biblio) {
+                $biblioitem = $biblio->biblioitem;
+            }
             my $row = {
-                contractname => $contract->{'contractname'},
-                ordernumber => $order->{'ordernumber'},
-                entrydate => $order->{'entrydate'},
-                isbn => $order->{'isbn'},
-                author => $biblio->author,
-                title => $biblio->title,
-                publicationyear => $biblioitem->publicationyear,
-                publishercode => $biblioitem->publishercode,
-                collectiontitle => $biblioitem->collectiontitle,
-                notes => $order->{'order_vendornote'},
-                quantity => $order->{'quantity'},
-                rrp => $order->{'rrp'},
+                contractname    => $contract->{'contractname'},
+                ordernumber     => $order->{'ordernumber'},
+                entrydate       => $order->{'entrydate'},
+                isbn            => $order->{'isbn'},
+                author          => $biblio     ? $biblio->author              : q{},
+                title           => $biblio     ? $biblio->title               : q{},
+                publicationyear => $biblioitem ? $biblioitem->publicationyear : q{},
+                publishercode   => $biblioitem ? $biblioitem->publishercode   : q{},
+                collectiontitle => $biblioitem ? $biblioitem->collectiontitle : q{},
+                notes           => $order->{'order_vendornote'},
+                quantity        => $order->{'quantity'},
+                rrp             => $order->{'rrp'},
             };
             for my $place ( qw( deliveryplace billingplace ) ) {
                 if ( my $library = Koha::Libraries->find( $row->{deliveryplace} ) ) {