diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index ecc93b0d42..f99d52ce5d 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -26,6 +26,7 @@ class CompanySettings extends BaseSettings public $auto_archive_invoice = false; // @implemented public $qr_iban = ''; //@implemented + public $besr_id = ''; //@implemented public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented diff --git a/app/Helpers/SwissQr/SwissQrGenerator.php b/app/Helpers/SwissQr/SwissQrGenerator.php index 354b763921..0302fcc657 100644 --- a/app/Helpers/SwissQr/SwissQrGenerator.php +++ b/app/Helpers/SwissQr/SwissQrGenerator.php @@ -104,16 +104,32 @@ class SwissQrGenerator // Add payment reference // This is what you will need to identify incoming payments. - $referenceNumber = QrBill\Reference\QrPaymentReferenceGenerator::generate( - $this->company->present()->besr_id() ?: '', // You receive this number from your bank (BESR-ID). Unless your bank is PostFinance, in that case use NULL. - $this->invoice->number// A number to match the payment with your internal data, e.g. an invoice number - ); - $qrBill->setPaymentReference( - QrBill\DataGroup\Element\PaymentReference::create( - QrBill\DataGroup\Element\PaymentReference::TYPE_QR, - $referenceNumber - )); + if(strlen($this->company->present()->besr_id()) > 1) + { + nlog("i have a besr"); + + $referenceNumber = QrBill\Reference\QrPaymentReferenceGenerator::generate( + $this->company->present()->besr_id() ?: '', // You receive this number from your bank (BESR-ID). Unless your bank is PostFinance, in that case use NULL. + $this->invoice->number// A number to match the payment with your internal data, e.g. an invoice number + ); + + $qrBill->setPaymentReference( + QrBill\DataGroup\Element\PaymentReference::create( + QrBill\DataGroup\Element\PaymentReference::TYPE_QR, + $referenceNumber + )); + + } + else{ + + nlog("i have no besr"); + $qrBill->setPaymentReference( + QrBill\DataGroup\Element\PaymentReference::create( + QrBill\DataGroup\Element\PaymentReference::TYPE_NON + )); + + } // Optionally, add some human-readable information about what the bill is for. $qrBill->setAdditionalInformation( @@ -141,6 +157,8 @@ class SwissQrGenerator nlog($violation); } + nlog($e->getMessage()); + return ''; // return $e->getMessage(); } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index d9141493f4..dae1e0f8ad 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -168,7 +168,7 @@ class HtmlEngine $data['$invoice.vendor'] = ['value' => $this->entity->vendor->present()->name(), 'label' => ctrans('texts.vendor_name')]; } - if(strlen($this->company->getSetting('qr_iban')) > 5 && strlen($this->company->getSetting('besr_id')) > 1) + if(strlen($this->company->getSetting('qr_iban')) > 5) { try{ $data['$swiss_qr'] = ['value' => (new SwissQrGenerator($this->entity, $this->company))->run(), 'label' => ''];