From b34abf2a95296882452dbe5ed3df2fc1067f395a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 8 Apr 2015 15:17:01 -0400 Subject: [PATCH] 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 --- .../web/js/ui/default/acq/invoice/view.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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); -- 2.43.2