mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
SEPA EPC codes
This commit is contained in:
parent
f54f4b9200
commit
acb6b8e579
@ -45,8 +45,12 @@ class EpcQrGenerator
|
|||||||
);
|
);
|
||||||
$writer = new Writer($renderer);
|
$writer = new Writer($renderer);
|
||||||
|
|
||||||
|
$this->validateFields();
|
||||||
|
|
||||||
$qr = $writer->writeString($this->encodeMessage());
|
$qr = $writer->writeString($this->encodeMessage());
|
||||||
|
|
||||||
|
nlog($qr);
|
||||||
|
|
||||||
return "<svg viewBox='0 0 200 200' width='200' height='200' x='0' y='0' xmlns='http://www.w3.org/2000/svg'>
|
return "<svg viewBox='0 0 200 200' width='200' height='200' x='0' y='0' xmlns='http://www.w3.org/2000/svg'>
|
||||||
<rect x='0' y='0' width='100%'' height='100%' />{$qr}</svg>";
|
<rect x='0' y='0' width='100%'' height='100%' />{$qr}</svg>";
|
||||||
|
|
||||||
@ -60,9 +64,9 @@ class EpcQrGenerator
|
|||||||
sprintf('%03d', $this->sepa['version']),
|
sprintf('%03d', $this->sepa['version']),
|
||||||
$this->sepa['characterSet'],
|
$this->sepa['characterSet'],
|
||||||
$this->sepa['identification'],
|
$this->sepa['identification'],
|
||||||
$this->sepa['bic'],
|
isset($this->company?->custom_fields?->company2) ? $this->company->settings->custom_value2 : '',
|
||||||
$this->company->present()->name(),
|
$this->company->present()->name(),
|
||||||
$this->company?->custom_fields?->company1 ?: '',
|
isset($this->company?->custom_fields?->company1) ? $this->company->settings->custom_value1 : '',
|
||||||
$this->formatMoney($this->amount),
|
$this->formatMoney($this->amount),
|
||||||
$this->sepa['purpose'],
|
$this->sepa['purpose'],
|
||||||
substr($this->invoice->number,0,34),
|
substr($this->invoice->number,0,34),
|
||||||
@ -72,6 +76,17 @@ class EpcQrGenerator
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function validateFields()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isset($this->company?->custom_fields?->company2))
|
||||||
|
nlog('The BIC field is not present and _may_ be a required fields for EPC QR codes');
|
||||||
|
|
||||||
|
if(isset($this->company?->custom_fields?->company1))
|
||||||
|
nlog('The IBAN field is required');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function formatMoney($value) {
|
private function formatMoney($value) {
|
||||||
return sprintf('EUR%s', number_format($value, 2, '.', ''));
|
return sprintf('EUR%s', number_format($value, 2, '.', ''));
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace App\Utils;
|
namespace App\Utils;
|
||||||
|
|
||||||
|
use App\Helpers\Epc\EpcQrGenerator;
|
||||||
use App\Helpers\SwissQr\SwissQrGenerator;
|
use App\Helpers\SwissQr\SwissQrGenerator;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
use App\Models\CreditInvitation;
|
use App\Models\CreditInvitation;
|
||||||
@ -581,6 +582,11 @@ class HtmlEngine
|
|||||||
$data['$payments'] = ['value' => $payment_list, 'label' => ctrans('texts.payments')];
|
$data['$payments'] = ['value' => $payment_list, 'label' => ctrans('texts.payments')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->entity_string == 'invoice' && isset($this->company?->custom_fields?->company1))
|
||||||
|
{
|
||||||
|
$data['$sepa_qr_code'] = ['value' => (new EpcQrGenerator($this->company, $this->entity,$data['$amount_raw']['value']))->getQrCode(), 'label' => ''];
|
||||||
|
}
|
||||||
|
|
||||||
$arrKeysLength = array_map('strlen', array_keys($data));
|
$arrKeysLength = array_map('strlen', array_keys($data));
|
||||||
array_multisort($arrKeysLength, SORT_DESC, $data);
|
array_multisort($arrKeysLength, SORT_DESC, $data);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user