Tim Roberson
06/24/2026, 4:21 PMCeligo AI
06/24/2026, 4:21 PMAI generated answer (using internal Slack threads):The error
TRANS_UNBALNCD or Transaction was not in balance typically occurs when there is an imbalance in the transaction, often due to missing or incorrect values in one of the line items, tax items, shipping items, discount items, etc. This could also happen if you are modifying the transaction after it has been posted, which can cause an imbalance in the amounts due to changes in tax or other factors.
In your case, it seems like the error is related to the Shipping Cost of the invoice. You might want to check if the shipping cost is correctly calculated and applied to the invoice. Also, ensure that all the necessary fields related to the shipping cost are correctly filled.
If you are using a script to create the Small Balance Write Off credit memos, you might want to check the script for any errors or missing values. Make sure that the script correctly calculates and applies the shipping cost to the invoice.
Here is a sample code snippet that might help you troubleshoot the issue:
javascript
var paymentObj = record.transform({
fromType: record.Type.INVOICE,
fromId: invoiceId,
toType: record.Type.CUSTOMER_PAYMENT,
isDynamic: true
});
paymentObj.setValue({ fieldId: 'paymentoption', value: paymentMethod });
paymentObj.setValue({ fieldId: 'checknumber', value: checkNumber });
paymentObj.setValue({ fieldId: 'payment', value: paymentAmount });
var lineCount = paymentObj.getLineCount({
sublistId: 'apply'
});
for (var i = 0; i < lineCount; i++) {
var lineInvoiceId = paymentObj.getSublistValue({ sublistId: 'apply', fieldId: 'internalid', line: i });
if(lineInvoiceId == invoiceId){
paymentObj.selectLine({
sublistId: 'apply',
line: i
});
paymentObj.setCurrentSublistValue({ sublistId: 'apply', fieldId: 'apply', value: true});
paymentObj.setCurrentSublistValue({ sublistId: 'apply', fieldId: 'amount', value: paymentAmount });
paymentObj.commitLine({
sublistId: 'apply'
});
}
}
var paymentId = paymentObj.save();
This script transforms an invoice into a customer payment and sets the necessary values. It then loops through the line items and applies the payment to the correct invoice. If the invoice ID matches the line invoice ID, it selects the line and sets the 'apply' and 'amount' fields. Finally, it commits the line and saves the payment.
Please note that this is just a sample script and might need to be adjusted according to your specific requirements.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
06/24/2026, 4:22 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.879516721
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.874145687
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.872375548
Celigo AI
06/24/2026, 4:22 PM