1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

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>";
} 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);
}

View File

@ -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;
}

View File

@ -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));
}
}