Bug 18627 - Items created via MarcItemFieldsToOrder are not linked to orders
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 18 May 2017 15:41:34 +0000 (08:41 -0700)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 19 May 2017 13:22:57 +0000 (09:22 -0400)
If using MarcItemFieldsToOrder with AcqCreateItem = Create,
the order and the items will be created, but they will not be linked via aqorders_items!

Test Plan:
1) Enable creation of items when ordering
2) Set up MarcItemFieldsToOrder
3) Upload an order record that uses the fields in step 2
4) Create a basket and add the records from the file
5) Note the order and items are created, but no rows in aqorders_items are created
6) Apply this patch
7) Repeat steps 3-4
8) Note the rows in aqorders_items are created!

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marci Chen <mchen@mckinneytexas.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
acqui/addorderiso2709.pl

index 8fb4ead..5d3ee54 100755 (executable)
@@ -217,6 +217,8 @@ if ($op eq ""){
         my @replacementprices = $input->multi_param('replacementprice_' . $biblio_count);
         my @itemcallnumbers = $input->multi_param('itemcallnumber_' . $biblio_count);
         my $itemcreation = 0;
+
+        my @itemnumbers;
         for (my $i = 0; $i < $count; $i++) {
             $itemcreation = 1;
             my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({
@@ -234,6 +236,7 @@ if ($op eq ""){
                 replacementprice => $replacementprices[$i],
                 itemcallnumber => $itemcallnumbers[$i],
             }, $biblionumber);
+            push( @itemnumbers, $itemnumber );
         }
         if ($itemcreation == 1) {
             # Group orderlines from MarcItemFieldsToOrder
@@ -302,6 +305,7 @@ if ($op eq ""){
                     };
 
                     my $order = Koha::Acquisition::Order->new( \%orderinfo )->insert;
+                    $order->add_item( $_ ) for @itemnumbers;
                 }
             }
         } else {