Skip to main content

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::Job references an Outlet (where the work happens)
  • Org::PayRate can 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 enter pending status and must be approved by an hq_manager or area_manager before 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​

ContextDetails
EntityOrg::Outlet (independent — not an aggregate root with children)
LayerOrganisation Structure
Upstream dependenciesOrg::Company (which company owns this outlet), Geo::Area (geographic location)
Downstream dependentsGig::Job (references which outlet the work is at), Org::PayRate (rates can be scoped to a specific outlet)

State Machine​

FromToTriggerNotes
(new)activeUC-1: Outlet createdDefault status on creation
activeinactiveUC-3: Outlet deactivatedNo new Jobs can reference this outlet. Existing Jobs/Shifts are unaffected.
inactiveactiveUC-4: Outlet reactivatedOutlet is available for new Jobs again.

Use Cases​

IDUse CaseTriggerActor
UC-1Create an outlet for a companyCompany opens a new branch/storeAdmin (onboarding) or Employer
UC-2Edit an outlet's detailsAddress changes, name updatedAdmin or Employer
UC-3Deactivate an outletBranch closes or is no longer using gig workersAdmin or Employer
UC-4Reactivate an outletBranch resumes gig worker usageAdmin or Employer
UC-5View outlets for a companyEmployer managing their branchesEmployer
UC-6Admin views all outlets across companiesOps reviewing platform structureAdmin

UC-1: Create an outlet for a company​

FieldDetails
ActorIdentities::Admin (during onboarding) or Org::Membership with hq_manager role (employer self-serve)
TriggerCompany opens a new branch/store

Endpoint:

ActorEndpointCompany
hq_managerPOST /employers/org/outletsOptional org_company_id. See "Which company" below
Identities::AdminPOST /team/org/outletsRequired 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::Company exists and is active
  • For an hq_manager: the actor has a usable hq_manager membership 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:

  1. Actor chooses the company and enters the outlet details
  2. Actor selects the Geo::Area for the outlet's location
  3. System creates the Outlet with is_active: true
  4. System returns the new outlet

Business Rules:

  • An Outlet must belong to exactly one Org::Company
  • Which company an hq_manager can add an outlet to:
    • The company they are acting as, which is the default when org_company_id is empty.
    • Any other company where the hq_manager also has a usable hq_manager membership.
    • 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.
  • Which company an Identities::Admin can add an outlet to:
    • An admin has no company to act as, so org_company_id is required.
    • Any company with status active is 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.
  • These fields are required:
    • name, address and postal_code.
    • latitude, from -90 to 90, and longitude, from -180 to 180.
    • geo_area_id, which must point at a Geo::Area with is_leaf: true.
  • org_outlets.postal_code can be empty only for an outlet that came from JodGig. An outlet added in JodApp always has one.
  • name must 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 from name.parameterize, for example kopi-house-bedok.
    • org_outlets.is_active, always true.
    • org_outlets.remote_id, always empty, so the JodGig sync does not match this outlet.
    • org_outlets.created_by_type and org_outlets.created_by_id, set to the actor.
      • For an hq_manager, the actor is the hq_manager membership in the chosen company.
      • For an Identities::Admin, the actor is that admin, and created_by_type is Identities::Admin.
    • org_outlets.updated_by_type and org_outlets.updated_by_id, set to the same actor.
  • The slug has no random ending. The code does not use SlugGenerator, because SlugGenerator adds a random ending.
  • A name whose slug already exists in the same company gets one error under name.
    • An hq_manager sees "Your company already has an outlet with this name. Please use a different name."
    • An Identities::Admin sees "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_at set, because they keep their slug.
    • The unique index on (slug, company_id) still protects the data when two requests arrive at the same moment.
  • Creating an outlet does not create any pay rates — those are configured separately
  • Creating an outlet does not create any Org::OutletAssignment, because an hq_manager already sees every outlet

Postconditions:

  • Outlet exists and is active
  • Pay rates can now be configured for this outlet (via Org::PayRate)
  • Gig::Job can reference this outlet

UC-2: Edit an outlet's details​

FieldDetails
ActorIdentities::Admin or Org::Membership (hq_manager)
TriggerAddress changes, name updated

Endpoint:

ActorEndpoint
hq_managerPATCH /employers/org/outlets/:id
Identities::AdminPATCH /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_at is empty
  • For an hq_manager: the actor has a usable hq_manager membership 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_id present.

System Behavior:

  1. Actor sends the fields to change: name, address, postal code, latitude, longitude, Geo::Area
  2. System checks every field that is in the request
    • A field that is missing or empty is not checked.
  3. System saves only the fields in the request
  4. System sets updated_by and returns the outlet

