Koha/t/db_dependent/Acquisition/OrderFromSubscription.t
Yohann Dufour 63789fc095 Bug 12482: removing the use of the module C4::SQLHelper.pm, it is replaced by DBIx::Class
This patch includes:
- removing the use of subroutines InsertInTable, UpdateInTable, SearchInTable replaced by subroutines of DBIx::Class in the subroutines AddBudget, ModBudget, GetBudgets, AddBudgetPeriods, ModBudgetPeriod and GetBudgetPeriods and admin/aqbudgetperiods.pl
- removing old database fields in OrderFromSubscription.t, Bookseller.t, Budgets.t, Serials.t, Serials_2.t
- improvement of unit tests in t/db_dependent/Budgets.t
- adaptation of calls to the subroutines AddBudget, ModBudget, GetBudgets, AddBudgetPeriods, ModBudgetPeriod and GetBudgetPeriods in order to match with the use of DBIx::Class

Test plan:

1) Execute the UT of all of files wich uses AddBudget, ModBudget, GetBudgets, AddBudgetPeriods, ModBudgetPeriod or GetBudgetPeriods by launching the command :
prove t/Budgets/ t/Budgets.t t/db_dependent/Budgets.t t/db_dependent/Acquisition.t t/db_dependent/Acquisition/ t/db_dependent/Bookseller.t t/db_dependent/Serials.t t/db_dependent/Serials_2.t

2) The result has to be a success :
t/Budgets/CanUserModifyBudget.t ........................... ok
t/Budgets/CanUserUseBudget.t .............................. ok
t/Budgets.t ............................................... ok
t/db_dependent/Budgets.t .................................. ok
t/db_dependent/Acquisition.t .............................. ok
t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t .. ok
t/db_dependent/Acquisition/GetOrdersByBiblionumber.t ...... ok
t/db_dependent/Acquisition/Invoices.t ..................... ok
t/db_dependent/Acquisition/OrderFromSubscription.t ........ ok
t/db_dependent/Acquisition/TransferOrder.t ................ 1/11 # Transfering order to basket2
t/db_dependent/Acquisition/TransferOrder.t ................ ok
t/db_dependent/Acquisition/close_reopen_basket.t .......... ok
t/db_dependent/Bookseller.t ............................... 16/72 WARNING: GetBooksellerWithLateOrders is called with a negative value at /home/yohann/koha/C4/Bookseller.pm line 135.
t/db_dependent/Bookseller.t ............................... ok
t/db_dependent/Serials.t .................................. ok
t/db_dependent/Serials_2.t ................................ ok
All tests successful.
Files=14, Tests=571, 22 wallclock secs ( 0.17 usr  0.03 sys + 20.26 cusr  1.10 csys = 21.56 CPU)
Result: PASS

3) Go on the page admin/aqbudgetperiods.pl : Koha Administration > Budgets
4) Click on the button "New Budget" and record a new budget with a "nonzero amount" and "make budget active"
5) Click on the button "New Budget" and record another budget without "make budget active"
6) Verify there is the firt budget displayed in "Active budgets" and the second budget in "Inactive budgets"
7) Edit a budget and verify the new values are updated
8) Click on the budget active name in order to go on the page admin/aqbudgets.pl
9) Click on the button "New fund for ..." and record a new fund
10) Click on the button "Edit" then "Duplicate budget ..." in order to duplicate the budget
11) Verify there are two budgets in "Active Budgets" and one in "Inactive Budgets"
12) Click on "Funds" in the menu and verify there are two identical funds and each is associated to a different budget.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-07-03 14:24:58 -03:00

112 lines
3.7 KiB
Perl

use Modern::Perl;
use Test::More tests => 13;
use Data::Dumper;
use_ok('C4::Acquisition');
use_ok('C4::Biblio');
use_ok('C4::Budgets');
use_ok('C4::Serials');
# Start transaction
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $supplierlist=eval{GetSuppliersWithLateIssues()};
ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues");
my $booksellerid = C4::Bookseller::AddBookseller(
{
name => "my vendor",
address1 => "bookseller's address",
phone => "0123456",
active => 1
}
);
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
my $budgetid;
my $bpid = AddBudgetPeriod({
budget_period_startdate => '01-01-2015',
budget_period_enddate => '12-31-2015',
budget_period_description => "budget desc"
});
my $budget_id = AddBudget({
budget_code => "ABCD",
budget_amount => "123.132",
budget_name => "Périodiques",
budget_notes => "This is a note",
budget_period_id => $bpid
});
my $subscriptionid = NewSubscription(
undef, "", undef, undef, $budget_id, $biblionumber,
'01-01-2013',undef, undef, undef, undef,
undef, undef, undef, undef, undef, undef,
1, "notes",undef, '01-01-2013', undef, undef,
undef, undef, 0, "intnotes", 0,
undef, undef, 0, undef, '31-12-2013', 0
);
die unless $subscriptionid;
my ($basket, $basketno);
ok($basketno = NewBasket($booksellerid, 1), "NewBasket( $booksellerid , 1 ) returns $basketno");
my $cost = 42.00;
my $subscription = GetSubscription( $subscriptionid );
my $ordernumber;
( $basketno, $ordernumber ) = NewOrder({
biblionumber => $subscription->{biblionumber},
entrydate => '01-01-2013',
quantity => 1,
currency => 'USD',
listprice => $cost,
notes => "This is a note",
basketno => $basketno,
rrp => $cost,
ecost => $cost,
gstrate => 0.0500,
orderstatus => 'new',
subscriptionid => $subscription->{subscriptionid},
budget_id => $budget_id,
});
my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} );
is ( $is_currently_on_order, 1, "The subscription is currently on order");
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");
$dbh->do(q{DELETE FROM aqinvoices});
my $invoiceid = AddInvoice(invoicenumber => 'invoice1', booksellerid => $booksellerid, unknown => "unknown");
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber,
ordernumber => $ordernumber,
quantityreceived => 1,
cost => $cost,
ecost => $cost,
rrp => $cost,
budget_id => $budget_id,
datereceived => '02-01-2013',
invoiceid => $invoiceid,
}
);
$order = GetLastOrderReceivedFromSubscriptionid( $subscription->{subscriptionid} );
is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order received");
ok( $order->{ecost} == $cost, "test cost for the last order received");
$order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
is ( $order, undef, "test no not received order for a received order");
my @invoices = GetInvoices();
my @invoices_linked_to_subscriptions = grep { $_->{is_linked_to_subscriptions} } @invoices;
is(scalar(@invoices_linked_to_subscriptions), 1, 'GetInvoices() can identify invoices that are linked to a subscription');
# Cleanup
$dbh->rollback;