Thank you so much for implementing a native swiss qr solution!
Two questions:
although the configured languages in Ninja is german, the SPC slip is always shown in english?
(my browser and os is set to be english, but this should have any implications, should it?)
in the preview of an invoice (invoice → edit) the SPC is not shown; once downloaded it is included
$metadata->addPropertyConstraints('referenceNumber', [
// Only numbers are allowed (including leading zeros)
new Assert\Regex([
'pattern' => '/^\d*$/',
'match' => true
]),
new Assert\NotBlank()
]);
My dirty workaround in app/Helpers/SwissQr/SwissQrGenerator.php now always displays it:
if(stripos($this->invoice->number, "Live-") === 0)
{
// we're currently in preview status. Let's give a dummy reference for now
$invoicenumber = "123456789";
}
else
{
$invoicenumber = $this->invoice->number;
}
if(strlen($this->company->present()->besr_id()) > 1)
{
$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.
$invoicenumber // A number to match the payment with your internal data, e.g. an invoice number
);
Also, if your standard reference number includes anything else but numbers, SPC generation will fail.
I’m not sure if that’s standard conform, since Creditor Reference should also be possible (alphanumeric starting with RF (ISO 11649)). Will check with sprain/php-swiss-qr-bill author.
Thanks for this, I’ve ported your change into the repository for this and it will be available in the next release.
if(stripos($this->invoice->number, "Live-") === 0)
{
// we're currently in preview status. Let's give a dummy reference for now
$invoice_number = "123456789";
}
else
{
$invoice_number = $this->invoice->number;
}
// Localize QrBill output according to customer language.
// FIXME: anon array should match potential future translations of sprain/php-swiss-qr-bill
if (in_array($this->client->locale(), array('en','fr','de','it')))
{
$language = $this->client->locale();
}
else
{
// language not supported, fall back to 'en'
$language = 'en';
}
// Now get the QR code image and save it as a file.
try {
$output = new QrBill\PaymentPart\Output\HtmlOutput\HtmlOutput($qrBill, $language);
This works for me in order to localize qr bill text data for now.