From f622c21c23f19ff06bfdb43db83b08e34c09c646 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 10 Jan 2017 17:08:51 +0100 Subject: [PATCH] Bug 11708: Move acq related Koha::Objects to Koha::Acquisition namespace and fix Koha::Acquisition::Order usage everywhere --- C4/Acquisition.pm | 8 +++-- Koha/Acquisition/Basket.pm | 26 +++++++++++++--- Koha/{ => Acquisition}/Basketgroup.pm | 8 ++--- Koha/{ => Acquisition}/Basketgroups.pm | 6 ++-- Koha/Acquisition/Baskets.pm | 28 +---------------- Koha/Acquisition/Order.pm | 11 +++++-- Koha/Acquisition/Orders.pm | 20 ------------ Koha/Basket.pm | 36 ---------------------- Koha/Baskets.pm | 32 ------------------- Koha/Bookseller.pm | 26 ---------------- Koha/Booksellers.pm | 32 ------------------- Koha/Order.pm | 26 ---------------- Koha/Orders.pm | 32 ------------------- admin/currency.pl | 1 + t/db_dependent/Acquisition.t | 1 - .../Acquisition/GetOrdersByBiblionumber.t | 9 ++---- t/db_dependent/Acquisition/Invoices.t | 25 +++++++++------ t/db_dependent/Acquisition/NewOrder.t | 2 +- t/db_dependent/Acquisition/OrderFromSubscription.t | 8 ++--- t/db_dependent/Acquisition/OrderUsers.t | 1 - t/db_dependent/Acquisition/close_reopen_basket.t | 4 +-- t/db_dependent/Bookseller.t | 20 +++++------- t/db_dependent/Budgets.t | 7 ++--- 23 files changed, 81 insertions(+), 288 deletions(-) rename Koha/{ => Acquisition}/Basketgroup.pm (87%) rename Koha/{ => Acquisition}/Basketgroups.pm (87%) delete mode 100644 Koha/Basket.pm delete mode 100644 Koha/Baskets.pm delete mode 100644 Koha/Bookseller.pm delete mode 100644 Koha/Booksellers.pm delete mode 100644 Koha/Order.pm delete mode 100644 Koha/Orders.pm diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 92ab382230..c8c19c79c7 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1510,7 +1510,9 @@ sub ModReceiveOrder { $order->{datereceived} = $datereceived; $order->{invoiceid} = $invoice->{invoiceid}; $order->{orderstatus} = 'complete'; - $new_ordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber; # TODO What if the store fails? + my @columns = Koha::Acquisition::Orders->columns; + my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns; + $new_ordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber; if ($received_items) { foreach my $itemnumber (@$received_items) { @@ -2000,7 +2002,9 @@ sub TransferOrder { delete $order->{parent_ordernumber}; $order->{'basketno'} = $basketno; - my $newordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber; + my @columns = Koha::Acquisition::Orders->columns; + my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns; + my $newordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber; $query = q{ UPDATE aqorders_items diff --git a/Koha/Acquisition/Basket.pm b/Koha/Acquisition/Basket.pm index 98e4bd45b5..b0329f112c 100644 --- a/Koha/Acquisition/Basket.pm +++ b/Koha/Acquisition/Basket.pm @@ -19,7 +19,7 @@ package Koha::Acquisition::Basket; use Modern::Perl; -use Koha::Database; +use Koha::Acquisition::Orders; use base qw( Koha::Object ); @@ -31,8 +31,6 @@ Koha::Acquisition::Basket - Koha Basket Object class =head2 Class Methods -=cut - =head3 bookseller Returns the vendor @@ -45,7 +43,6 @@ sub bookseller { return Koha::Acquisition::Bookseller->_new_from_dbic( $bookseller_rs ); } - =head3 effective_create_items Returns C for this basket, falling back to C if unset. @@ -58,6 +55,27 @@ sub effective_create_items { return $self->create_items || C4::Context->preference('AcqCreateItem'); } +=head3 orders + +Returns basket's orders + + # As an arrayref + my $orders = $basket->orders; + + # As an array + my @orders = $basket->orders; + +=cut + +sub orders { + my ($self) = @_; + + $self->{_orders} ||= Koha::Acquisition::Orders->search({ basketno => $self->basketno }); + + return wantarray ? $self->{_orders}->as_list : $self->{_orders}; +} + + =head2 Internal methods =head3 _type diff --git a/Koha/Basketgroup.pm b/Koha/Acquisition/Basketgroup.pm similarity index 87% rename from Koha/Basketgroup.pm rename to Koha/Acquisition/Basketgroup.pm index e624a35b0b..dd7ece6baa 100644 --- a/Koha/Basketgroup.pm +++ b/Koha/Acquisition/Basketgroup.pm @@ -1,4 +1,4 @@ -package Koha::Basketgroup; +package Koha::Acquisition::Basketgroup; # This file is part of Koha. # @@ -19,7 +19,7 @@ use Modern::Perl; use List::MoreUtils qw/uniq/; -use Koha::Baskets; +use Koha::Acquisition::Baskets; use base qw(Koha::Object); @@ -30,13 +30,13 @@ sub _type { sub bookseller { my ($self) = @_; - return Koha::Booksellers->find($self->booksellerid); + return scalar Koha::Acquisition::Booksellers->find($self->booksellerid); } sub baskets { my ($self) = @_; - $self->{_baskets} ||= Koha::Baskets->search({ basketgroupid => $self->id }); + $self->{_baskets} ||= Koha::Acquisition::Baskets->search({ basketgroupid => $self->id }); return wantarray ? $self->{_baskets}->as_list : $self->{_baskets}; } diff --git a/Koha/Basketgroups.pm b/Koha/Acquisition/Basketgroups.pm similarity index 87% rename from Koha/Basketgroups.pm rename to Koha/Acquisition/Basketgroups.pm index 1dbc6d1e74..6f648cc938 100644 --- a/Koha/Basketgroups.pm +++ b/Koha/Acquisition/Basketgroups.pm @@ -1,4 +1,4 @@ -package Koha::Basketgroups; +package Koha::Acquisition::Basketgroups; # This file is part of Koha. # @@ -17,7 +17,7 @@ package Koha::Basketgroups; use Modern::Perl; -use Koha::Basketgroup; +use Koha::Acquisition::Basketgroup; use base qw(Koha::Objects); @@ -26,7 +26,7 @@ sub _type { } sub object_class { - return 'Koha::Basketgroup'; + return 'Koha::Acquisition::Basketgroup'; } 1; diff --git a/Koha/Acquisition/Baskets.pm b/Koha/Acquisition/Baskets.pm index 2de46835a7..e29f2e1ac8 100644 --- a/Koha/Acquisition/Baskets.pm +++ b/Koha/Acquisition/Baskets.pm @@ -1,7 +1,5 @@ package Koha::Acquisition::Baskets; -# Copyright 2017 Aleisha Amohia -# # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the @@ -19,40 +17,16 @@ package Koha::Acquisition::Baskets; use Modern::Perl; -use Koha::Database; use Koha::Acquisition::Basket; -use base qw( Koha::Objects ); - -=head1 NAME - -Koha::Acquisition::Baskets - Koha Baskets object set class - -=head1 API - -=head2 Internal methods - -=head3 _type - -=cut +use base qw(Koha::Objects); sub _type { return 'Aqbasket'; } -=head3 object_class - -=cut - sub object_class { return 'Koha::Acquisition::Basket'; } -=head1 AUTHOR - -Aleisha Amohia -Catalyst IT - -=cut - 1; diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index 1c52497279..c969c2a3b6 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -16,12 +16,14 @@ package Koha::Acquisition::Order; # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use Modern::Perl; +use Carp qw( croak ); use Carp qw( croak ); use Koha::Acquisition::Baskets; use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::Acquisition::Baskets; use base qw(Koha::Object); @@ -59,9 +61,12 @@ Overloaded I method for backwards compatibility. sub store { my ($self) = @_; - my $schema = Koha::Database->new->schema; - # Override quantity for standing orders - $self->quantity(1) if ( $self->basketno && $schema->resultset('Aqbasket')->find( $self->basketno )->is_standing ); + if ($self->basketno) { + my $basket = Koha::Acquisition::Baskets->find($self->basketno); + if ($basket->is_standing) { + $self->quantity(1); + } + } # if these parameters are missing, we can't continue for my $key (qw( basketno quantity biblionumber budget_id )) { diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm index 56c2fb45d5..9af45ee722 100644 --- a/Koha/Acquisition/Orders.pm +++ b/Koha/Acquisition/Orders.pm @@ -17,34 +17,14 @@ package Koha::Acquisition::Orders; use Modern::Perl; -use Carp; - -use Koha::Database; - use Koha::Acquisition::Order; use base qw(Koha::Objects); -=head1 NAME - -Koha::Acquisition::Orders object set class - -=head1 API - -=head2 Internal methods - -=head3 _type (internal) - -=cut - sub _type { return 'Aqorder'; } -=head3 object_class (internal) - -=cut - sub object_class { return 'Koha::Acquisition::Order'; } diff --git a/Koha/Basket.pm b/Koha/Basket.pm deleted file mode 100644 index 4703101a50..0000000000 --- a/Koha/Basket.pm +++ /dev/null @@ -1,36 +0,0 @@ -package Koha::Basket; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use Koha::Orders; - -use base qw(Koha::Object); - -sub _type { - return 'Aqbasket'; -} - -sub orders { - my ($self) = @_; - - $self->{_orders} ||= Koha::Orders->search({ basketno => $self->basketno }); - - return wantarray ? $self->{_orders}->as_list : $self->{_orders}; -} - -1; diff --git a/Koha/Baskets.pm b/Koha/Baskets.pm deleted file mode 100644 index badd91ab5b..0000000000 --- a/Koha/Baskets.pm +++ /dev/null @@ -1,32 +0,0 @@ -package Koha::Baskets; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use Koha::Basket; - -use base qw(Koha::Objects); - -sub _type { - return 'Aqbasket'; -} - -sub object_class { - return 'Koha::Basket'; -} - -1; diff --git a/Koha/Bookseller.pm b/Koha/Bookseller.pm deleted file mode 100644 index 1979f6207d..0000000000 --- a/Koha/Bookseller.pm +++ /dev/null @@ -1,26 +0,0 @@ -package Koha::Bookseller; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use base qw(Koha::Object); - -sub _type { - return 'Aqbookseller'; -} - -1; diff --git a/Koha/Booksellers.pm b/Koha/Booksellers.pm deleted file mode 100644 index fb689c7a95..0000000000 --- a/Koha/Booksellers.pm +++ /dev/null @@ -1,32 +0,0 @@ -package Koha::Booksellers; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use Koha::Bookseller; - -use base qw(Koha::Objects); - -sub _type { - return 'Aqbookseller'; -} - -sub object_class { - return 'Koha::Bookseller'; -} - -1; diff --git a/Koha/Order.pm b/Koha/Order.pm deleted file mode 100644 index 7ab7ed11e5..0000000000 --- a/Koha/Order.pm +++ /dev/null @@ -1,26 +0,0 @@ -package Koha::Order; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use base qw(Koha::Object); - -sub _type { - return 'Aqorder'; -} - -1; diff --git a/Koha/Orders.pm b/Koha/Orders.pm deleted file mode 100644 index 49f616b12a..0000000000 --- a/Koha/Orders.pm +++ /dev/null @@ -1,32 +0,0 @@ -package Koha::Orders; - -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use Modern::Perl; - -use Koha::Order; - -use base qw(Koha::Objects); - -sub _type { - return 'Aqorder'; -} - -sub object_class { - return 'Koha::Order'; -} - -1; diff --git a/admin/currency.pl b/admin/currency.pl index 171949850b..bb6cebba0e 100755 --- a/admin/currency.pl +++ b/admin/currency.pl @@ -27,6 +27,7 @@ use C4::Output; use Koha::Acquisition::Booksellers; use Koha::Acquisition::Currencies; +use Koha::Acquisition::Currency; use Koha::Acquisition::Orders; my $input = CGI->new; diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index 0475872fb9..e39e3ccd06 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -180,7 +180,6 @@ my @order_content = ( uncertainprice => 0, order_internalnote => "internal note", order_vendornote => "vendor note", - ordernumber => '', }, num => { quantity => 24, diff --git a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t b/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t index b622ced624..804f0765b0 100644 --- a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t +++ b/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t @@ -41,7 +41,7 @@ my $budget = C4::Budgets::GetBudget( $budgetid ); my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, ''); my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); -my $order1 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno, quantity => 24, @@ -49,9 +49,8 @@ my $order1 = Koha::Acquisition::Order->new( budget_id => $budget->{budget_id}, } )->store; -my $ordernumber1 = $order1->ordernumber; -my $order2 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno, quantity => 42, @@ -59,9 +58,8 @@ my $order2 = Koha::Acquisition::Order->new( budget_id => $budget->{budget_id}, } )->store; -my $ordernumber2 = $order2->ordernumber; -my $order3 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno, quantity => 4, @@ -69,7 +67,6 @@ my $order3 = Koha::Acquisition::Order->new( budget_id => $budget->{budget_id}, } )->store; -my $ordernumber3 = $order3->ordernumber; my @orders = GetOrdersByBiblionumber(); is(scalar(@orders), 0, 'GetOrdersByBiblionumber : no argument, return undef'); diff --git a/t/db_dependent/Acquisition/Invoices.t b/t/db_dependent/Acquisition/Invoices.t index b472ce7d16..5e84a6b729 100644 --- a/t/db_dependent/Acquisition/Invoices.t +++ b/t/db_dependent/Acquisition/Invoices.t @@ -44,12 +44,22 @@ my $budgetid = C4::Budgets::AddBudget( my $budget = C4::Budgets::GetBudget( $budgetid ); my $bibrec1 = MARC::Record->new(); -$bibrec1->append_fields( - MARC::Field->new('020', '', '', 'a' => '1234567890'), - MARC::Field->new('100', '', '', 'a' => 'Shakespeare, Billy'), - MARC::Field->new('245', '', '', 'a' => 'Bug 8854'), - MARC::Field->new('260', '', '', 'b' => 'Scholastic Publishing', c => 'c2012'), -); +if (C4::Context->preference('marcflavour') eq 'UNIMARC') { + $bibrec1->append_fields( + MARC::Field->new('010', '', '', 'a' => '1234567890'), + MARC::Field->new('200', '', '', 'f' => 'Shakespeare, Billy'), + MARC::Field->new('200', '', '', 'a' => 'Bug 8854'), + MARC::Field->new('210', '', '', 'c' => 'Scholastic Publishing', d => '2012'), + ); +} else { + $bibrec1->append_fields( + MARC::Field->new('020', '', '', 'a' => '1234567890'), + MARC::Field->new('100', '', '', 'a' => 'Shakespeare, Billy'), + MARC::Field->new('245', '', '', 'a' => 'Bug 8854'), + MARC::Field->new('260', '', '', 'b' => 'Scholastic Publishing', c => '2012'), + ); +} + my ($biblionumber1, $biblioitemnumber1) = AddBiblio($bibrec1, ''); my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); my ($biblionumber3, $biblioitemnumber3) = AddBiblio(MARC::Record->new, ''); @@ -62,7 +72,6 @@ my $order1 = Koha::Acquisition::Order->new( budget_id => $budget->{budget_id}, } )->store; -my $ordernumber1 = $order1->ordernumber; my $order2 = Koha::Acquisition::Order->new( { @@ -72,7 +81,6 @@ my $order2 = Koha::Acquisition::Order->new( budget_id => $budget->{budget_id}, } )->store; -my $ordernumber2 = $order2->ordernumber; my $order3 = Koha::Acquisition::Order->new( { @@ -84,7 +92,6 @@ my $order3 = Koha::Acquisition::Order->new( rrp => 42, } )->store; -my $ordernumber3 = $order3->ordernumber; my $invoiceid1 = AddInvoice(invoicenumber => 'invoice1', booksellerid => $booksellerid, unknown => "unknown"); my $invoiceid2 = AddInvoice(invoicenumber => 'invoice2', booksellerid => $booksellerid, unknown => "unknown", diff --git a/t/db_dependent/Acquisition/NewOrder.t b/t/db_dependent/Acquisition/NewOrder.t index b327a8d878..3929317fa5 100644 --- a/t/db_dependent/Acquisition/NewOrder.t +++ b/t/db_dependent/Acquisition/NewOrder.t @@ -84,7 +84,7 @@ $order = Koha::Acquisition::Order->new( )->store; my $ordernumber = $order->ordernumber; $order = Koha::Acquisition::Orders->find( $ordernumber ); -is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' ); +is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->store set quantityreceivedto 0 if undef is given' ); is( $order->entrydate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' ); $schema->storage->txn_rollback(); diff --git a/t/db_dependent/Acquisition/OrderFromSubscription.t b/t/db_dependent/Acquisition/OrderFromSubscription.t index cc691d0585..39bbe51a98 100644 --- a/t/db_dependent/Acquisition/OrderFromSubscription.t +++ b/t/db_dependent/Acquisition/OrderFromSubscription.t @@ -31,7 +31,6 @@ my $bookseller = Koha::Acquisition::Bookseller->new( )->store; my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, ''); -my $budgetid; my $bpid = AddBudgetPeriod({ budget_period_startdate => '2015-01-01', budget_period_enddate => '2015-12-31', @@ -56,13 +55,13 @@ my $subscriptionid = NewSubscription( ); die unless $subscriptionid; -my ($basket, $basketno); +my $basketno; ok($basketno = NewBasket($bookseller->id, 1), "NewBasket( " . $bookseller->id . ", 1 ) returns $basketno"); my $cost = 42.00; my $subscription = GetSubscription( $subscriptionid ); -my $order = Koha::Acquisition::Order->new({ +Koha::Acquisition::Order->new({ biblionumber => $subscription->{biblionumber}, entrydate => '2013-01-01', quantity => 1, @@ -75,12 +74,11 @@ my $order = Koha::Acquisition::Order->new({ subscriptionid => $subscription->{subscriptionid}, budget_id => $budget_id, })->store; -my $ordernumber = $order->ordernumber; my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} ); is ( $is_currently_on_order, 1, "The subscription is currently on order"); -$order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} ); +my $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} ); is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received"); ok( $order->{ecost} == $cost, "test cost for the last order not received"); diff --git a/t/db_dependent/Acquisition/OrderUsers.t b/t/db_dependent/Acquisition/OrderUsers.t index 5b142f75b4..cef22d51cf 100644 --- a/t/db_dependent/Acquisition/OrderUsers.t +++ b/t/db_dependent/Acquisition/OrderUsers.t @@ -40,7 +40,6 @@ my $budgetid = C4::Budgets::AddBudget( ); my $budget = C4::Budgets::GetBudget($budgetid); -my @ordernumbers; my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' ); my $order = Koha::Acquisition::Order->new( diff --git a/t/db_dependent/Acquisition/close_reopen_basket.t b/t/db_dependent/Acquisition/close_reopen_basket.t index adc1d9ce91..71a2c1514f 100644 --- a/t/db_dependent/Acquisition/close_reopen_basket.t +++ b/t/db_dependent/Acquisition/close_reopen_basket.t @@ -47,7 +47,7 @@ my $budget = C4::Budgets::GetBudget( $budgetid ); my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, ''); my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); -my $order1 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno, quantity => 24, @@ -57,7 +57,7 @@ my $order1 = Koha::Acquisition::Order->new( )->store; my $ordernumber1 = $order1->ordernumber; -my $order2 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno, quantity => 42, diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t index b9de02cf9c..f25969cbac 100644 --- a/t/db_dependent/Bookseller.t +++ b/t/db_dependent/Bookseller.t @@ -349,7 +349,7 @@ is(scalar(@subscriptions), 1, 'search for subscriptions by call number'); is(scalar(@subscriptions), 1, 'search for subscriptions by location'); #Add 4 orders -my $order1 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno1, quantity => 24, @@ -358,7 +358,7 @@ my $order1 = Koha::Acquisition::Order->new( entrydate => '2013-01-01', currency => $curcode, notes => "This is a note1", - tax_rate => 0.0500, + tax_rate_on_ordering => 0.0500, orderstatus => 1, subscriptionid => $id_subscription1, quantityreceived => 2, @@ -367,9 +367,8 @@ my $order1 = Koha::Acquisition::Order->new( datereceived => '2013-06-01' } )->store; -my $ordernumber1 = $order1->ordernumber; -my $order2 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno2, quantity => 20, @@ -378,16 +377,15 @@ my $order2 = Koha::Acquisition::Order->new( entrydate => '2013-01-01', currency => $curcode, notes => "This is a note2", - tax_rate => 0.0500, + tax_rate_on_ordering => 0.0500, orderstatus => 1, subscriptionid => $id_subscription2, rrp => 10, ecost => 10, } )->store; -my $ordernumber2 = $order2->ordernumber; -my $order3 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno3, quantity => 20, @@ -396,16 +394,15 @@ my $order3 = Koha::Acquisition::Order->new( entrydate => '2013-02-02', currency => $curcode, notes => "This is a note3", - tax_rate => 0.0500, + tax_rate_on_ordering => 0.0500, orderstatus => 2, subscriptionid => $id_subscription3, rrp => 11, ecost => 11, } )->store; -my $ordernumber3 = $order3->ordernumber; -my $order4 = Koha::Acquisition::Order->new( +Koha::Acquisition::Order->new( { basketno => $basketno4, quantity => 20, @@ -414,7 +411,7 @@ my $order4 = Koha::Acquisition::Order->new( entrydate => '2013-02-02', currency => $curcode, notes => "This is a note3", - tax_rate => 0.0500, + tax_rate_on_ordering => 0.0500, orderstatus => 2, subscriptionid => $id_subscription3, rrp => 11, @@ -422,7 +419,6 @@ my $order4 = Koha::Acquisition::Order->new( quantityreceived => 20 } )->store; -my $ordernumber4 = $order4->ordernumber; #Test cases: # Sample datas : diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t index 21f2d59b1f..f13eae8494 100755 --- a/t/db_dependent/Budgets.t +++ b/t/db_dependent/Budgets.t @@ -350,10 +350,10 @@ for my $infos (@order_infos) { order_internalnote => "internal note", order_vendornote => "vendor note", quantity => 2, - cost_tax_included => $item_price, + ecost_tax_included => $item_price, rrp_tax_included => $item_price, listprice => $item_price, - ecost_tax_include => $item_price, + ecost_tax_included => $item_price, discount => 0, uncertainprice => 0, } @@ -371,7 +371,7 @@ for my $infos (@order_infos) { order_internalnote => "internal note", order_vendornote => "vendor note", quantity => $item_quantity, - cost => $item_price, + ecost => $item_price, rrp_tax_included => $item_price, listprice => $item_price, ecost_tax_included => $item_price, @@ -379,7 +379,6 @@ for my $infos (@order_infos) { uncertainprice => 0, } )->store; - my $ordernumber = $order->ordernumber; ModReceiveOrder({ biblionumber => $biblionumber, order => $order->unblessed, -- 2.14.2