Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
|
5 |
use Test::More; |
6 |
use C4::Acquisition; |
7 |
use C4::Biblio; |
8 |
use C4::Items; |
9 |
use C4::Bookseller; |
10 |
use C4::Budgets; |
11 |
use MARC::Record; |
12 |
|
13 |
my $booksellerid1 = C4::Bookseller::AddBookseller( |
14 |
{ |
15 |
name => "my vendor 1", |
16 |
address1 => "bookseller's address", |
17 |
phone => "0123456", |
18 |
active => 1 |
19 |
} |
20 |
); |
21 |
|
22 |
my $basketno1 = C4::Acquisition::NewBasket( |
23 |
$booksellerid1 |
24 |
); |
25 |
|
26 |
my $booksellerid2 = C4::Bookseller::AddBookseller( |
27 |
{ |
28 |
name => "my vendor 2", |
29 |
address1 => "bookseller's address", |
30 |
phone => "0123456", |
31 |
active => 1 |
32 |
} |
33 |
); |
34 |
|
35 |
my $basketno2 = C4::Acquisition::NewBasket( |
36 |
$booksellerid2 |
37 |
); |
38 |
|
39 |
my $budgetid = C4::Budgets::AddBudget( |
40 |
{ |
41 |
budget_code => "budget_code_test_transferorder", |
42 |
budget_name => "budget_name_test_transferorder", |
43 |
} |
44 |
); |
45 |
|
46 |
my $budget = C4::Budgets::GetBudget( $budgetid ); |
47 |
|
48 |
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, ''); |
49 |
my $itemnumber = AddItem({}, $biblionumber); |
50 |
|
51 |
my ( undef, $ordernumber ) = C4::Acquisition::NewOrder( |
52 |
{ |
53 |
basketno => $basketno1, |
54 |
quantity => 24, |
55 |
biblionumber => $biblionumber, |
56 |
budget_id => $budget->{budget_id}, |
57 |
} |
58 |
); |
59 |
NewOrderItem($itemnumber, $ordernumber); |
60 |
|
61 |
# Begin tests |
62 |
my $order; |
63 |
is(scalar GetOrders($basketno1), 1, "1 order in basket1"); |
64 |
($order) = GetOrders($basketno1); |
65 |
is(scalar GetItemnumbersFromOrder($order->{ordernumber}), 1, "1 item in basket1's order"); |
66 |
is(scalar GetOrders($basketno2), 0, "0 order in basket2"); |
67 |
|
68 |
diag("Transfering order to basket2"); |
69 |
my $newordernumber = TransferOrder($ordernumber, $basketno2); |
70 |
is(scalar GetOrders($basketno1), 0, "0 order in basket1"); |
71 |
is(scalar GetOrders($basketno2), 1, "1 order in basket2"); |
72 |
($order) = GetOrders($basketno2); |
73 |
is(scalar GetItemnumbersFromOrder($order->{ordernumber}), 1, "1 item in basket2's order"); |
74 |
|
75 |
END { |
76 |
C4::Acquisition::DelOrder( $biblionumber, $ordernumber ); |
77 |
C4::Acquisition::DelOrder( $biblionumber, $newordernumber ); |
78 |
C4::Budgets::DelBudget( $budgetid ); |
79 |
C4::Acquisition::DelBasket( $basketno1 ); |
80 |
C4::Bookseller::DelBookseller( $booksellerid1 ); |
81 |
C4::Acquisition::DelBasket( $basketno2 ); |
82 |
C4::Bookseller::DelBookseller( $booksellerid2 ); |
83 |
C4::Biblio::DelBiblio($biblionumber); |
84 |
}; |
85 |
|
86 |
done_testing; |