]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/live_t/22-acq-po-status.t
LP#1796945 Reporter cloning and creation fixes
[working/Evergreen.git] / Open-ILS / src / perlmods / live_t / 22-acq-po-status.t
1 #!perl
2 use strict; use warnings;
3 use Test::More tests => 11;
4 use OpenILS::Utils::TestUtils;
5 use OpenILS::Utils::CStoreEditor qw/:funcs/;
6 use OpenILS::Application::Acq::Order;
7
8 diag("Tests ACQ purchase orders");
9
10 my $script = OpenILS::Utils::TestUtils->new();
11 $script->bootstrap;
12
13 $script->authenticate({
14     username => 'admin',
15     password => 'demo123',
16     type => 'staff'
17 });
18
19 my $e = $script->editor(authtoken=>$script->authtoken);
20 $e->xact_begin;
21
22 ok($script->authtoken, 'Have an authtoken');
23
24 my $conn; # dummy for now
25 my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn);
26
27 my $origpo = $e->retrieve_acq_purchase_order(2);
28 is($origpo->state, 'on-order', 'order starts at expected state') or
29     BAIL_OUT('order 2 does not have expected state');
30
31 my $origli3 = $e->retrieve_acq_lineitem(3);
32 my $origli4 = $e->retrieve_acq_lineitem(4);
33 my $origli5 = $e->retrieve_acq_lineitem(5);
34
35 is($origli3->state, 'on-order', 'line item 3 starts at expected state') or
36     BAIL_OUT('line item 3 does not have expected state');
37 is($origli4->state, 'cancelled', 'line item 4 starts at expected state') or
38     BAIL_OUT('line item 4 does not have expected state');
39 is($origli5->state, 'cancelled', 'line item 5 starts at expected state') or
40     BAIL_OUT('line item 5 does not have expected state');
41 is($origli4->cancel_reason, 1283, 'line item 4 starts at expected cancel_reason') or
42     BAIL_OUT('line item 4 does not have expected cancel_reason');
43 is($origli5->cancel_reason, 1, 'line item 5 starts at expected cancel_reason') or
44     BAIL_OUT('line item 5 does not have expected cancel_reason');
45
46 my $ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2);
47 is($ret->state, 'on-order', 'order cannot be received (yet)');
48
49 OpenILS::Application::Acq::Order::receive_lineitem($mgr, 3, 1);
50 my $li = $e->retrieve_acq_lineitem(3);
51 is($li->state, 'received', 'line item 3 received');
52
53 $ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2);
54 is($ret->state, 'on-order', 'order still cannot be received');
55
56 $li = $e->retrieve_acq_lineitem(4);
57 $li->cancel_reason(2); # this one has keep_debits = false, i.e., we don't expect
58                        # this one to ever show up
59 $e->update_acq_lineitem($li);
60
61 $ret = OpenILS::Application::Acq::Order::check_purchase_order_received($mgr, 2);
62 is($ret->state, 'received', 'LP#1257915: order now received');
63
64 $e->rollback;