diff --git a/app/Helpers/Epc/EpcQrGenerator.php b/app/Helpers/Epc/EpcQrGenerator.php index 3c301f2b6c3b..b38dc7efcf5c 100644 --- a/app/Helpers/Epc/EpcQrGenerator.php +++ b/app/Helpers/Epc/EpcQrGenerator.php @@ -59,13 +59,13 @@ class EpcQrGenerator {$qr}"; } catch(\Throwable $e) { - // nlog("EPC QR failure => ".$e->getMessage()); + nlog("EPC QR failure => ".$e->getMessage()); return ''; } catch(\Exception $e) { - // nlog("EPC QR failure => ".$e->getMessage()); + nlog("EPC QR failure => ".$e->getMessage()); return ''; } catch(InvalidArgumentException $e) { - // nlog("EPC QR failure => ".$e->getMessage()); + nlog("EPC QR failure => ".$e->getMessage()); return ''; } @@ -73,20 +73,37 @@ class EpcQrGenerator public function encodeMessage() { - return rtrim(implode("\n", [ - $this->sepa['serviceTag'], - sprintf('%03d', $this->sepa['version']), - $this->sepa['characterSet'], - $this->sepa['identification'], - isset($this->company?->custom_fields?->company2) ? $this->company->settings->custom_value2 : '', - $this->company->present()->name(), - isset($this->company?->custom_fields?->company1) ? $this->company->settings->custom_value1 : '', - $this->formatMoney($this->amount), - $this->sepa['purpose'], - substr($this->invoice->number, 0, 34), - '', - ' ' - ]), "\n"); + // return rtrim(implode("\n", [ + // $this->sepa['serviceTag'], + // sprintf('%03d', $this->sepa['version']), + // $this->sepa['characterSet'], + // $this->sepa['identification'], + // isset($this->company?->custom_fields?->company2) ? $this->company->settings->custom_value2 : '', + // $this->company->present()->name(), + // isset($this->company?->custom_fields?->company1) ? $this->company->settings->custom_value1 : '', + // $this->formatMoney($this->amount), + // $this->sepa['purpose'], + // substr($this->invoice->number, 0, 34), + // '', + // ' ' + // ]), "\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); + } diff --git a/app/Services/EDocument/Standards/Peppol.php b/app/Services/EDocument/Standards/Peppol.php index 93cd1c5be5bb..7d2065df1e05 100644 --- a/app/Services/EDocument/Standards/Peppol.php +++ b/app/Services/EDocument/Standards/Peppol.php @@ -74,6 +74,7 @@ class Peppol extends AbstractService public function getInvoice(): \InvoiceNinja\EInvoice\Models\Peppol\Invoice { + //@todo - need to process this and remove null values return $this->p_invoice; } diff --git a/tests/Feature/EInvoice/PeppolTest.php b/tests/Feature/EInvoice/PeppolTest.php index 1e613c13457b..2933d571d488 100644 --- a/tests/Feature/EInvoice/PeppolTest.php +++ b/tests/Feature/EInvoice/PeppolTest.php @@ -117,10 +117,10 @@ class PeppolTest extends TestCase $invoice->service()->markSent()->save(); - $fat = new Peppol($invoice); - $fat->run(); + $peppol = new Peppol($invoice); + $peppol->run(); - $fe = $fat->getInvoice(); + $fe = $peppol->getInvoice(); $this->assertNotNull($fe); @@ -149,6 +149,6 @@ class PeppolTest extends TestCase $this->assertCount(0, $errors); - + nlog(json_encode($fe, JSON_PRETTY_PRINT)); } }