Acq: optionally mark POs as prepayment_required; show/confirm it where needed
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 23 Mar 2010 16:00:26 +0000 (16:00 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 23 Mar 2010 16:00:26 +0000 (16:00 +0000)
The PO creation dialog box now has a checkbox for "prepayment required." This
will be checked or unchecked automatically when choosing a vendor from the
above dropdown based on whether that vendor's "prepayment required" value is
true.  The user can override the default value for a vendor, but will face a
confirmation dialog about it.

The PO viewing interface shows whether or not a PO is marked "prepayment
required," and if it is, when the user wishes to activate the PO, there will
be another confirmation dialog reminding the user to deal with payment.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15937 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
Open-ILS/web/css/skin/default/acq.css
Open-ILS/web/js/dojo/openils/acq/nls/acq.js
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/po/view_po.js
Open-ILS/web/templates/default/acq/common/li_table.tt2
Open-ILS/web/templates/default/acq/po/view.tt2

index 36bf5ef..d61f720 100644 (file)
@@ -1433,6 +1433,8 @@ sub create_purchase_order_api {
     my %pargs = (ordering_agency => $e->requestor->ws_ou); # default
     $pargs{provider} = $po->provider if $po->provider;
     $pargs{ordering_agency} = $po->ordering_agency if $po->ordering_agency;
+    $pargs{prepayment_required} = $po->prepayment_required
+        if $po->prepayment_required;
     $po = create_purchase_order($mgr, %pargs) or return $e->die_event;
 
     my $li_ids = $$args{lineitems};
index f0d436b..d1a2bd4 100644 (file)
@@ -60,6 +60,7 @@
 .oils-acq-po-records-author-row td { padding-left: 30px; }
 .oils-acq-po-records-phys_desc-row td { padding-left: 30px; }
 .oils-acq-po-records-phys_desc-row {}
+.oils-acq-po-prepay { font-weight: bold; color: #c00; }
 
 #oils-acq-po-paging-block { width: 50%; text-align: left;}
 #oils-acq-po-actions-block { width: 50%; text-align: right;}
index fdb5b39..4eeab76 100644 (file)
     'LI_CANCEL_CONFIRM': "Are you SURE you want to cancel this line item?",
     'LID_CANCEL_CONFIRM': "Are you SURE you want to cancel this copy?",
     'CANCEL_REASON': "Cancel reason",
-    'CANCEL': "Cancel"
+    'CANCEL': "Cancel",
+    'YES': "Yes",
+    'NO' : "No",
+    'VENDOR_SAYS_PREPAY_NOT_NEEDED': "The selected vendor does not necessarily require prepayment, according\nto records. Require prepayment on this PO anyway?",
+    'VENDOR_SAYS_PREPAY_NEEDED': "The selected vendor requires prepayment, according to records.\nProceed anyway without required prepayment on this PO?",
+    'PREPAYMENT_REQUIRED_REMINDER': "This PO requires prepayment.  Are you certain you're ready to activate it?"
 }
index 63849f5..b4f97d4 100644 (file)
@@ -68,8 +68,12 @@ function AcqLiTable() {
         });
 
     acqLitCreatePoSubmit.onClick = function() {
-        acqLitPoCreateDialog.hide();
-        self._createPO(acqLitPoCreateDialog.getValues());
+        if (self._confirmPoPrepaySituation()) {
+            acqLitPoCreateDialog.hide();
+            self._createPO(acqLitPoCreateDialog.getValues());
+        } else {
+            return false;
+        }
     }
 
     acqLitSavePlButton.onClick = function() {
@@ -456,7 +460,7 @@ function AcqLiTable() {
             }
         }
 
-        if (note.vendor_public() == "t")
+        if (openils.Util.isTrue(note.vendor_public()))
             nodeByName("vendor_public", row).innerHTML =
                 localeStrings.VENDOR_PUBLIC;
 
@@ -1485,6 +1489,25 @@ function AcqLiTable() {
         }
     }
 
