Payment cannot process due to currency difference

Dear Tryton Community,

I have a problem with the account_invoice module where I have cases in which invoices payments cannot be processes because the following UserError exception pops up:

“Payment lines amount on invoice “#####” can not be greater than the invoice amount.”

Now this exception originates in the Invoice.check_payment_lines() function that basically blocks attempts to process a payment in which the payment amount is greater than the invoice amount to pay (overpayment). In common sense, this is a correct behavior, however there are cases that this “overpaid” amount will surface due to a currency exchange rate fluctuation. I will explain with the following example:

The company’s currency is in USD and we use a secondary currency which is CRC (Costa Rican Colon). We create an invoice for an item that cost $10USD and the customer will pay in CRC. The exchange rate at the moment of issue was 580 CRC = 1 USD. So the total invoice amount was 5800 CRC. We will ignore the taxes for now to keep the example simple. Internally Tryton stores the amount owned as $10USD in the receivables account.
Now 30 days later, when the customer pays the invoice (30 day credit payment term was used), the exchange rate happened to drop to 570 CRC = 1 USD. The customer proceeds to pay the 5800 CRC that was originally printed in the invoice, so now upon processing the payment, Tryton generates the reconcile lines for the amount in the company’s currency which is 5800 / 570 = $10.1754 USD. There is an overpayment amount of $0.1754 USD and the payment checks raises the exception.
Now, to my humble opinion, the correct way to process this overpayment amount is to handle it like a writeoff that goes into a exchange rate difference account.

Right now my solution is to disable this check, but I don’t know yet if there is any implication on doing so. Anyone have any comments about this?

Investigating a bit further for a better solution instead of ignoring the check, I tried adding a few lines of code in Invoice.check_payment_lines to sum the line.amount_second_currency if there is second currency available; and then check if there is overpayment in the second currency before raising the exception.

So this will still provide the accidental over payment checks but relaxes this check if the overpayment is due to currency exchange rate.

I could provide a patch, but don’t where to upload it.

This is wrong. You must not register payment on an invoice that is overpaid because it will fail to make a proper reconciliation.
In your case, you must not register the over payment directly on the invoice but in a move (usually you use a statement). Then you reconcile the over paid line with the invoice line and the wizard will ask for a write-off in this case.

Now we could improve the payment wizard on invoice to ask for the write-off in case of over payment and use it to make the reconciliation.

Hello Mr. Krier,

Thank you for your response. I have some further comments:

I have checked the moves that generates from the payment transaction with my modifications, and it appears that the reconciliation is working, the system handles the excess amount as a “negative” remainder and I just process it as a writeoff. In the normal transactions, the writeoff is a remainder amount not paid (covered) by the payment amount and becomes a loss for the company, but in my case it is a “credit” (gain/revenue) writeoff.

I don’t know how to use the statements module to submit (register) payments. I do know however, how to manually create a move by hand and register the payment but I believe this opens up too much the system and the person who process the payments could make mistakes. In addition, I believe the person does not necessary know in advanced if the payment under the secondary currency will turn out to be an “over payment” when converted into the company’s currency. So if by registering in a move only in the case of over payment is a bit awkward. He/she will have to convert (calculate) by hand the payment amount from the secondary currency back into the company’s currency and then decide which action to choose. I prefer to register it directly with a click of the “pay” button in the invoice.

I think with that change in the check_payments_line function that I am proposing, it is currently handling the over payment as a write off and generating the respective reconciliation. (I think)

Once again, thank you for your feedback.