From 021958c5f29d1e7fb1e8b301e3b0533b8a70c9cf Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 12 Apr 2010 14:50:09 +0000 Subject: [PATCH] added a total-estimated value to the PO view. format prices with 2 decimals in PO summary 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 | 13 ++++++++++--- Open-ILS/web/templates/default/acq/po/view.tt2 | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index 2ca7de2d57..b373a941ae 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -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); } } ); diff --git a/Open-ILS/web/templates/default/acq/po/view.tt2 b/Open-ILS/web/templates/default/acq/po/view.tt2 index f485c11445..cc401378da 100644 --- a/Open-ILS/web/templates/default/acq/po/view.tt2 +++ b/Open-ILS/web/templates/default/acq/po/view.tt2 @@ -12,6 +12,7 @@ Name Provider Total Lineitems + Total Estimated$ Total Encumbered$ Total Spent$ Status -- 2.11.0