Overview
jshERP implements a comprehensive Role-Based Access Control (RBAC) system that allows administrators to define roles and assign specific permissions to users. The system supports function-level permissions, button-level controls, and price visibility restrictions.Roles are tenant-scoped, meaning each tenant can define their own roles independently. System-level roles are available across all tenants.
Role Structure
Each role in jshERP contains:Unique role identifier
Role display name (e.g., “Sales Manager”, “Warehouse Clerk”)
Role type defining scope and permissions level
Price visibility restrictions (see Price Limits section)
Role value used for internal logic
Detailed role description
Whether the role is active
Display order for role listing
Associated tenant ID (null for system roles)
Role.java:1-103
Creating Roles
Assign Functions
Link specific functions (menu items, features) to this role through the UserBusiness relationship with type “RoleFunctions”.
Permission Types
Function Permissions
Functions represent menu items, pages, and major features in the system. Each function has:Unique function identifier (e.g., “01”, “0101”)
Display name of the function
Parent function for hierarchical menu structure
Route URL for navigation
Frontend component path
Function type (menu, button, etc.)
Associated button permissions (comma-separated)
Icon identifier for UI display
Open/closed state for tree navigation
Whether function is active
Function.java:1-133
Button Permissions
Button-level permissions control specific actions within pages:- Create/Add
- Edit/Update
- Delete
- Import/Export
- Approve/Audit
- Custom actions
pushBtn field of Function entities and assigned to roles via UserBusiness relationships.
Reference: UserController.java:438-456
Price Visibility Controls
jshERP includes sophisticated price visibility restrictions to control what financial information different roles can see.Price Limit Codes
Home Purchase Price - Hide purchase prices on homepage/dashboard
Home Retail Price - Hide retail prices on homepage/dashboard
Home Sales Price - Hide sales prices on homepage/dashboard
Purchase Bill Price - Hide prices in purchase documents
Retail Bill Price - Hide prices in retail documents
Sales Bill Price - Hide prices in sales documents
Configuring Price Limits
Set thepriceLimit field as a comma-separated string of limit codes:
- Purchase prices on homepage (1)
- Prices in purchase bills (4)
- Prices in sales bills (6)
RoleService.java:240-298
Price Masking Logic
When a user has price restrictions:- Checks user’s role
priceLimitsetting - Compares against current page/bill type
- Masks prices matching the restriction codes
RoleService.java:264-298
Role Assignment
Assigning Roles to Users
Users can have multiple roles simultaneously:RoleController.java:119-144
Role Functions Assignment
Link functions to roles through the UserBusiness table:- Type: “RoleFunctions”
- Key ID: Role ID
- Value: Comma-separated function IDs in format
[1],[2],[3]
UserService.java:862-876
API Endpoints
Get Role Information
RoleController.java:44-56
List All Roles
name: Filter by role namedescription: Search in description
RoleController.java:58-66
List Tenant Roles
RoleController.java:152-156
List All Roles (Including System)
RoleController.java:146-150
Update Role
RoleController.java:76-82
Delete Roles
RoleController.java:84-98
Batch Operations
Enable/Disable Multiple Roles
RoleController.java:164-177
Permission Checking
Get Current User Price Limit
UserController.java:389-405
Get Current User Role Type
UserController.java:412-429
Get User Button Permissions
The
admin user bypasses all permission checks and has access to everything.UserController.java:438-456
Common Role Configurations
System Administrator
Sales Manager
Warehouse Staff
Accountant
Validation
Check Role Name Uniqueness
RoleController.java:100-112
Multi-Tenant Considerations
Tenant Isolation:
- Roles with
tenantId = nullare system roles available to all tenants - Roles with a specific
tenantIdare only visible to that tenant - Users can only be assigned roles from their own tenant or system roles
Best Practices
Role Design Tips:
- Create roles based on job functions, not individuals
- Keep the number of roles manageable (5-15 is typical)
- Use price limits to separate operational from financial roles
- Combine function permissions with button permissions for granular control
- Consider role hierarchy in your organization
Permission Flow
Related Documentation
- User Management - Managing user accounts
- Tenant Management - Multi-tenant configuration
- System Configuration - System-wide settings