NEW Option MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS: enter the real amounts on multicurrency payments - #39665
Open
Pichinov-Jose wants to merge 1 commit into
Conversation
Pichinov-Jose
force-pushed
the
feat/multicurrency-payment-real-amounts
branch
from
August 22, 2026 17:33
5e3be59 to
9d9e15c
Compare
Pichinov-Jose
force-pushed
the
feat/multicurrency-payment-real-amounts
branch
from
August 22, 2026 18:35
9d9e15c to
a02ae67
Compare
…unts on multicurrency payments On a payment for an invoice in a foreign currency, Dolibarr derives one of the two amounts (company currency / invoice currency) from the other at the invoice rate. The amount really paid in the company currency almost always differs from that derivation, so the recorded payment does not match the bank. Under this option (off by default): - both the amount in the invoice currency and the real amount in the company currency can be entered on the payment pages (customer and supplier); a read-only derived exchange rate is displayed live; - Paiement/PaiementFourn::create() keep both amounts as entered, derive the per-invoice exchange rate from them and store it on the dispatch line; a warning is raised when the derived rate is far from the invoice rate (probable swap), an error when the signs differ; - the paid status is decided on the balance in the invoice currency: the residual amount in company currency is the exchange-rate difference; - the payment list of the invoice card and the invoice/payment tooltips show the amount in the invoice currency and the rate as a sub-line; - a payment whose foreign amount is missing can be fixed a posteriori from the payment card (hidden option MULTICURRENCY_PAYMENT_ALLOW_EDIT_REAL_AMOUNT, admin only).
Pichinov-Jose
force-pushed
the
feat/multicurrency-payment-real-amounts
branch
from
August 22, 2026 18:51
a02ae67 to
c1a2485
Compare
Pichinov-Jose
marked this pull request as ready for review
August 22, 2026 18:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this solves
On a payment for an invoice in a foreign currency, Dolibarr derives one of the two amounts (company currency / invoice currency) from the other at the invoice rate. The amount really paid in the company currency almost always differs from that derivation — the bank applies its own rate on the day of the transfer — so the recorded payment does not match the bank statement, and the reconciliation carries a phantom difference.
What it adds
Everything is gated by a new option
MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS(off by default — behaviour is strictly unchanged without it).Paiement::create()/PaiementFourn::create(): when both amounts are provided for an invoice, keep them as entered (no derivation), derive the per-invoice exchange rate and store it on the dispatch line. An error is raised when the two amounts have opposite signs, a non-blocking warning when the derived rate differs by more than 50% from the invoice rate (probable swap of the two fields).multicurrency_amount / amount), so a rate different from the invoice rate is visible at a glance. The payment tooltip (customer and supplier) and the supplier invoice tooltip show the same information (amount in the invoice currency, rate).MULTICURRENCY_PAYMENT_ALLOW_EDIT_REAL_AMOUNTplus admin rights.Relationship with #38972 (@lvessiller)
The merged fix #38972 stores the invoice currency code/rate on the dispatch line when the caller does not fill the arrays. This PR integrates with it: in real-amounts mode the per-invoice derived rate is set into
$this->multicurrency_tx[$key], which that fallback then naturally respects; without the option, the fallback behaviour is unchanged.Compatibility
multicurrency_amount/multicurrency_tx.Tested
Supplier and customer flows on real USD/TWD invoices: payment recorded with the real amounts, per-invoice derived rate stored, paid status set from the foreign balance, residual company-currency amount visible as the exchange difference.
Here is a screenshot:
Here are the tooltip and sublines orders screenshots: