Introduction
A distribution company rolls out new order management software across eight branches. On day one, a sales executive in one branch edits a customer that belongs to another branch. On day two, the regional manager complains she cannot see half of her region's orders. On day three, someone suggests giving everyone admin access "until we sort permissions out."

The software had roles, but roles alone were not enough. A role says what someone can do. A multi-branch business also needs to say where they can do it. That second dimension, scope, is what most simple role systems are missing.

In this article you will learn how to model roles and scopes, represent location hierarchies, check permissions in your application, filter lists efficiently, and present all of this in a way administrators can manage.

Roles, Permissions, and Scopes
Split the model into three parts. Permissions are fine-grained actions such as order. view, order, approve, or stock. transfer.create. Roles are named bundles of permissions, such as Sales Executive, Branch Manager, or Accountant. Scopes are the parts of the organization a role assignment applies to: one branch, a region, or the whole company.

A user can hold several role assignments, each with its own scope. The same person might be the branch manager for Pune and the accountant for the whole company. Checking access always asks: do any of this user's assignments grant this permission at a scope that contains this resource?

Modelling Location Hierarchies
Organizations are trees: company, regions, branches, sometimes warehouses within branches. Store the hierarchy explicitly, and precompute ancestry so checks do not walk the tree on every request.

`CREATE TABLE locations (
id bigint PRIMARY KEY, parent_id bigint REFERENCES locations, kind text NOT NULL
);
-- closure table: every ancestor/descendant pair, including self
CREATE TABLE location_closure (
ancestor_id bigint NOT NULL, descendant_id bigint NOT NULL,
PRIMARY KEY (ancestor_id, descendant_id)
);
CREATE TABLE role_assignments (
user_id bigint NOT NULL, role_id bigint NOT NULL,
location_id bigint NOT NULL REFERENCES locations
);

-- Can user 42 approve orders at branch 17?
SELECT EXISTS (
SELECT 1 FROM role_assignments ra
JOIN role_permissions rp ON rp.role_id = ra.role_id AND rp.permission = 'order.approve'
JOIN location_closure lc ON lc.ancestor_id = ra.location_id AND lc.descendant_id = 17
WHERE ra.user_id = 42);`

The closure table makes "Is branch 17 inside this user's region?" a single indexed join. Rebuild affected closure rows when a branch moves between regions, which is rare.

Enforcing Permissions in the Application
Centralize checks in one authorization module with a small API, such as can(user, permission, resource). Every resource that belongs to a location carries its location ID, so the check is uniform for orders, customers, invoices, and stock.

For list screens, checking each row is too slow. Instead, compute the set of location IDs where the user holds the needed permission once per request, and filter queries with location_id = ANY($1). Cache that set for the request, and invalidate it when role assignments change. A follow-up article in this series covers pushing the same rules down into Postgres with row-level security as a second layer.

Making It Manageable for Administrators
Permissions fail when admins cannot understand them. Provide a screen that shows, for any user, every assignment with its role and scope and an "effective access" view that answers "What can this person do at this branch, and why?" Ship sensible default roles that match how most customers work, and let customers clone and adjust them rather than build from scratch.

Practical Examples: Real-World Use Cases
A pharmaceutical distributor with 14 depots uses branch-scoped roles for depot staff, region-scoped roles for area managers, and company-scoped roles for finance. When two depots merged, an admin moved one location under the other, and all access updated automatically.

A facilities services company scopes technicians to the sites they service, so the mobile app only lists work orders for their sites, while supervisors see their whole zone.

A B2B SaaS for restaurant groups lets franchise owners manage their own outlets while the brand's head office sees menus and sales across all outlets but cannot change local staff schedules.

Common Mistakes to Avoid

  • Encoding location in role names, such as Pune_Manager. Roles multiply and become unmanageable.

  • Checking permissions in the UI only. Every API endpoint must enforce the same rules.

  • Filtering lists in application memory after loading all rows.

  • Forgetting resources that move between locations, such as stock in transit. Decide which location owns them at each stage.

  • Giving temporary admin access during rollout and never removing it.

Best Practices: Actionable Tips

  • Keep permissions fine-grained and roles coarse.

  • Store a location ID on every location-owned record from the start.

  • Write automated tests for cross-branch access, including attempts that should fail.

  • Log permission denials; they reveal both attacks and badly configured roles.

  • Review role assignments quarterly with each customer's admins.

Conclusion
Multi-branch businesses need permissions that combine what a person can do with where they can do it. Model permissions, roles, and scopes separately, represent your location hierarchy with a closure table, enforce checks in one central module, and give administrators clear views of effective access. The takeaway: add scope to your role model early, because retrofitting it after go-live touches every query in the system.

Build Multi-Branch Software With Parallaxis
Parallaxis builds ERP and operations software for multi-branch B2B companies, with location-scoped permissions, approvals, and reporting designed around how your business is actually organized. If your current system cannot keep branches separate, visit parallaxis.in to explore our ERP solutions or talk to our team