[Koha-patches] [PATCH] kohabug 2139 Fixes C4::Aquisition::NewOrder so that it saves the branchcode

Galen Charlton galen.charlton at liblime.com
Thu Jul 24 20:44:19 CEST 2008


From: Chris Nighswonger <chris.nighswonger at liblime.com>

&NewOrder did not save the branchcode posted with a new order. This patch adds that param.

Added code to select the branch the order is for in the branch dropdown list on
acqui/orderreceive.pl

Updating POD and tests

Signed-off-by: Galen Charlton <galen.charlton at liblime.com>
---
 C4/Acquisition.pm                      |   11 ++++++-----
 acqui/addorder.pl                      |    3 ++-
 acqui/orderreceive.pl                  |    2 ++
 t/lib/KohaTest/Acquisition/NewOrder.pm |    6 ++++--
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index a599fdd..b846ca5 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -370,7 +370,7 @@ sub GetOrder {
   &NewOrder($basket, $biblionumber, $title, $quantity, $listprice,
     $booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp,
     $ecost, $gst, $budget, $unitprice, $subscription,
-    $booksellerinvoicenumber, $purchaseorder);
+    $booksellerinvoicenumber, $purchaseorder, $branchcode);
 
 Adds a new order to the database. Any argument that isn't described
 below is the new value of the field with the same name in the aqorders
@@ -398,7 +398,8 @@ sub NewOrder {
         $listprice, $booksellerid, $authorisedby, $notes,
         $bookfund,  $bibitemnum,   $rrp,          $ecost,
         $gst,       $budget,       $cost,         $sub,
-        $invoice,   $sort1,        $sort2,        $purchaseorder
+        $invoice,   $sort1,        $sort2,        $purchaseorder,
+		$branchcode
       )
       = @_;
 
@@ -454,11 +455,11 @@ sub NewOrder {
     #get ordnum MYSQL dependant, but $dbh->last_insert_id returns null
     my $ordnum = $dbh->{'mysql_insertid'};
     $query = "
-        INSERT INTO aqorderbreakdown (ordernumber,bookfundid)
-        VALUES (?,?)
+        INSERT INTO aqorderbreakdown (ordernumber,bookfundid, branchcode)
+        VALUES (?,?,?)
     ";
     $sth = $dbh->prepare($query);
-    $sth->execute( $ordnum, $bookfund );
+    $sth->execute( $ordnum, $bookfund, $branchcode );
     $sth->finish;
     return ( $basketno, $ordnum );
 }
diff --git a/acqui/addorder.pl b/acqui/addorder.pl
index a87702c..a9b5f9c 100755
--- a/acqui/addorder.pl
+++ b/acqui/addorder.pl
@@ -216,7 +216,8 @@ if ( $quantity ne '0' ) {
             $listprice, $booksellerid, $loggedinuser, $notes,
             $bookfund,  $bibitemnum,   $rrp,          $ecost,
             $gst,       $budget,       $cost,         $sub,
-            $invoice,   $sort1,        $sort2,		$purchaseorder
+            $invoice,   $sort1,        $sort2,		$purchaseorder,
+			$branch
         );
     }
 }
diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl
index eaab7ee..313a384 100755
--- a/acqui/orderreceive.pl
+++ b/acqui/orderreceive.pl
@@ -82,6 +82,7 @@ my $gst          = $input->param('gst');
 
 my @results = SearchOrder( $search, $supplierid, $biblionumber, $catview );
 my $count   = scalar @results;
+my $order 	= GetOrder($search);
 
 my $bookseller = GetBookSellerFromId( $results[0]->{'booksellerid'} );
 
@@ -144,6 +145,7 @@ if ( $count == 1 ) {
             value      => $thisbranch,
             description => $branches->{$thisbranch}->{'branchname'},
         );
+	    $row{'selected'} = 1 if( $thisbranch eq $order->{branchcode}) ;
         push @branchloop, \%row;
     }
 
diff --git a/t/lib/KohaTest/Acquisition/NewOrder.pm b/t/lib/KohaTest/Acquisition/NewOrder.pm
index bf39d2f..e309b4c 100644
--- a/t/lib/KohaTest/Acquisition/NewOrder.pm
+++ b/t/lib/KohaTest/Acquisition/NewOrder.pm
@@ -44,7 +44,8 @@ sub new_order_no_budget : Test( 4 ) {
                                           $invoice, # $invoice,
                                           undef, # $sort1,
                                           undef, # $sort2,
-                                          undef, # $purchaseorder
+                                          undef, # $purchaseorder,
+										  undef, # $branchcode
                                      );
     ok( $basketno, "my basket number is $basketno" );
     ok( $ordnum,   "my order number is $ordnum" );
@@ -91,7 +92,8 @@ sub new_order_set_budget : Test( 4 ) {
                                           $invoice, # $invoice,
                                           undef, # $sort1,
                                           undef, # $sort2,
-                                          undef, # $purchaseorder
+                                          undef, # $purchaseorder,
+										  undef, # $branchcode
                                      );
     ok( $basketno, "my basket number is $basketno" );
     ok( $ordnum,   "my order number is $ordnum" );
-- 
1.5.5.GIT




More information about the Koha-patches mailing list