Room types: data model, saving and delete protection
Structure of the room type master, the checks on saving, the two kinds of deletion and how the area calculation rules are stored.
The room type master is operator master data: it feeds the type selector of a property's room list and the rules for calculating the net usable area. It holds no company data, so it has no content scope.
Data model
Table names carry the installation's own prefix in the database.
| Table | Role | Main fields |
|---|---|---|
room_type | the type and its rule; unique code | code, counts_as, area_bucket, area_factor, threshold_pct, factor_over, half_room_max, sort_order, status |
room_type_description | name per language (max. 64 characters) | room_type_id, language_id, name |
The room row refers to the code (property_room.room_type). Public methods of the owning model used by other modules: getRules() (property form, saving, area calculation), getOptions() (room selector), ready().
Saving
- The code is lower-cased and must start with a letter and contain 2–32 lowercase letters, digits or underscores. Wrong: "Use 2–32 characters: lowercase letters, numbers, underscore, starting with a letter."; taken: "This code is already used by another room type."
- A name is needed in at least one language: "Enter the name in at least one language." Any error shows at the top: "Please check the highlighted fields."
- Shares arrive as percentages and are stored as factors (percentage divided by 100). The model writes through a whitelist: an unknown
counts_asbecomes other, an unknownarea_bucketbecomes net. Limits: factor 0–10, threshold 0–1000 %, half-room limit 0–1000. - After reading back: "Saved."; for a new record the response also returns the new ID, which the form writes into the hidden field so that the next save is an update.
States and deletion
- Status: 0 inactive, 1 active, 9 deleted (trash). The room selector offers only active types; the calculation uses the rule of every type that is not deleted.
- There is one delete endpoint. With the
deleteright a permanent deletion runs, but only if no room uses the code (counted by the property model'scountRoomsByType()); otherwise: "It cannot be deleted: 3 room(s) use this type. Deactivate it instead." This branch also runs when the user holds both delete rights. - With
statusdeleteonly, the row goes to the trash (status 9). A missing row: "The room type was not found."
Seed data
The migration adds 23 types with English, Hungarian and German names. Room types with a 12 m² half-room limit: living, bedroom, study, office. Net bucket at 100 % among others: kitchen, dining, hall, corridor, wardrobe, pantry, laundry, basement, attic, other. Terrace and balcony go to the terrace bucket at 50 % with a 50 % threshold and 30 % above it. Storage, garage and garden go to their own bucket at 0 %, pool and stairs to the other bucket at 0 %.
Permissions
- Base access: the menu path of the room type screen.
- Function rights (base package):
list,add,edit,statusdelete,delete,debug. Activation and deactivation belong toedit; the trash is visible only to users allowed to see deleted items. - Content scope: none, operator master data.
Known limitations
The data room and the REST export pass on the room's type code. The code does not show whether the data room prints the master name or a built-in caption.