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>
(cherry picked from commit ab1a74897e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Conflicts:
	t/db_dependent/Acquisition.t
This commit is contained in:
Jonathan Druart 2014-03-05 13:07:53 +01:00 committed by Fridolin Somers
parent 37f8245894
commit 1904e0c129
4 changed files with 34 additions and 16 deletions

View File

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

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