|
Lines 1-61
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
|
|
3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Copyright 2014 - Biblibre SARL |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
| 3 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 4 |
use Test::More tests => 18; |
21 |
use Test::More tests => 18; |
| 5 |
use Data::Dumper; |
22 |
use t::lib::TestBuilder; |
| 6 |
|
|
|
| 7 |
use C4::Acquisition qw( NewOrder NewBasket GetBasketsInfosByBookseller ); |
| 8 |
use C4::Biblio qw( AddBiblio ); |
| 9 |
use C4::Bookseller qw( AddBookseller ); |
| 10 |
use C4::Budgets qw( AddBudget ); |
| 11 |
use C4::Context; |
| 12 |
my $dbh = C4::Context->dbh; |
| 13 |
$dbh->{AutoCommit} = 0; |
| 14 |
$dbh->{RaiseError} = 1; |
| 15 |
|
23 |
|
| 16 |
my $supplierid = C4::Bookseller::AddBookseller( |
24 |
BEGIN { |
| 17 |
{ |
25 |
use_ok('C4::Acquisition'); |
| 18 |
name => 'my vendor', |
26 |
} |
| 19 |
address1 => 'bookseller\'s address', |
|
|
| 20 |
phone => '0123456', |
| 21 |
active => 1, |
| 22 |
deliverytime => 5, |
| 23 |
} |
| 24 |
); |
| 25 |
|
27 |
|
| 26 |
my $basketno; |
|
|
| 27 |
ok($basketno = NewBasket($supplierid, 1), 'NewBasket( $supplierid , 1 ) returns $basketno'); |
| 28 |
|
28 |
|
| 29 |
my $budgetid = C4::Budgets::AddBudget( |
29 |
my $builder = t::lib::TestBuilder->new(); |
| 30 |
{ |
30 |
$builder->clear( { source => 'Aqorder' } ); |
| 31 |
budget_code => 'budget_code_test_getordersbybib', |
|
|
| 32 |
budget_name => 'budget_name_test_getordersbybib', |
| 33 |
} |
| 34 |
); |
| 35 |
my $budget = C4::Budgets::GetBudget( $budgetid ); |
| 36 |
|
31 |
|
| 37 |
my ($ordernumber1, $ordernumber2, $ordernumber3); |
32 |
my $order1 = $builder->build({ |
| 38 |
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, ''); |
33 |
source => 'Aqorder', |
| 39 |
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); |
34 |
value => { |
| 40 |
my ($biblionumber3, $biblioitemnumber3) = AddBiblio(MARC::Record->new, ''); |
35 |
quantity => 2, |
|
|
36 |
quantityreceived => 0, |
| 37 |
datecancellationprinted => undef, |
| 38 |
basketno => { |
| 39 |
closedate => undef, |
| 40 |
}, |
| 41 |
}, |
| 42 |
only_fk => 1, |
| 43 |
}); |
| 44 |
my (undef, $ordernumber1) = C4::Acquisition::NewOrder($order1); |
| 41 |
|
45 |
|
| 42 |
( undef, $ordernumber1 ) = C4::Acquisition::NewOrder( |
46 |
my $order2 = $builder->build({ |
| 43 |
{ |
47 |
source => 'Aqorder', |
| 44 |
basketno => $basketno, |
48 |
value => { |
| 45 |
quantity => 2, |
49 |
basketno => $order1->{basketno}, |
| 46 |
biblionumber => $biblionumber1, |
50 |
quantity => 4, |
| 47 |
budget_id => $budget->{budget_id}, |
51 |
quantityreceived => 0, |
| 48 |
} |
52 |
datecancellationprinted => undef, |
| 49 |
); |
53 |
}, |
|
|
54 |
only_fk => 1, |
| 55 |
}); |
| 56 |
my (undef, $ordernumber2) = C4::Acquisition::NewOrder($order2); |
| 50 |
|
57 |
|
| 51 |
( undef, $ordernumber2 ) = C4::Acquisition::NewOrder( |
58 |
my $basketno = $order1->{basketno}; |
| 52 |
{ |
59 |
my $biblionumber1 = $order1->{biblionumber}; |
| 53 |
basketno => $basketno, |
60 |
my $biblionumber2 = $order2->{biblionumber}; |
| 54 |
quantity => 4, |
61 |
my $supplierid = $order1->{_fk}->{basketno}->{booksellerid}; |
| 55 |
biblionumber => $biblionumber2, |
|
|
| 56 |
budget_id => $budget->{budget_id}, |
| 57 |
} |
| 58 |
); |
| 59 |
|
62 |
|
| 60 |
my $baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid ); |
63 |
my $baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid ); |
| 61 |
is( scalar(@$baskets), 1, 'Start: 1 basket' ); |
64 |
is( scalar(@$baskets), 1, 'Start: 1 basket' ); |
|
Lines 88-93
$baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid );
Link Here
|
| 88 |
is( scalar(@$baskets), 0, 'Basket is closed, 0 basket opened' ); |
91 |
is( scalar(@$baskets), 0, 'Basket is closed, 0 basket opened' ); |
| 89 |
$baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid, 1 ); |
92 |
$baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid, 1 ); |
| 90 |
is( scalar(@$baskets), 1, 'Basket is closed, test allbasket parameter'); |
93 |
is( scalar(@$baskets), 1, 'Basket is closed, test allbasket parameter'); |
| 91 |
|
|
|
| 92 |
|
| 93 |
$dbh->rollback |
| 94 |
- |