LP#1627373 - Use EDI availibility codes if they exist. user/csharp/lp1627373_edi_availability_codes
authorChris Sharp <csharp@georgialibraries.org>
Thu, 3 Nov 2016 17:43:45 +0000 (13:43 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 3 Nov 2016 17:43:45 +0000 (13:43 -0400)
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.acq_cancel_reasons.sql [new file with mode: 0644]

index 2581ab8..0099c59 100644 (file)
@@ -789,31 +789,26 @@ sub process_parsed_msg {
                         $reason_id = 1283; # back-order
                     }
 
-                } elsif ($stat = $li_hash->{avail_status}) {
+                } 
+                if (my $avail_stat = $li_hash->{avail_status}) {
                     $logger->info("EDI: lineitem has availability status $stat");
                     # These codes are based on documentation provided to GPLS
                     # from Brodart, who uses these codes rather than the 12B codes
                     # handled in the order_status block above.
-                    # TODO: should these be in a database table?
-                    my @backorder_statuses = (
-                        'OB', # temporarily out of stock
-                        'NP', # not yet published
-                        'NK'  # item not known
+                                       my %status_hash = (
+                        OB => 1500, # temporarily out of stock 
+                        NP => 1501, # not yet published 
+                        NK => 1502, # item not known 
+                        NN => 1503, # vendor does not supply item 
+                        RF => 1504, # refer to other publisher/distributor 
+                        PN => 1505, # publisher no longer in business 
+                        OP => 1506, # out of print 
+                        AD => 1507, # must order direct from publisher 
+                        AB => 1508, # publication abandoned 
+                        UC => 1509  # unavailable
                     );
-                    my @cancel_statuses = (
-                        'NN', # vendor does not supply item
-                        'RF', # refer to other publisher/distributor
-                        'PN', # publisher no longer in business
-                        'OP', # out of print
-                        'AD', # must order direct from publisher
-                        'AB', # publication abandoned
-                        'UC'  # unavailable
-                    );
-                    if (grep $stat, @backorder_statuses) {
-                        $reason_id = 1283; # back-order
-                    } elsif (grep $stat, @cancel_statuses) {
-                        $reason_id = 1285; # canceled by vendor
-                    }
+                                       # availabilty statuses override order statuses if available
+                                       $reason_id = $status_hash{$avail_stat} if $status_hash{$avail_stat};
                 }
 
                 if ($reason_id) {
index e029263..6c09c78 100644 (file)
@@ -11533,6 +11533,28 @@ INSERT INTO acq.cancel_reason (org_unit, keep_debits, id, label, description) VA
 (1, 'f',( 85+1200), oils_i18n_gettext(1285, 'Canceled: By Vendor', 'acqcr', 'label'),
     oils_i18n_gettext(1285, 'Line item canceled by vendor', 'acqcr', 'description'));
 
+INSERT INTO acq.cancel_reason (id, org_unit, label, description, keep_debits) VALUES
+(1500, 1, oils_i18n_gettext(1500, 'Delayed: Temporarily Out of Stock', 'acqcr', 'label'), 
+    oils_i18n_gettext(1500, 'Temporarily out of stock', 'acqcr', 'description'), 't'),
+(1501, 1, oils_i18n_gettext(1501, 'Delayed: Not Yet Published', 'acqcr', 'label'), 
+    oils_i18n_gettext(1501, 'Not Yet Published', 'acqcr', 'description'), 't'),
+(1502, 1, oils_i18n_gettext(1502, 'Delayed: Item Not Known', 'acqcr', 'label'),
+    oils_i18n_gettext(1502, 'Item Not Known', 'acqcr', 'description'), 't'),
+(1503, 1, oils_i18n_gettext(1503, 'Canceled: Item Not Supplied', 'acqcr', 'label'), 
+    oils_i18n_gettext(1503, 'Vendor does not supply item', 'acqcr', 'description'), 'f'),
+(1504, 1, oils_i18n_gettext(1504, 'Canceled: Refer to Other Publisher/Distributor', 'acqcr', 'label'),
+    oils_i18n_gettext(1504, 'Refer to other publisher/distributor', 'acqcr', 'description'), 'f'),
+(1505, 1, oils_i18n_gettext(1505, 'Canceled: Publisher Out of Business', 'acqcr', 'label'),
+    oils_i18n_gettext(1505, 'Publisher no longer in business', 'acqcr', 'description'), 'f'),
+(1506, 1, oils_i18n_gettext(1506, 'Canceled: Out of Print', 'acqcr', 'label'),
+    oils_i18n_gettext(1506, 'Out of print', 'acqcr', 'description'), 'f'),
+(1507, 1, oils_i18n_gettext(1507, 'Canceled: Order Direct', 'acqcr', 'label'),
+    oils_i18n_gettext(1507, 'Must order direct from publisher', 'acqcr', 'description'), 'f'),
+(1508, 1, oils_i18n_gettext(1508, 'Canceled: Publication Abandoned', 'acqcr', 'label'),
+    oils_i18n_gettext(1508, 'Publication abandoned', 'acqcr', 'description'), 'f'),
+(1509, 1, oils_i18n_gettext(1509, 'Canceled: Unavailable', 'acqcr', 'label'),
+    oils_i18n_gettext(1509, 'Unavailable', 'acqcr', 'description'), 'f');
+
 INSERT INTO config.global_flag (name, label, enabled)
     VALUES (
         'circ.holds.usr_not_requestor',
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.acq_cancel_reasons.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.acq_cancel_reasons.sql
new file mode 100644 (file)
index 0000000..e558ae5
--- /dev/null
@@ -0,0 +1,27 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO acq.cancel_reason (id, org_unit, label, description, keep_debits) VALUES
+       (1500, 1, oils_i18n_gettext(1500, 'Delayed: Temporarily Out of Stock', 'acqcr', 'label'),
+       oils_i18n_gettext(1500, 'Temporarily out of stock', 'acqcr', 'description'), 't'),
+       (1501, 1, oils_i18n_gettext(1501, 'Delayed: Not Yet Published', 'acqcr', 'label'),
+       oils_i18n_gettext(1501, 'Not Yet Published', 'acqcr', 'description'), 't'),
+       (1502, 1, oils_i18n_gettext(1502, 'Delayed: Item Not Known', 'acqcr', 'label'),
+       oils_i18n_gettext(1502, 'Item Not Known', 'acqcr', 'description'), 't'),
+       (1503, 1, oils_i18n_gettext(1503, 'Canceled: Item Not Supplied', 'acqcr', 'label'),
+       oils_i18n_gettext(1503, 'Vendor does not supply item', 'acqcr', 'description'), 'f'),
+       (1504, 1, oils_i18n_gettext(1504, 'Canceled: Refer to Other Publisher/Distributor', 'acqcr', 'label'),
+       oils_i18n_gettext(1504, 'Refer to other publisher/distributor', 'acqcr', 'description'), 'f'),
+       (1505, 1, oils_i18n_gettext(1505, 'Canceled: Publisher Out of Business', 'acqcr', 'label'),
+       oils_i18n_gettext(1505, 'Publisher no longer in business', 'acqcr', 'description'), 'f'),
+       (1506, 1, oils_i18n_gettext(1506, 'Canceled: Out of Print', 'acqcr', 'label'),
+       oils_i18n_gettext(1506, 'Out of print', 'acqcr', 'description'), 'f'),
+       (1507, 1, oils_i18n_gettext(1507, 'Canceled: Order Direct', 'acqcr', 'label'),
+       oils_i18n_gettext(1507, 'Must order direct from publisher', 'acqcr', 'description'), 'f'),
+       (1508, 1, oils_i18n_gettext(1508, 'Canceled: Publication Abandoned', 'acqcr', 'label'),
+       oils_i18n_gettext(1508, 'Publication abandoned', 'acqcr', 'description'), 'f'),
+       (1509, 1, oils_i18n_gettext(1509, 'Canceled: Unavailable', 'acqcr', 'label'),
+       oils_i18n_gettext(1509, 'Unavailable', 'acqcr', 'description'), 'f');
+
+COMMIT;