Add support for QR IBAN and reference
This commit is contained in:
parent
408b958226
commit
0b5bf953d7
|
|
@ -857,7 +857,7 @@ class pdf_swissqr extends ModelePDFFactures
|
||||||
// Add page for the Swiss QR-invoice
|
// Add page for the Swiss QR-invoice
|
||||||
$pdf->AddPage();
|
$pdf->AddPage();
|
||||||
$this->_pagehead($pdf, $object, 0, $outputlangs);
|
$this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||||
$this->qrinvoice($pdf, $object, $outputlangs);
|
$this->qrinvoice($pdf, $object, $outputlangs, $conf);
|
||||||
|
|
||||||
$pdf->Close();
|
$pdf->Close();
|
||||||
|
|
||||||
|
|
@ -898,8 +898,9 @@ class pdf_swissqr extends ModelePDFFactures
|
||||||
* @param object TFTP object
|
* @param object TFTP object
|
||||||
* @param object the Dolibarr invoice object
|
* @param object the Dolibarr invoice object
|
||||||
* @param object the Dolibarr langs object
|
* @param object the Dolibarr langs object
|
||||||
|
* @param object the Dolibarr configuration
|
||||||
*/
|
*/
|
||||||
protected function qrinvoice($pdf, $object, $langs)
|
protected function qrinvoice($pdf, $object, $langs, $conf)
|
||||||
{
|
{
|
||||||
// Create a new instance of QrBill, containing default headers with fixed values
|
// Create a new instance of QrBill, containing default headers with fixed values
|
||||||
$qrBill = QrBill\QrBill::create();
|
$qrBill = QrBill\QrBill::create();
|
||||||
|
|
@ -918,6 +919,44 @@ class pdf_swissqr extends ModelePDFFactures
|
||||||
QrBill\DataGroup\Element\CreditorInformation::create($object->iban // This is a special QR-IBAN. Classic IBANs will not be valid here.
|
QrBill\DataGroup\Element\CreditorInformation::create($object->iban // This is a special QR-IBAN. Classic IBANs will not be valid here.
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$creditorInformation = QrBill\DataGroup\Element\CreditorInformation::create($object->iban);
|
||||||
|
|
||||||
|
if ($creditorInformation->containsQrIban()) {
|
||||||
|
|
||||||
|
$ref = $object->ref;
|
||||||
|
|
||||||
|
if (str_contains($ref, 'FA'))
|
||||||
|
{
|
||||||
|
// Remove FA and - from the invoice reference
|
||||||
|
$ref = str_replace('FA', '', $ref);
|
||||||
|
$ref = str_replace('-', '', $ref);
|
||||||
|
} else {
|
||||||
|
$ref = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add payment reference for QR-IBAN
|
||||||
|
// This is what you will need to identify incoming payments.
|
||||||
|
$referenceNumber = QrBill\Reference\QrPaymentReferenceGenerator::generate(
|
||||||
|
$conf->global->SI_SWISSQR_REF, // You receive this number from your bank (BESR-ID). Unless your bank is PostFinance, in that case use NULL.
|
||||||
|
$ref // 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 {
|
||||||
|
// Add payment reference CLASSIC-IBAN
|
||||||
|
// This is what you will need to identify incoming payments.
|
||||||
|
$qrBill->setPaymentReference(
|
||||||
|
QrBill\DataGroup\Element\PaymentReference::create(
|
||||||
|
QrBill\DataGroup\Element\PaymentReference::TYPE_NON
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Add debtor information
|
// Add debtor information
|
||||||
// Who has to pay the invoice? This part is optional.
|
// Who has to pay the invoice? This part is optional.
|
||||||
$qrBill->setUltimateDebtor(
|
$qrBill->setUltimateDebtor(
|
||||||
|
|
@ -936,13 +975,6 @@ class pdf_swissqr extends ModelePDFFactures
|
||||||
$object->total_ttc
|
$object->total_ttc
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add payment reference
|
|
||||||
$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(
|
||||||
QrBill\DataGroup\Element\AdditionalInformation::create(
|
QrBill\DataGroup\Element\AdditionalInformation::create(
|
||||||
|
|
@ -973,7 +1005,6 @@ class pdf_swissqr extends ModelePDFFactures
|
||||||
$output->setPrintable(false)->getPaymentPart();
|
$output->setPrintable(false)->getPaymentPart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue