You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NEW Option MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS: enter the real amounts 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).
@@ -502,7 +551,7 @@ public function create($user, $closepaidinvoices = 0, $thirdparty = null)
502
551
503
552
if (!in_array($invoice->type, $affected_types)) {
504
553
dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more.");
505
-
} elseif ($remaintopay) {
554
+
} elseif ($remaintopayforclosure) {
506
555
// hook to have an option to automatically close a closable invoice with less payment than the total amount (e.g. agreed cash discount terms)
507
556
global$hookmanager;
508
557
$hookmanager->initHooks(array('paymentdao'));
@@ -566,22 +615,46 @@ public function create($user, $closepaidinvoices = 0, $thirdparty = null)
566
615
}
567
616
}
568
617
618
+
// Option MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS: carry the invoice currency and the real exchange
619
+
// rate onto the discount, and scale its company-currency value to the real amount paid, so the real
620
+
// cost propagates when the deposit is later consumed in a final invoice. Without the option, nothing changes.
621
+
$discountmccode = '';
622
+
$discountmctx = null;
623
+
$discountrealratio = 1;
624
+
if (getDolGlobalInt('MULTICURRENCY_PAYMENT_USE_REAL_AMOUNTS') && isModEnabled('multicurrency')
0 commit comments