From a98878b1624060de2a017c690175e5c6419213ca Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Thu, 3 Nov 2016 13:43:45 -0400 Subject: [PATCH] LP#1627373 - Use EDI availibility codes if they exist. Signed-off-by: Chris Sharp --- .../perlmods/lib/OpenILS/Application/Acq/EDI.pm | 35 ++++++++++------------ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 22 ++++++++++++++ .../Pg/upgrade/XXXX.data.acq_cancel_reasons.sql | 27 +++++++++++++++++ 3 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.acq_cancel_reasons.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm index 2581ab82b0..0099c59c09 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -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) { diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index e029263de2..6c09c780b6 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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 index 0000000000..e558ae58a1 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.acq_cancel_reasons.sql @@ -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; -- 2.11.0