+    this._updateCreatePoPrepayCheckbox = function(prepay) {
+        var prepay = openils.Util.isTrue(prepay);
+        this._prepayRequiredByVendor = prepay;
+        dijit.byId("acq-lit-po-prepay").attr("checked", prepay);
+    };
+
+    this._confirmPoPrepaySituation = function() {
+        var want_prepay = dijit.byId("acq-lit-po-prepay").attr("checked");
+        if (want_prepay != this._prepayRequiredByVendor) {
+            return confirm(
+                want_prepay ?
+                    localeStrings.VENDOR_SAYS_PREPAY_NOT_NEEDED :
+                    localeStrings.VENDOR_SAYS_PREPAY_NEEDED
+            );
+        } else {
+            return true;
+        }
+    };
+
     this.applySelectedLiAction = function(action) {
         var self = this;
         switch(action) {
@@ -1501,6 +1524,15 @@ function AcqLiTable() {
                         fmClass : 'acqpo',
                         searchFilter: {"active": "t"},
                         parentNode : dojo.byId('acq-lit-po-provider'),
+                        dijitArgs : {
+                            "onChange": function() {
+                                if (this.item) {
+                                    self._updateCreatePoPrepayCheckbox(
+                                        this.item.prepayment_required
+                                    );
+                                }
+                            }
+                        }
                     });
                     widget.build(
                         function(w) { self.createPoProviderSelector = w; }
@@ -1829,6 +1861,7 @@ function AcqLiTable() {
         var po = new fieldmapper.acqpo();
         po.provider(this.createPoProviderSelector.attr('value'));
         po.ordering_agency(this.createPoAgencySelector.attr('value'));
+        po.prepayment_required(fields.prepayment_required[0] ? true : false);
 
         var selected = this.getSelected( (fields.create_from == 'all') );
         if(selected.length == 0) return;
index 60c5588..72e7ce1 100644 (file)
@@ -46,7 +46,7 @@ function AcqPoNoteTable() {
 
         nodeByName("value", row).innerHTML = note.value();
 
-        if (note.vendor_public() == "t")
+        if (openils.Util.isTrue(note.vendor_public()))
             nodeByName("vendor_public", row).innerHTML =
                 localeStrings.VENDOR_PUBLIC;
 
@@ -187,6 +187,16 @@ function cancellationUpdater(r) {
     }
 }
 
+function makePrepayWidget(node, prepay) {
+    if (prepay) {
+        openils.Util.addCSSClass(node, "oils-acq-po-prepay");
+        node.innerHTML = localeStrings.YES;
+    } else {
+        openils.Util.removeCSSClass(node, "oils-acq-po-prepay");
+        node.innerHTML = localeStrings.NO;
+    }
+}
+
 function makeCancelWidget(node, labelnode) {
     openils.Util.hide("acq-po-choose-cancel-reason");
 
@@ -246,6 +256,10 @@ function renderPo() {
     dojo.byId("acq-po-view-total-enc").innerHTML = PO.amount_encumbered();
     dojo.byId("acq-po-view-total-spent").innerHTML = PO.amount_spent();
     dojo.byId("acq-po-view-state").innerHTML = PO.state(); // TODO i18n
+    makePrepayWidget(
+        dojo.byId("acq-po-view-prepay"),
+        openils.Util.isTrue(PO.prepayment_required())
+    );
     makeCancelWidget(
         dojo.byId("acq-po-view-cancel-reason"),
         dojo.byId("acq-po-cancel-label")
@@ -299,6 +313,11 @@ params: [openils.User.authtoken, {purchase_order:poId}, {flesh_attrs:true, flesh
 }
 
 function activatePo() {
+    if (
+        openils.Util.isTrue(PO.prepayment_required()) &&
+        !confirm(localeStrings.PREPAYMENT_REQUIRED_REMINDER)
+    ) return false;
+
     progressDialog.show(true);
     try {
         fieldmapper.standardRequest(
index 0600347..3617fbb 100644 (file)
                     <td><div name='provider' id='acq-lit-po-provider'/></td>
                 </tr>
                 <tr>
+                    <td>Prepayment Required</td>
+                    <td><input id="acq-lit-po-prepay" name="prepayment_required" dojoType="dijit.form.CheckBox"/></td>
+                </tr>
+                <tr>
                     <td>All Lineitems</td>
                     <td><input checked='checked' name='create_from' value='all' dojoType='dijit.form.RadioButton'/></td>
                 </tr>
index 4c20b56..4c43c7a 100644 (file)
@@ -13,6 +13,7 @@
                 <tr><td>Total Encumbered</td><td>$<span id='acq-po-view-total-enc'/></td></tr>
                 <tr><td>Total Spent</td><td>$<span id='acq-po-view-total-spent'/></td></tr>
                 <tr><td>Status</td><td><span id='acq-po-view-state'/></td></tr>
+                <tr><td>Prepayment Required?</td><td><span id="acq-po-view-prepay"/></td></tr>
                 <tr>
                     <td id="acq-po-cancel-label"></td>
                     <td>