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; }