From 1904e0c129bed1f8659e53a2fcfffcd1581f4502 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 (cherry picked from commit ab1a74897efb82b99ed3931dff719bb64b930bc4) Signed-off-by: Fridolin Somers Conflicts: t/db_dependent/Acquisition.t --- C4/Acquisition.pm | 26 +++++++++++-------- acqui/finishreceive.pl | 3 ++- .../prog/en/modules/acqui/orderreceive.tt | 2 +- t/db_dependent/Acquisition.t | 19 +++++++++++--- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 7e96a2516c..fed5765f9f 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1437,7 +1437,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 ) = @_; @@ -1465,14 +1465,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'} ); @@ -1493,11 +1494,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 aeb4394453..bc63cec35f 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 cac2132604..544d36f4d0 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 5bfba1a5ea..22a0664139 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 => 66; +use Test::More tests => 69; BEGIN { use_ok('C4::Acquisition'); @@ -168,11 +168,16 @@ my ($datereceived, $new_ordernumber) = ModReceiveOrder( 12, $invoiceid, 42, + undef, + undef, + undef, + "my notes" ); my $order2 = GetOrder( $ordernumber2 ); 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'); @@ -195,13 +200,17 @@ my $budgetid2 = C4::Budgets::AddBudget( 12, $invoiceid, 42, - $budgetid2 + $budgetid2, + undef, + undef, + "my other notes" ); my $order3 = GetOrder( $ordernumber3 ); is($order3->{'quantityreceived'}, 0, 'Splitting up order did not receive any on original order'); 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'); @@ -217,13 +226,17 @@ is($neworder->{'budget_id'}, $budgetid2, 'Budget on new order is changed'); 12, $invoiceid, 42, - $budgetid2 + $budgetid2, + undef, + undef, + "my third notes" ); $order3 = GetOrder( $ordernumber3 ); 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