Bug 31649: Fix acquisition basket group CSV export if biblio does not exist
authorFridolin Somers <fridolin.somers@biblibre.com>
Thu, 29 Sep 2022 06:42:57 +0000 (20:42 -1000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 11 Oct 2022 13:00:13 +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 960902c..1edd052 100644 (file)
@@ -394,30 +394,33 @@ sub GetBasketGroupAsCSV {
 
         foreach my $order (@orders) {
             my $biblio = Koha::Biblios->find( $order->{biblionumber} );
-            my $biblioitem = $biblio->biblioitem;
+            my $biblioitem;
+            if ($biblio) {
+                $biblioitem = $biblio->biblioitem;
+            }
             my $row = {
-                clientnumber => $bookseller->accountnumber,
-                basketname => $basket->{basketname},
-                ordernumber => $order->{ordernumber},
-                author => $biblio->author,
-                title => $biblio->title,
-                publishercode => $biblioitem->publishercode,
-                publicationyear => $biblioitem->publicationyear,
-                collectiontitle => $biblioitem->collectiontitle,
-                isbn => $order->{isbn},
-                quantity => $order->{quantity},
-                rrp_tax_included => $order->{rrp_tax_included},
-                rrp_tax_excluded => $order->{rrp_tax_excluded},
-                discount => $bookseller->discount,
+                clientnumber       => $bookseller->accountnumber,
+                basketname         => $basket->{basketname},
+                ordernumber        => $order->{ordernumber},
+                author             => $biblio     ? $biblio->author              : q{},
+                title              => $biblio     ? $biblio->title               : q{},
+                publishercode      => $biblioitem ? $biblioitem->publishercode   : q{},
+                publicationyear    => $biblioitem ? $biblioitem->publicationyear : q{},
+                collectiontitle    => $biblioitem ? $biblioitem->collectiontitle : q{},
+                isbn               => $order->{isbn},
+                quantity           => $order->{quantity},
+                rrp_tax_included   => $order->{rrp_tax_included},
+                rrp_tax_excluded   => $order->{rrp_tax_excluded},
+                discount           => $bookseller->discount,
                 ecost_tax_included => $order->{ecost_tax_included},
                 ecost_tax_excluded => $order->{ecost_tax_excluded},
-                notes => $order->{order_vendornote},
-                entrydate => $order->{entrydate},
-                booksellername => $bookseller->name,
-                bookselleraddress => $bookseller->address1,
-                booksellerpostal => $bookseller->postal,
-                contractnumber => $contract->{contractnumber},
-                contractname => $contract->{contractname},
+                notes              => $order->{order_vendornote},
+                entrydate          => $order->{entrydate},
+                booksellername     => $bookseller->name,
+                bookselleraddress  => $bookseller->address1,
+                booksellerpostal   => $bookseller->postal,
+                contractnumber     => $contract->{contractnumber},
+                contractname       => $contract->{contractname},
             };
             my $temp = {
                 basketgroupdeliveryplace => $basketgroup->{deliveryplace},