Fix balance and test currency

This commit is contained in:
Benoit Vianin 2025-08-30 13:25:59 +00:00
parent 5ad5a0ba56
commit 92fc11e58b
1 changed files with 13 additions and 8 deletions

View File

@ -175,7 +175,7 @@ class pdf_swissqr extends pdf_sponge
$amount_deposits_included = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0); $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
$total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$balance = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); $balance = price2num($total_ttc - $deja_regle - $amount_credit_notes_included - $amount_deposits_included, 'MT');
if ($balance < 0) { if ($balance < 0) {
$balance = 0; $balance = 0;
@ -183,6 +183,7 @@ class pdf_swissqr extends pdf_sponge
$currencyinvoicecode = $object->multicurrency_code ? $object->multicurrency_code : $conf->currency; $currencyinvoicecode = $object->multicurrency_code ? $object->multicurrency_code : $conf->currency;
if ($currencyinvoicecode == "CHF" || $currencyinvoicecode == "EUR") {
// Add payment amount information // Add payment amount information
// What amount is to be paid? // What amount is to be paid?
$qrBill->setPaymentAmountInformation( $qrBill->setPaymentAmountInformation(
@ -190,6 +191,10 @@ class pdf_swissqr extends pdf_sponge
$currencyinvoicecode, $currencyinvoicecode,
$balance $balance
)); ));
} else {
$this->error = "Only CHF or EUR currencies accepted";
return false;
}
// Optionally, add some human-readable information about what the bill is for. // Optionally, add some human-readable information about what the bill is for.
$qrBill->setAdditionalInformation( $qrBill->setAdditionalInformation(