Posting Retail Statement Generates the error:
"Update for voucher XXXXX has been cancelled to avoid oversettlement. The settled customer or vendor balance for the transaction must not exceed the transaction amount."
You may run into this scenario when a POS transaction contains a sale and return on the same transaction for the same amount. The transaction subtotal will be $0.00 and there is a tax amount of .01 or -.01.
A good way to find if you have a POS transaction on your statement with a $0 subtotal and a tax amount would be to look at the RETAILTRANSACTIONTABLE where the NetAmount = 0 and the GrossAmount <> 0 (normally you will see a GrossAmount of .01 or -.01)
I would advise setting the Sales Tax Group for your store (General Ledger>>Setup>>Sales Tax>>Sales Tax Groups) to rounding by "Sales Tax Code Combination". For the Sales Tax Codes (General Ledger>>Setup>>Sales Tax>>Sales Tax Codes) set the Marginal base field to "Net amount per line". This will help going forward.
If you still receive the error, I would advise limiting your statement, by date and time, so only the transaction with the issue is included in the statement.
The following code change will allow the statement to post without the settlement. As always, try this in a test environment before running on production. Make sure no other statements are being posted manually or in a batch job or you will need to manually settle all transactions that are posted.
//toSettle = true;
totalCreditAmountCur = totalRoundAmountCur;
lastInvoiceId = transTable.invoiceId;
Once the statement is posted, change the toSettle back to true and you can manually settle the payment and invoice for the customer. You may need to create a transaction either positive or negative to bring the customer balance to 0 and settle the transaction created when the statement posted.