From: Bill Erickson Date: Wed, 8 Apr 2015 19:17:01 +0000 (-0400) Subject: LP#1440114 Remove inv_item via po_item from invoice X-Git-Tag: sprint4-merge-nov22~1223 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b34abf2a95296882452dbe5ed3df2fc1067f395a;p=working%2FEvergreen.git LP#1440114 Remove inv_item via po_item from invoice Allow invoice_items which were descended from po_item's (direct charges) to be removed from invoices. Prior to this, a JS exception prevented removal of these items. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- 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 d5cf6f1c35..313e4d7185 100644 --- a/Open-ILS/web/js/ui/default/acq/invoice/view.js +++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js @@ -702,11 +702,23 @@ function addInvoiceItem(item) { nodeByName('delete', row).onclick = function() { var cost = widgetRegistry.acqii[item.id()].cost_billed.getFormattedValue(); + + var iTypeName = ''; + if (widgetRegistry.acqii[item.id()].inv_item_type) { + iTypeName = widgetRegistry.acqii[item.id()] + .inv_item_type.getFormattedValue() + } else { + // if the invoice_item came from a po_item, the type is + // read-only, hence no widget in the registry. Look up + // the name in the cached types list. + var itype = itemTypes.filter( + function(t) { return (t.code() == item.inv_item_type()) })[0]; + iTypeName = itype.name(); + } + var msg = dojo.string.substitute( - localeStrings.INVOICE_CONFIRM_ITEM_DELETE, [ - cost || 0, - widgetRegistry.acqii[item.id()].inv_item_type.getFormattedValue() || '' - ] + localeStrings.INVOICE_CONFIRM_ITEM_DELETE, + [cost || 0, iTypeName || ''] ); if(!confirm(msg)) return; itemTbody.removeChild(row);