Overview
Employee management in NominaSoft covers the complete lifecycle from initial registration through payroll calculation. The system stores employee data intab_emplea and provides CRUD functions for all operations.
Employee Data Structure
Thetab_emplea table contains comprehensive employee information organized into three categories:
Basic Information
| Field | Type | Description | Constraints |
|---|---|---|---|
id_emplea | DECIMAL(10) | Unique employee identifier | Primary key, auto-generated |
nom_emplea | VARCHAR | Employee first name | ≥ 3 characters |
ape_emplea | VARCHAR | Employee last name | ≥ 2 characters |
ind_genero | BOOLEAN | Gender indicator | TRUE = Female, FALSE = Male |
dir_emplea | VARCHAR | Home address | ≥ 5 characters |
tel_emplea | DECIMAL(10,0) | Phone number | 10-digit number |
ind_estrato | DECIMAL(1) | Socioeconomic stratum | 1-6 |
Personal Information
| Field | Type | Description | Constraints |
|---|---|---|---|
ind_est_civil | DECIMAL(1) | Civil status | 0=Single, 1=Married, 2=Divorced, 3=Widowed, 4=Other |
num_hijos | DECIMAL(1,0) | Number of children | ≥ 0, whole numbers only |
val_tipo_sangre | VARCHAR | Blood type | e.g., A+, O-, AB+ |
val_edad | DECIMAL(2,0) | Age | ≥ 16 years |
Labor Information
| Field | Type | Description | Constraints |
|---|---|---|---|
id_cargo | DECIMAL(2,0) | Position/role ID | Foreign key to tab_cargos |
val_sal_basico | DECIMAL(8) | Basic monthly salary | ≥ 0 |
fec_ingreso | DATE | Hire date | Valid date |
The
id_cargo must reference an existing position in the tab_cargos table. If the position doesn’t exist, you’ll receive SQLSTATE 23503 (Foreign Key Violation).Creating Employees
Use thefun_insert_emplea() function to register new employees. The function automatically generates the employee ID.
Function Signature
Example: Creating an Employee
ID Generation Logic
The system automatically generates sequential employee IDs:- First employee gets ID 1
- Each subsequent employee gets the next available number
- No ID conflicts or duplicates
Updating Employee Information
Thefun_update_emplea() function allows modification of all employee fields except the ID.
Common Update Scenarios
Salary Adjustment
Salary Adjustment
Update an employee’s basic salary (e.g., for annual raise):
Position Change (Promotion)
Position Change (Promotion)
Update employee’s position when promoted:
Contact Information Update
Contact Information Update
Update address and phone number:
Update Implementation
The function updates all fields for the specified employee:You must provide all employee fields when updating, even if only changing one value. The function replaces all fields with the provided values.
Deleting Employees
Usefun_delete_emplea() to remove employee records. This is typically used for:
- Employees who never actually started
- Test records
- Data cleanup
Deletion Function
Example: Delete Employee
Cascade Deletion Behavior
Due to foreign key constraints withON DELETE CASCADE, deleting an employee automatically removes:
Querying Employee Information
View All Employees with Position Names
Find Employees by Salary Range
Check Transportation Subsidy Eligibility
Employee-to-Payroll Integration
When payroll is calculated, the system processes each employee:Salary calculation per employee
For each employee, the system:
- Retrieves their
val_sal_basico(basic salary) - Calculates prorated amount based on payment period
- Determines transportation subsidy eligibility
- Applies percentage-based deductions (EPS, AFP)
Payroll Impact of Employee Changes
| Employee Change | Payroll Impact |
|---|---|
| Salary increase | Affects basic salary and percentage-based deductions (EPS, AFP) |
| Salary decrease | May trigger transportation subsidy eligibility |
| Position change | No direct impact (unless accompanied by salary change) |
| Hire date | No impact on current payroll (historical reference only) |
| Deletion | Removes all historical payroll records (cascading delete) |
Validation and Constraints
The employee table enforces several data quality constraints:Name Validation
- Names cannot be empty or just whitespace
- First name must be at least 3 characters
- Last name must be at least 2 characters
Numeric Validations
Referential Integrity
- Every employee has a valid position
- If a position is deleted, associated employees are also deleted (or blocked if they exist)
- Position ID updates automatically propagate to employees
Best Practices
Salary Updates
Salary Updates
- Always verify the current salary before updating
- Document the reason for salary changes
- Consider the payroll period when applying changes
- Update immediately after period closes to avoid mid-period confusion
Employee Deletion
Employee Deletion
- Never delete employees with payroll history
- Instead, create an inactive status indicator if needed
- Only delete test records or employees who never started
- Always backup data before performing deletions
Data Quality
Data Quality
- Validate phone numbers are 10 digits
- Use consistent blood type format (e.g., A+, O-, AB+)
- Verify position exists before assigning
- Keep ages updated (or calculate from birth date if implemented)
Transportation Subsidy
Transportation Subsidy
- Monitor salary changes near the SMLV threshold
- Employees just below threshold qualify for extra subsidy
- Small salary increase could reduce net pay if subsidy is lost
- Current threshold: 2 × SMLV (configurable in
tab_pmtros)
Next Steps
Payroll Calculation
Learn how employee data is used in payroll processing
Error Handling
Understand error codes for employee operations