Updates for e-invoicing

This commit is contained in:
David Bomba 2024-09-03 09:02:46 +10:00
parent 8b8a5e3148
commit f85e96c3a6

View File

@ -307,7 +307,7 @@ class Peppol extends AbstractService
if($this->invoice->e_invoice) {
$this->p_invoice = $this->e->decode('Peppol', json_encode($this->invoice->e_invoice), 'json');
$this->p_invoice = $this->e->decode('Peppol', json_encode($this->invoice->e_invoice->Invoice), 'json');
return $this;
@ -402,7 +402,7 @@ class Peppol extends AbstractService
*/
public function toArray(): array
{
return json_decode($this->toJson(), true);
return ['Invoice' => json_decode($this->toJson(), true)];
}
/**
@ -1046,6 +1046,24 @@ class Peppol extends AbstractService
*/
public function setInvoiceDefaults(): self
{
// Stub new invoice with company settings.
if($this->_company_settings)
{
foreach(get_object_vars($this->_company_settings) as $prop => $value){
$this->p_invoice->{$prop} = $value;
}
}
// Overwrite with any client level settings
if($this->_client_settings)
{
foreach (get_object_vars($this->_client_settings) as $prop => $value) {
$this->p_invoice->{$prop} = $value;
}
}
// Plucks special overriding properties scanning the correct settings level
$settings = [
'AccountingCostCode' => 7,
'AccountingCost' => 7,