You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Technical Debt]: Unify signatures of model->save_value() functions #4459
Currently some model save_value functions take the database primary key as an optional second parameter. Other require the ID as a second parameter. Given that the first parameter is the data array, we shouldn't need a second parameter at all. if the primary key id is populated in the data array then it should be checked to see if the object exists in the database then update if it does. If it doesn't exist or the primary key is not populated in the data array first parameter then the object should be inserted into the database.
Remove second parameter.
Refactor logic in save_value() functions to look for the primary key id in the data array and update/insert accordingly
Refactor calling code to properly call the functions
Refactor function naming to saveValue() for PSR compliance
Additional Information
No response
Verify you searched open requests in OpensourcePOS
A repo-wide search for save_value( across app/Models/ confirms the inconsistency described is still there:
Item::save_value(array &$item_data, int $item_id = NEW_ENTRY): bool still carries the literal TODO // TODO: need to bring this in line with parent or change the name.
Some models take an optional second parameter defaulting to NEW_ENTRY (Person, Tax, Item_kit, Tax_category, Tax_jurisdiction, Item, Cashup), while others require it with no default (Dinner_table::save_value(array $table_data, int $dinner_table_id): bool, Item_quantity::save_value(array $location_detail, int $item_id, int $location_id): bool, Item_taxes::save_value(array &$items_taxes_data, int $item_id): bool, Customer_rewards::save_value(array $package_data, int $package_id): bool).
Rewards::save_value(array &$rewards_data, bool $rewards_id = false): bool even types its id parameter as bool rather than int.
None of these have been renamed to saveValue() for PSR-12 compliance, and none have been refactored to derive insert-vs-update purely from the primary key's presence in the data array — the id is still passed as an explicit second parameter everywhere.
No related PR addressing this unification was found. The technical debt described remains outstanding on master.
Activity
refactor: unify Item model save_value signature
objecttothis commentedon Oct 25, 2026
Claude Issue Checker Agent (cc @objecttothis)
Investigated against current
master.Status: Still present (refactor not done).
A repo-wide search for
save_value(acrossapp/Models/confirms the inconsistency described is still there:Item::save_value(array &$item_data, int $item_id = NEW_ENTRY): boolstill carries the literal TODO// TODO: need to bring this in line with parent or change the name.NEW_ENTRY(Person,Tax,Item_kit,Tax_category,Tax_jurisdiction,Item,Cashup), while others require it with no default (Dinner_table::save_value(array $table_data, int $dinner_table_id): bool,Item_quantity::save_value(array $location_detail, int $item_id, int $location_id): bool,Item_taxes::save_value(array &$items_taxes_data, int $item_id): bool,Customer_rewards::save_value(array $package_data, int $package_id): bool).Rewards::save_value(array &$rewards_data, bool $rewards_id = false): booleven types its id parameter asboolrather thanint.saveValue()for PSR-12 compliance, and none have been refactored to derive insert-vs-update purely from the primary key's presence in the data array — the id is still passed as an explicit second parameter everywhere.No related PR addressing this unification was found. The technical debt described remains outstanding on
master.