minor fixes

This commit is contained in:
David Bomba 2024-06-11 07:22:04 +10:00
parent f7bd62d84a
commit 32744d3fa8
3 changed files with 39 additions and 21 deletions

View File

@ -59,13 +59,13 @@ class EpcQrGenerator
<rect x='0' y='0' width='100%'' height='100%' />{$qr}</svg>"; <rect x='0' y='0' width='100%'' height='100%' />{$qr}</svg>";
} catch(\Throwable $e) { } catch(\Throwable $e) {
// nlog("EPC QR failure => ".$e->getMessage()); nlog("EPC QR failure => ".$e->getMessage());
return ''; return '';
} catch(\Exception $e) { } catch(\Exception $e) {
// nlog("EPC QR failure => ".$e->getMessage()); nlog("EPC QR failure => ".$e->getMessage());
return ''; return '';
} catch(InvalidArgumentException $e) { } catch(InvalidArgumentException $e) {
// nlog("EPC QR failure => ".$e->getMessage()); nlog("EPC QR failure => ".$e->getMessage());
return ''; return '';
} }
@ -73,20 +73,37 @@ class EpcQrGenerator
public function encodeMessage() public function encodeMessage()
{ {
return rtrim(implode("\n", [ // return rtrim(implode("\n", [
$this->sepa['serviceTag'], // $this->sepa['serviceTag'],
sprintf('%03d', $this->sepa['version']), // sprintf('%03d', $this->sepa['version']),
$this->sepa['characterSet'], // $this->sepa['characterSet'],
$this->sepa['identification'], // $this->sepa['identification'],
isset($this->company?->custom_fields?->company2) ? $this->company->settings->custom_value2 : '', // isset($this->company?->custom_fields?->company2) ? $this->company->settings->custom_value2 : '',
$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->sepa['purpose'],
substr($this->invoice->number, 0, 34), // substr($this->invoice->number, 0, 34),
'', // '',
' ' // ' '
]), "\n"); // ]), "\n");
$data = [
'BCD',
'002', // Version
'1', // Encoding: 1 = UTF-8
'SCT', // Service Tag: SEPA Credit Transfer
isset($this->company?->custom_fields?->company2) ? $this->company->settings->custom_value2 : '', // BIC
$this->company->present()->name(), // Name of the beneficiary
isset($this->company?->custom_fields?->company1) ? $this->company->settings->custom_value1 : '', // IBAN
$this->formatMoney($this->amount), // Amount with EUR prefix
'', // Reference
substr($this->invoice->number, 0, 34) // Unstructured remittance information
];
return implode("\n", $data);
} }

View File

@ -74,6 +74,7 @@ class Peppol extends AbstractService
public function getInvoice(): \InvoiceNinja\EInvoice\Models\Peppol\Invoice public function getInvoice(): \InvoiceNinja\EInvoice\Models\Peppol\Invoice
{ {
//@todo - need to process this and remove null values
return $this->p_invoice; return $this->p_invoice;
} }

View File

@ -117,10 +117,10 @@ class PeppolTest extends TestCase
$invoice->service()->markSent()->save(); $invoice->service()->markSent()->save();
$fat = new Peppol($invoice); $peppol = new Peppol($invoice);
$fat->run(); $peppol->run();
$fe = $fat->getInvoice(); $fe = $peppol->getInvoice();
$this->assertNotNull($fe); $this->assertNotNull($fe);
@ -149,6 +149,6 @@ class PeppolTest extends TestCase
$this->assertCount(0, $errors); $this->assertCount(0, $errors);
nlog(json_encode($fe, JSON_PRETTY_PRINT));
} }
} }