i have this code, but it says "The amounts in a journal entry must balance." i am not able to find any thing wrong on this. could anyone please help sme?
for(var j = 0; j < (resultArray.length * 2); j++){
journalRecord.selectLine({
sublistId : 'line',
line : j
});
if(j === 0 || 2){
log.debug('j',j);
journalRecord.setCurrentSublistValue({
sublistId : 'line',
fieldId : 'account',
value : accountID,
ignoreFieldChange : true
});
if(nonDeductableP < 0)
log.debug('less than 0')
journalRecord.setCurrentSublistValue({
sublistId : 'line',
fieldId : 'debit',
value : (nonDeductableP * -1),
ignoreFieldChange : true
});
}else if (nonDeductableP > 0){
log.debug('greater than 0')
journalRecord.setCurrentSublistValue({
sublistId : 'line',
fieldId : 'credit',
value : nonDeductableP,
ignoreFieldChange : true
});
}
else if (j === 1 || 3){
log.debug('j',j);
journalRecord.setCurrentSublistValue({
sublistId : 'line',
fieldId : 'account',
value : 255,
ignoreFieldChange : true
});
if (nonDeductableP > 0){
log.debug('greater than 0')
journalRecord.setCurrentSublistValue({
sublistId : 'line',
fieldId : 'debit',
value : nonDeductableP,
ignoreFieldChange : true
});
}else if (nonDeductableP < 0){
log.debug('less than 0')
journalRecord.setCurrentSublistValue({
sublistId : 'line',
fieldId : 'credit',
value : (nonDeductableP * -1),
ignoreFieldChange : true
});
}
}