LP#1440114 Blanket PO finalize from PO view
authorBill Erickson <berickxx@gmail.com>
Wed, 15 Apr 2015 21:44:37 +0000 (17:44 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 19 Aug 2015 16:33:28 +0000 (12:33 -0400)
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 <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/acq/po/view.tt2
Open-ILS/web/js/dojo/openils/acq/nls/acq.js
Open-ILS/web/js/ui/default/acq/po/view_po.js

index 00a8543..9aa8b11 100644 (file)
                                 [% l('Activate Without Loading Items') %]
                             </span>
                         </span>
+                        <span class="hidden" id="acq-po-finalize-links" style='padding: 5px'>
+                            <span dojoType="dijit.form.Button" onClick="finalizePo()" jsId="finalizePoButton">
+                                [% l('Finalize Blanket Order') %]
+                            </span>
+                        </span>
                     </td>
                 </tr>
                 <tr>
index 9eaeabb..0947f21 100644 (file)
     "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...",
index 9b76c08..f9f633d 100644 (file)
@@ -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");  /* <span> not <a> 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);