From cc61c578b7ebcfdf20d6f83cd91206e3c803d70b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 15 Apr 2015 17:44:37 -0400 Subject: [PATCH] LP#1440114 Blanket PO finalize from PO view Adds new "Finalize Blanket Order" button to purchase page for PO's that are activated and have at least on blanket charge. Finalizing the PO disencumbers all blanket charges and marks the PO as complete. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- Open-ILS/src/templates/acq/po/view.tt2 | 5 ++++ Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 1 + Open-ILS/web/js/ui/default/acq/po/view_po.js | 43 ++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/Open-ILS/src/templates/acq/po/view.tt2 b/Open-ILS/src/templates/acq/po/view.tt2 index 00a8543f1e..9aa8b1197c 100644 --- a/Open-ILS/src/templates/acq/po/view.tt2 +++ b/Open-ILS/src/templates/acq/po/view.tt2 @@ -35,6 +35,11 @@ [% l('Activate Without Loading Items') %] + diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index 9eaeabbc4a..0947f21e95 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -104,6 +104,7 @@ "DUPE_PO_NAME_MSG" : "This name is already in use by another PO", "DUPE_PO_NAME_LINK" : "View PO", "PO_NAME_OPTIONAL" : "${0} (optional)", + "FINALIZE_PO" : "Finalize this blanket PO?\nThis will disencumber all blanket charges and mark the PO as received", "LI_EXISTING_COPIES" : "There are ${0} existing copies for this bibliographic record at this location", "LI_CREATING_ASSETS" : "Creating bib, call number, and copy records...", "PO_ACTIVATING" : "Activating purchase order...", diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index 9b76c08f8f..f9f633d5cb 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -396,6 +396,7 @@ function renderPo() { } else { if (PO.order_date()) { dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.PO_ALREADY_ACTIVATED; + checkCouldBlanketFinalize(); } else { dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.NO; } @@ -519,6 +520,30 @@ function init2() { ); } +function checkCouldBlanketFinalize() { + + if (PO.state() == 'received') return; + + var inv_types = []; + + // get the unique set of invoice item type IDs + PO.po_items().forEach(function(item) { + if (inv_types.indexOf(item.inv_item_type()) == -1) + inv_types.push(item.inv_item_type()); + }); + + if (inv_types.length == 0) return; + + pcrud.search('aiit', + {code : inv_types, blanket : 't'}, { + oncomplete : function(r) { + r = openils.Util.readResponse(r); + if (r.length == 0) return; + openils.Util.show(dojo.byId('acq-po-finalize-links'), 'inline'); + } + }); +} + function checkCouldActivatePo() { var d = dojo.byId("acq-po-activate-checking"); var a = dojo.byId("acq-po-activate-links"); /* not now, but no diff */ @@ -607,6 +632,24 @@ function checkCouldActivatePo() { ); } +function finalizePo() { + + if (!confirm(localeStrings.FINALIZE_PO)) return; + + finalizePoButton.attr('disabled', true); + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.purchase_order.blanket.finalize'], + { async : true, + params : [openils.User.authtoken, PO.id()], + oncomplete : function(r) { + if (openils.Util.readResponse(r) == 1) + location.href = location.href; + } + } + ); +} + function activatePo(noAssets) { activatePoButton.attr("disabled", true); activatePoNoAssetsButton.attr("disabled", true); -- 2.11.0