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 <mtompset@hotmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
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 <gmc@esilibrary.com>
This commit is contained in:
Jonathan Druart 2014-03-05 13:07:53 +01:00 committed by Galen Charlton
parent 9bcd3fcb99
commit ab1a74897e
4 changed files with 27 additions and 17 deletions

View File

@ -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);
}

View File

@ -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,
);
}

View File

@ -329,7 +329,7 @@
[% ELSE %]
<input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
[% END %]</li></ol>
<label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
<label for="note">Notes: </label><textarea name="notes" width="40" rows="8" >[% notes %]</textarea>
</fieldset>
</div>

View File

@ -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' );