Line 0
Link Here
|
|
|
1 |
use Modern::Perl; |
2 |
|
3 |
use Test::More tests => 10; |
4 |
use Data::Dumper; |
5 |
|
6 |
use_ok('C4::Serials'); |
7 |
use_ok('C4::Budgets'); |
8 |
use_ok('C4::Acquisition'); |
9 |
my $supplierlist=eval{GetSuppliersWithLateIssues()}; |
10 |
ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues"); |
11 |
|
12 |
my $biblionumber = 1; |
13 |
my $budgetid; |
14 |
my $bpid = AddBudgetPeriod({ |
15 |
budget_period_startdate => '01-01-2015', |
16 |
budget_period_enddate => '31-12-2015', |
17 |
budget_description => "budget desc" |
18 |
}); |
19 |
|
20 |
my $budget_id = AddBudget({ |
21 |
budget_code => "ABCD", |
22 |
budget_amount => "123.132", |
23 |
budget_name => "Périodiques", |
24 |
budget_notes => "This is a note", |
25 |
budget_description => "Serials", |
26 |
budget_active => 1, |
27 |
budget_period_id => $bpid |
28 |
}); |
29 |
|
30 |
my $subscriptionid = NewSubscription( |
31 |
undef, "", undef, undef, $budget_id, $biblionumber, '01-01-2013',undef, |
32 |
undef, undef, undef, undef, undef, undef, undef, undef, |
33 |
undef, undef, undef, undef, undef, undef, undef, undef, |
34 |
undef, undef, undef, undef, undef, undef, undef, 1, |
35 |
"notes", undef, undef, undef, undef, undef, undef, 0, |
36 |
"intnotes", 0, undef, undef, 0, undef, '31-12-2013', |
37 |
); |
38 |
die unless $subscriptionid; |
39 |
my $cost = 42.00; |
40 |
my $subscription = GetSubscription( $subscriptionid ); |
41 |
my ( $basketno, $ordernumber ) = NewOrder({ |
42 |
biblionumber => $subscription->{biblionumber}, |
43 |
entrydate => '01-01-2013', |
44 |
quantity => 1, |
45 |
currency => 'USD', |
46 |
listprice => $cost, |
47 |
notes => "This is a note", |
48 |
basketno => 1, |
49 |
rrp => $cost, |
50 |
ecost => $cost, |
51 |
gstrate => 0.0500, |
52 |
orderstatus => 0, |
53 |
subscriptionid => $subscription->{subscriptionid}, |
54 |
budget_id => $budget_id, |
55 |
}); |
56 |
|
57 |
my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} ); |
58 |
is ( $is_currently_on_order, 1, "The subscription is currently on order"); |
59 |
|
60 |
my $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} ); |
61 |
is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received"); |
62 |
ok( $order->{ecost} == $cost, "test cost for the last order not received"); |
63 |
|
64 |
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder( |
65 |
$biblionumber, $ordernumber, 1, undef, $cost, $cost, |
66 |
undef, $cost, $budget_id, '02-01-2013', undef); |
67 |
|
68 |
$order = GetLastOrderReceivedFromSubscriptionid( $subscription->{subscriptionid} ); |
69 |
is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order received"); |
70 |
ok( $order->{ecost} == $cost, "test cost for the last order received"); |
71 |
|
72 |
$order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} ); |
73 |
is ( $order, undef, "test no not received order for a received order"); |
74 |
|
75 |
# cleaning |
76 |
DelSubscription( $subscription->{subscriptionid} ); |
77 |
DelOrder( $subscription->{biblionumber}, $ordernumber ); |
78 |
DelBudgetPeriod($bpid); |
79 |
DelBudget($budget_id); |
80 |
|