diff --git a/onprc_billing/resources/queries/onprc_billing/chargeRates.js b/onprc_billing/resources/queries/onprc_billing/chargeRates.js index 3ee20ddab..0b8f87628 100644 --- a/onprc_billing/resources/queries/onprc_billing/chargeRates.js +++ b/onprc_billing/resources/queries/onprc_billing/chargeRates.js @@ -16,10 +16,18 @@ function beforeUpdate(row, errors){ function beforeUpsert(row, errors){ if (row.startDate){ + // normalize to date-only (00:00) row.startDate = ldkUtils.removeTimeFromDate(row.startDate); } if (row.endDate){ - row.endDate = ldkUtils.removeTimeFromDate(row.endDate); + // normalize to date-only first + var cleanDate = ldkUtils.removeTimeFromDate(row.endDate); + + // create a new date object set to 23:59 + var endOfDay = new Date(cleanDate); + endOfDay.setHours(23, 59, 0, 0); + + row.endDate = endOfDay; } } \ No newline at end of file diff --git a/onprc_billing/resources/queries/onprc_billing/miscCharges.query.xml b/onprc_billing/resources/queries/onprc_billing/miscCharges.query.xml index 7b284cbb5..15de3d9a1 100644 --- a/onprc_billing/resources/queries/onprc_billing/miscCharges.query.xml +++ b/onprc_billing/resources/queries/onprc_billing/miscCharges.query.xml @@ -27,6 +27,17 @@ + + Source Transaction + false + + /ONPRC/Admin/Finance + onprc_billing + invoicedItems + objectid + transactionNumber + + onprc_billing diff --git a/onprc_billing/resources/schemas/onprc_billing.xml b/onprc_billing/resources/schemas/onprc_billing.xml index 2bb09f73b..f6e728bc5 100644 --- a/onprc_billing/resources/schemas/onprc_billing.xml +++ b/onprc_billing/resources/schemas/onprc_billing.xml @@ -419,10 +419,11 @@ Source Transaction true + /ONPRC/Admin/Finance onprc_billing invoicedItems objectid - rowid + transactionNumber diff --git a/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js b/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js index fb7058865..d87cd5df1 100644 --- a/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js +++ b/onprc_billing/resources/web/onprc_billing/window/ReverseChargeWindow.js @@ -4,6 +4,9 @@ * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 * Modified jonesga October 30, 2024 * **Per Finance Issue Tracker 11380 added debit Aklias add function to allow change of debit alias when no center project is associated + * Modified [Your Name] September 29, 2025 + * **Added transaction number links to the header for easy reference to invoiced items + * **Optimized link generation to prevent script timeout on large datasets */ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { extend: 'Ext.window.Window', @@ -48,8 +51,10 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { labelWidth: 150 }, items: [{ + itemId: 'headerPanel', html: 'This helper allows you to make adjustments and reversals. Once you select the type of adjustment, look below to see an explanation of the items it will create.

' + - 'NOTE: You have selected ' + this.checked.length + ' items to be reversed or adjusted. These are based on the rows you checked on the previous grid.', + 'NOTE: You have selected ' + this.checked.length + ' items to be reversed or adjusted. These are based on the rows you checked on the previous grid.

' + + 'Loading transaction details...', style: 'padding-bottom: 10px;' },{ xtype: 'radiogroup', @@ -122,7 +127,7 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { filterArray: [ LABKEY.Filter.create('objectid', this.checked.join(';'), LABKEY.Filter.Types.IN) ], - columns: 'rowid,objectid,invoiceid,invoiceid/status,Id,date,project,creditedaccount,debitedaccount,rateId,exemptionId,quantity,investigatorId,chargeid,unitcost', + columns: 'rowid,transactionNumber,objectid,invoiceid,invoiceid/status,Id,date,project,creditedaccount,debitedaccount,rateId,exemptionId,quantity,investigatorId,chargeid,unitcost,transactionNumber', scope: this, failure: LDK.Utils.getErrorCallback(), success: this.onDataLoad @@ -134,13 +139,56 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { this.selectRowsResults = results; var missingCharge = 0; + var transactionMap = {}; + var maxLinksToShow = 20; + if (results && results.rows && results.rows.length){ - Ext4.Array.forEach(results.rows, function(r){ + for (var i = 0; i < results.rows.length; i++) { + var r = results.rows[i]; var sr = new LDK.SelectRowsRow(r); + if (!sr.getValue('chargeId')){ missingCharge++; } - }, this); + + var transNum = sr.getValue('transactionNumber'); + if (transNum && Object.keys(transactionMap).length < maxLinksToShow) { + if (!transactionMap[transNum]) { + var url = LABKEY.ActionURL.buildURL('query', 'executeQuery', null, { + schemaName: 'onprc_billing', + 'query.queryName': 'invoicedItems', + 'query.transactionNumber~eq': transNum + }); + transactionMap[transNum] = '' + Ext4.util.Format.htmlEncode(transNum) + ''; + } + } + } + } + + var headerPanel = this.down('#headerPanel'); + if (headerPanel) { + var linksHtml = ''; + var transactionLinks = []; + + for (var key in transactionMap) { + if (transactionMap.hasOwnProperty(key)) { + transactionLinks.push(transactionMap[key]); + } + } + + if (transactionLinks.length > 0) { + linksHtml = '
Transaction Numbers: ' + transactionLinks.join(', '); + if (results.rows.length > maxLinksToShow) { + linksHtml += ' (showing first ' + transactionLinks.length + ' unique transactions)'; + } + } + + headerPanel.update( + 'This helper allows you to make adjustments and reversals. Once you select the type of adjustment, look below to see an explanation of the items it will create.

' + + 'NOTE: You have selected ' + this.checked.length + ' items to be reversed or adjusted. These are based on the rows you checked on the previous grid.' + + linksHtml + ); } if (Ext4.Msg.isVisible()) @@ -192,13 +240,13 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { items.push({ html: 'This will reverse the original charges and create adjustments based on your selections below. ' + - '', + '', style: 'padding-bottom: 10px;' },{ xtype: 'datefield', @@ -429,7 +477,7 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { } //added as part of Finance 11380 update by Gary //this issues is causing error - if (this.down('#doChangedebitAlias').getValue() && !this.down('#newDebitAliasField').getValue()){ + if (this.down('#doChangedebitAlias').getValue() && !this.down('#newDebitAliasField').getValue()){ Ext4.Msg.alert('Error', 'You have checked that you want to alter the debit alias, but did not supply the new alias. Either enter an alias or uncheck the field'); return; } @@ -491,7 +539,7 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { toApply.debitedaccount = Ext4.String.trim(toApply.debitedaccount); } } - //Added by Gary as part of 11380 update + //Added by Gary as part of 11380 update if (this.down('#doChangedebitAlias').getValue()){ toApply.debitedaccount = this.down('#newDebitAliasField').getValue(); if (toApply.debitedaccount){ @@ -529,16 +577,16 @@ Ext4.define('ONPRC_Billing.window.ReverseChargeWindow', { investigatorId: sr.getValue('investigatorId'), chargeId: sr.getValue('chargeId'), quantity: sr.getValue('quantity'), - sourceInvoicedItem: sr.getValue('objectid'), + sourceInvoicedItem: sr.getValue('transactionNumber'), //these may be overridden project: sr.getValue('project'), debitedaccount: sr.getValue('debitedaccount'), creditedaccount: sr.getValue('creditedaccount'), - unitcost: sr.getValue('unitcost') + unitcost: sr.getValue('unitcost'), //these are deliberately ignored - //transactionNumber: sr.getValue('transactionNumber'), + transactionNumber: sr.getValue('transactionNumber') //item: sr.getValue('item'), //itemCode: sr.getValue('itemCode'), //category: sr.getValue('category'),