LP#1373690 rearrange experiment cont. user/berick/lp1373690-acq-order-edi-exp
authorBill Erickson <berickxx@gmail.com>
Fri, 6 Nov 2015 16:26:33 +0000 (11:26 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 6 Nov 2015 16:26:33 +0000 (11:26 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/GeneratePurchaseOrderJEDI.pm
Open-ILS/src/sql/Pg/upgrade/VVVV.schema.acq-provider-edi-settings.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.data.acq-order-edi.sql

index 4a6e8cd..fe0d6a5 100644 (file)
@@ -46,8 +46,8 @@ sub munge_acq_data {
 
         # -----------------------------------------------------------
         # find the order identifier type and value
-        my $ident_attr = $helpers->get_li_order_ident($li->attributes);
         $li->{idqual} = 'EN';
+        my $ident_attr = $helpers->get_li_order_ident($li->attributes);
 
         if ($ident_attr) {
             my $idname = $ident_attr->attr_name;
@@ -66,12 +66,9 @@ sub munge_acq_data {
         # -----------------------------------------------------------
         # Common EDI "display" fields
         if ($li->attributes) {
-            $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->{$_} = 
+                $helpers->get_li_attr_edi($_, '', $li->attributes)
+                for qw/title author edition pubdate publisher pagination/;
         }
 
         next unless $li->lineitem_details;
@@ -101,7 +98,7 @@ sub munge_acq_data {
                 $copy->{location} = $acp->location->name;
             }
 
-            # see if already have a copy_groups item that matches the current copy
+            # see if we already have a copy_groups item that matches the current copy
             my ($match) = grep {
                 ($_->{fund} eq $copy->{fund} or 
                     (!$_->{fund} and !$copy->fund))
@@ -123,13 +120,13 @@ sub munge_acq_data {
             } @{$li->{copy_groups}};
 
             if ($match) {
-                # if we have a match, just increment the counter 
-                # of copies we want to order.
+                # If we have a match, just increment the counter 
+                # of copies of this type we want to order.
                 $match->{quantity}++;
 
             } else {
 
-                # a copy group with these values is not yet represented, add it.
+                # A copy group with these values is not yet represented.
                 push(@{$li->{copy_groups}}, $copy);
             }
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/VVVV.schema.acq-provider-edi-settings.sql b/Open-ILS/src/sql/Pg/upgrade/VVVV.schema.acq-provider-edi-settings.sql
new file mode 100644 (file)
index 0000000..fff8043
--- /dev/null
@@ -0,0 +1,60 @@
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('', :eg_version);
+
+-- org unit shortname mapping?
+
+CREATE TABLE acq.edi_attribute (
+    name TEXT PRIMARY KEY,
+    label TEXT UNIQUE NOT NULL
+);
+
+CREATE TABLE acq.edi_account_attr_map (
+    id SERIAL PRIMARY KEY,
+    edi_account INTEGER NOT NULL REFERENCES acq.edi_account (id),
+    attr TEXT NOT NULL REFERENCES acq.edi_attribute (name),
+    CONSTRAINT edi_attr_once_per_accout UNIQUE (edi_account, attr)
+);
+
+
+INSERT INTO acq.edi_attribute (name, label) VALUES
+    ('delivery.orders', oils_i18n_gettext(
+        'delivery.orders', 'Sends Orders', 'aea', 'label')),
+    ('delivery.ordrsp', oils_i18n_gettext(
+        'delivery.ordrsp', 'Receives Order Responses', 'aea', 'label')),
+    ('delivery.invoic', oils_i18n_gettext(
+        'delivery.invoic', 'Receives Invoices', 'aea', 'label')),
+    ('order.fields.po_name', oils_i18n_gettext(
+        'order.fields.po_name', 'Order Includes PO Name', 'aea', 'label')),
+    ('order.fields.copies', oils_i18n_gettext(
+        'order.fields.copies', 'Order Includes Copies', 'aea', 'label')),
+    ('order.fields.fund', oils_i18n_gettext(
+        'order.fields.fund', 'Order Includes Funds', 'aea', 'label')),
+    ('order.fields.call_number', oils_i18n_gettext(
+        'order.fields.call_number', 'Order Includes Call Numbers', 'aea', 'label')),
+    ('order.fields.item_type', oils_i18n_gettext(
+        'order.fields.item_type', 'Order Includes Copy Item Type', 'aea', 'label')),
+    ('order.fields.location', oils_i18n_gettext(
+        'order.fields.location', 'Order Includes Copy Location', 'aea', 'label')),
+    ('order.fields.collection_code', oils_i18n_gettext(
+        'order.fields.collection_code', 'Order Includes Copy Collection Code', 'aea', 'label')),
+    ('order.fields.owning_lib', oils_i18n_gettext(
+        'order.fields.owning_lib', 'Order Includes Copy Owning Lib', 'aea', 'label')),
+    ('order.fields.quantity', oils_i18n_gettext(
+        'order.fields.quantity', 'Order Includes Copy Quantity', 'aea', 'label')),
+    ('order.fields.copy_id', oils_i18n_gettext(
+        'order.fields.copy_id', 'Order Includes Copy ID', 'aea', 'label')),
+    ('order.fields.author', oils_i18n_gettext(
+        'order.fields.author', 'Order Includes Author', 'aea', 'label')),
+    ('order.fields.edition', oils_i18n_gettext(
+        'order.fields.edition', 'Order Includes Edition', 'aea', 'label')),
+    ('order.fields.pagination', oils_i18n_gettext(
+        'order.fields.pagination', 'Order Includes Pagination', 'aea', 'label')),
+    ('order.fields.inc_empty_ftx', oils_i18n_gettext(
+        'order.fields.inc_empty_ftx', 'Order Includes Empty FTX', 'aea', 'label')),
+    ('order.fields.inc_empty_gir', oils_i18n_gettext(
+        'order.fields.inc_empty_ftx', 'Order Includes Empty GIR', 'aea', 'label'));
+
+-- boolean fields
+ROLLBACK;
+
index 78c3208..a9c128a 100644 (file)
@@ -80,7 +80,6 @@ SEGMENT_COUNT = 13;
 
 # munge the lineitem / copy data for easier template integration
 
-LINEITEMS = [];
 FOR li_hash IN po_pre_process.lineitems;
     SEGMENT_COUNT = SEGMENT_COUNT + 10; # needs verification
 
@@ -90,9 +89,9 @@ FOR li_hash IN po_pre_process.lineitems;
         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_])');
+        FOR lid IN li_hash.all_copies;
+            IF lid.source_note;
+                spec_note = lid.source_note.match('spec code ([a-zA-Z0-9_])');
                 IF spec_note.0; ftx_vals.push(spec_note.0); END;
             END;
         END;
@@ -117,6 +116,16 @@ FOR li_hash IN po_pre_process.lineitems;
 
     li_hash.notes = notes;
 
+    # Including the copy ID implies one GIR section per copy.
+    # Otherwise, there is one GIR segement per copy group
+    IF INC_COPIES;
+        IF INC_COPY_ID;
+            li_hash.copies = li_hash.all_copies;
+        ELSE;
+            li_hash.copies = li_hash.copy_groups;
+        END;
+    END;
+
 END; # for lineitem
 
 # IMD fields are limited to 70 chars per value.  Any values longer
@@ -144,7 +153,7 @@ NAD+BY+[% BUYER_CODE %]::91'
 NAD+SU+[% VENDOR_SAN %]::31B'
 NAD+SU+[% target.provider.id %]::92'
 CUX+2:[% target.provider.currency_type %]:9'
-[%- FOR li_hash IN LINEITEMS -%]
+[%- FOR li_hash IN po_pre_process.lineitems -%]
 LIN+[% li_hash.id %]++[% li_hash.idval %]:[% li_hash.idqual %]'
 PIA+5+[% li_hash.idval %]:[% li_hash.idqual %]'
 [% IMD('BTI', li_hash.title) -%]