added a total-estimated value to the PO view. format prices with 2 decimals in PO...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 Apr 2010 14:50:09 +0000 (14:50 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 Apr 2010 14:50:09 +0000 (14:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16202 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/acq/po/view_po.js
Open-ILS/web/templates/default/acq/po/view.tt2

index 2ca7de2..b373a94 100644 (file)
@@ -305,8 +305,8 @@ function renderPo() {
         PO.provider()
     );
     dojo.byId("acq-po-view-total-li").innerHTML = PO.lineitem_count();
-    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-total-enc").innerHTML = PO.amount_encumbered().toFixed(2);
+    dojo.byId("acq-po-view-total-spent").innerHTML = PO.amount_spent().toFixed(2);
     dojo.byId("acq-po-view-state").innerHTML = PO.state(); // TODO i18n
     makePrepayWidget(
         dojo.byId("acq-po-view-prepay"),
@@ -356,13 +356,20 @@ function init() {
         }
     );
 
+    var totalEstimated = 0;
     fieldmapper.standardRequest(
         ['open-ils.acq', 'open-ils.acq.lineitem.search'],
         {   async: true,
 params: [openils.User.authtoken, {purchase_order:poId}, {flesh_attrs:true, flesh_notes:true, flesh_cancel_reason:true}],
             onresponse: function(r) {
                 liTable.show('list');
-                liTable.addLineitem(openils.Util.readResponse(r));
+                var li = openils.Util.readResponse(r);
+                totalEstimated += (Number(li.item_count() || 0) * Number(li.estimated_unit_price() || 0));
+                liTable.addLineitem(li);
+            },
+
+            oncomplete : function() {
+                dojo.byId("acq-po-view-total-estimated").innerHTML = totalEstimated.toFixed(2);
             }
         }
     );
index f485c11..cc40137 100644 (file)
@@ -12,6 +12,7 @@
                 <tr><td>Name</td><td><a id='acq-po-view-name' href='javascript:void(0);' onclick='updatePoName()'></a></td></tr>
                 <tr><td>Provider</td><td><span id="acq-po-view-provider"/></td></tr>
                 <tr><td>Total Lineitems</td><td><span id='acq-po-view-total-li'/></td></tr>
+                <tr><td>Total Estimated</td><td>$<span id='acq-po-view-total-estimated'/></td></tr>
                 <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>