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>
Wed, 25 Jul 2012 14:37:59 +0000 (10:37 -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 9337575..6fe4b0e 100644 (file)
@@ -645,6 +645,25 @@ function focusLi() {
     100);
 }
 
+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) {
 
@@ -679,6 +698,7 @@ function addInvoiceEntry(entry) {
             console.log(dojo.byId('li-title-ref-' + li.id()));
 
             updateReceiveLink(li);
+            updateExpectedCost(li, entry);
 
             dojo.forEach(
                 ['inv_item_count', 'phys_item_count', 'cost_billed', 'amount_paid'],