SET · Settings
Each organization has one settings row. A pool may override a few of its values; an empty pool value means the organization's applies. app.setting(pool, key) returns the value that applies. Code SET.
Answered questions
Section titled “Answered questions”-
DOC-Q10, SET open 1 (is there always an organization row to fall back to): yes. A new rule, R-SET-06: the settings row is created with the organization.
-
The settings tabs (#459, zuki and the lead, 2026-11-17): organization and pool settings are written only through database functions (R-SET-17); the organization tab edits every column, max_repossessions (R-SET-10) and cp_skip_weeks_limit (R-SET-11) included, each within its bounds (R-SET-18 to R-SET-20). Saving a pool's value empty makes the organization's apply (R-SET-21). R-SET-12, the service interval by powertrain, came in the carry-over slice #650 (#666).
Not yet a rule
Section titled “Not yet a rule”- Which settings a pool can override, after the review. It stays open after #144. R-SET-09 lists what pool_settings holds today, max_queue_miss included (D43, R-SET-08); R-INSP-06's checkpoint_interval_weeks is in it as V13 had it.
R-SET-01 · A pool's setting, when set, overrides the organization's; when empty, the organization's applies
Section titled “R-SET-01 · A pool's setting, when set, overrides the organization's; when empty, the organization's applies”- Status: built
- Example: given the organization's checkpoint_interval_weeks is 2 and pool SBY sets 1, when app.setting(SBY, 'checkpoint_interval_weeks') is read, then it returns 1; for pool PML, with no value of its own, it returns 2.
- Refusal: none.
- Who: every reader of a setting: the gate, the checkpoint list, the queue.
- Source: D9 (P10, S2); the M0 acceptance checks.
R-SET-02 · Only queue opening, queue hours, tickets per phone and the checkpoint interval can be set per pool
Section titled “R-SET-02 · Only queue opening, queue hours, tickets per phone and the checkpoint interval can be set per pool”- Status: retired (replaced by R-SET-09, which adds max_queue_miss to the list)
- Example: given pool SBY, when its overdue_limit_days is set, then there is no such column in pool_settings; queue_open, queue_opens_at, queue_closes_at, max_tickets_per_phone and checkpoint_interval_weeks are the only ones.
- Refusal: none: this describes the schema.
- Who: every pool.
- Source: [Ref] Data model V13: pool_settings. Retired in #210: an exact list that grows is a new statement (as R-ACC-25 became R-ACC-35), so it is R-SET-09.
R-SET-03 · A new organization's settings start at the defaults listed in [Ref] Database rules
Section titled “R-SET-03 · A new organization's settings start at the defaults listed in [Ref] Database rules”- Status: built
- Example: given a new organization, when its settings are read, then checkpoint_interval_weeks is 2, overdue_limit_days is 3, panel_fee is 300000, allow_cross_entity_payments is true and require_visit_before_booking is false, as the table lists.
- Refusal: none.
- Who: every new organization.
- Source: [Ref] Database rules and conventions, Settings; [Ref] Data model V13: organization_settings.
R-SET-04 · Organization and pool settings are readable by every member of the organization
Section titled “R-SET-04 · Organization and pool settings are readable by every member of the organization”- Status: built
- Example: given a satpam, when they read organization_settings, then their organization's row comes back.
- Refusal: none.
- Who: every member, whatever their roles.
- Source: [Ref] Roles, policy matrix.
R-SET-05 · Changing organization or pool settings needs master_data:write
Section titled “R-SET-05 · Changing organization or pool settings needs master_data:write”- Status: built
- Example: given a checker, when they set pool PML's checkpoint interval to 10, then it is refused and nothing changes; an admin's change goes through.
- Refusal: master_data.not_allowed, from the functions of R-SET-17.
- Who: super_admin, admin, maintenance and asuransi hold master_data:write.
- Source: [Ref] Roles, policy matrix; the key: zuki on #459 (2026-11-17) (every write through a function, as R-MD-24 did).
R-SET-06 · Every organization has a settings row, created with the organization
Section titled “R-SET-06 · Every organization has a settings row, created with the organization”- Status: built
- Example: given a new organization is saved, when organization_settings is read in the same transaction, then its row is there with the defaults, so app.setting() always has an organization value to fall back to.
- Refusal: none.
- Who: every new organization.
- Source: D9 (P10: app.setting falls back to the organization); [Ref] Data model V13: organization_settings, keyed by organization with every column defaulted. Added for DOC-Q10 (SET open 1).
R-SET-08 · max_queue_miss is 3 for a new organization, and a pool may set its own
Section titled “R-SET-08 · max_queue_miss is 3 for a new organization, and a pool may set its own”- Status: built
- Example: given a new organization, when its settings are read, then max_queue_miss is 3; when an admin sets PML's to 2, then app.setting(PML, 'max_queue_miss') returns 2 and SBY's, with no value of its own, returns 3.
- Refusal: none.
- Who: every organization and pool; changing it needs master_data:write (R-SET-05).
- Source: D43 (a pool setting, default 3, set by an admin); General Flow Parameters, MAX_QUEUE_MISS (DRV-05).
R-SET-09 · Only queue opening, queue hours, tickets per phone, the checkpoint interval and the queue miss limit can be set per pool
Section titled “R-SET-09 · Only queue opening, queue hours, tickets per phone, the checkpoint interval and the queue miss limit can be set per pool”- Status: built
- Example: given pool SBY, when its overdue_limit_days is set, then there is no such column in pool_settings; queue_open, queue_opens_at, queue_closes_at, max_tickets_per_phone, checkpoint_interval_weeks and max_queue_miss are the only ones.
- Refusal: none: this describes the schema.
- Who: every pool.
- Source: [Ref] Data model V13: pool_settings; D43 (max_queue_miss, a pool setting: R-SET-08), added in BE pack G2 (#212); the CTO on #210 (2026-10-20: R-SET-02 becomes R-SET-09). Replaces R-SET-02.
R-SET-10 · max_repossessions is 2 for a new organization, and an admin may change it
Section titled “R-SET-10 · max_repossessions is 2 for a new organization, and an admin may change it”- Status: built
- Example: given a new organization, when its settings are read, then max_repossessions is 2; an admin sets it to 3 and a checker's change is refused (R-SET-05). It is the organization's only, not a pool's (R-SET-09).
- Refusal: master_data.not_allowed, as for other settings (R-SET-05).
- Who: every organization; changing it needs master_data:write (R-SET-05). R-DRV-30 reads it.
- Source: D66 (an organization setting, max_repossessions, default 2; lowering it blacklists nobody by itself).
R-SET-11 · cp_skip_weeks_limit is 3 for a new organization, and an admin may change it
Section titled “R-SET-11 · cp_skip_weeks_limit is 3 for a new organization, and an admin may change it”- Status: built
- Example: given a new organization, when its settings are read, then cp_skip_weeks_limit is 3; an admin sets it to 4 and a checker's change is refused (R-SET-05). It is the organization's only (R-SET-09).
- Refusal: master_data.not_allowed, as for other settings (R-SET-05).
- Who: every organization; changing it needs master_data:write (R-SET-05). R-REP-31 reads it.
- Source: D71 (VEH-32); zuki on #236 (2026-11-02: a repo request opens after 3 skips). BE adds the column.
R-SET-12 · The service interval is a number of kilometres for each powertrain, ev 20,000 and ice 10,000 for a new organization, in settings and not on the model
Section titled “R-SET-12 · The service interval is a number of kilometres for each powertrain, ev 20,000 and ice 10,000 for a new organization, in settings and not on the model”- Status: built
- Example: given a new organization, when its settings are read, then service_interval_km_ev is 20000 and service_interval_km_ice is 10000; an admin may change either (R-SET-05). A pool does not set its own (R-SET-09). The car's powertrain is its model's (vehicle_models.powertrain). This replaces the single service_interval_km.
- Refusal: master_data.not_allowed, as for other settings (R-SET-05); settings.out_of_range for a value below 1 or above the column (R-SET-18).
- Who: every organization; changing either needs master_data:write, through set_organization_settings() (R-SET-17), and the Pengaturan tab edits both. R-GATE-12 reads it.
- Source: zuki on #236 (2026-11-02: the odometer limit is by powertrain, ev 20k and ice 10k); zuki on #459 (2026-11-17: two columns in organization settings), confirmed by #666. BE changes the column.
R-SET-13 · notification_escalation_hours holds each escalating notification type's escalation time, in hours; a type with no key escalates after 24
Section titled “R-SET-13 · notification_escalation_hours holds each escalating notification type's escalation time, in hours; a type with no key escalates after 24”- Status: built
- Example: given a new organization, when its settings are read, then notification_escalation_hours is an empty jsonb object, so every escalating type escalates after 24 hours (R-NTF-27); an admin sets {"work_order.route_waiting": 8} and that type escalates after 8, the others still after 24. It is the organization's only, not a pool's (R-SET-09).
- Refusal: master_data.not_allowed, as for other settings (R-SET-05).
- Who: every organization; changing it needs master_data:write (R-SET-05). R-NTF-27 reads it.
- Source: D95 (the escalation time of each escalating type, 24 hours by default, an organization setting); the lead in the session on #584 (jsonb on organization_settings; a missing key means 24).
R-SET-14 · A key of notification_escalation_hours that isn't an escalating notification type's code is refused
Section titled “R-SET-14 · A key of notification_escalation_hours that isn't an escalating notification type's code is refused”- Status: built
- Example: given an admin, when they set notification_escalation_hours to {"no_such_type": 8}, or to a key naming a type that doesn't escalate, then it is refused and the setting stays as it was.
- Refusal: settings.not_escalating_type, with type_code.
- Who: every writer of organization_settings.
- Source: D95; the lead in the session on #584 (a key that isn't an escalating type's code is refused). The key is DOC's proposal (D10).
R-SET-15 · Each escalation time in notification_escalation_hours is a whole number of hours, at least 1
Section titled “R-SET-15 · Each escalation time in notification_escalation_hours is a whole number of hours, at least 1”- Status: built
- Example: given an admin, when they set an escalating type's time to 0, -2, 1.5 or "8", then it is refused; 1 and 72 are accepted.
- Refusal: settings.escalation_hours_invalid, with type_code.
- Who: every writer of organization_settings.
- Source: D95. The bounds and the key are DOC's proposal in the session on #584.
R-SET-16 · notification_digest_at is 07:00 for a new organization, in the organization's time, and an admin may change it
Section titled “R-SET-16 · notification_digest_at is 07:00 for a new organization, in the organization's time, and an admin may change it”- Status: built
- Example: given a new organization, when its settings are read, then notification_digest_at is 07:00; an admin sets it to 06:30, and the digest is made at 06:30 in the organization's time zone. A pool does not set its own (R-SET-09).
- Refusal: master_data.not_allowed, as for other settings (R-SET-05).
- Who: every organization; changing it needs master_data:write (R-SET-05). M7's digest reads it (#507).
- Source: D95 (the digest's hour, 07:00 in the organization's time; not per pool).
R-SET-17 · Organization and pool settings are written only through database functions
Section titled “R-SET-17 · Organization and pool settings are written only through database functions”- Status: built
- Example: given an admin, when they update organization_settings or insert a pool_settings row straight through PostgREST, then it is refused; the same change through the function goes through. A call that names a pool the caller's organization doesn't hold raises settings.pool_not_found, and a call for an organization the caller isn't a member of raises master_data.not_allowed. A setting that doesn't exist is app.setting()'s refusal, not these functions' (R-CONV-14).
- Refusal: settings.pool_not_found for an unknown pool, or master_data.not_allowed with {organization_id} in its detail for another organization, from a function; a direct insert, update or delete: none: insufficient_privilege (42501), as authenticated holds only select on these tables.
- Who: every app user. The functions are security definer and check master_data:write (R-SET-05); each refusal raises a key (D10). The checks of R-SET-14 and R-SET-15 run inside them.
- Source: D3, D10; the lead on #459 (2026-11-17: the R-MD-23 pattern for every table of the slice, pool_settings included).
R-SET-18 · A number setting below its least value, or above what its column holds, is refused
Section titled “R-SET-18 · A number setting below its least value, or above what its column holds, is refused”- Status: built
- Example: given an admin, when they set max_repossessions to 0, overdue_limit_days to -1 or max_tickets_per_phone to 40000, then it is refused and the setting stays as it was. The least values, for the organization and, where it may override, a pool:
- At least 1: checkpoint_interval_weeks, cp_warning_days, cp_critical_days, service_interval_km_ev, service_interval_km_ice, max_tickets_per_phone, max_queue_miss, default_contract_months, max_repossessions and cp_skip_weeks_limit.
- At least 0: overdue_limit_days, visit_due_days, panel_fee and repo_fine.
- The most is the most its column holds, by type: 32767 for the int2 day, week, month and count settings; 2147483647 for service_interval_km_ev and service_interval_km_ice, each an int; and 9223372036854775807 for panel_fee and repo_fine, which are bigint.
- Refusal: settings.out_of_range, with {field, min, max} in its detail.
- Who: every holder of master_data:write, through the functions of R-SET-17.
- Source: the column checks on organization_settings and pool_settings; zuki on #459 (2026-11-17: every column with bounds, which DOC writes). No upper limit below the column's, as D57 set none for due days; the bounds and the key are DOC's proposal.
R-SET-19 · cp_warning_days must be fewer than cp_critical_days
Section titled “R-SET-19 · cp_warning_days must be fewer than cp_critical_days”- Status: built
- Example: given the organization's cp_warning_days of 10 and cp_critical_days of 14, when an admin sets cp_warning_days to 14 or cp_critical_days to 9, then it is refused; 12 and 14 are accepted, as a checkpoint warns before it turns critical.
- Refusal: settings.warning_after_critical, with {cp_warning_days, cp_critical_days} in its detail.
- Who: every holder of master_data:write, through the functions of R-SET-17.
- Source: zuki on #459 (2026-11-17: each column with bounds). The order of the two and the key are DOC's proposal.
R-SET-20 · The queue opens before it closes, in the values that apply at each pool
Section titled “R-SET-20 · The queue opens before it closes, in the values that apply at each pool”- Status: built
- Example: given the organization's queue hours 08:00 to 16:00, when an admin sets pool PML's queue_opens_at to 17:00, or the organization's queue_closes_at to 07:30, then it is refused, because some pool's queue would close before it opens (R-SET-01); PML opening at 09:00 is accepted. A change to the organization's hours is checked against every pool that takes them.
- Refusal: settings.queue_hours_invalid, with {pool_id, pool_code, queue_opens_at, queue_closes_at} in its detail, so the page can name the pool; pool_id and pool_code are empty for the organization's own values.
- Who: every holder of master_data:write, through the functions of R-SET-17.
- Source: zuki on #459 (2026-11-17: each column with bounds). The check and the key are DOC's proposal.
R-SET-21 · A pool setting saved empty is cleared, and the organization's value applies again
Section titled “R-SET-21 · A pool setting saved empty is cleared, and the organization's value applies again”- Status: built
- Example: given pool PML with max_queue_miss 2 of its own and the organization's 3, when an admin clears PML's value, then pool_settings holds none for it and app.setting(PML, 'max_queue_miss') returns 3 (R-SET-01). Clearing a value the pool doesn't hold changes nothing.
- Refusal: none.
- Who: every holder of master_data:write, through the functions of R-SET-17.
- Source: zuki on #459 (2026-11-17: clearing an override makes the organization's value apply); R-SET-01.
R-SET-22 · Every change of an organization's or a pool's settings writes an audit row
Section titled “R-SET-22 · Every change of an organization's or a pool's settings writes an audit row”- Status: built
- Example: given an admin, when they set max_repossessions to 3 and then clear PML's max_queue_miss, then organization_settings and pool_settings have one audit row each, naming the admin and the changed field (R-AUD-01, R-AUD-02).
- Refusal: none.
- Who: every writer, and the functions of R-SET-17.
- Source: #459 (the slice: edits write audit entries); R-AUD-01; both tables are watched already.
R-SET-23 · The pool settings tab shows, for each value a pool doesn't set, the organization's value it takes, marked as such
Section titled “R-SET-23 · The pool settings tab shows, for each value a pool doesn't set, the organization's value it takes, marked as such”- Status: built
- Example: given PML with no checkpoint interval of its own and the organization's 2, when an admin opens PML's settings, then the field shows 2 marked as the organization's value, with a way to set PML's own; a value PML sets shows with a way to clear it (R-SET-21). Only the columns of R-SET-09 appear there.
- Refusal: none.
- Who: apps/web, for every user who opens the page.
- Source: R-SET-01, R-SET-09; #459 (the slice: pools and pool settings).