From 36fc9a3e641b82cb9ef044c54872f68d5a7ebbf3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 5 Mar 2014 13:23:07 +0100 Subject: [PATCH] Bug 11699: change ModReceiveOrder to used named parameters Test plan: prove t/db_dependent/Acquisition.t prove t/db_dependent/Acquisition/Invoices.t prove t/db_dependent/Acquisition/OrderFromSubscription.t all should return green. NOTE: Any error messages are the same between master and this patch, and are unrelated to the added/revised tests. Signed-off-by: Mark Tompsett Signed-off-by: Katrin Fischer Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 34 ++++++++-- acqui/finishreceive.pl | 28 ++++---- t/db_dependent/Acquisition.t | 62 +++++++++++++---- t/db_dependent/Acquisition/Invoices.t | 66 ++++++++++--------- .../Acquisition/OrderFromSubscription.t | 13 +++- 5 files changed, 136 insertions(+), 67 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index fa2a30dccd..da8e86d6fb 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1420,8 +1420,20 @@ sub GetCancelledOrders { =head3 ModReceiveOrder - &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user, - $cost, $ecost, $invoiceid, rrp, budget_id, datereceived, \@received_itemnumbers); + &ModReceiveOrder({ + biblionumber => $biblionumber, + ordernumber => $ordernumber, + quantityreceived => $quantityreceived, + user => $user, + cost => $cost, + ecost => $ecost, + invoiceid => $invoiceid, + rrp => rrp, + budget_id => budget_id, + datereceived => datereceived, + received_itemnumbers => \@received_itemnumbers, + notes => $notes, + ); Updates an order, to reflect the fact that it was received, at least in part. All arguments not mentioned below update the fields with the @@ -1436,11 +1448,19 @@ C<$ordernumber>. sub ModReceiveOrder { - my ( - $biblionumber, $ordernumber, $quantrec, $user, $cost, $ecost, - $invoiceid, $rrp, $budget_id, $datereceived, $received_items, $notes - ) - = @_; + my ( $params ) = @_; + my $biblionumber = $params->{biblionumber}; + my $ordernumber = $params->{ordernumber}; + my $quantrec = $params->{quantityreceived}; + my $user = $params->{user}; + my $cost = $params->{cost}; + my $ecost = $params->{ecost}; + my $invoiceid = $params->{invoiceid}; + my $rrp = $params->{rrp}; + my $budget_id = $params->{budget_id}; + my $datereceived = $params->{datereceived}; + my $received_items = $params->{received_items}; + my $notes = $params->{notes}; my $dbh = C4::Context->dbh; $datereceived = C4::Dates->output('iso') unless $datereceived; diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index f1f9a0977a..68870945c2 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -100,20 +100,20 @@ if ($quantityrec > $origquantityrec ) { # save the quantity received. if ( $quantityrec > 0 ) { - ($datereceived, $new_ordernumber) = ModReceiveOrder( - $biblionumber, - $ordernumber, - $quantityrec, - $user, - $order->{unitprice}, - $order->{ecost}, - $invoiceid, - $order->{rrp}, - $bookfund, - $datereceived, - \@received_items, - $notes, - ); + ($datereceived, $new_ordernumber) = ModReceiveOrder({ + biblionumber => $biblionumber, + ordernumber => $ordernumber, + quantityreceived => $quantityrec, + user => $user, + cost => $order->{unitprice}, + ecost => $order->{ecost}, + invoiceid => $invoiceid, + rrp => $order->{rrp}, + budget_id => $bookfund, + datereceived => $datereceived, + received_items => \@received_items, + notes => $notes, + } ); } # now, add items if applicable diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index ed352b0faf..f085103191 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -651,9 +651,18 @@ my $invoiceid = AddInvoice( unknown => "unknown" ); -my ( $datereceived, $new_ordernumber ) = - ModReceiveOrder( $biblionumber4, $ordernumbers[4], 1, undef, 10, 10, - $invoiceid, 10, $order_content[4]->{str}->{budget_id} ); +my ($datereceived, $new_ordernumber) = ModReceiveOrder( + { + biblionumber => $biblionumber4, + ordernumber => $ordernumbers[4], + quantityreceived => 1, + cost => 10, + ecost => 10, + invoiceid => $invoiceid, + rrp => 10, + budget_id => $order_content[4]->{str}->{budget_id}, + } +); my $search_orders = SearchOrders({ booksellerid => $booksellerid, @@ -791,9 +800,18 @@ is( "AddClaim : Check claimed_date" ); -( $datereceived, $new_ordernumber ) = - ModReceiveOrder( $biblionumber2, $ordernumbers[1], 2, undef, 12, 12, - $invoiceid, 42, undef, undef, undef, "my notes"); +( $datereceived, $new_ordernumber ) = ModReceiveOrder( + { + biblionumber => $biblionumber2, + ordernumber => $ordernumbers[1], + quantityreceived => 2, + cost => 12, + ecost => 12, + invoiceid => $invoiceid, + rrp => 42, + notes => "my notes", + } +); my $order2 = GetOrder( $ordernumbers[1] ); is( $order2->{'quantityreceived'}, 0, 'Splitting up order did not receive any on original order' ); @@ -816,9 +834,19 @@ my $budgetid2 = C4::Budgets::AddBudget( } ); -( $datereceived, $new_ordernumber ) = - ModReceiveOrder( $biblionumber2, $ordernumbers[2], 2, undef, 12, 12, - $invoiceid, 42, $budgetid2, undef, undef, "my other notes" ); +( $datereceived, $new_ordernumber ) = ModReceiveOrder( + { + biblionumber => $biblionumber2, + ordernumber => $ordernumbers[2], + quantityreceived => 2, + cost => 12, + ecost => 12, + invoiceid => $invoiceid, + rrp => 42, + budget_id => $budgetid2, + notes => "my other notes", + } +); my $order3 = GetOrder( $ordernumbers[2] ); is( $order3->{'quantityreceived'}, @@ -835,9 +863,19 @@ is( $neworder->{'quantityreceived'}, 2, 'Splitting up order received items on new order' ); 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, undef, undef, "my third notes" ); +( $datereceived, $new_ordernumber ) = ModReceiveOrder( + { + biblionumber => $biblionumber2, + ordernumber => $ordernumbers[2], + quantityreceived => 2, + cost => 12, + ecost => 12, + invoiceid => $invoiceid, + rrp => 42, + budget_id => $budgetid2, + notes => "my third notes", + } +); $order3 = GetOrder( $ordernumbers[2] ); is( $order3->{'quantityreceived'}, 2, 'Order not split up' ); diff --git a/t/db_dependent/Acquisition/Invoices.t b/t/db_dependent/Acquisition/Invoices.t index 78b7cfb26b..3b86a545ba 100644 --- a/t/db_dependent/Acquisition/Invoices.t +++ b/t/db_dependent/Acquisition/Invoices.t @@ -87,39 +87,41 @@ my $invoiceid2 = AddInvoice(invoicenumber => 'invoice2', booksellerid => $bookse shipmentdate => '2012-12-24', ); -my ($datereceived, $new_ordernumber) = ModReceiveOrder( - $biblionumber1, - $ordernumber1, - 2, - undef, - 12, - 12, - $invoiceid1, - 42 - ); - -($datereceived, $new_ordernumber) = ModReceiveOrder( - $biblionumber2, - $ordernumber2, - 1, - undef, - 5, - 5, - $invoiceid2, - 42 - ); - -($datereceived, $new_ordernumber) = ModReceiveOrder( - $biblionumber3, - $ordernumber3, - 1, - undef, - 12, - 12, - $invoiceid2, - 42 - ); +my ( $datereceived, $new_ordernumber ) = ModReceiveOrder( + { + biblionumber => $biblionumber1, + ordernumber => $ordernumber1, + quantityreceived => 2, + cost => 12, + ecost => 12, + invoiceid => $invoiceid1, + rrp => 42 + } +); + +( $datereceived, $new_ordernumber ) = ModReceiveOrder( + { + biblionumber => $biblionumber2, + ordernumber => $ordernumber2, + quantityreceived => 1, + cost => 5, + ecost => 5, + invoiceid => $invoiceid2, + rrp => 42 + } +); +( $datereceived, $new_ordernumber ) = ModReceiveOrder( + { + biblionumber => $biblionumber3, + ordernumber => $ordernumber3, + quantityreceived => 1, + cost => 12, + ecost => 12, + invoiceid => $invoiceid2, + rrp => 42 + } +); my $invoice1 = GetInvoiceDetails($invoiceid1); my $invoice2 = GetInvoiceDetails($invoiceid2); diff --git a/t/db_dependent/Acquisition/OrderFromSubscription.t b/t/db_dependent/Acquisition/OrderFromSubscription.t index 60b1d3a03d..12ca9a4bd2 100644 --- a/t/db_dependent/Acquisition/OrderFromSubscription.t +++ b/t/db_dependent/Acquisition/OrderFromSubscription.t @@ -83,8 +83,17 @@ is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscripti ok( $order->{ecost} == $cost, "test cost for the last order not received"); my ( $datereceived, $new_ordernumber ) = ModReceiveOrder( - $biblionumber, $ordernumber, 1, undef, $cost, $cost, - undef, $cost, $budget_id, '02-01-2013', undef); + { + biblionumber => $biblionumber, + ordernumber => $ordernumber, + quantityreceived => 1, + cost => $cost, + ecost => $cost, + rrp => $cost, + budget_id => $budget_id, + datereceived => '02-01-2013' + } +); $order = GetLastOrderReceivedFromSubscriptionid( $subscription->{subscriptionid} ); is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order received"); -- 2.39.5