Org::Outlet
Purpose
An Outlet represents a physical branch, store, or site where an Org::Company operates and where gig work takes place. Each outlet has its own address, and different outlets of the same company may have different pay rates for the same role.
In the legacy system, outlets are called "locations." The term "Outlet" is used in the new system to avoid confusion with geographic concepts (Geo::Area) and to match how Singapore's retail and F&B industries refer to their branches.
Outlets are a critical dependency for the Gig domain because:
- A
Gig::Jobreferences an Outlet (where the work happens) Org::PayRatecan be scoped to a specific Outlet (outlet-level rates vs company-wide defaults)- Data shows that 92.5% of company-role combinations have different rates across outlets — rate resolution requires knowing which outlet the shift is for
Outlet Settings
Outlets carry per-outlet settings that control operational behavior. Settings use the is_setting_ prefix to distinguish them from core data fields:
is_setting_job_approval_required(boolean, default: false) — when enabled, gig jobs created at this outlet enterpendingstatus and must be approved by anhq_managerorarea_managerbefore they become visible to workers. See JodGig Org Statistics — Job Approval for usage data that informed this design.
Settings are columns directly on the org_outlets table, not a separate settings table. This is appropriate for a small, known set of boolean flags. If the number of settings grows beyond ~10, consider extracting to a separate Org::OutletSetting table.
Model Context
| Context | Details |
|---|---|
| Entity | Org::Outlet (independent — not an aggregate root with children) |
| Layer | Organisation Structure |
| Upstream dependencies | Org::Company (which company owns this outlet), Geo::Area (geographic location) |
| Downstream dependents | Gig::Job (references which outlet the work is at), Org::PayRate (rates can be scoped to a specific outlet) |
State Machine
| From | To | Trigger | Notes |
|---|---|---|---|
| (new) | active | UC-1: Outlet created | Default status on creation |
active | inactive | UC-3: Outlet deactivated | No new Jobs can reference this outlet. Existing Jobs/Shifts are unaffected. |
inactive | active | UC-4: Outlet reactivated | Outlet is available for new Jobs again. |
Use Cases
| ID | Use Case | Trigger | Actor |
|---|---|---|---|
| UC-1 | Create an outlet for a company | Company opens a new branch/store | Admin (onboarding) or Employer |
| UC-2 | Edit an outlet's details | Address changes, name updated | Admin or Employer |
| UC-3 | Deactivate an outlet | Branch closes or is no longer using gig workers | Admin or Employer |
| UC-4 | Reactivate an outlet | Branch resumes gig worker usage | Admin or Employer |
| UC-5 | View outlets for a company | Employer managing their branches | Employer |
| UC-6 | Admin views all outlets across companies | Ops reviewing platform structure | Admin |
UC-1: Create an outlet for a company
| Field | Details |
|---|---|
| Actor | Identities::Admin (during onboarding) or Org::Membership with hq_manager role (employer self-serve) |
| Trigger | Company opens a new branch/store |
Endpoint:
| Actor | Endpoint | Company |
|---|---|---|
hq_manager | POST /employers/org/outlets | Optional org_company_id. See "Which company" below |
Identities::Admin | POST /team/org/outlets | Required org_company_id. Any active company |
User story:
- As an
hq_manager, I want to add an outlet to my company, so I can use it for new work when we open a new branch. - As an admin, I want to add an outlet to any active company, so I can set up an employer that cannot do it alone.
Preconditions:
Org::Companyexists and is active- For an
hq_manager: the actor has a usablehq_managermembership in that company, which means the membership and the company are both active - For an
Identities::Admin: the admin is signed in. Any signed-in admin can use this endpoint, with no department limit
System Behavior:
- Actor chooses the company and enters the outlet details
- Actor selects the
Geo::Areafor the outlet's location - System creates the Outlet with
is_active: true - System returns the new outlet
Business Rules:
- An Outlet must belong to exactly one
Org::Company - Which company an
hq_managercan add an outlet to:- The company they are acting as, which is the default when
org_company_idis empty. - Any other company where the
hq_manageralso has a usablehq_managermembership. - A membership in a parent company or a sub-company does not count, only the membership in the chosen company.
- Any other company gets one error under
org_company_id, the same error as for a company that does not exist.
- The company they are acting as, which is the default when
- Which company an
Identities::Admincan add an outlet to:- An admin has no company to act as, so
org_company_idis required. - Any company with status
activeis allowed. - A company that does not exist, or is not active, gets one error under
org_company_id. - The admin sees the real reason, because an admin may see every company.
- An admin has no company to act as, so
- These fields are required:
name,addressandpostal_code.latitude, from -90 to 90, andlongitude, from -180 to 180.geo_area_id, which must point at aGeo::Areawithis_leaf: true.
org_outlets.postal_codecan be empty only for an outlet that came from JodGig. An outlet added in JodApp always has one.namemust hold at least one letter (A to Z) or number, because the system builds the slug from it- Multiple outlets can exist at the same address (e.g., two different brands in the same building)
- The system sets these columns, and the actor cannot send them:
org_outlets.slug, built fromname.parameterize, for examplekopi-house-bedok.org_outlets.is_active, alwaystrue.org_outlets.remote_id, always empty, so the JodGig sync does not match this outlet.org_outlets.created_by_typeandorg_outlets.created_by_id, set to the actor.- For an
hq_manager, the actor is thehq_managermembership in the chosen company. - For an
Identities::Admin, the actor is that admin, andcreated_by_typeisIdentities::Admin.
- For an
org_outlets.updated_by_typeandorg_outlets.updated_by_id, set to the same actor.
- The slug has no random ending. The code does not use
SlugGenerator, becauseSlugGeneratoradds a random ending. - A
namewhose slug already exists in the same company gets one error undername.- An
hq_managersees "Your company already has an outlet with this name. Please use a different name." - An
Identities::Adminsees "This company already has an outlet with this name.", because the admin is not part of the company. - The check counts outlets that were deactivated or have
deleted_atset, because they keep their slug. - The unique index on
(slug, company_id)still protects the data when two requests arrive at the same moment.
- An
- Creating an outlet does not create any pay rates — those are configured separately
- Creating an outlet does not create any
Org::OutletAssignment, because anhq_manageralready sees every outlet
Postconditions:
- Outlet exists and is active
- Pay rates can now be configured for this outlet (via
Org::PayRate) Gig::Jobcan reference this outlet
UC-2: Edit an outlet's details
| Field | Details |
|---|---|
| Actor | Identities::Admin or Org::Membership (hq_manager) |
| Trigger | Address changes, name updated |
Endpoint:
| Actor | Endpoint |
|---|---|
hq_manager | PATCH /employers/org/outlets/:id |
Identities::Admin | PATCH /team/org/outlets/:id |
User story:
- As an
hq_manager, I want to change the details of an outlet of my company, so the address and name stay correct. - As an admin, I want to change the details of any outlet, so I can fix wrong data for an employer.
Preconditions:
- Outlet exists, and
org_outlets.deleted_atis empty - For an
hq_manager: the actor has a usablehq_managermembership in the outlet's company- Usable means the membership and the company are both active.
- For an
Identities::Admin: the admin is signed in. Any signed-in admin can use this endpoint, with no department limit - The outlet is not linked to JodGig
- A linked outlet has
org_outlets.remote_idpresent.
- A linked outlet has
System Behavior:
- Actor sends the fields to change: name, address, postal code, latitude, longitude,
Geo::Area - System checks every field that is in the request
- A field that is missing or empty is not checked.
- System saves only the fields in the request
- System sets
updated_byand returns the outlet
Business Rules:
- Editable fields:
name,address,postal_code,latitude,longitudeandgeo_area_id- Every field is optional.
- A field that is not in the request does not change.
- A field that is missing or empty in the request does not change.
- These rules apply to a field that is in the request:
latitudeis from -90 to 90, andlongitudeis from -180 to 180.geo_area_idmust point at aGeo::Areawithis_leaf: true.
- A new
namehas no rule, because the slug is built from the name only when the outlet is created. - Immutable fields: these columns cannot change, and the system does not read them from the request:
org_outlets.company_id, because an outlet cannot be transferred between companies.org_outlets.slug, becauselistings_jobs.outlet_slugand the JodGig sync use it.org_outlets.remote_id.
- An
hq_managergets the same error underidin three cases:- The outlet does not exist.
- The outlet has
deleted_atset. - The actor cannot update the outlet.
- The error does not show which ids exist.
- An
Identities::Admingets HTTP 404 with coderecord_not_foundwhen the outlet does not exist or hasdeleted_atset.- An admin may see every company, so there is nothing to hide.
- A linked outlet cannot be updated here
- The system returns a different error under
id, and saves nothing. - The JodGig sync writes every mapped column of a linked outlet when the JodGig location changes.
- An edit in JodApp would disappear without a message.
- The actor must make the change in JodGig, until JodApp owns that data.
- The system returns a different error under
- An inactive outlet can be updated
- UC-2 needs only that the outlet exists.
- The system sets
org_outlets.updated_by_typeandorg_outlets.updated_by_id- For an
hq_manager, the value is the actor'shq_managermembership in the outlet's company. - For an
Identities::Admin, the value is that admin. created_bydoes not change.
- For an
- Edits do not affect existing
Gig::Jobrecords or their Shifts Listings::Jobrows are not part of this use case- They copy the address from
Gig::TempJoband have no link toOrg::Outlet. - They need a separate design.
- They copy the address from
Postconditions:
- Outlet reflects updated values
UC-3: Deactivate an outlet
| Field | Details |
|---|---|
| Actor | Identities::Admin or Org::Membership (hq_manager) |
| Trigger | Branch closes or is no longer using gig workers |
Endpoint:
| Actor | Endpoint | Body |
|---|---|---|
hq_manager | PATCH /employers/org/outlets/:id/deactivate | No body |
Identities::Admin | PATCH /team/org/outlets/:id/deactivate | No body |
The system never deletes an outlet, so there is no DELETE endpoint. A success returns HTTP 200 with the key org_outlet.
User story:
- As an
hq_manager, I want to deactivate an outlet of my company, so my branch cannot be chosen for new work after it closes. - As an admin, I want to deactivate any outlet, so it cannot be chosen for new work.
Preconditions:
- Outlet exists, has
deleted_atempty, and hasis_active: true - For an
hq_manager: the actor has a usablehq_managermembership in the outlet's company, which means the membership and the company are both active - For an
Identities::Admin: the admin is signed in. Any signed-in admin can use this endpoint, with no department limit - The outlet is not linked to JodGig, which means
remote_idis empty
System Behavior:
- Actor deactivates the outlet
- For an
hq_manager, the system finds the actor'shq_managermembership in the outlet's company - System checks the outlet, one check at a time, and stops at the first refusal
- System sets
is_active: falseandupdated_byto the actor - System returns the outlet
Business Rules:
- Which outlets an
hq_managercan deactivate:- Any outlet of a company where they have a usable
hq_managermembership. A parent company gives no access to its sub-companies. - A missing outlet, a deleted outlet (
deleted_atset) and an outlet of any other company get one error underid. It is the same error, so the response does not show which ids exist.
- Any outlet of a company where they have a usable
- An
Identities::Admincan deactivate any outlet of any company- A missing outlet and a deleted outlet (
deleted_atset) get HTTP 404 with coderecord_not_found. - An admin may see every company, so there is nothing to hide.
- A missing outlet and a deleted outlet (
- A linked outlet cannot be deactivated here, because the daily JodGig sync would set
is_activeback totrue. The actor must make the change in JodGig. - An outlet that is already inactive returns an error, and the system does not save the row again
- The system sets
is_activetofalseand never writesdeleted_at, so the row stays in the table updated_byis the actor.created_bydoes not change- For an
hq_manager, the actor is thehq_managermembership in the outlet's company. - For an
Identities::Admin, the actor is that admin.
- For an
Org::OutletAssignmentrows do not change, so the same managers return when the outlet is reactivated- Existing Jobs and their Shifts referencing this outlet are NOT affected
- A new invite cannot assign an inactive outlet
- No new
Gig::Jobcan be created referencing an inactive outlet Org::PayRateentries for this outlet remain in the database but are no longer used for new rate resolution- Deactivation is reversible (see UC-4)
Cross-Domain Check — Billing::OutletBudget:
- Not built yet.
PATCH /employers/org/outlets/:id/deactivateandPATCH /team/org/outlets/:id/deactivatedo not check this, becauseBilling::OutletBudgetdoes not exist yet. - Credits never block a deactivation. The Billing domain only warns the admin about credits that stay on the outlet.
- The rule for an outlet that still holds credits belongs to the Billing domain.
- See Billing::OutletBudget — Cross-Domain: Org::Outlet Deactivation.
Postconditions:
- Outlet
is_active: false - Outlet no longer available for new Job creation
- If outlet had a
Billing::OutletBudget: budget remains but will not receive new reservations
UC-4: Reactivate an outlet
| Field | Details |
|---|---|
| Actor | Identities::Admin or Org::Membership (hq_manager) |
| Trigger | Branch resumes gig worker usage |
User story:
- As an
hq_manager, I want to reactivate an outlet, so my branch can be used again. - As an admin, I want to reactivate any outlet, so it can be chosen for new work again.
Endpoint:
| Actor | Endpoint | Body |
|---|---|---|
hq_manager | PATCH /employers/org/outlets/:id/reactivate | No body |
Identities::Admin | PATCH /team/org/outlets/:id/reactivate | No body |
A success returns HTTP 200 with the key org_outlet.
Preconditions:
- Outlet exists, has
deleted_atempty, and hasis_active: false - For an
hq_manager: the actor has a usablehq_managermembership in the outlet's company, which means the membership and the company are both active - For an
Identities::Admin: the admin is signed in. Any signed-in admin can use this endpoint, with no department limit - The outlet is not linked to JodGig, which means
remote_idis empty
System Behavior:
- Actor reactivates the outlet
- For an
hq_manager, the system finds the actor'shq_managermembership in the outlet's company - System checks the outlet, one check at a time, and stops at the first refusal
- System sets
is_active: trueandupdated_byto the actor - System returns the outlet
Business Rules:
- Which outlets an
hq_managercan reactivate:- Any outlet of a company where they have a usable
hq_managermembership. A parent company gives no access to its sub-companies. - A missing outlet, a deleted outlet (
deleted_atset) and an outlet of any other company get one error underid. It is the same error, so the response does not show which ids exist. - JodGig removed an outlet with
deleted_atset, so this endpoint cannot bring it back.
- Any outlet of a company where they have a usable
- An
Identities::Admincan reactivate any outlet of any company- A missing outlet and a deleted outlet (
deleted_atset) get HTTP 404 with coderecord_not_found. - An admin may see every company, so there is nothing to hide.
- A missing outlet and a deleted outlet (
- A linked outlet cannot be reactivated here, because the daily JodGig sync can set
is_activeback tofalse. The actor must make the change in JodGig. - An outlet that is already active returns an error, and the system does not save the row again
- The system sets
is_activetotrueand never writesdeleted_at updated_byis the actor.created_bydoes not change- For an
hq_manager, the actor is thehq_managermembership in the outlet's company. - For an
Identities::Admin, the actor is that admin.
- For an
Org::OutletAssignmentrows do not change, so the managers assigned before the deactivation can see the outlet again- Existing
Org::PayRateentries become available for rate resolution again- The system does not copy or change
Org::PayRaterows.
- The system does not copy or change
- No automatic creation of Jobs or Shifts
- The employer posts new work separately.
- A new invite can assign the outlet again
Postconditions:
- Outlet
is_active: true - Available for new Job creation and rate resolution
UC-5: View outlets for a company
| Field | Details |
|---|---|
| Actor | Org::Membership (employer, any role) |
| Trigger | Employer managing their branches |
Endpoint:
| Actor | Endpoint | Company |
|---|---|---|
Org::Membership, any role | GET /employers/org/outlets | Optional org_company_id. See "Which companies" below |
Preconditions:
- Employer has an active
Org::Membershipin the company they are acting as
System Behavior:
- Employer navigates to outlet management
- System finds the companies the employer can reach
- System finds the outlets that the employer's role can see in those companies
- System displays each outlet with its name, address, location and status
Business Rules:
- Which companies the employer can see:
- Every company where the employer has a usable membership, in any role.
- A usable membership means the membership and the company are both active.
- A membership in a parent company or a sub-company does not count, only the membership in the company itself.
- Any other
org_company_idreturns one error underorg_company_id, the same error as for a company that does not exist.
- Which outlets each role can see in a company:
| Role | Outlets the role sees |
|---|---|
hq_manager | Every outlet of the company. |
area_manager, outlet_manager | Only the outlets with an active Org::OutletAssignment for their membership in that company. |
- An
Org::OutletAssignmentwithrevoked_atset gives no access. - An
area_manageroroutlet_managerwith no assignment sees an empty list. - An outlet with
org_outlets.deleted_atset never appears. - The list has these filters:
org_company_idshows the outlets of one reachable company.namematches part oforg_outlets.name, ignoring case.is_activeistrueorfalse.
- The list sorts by
id,name,created_atorupdated_at.- The default is
nameascending.
- The default is
- The list is paginated with
pageandpage_size, and the defaultpage_sizeis 10. - The list does not count Jobs yet
- An outlet can have
careers_jobs,gig_jobsandgig_temp_jobs, all shown asListings::Job. - The count needs a separate design.
- An outlet can have
is_linked_to_jodgigistruewhenorg_outlets.remote_idis present.- The web page turns off the edit buttons for these outlets.
- The response never holds a credit column of
org_outlets.
Response fields:
| Field | Source |
|---|---|
id | org_outlets.id |
company_id | org_outlets.company_id |
name | org_outlets.name |
address | org_outlets.address |
postal_code | org_outlets.postal_code |
latitude | org_outlets.latitude, as a string |
longitude | org_outlets.longitude, as a string |
geo_area_id | org_outlets.geo_area_id |
is_active | org_outlets.is_active |
is_linked_to_jodgig | true when org_outlets.remote_id is present |
Postconditions:
- Read-only operation — no data changes
UC-6: Admin views all outlets across companies
| Field | Details |
|---|---|
| Actor | Identities::Admin |
| Trigger | Ops reviewing platform structure |
User story:
- As an admin, I want to list and filter the outlets of all companies, so I can review the platform.
Endpoint:
| Actor | Endpoint | Company |
|---|---|---|
Identities::Admin | GET /team/org/outlets | All companies. Optional org_company_id keeps one company. |
Preconditions:
- The admin is signed in. Any signed-in admin can use this endpoint.
System Behavior:
- Admin navigates to the outlets admin page
- System finds the outlets of every company
- System keeps only the outlets that match the filters
- System displays each outlet with its name, address, location, status and company
Business Rules:
- The list covers every company.
- The list has no membership filter and no assignment filter.
- The list shows active and inactive outlets when
is_activeis missing. - An outlet with
org_outlets.deleted_atset never appears. - The list has these filters:
| Filter | Rule |
|---|---|
org_company_id | Keeps the outlets of one company. |
is_active | true keeps active outlets. false keeps inactive outlets. |
address_geo_area_path | Keeps the outlets in this Geo::Area and in its child areas. |
name | Matches part of org_outlets.name, ignoring case. |
- The area filter follows
geo_areas.path, the same as the company list inOrg::Companies::TeamIndexManager.- The area of an outlet is
org_outlets.geo_area_id. address_geo_area_pathis labels joined by dots, for examplesg.central.- A label holds letters, numbers and underscores.
- Any other text returns one error under
address_geo_area_path, because the database refuses it.
- The area of an outlet is
- The list sorts by
id,name,created_atorupdated_at.- The default is
nameascending. - When two outlets have the same value, the lower
idcomes first, so a page never changes between requests.
- The default is
- The list is paginated with
pageandpage_size, and the defaultpage_sizeis 10. - The system loads the company of every outlet in the same query as the list, not one query for each outlet.
is_linked_to_jodgigistruewhenorg_outlets.remote_idis present.- The admin can see where the data comes from.
- The response never holds a credit column of
org_outlets.
Response fields:
| Field | Source |
|---|---|
id | org_outlets.id |
name | org_outlets.name |
address | org_outlets.address |
postal_code | org_outlets.postal_code |
latitude | org_outlets.latitude, as a string |
longitude | org_outlets.longitude, as a string |
geo_area_id | org_outlets.geo_area_id |
is_active | org_outlets.is_active |
is_linked_to_jodgig | true when org_outlets.remote_id is present |
created_at | org_outlets.created_at |
updated_at | org_outlets.updated_at |
org_company | The company of the outlet, with its id and name |
Postconditions:
- Read-only operation — no data changes
Invariants
- An Outlet must belong to exactly one
Org::Company— this cannot change after creation - Outlets are never hard-deleted — only deactivated via
is_active - An inactive outlet cannot be referenced by new
Gig::Jobrecords - Deactivating an outlet does not affect existing Jobs, Shifts, or Assignments
- Name and address are required fields
Model Interactions
| Related Model | Relationship | Interaction |
|---|---|---|
Org::Company | Outlet belongs_to Company | Every outlet is owned by one company. |
Geo::Area | Outlet belongs_to Area | Geographic area where the outlet is located. Used for "jobs near you" on the marketplace. |
Org::PayRate | PayRate optionally scoped to Outlet | Pay rates can be company-wide (outlet NULL) or outlet-specific. Outlet-specific rates take precedence. |
Gig::Job | Job belongs_to Outlet | Each Job references the outlet where the work happens. This determines which pay rates apply to its Shifts. |
Org::Membership | Employer manages outlets via membership | hq_manager has implicit access to all outlets. area_manager and outlet_manager are scoped via Org::OutletAssignment. |
Org::OutletAssignment | Assignment scopes membership to outlet | Links an Org::Membership to specific outlets for area_manager and outlet_manager roles. |
Schema Gaps
| Gap | Impact | Suggested Resolution |
|---|---|---|
No org_outlets table exists in current DBML | Outlet concept is missing from the new system entirely | Resolved in DBML. org_outlets table defined with company_id, name, address, geo_area_id, is_active and all other columns. |
No is_setting_job_approval_required column | Cannot control per-outlet job approval. Legacy uses locations.job_approval_required. | Resolved in DBML. is_setting_job_approval_required boolean [not null, default: false] defined on org_outlets. |
Legacy credit fields on org_outlets are transitional | available_credits, consumed_credits, job_credit_deduction, min_credit_limit, is_credit_negative_validation are synced from JodGig for migration. They do not belong in the new system — all credits live in Billing::EntitlementBalance at the company level. | Remove these columns once the legacy migration to Billing::LedgerEntry is complete. Do NOT model outlet-level credit pools in the new system. |
Legacy locations table has many fields not needed | Legacy has credit tracking, auto-select config, etc. on location | New org_outlets table should be clean — outlet-specific config can be separate tables if needed |