Target repository: InvoicePlane (main app) · branch prep/v180
Related feature issues: #13 · #14
Depends on: #55 — DB migration · #56 — client form UI
What to do
1. Mdl_clients — add new columns to allowed fields
Add client_peppol_id and client_company_number to the allowed fields array in Mdl_clients so the standard save() call persists them automatically. No extra code is needed beyond this.
2. Client controller — meta upsert on save
After Mdl_clients->save(), explicitly upsert the two FatturaPA meta fields into ip_client_meta. These are not columns and are not saved by the model:
foreach (['client_einvoice_sdi_code', 'client_einvoice_pec_email'] as $key) {
$value = $this->input->post($key) ?: null;
// INSERT INTO ip_client_meta (client_id, meta_key, meta_value) VALUES (?, ?, ?)
// ON DUPLICATE KEY UPDATE meta_value = VALUES(meta_value)
}
Clearing a field (empty string submitted) should set the meta row to NULL or delete the row.
3. Client controller — meta load on edit
When loading a client for the edit form, read both meta keys back from ip_client_meta and pass them to the view:
$meta_rows = $this->db->get_where('ip_client_meta', ['client_id' => $id])->result();
$client_meta = array_column($meta_rows, 'meta_value', 'meta_key');
// Pass $client_meta['client_einvoice_sdi_code'] and ['client_einvoice_pec_email'] to view
Acceptance criteria
What to do
1. Mdl_clients — add new columns to allowed fields
Add
client_peppol_idandclient_company_numberto the allowed fields array inMdl_clientsso the standardsave()call persists them automatically. No extra code is needed beyond this.2. Client controller — meta upsert on save
After
Mdl_clients->save(), explicitly upsert the two FatturaPA meta fields intoip_client_meta. These are not columns and are not saved by the model:Clearing a field (empty string submitted) should set the meta row to
NULLor delete the row.3. Client controller — meta load on edit
When loading a client for the edit form, read both meta keys back from
ip_client_metaand pass them to the view:Acceptance criteria
client_peppol_idandclient_company_numbersaved via standardMdl_clients->save()client_einvoice_sdi_codeandclient_einvoice_pec_emailupserted intoip_client_metaafter save