Business Rules:

  • Editable fields: name, address, postal_code, latitude, longitude and geo_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:
    • latitude is from -90 to 90, and longitude is from -180 to 180.
    • geo_area_id must point at a Geo::Area with is_leaf: true.
  • A new name has 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, because listings_jobs.outlet_slug and the JodGig sync use it.
    • org_outlets.remote_id.
  • An hq_manager gets the same error under id in three cases:
    • The outlet does not exist.
    • The outlet has deleted_at set.
    • The actor cannot update the outlet.
    • The error does not show which ids exist.
  • An Identities::Admin gets HTTP 404 with code record_not_found when the outlet does not exist or has deleted_at set.
    • 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.
  • An inactive outlet can be updated
    • UC-2 needs only that the outlet exists.
  • The system sets org_outlets.updated_by_type and org_outlets.updated_by_id
    • For an hq_manager, the value is the actor's hq_manager membership in the outlet's company.
    • For an Identities::Admin, the value is that admin.
    • created_by does not change.
  • Edits do not affect existing Gig::Job records or their Shifts
  • Listings::Job rows are not part of this use case
    • They copy the address from Gig::TempJob and have no link to Org::Outlet.
    • They need a separate design.

Postconditions:

  • Outlet reflects updated values

UC-3: Deactivate an outlet​

FieldDetails
ActorIdentities::Admin or Org::Membership (hq_manager)
TriggerBranch closes or is no longer using gig workers

Endpoint:

ActorEndpointBody
hq_managerPATCH /employers/org/outlets/:id/deactivateNo body
Identities::AdminPATCH /team/org/outlets/:id/deactivateNo 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_at empty, and has is_active: true
  • For an hq_manager: the actor has a usable hq_manager membership 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_id is empty

System Behavior:

  1. Actor deactivates the outlet
  2. For an hq_manager, the system finds the actor's hq_manager membership in the outlet's company
  3. System checks the outlet, one check at a time, and stops at the first refusal
  4. System sets is_active: false and updated_by to the actor
  5. System returns the outlet

Business Rules:

  • Which outlets an hq_manager can deactivate:
    • Any outlet of a company where they have a usable hq_manager membership. A parent company gives no access to its sub-companies.
    • A missing outlet, a deleted outlet (deleted_at set) and an outlet of any other company get one error under id. It is the same error, so the response does not show which ids exist.
  • An Identities::Admin can deactivate any outlet of any company
    • A missing outlet and a deleted outlet (deleted_at set) get HTTP 404 with code record_not_found.
    • An admin may see every company, so there is nothing to hide.
  • A linked outlet cannot be deactivated here, because the daily JodGig sync would set is_active back to true. 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_active to false and never writes deleted_at, so the row stays in the table
  • updated_by is the actor. created_by does not change
    • For an hq_manager, the actor is the hq_manager membership in the outlet's company.
    • For an Identities::Admin, the actor is that admin.
  • Org::OutletAssignment rows 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::Job can be created referencing an inactive outlet
  • Org::PayRate entries 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/deactivate and PATCH /team/org/outlets/:id/deactivate do not check this, because Billing::OutletBudget does 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​

FieldDetails
ActorIdentities::Admin or Org::Membership (hq_manager)
TriggerBranch 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:

ActorEndpointBody
hq_managerPATCH /employers/org/outlets/:id/reactivateNo body
Identities::AdminPATCH /team/org/outlets/:id/reactivateNo body

A success returns HTTP 200 with the key org_outlet.

Preconditions:

  • Outlet exists, has deleted_at empty, and has is_active: false
  • For an hq_manager: the actor has a usable hq_manager membership 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_id is empty

System Behavior:

  1. Actor reactivates the outlet
  2. For an hq_manager, the system finds the actor's hq_manager membership in the outlet's company
  3. System checks the outlet, one check at a time, and stops at the first refusal
  4. System sets is_active: true and updated_by to the actor
  5. System returns the outlet

Business Rules:

  • Which outlets an hq_manager can reactivate:
    • Any outlet of a company where they have a usable hq_manager membership. A parent company gives no access to its sub-companies.
    • A missing outlet, a deleted outlet (deleted_at set) and an outlet of any other company get one error under id. It is the same error, so the response does not show which ids exist.
    • JodGig removed an outlet with deleted_at set, so this endpoint cannot bring it back.
  • An Identities::Admin can reactivate any outlet of any company
    • A missing outlet and a deleted outlet (deleted_at set) get HTTP 404 with code record_not_found.
    • An admin may see every company, so there is nothing to hide.
  • A linked outlet cannot be reactivated here, because the daily JodGig sync can set is_active back to false. 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_active to true and never writes deleted_at
  • updated_by is the actor. created_by does not change
    • For an hq_manager, the actor is the hq_manager membership in the outlet's company.
    • For an Identities::Admin, the actor is that admin.
  • Org::OutletAssignment rows do not change, so the managers assigned before the deactivation can see the outlet again
  • Existing Org::PayRate entries become available for rate resolution again
    • The system does not copy or change Org::PayRate rows.
  • 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​

FieldDetails
ActorOrg::Membership (employer, any role)
TriggerEmployer managing their branches

Endpoint:

ActorEndpointCompany
Org::Membership, any roleGET /employers/org/outletsOptional org_company_id. See "Which companies" below

Preconditions:

  • Employer has an active Org::Membership in the company they are acting as

System Behavior:

  1. Employer navigates to outlet management
  2. System finds the companies the employer can reach
  3. System finds the outlets that the employer's role can see in those companies
  4. 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_id returns one error under org_company_id, the same error as for a company that does not exist.
  • Which outlets each role can see in a company:
