Prerequisites
Before you begin, ensure you have:- PostgreSQL 12 or higher installed
- Database access with CREATE privileges
- Basic understanding of SQL
Step 1: Initialize the Database
Create the Database Schema
Run the complete database schema script to create all necessary tables. The system includes tables for employees, positions, concepts, parameters, and payroll records.Key tables created:
tab_conceptos: Payroll concepts (earnings/deductions)tab_cargos: Job positionstab_meses: Month definitionstab_pmtros: System parameters (SMLV, transport allowance, etc.)tab_emplea: Employee recordstab_novedades: Payroll adjustments/noveltiestab_nomina: Final payroll calculations
Step 2: Configure System Parameters
Set up your company parameters using thefun_insert_pmtros() function:
The transport allowance is automatically applied to employees earning up to 2x the minimum wage (SMLV × ind_num_trans).
Step 3: Set Up Months
Insert month definitions for payroll processing:Step 4: Create Job Positions
Define the job positions in your organization:Step 5: Define Payroll Concepts
Create the payroll concepts that will be used in calculations:Step 6: Add Employees
Register employees using thefun_insert_emplea() function:
Step 7: Add Payroll Novelties (Optional)
Register any payroll adjustments for the period, such as bonuses, overtime, or deductions:Novelties are optional adjustments. If no novelties are added, the system will calculate standard payroll based on base salaries and mandatory deductions.
Step 8: Calculate Payroll
Run the main payroll calculation function:2025- Year (must match tab_pmtros.ano_nomina)1- Month (must match tab_pmtros.mes_nomina)1- Period (1 or 2 for biweekly pay)
- Validate parameters against tab_pmtros
- Delete any existing payroll for the period
- Calculate base salary (prorated for biweekly)
- Apply transportation allowance if salary ≤ 2×SMLV
- Calculate mandatory deductions (EPS 4%, AFP 4%)
- Insert all results into tab_nomina
Step 9: View Results
Query the payroll results:Expected Output
After running the payroll calculation, you should see records intab_nomina with:
- Base salary: Prorated for 15 days (biweekly) or 30 days (monthly)
- Transportation allowance: Applied to employees earning ≤ 2×SMLV
- EPS deduction: 4% of base salary (monthly)
- AFP deduction: 4% of base salary (monthly)
- Optional concepts: Any bonuses or overtime from tab_novedades
Next Steps
Employee Management
Learn how to manage employee records
Concepts Configuration
Configure payroll concepts and rules
Payroll Calculation
Deep dive into payroll calculations
Database Schema
Explore the complete database structure
Troubleshooting
Error: Year/month/period don't match PMTROS
Error: Year/month/period don't match PMTROS
Ensure the parameters you pass to
fun_act_nomina() match the values in tab_pmtros:Employee not receiving transportation allowance
Employee not receiving transportation allowance
The transportation allowance is only applied if:
- Base salary ≤ (SMLV × ind_num_trans)
- Default: salary ≤ 2,847,000 (2 × 1,423,500)
tab_emplea.Position doesn't exist error
Position doesn't exist error
Before adding employees, ensure the position exists:Create missing positions with
fun_insert_cargos().Payroll calculation returns FALSE
Payroll calculation returns FALSE
Check the PostgreSQL NOTICE messages for specific error details:
- 22008: Invalid year/month/period
- 23502: NULL value in required field
- 23503: Foreign key violation (position doesn’t exist)
- 23505: Duplicate record