use OpenILS::Utils::TestUtils;
use OpenILS::Utils::CStoreEditor (':funcs');
use OpenILS::Utils::Fieldmapper;
+use OpenILS::Application::Acq::EDI;
use Test::More tests => 5;
ADMIN_PASS => 'demo123'
};
+# Stub MARC with an ISBN as an order identifier
+my $LI_MARC = <<MARC;
+<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.loc.gov/MARC21/slim
+ http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
+ xmlns="http://www.loc.gov/MARC21/slim">
+ <leader> a </leader>
+ <datafield tag="020" ind1=" " ind2=" ">
+ <subfield code="a">9780307887436</subfield>
+ </datafield>
+</record>
+MARC
+
my $U = 'OpenILS::Application::AppUtils';
my $script = OpenILS::Utils::TestUtils->new();
$script->bootstrap;
+my $po_id;
+my $li_id;
+my $edi_account;
my $e = new_editor;
$e->init;
BAIL_OUT('Failed to Login') unless $script->authtoken;
sub main {
+ $e->xact_begin;
create_seed_data();
- process_asn(create_po());
+ create_po();
+ BAIL_OUT("Failed to commit transaction") unless $e->commit;
+ process_asn();
}
BAIL_OUT("Could not apply SAN to BR1 " . $e->die_event)
unless $e->update_actor_org_address($addr);
- my $acct = Fieldmapper::acq::edi_account->new;
- $acct->provider(PROVIDER_ID);
- $acct->host("example.org");
- $acct->label("ASN TEST");
+ $edi_account = Fieldmapper::acq::edi_account->new;
+ $edi_account->provider(PROVIDER_ID);
+ $edi_account->host("example.org");
+ $edi_account->label("ASN TEST");
BAIL_OUT("Could not create EDI account " . $e->die_event)
- unless $e->create_acq_edi_account($acct);
+ unless $e->create_acq_edi_account($edi_account);
}
sub create_po {
'open-ils.acq.purchase_order.create', $script->authtoken, $po);
BAIL_OUT("Failed to create PO: $resp") if $U->is_event($resp);
+
+ $po_id = $resp->purchase_order->id;
my $li = Fieldmapper::acq::lineitem->new;
- $li->purchase_order($resp->purchase_order->id);
+ $li->purchase_order($po_id);
$li->eg_bib_id(BIB_ID);
- $li->marc('<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"><leader> a </leader><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9780307887436</subfield></record>');
+ $li->marc($LI_MARC);
$li->creator(ADMIN_ID);
$li->editor(ADMIN_ID);
$li->selector(ADMIN_ID);
BAIL_OUT("Failed to create Lineitem Detail: $resp") if $U->is_event($resp);
- return $$resp->purchase_order->id;
+ my $attr = $e->search_acq_lineitem_marc_attr_definition({
+ lineitem => $li_id, attr_name => 'isbn'})->[0];
+
+ BAIL_OUT("Lineitem creation did not create an ISBN attribute")
+ unless $attr;
+
+ $attr->order_ident('t');
+
+ BAIL_OUT("Failed apply order_ident to ISBN attr: " . $e->die_event)
+ unless $e->update_acq_lineitem_marc_attr_definition($attr);
}
sub process_asn {
- my $po_id = shift;
my $ASN = <<ASN;
- UNA:+.?
- UNB+UNOC:3+7654321:31B+1234567:31B+211130:0825+99
- UNG+DESADV+7654321:31B+1234567:31B+211130:0825+94+UN+D:96A:UN
- UNH+193+DESADV:D:96A:UN
- BGM+351+MOM9681366+9
- DTM+137:20211130:102
- DTM+11:20211130:102
- DTM+132:20211207:102
- RFF+BM:2036362399
- NAD+SU+7654321::9
- NAD+BY+1234567 0011::9
- NAD+DP+1234567 0011::9
- CPS+1
- PAC+1+5
- GIN+BJ+00016921002621109648
- LIN+00001++9781643857701:EN
- QTY+12:1
- RFF+ON:$po_id
- CNT+2:1
- UNT+17+193
- UNE+1+94
- UNZ+1+99
+UNA:+.?'
+UNB+UNOC:3+7654321:31B+1234567:31B+211130:0825+99'
+UNG+DESADV+7654321:31B+1234567:31B+211130:0825+94+UN+D:96A:UN'
+UNH+193+DESADV:D:96A:UN'
+BGM+351+MOM9681366+9'
+DTM+137:20211130:102'
+DTM+11:20211130:102'
+DTM+132:20211207:102'
+RFF+BM:2036362399'
+NAD+SU+7654321::9'
+NAD+BY+1234567 0011::9'
+NAD+DP+1234567 0011::9'
+CPS+1'
+PAC+1+5'
+GIN+BJ+00016921002621109648'
+LIN+00001++9781643857701:EN'
+QTY+12:1'
+RFF+ON:$po_id'
+CNT+2:1'
+UNT+17+193'
+UNE+1+94'
+UNZ+1+99'
ASN
+ my $in = OpenILS::Application::Acq::EDI->process_retrieval(
+ $ASN, "remote-file-name",
+ OpenILS::Application::Acq::EDI->remote_account($edi_account),
+ $edi_acctount
+ );
+
+ # TODO test presence of shipment notification and entry
+
}
main();