[open-ils-commits] r18224 - in trunk/Open-ILS/src/sql/Pg: . upgrade (atz)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Oct 7 14:48:50 EDT 2010
Author: atz
Date: 2010-10-07 14:48:45 -0400 (Thu, 07 Oct 2010)
New Revision: 18224
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0433.edi_orders_template.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
EDI template update for ORDERS
This template produces JSON for the edi translator to convert into
actual EDI lines. It now handles vendor-specific requirements for
account and sub-account identification, and also transmits notes
of the vendor-public variety as FTX segments in the lineitem.
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-10-07 17:19:45 UTC (rev 18223)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-10-07 18:48:45 UTC (rev 18224)
@@ -70,7 +70,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0432'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0433'); -- atz
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-10-07 17:19:45 UTC (rev 18223)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-10-07 18:48:45 UTC (rev 18224)
@@ -4949,9 +4949,19 @@
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', 'acqpo.activated', 'Acq::PurchaseOrderEDIRequired', 'GeneratePurchaseOrderJEDI', NULL, NULL, '00:05:00', NULL, NULL,
+ VALUES (23, true, 1, 'PO JEDI', 'acqpo.activated', 'Acq::PurchaseOrderEDIRequired', 'GeneratePurchaseOrderJEDI', NULL, NULL, '00:00:00', NULL, NULL,
$$[%- USE date -%]
-[%# start JEDI document -%]
+[%# start JEDI document
+ # Vendor specific kludges:
+ # BT - vendcode goes to NAD/BY *suffix* w/ 91 qualifier
+ # INGRAM - vendcode goes to NAD/BY *segment* w/ 91 qualifier (separately)
+ # BRODART - vendcode goes to FTX segment (lineitem level)
+-%]
+[%-
+IF target.provider.edi_default.vendcode && target.provider.code == 'BRODART';
+ xtra_ftx = target.provider.edi_default.vendcode;
+END;
+-%]
[%- BLOCK big_block -%]
{
"recipient":"[% target.provider.san %]",
@@ -4960,23 +4970,27 @@
"ORDERS":[ "order", {
"po_number":[% target.id %],
"date":"[% date.format(date.now, '%Y%m%d') %]",
- "buyer":[{
- [%- IF target.provider.edi_default.vendcode -%]
- "id":"[% target.ordering_agency.mailing_address.san _ ' ' _ target.provider.edi_default.vendcode %]",
- "id-qualifier": 91
+ "buyer":[
+ [% IF target.provider.edi_default.vendcode && (target.provider.code == 'BT' || target.provider.name.match('(?i)^BAKER & TAYLOR')) -%]
+ {"id-qualifier": 91, "id":"[% target.ordering_agency.mailing_address.san _ ' ' _ target.provider.edi_default.vendcode %]"}
+ [%- ELSIF target.provider.edi_default.vendcode && target.provider.code == 'INGRAM' -%]
+ {"id":"[% target.ordering_agency.mailing_address.san %]"},
+ {"id-qualifier": 91, "id":"[% target.provider.edi_default.vendcode %]"}
[%- ELSE -%]
- "id":"[% target.ordering_agency.mailing_address.san %]"
- [%- END -%]
- }],
- "vendor":[
+ {"id":"[% target.ordering_agency.mailing_address.san %]"}
+ [%- END -%]
+ ],
+ "vendor":[
[%- # target.provider.name (target.provider.id) -%]
"[% target.provider.san %]",
{"id-qualifier": 92, "id":"[% target.provider.id %]"}
],
"currency":"[% target.provider.currency_type %]",
+
"items":[
- [% FOR li IN target.lineitems %]
+ [%- FOR li IN target.lineitems %]
{
+ "line_index":"[% li.id %]",
"identifiers":[ [%-# li.isbns = helpers.get_li_isbns(li.attributes) %]
[% FOR isbn IN helpers.get_li_isbns(li.attributes) -%]
[% IF isbn.length == 13 -%]
@@ -4985,23 +4999,35 @@
{"id-qualifier":"IB","id":"[% isbn %]"},
[%- END %]
[% END %]
- {"id-qualifier":"SA","id":"[% li.id %]"}
+ {"id-qualifier":"IN","id":"[% li.id %]"}
],
"price":[% li.estimated_unit_price || '0.00' %],
"desc":[
- {"BTI":"[% helpers.get_li_attr('title', '', li.attributes) %]"},
+ {"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) %]"}
],
+ [%- ftx_vals = [];
+ FOR note IN li.lineitem_notes;
+ NEXT UNLESS note.vendor_public == 't';
+ ftx_vals.push(note.value);
+ END;
+ IF xtra_ftx; ftx_vals.unshift(xtra_ftx); END;
+ IF ftx_vals.size == 0; ftx_vals.unshift(''); END; # BT needs FTX+LIN for every LI, even if it is an empty one
+ -%]
+
+ "free-text":[
+ [% FOR note IN ftx_vals -%] "[% note %]"[% UNLESS loop.last %], [% END %][% END %]
+ ],
"quantity":[% li.lineitem_details.size %]
}[% UNLESS loop.last %],[% END %]
[%-# TODO: lineitem details (later) -%]
[% END %]
],
"line_items":[% target.lineitems.size %]
- }] [% # close ORDERS array %]
- }] [% # close body array %]
+ }] [%# close ORDERS array %]
+ }] [%# close body array %]
}
[% END %]
[% tempo = PROCESS big_block; helpers.escape_json(tempo) %]
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0433.edi_orders_template.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0433.edi_orders_template.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0433.edi_orders_template.sql 2010-10-07 18:48:45 UTC (rev 18224)
@@ -0,0 +1,91 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0433'); -- atz
+
+UPDATE action_trigger.event_definition SET delay='00:00:00', template=$$
+[%- USE date -%]
+[%# start JEDI document
+ # Vendor specific kludges:
+ # BT - vendcode goes to NAD/BY *suffix* w/ 91 qualifier
+ # INGRAM - vendcode goes to NAD/BY *segment* w/ 91 qualifier (separately)
+ # BRODART - vendcode goes to FTX segment (lineitem level)
+-%]
+[%-
+IF target.provider.edi_default.vendcode && target.provider.code == 'BRODART';
+ xtra_ftx = target.provider.edi_default.vendcode;
+END;
+-%]
+[%- BLOCK big_block -%]
+{
+ "recipient":"[% target.provider.san %]",
+ "sender":"[% target.ordering_agency.mailing_address.san %]",
+ "body": [{
+ "ORDERS":[ "order", {
+ "po_number":[% target.id %],
+ "date":"[% date.format(date.now, '%Y%m%d') %]",
+ "buyer":[
+ [% IF target.provider.edi_default.vendcode && (target.provider.code == 'BT' || target.provider.name.match('(?i)^BAKER & TAYLOR')) -%]
+ {"id-qualifier": 91, "id":"[% target.ordering_agency.mailing_address.san _ ' ' _ target.provider.edi_default.vendcode %]"}
+ [%- ELSIF target.provider.edi_default.vendcode && target.provider.code == 'INGRAM' -%]
+ {"id":"[% target.ordering_agency.mailing_address.san %]"},
+ {"id-qualifier": 91, "id":"[% target.provider.edi_default.vendcode %]"}
+ [%- ELSE -%]
+ {"id":"[% target.ordering_agency.mailing_address.san %]"}
+ [%- END -%]
+ ],
+ "vendor":[
+ [%- # target.provider.name (target.provider.id) -%]
+ "[% target.provider.san %]",
+ {"id-qualifier": 92, "id":"[% target.provider.id %]"}
+ ],
+ "currency":"[% target.provider.currency_type %]",
+
+ "items":[
+ [%- FOR li IN target.lineitems %]
+ {
+ "line_index":"[% li.id %]",
+ "identifiers":[ [%-# li.isbns = helpers.get_li_isbns(li.attributes) %]
+ [% FOR isbn IN helpers.get_li_isbns(li.attributes) -%]
+ [% IF isbn.length == 13 -%]
+ {"id-qualifier":"EN","id":"[% isbn %]"},
+ [% ELSE -%]
+ {"id-qualifier":"IB","id":"[% isbn %]"},
+ [%- END %]
+ [% END %]
+ {"id-qualifier":"IN","id":"[% li.id %]"}
+ ],
+ "price":[% li.estimated_unit_price || '0.00' %],
+ "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) %]"}
+ ],
+ [%- ftx_vals = [];
+ FOR note IN li.lineitem_notes;
+ NEXT UNLESS note.vendor_public == 't';
+ ftx_vals.push(note.value);
+ END;
+ IF xtra_ftx; ftx_vals.unshift(xtra_ftx); END;
+ IF ftx_vals.size == 0; ftx_vals.unshift(''); END; # BT needs FTX+LIN for every LI, even if it is an empty one
+ -%]
+
+ "free-text":[
+ [% FOR note IN ftx_vals -%] "[% note %]"[% UNLESS loop.last %], [% END %][% END %]
+ ],
+ "quantity":[% li.lineitem_details.size %]
+ }[% UNLESS loop.last %],[% END %]
+ [%-# TODO: lineitem details (later) -%]
+ [% END %]
+ ],
+ "line_items":[% target.lineitems.size %]
+ }] [%# close ORDERS array %]
+ }] [%# close body array %]
+}
+[% END %]
+[% tempo = PROCESS big_block; helpers.escape_json(tempo) %]
+
+$$
+WHERE id=23;
+
+COMMIT;
More information about the open-ils-commits
mailing list