From: Bill Erickson Date: Mon, 4 Jan 2016 16:20:27 +0000 (-0500) Subject: LP#1380709 Perl live test X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=136b6b146483ecaa00b846eadcbc9383a28c2e9e;p=evergreen%2Fpines.git LP#1380709 Perl live test Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- 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 index 0000000000..1df01fa40c --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/12-acq-invoicing.t @@ -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'); +