<field reporter:label="Provider" name="provider" reporter:datatype="link"/>
<field reporter:label="Shipper" name="shipper" reporter:datatype="link"/>
<field reporter:label="Receive Date" name="recv_date" reporter:datatype="timestamp" />
+ <field reporter:label="Receive Method" name="recv_method" reporter:datatype="link" />
<field reporter:label="Container Barcode" name="container_code" reporter:datatype="text" />
<field reporter:label="Lading Number" name="lading_number" reporter:datatype="text" />
<field reporter:label="Note" name="note" reporter:datatype="text" />
<link field="receiver" reltype="has_a" key="id" map="" class="aou"/>
<link field="provider" reltype="has_a" key="id" map="" class="acqpro"/>
<link field="shipper" reltype="has_a" key="id" map="" class="acqpro"/>
+ <link field="recv_method" reltype="has_a" key="code" map="" class="acqim"/>
<link field="entries" reltype="has_many" key="shipment_notification" map="" class="acqsne"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<field reporter:label="ID" name="id" reporter:datatype="id"/>
<field reporter:label="Shipment Notification" name="shipment_notification" reporter:datatype="link" />
<field reporter:label="Line Item" name="lineitem" reporter:datatype="link"/>
- <field reporter:label="Item Count" name="inv_item_count" reporter:datatype="int" />
+ <field reporter:label="Item Count" name="item_count" reporter:datatype="int" />
</fields>
<links>
<link field="shipment_notification" reltype="has_a" key="id" map="" class="acqinv"/>
use OpenILS::Utils::EDIReader;
use Data::Dumper;
+$Data::Dumper::Indent = 0;
our $verbose = 0;
sub new {
my ($class, $msg_data, $provider_id, $edi_message) = @_;
# $msg_data is O::U::EDIReader hash
+ $logger->info("ASN: " . Dumper($msg_data));
+
my $e = new_editor();
my $eg_asn = Fieldmapper::acq::shipment_notification->new;
from => {
jub => {
acqlia => {
- filter => {order_ident => 't', value => $ident}
+ filter => {
+ order_ident => 't',
+ attr_value => $ident
+ }
}
}
},
my $entry = Fieldmapper::acq::shipment_notification_entry->new;
$entry->lineitem($li_id);
- $entry->item_count($quant);
+ $entry->item_count($quantity);
push(@entries, $entry);
}
invoice_ident => qr/^BGM\+380\+([^\+]+)/,
total_billed => qr/^MOA\+86:([^:]+)/,
invoice_date => qr/^DTM\+137:([^:]+)/, # This is really "messge date"
- package_code => qr/^GIN\+BJ\+([^:]+)/,
+ container_code => qr/^GIN\+BJ\+([^:]+)/,
lading_number => qr/^RFF\+BM:([^:]+)/
);
use OpenILS::Application::Acq::EDI;
$Data::Dumper::Indent = 0;
-use Test::More tests => 3;
+use Test::More tests => 5;
diag("Tests EDI Shipment Notifications");
$edi_account->provider(PROVIDER_ID);
$edi_account->host("example.org");
$edi_account->label("ASN TEST");
+ $edi_account->use_attrs('f'); # doesn't matter here
BAIL_OUT("Could not create EDI account " . Dumper($e->die_event))
unless $e->create_acq_edi_account($edi_account);
$li->provider(PROVIDER_ID);
$li->estimated_unit_price('25.00');
- my $li_id = $U->simplereq('open-ils.acq',
+ $li_id = $U->simplereq('open-ils.acq',
'open-ils.acq.lineitem.create', $script->authtoken, $li);
BAIL_OUT("Failed to create Lineitem: " . Dumper($li_id)) if $U->is_event($li_id);
CPS+1'
PAC+1+5'
GIN+BJ+00016921002621109648'
-LIN+00001++9781643857701:EN'
+LIN+00001++9780307887436:EN'
QTY+12:1'
RFF+ON:$po_id'
CNT+2:1'
$edi_account
);
- # TODO test presence of shipment notification and entry
+ my $notification = $e->search_acq_shipment_notification([
+ {id => {'<>' => undef}},
+ {flesh => 1, flesh_fields => {acqsn => ['entries']}}
+ ])->[0];
+ ok($notification, 'Created a notification');
+
+ ok($notification->entries->[0]->lineitem eq $li_id,
+ "Created notification for lineitem $li_id");
}
main();
'ORDRSP',
'INVOIC',
'OSTENQ',
- 'OSTRPT'
+ 'OSTRPT',
+ 'DESADV'
))
);
CREATE INDEX edi_message_account_status_idx ON acq.edi_message (account,status);
provider INT NOT NULL REFERENCES acq.provider (id),
shipper INT NOT NULL REFERENCES acq.provider (id),
recv_date TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ recv_method TEXT NOT NULL REFERENCES acq.invoice_method (code) DEFAULT 'EDI',
container_code TEXT NOT NULL, -- vendor-supplied super-barcode
lading_number TEXT, -- informational
note TEXT,
CREATE TABLE acq.shipment_notification_entry (
id SERIAL PRIMARY KEY,
- shipment_notification INT NOT NULL REFERENCES acq.invoice (id) ON DELETE CASCADE,
- lineitem INT REFERENCES acq.lineitem (id) ON UPDATE CASCADE ON DELETE SET NULL,
+ shipment_notification INT NOT NULL REFERENCES acq.shipment_notification (id)
+ ON DELETE CASCADE,
+ lineitem INT REFERENCES acq.lineitem (id)
+ ON UPDATE CASCADE ON DELETE SET NULL,
item_count INT NOT NULL -- How many items the provider shipped
);
+/* TODO alter valid_message_type constraint */
+
+ALTER TABLE acq.edi_message DROP CONSTRAINT valid_message_type;
+ALTER TABLE acq.edi_message ADD CONSTRAINT valid_message_type
+CHECK (
+ message_type IN (
+ 'ORDERS',
+ 'ORDRSP',
+ 'INVOIC',
+ 'OSTENQ',
+ 'OSTRPT',
+ 'DESADV'
+ )
+);
+
COMMIT;
/* UNDO