From ab1a74897efb82b99ed3931dff719bb64b930bc4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 5 Mar 2014 13:07:53 +0100 Subject: [PATCH] Bug 11699: fixed saving notes entered when receiving orders Revised test plan: 1/ Create an order with 2 items 2/ Receive 1 item and enter a note for the order 3/ Verify the note is not saved The note should be visible on the Mod Order Details screen, but it isn't there. 4/ Apply patch 5/ Receive the second item and enter a note for the order 6/ Verify the note is correctly saved The note is visible on the Mod Order Details screen. Signed-off-by: Mark Tompsett Signed-off-by: Katrin Fischer Passes all tests and QA script. Works as described. The note now saves correctly and also remains when you undo a receipt. Note: it would be nice to show the note on the receive page as well. Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 26 +++++++++++-------- acqui/finishreceive.pl | 3 ++- .../prog/en/modules/acqui/orderreceive.tt | 2 +- t/db_dependent/Acquisition.t | 13 +++++++--- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 33aa8e3c08..fa2a30dccd 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1438,7 +1438,7 @@ C<$ordernumber>. sub ModReceiveOrder { my ( $biblionumber, $ordernumber, $quantrec, $user, $cost, $ecost, - $invoiceid, $rrp, $budget_id, $datereceived, $received_items + $invoiceid, $rrp, $budget_id, $datereceived, $received_items, $notes ) = @_; @@ -1466,14 +1466,15 @@ q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, # without received items (the quantity is decreased), # the second part is a new order line with quantity=quantityrec # (entirely received) - my $sth=$dbh->prepare(" + my $query = q| UPDATE aqorders SET quantity = ?, - orderstatus = 'partial' - WHERE ordernumber = ? - "); + orderstatus = 'partial'|; + $query .= q|, notes = ?| if defined $notes; + $query .= q| WHERE ordernumber = ?|; + my $sth = $dbh->prepare($query); - $sth->execute($order->{quantity} - $quantrec, $ordernumber); + $sth->execute($order->{quantity} - $quantrec, ( defined $notes ? $notes : () ), $ordernumber); delete $order->{'ordernumber'}; $order->{'budget_id'} = ( $budget_id || $order->{'budget_id'} ); @@ -1494,11 +1495,14 @@ q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, } } } else { - my $sth=$dbh->prepare("update aqorders - set quantityreceived=?,datereceived=?,invoiceid=?, - unitprice=?,rrp=?,ecost=?,budget_id=?,orderstatus='complete' - where biblionumber=? and ordernumber=?"); - $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$budget_id,$biblionumber,$ordernumber); + my $query = q| + update aqorders + set quantityreceived=?,datereceived=?,invoiceid=?, + unitprice=?,rrp=?,ecost=?,budget_id=?,orderstatus='complete'|; + $query .= q|, notes = ?| if defined $notes; + $query .= q| where biblionumber=? and ordernumber=?|; + my $sth = $dbh->prepare( $query ); + $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$budget_id,( defined $notes ? $notes : () ),$biblionumber,$ordernumber); } return ($datereceived, $new_ordernumber); } diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 71bf90c43a..f1f9a0977a 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -53,7 +53,7 @@ my $booksellerid = $input->param('booksellerid'); my $cnt = 0; my $ecost = $input->param('ecost'); my $rrp = $input->param('rrp'); -my $note = $input->param("note"); +my $notes = $input->param("notes"); my $bookfund = $input->param("bookfund"); my $order = GetOrder($ordernumber); my $new_ordernumber = $ordernumber; @@ -112,6 +112,7 @@ if ($quantityrec > $origquantityrec ) { $bookfund, $datereceived, \@received_items, + $notes, ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 47eea316dd..3f5dc42d5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -329,7 +329,7 @@ [% ELSE %] [% END %] - + diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index f2ee82097b..ed352b0faf 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -8,7 +8,7 @@ use POSIX qw(strftime); use C4::Bookseller qw( GetBookSellerFromId ); -use Test::More tests => 68; +use Test::More tests => 71; BEGIN { use_ok('C4::Acquisition'); @@ -793,13 +793,15 @@ is( ( $datereceived, $new_ordernumber ) = ModReceiveOrder( $biblionumber2, $ordernumbers[1], 2, undef, 12, 12, - $invoiceid, 42, ); + $invoiceid, 42, undef, undef, undef, "my notes"); my $order2 = GetOrder( $ordernumbers[1] ); is( $order2->{'quantityreceived'}, 0, 'Splitting up order did not receive any on original order' ); is( $order2->{'quantity'}, 40, '40 items on original order' ); is( $order2->{'budget_id'}, $budgetid, 'Budget on original order is unchanged' ); +is( $order2->{notes}, "my notes", + 'ModReceiveOrder and GetOrder deal with notes' ); $neworder = GetOrder($new_ordernumber); is( $neworder->{'quantity'}, 2, '2 items on new order' ); @@ -816,7 +818,7 @@ my $budgetid2 = C4::Budgets::AddBudget( ( $datereceived, $new_ordernumber ) = ModReceiveOrder( $biblionumber2, $ordernumbers[2], 2, undef, 12, 12, - $invoiceid, 42, $budgetid2 ); + $invoiceid, 42, $budgetid2, undef, undef, "my other notes" ); my $order3 = GetOrder( $ordernumbers[2] ); is( $order3->{'quantityreceived'}, @@ -824,6 +826,8 @@ is( $order3->{'quantityreceived'}, is( $order3->{'quantity'}, 2, '2 items on original order' ); is( $order3->{'budget_id'}, $budgetid, 'Budget on original order is unchanged' ); +is( $order3->{notes}, "my other notes", + 'ModReceiveOrder and GetOrder deal with notes' ); $neworder = GetOrder($new_ordernumber); is( $neworder->{'quantity'}, 2, '2 items on new order' ); @@ -833,12 +837,13 @@ is( $neworder->{'budget_id'}, $budgetid2, 'Budget on new order is changed' ); ( $datereceived, $new_ordernumber ) = ModReceiveOrder( $biblionumber2, $ordernumbers[2], 2, undef, 12, 12, - $invoiceid, 42, $budgetid2 ); + $invoiceid, 42, $budgetid2, undef, undef, "my third notes" ); $order3 = GetOrder( $ordernumbers[2] ); is( $order3->{'quantityreceived'}, 2, 'Order not split up' ); is( $order3->{'quantity'}, 2, '2 items on order' ); is( $order3->{'budget_id'}, $budgetid2, 'Budget has changed' ); +is( $order3->{notes}, "my third notes", 'ModReceiveOrder and GetOrder deal with notes' ); my $nonexistent_order = GetOrder(); is( $nonexistent_order, undef, 'GetOrder returns undef if no ordernumber is given' ); -- 2.39.5