From 1485d56bafa63b42536be1789c3f46b9a345e125 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 3 Jun 2014 10:55:12 -0400 Subject: [PATCH] LP#1270289 Show delay/cancel reason print PO / worksheets Display the cancel reason label in the print PO and lineitem worksheets. Note: this only applies to templates which have not been locally modified. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier Signed-off-by: Ben Shum --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 10 + .../upgrade/XXXY.data.acq-cancel-display.sql | 455 +++++++++++++++++- 2 files changed, 460 insertions(+), 5 deletions(-) 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 2343fce842..41c93b8892 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -7242,6 +7242,7 @@ date [% date.format(date.now, '%Y%m%d') %] Quantity Unit Price Line Total + Delayed / Canceled Notes @@ -7265,6 +7266,7 @@ date [% date.format(date.now, '%Y%m%d') %] [% count %] [% price %] [% litotal %] + [% li.cancel_reason.label %]
    [% FOR note IN li.lineitem_notes %] @@ -7297,6 +7299,7 @@ INSERT INTO action_trigger.environment (event_def, path) VALUES (4, 'ordering_agency.billing_address'), (4, 'provider.addresses'), (4, 'lineitems.attributes'), + (4, 'lineitems.cancel_reason'), (4, 'lineitems.lineitem_notes'), (4, 'notes'); @@ -8602,6 +8605,9 @@ $$
    Item Count: [% li.lineitem_details.size %]
    Lineitem ID: [% li.id %]
    Open Holds: [% helpers.bre_open_hold_count(li.eg_bib_id) %]
    + [% IF li.cancel_reason.label %] +
    [% li.cancel_reason.label %]
    + [% END %] [% IF li.distribution_formulas.size > 0 %] [% SET forms = [] %] @@ -8638,6 +8644,7 @@ $$ Shelving Location Recd. Notes + Delayed / Canceled @@ -8665,6 +8672,7 @@ $$ [% copy.location.name %] [% IF detail.recv_time %][% detail.recv_time %][% END %] [% detail.note %] + [% detail.cancel_reason.label %] [% END %] @@ -8676,10 +8684,12 @@ $$ INSERT INTO action_trigger.environment (event_def, path) VALUES ( 14, 'attributes' ), + ( 14, 'cancel_reason' ), ( 14, 'lineitem_notes' ), ( 14, 'lineitem_notes.alert_text' ), ( 14, 'distribution_formulas.formula' ), ( 14, 'lineitem_details' ), + ( 14, 'lineitem_details.cancel_reason' ), ( 14, 'lineitem_details.owning_lib' ), ( 14, 'lineitem_details.fund' ), ( 14, 'lineitem_details.location' ), diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXY.data.acq-cancel-display.sql b/Open-ILS/src/sql/Pg/upgrade/XXXY.data.acq-cancel-display.sql index 153602b2bf..c32cb844b6 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXY.data.acq-cancel-display.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXY.data.acq-cancel-display.sql @@ -41,23 +41,468 @@ UPDATE acq.cancel_reason WHERE id = 1010 AND label = 'Not found'; UPDATE acq.cancel_reason - SET label = oils_i18n_gettext(1,'Delayed : Accepted with amendment', 'acqcr', 'label') + SET label = oils_i18n_gettext(1,'Delayed: Accepted with amendment', 'acqcr', 'label') WHERE id = 1024 AND label = 'Accepted with amendment, no confirmation required'; UPDATE acq.cancel_reason - SET label = oils_i18n_gettext(1,'Delayed : Split Quantity', 'acqcr', 'label') + SET label = oils_i18n_gettext(1,'Delayed: Split Quantity', 'acqcr', 'label') WHERE id = 1211 AND label = 'Split quantity'; UPDATE acq.cancel_reason - SET label = oils_i18n_gettext(1,'Delayed : Ordered Quantity', 'acqcr', 'label') + SET label = oils_i18n_gettext(1,'Delayed: Ordered Quantity', 'acqcr', 'label') WHERE id = 1221 AND label = 'Ordered quantity'; UPDATE acq.cancel_reason - SET label = oils_i18n_gettext(1,'Delayed : Pieces Delivered', 'acqcr', 'label') + SET label = oils_i18n_gettext(1,'Delayed: Pieces Delivered', 'acqcr', 'label') WHERE id = 1246 AND label = 'Pieces delivered'; UPDATE acq.cancel_reason - SET label = oils_i18n_gettext(1,'Delayed : Backorder', 'acqcr', 'label') + SET label = oils_i18n_gettext(1,'Delayed: Backorder', 'acqcr', 'label') WHERE id = 1283 AND label = 'Backorder quantity'; +-- action/trigger additions +-- All following changes are only applied where the source data matches +-- the stock data. IOW, if a template has been locally modified, +-- it's left unchanged. + +DO $$ +BEGIN + -- avoid collisions by testing for the presence of the + -- desired environment addition. + + PERFORM 1 FROM action_trigger.environment + WHERE event_def = 4 AND path = 'lineitems.cancel_reason'; + IF NOT FOUND THEN + INSERT INTO action_trigger.environment (event_def, path) + VALUES (4, 'lineitems.cancel_reason'); + END IF; + + PERFORM 1 FROM action_trigger.environment + WHERE event_def = 14 AND path = 'cancel_reason'; + IF NOT FOUND THEN + INSERT INTO action_trigger.environment (event_def, path) + VALUES ( 14, 'cancel_reason' ); + END IF; + + PERFORM 1 FROM action_trigger.environment + WHERE event_def = 14 AND path = 'lineitem_details.cancel_reason'; + IF NOT FOUND THEN + INSERT INTO action_trigger.environment (event_def, path) + VALUES ( 14, 'lineitem_details.cancel_reason' ); + END IF; +END $$; + +UPDATE action_trigger.event_definition SET template = +$$ +[%- USE date -%] +[%- + # find a lineitem attribute by name and optional type + BLOCK get_li_attr; + FOR attr IN li.attributes; + IF attr.attr_name == attr_name; + IF !attr_type OR attr_type == attr.attr_type; + attr.attr_value; + LAST; + END; + END; + END; + END +-%] + +

    Purchase Order: [% target.name %] ([% target.id %])

    +
    +date [% date.format(date.now, '%Y%m%d') %] +
    + + + + + + + + + +
    Vendor +
    [% target.provider.name %]
    +
    [% target.provider.addresses.0.street1 %]
    +
    [% target.provider.addresses.0.street2 %]
    +
    [% target.provider.addresses.0.city %]
    +
    [% target.provider.addresses.0.state %]
    +
    [% target.provider.addresses.0.country %]
    +
    [% target.provider.addresses.0.post_code %]
    +
    Ship to / Bill to +
    [% target.ordering_agency.name %]
    +
    [% target.ordering_agency.billing_address.street1 %]
    +
    [% target.ordering_agency.billing_address.street2 %]
    +
    [% target.ordering_agency.billing_address.city %]
    +
    [% target.ordering_agency.billing_address.state %]
    +
    [% target.ordering_agency.billing_address.country %]
    +
    [% target.ordering_agency.billing_address.post_code %]
    +
    + +

    +
    + Notes to the Vendor +
      + [% FOR note IN target.notes %] + [% IF note.vendor_public == 't' %] +
    • [% note.value %]
    • + [% END %] + [% END %] +
    +
    +

    + + + + + + + + + + + + + + + + + [% subtotal = 0 %] + [% FOR li IN target.lineitems %] + + + [% count = li.lineitem_details.size %] + [% price = li.estimated_unit_price %] + [% litotal = (price * count) %] + [% subtotal = subtotal + litotal %] + [% + ident_attr = helpers.get_li_order_ident(li.attributes); + SET ident_value = ident_attr.attr_value IF ident_attr; + %] + + + + + + + + + + [% END %] + + + + + +
    PO#ISBN or Item #TitleQuantityUnit PriceLine TotalDelayed / CanceledNotes
    [% target.id %][% ident_value %][% PROCESS get_li_attr attr_name = 'title' %][% count %][% price %][% litotal %][% li.cancel_reason.label %] +
      + [% FOR note IN li.lineitem_notes %] + [% IF note.vendor_public == 't' %] +
    • [% note.value %]
    • + [% END %] + [% END %] +
    +
    + Subtotal[% subtotal %]
    + +
    + +Total Line Item Count: [% target.lineitems.size %] +$$ +WHERE id = 4 AND template = +$$ +[%- USE date -%] +[%- + # find a lineitem attribute by name and optional type + BLOCK get_li_attr; + FOR attr IN li.attributes; + IF attr.attr_name == attr_name; + IF !attr_type OR attr_type == attr.attr_type; + attr.attr_value; + LAST; + END; + END; + END; + END +-%] + +

    Purchase Order: [% target.name %] ([% target.id %])

    +
    +date [% date.format(date.now, '%Y%m%d') %] +
    + + + + + + + + + +
    Vendor +
    [% target.provider.name %]
    +
    [% target.provider.addresses.0.street1 %]
    +
    [% target.provider.addresses.0.street2 %]
    +
    [% target.provider.addresses.0.city %]
    +
    [% target.provider.addresses.0.state %]
    +
    [% target.provider.addresses.0.country %]
    +
    [% target.provider.addresses.0.post_code %]
    +
    Ship to / Bill to +
    [% target.ordering_agency.name %]
    +
    [% target.ordering_agency.billing_address.street1 %]
    +
    [% target.ordering_agency.billing_address.street2 %]
    +
    [% target.ordering_agency.billing_address.city %]
    +
    [% target.ordering_agency.billing_address.state %]
    +
    [% target.ordering_agency.billing_address.country %]
    +
    [% target.ordering_agency.billing_address.post_code %]
    +
    + +

    +
    + Notes to the Vendor +
      + [% FOR note IN target.notes %] + [% IF note.vendor_public == 't' %] +
    • [% note.value %]
    • + [% END %] + [% END %] +
    +
    +

    + + + + + + + + + + + + + + + + [% subtotal = 0 %] + [% FOR li IN target.lineitems %] + + + [% count = li.lineitem_details.size %] + [% price = li.estimated_unit_price %] + [% litotal = (price * count) %] + [% subtotal = subtotal + litotal %] + [% + ident_attr = helpers.get_li_order_ident(li.attributes); + SET ident_value = ident_attr.attr_value IF ident_attr; + %] + + + + + + + + + [% END %] + + + + + +
    PO#ISBN or Item #TitleQuantityUnit PriceLine TotalNotes
    [% target.id %][% ident_value %][% PROCESS get_li_attr attr_name = 'title' %][% count %][% price %][% litotal %] +
      + [% FOR note IN li.lineitem_notes %] + [% IF note.vendor_public == 't' %] +
    • [% note.value %]
    • + [% END %] + [% END %] +
    +
    + Subtotal[% subtotal %]
    + +
    + +Total Line Item Count: [% target.lineitems.size %] +$$; + +-- lineitem worksheet +UPDATE action_trigger.event_definition SET template = +$$ +[%- USE date -%] +[%- SET li = target; -%] +
    +
    + +
    Title: [% helpers.get_li_attr("title", "", li.attributes) %]
    +
    Author: [% helpers.get_li_attr("author", "", li.attributes) %]
    +
    Item Count: [% li.lineitem_details.size %]
    +
    Lineitem ID: [% li.id %]
    +
    Open Holds: [% helpers.bre_open_hold_count(li.eg_bib_id) %]
    + [% IF li.cancel_reason.label %] +
    [% li.cancel_reason.label %]
    + [% END %] + + [% IF li.distribution_formulas.size > 0 %] + [% SET forms = [] %] + [% FOREACH form IN li.distribution_formulas; forms.push(form.formula.name); END %] +
    Distribution Formulas: [% forms.join(',') %]
    + [% END %] + + [% IF li.lineitem_notes.size > 0 %] + Lineitem Notes: +
      + [%- FOR note IN li.lineitem_notes -%] +
    • + [% IF note.alert_text %] + [% note.alert_text.code -%] + [% IF note.value -%] + : [% note.value %] + [% END %] + [% ELSE %] + [% note.value -%] + [% END %] +
    • + [% END %] +
    + [% END %] +
    +
    + + + + + + + + + + + + + + + + [% FOREACH detail IN li.lineitem_details %] + [% detail.owning_lib = detail.owning_lib.shortname %] + [% END %] + + [% FOREACH detail IN li.lineitem_details.sort('owning_lib') %] + [% + IF detail.eg_copy_id; + SET copy = detail.eg_copy_id; + SET cn_label = copy.call_number.label; + ELSE; + SET copy = detail; + SET cn_label = detail.cn_label; + END + %] + + + + + + + + + + + + [% END %] + +
    BranchBarcodeCall NumberFundShelving LocationRecd.NotesDelayed / Canceled
    [% detail.owning_lib %][% IF copy.barcode %][% detail.barcode %][% END %][% IF cn_label %][% cn_label %][% END %][% IF detail.fund %][% detail.fund.code %] ([% detail.fund.year %])[% END %][% copy.location.name %][% IF detail.recv_time %][% detail.recv_time %][% END %][% detail.note %][% detail.cancel_reason.label %]
    +
    +$$ +WHERE id = 14 AND template = +$$ +[%- USE date -%] +[%- SET li = target; -%] +
    +
    + +
    Title: [% helpers.get_li_attr("title", "", li.attributes) %]
    +
    Author: [% helpers.get_li_attr("author", "", li.attributes) %]
    +
    Item Count: [% li.lineitem_details.size %]
    +
    Lineitem ID: [% li.id %]
    +
    Open Holds: [% helpers.bre_open_hold_count(li.eg_bib_id) %]
    + + [% IF li.distribution_formulas.size > 0 %] + [% SET forms = [] %] + [% FOREACH form IN li.distribution_formulas; forms.push(form.formula.name); END %] +
    Distribution Formulas: [% forms.join(',') %]
    + [% END %] + + [% IF li.lineitem_notes.size > 0 %] + Lineitem Notes: +
      + [%- FOR note IN li.lineitem_notes -%] +
    • + [% IF note.alert_text %] + [% note.alert_text.code -%] + [% IF note.value -%] + : [% note.value %] + [% END %] + [% ELSE %] + [% note.value -%] + [% END %] +
    • + [% END %] +
    + [% END %] +
    +
    + + + + + + + + + + + + + + + [% FOREACH detail IN li.lineitem_details %] + [% detail.owning_lib = detail.owning_lib.shortname %] + [% END %] + + [% FOREACH detail IN li.lineitem_details.sort('owning_lib') %] + [% + IF detail.eg_copy_id; + SET copy = detail.eg_copy_id; + SET cn_label = copy.call_number.label; + ELSE; + SET copy = detail; + SET cn_label = detail.cn_label; + END + %] + + + + + + + + + + + [% END %] + +
    BranchBarcodeCall NumberFundShelving LocationRecd.Notes
    [% detail.owning_lib %][% IF copy.barcode %][% detail.barcode %][% END %][% IF cn_label %][% cn_label %][% END %][% IF detail.fund %][% detail.fund.code %] ([% detail.fund.year %])[% END %][% copy.location.name %][% IF detail.recv_time %][% detail.recv_time %][% END %][% detail.note %]
    +
    +$$; + + COMMIT; -- 2.43.2