Bug 10541: enable cross-browser AJAX in additem.js
[koha.git] / t / db_dependent / Acquisition.t
blobc7b3c4a92782fa05d5465e1352710dbcf36c6f1f
1 #!/usr/bin/perl
3 # This Koha test module is a stub!
4 # Add more tests here!!!
6 use Modern::Perl;
7 use POSIX qw(strftime);
9 use C4::Bookseller qw( GetBookSellerFromId );
11 use Test::More tests => 41;
13 BEGIN {
14 use_ok('C4::Acquisition');
15 use_ok('C4::Bookseller');
16 use_ok('C4::Biblio');
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(
27 name => "my vendor",
28 address1 => "bookseller's address",
29 phone => "0123456",
30 active => 1,
31 deliverytime => 5,
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,
57 quantity => 24,
58 biblionumber => $biblionumber1,
59 budget_id => $budget->{budget_id},
63 ( undef, $ordernumber2 ) = C4::Acquisition::NewOrder(
65 basketno => $basketno,
66 quantity => 42,
67 biblionumber => $biblionumber2,
68 budget_id => $budget->{budget_id},
72 ( undef, $ordernumber3 ) = C4::Acquisition::NewOrder(
74 basketno => $basketno,
75 quantity => 4,
76 biblionumber => $biblionumber2,
77 budget_id => $budget->{budget_id},
78 ecost => 42,
79 rrp => 42,
83 my $grouped = 0;
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
95 biblionumber
96 invoiceid
97 budgetdate
98 cancelledby
99 closedate
100 creationdate
101 currency
102 datecancellationprinted
103 datereceived
104 ecost
105 entrydate
106 firstname
107 freight
108 gstrate
109 listprice
110 notes
111 ordernumber
112 purchaseordernumber
113 quantity
114 quantityreceived
116 sort1
117 sort2
118 subscriptionid
119 supplierreference
120 surname
121 timestamp
122 title
123 totalamount
124 unitprice );
125 my $firstorder = $orders->[0];
126 for my $field ( @expectedfields ) {
127 ok( exists( $firstorder->{ $field } ), "This order has a $field field" );
130 $dbh->rollback;