when amount paid exceeds amount billed, disable save/prorate buttons and style the...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 9 Apr 2010 13:48:48 +0000 (13:48 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 9 Apr 2010 13:48:48 +0000 (13:48 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16193 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/css/skin/default/acq.css
Open-ILS/web/js/ui/default/acq/invoice/view.js
Open-ILS/web/templates/default/acq/invoice/view.tt2

index aa942c8..ffdb200 100644 (file)
@@ -221,3 +221,5 @@ option[disabled="disabled"] { font-style: italic; }
 .acq-inoice-item-extra-info { padding-left: 10px; }
 .acq-inoice-item-info { font-weight: bold; }
 .acq-invoice-row td { border-bottom: 1px solid #e0e0e0; }
+.acq-invoice-invalid-amount input { color: red; font-weight: bold; }
+
index cf1d1b3..bac605d 100644 (file)
@@ -164,31 +164,56 @@ function doAttachPo() {
 }
 
 function updateTotalCost() {
-    var total = 0;    
+
+    var totalCost = 0;    
     if(!totalInvoicedBox) {
         totalInvoicedBox = new dijit.form.CurrencyTextBox(
             {style : 'width: 5em'}, dojo.byId('acq-invoice-total-invoiced'));
     }
     for(var id in widgetRegistry.acqii) 
         if(!widgetRegistry.acqii[id]._object.isdeleted())
-            total += widgetRegistry.acqii[id].cost_billed.getFormattedValue();
+            totalCost += widgetRegistry.acqii[id].cost_billed.getFormattedValue();
     for(var id in widgetRegistry.acqie) 
         if(!widgetRegistry.acqie[id]._object.isdeleted())
-            total += widgetRegistry.acqie[id].cost_billed.getFormattedValue();
-    totalInvoicedBox.attr('value', total);
+            totalCost += widgetRegistry.acqie[id].cost_billed.getFormattedValue();
+    totalInvoicedBox.attr('value', totalCost);
 
-    total = 0;    
+    totalPaid = 0;    
     if(!totalPaidBox) {
         totalPaidBox = new dijit.form.CurrencyTextBox(
             {style : 'width: 5em'}, dojo.byId('acq-invoice-total-paid'));
     }
     for(var id in widgetRegistry.acqii) 
         if(!widgetRegistry.acqii[id]._object.isdeleted())
-            total += widgetRegistry.acqii[id].amount_paid.getFormattedValue();
+            totalPaid += widgetRegistry.acqii[id].amount_paid.getFormattedValue();
     for(var id in widgetRegistry.acqie) 
         if(!widgetRegistry.acqie[id]._object.isdeleted())
-            total += widgetRegistry.acqie[id].amount_paid.getFormattedValue();
-    totalPaidBox.attr('value', total);
+            totalPaid += widgetRegistry.acqie[id].amount_paid.getFormattedValue();
+    totalPaidBox.attr('value', totalPaid);
+
+    var buttonsDisabled = false;
+    if(totalPaid > totalCost || totalPaid < 0) {
+        openils.Util.addCSSClass(totalPaidBox.domNode, 'acq-invoice-invalid-amount');
+        invoiceSaveButton.attr('disabled', true);
+        invoiceProrateButton.attr('disabled', true);
+        buttonsDisabled = true;
+    } else {
+        openils.Util.removeCSSClass(totalPaidBox.domNode, 'acq-invoice-invalid-amount');
+        invoiceSaveButton.attr('disabled', false);
+        invoiceProrateButton.attr('disabled', false);
+    }
+
+    if(totalCost < 0) {
+        openils.Util.addCSSClass(totalInvoicedBox.domNode, 'acq-invoice-invalid-amount');
+        invoiceSaveButton.attr('disabled', true);
+        invoiceProrateButton.attr('disabled', true);
+    } else {
+        openils.Util.removeCSSClass(totalInvoicedBox.domNode, 'acq-invoice-invalid-amount');
+        if(!buttonsDisabled) {
+            invoiceSaveButton.attr('disabled', false);
+            invoiceProrateButton.attr('disabled', false);
+        }
+    }
 }
 
 
index 3368e6b..190dbd7 100644 (file)
             <tbody>
                 <tr>
                     <td colspan='4' style='text-align:right;'>
-                        <button dojoType='dijit.form.Button' onclick='saveChanges();'>Save Changes</button>
-                        <button dojoType='dijit.form.Button' onclick='saveChanges(true);'>Save &amp; Prorate Charges</button>
+                        <button jsId='invoiceSaveButton' 
+                            dojoType='dijit.form.Button' onclick='saveChanges();'>Save Changes</button>
+                        <button jsId='invoiceProrateButton' 
+                            dojoType='dijit.form.Button' onclick='saveChanges(true);'>Save &amp; Prorate Charges</button>
                     </td>
                     <td><div id='acq-invoice-total-invoiced'/></td>
                     <td><div id='acq-invoice-total-paid'/></td>