Target repository: InvoicePlane-e-invoices · branch develop
Related feature issues: #13 · #15
Required by: #16, #17, #18, #19, #20, #21
Problem
New v1.8.0 fields are split across two storage layers:
- Standard columns (
client_peppol_id, client_company_number) — already present on the $client object, no change needed
- Meta key→value pairs (
client_einvoice_sdi_code, client_einvoice_pec_email, invoice_routing_code_1/2/3) — stored in ip_client_meta / ip_invoice_meta, not on the main objects
Generators currently receive $client and $invoice objects only. They have no way to access meta values. This must be solved before any generator can implement SdI/PEC routing (#19) or routing codes (#16, #17, #20).
What to do
1. E-invoicing controller (main app) — load meta before generator call
Before calling any generator, load both meta arrays:
$client_meta_rows = $this->db->get_where('ip_client_meta', ['client_id' => $client->client_id])->result();
$client_meta = array_column($client_meta_rows, 'meta_value', 'meta_key');
$invoice_meta_rows = $this->db->get_where('ip_invoice_meta', ['invoice_id' => $invoice->invoice_id])->result();
$invoice_meta = array_column($invoice_meta_rows, 'meta_value', 'meta_key');
Pass both arrays to the generator constructor or a new setMeta() method.
2. BaseXml — store meta as properties
Add $client_meta and $invoice_meta as protected properties on BaseXml so every subclass can access them:
protected array $client_meta = [];
protected array $invoice_meta = [];
3. Safe access pattern (all generators)
$value = $this->client_meta['client_einvoice_sdi_code'] ?? null;
$code1 = $this->invoice_meta['invoice_routing_code_1'] ?? null;
// null-safe — no PHP warning if key absent
Acceptance criteria
Problem
New v1.8.0 fields are split across two storage layers:
client_peppol_id,client_company_number) — already present on the$clientobject, no change neededclient_einvoice_sdi_code,client_einvoice_pec_email,invoice_routing_code_1/2/3) — stored inip_client_meta/ip_invoice_meta, not on the main objectsGenerators currently receive
$clientand$invoiceobjects only. They have no way to access meta values. This must be solved before any generator can implement SdI/PEC routing (#19) or routing codes (#16, #17, #20).What to do
1. E-invoicing controller (main app) — load meta before generator call
Before calling any generator, load both meta arrays:
Pass both arrays to the generator constructor or a new
setMeta()method.2. BaseXml — store meta as properties
Add
$client_metaand$invoice_metaas protected properties onBaseXmlso every subclass can access them:3. Safe access pattern (all generators)
Acceptance criteria
$client_metaand$invoice_metaavailable in every generator viaBaseXmlpropertiesnullsafely — no PHP warnings[]