Bug 9416: (follow-up) reconcile with work done on bug 11699

This patch teaches the ordering receiving process how to
set vendor and internal order notes.

One observation: I'm not sure it's entirely useful to set
a note to communicate to the vendor during receiving --
how is it to be sent to them, and why?

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Galen Charlton 2014-04-19 15:52:45 +00:00
parent 78551cc976
commit 58b5b384f6
3 changed files with 42 additions and 16 deletions

View File

@ -1432,7 +1432,8 @@ sub GetCancelledOrders {
budget_id => $budget_id,
datereceived => $datereceived,
received_itemnumbers => \@received_itemnumbers,
notes => $notes,
order_internalnote => $order_internalnote,
order_vendornote => $order_vendornote,
});
Updates an order, to reflect the fact that it was received, at least
@ -1460,7 +1461,8 @@ sub ModReceiveOrder {
my $budget_id = $params->{budget_id};
my $datereceived = $params->{datereceived};
my $received_items = $params->{received_items};
my $notes = $params->{notes};
my $order_internalnote = $params->{order_internalnote};
my $order_vendornote = $params->{order_vendornote};
my $dbh = C4::Context->dbh;
$datereceived = C4::Dates->output('iso') unless $datereceived;
@ -1490,11 +1492,17 @@ q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?},
UPDATE aqorders
SET quantity = ?,
orderstatus = 'partial'|;
$query .= q|, notes = ?| if defined $notes;
$query .= q|, order_internalnote = ?| if defined $order_internalnote;
$query .= q|, order_vendornote = ?| if defined $order_vendornote;
$query .= q| WHERE ordernumber = ?|;
my $sth = $dbh->prepare($query);
$sth->execute($order->{quantity} - $quantrec, ( defined $notes ? $notes : () ), $ordernumber);
$sth->execute(
$order->{quantity} - $quantrec,
( defined $order_internalnote ? $order_internalnote : () ),
( defined $order_vendornote ? $order_vendornote : () ),
$ordernumber
);
delete $order->{'ordernumber'};
$order->{'budget_id'} = ( $budget_id || $order->{'budget_id'} );
@ -1519,10 +1527,23 @@ q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?},
update aqorders
set quantityreceived=?,datereceived=?,invoiceid=?,
unitprice=?,rrp=?,ecost=?,budget_id=?,orderstatus='complete'|;
$query .= q|, notes = ?| if defined $notes;
$query .= q|, order_internalnote = ?| if defined $order_internalnote;
$query .= q|, order_vendornote = ?| if defined $order_vendornote;
$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);
$sth->execute(
$quantrec,
$datereceived,
$invoiceid,
$cost,
$rrp,
$ecost,
$budget_id,
( defined $order_internalnote ? $order_internalnote : () ),
( defined $order_vendornote ? $order_vendornote : () ),
$biblionumber,
$ordernumber
);
}
return ($datereceived, $new_ordernumber);
}

View File

@ -53,7 +53,8 @@ my $booksellerid = $input->param('booksellerid');
my $cnt = 0;
my $ecost = $input->param('ecost');
my $rrp = $input->param('rrp');
my $notes = $input->param("notes");
my $order_internalnote = $input->param("order_internalnote");
my $order_vendornote = $input->param("order_vendornote");
my $bookfund = $input->param("bookfund");
my $order = GetOrder($ordernumber);
my $new_ordernumber = $ordernumber;
@ -112,7 +113,8 @@ if ($quantityrec > $origquantityrec ) {
budget_id => $bookfund,
datereceived => $datereceived,
received_items => \@received_items,
notes => $notes,
order_internalnote => $order_internalnote,
order_vendornote => $order_vendornote,
} );
}

View File

@ -8,7 +8,7 @@ use POSIX qw(strftime);
use C4::Bookseller qw( GetBookSellerFromId );
use Test::More tests => 71;
use Test::More tests => 72;
BEGIN {
use_ok('C4::Acquisition');
@ -818,7 +818,8 @@ is(
ecost => 12,
invoiceid => $invoiceid,
rrp => 42,
notes => "my notes",
order_internalnote => "my notes",
order_vendornote => "my vendor notes",
}
);
my $order2 = GetOrder( $ordernumbers[1] );
@ -827,8 +828,10 @@ is( $order2->{'quantityreceived'},
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' );
is( $order2->{order_internalnote}, "my notes",
'ModReceiveOrder and GetOrder deal with internal notes' );
is( $order2->{order_vendornote}, "my vendor notes",
'ModReceiveOrder and GetOrder deal with vendor notes' );
$neworder = GetOrder($new_ordernumber);
is( $neworder->{'quantity'}, 2, '2 items on new order' );
@ -853,7 +856,7 @@ my $budgetid2 = C4::Budgets::AddBudget(
invoiceid => $invoiceid,
rrp => 42,
budget_id => $budgetid2,
notes => "my other notes",
order_internalnote => "my other notes",
}
);
@ -863,7 +866,7 @@ 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",
is( $order3->{order_internalnote}, "my other notes",
'ModReceiveOrder and GetOrder deal with notes' );
$neworder = GetOrder($new_ordernumber);
@ -882,7 +885,7 @@ is( $neworder->{'budget_id'}, $budgetid2, 'Budget on new order is changed' );
invoiceid => $invoiceid,
rrp => 42,
budget_id => $budgetid2,
notes => "my third notes",
order_internalnote => "my third notes",
}
);
@ -890,7 +893,7 @@ $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' );
is( $order3->{order_internalnote}, "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' );