INSERT INTO action_trigger.environment ( event_def, path) VALUES
( 13, 'open_billable_transactions_summary.circulation' );
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, cleanup_success, cleanup_failure, delay, delay_field, group_field, template) VALUES (23, true, 1, 'PO JEDI', 'format.po.jedi', 'NOOP_True', 'ProcessTemplate', NULL, NULL, '00:05:00', NULL, NULL,
+$$[%- USE date -%]
+[%# start JEDI document -%]
+[%- BLOCK big_block -%]
+["order", {
+ "po_number":[% target.id %],
+ "date":"[% date.format(date.now, '%Y%m%d') %]",
+ "buyer":[
+ {"id":"[% target.ordering_agency.mailing_address.san %]",
+ "reference":{"API":"[% target.ordering_agency.mailing_address.san %]"}}
+ ],
+ "vendor":[
+ "[% target.provider.san %]", // [% target.provider.name %] ([% target.provider.id %])
+ {"id-qualifier":"91", "reference":{"IA":"[% target.provider.id %]"}, "id":"[% target.provider.san %]"}
+ ],
+ "currency":"[% target.provider.currency_type %]",
+ "items":[
+ [% FOR li IN target.lineitems %]
+ {
+ "identifiers":[
+ {"id-qualifier":"SA","id":"[% li.id %]"},
+ {"id-qualifier":"IB","id":"[% helpers.get_li_attr('isbn', li.attributes) %]"}
+ ],
+ "price":[% helpers.get_li_attr('estimated_price', '', li.attributes) %],
+ "desc":[
+ {"BTI":"[% helpers.get_li_attr('title', '', li.attributes) %]"},
+ {"BPU":"[% helpers.get_li_attr('publisher', '', li.attributes) %]"},
+ {"BPD":"[% helpers.get_li_attr('pubdate', '', li.attributes) %]"},
+ {"BPH":"[% helpers.get_li_attr('pagination','', li.attributes) %]"}
+ ],
+ "quantity":[% li.lineitem_details.size %]
+ [%-# TODO: lineitem details (later) -%]
+ }[% UNLESS loop.last %],[% END -%]
+ [%- END %]
+ ],
+ "line_items":[% target.lineitems.size %]
+}]
+[% END %]
+[% tempo = PROCESS big_block; helpers.escape_json(tempo) %]
+$$
+);
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+ (23, 'lineitems.attributes'),
+ (23, 'lineitems.lineitem_details'),
+ (23, 'lineitems.lineitem_notes'),
+ (23, 'ordering_agency.mailing_address'),
+ (23, 'provider'),
+ (23, 'provider.edi_default');
INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
VALUES (
INSERT INTO config.upgrade_log (version) VALUES ('0167');
-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,
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, cleanup_success, cleanup_failure, delay, delay_field, group_field, template) VALUES (23, true, 1, 'PO JEDI', 'format.po.jedi', 'NOOP_True', 'ProcessTemplate', NULL, NULL, '00:05:00', NULL, NULL,
$$[%- USE date -%]
[%# start JEDI document -%]
[%- BLOCK big_block -%]
INSERT INTO action_trigger.environment (event_def, path) VALUES
- ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.attributes'),
- ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.lineitem_details'),
- ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.lineitem_notes'),
- ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'ordering_agency.mailing_address'),
- ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'provider');
+ (23, 'lineitems.attributes'),
+ (23, 'lineitems.lineitem_details'),
+ (23, 'lineitems.lineitem_notes'),
+ (23, 'ordering_agency.mailing_address'),
+ (23, 'provider');
-- The environment insert has to happen here because it relies on subquerying the user-editable field "name" to
-- provide the FK. Outside of this transaction, we cannot be sure the user hasn't changed the name to something else.
INSERT INTO config.upgrade_log (version) VALUES ('0246');
-UPDATE action_trigger.event_definition SET template =
+UPDATE action_trigger.event_definition SET id=23, template =
$$[%- USE date -%]
[%# start JEDI document -%]
[%- BLOCK big_block -%]
[% END %]
[% tempo = PROCESS big_block; helpers.escape_json(tempo) %]
$$
-WHERE name='PO JEDI';
-
+WHERE name='PO JEDI' or id=23; -- bring updated DB in line w/ baseline DB
+ -- nobody but devs will have the old 100+ id, and only atz put it in use
INSERT INTO action_trigger.environment (event_def, path) VALUES
- ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'provider.edi_default');
+ (23, 'provider.edi_default');
-- Hope they haven't changed the name...