mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 05:44:32 -04:00
Process Invoice Numbers which includes letters
-Using custom Invoice Number Patterns like R-ABC-P224301 breaks the QR Bill Generation -This solution loops through the Invoice Number and translates letter into ASCII -Makes sure that the field Additional Information not shows the wrong content
This commit is contained in:
parent
577f2a4809
commit
b2e3ea53d0
@ -112,7 +112,34 @@ class SwissQrGenerator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$invoice_number = $this->invoice->number;
|
$tempInvoiceNumber = $this->invoice->number;
|
||||||
|
$tempInvoiceNumber = preg_replace('/[^A-Za-z0-9]/', '', $tempInvoiceNumber);
|
||||||
|
$tempInvoiceNumber = substr($tempInvoiceNumber, 1);
|
||||||
|
|
||||||
|
$calcInvoiceNumber = "";
|
||||||
|
$array = str_split($tempInvoiceNumber);
|
||||||
|
foreach($array as $char)
|
||||||
|
{
|
||||||
|
if (is_numeric($char))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($char)
|
||||||
|
{
|
||||||
|
$char = strtolower($char);
|
||||||
|
$char = ord($char) - 96;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$calcInvoiceNumber .= $char;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoice_number = $calcInvoiceNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strlen($this->company->present()->besr_id()) > 1)
|
if(strlen($this->company->present()->besr_id()) > 1)
|
||||||
@ -141,7 +168,7 @@ class SwissQrGenerator
|
|||||||
// 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(
|
||||||
$this->invoice->public_notes ? substr($this->invoice->public_notes, 0, 139) : ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice_number])
|
$this->invoice->public_notes ? substr($this->invoice->public_notes, 0, 139) : ctrans('texts.invoice_number_placeholder', ['invoice' => $this->invoice->number])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user