acq : invoice running cost total, experimenting
authorBill Erickson <berick@esilibrary.com>
Fri, 20 Jul 2012 20:17:30 +0000 (16:17 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 20 Jul 2012 20:17:30 +0000 (16:17 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/acq/invoice/view.tt2
Open-ILS/web/js/ui/default/acq/invoice/view.js

index d0aefa4..8d6aa72 100644 (file)
@@ -16,7 +16,8 @@
         </div>
         <div id='acq-invoice-summary-small'>
             <h3 id='acq-invoice-summary-name'></h3>
-            <div>[% l("Lineitems: " ) %]<span id='acq-invoice-summary-count'>0</span></div><br/>
+            <div>[% l("Lineitems: " ) %]<span id='acq-invoice-summary-count'>0</span></div>
+            <div>[% l("Expected Cost: " ) %]<span id='acq-invoice-summary-cost'>0</span></div><br/>
             <button id='acq-invoice-summary-toggle-on'>[% l('Show Details') %]</button>
         </div>
         <br/>
index a82ce83..86785cf 100644 (file)
@@ -595,6 +595,26 @@ function updateReceiveLink(li) {
     link.onclick = function() { location.href =  oilsBasePath + '/acq/invoice/receive/' + invoiceId; };
 }
 
+function updateExpectedCost(li, entry) {
+    
+    var prevCost = Number(li._expected_cost || 0);
+
+    if (entry.isnew()) {
+        // total estimated minus any elsewhere invoiced
+        li._expected_cost = 
+            Number(li.order_summary().estimated_amount() || 0) - 
+            Number(li.order_summary().paid_amount() || 0);
+
+    } else {
+
+        li._expected_cost = Number(entry.cost_billed() || 0);
+    }
+
+    var total = Number(dojo.byId('acq-invoice-summary-cost').innerHTML || 0);
+    total += li._expected_cost;
+    dojo.byId('acq-invoice-summary-cost').innerHTML = total.toFixed(2);
+}
+
 function addInvoiceEntry(entry) {
 
     openils.Util.removeCSSClass(dojo.byId('acq-invoice-entry-header'), 'hidden');
@@ -625,6 +645,7 @@ function addInvoiceEntry(entry) {
             nodeByName('title_details', row).innerHTML = html;
 
             updateReceiveLink(li);
+            updateExpectedCost(li, entry);
 
             dojo.forEach(
                 ['inv_item_count', 'phys_item_count', 'cost_billed', 'amount_paid'],