li_hash.idqual = idqual;
li_hash.title = helpers.get_li_attr_edi('title', '', li.attributes);
li_hash.author = helpers.get_li_attr_edi('author', '', li.attributes);
+ li_hash.edition = helpers.get_li_attr_edi('edition', '', li.attributes);
li_hash.pubdate = helpers.get_li_attr_edi('pubdate', '', li.attributes);
+ li_hash.publisher = helpers.get_li_attr_edi('publisher', '', li.attributes);
li_hash.pagination = helpers.get_li_attr_edi('pagination','', li.attributes);
li_hash.quantity = li.lineitem_details.size;
li_hash.copies = [];
+ ftx_vals = [];
+ FOR note IN li.lineitem_notes;
+ NEXT UNLESS note.vendor_public == 't';
+ ftx_vals.push(note.value);
+ END;
+ IF VENDOR_BRODART; # look for copy-level spec code
+ FOR lid IN li.lineitem_details;
+ IF lid.note;
+ spec_note = lid.note.match('spec code ([a-zA-Z0-9_])');
+ IF spec_note.0; ftx_vals.push(spec_note.0); END;
+ END;
+ END;
+ END;
+ IF xtra_ftx; ftx_vals.unshift(xtra_ftx); END;
+
+ # BT & ULS want FTX+LIN for every LI, even if empty
+ IF ((VENDOR_BT OR VENDOR_ULS) AND ftx_vals.size == 0);
+ ftx_vals.unshift('');
+ END;
+
+ # EDI FTX fields have a max length of 512
+ notes = [];
+ FOR note IN ftx_vals;
+ sub_notes = note.chunk(512);
+ FOR sub_note IN sub_notes;
+ notes.push(helpers.escape_edi(sub_note));
+ END;
+ END;
+
+ li_hash.notes = notes;
+
IF INC_COPIES;
SEGMENT_COUNT = SEGMENT_COUNT + 1;
FOR lid IN li.lineitem_details;
DTM+137:[% date.format(date.now, '%Y%m%d') %]:102'
NAD+BY+[% BUYER_CODE %]::91'
NAD+SU+[% VENDOR_SAN %]::31B'
-NAD+SU+12::92'
+NAD+SU+[% target.provider.id %]::92'
CUX+2:[% target.provider.currency_type %]:9'
[%- FOR li_hash IN LINEITEMS -%]
LIN+[% li_hash.id %]++[% li_hash.idval %]:[% li_hash.idqual %]'
PIA+5+[% li_hash.idval %]:[% li_hash.idqual %]'
IMD+F+BTI+:::[% li_hash.title %]'
-IMD+F+BPU+:::[% li_hash.author %]'
IMD+F+BPD+:::[% li_hash.pubdate %]'
+IMD+F+BPU+:::[% li_hash.publisher %]'
+[%- IF VENDOR_ULS -%]
+IMD+F+BPU+:::[% li_hash.author %]'
+IMD+F+BEN+:::[% li_hash.edition %]'
+[%- ELSE -%]
IMD+F+BPH+:::[% li_hash.pagination %]'
+[%- END -%]
QTY+21:[% li_hash.quantity %]'
[%- GIR_INDEX = 0; -%]
[% FOR copy IN li_hash.copies;
[%- IF INC_COPY_ID AND (VENDOR_BT OR copy.copy_id);
FIELD_COUNT = FIELD_COUNT + 1 -%]
+[% copy.copy_id %]:LCO[%- END -%]
+'[%# finalize the GIR segment with a "'" -%]
[% END %] [%# FOR copies %]
-FTX+LIN+1'
+[%- FOR note IN li_hash.notes -%]
+FTX+LIN+1+[% note %]'
+[% END -%]
PRI+AAB:[% li.estimated_unit_price || "0.00" %]'
+[%- IF INC_PO_NAME -%]
+RFF+LI:[% helpers.escape_edi(target.name) %]/[% li.id %]'
+[%- ELSE -%]
RFF+LI:[% target.id %]/[% li.id %]'
+[%- END -%]
[%- END -%][%# for lineitems %]
UNS+S'
CNT+2:[% target.lineitems.size %]'
UNZ+1+1'
[% END %][%# block %]
[%
- tempo = PROCESS big_block;
- # EDI should not have newlines, but they are useful for testing.
- #tempo.remove('\n');
- tempo;
+ edi_text = PROCESS big_block;
+ #edi_text; # To test with newlines, which are easier on the eyes.
+ edi_text.remove('\n');
%]
$$
);