From: Bill Erickson Date: Wed, 25 Jul 2012 19:12:55 +0000 (-0400) Subject: acq invoice : price per copy column X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9e76d9254cc8da0aa9de611093ca48a4bcd65001;p=evergreen%2Fequinox.git acq invoice : price per copy column Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/acq/invoice/view.tt2 b/Open-ILS/src/templates/acq/invoice/view.tt2 index 86b58849fd..dd6c7129b7 100644 --- a/Open-ILS/src/templates/acq/invoice/view.tt2 +++ b/Open-ILS/src/templates/acq/invoice/view.tt2 @@ -17,6 +17,9 @@ padding-bottom: 5px; border-bottom: 2px solid #888; } + #acq-invoice-num-summary-table td[id] { + font-weight:bold; + } @@ -25,6 +28,7 @@
[% l("Lineitems: " ) %]0
0.00
+
@@ -68,6 +72,7 @@ Title Details # Invoiced / # Paid Billed + Per Copy Paid Detach @@ -82,6 +87,7 @@  / 
+
0.00
Detach @@ -100,6 +106,7 @@ Fund Title/Description Billed + Paid Delete @@ -110,6 +117,7 @@
+
Delete @@ -132,6 +140,7 @@ Total + Total Balance diff --git a/Open-ILS/web/js/ui/default/acq/invoice/view.js b/Open-ILS/web/js/ui/default/acq/invoice/view.js index 7b5e0be5bb..3e64528cf5 100644 --- a/Open-ILS/web/js/ui/default/acq/invoice/view.js +++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js @@ -70,14 +70,14 @@ function init() { openils.Util.hide(dojo.byId('acq-invoice-summary-small')); } - // show summary info by default - dojo.byId('acq-invoice-summary-toggle-on').onclick(); - - if(cgi.param('create')) { renderInvoice(); + // show summary info by default for new invoices + dojo.byId('acq-invoice-summary-toggle-on').onclick(); + } else { + dojo.byId('acq-invoice-summary-toggle-off').onclick(); fieldmapper.standardRequest( ['open-ils.acq', 'open-ils.acq.invoice.retrieve.authoritative'], { @@ -666,6 +666,7 @@ function updateExpectedCost(li, entry) { dojo.byId('acq-invoice-summary-cost').innerHTML = total.toFixed(2); } +var invoicEntryWidgets = {}; function addInvoiceEntry(entry) { console.log('Adding new entry for lineitem ' + entry.lineitem()); @@ -731,6 +732,7 @@ function addInvoiceEntry(entry) { parentNode : nodeByName(field, row) }), function(w) { + if(field == 'phys_item_count') { dojo.connect(w, 'onChange', function() { @@ -743,8 +745,15 @@ function addInvoiceEntry(entry) { } } ) - } - } + } // if + + if(field == 'inv_item_count' || field == 'cost_billed') { + setPerCopyPrice(row, entry); + // update the per-copy count as invoice count and cost billed change + dojo.connect(w, 'onChange', function() { setPerCopyPrice(row, entry) } ); + } + + } // func ); } ); @@ -784,6 +793,22 @@ function addInvoiceEntry(entry) { updateTotalCost(); } +function setPerCopyPrice(row, entry) { + var inv_w = widgetRegistry.acqie[entry.id()].inv_item_count; + var bill_w = widgetRegistry.acqie[entry.id()].cost_billed; + + if (inv_w && bill_w) { + var invoiced = Number(inv_w.getFormattedValue()); + var billed = Number(bill_w.getFormattedValue()); + console.log(invoiced + ' : ' + billed); + if (invoiced > 0) { + nodeByName('amount_paid_per_copy', row).innerHTML = (billed / invoiced).toFixed(2); + } else { + nodeByName('amount_paid_per_copy', row).innerHTML = '0.00'; + } + } +} + function liMarcAttr(lineitem, name) { var attr = lineitem.attributes().filter( function(attr) {