rustyshackles
07/18/2025, 12:54 AMNickSuite
07/18/2025, 10:55 AMrustyshackles
07/18/2025, 8:56 PMfunction _checkSelection(recCurrent, inLineCount) {
var flAmount = 0.0;
var stCustomer = null;
var stProvider = null;
var stAccountManager = null;
var stReason = null;
var stCloseAmount = null;
var blSelected = false;
var blSelectedItem = false;
var blSplitInvoice = false;
var blClose = false;
for (var inIndex = 0; inIndex < inLineCount; inIndex++) {
blSelected = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_select",
line: inIndex,
});
stCustomer = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_customer",
line: inIndex,
});
stProvider = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_provider",
line: inIndex,
});
stAccountManager = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_accnt_mngr",
line: inIndex,
});
flAmount = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_inv_amount",
line: inIndex,
});
blSplitInvoice = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_split",
line: inIndex,
});
blClose = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_close",
line: inIndex,
});
stCloseAmount = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_close_amount",
line: inIndex,
});
stReason = recCurrent.getSublistValue({
sublistId: "custpage_billableexpensesublist",
fieldId: "custpage_close_reason",
line: inIndex,
});
if (blSelected == true || blSelected == "T") {
blSelectedItem = true;
// <Gerrom V. Infante (ginfan@appwrap.tech) 02/10/2024> - added logic to ignore Customer, and Provider if the User has checked the split invoice or if the Close field is selected
if (
(blSplitInvoice == false || blSplitInvoice == "F") &&
(blClose == false || blClose == "F")
) {
if (
!stCustomer ||
!stProvider ||
!stAccountManager ||
!flAmount ||
stCustomer == -1 ||
stProvider == -1 ||
stAccountManager == -1
) {
dialog.alert({
message:
"At least one of the following fields is blank. Please provide a value to the field and try" +
" again.<br/>Customer<br/>Provider<br/>Account Manager<br/>Invoice Amount",
});
return false;
}
}
if (blClose == true || blClose == "T") {
// if customer or provider is selected for line marked as closed, check if amount is provided
if (
!stCustomer ||
!stProvider ||
!stAccountManager ||
stCustomer == -1 ||
stProvider == -1||
stAccountManager == -1
) {
if (!flAmount) {
dialog.alert({
message: "Invoice amount is a required field.",
});
return false;
}
}
// check if Close Reason is provided
if (!stReason) {
dialog.alert({
message: "Please provide a close reason.",
});
return false;
}
if (!stCloseAmount) {
dialog.alert({
message: "Close Amount is a required field.",
});
return false;
}
// stCloseAmount should not be more than flAmount
if (Number(flAmount) < Number(stCloseAmount)) {
dialog.alert({
message: "Close Amount cannot be more than Invoice amount.",
});
return false;
}
}
}
}
if (!blSelectedItem) {
dialog.alert({ message: "Please select at least one item." });
return false;
}
return true;
}
NickSuite
07/19/2025, 12:12 AMrustyshackles
07/19/2025, 2:07 AM