From: Bill Erickson Date: Mon, 6 Dec 2021 16:01:23 +0000 (-0500) Subject: LP1952931 ASN shipment notifiation Perl Test X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=329b60426b3d2fc0edc00c1b2f19320e2ab479ba;p=working%2FEvergreen.git LP1952931 ASN shipment notifiation Perl Test Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t b/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t index 19109f7a06..d5e246a22a 100755 --- a/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t +++ b/Open-ILS/src/perlmods/live_t/35-acq-asn-edi.t @@ -10,8 +10,14 @@ diag("Tests EDI Shipment Notifications"); use constant { BR1_ID => 4, - BIB_ID => 248, + BR1_ADDR_ID => 4, + BR1_SAN => 1234567, + PROVIDER_SAN => 7654321, PROVIDER_ID => 2, + BIB_ID => 248, + LOCATION_ID => 1, + FUND_ID => 1, + ADMIN_ID => 1, ADMIN_USER => 'admin', ADMIN_PASS => 'demo123' }; @@ -31,18 +37,99 @@ $script->authenticate({ BAIL_OUT('Failed to Login') unless $script->authtoken; +sub main { + create_seed_data(); + process_asn(create_po()); +} -sub create_po { + +sub create_seed_data { + + my $addr = $e->retrieve_actor_org_address(BR1_ADDR_ID); + $addr->san(BR1_SAN); + + BAIL_OUT("Could not apply SAN to BR1 " . $e->die_event) + unless $e->update_actor_org_address($addr); - my $li = Fieldmapper::acq::lineitem->new; - $li->eg_bib_id(BIB_ID); - $li->marc(' a 9780307887436'); - $li-> + my $acct = Fieldmapper::acq::edi_account->new; + $acct->provider(PROVIDER_ID); + $acct->host("example.org"); + $acct->label("ASN TEST"); + + BAIL_OUT("Could not create EDI account " . $e->die_event) + unless $e->create_acq_edi_account($acct); +} + +sub create_po { my $po = Fieldmapper::acq::purchase_order->new; $po->ordering_agency(BR1_ID); $po->provider(PROVIDER_ID); $po->name("ASN-Test"); + + my $resp = $U->simplereq('open-ils.acq', + 'open-ils.acq.purchase_order.create', $script->authtoken, $po); + + BAIL_OUT("Failed to create PO: $resp") if $U->is_event($resp); + + my $li = Fieldmapper::acq::lineitem->new; + $li->purchase_order($resp->purchase_order->id); + $li->eg_bib_id(BIB_ID); + $li->marc(' a 9780307887436'); + $li->creator(ADMIN_ID); + $li->editor(ADMIN_ID); + $li->selector(ADMIN_ID); + $li->provider(PROVIDER_ID); + $li->estimated_unit_price('25.00'); + + my $li_id = $U->simplereq('open-ils.acq', + 'open-ils.acq.lineitem.create', $script->authtoken, $li); + + BAIL_OUT("Failed to create Lineitem: $li_id") if $U->is_event($li_id); + + my $lid = Fieldmapper::acq::lineitem_detail->new; + $lid->lineitem($lid); + $lid->fund(FUND_ID); + $lid->owning_lib(BR1_ID); + $lid->location(LOCATION_ID); + + $resp = $U->simplereq('open-ils.acq', + 'open-ils.acq.lineitem_detail.cud.batch', $script->authtoken, $lid); + + BAIL_OUT("Failed to create Lineitem Detail: $resp") if $U->is_event($resp); + + return $$resp->purchase_order->id; +} + +sub process_asn { + my $po_id = shift; + + my $ASN = <