3 # This Koha test module is a stub!
4 # Add more tests here!!!
7 use POSIX
qw(strftime);
9 use C4
::Bookseller
qw( GetBookSellerFromId );
11 use Test
::More tests
=> 41;
14 use_ok
('C4::Acquisition');
15 use_ok
('C4::Bookseller');
17 use_ok
('C4::Budgets');
18 use_ok
('C4::Bookseller');
21 my $dbh = C4
::Context
->dbh;
22 $dbh->{AutoCommit
} = 0;
23 $dbh->{RaiseError
} = 1;
25 my $booksellerid = C4
::Bookseller
::AddBookseller
(
28 address1
=> "bookseller's address",
35 my $booksellerinfo = C4
::Bookseller
::GetBookSellerFromId
( $booksellerid );
37 is
($booksellerinfo->{deliverytime
}, 5, 'set deliverytime when creating vendor (Bug 10556)');
39 my ($basket, $basketno);
40 ok
($basketno = NewBasket
($booksellerid, 1), "NewBasket( $booksellerid , 1 ) returns $basketno");
41 ok
($basket = GetBasket
($basketno), "GetBasket($basketno) returns $basket");
43 my $budgetid = C4
::Budgets
::AddBudget
(
45 budget_code
=> "budget_code_test_getordersbybib",
46 budget_name
=> "budget_name_test_getordersbybib",
49 my $budget = C4
::Budgets
::GetBudget
( $budgetid );
51 my ($ordernumber1, $ordernumber2, $ordernumber3);
52 my ($biblionumber1, $biblioitemnumber1) = AddBiblio
(MARC
::Record
->new, '');
53 my ($biblionumber2, $biblioitemnumber2) = AddBiblio
(MARC
::Record
->new, '');
54 ( undef, $ordernumber1 ) = C4
::Acquisition
::NewOrder
(
56 basketno
=> $basketno,
58 biblionumber
=> $biblionumber1,
59 budget_id
=> $budget->{budget_id
},
63 ( undef, $ordernumber2 ) = C4
::Acquisition
::NewOrder
(
65 basketno
=> $basketno,
67 biblionumber
=> $biblionumber2,
68 budget_id
=> $budget->{budget_id
},
72 ( undef, $ordernumber3 ) = C4
::Acquisition
::NewOrder
(
74 basketno
=> $basketno,
76 biblionumber
=> $biblionumber2,
77 budget_id
=> $budget->{budget_id
},
84 my $orders = GetPendingOrders
( $booksellerid, $grouped );
85 isa_ok
( $orders, 'ARRAY' );
87 C4
::Acquisition
::CloseBasket
( $basketno );
88 my @lateorders = GetLateOrders
(0);
89 my $order = $lateorders[0];
90 AddClaim
( $order->{ordernumber
} );
91 my $neworder = GetOrder
( $order->{ordernumber
} );
92 is
( $neworder->{claimed_date
}, strftime
( "%Y-%m-%d", localtime(time) ), "AddClaim : Check claimed_date" );
94 my @expectedfields = qw( basketno
102 datecancellationprinted
125 my $firstorder = $orders->[0];
126 for my $field ( @expectedfields ) {
127 ok
( exists( $firstorder->{ $field } ), "This order has a $field field" );