NEW Show the exchange difference and allow re-aligning the invoice rate (option MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS) - #39667
Open
Pichinov-Jose wants to merge 1 commit into
Conversation
Pichinov-Jose
force-pushed
the
feat/multicurrency-exchange-difference
branch
from
August 22, 2026 18:52
a01157e to
33537e9
Compare
…te (option MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS) On a supplier invoice in a foreign currency settled at the real amounts, the company-currency value of what was paid differs from the invoice-rate conversion: that gap is the realised exchange gain or loss. - next to the exchange rate, show the realised exchange difference (foreign settled / invoice rate - real company amount paid); - an opt-in 'Align' button re-rates the invoice multicurrency_tx to the realised effective rate via setMulticurrencyRate() so the difference is absorbed; guarded by a confirm dialog, write permission, and refused once the invoice is recorded in accountancy; recorded payments and bank entries are left unchanged; a 'Restore' button reverts to the rate before the alignment; - an exchange gain/loss line is shown after 'Remainder to pay, original currency' in the totals block (red on loss, orange on gain); - a generic $morehtmlmulticurrencyrate slot is added to core/tpl/object_currency_amount.tpl.php to host content next to the rate (empty for other callers, no change); - no mutation by default: standard accounting settles the foreign debt at face value, the delta is an FX result. The accounting booking of the difference is out of scope here. NOTE for reviewers: the pre-alignment rate is currently backed up in a per-invoice constant (provisional, to be replaced by an extrafield or a column if preferred).
Pichinov-Jose
force-pushed
the
feat/multicurrency-exchange-difference
branch
from
August 22, 2026 19:01
33537e9 to
aa4b977
Compare
Pichinov-Jose
marked this pull request as ready for review
August 22, 2026 19:14
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.
Third part of the real-amounts series (builds on #39665 and #39666; independent code paths, reviewable on its own).
What this solves
An invoice in a foreign currency settled at the real amounts (#39665) keeps a residual in the company currency: the difference between the invoice-rate conversion and what was really paid — the realised exchange gain or loss. Today Dolibarr neither shows it nor offers anything to deal with it.
What it adds
Gated by option
MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS(off by default), on the supplier invoice card:multicurrency_txto the realised effective rate viasetMulticurrencyRate(), so the difference is absorbed — guarded by a confirm dialog and write permission, refused once the invoice is recorded in accountancy; recorded payments and bank entries are left unchanged. A Restore button reverts to the rate before the alignment.A generic
$morehtmlmulticurrencyrateslot is added tocore/tpl/object_currency_amount.tpl.phpto host content next to the rate (empty for other callers, no change for them).NOTE for reviewers: the pre-alignment rate is currently backed up in a per-invoice constant (provisional — an extrafield or a column can replace it if preferred).
Accounting follow-up — input welcome from @eldy and @aspangaro
This PR deliberately stops at measuring and displaying the realised exchange difference (plus the opt-in Align convenience). The proper accounting treatment is a planned follow-up we would like to design with the accountancy maintainers rather than improvise here:
Our position so far: the invoice keeps its face value in the foreign currency, the payments record the real amounts (#39665), and the company-currency residual is an FX result that belongs to the accountancy module — not to the invoice. The Align button is only an opt-in for users who prefer to absorb the difference before the transfer to accountancy (it is refused after). Scope and design of the booking part are open — happy to adjust or split as you prefer.
Tested
USD/TWD supplier invoices paid at real amounts: difference displayed next to the rate and in the totals, Align absorbs it (foreign balance unchanged, payments untouched), Restore brings the previous rate back, both refused after transfer to accountancy.
Here is a screenshot:
