3 use Test::More tests => 13;
6 use_ok('C4::Acquisition');
12 my $dbh = C4::Context->dbh;
13 $dbh->{AutoCommit} = 0;
14 $dbh->{RaiseError} = 1;
16 my $supplierlist=eval{GetSuppliersWithLateIssues()};
17 ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues");
19 my $booksellerid = C4::Bookseller::AddBookseller(
22 address1 => "bookseller's address",
28 my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
30 my $bpid = AddBudgetPeriod({
31 budget_period_startdate => '01-01-2015',
32 budget_period_enddate => '12-31-2015',
33 budget_period_description => "budget desc"
36 my $budget_id = AddBudget({
37 budget_code => "ABCD",
38 budget_amount => "123.132",
39 budget_name => "Périodiques",
40 budget_notes => "This is a note",
41 budget_period_id => $bpid
44 my $subscriptionid = NewSubscription(
45 undef, "", undef, undef, $budget_id, $biblionumber,
46 '01-01-2013',undef, undef, undef, undef,
47 undef, undef, undef, undef, undef, undef,
48 1, "notes",undef, '01-01-2013', undef, undef,
49 undef, undef, 0, "intnotes", 0,
50 undef, undef, 0, undef, '31-12-2013', 0
52 die unless $subscriptionid;
54 my ($basket, $basketno);
55 ok($basketno = NewBasket($booksellerid, 1), "NewBasket( $booksellerid , 1 ) returns $basketno");
58 my $subscription = GetSubscription( $subscriptionid );
60 $ordernumber = NewOrder({
61 biblionumber => $subscription->{biblionumber},
62 entrydate => '01-01-2013',
66 notes => "This is a note",
67 basketno => $basketno,
72 subscriptionid => $subscription->{subscriptionid},
73 budget_id => $budget_id,
76 my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} );
77 is ( $is_currently_on_order, 1, "The subscription is currently on order");
79 my $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
80 is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received");
81 ok( $order->{ecost} == $cost, "test cost for the last order not received");
83 $dbh->do(q{DELETE FROM aqinvoices});
84 my $invoiceid = AddInvoice(invoicenumber => 'invoice1', booksellerid => $booksellerid, unknown => "unknown");
86 my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
88 biblionumber => $biblionumber,
89 ordernumber => $ordernumber,
90 quantityreceived => 1,
94 budget_id => $budget_id,
95 datereceived => '02-01-2013',
96 invoiceid => $invoiceid,
100 $order = GetLastOrderReceivedFromSubscriptionid( $subscription->{subscriptionid} );
101 is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order received");
102 ok( $order->{ecost} == $cost, "test cost for the last order received");
104 $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
105 is ( $order, undef, "test no not received order for a received order");
107 my @invoices = GetInvoices();
108 my @invoices_linked_to_subscriptions = grep { $_->{is_linked_to_subscriptions} } @invoices;
109 is(scalar(@invoices_linked_to_subscriptions), 1, 'GetInvoices() can identify invoices that are linked to a subscription');