3 INSERT INTO config.upgrade_log (version) VALUES ('0167');
5 INSERT INTO action_trigger.event_definition (active, owner, name, hook, validator, reactor, cleanup_success, cleanup_failure, delay, delay_field, group_field, template) VALUES (true, 1, 'PO JEDI', 'format.po.jedi', 'NOOP_True', 'ProcessTemplate', NULL, NULL, '00:05:00', NULL, NULL,
7 [%# start JEDI document -%]
8 [%- BLOCK big_block -%]
10 "po_number":[% target.id %],
11 "date":"[% date.format(date.now, '%Y%m%d') %]",
13 {"id":"[% target.ordering_agency.mailing_address.san %]",
14 "reference":{"API":"[% target.ordering_agency.mailing_address.san %]"}}
17 "[% target.provider.san %]", // [% target.provider.name %] ([% target.provider.id %])
18 {"id-qualifier":"91", "reference":{"IA":"[% target.provider.id %]"}, "id":"[% target.provider.san %]"}
20 "currency":"[% target.provider.currency_type %]",
22 [% FOR li IN target.lineitems %]
25 {"id-qualifier":"SA","id":"[% li.id %]"},
26 {"id-qualifier":"IB","id":"[% helpers.get_li_attr('isbn', li.attributes) %]"}
28 "price":[% helpers.get_li_attr('estimated_price', '', li.attributes) %],
30 {"BTI":"[% helpers.get_li_attr('title', '', li.attributes) %]"},
31 {"BPU":"[% helpers.get_li_attr('publisher', '', li.attributes) %]"},
32 {"BPD":"[% helpers.get_li_attr('pubdate', '', li.attributes) %]"},
33 {"BPH":"[% helpers.get_li_attr('pagination','', li.attributes) %]"}
35 "quantity":[% li.lineitem_details.size %]
36 [%-# TODO: lineitem details (later) -%]
37 }[% UNLESS loop.last %],[% END -%]
40 "line_items":[% target.lineitems.size %]
43 [% tempo = PROCESS big_block; helpers.escape_json(tempo) %]
48 // API : additional party identification -- supplier’s code for library acct or dept (EAN code)
49 // IA : internal vendor number (vendor profile number)
50 // VA : VAT registered number.... TODO
53 9 = EAN - location number -- not the same as EAN-13 barcode
54 31B = US book trade SANs (Standard Address Numbers aka EDItEUR code) - TRANSLATOR DEFAULT!
55 91 = Assigned by supplier or supplier’s agent
56 92 = Assigned by buyer
58 ITEM id-qualifier (Item number type, coded):
59 EN = EAN-13 article number - 13 digit barcode
60 IB = ISBN (International Standard Book Number)
61 IM = ISMN (International Standard Music Number)
62 IS = ISSN (International Standard Serial Number): use only in a continuation order message coded 22C in BGM DE 1001, to identify the series to which the order applies
63 MF = manufacturer’s article number
64 SA = supplier’s article number
68 INSERT INTO action_trigger.environment (event_def, path) VALUES
69 ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.attributes'),
70 ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.lineitem_details'),
71 ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.lineitem_notes'),
72 ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'ordering_agency.mailing_address'),
73 ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'provider');
75 -- The environment insert has to happen here because it relies on subquerying the user-editable field "name" to
76 -- provide the FK. Outside of this tranasaction, we cannot be sure the user hasn't changed the name to something else.