AFL
05/04/2020, 7:00 AMbattk
05/04/2020, 7:03 AMKevin
05/04/2020, 7:04 AMKevin
05/04/2020, 7:04 AMbattk
05/04/2020, 7:04 AMAFL
05/04/2020, 7:04 AMAFL
05/04/2020, 7:05 AMAFL
05/04/2020, 7:07 AMAFL
05/04/2020, 7:08 AMfunction createNewAllocationLines(objJE, objAllocations, arrValues){
var stLogTitle = 'createNewAllocationLines';
log.debug(stLogTitle, '##START##');
try {
for(var index = 0; index<arrValues.length; index++){
var objValues = JSON.parse(arrValues[index]);
//credit allocated amounts to their correct key account
var lenOfAllocations = Object.keys(objAllocations).length;
var normalFactor = objAllocations.NORMAL_FACTOR;
var amtToAllocate = 0;
var sumOfReAllocations = 0;
var lineCounter = 0;
for(var key in objAllocations){
if(key != "NORMAL_FACTOR"){
objJE.selectNewLine({
sublistId: 'line'
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'account',
value: objValues.recognitionAcct
});
amtToAllocate = objValues.amount*objAllocations[key]*normalFactor*100;
// amtToAllocate = round(amtToAllocate,2)*1;
// log.debug(stLogTitle, "amtToAllocate - "+amtToAllocate);
var arrOfAmt = (amtToAllocate.toFixed(0)).split("");
log.debug(stLogTitle, "arrOfAmt - "+arrOfAmt.toString());
var arrOfAmtLen = arrOfAmt.length;
var restructuredAmt = 0;
for(var place =0; place<arrOfAmtLen; place++){
var intPartofAmt = parseInt(arrOfAmt[place]);
// log.debug("intPartofAmt",intPartofAmt);
var pow = arrOfAmtLen-place-1;
// log.debug("POW", pow);
var multiplier = Math.pow(10, pow)
// log.debug("multiplier",multiplier);
var newPart = intPartofAmt*multiplier;
// log.debug("newPart",newPart);
restructuredAmt += newPart;
// log.debug(stLogTitle, "loop - restructuredAmt - "+restructuredAmt);
}
restructuredAmt = restructuredAmt/100;
log.debug(stLogTitle, "amtToAllocate - "+amtToAllocate+" restructuredAmt - "+restructuredAmt);
sumOfReAllocations = sumOfReAllocations +restructuredAmt//amtToAllocate;
log.debug(stLogTitle, "sumOfReAllocations - "+sumOfReAllocations);
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'credit',
value: restructuredAmt// (objValues.department!=2)?amtToAllocate:(amtToAllocate-.01)
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'entity',
value: objValues.clientInternalId
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'department',
value: objValues.department
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'class',
value: key
});
objJE.commitLine({
sublistId:'line'
});
var justSet = objJE.getSublistValue({sublistId: "line",
fieldId: "credit", line: lineCounter});
log.debug("Recently Set Line - "+lineCounter, " Amount - "+justSet);
}
lineCounter++;
}
//debit recognition account, amount, memo (original trans/JE?), client, dept,
//general key acct (class), NScontract # (text), element # (text), contract rec (internal id)
objJE.selectNewLine({
sublistId: 'line'
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'account',
value: objValues.recognitionAcct
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'debit',
value: objValues.amount
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'memo',
value: "Original Recognition JE #"+objValues.journal
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'entity',
value: objValues.clientInternalId
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'department',
value: objValues.department
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'class',
value: 2
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'custcol_contract_no',
value: objValues.sourceTrans
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'custcol_nxt_contract_record',
value: objValues.sourceInternalId
});
objJE.setCurrentSublistValue({
sublistId: 'line',
fieldId: 'custcol_element_no',
value: objValues.element
});
objJE.commitLine({
sublistId:'line'
});
var lineCounter = objJE.getLineCount({sublistId: "line"})-1;
var justSet = objJE.getSublistValue({
sublistId: "line",
fieldId: "debit",
line: lineCounter
});
log.debug("Recently Set Line - "+lineCounter, " Amount - "+justSet);
log.debug(stLogTitle, "Amount Debited: "+objValues.amount+" - Total Amount Credited: "+sumOfReAllocations );
}
var committedID = objJE.save();
battk
05/04/2020, 7:14 AMAFL
05/04/2020, 7:15 AMbattk
05/04/2020, 7:18 AMbattk
05/04/2020, 7:18 AMAFL
05/04/2020, 7:18 AMbattk
05/04/2020, 7:18 AMAFL
05/04/2020, 7:18 AMAFL
05/04/2020, 7:19 AMbattk
05/04/2020, 7:19 AMbattk
05/04/2020, 7:20 AMbattk
05/04/2020, 7:21 AMAFL
05/04/2020, 7:23 AMbattk
05/04/2020, 7:24 AMbattk
05/04/2020, 7:24 AMbattk
05/04/2020, 7:25 AMAFL
05/04/2020, 7:26 AMAFL
05/04/2020, 7:26 AMbattk
05/04/2020, 7:31 AMAFL
05/04/2020, 7:36 AMDaryl
05/04/2020, 7:36 AMbattk
05/04/2020, 7:37 AMbattk
05/04/2020, 7:37 AMAFL
05/04/2020, 7:37 AMAFL
05/04/2020, 7:37 AMAFL
05/04/2020, 7:37 AMAFL
05/04/2020, 7:38 AMAFL
05/04/2020, 7:39 AMbattk
05/04/2020, 7:40 AMAFL
05/04/2020, 7:41 AMAFL
05/04/2020, 7:41 AMAFL
05/04/2020, 7:42 AMAFL
05/04/2020, 7:42 AMAFL
05/04/2020, 7:42 AMbattk
05/04/2020, 7:45 AMbattk
05/04/2020, 7:45 AMAFL
05/04/2020, 7:46 AMAFL
05/04/2020, 7:47 AMbattk
05/04/2020, 7:48 AMbattk
05/04/2020, 7:48 AMbattk
05/04/2020, 7:49 AMbattk
05/04/2020, 7:49 AMAFL
05/04/2020, 7:57 AMAFL
05/04/2020, 7:57 AMbattk
05/04/2020, 8:12 AMbattk
05/04/2020, 8:13 AMAFL
05/04/2020, 8:14 AM