1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fixes for QR Ibans with no payment references

This commit is contained in:
David Bomba 2022-09-14 11:33:54 +10:00
parent 2845f2c79e
commit 895bb8deef
3 changed files with 29 additions and 10 deletions

View File

@ -26,6 +26,7 @@ class CompanySettings extends BaseSettings
public $auto_archive_invoice = false; // @implemented public $auto_archive_invoice = false; // @implemented
public $qr_iban = ''; //@implemented public $qr_iban = ''; //@implemented
public $besr_id = ''; //@implemented public $besr_id = ''; //@implemented
public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented

View File

@ -104,16 +104,32 @@ class SwissQrGenerator
// Add payment reference // Add payment reference
// This is what you will need to identify incoming payments. // 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( if(strlen($this->company->present()->besr_id()) > 1)
QrBill\DataGroup\Element\PaymentReference::create( {
QrBill\DataGroup\Element\PaymentReference::TYPE_QR, nlog("i have a besr");
$referenceNumber
)); $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. // Optionally, add some human-readable information about what the bill is for.
$qrBill->setAdditionalInformation( $qrBill->setAdditionalInformation(
@ -141,6 +157,8 @@ class SwissQrGenerator
nlog($violation); nlog($violation);
} }
nlog($e->getMessage());
return ''; return '';
// return $e->getMessage(); // return $e->getMessage();
} }

View File

@ -168,7 +168,7 @@ class HtmlEngine
$data['$invoice.vendor'] = ['value' => $this->entity->vendor->present()->name(), 'label' => ctrans('texts.vendor_name')]; $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{ try{
$data['$swiss_qr'] = ['value' => (new SwissQrGenerator($this->entity, $this->company))->run(), 'label' => '']; $data['$swiss_qr'] = ['value' => (new SwissQrGenerator($this->entity, $this->company))->run(), 'label' => ''];