From 066df875bc0a0384ab0d1ef46d970274f54c0860 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 May 2023 20:13:37 +0200 Subject: [PATCH] Fix error management --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 6 +++++- htdocs/core/modules/facture/modules_facture.php | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 607e4c01ecb..c55b6ce36bc 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -907,7 +907,11 @@ class pdf_crabe extends ModelePDFFactures } if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') { - $this->addBottomQRInvoice($pdf, $object, $outputlangs); + $result = $this->addBottomQRInvoice($pdf, $object, $outputlangs); + if (!$result) { + $pdf->Close(); + return 0; + } } $pdf->Close(); diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 2c55954b4e8..ae794fdb0b6 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -89,14 +89,17 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ private function getSwissQrBill(Facture $object, Translate $langs) { - global $conf; + if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') != 'bottom') { + return false; + } if ($object->mode_reglement_code != 'VIR') { $this->error = $langs->transnoentities("SwissQrOnlyVIR"); return false; } - if (empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) { + if (empty($object->fk_account)) { + $this->error = 'Bank account must be defined to use this experimental feature'; return false; }