LP#1380709 Perl live test
authorBill Erickson <berickxx@gmail.com>
Mon, 4 Jan 2016 16:20:27 +0000 (11:20 -0500)
committerKathy Lussier <klussier@masslnc.org>
Thu, 18 Feb 2016 16:47:32 +0000 (11:47 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/perlmods/live_t/12-acq-invoicing.t [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/live_t/12-acq-invoicing.t b/Open-ILS/src/perlmods/live_t/12-acq-invoicing.t
new file mode 100644 (file)
index 0000000..1df01fa
--- /dev/null
@@ -0,0 +1,67 @@
+#!perl
+use strict; use warnings;
+use Test::More tests => 4;
+use OpenILS::Utils::TestUtils;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+
+diag("Tests ACQ invoices");
+
+my $script = OpenILS::Utils::TestUtils->new();
+$script->bootstrap;
+
+my $e = new_editor();
+$e->init;
+
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff'
+});
+
+ok($script->authtoken, 'Have an authtoken');
+
+my $invoice = Fieldmapper::acq::invoice->new;
+$invoice->isnew(1);
+$invoice->receiver(1);
+$invoice->provider(1);
+$invoice->shipper(1);
+$invoice->inv_ident(rand());
+$invoice->complete('f');
+
+my $entry = Fieldmapper::acq::invoice_entry->new;
+$entry->isnew(1);
+$entry->lineitem(3);
+$entry->purchase_order(2);
+$entry->inv_item_count(1);
+$entry->phys_item_count(1);
+$entry->cost_billed('25.00');
+$entry->actual_cost('25.00');
+$entry->amount_paid('25.00');
+
+my $acq_ses = $script->session('open-ils.acq');
+
+my $req = $acq_ses->request(
+    'open-ils.acq.invoice.update', $script->authtoken, $invoice, [$entry]);
+
+$invoice = $req->recv->content;
+
+is(ref $invoice, 'Fieldmapper::acq::invoice', 'Invoice created');
+
+# Close the invoice.  LP#1333254. 
+$invoice->complete('t');
+$invoice->ischanged(1);
+
+$req = $acq_ses->request(
+    'open-ils.acq.invoice.update', $script->authtoken, $invoice);
+
+$invoice = $req->recv->content;
+
+is($invoice->complete, 't', 'Invoice is closed');
+
+$entry = $invoice->entries->[0];
+my $debits = $e->search_acq_fund_debit({id => [1,2]});
+my @matching = grep { ($_->invoice_entry || '') eq $entry->id } @$debits;
+
+isnt(scalar(@matching), 0, 
+    'At least one fund_debit should link to new invoice entry');
+