Bug 22611: Correction for call to get create_item in EDI.pm
authorColin Campbell <colin.campbell@ptfs-europe.com>
Mon, 1 Apr 2019 11:16:51 +0000 (12:16 +0100)
committerLucas Gass <lucas@bywatersolutions.com>
Mon, 15 Apr 2019 16:40:56 +0000 (16:40 +0000)
There was a typo in the addition of a call to
effective_create_items causing processing to abort after adding
a single copy.

This patch reverts to using the C4::Context call as used for the
first copy created, the intended call to effective_create_items
is a wrapper around that as the field in the basket is guaranteed
to be null (its not set when we call AddBasket). Being consistent
and explicit in what we call should guard against future changes
in dependencies exposing the logic flaw

Added some comments to make logical flow of code clearer

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit f6bc67e851722451a970d085f51fb11fb03e21b3)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 4a2e88549505afbf28c2e0236f81012789262496)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Koha/EDI.pm

index 8012353..1793a30 100644 (file)
@@ -558,6 +558,8 @@ sub quote_item {
     my $schema = Koha::Database->new()->schema();
     my $logger = Log::Log4perl->get_logger();
 
+    # $basketno is the return from AddBasket in the calling routine
+    # So this call should not fail unless that has
     my $basket = Koha::Acquisition::Baskets->find( $basketno );
     unless ( $basket ) {
         $logger->error('Skipping order creation no valid basketno');
@@ -808,7 +810,9 @@ sub quote_item {
                     );
                 }
 
-                if ( $basket->effective_create_item eq 'ordering' ) {
+                # Do not use the basket level value as it is always NULL
+                # See calling subs call to AddBasket
+                if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
                     my $new_item = {
                         notforloan       => -1,
                         cn_sort          => q{},