Add purpose code if available

This commit is contained in:
David Bomba 2024-05-15 20:57:40 +10:00
parent a212c04ace
commit f7fb20a7ec

View File

@ -82,13 +82,22 @@ class EpcQrGenerator
$this->company->present()->name(), $this->company->present()->name(),
isset($this->company?->custom_fields?->company1) ? $this->company->settings->custom_value1 : '', isset($this->company?->custom_fields?->company1) ? $this->company->settings->custom_value1 : '',
$this->formatMoney($this->amount), $this->formatMoney($this->amount),
$this->sepa['purpose'], $this->getPurposeCode(),
substr($this->invoice->number, 0, 34), substr($this->invoice->number, 0, 34),
'', '',
' ' ' '
]), "\n"); ]), "\n");
} }
private function getPurposeCode(): string
{
if(isset($this->invoice->client->id_number) && strlen($this->invoice->client->id_number) > 2)
return $this->invoice->client->id_number;
return $this->sepa['purpose'];
}
private function validateFields() private function validateFields()
{ {
if (Ninja::isSelfHost() && isset($this->company?->custom_fields?->company2)) { if (Ninja::isSelfHost() && isset($this->company?->custom_fields?->company2)) {