Reversal of journal lines using Suitescript

In order to reverse the Journal lines, we can use a script to fetch the line count and the line field values.
After fetching the values the lines can be reversed added to the existing Journal lines.

accountLines = accountLines.concat(accountLines.slice().reverse());
amountsLines = amountsLines.concat(amountsLines.slice().reverse());
additionalSegments = additionalSegments.concat(additionalSegments.slice().reverse());


//Exceptional case of Setting amount
if (k % 2 == 0)
                        JE_PARENT.setCurrentSublistValue({sublistId: 'line', value: amountsLines[k], fieldId: 'debit'}); //Debit
                    else
                        JE_PARENT.setCurrentSublistValue({
                            sublistId: 'line',
                            value: amountsLines[k],
                            fieldId: 'credit'
                        }); //Credit

So if there are 3 lines, the new reversed Journal will have 6 lines with the accounts, amounts and other segments reversed.

Leave a comment

Your email address will not be published. Required fields are marked *