RoleOutlets the role sees
hq_managerEvery outlet of the company.
area_manager, outlet_managerOnly the outlets with an active Org::OutletAssignment for their membership in that company.
  • An Org::OutletAssignment with revoked_at set gives no access.
  • An area_manager or outlet_manager with no assignment sees an empty list.
  • An outlet with org_outlets.deleted_at set never appears.
  • The list has these filters:
    • org_company_id shows the outlets of one reachable company.
    • name matches part of org_outlets.name, ignoring case.
    • is_active is true or false.
  • The list sorts by id, name, created_at or updated_at.
    • The default is name ascending.
  • The list is paginated with page and page_size, and the default page_size is 10.
  • The list does not count Jobs yet
    • An outlet can have careers_jobs, gig_jobs and gig_temp_jobs, all shown as Listings::Job.
    • The count needs a separate design.
  • is_linked_to_jodgig is true when org_outlets.remote_id is present.
    • The web page turns off the edit buttons for these outlets.
  • The response never holds a credit column of org_outlets.

Response fields:

FieldSource
idorg_outlets.id
company_idorg_outlets.company_id
nameorg_outlets.name
addressorg_outlets.address
postal_codeorg_outlets.postal_code
latitudeorg_outlets.latitude, as a string
longitudeorg_outlets.longitude, as a string
geo_area_idorg_outlets.geo_area_id
is_activeorg_outlets.is_active
is_linked_to_jodgigtrue when org_outlets.remote_id is present

Postconditions:

  • Read-only operation — no data changes

UC-6: Admin views all outlets across companies​

FieldDetails
ActorIdentities::Admin
TriggerOps 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:

ActorEndpointCompany
Identities::AdminGET /team/org/outletsAll companies. Optional org_company_id keeps one company.

Preconditions:

  • The admin is signed in. Any signed-in admin can use this endpoint.

System Behavior:

  1. Admin navigates to the outlets admin page
  2. System finds the outlets of every company
  3. System keeps only the outlets that match the filters
  4. 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_active is missing.
  • An outlet with org_outlets.deleted_at set never appears.
  • The list has these filters:
FilterRule
org_company_idKeeps the outlets of one company.
is_activetrue keeps active outlets. false keeps inactive outlets.
address_geo_area_pathKeeps the outlets in this Geo::Area and in its child areas.
nameMatches part of org_outlets.name, ignoring case.
  • The area filter follows geo_areas.path, the same as the company list in Org::Companies::TeamIndexManager.
    • The area of an outlet is org_outlets.geo_area_id.
    • address_geo_area_path is labels joined by dots, for example sg.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 list sorts by id, name, created_at or updated_at.
    • The default is name ascending.
    • When two outlets have the same value, the lower id comes first, so a page never changes between requests.
  • The list is paginated with page and page_size, and the default page_size is 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_jodgig is true when org_outlets.remote_id is present.
    • The admin can see where the data comes from.
  • The response never holds a credit column of org_outlets.

Response fields:

FieldSource
idorg_outlets.id
nameorg_outlets.name
addressorg_outlets.address
postal_codeorg_outlets.postal_code
latitudeorg_outlets.latitude, as a string
longitudeorg_outlets.longitude, as a string
geo_area_idorg_outlets.geo_area_id
is_activeorg_outlets.is_active
is_linked_to_jodgigtrue when org_outlets.remote_id is present
created_atorg_outlets.created_at
updated_atorg_outlets.updated_at
org_companyThe company of the outlet, with its id and name

Postconditions:

  • Read-only operation — no data changes

Invariants​

  1. An Outlet must belong to exactly one Org::Company — this cannot change after creation
  2. Outlets are never hard-deleted — only deactivated via is_active
  3. An inactive outlet cannot be referenced by new Gig::Job records
  4. Deactivating an outlet does not affect existing Jobs, Shifts, or Assignments
  5. Name and address are required fields

Model Interactions​

Related ModelRelationshipInteraction
Org::CompanyOutlet belongs_to CompanyEvery outlet is owned by one company.
Geo::AreaOutlet belongs_to AreaGeographic area where the outlet is located. Used for "jobs near you" on the marketplace.
Org::PayRatePayRate optionally scoped to OutletPay rates can be company-wide (outlet NULL) or outlet-specific. Outlet-specific rates take precedence.
Gig::JobJob belongs_to OutletEach Job references the outlet where the work happens. This determines which pay rates apply to its Shifts.
Org::MembershipEmployer manages outlets via membershiphq_manager has implicit access to all outlets. area_manager and outlet_manager are scoped via Org::OutletAssignment.
Org::OutletAssignmentAssignment scopes membership to outletLinks an Org::Membership to specific outlets for area_manager and outlet_manager roles.

Schema Gaps​

GapImpactSuggested Resolution
No org_outlets table exists in current DBMLOutlet concept is missing from the new system entirelyResolved 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 columnCannot 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 transitionalavailable_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 neededLegacy has credit tracking, auto-select config, etc. on locationNew org_outlets table should be clean — outlet-specific config can be separate tables if needed