Wednesday, July 30, 2008

Customer payment journal - Oversettlement

In Axapta 3.0, when you post a customer payment journal, sometimes it will just give you a dumb error message "Update has been canceled." without explaining what is going wrong that prevent you from posting the journal. One of the reasons that causing this error is due to you are trying to perform an oversettlement for the customer account, in other words, you are trying to making your company owing money to your customer and have a negative customer balance.

To simulate this problem, say there is an open credit note (CN) transaction -$100 and invoice transaction $25. Due to whatever reason, the customer is going to pay you $20, and you want to offset the balance from the CN. So, in the customer payment journal, you click Funtions\Settlement button and mark these 2 transactions. Then, in the journal lines, you manually overwrite the Credit amount to $20 since you are going to receive only $20 from the customer. You validate the journal and system is telling you Journal is OK. But when you post the journal, the above-mentioned error message is prompt out.

Without debugging the X++ code, you might need some time to find out the cause. The error is actually thrown out from \Classes\CustVendSettle\checkCreditRemainAmountCur() method.

First, let's look at some of the details for CustTrans table's AmountCur and SettleAmountCur fields.
When CustTrans.AmountCur > 0, it is a Invoice transaction.
When CustTrans.AmountCur < 0, it is a Payment transaction.

When posting a customer payment:-
CustTrans.AmountCur is negative value, because you are crediting the customer balance. CustTrans.SettleAmountCur must be same sign as CustTrans.AmountCur, so in this case, it could only be either zero, same negative value as AmountCur or differrent negative value.
1) Zero value
No invoice is marked for settlement against the payment transaction.

2) Same negative value as AmountCur
Payment transation is fully settled with marked invoice transaction(s) that have total invoice amount same or larger than payment amount.
Eg1. payment = 100, marked invoice = 100, so AmountCur = -100, SettleAmountCur = -100 Eg2. payment = 100, marked invoice = 120, so AmountCur = -100, SettleAmountCur = -100 (Thus, the payment transaction is fully settled, but there is 20 balance for the invoice transaction)

3) Different negative value, but smaller value than AmountCur.
This is a partial settlement for the payment transaction.
Eg. payment = 100, marked invoice = 20, so AmountCur = -100, SettleAmountCur = -20

When CustTrans.SettleAmountCur is positive, it means it is in the oversettlement situation. In the above senario, the SettleAmountCur is $75 (This is derived from the sum amount of marked transactions CN-$100 and Invoice $25, but the sign would be inverted because it is a settlement. In a normal situation eg. mark against a invoice transaction $10, the CustTrans.SettleAmountCur will be sum of the invoice amount with inverted sign, -$10).

In to the above senario, due to the different sign of CustTrans.AmountCur (-$20) and CustTrans.SettleAmountCur (+$75), the system throw an error "Update has been canceled."

Solution?
First, you should only mark the invoice transaction $25 in the payment journal. Then, use the Open transaction editing function to settle the balance $5 in the invoice transaction against the CN transaction.

In Dynamics AX 4.0 onwards, it has been improved as it is giving a more meaningful error message "Update has been canceled because of a potential oversettlement. The Balance on a customer- or vendor transaction must not exceed the amount.".

2 comments:

COA said...

I am working on Axapta 3.0 SP5. I have two transactions one has balance 1000 and another one has balance -200. I want to partially settle first transaction with another one. I have written the following code:
CustTable currentCustTable;
CustTrans settleTrans;
CustTrans settleWith;

settleWith.markForSettlement(settleTrans);
CustTrans::settleTransact(currentCustTable);

And as a result first transaction is marked for settlement but the balance isn’t changed.
Please help. How can I do this?

chingnoi said...

Hi there,
i just curious about the same error log

" Update has been canceled because of a potential oversettlement.
The Balance on a customer- or vendor transaction must not exceed the amount."

the fact is 2 lines in 'open transaction editing'(AP>Function) which has the same amount. One is debit and the other is credit. This looks like we can update, right? but after we try to update. It shows the mentioned log.

I wonder if you can help me.
Thank you for reading. :)