Automated Payroll Configuration Guide: PPh 21, BPJS, and System Integration
N
Back to Blog

Automated Payroll Configuration Guide: PPh 21, BPJS, and System Integration

Tutorial
Nugroho Setiawan · Konsultan IT & Full Stack Developer 29 Jun 2026 13 min baca 2,593 kata 380 views
This article guides you through automating payroll, PPh 21, and BPJS with technical and regulatory details. Explore system architecture, code examples, and best practices to enhance operational efficiency at your hospital or clinic.

Payroll management is one of the most crucial operational aspects yet often time-consuming and error-prone, especially in dynamic environments such as hospitals or clinics. With the complexity of PPh 21 regulations that continue to evolve according to the latest Minister of Finance Regulation (PMK), as well as various BPJS Kesehatan and BPJS Ketenagakerjaan contribution components based on Presidential Regulations and Government Regulations, manual payroll processes can become a significant administrative burden. Errors in calculations not only disadvantage employees but can also trigger sanctions from tax and BPJS authorities. Imagine the wasted time for data reconciliation, manual corrections, and monthly report preparation that could actually be allocated to innovation or improving patient services. This guide is designed for Hospital IT Managers, clinic owners, operational managers, and decision-makers seeking technology solutions to simplify and secure their payroll processes. We will discuss in depth how to configure an integrated automated payroll system, from basic concepts to technical implementation, complete with code examples and best practices that you can immediately apply to achieve maximum efficiency.

Basic Concepts of Payroll Automation, PPh 21, and BPJS

Payroll automation is not merely transferring data to a spreadsheet, but building an intelligent system capable of calculating basic salary, allowances, deductions, PPh 21, as well as BPJS Kesehatan and Ketenagakerjaan contributions accurately and automatically according to applicable regulations in Indonesia. For PPh 21, the calculation base is gross income which includes salary, fixed allowances, variable allowances, bonuses, and others. From this gross income, occupational expenses are deducted (maximum Rp 6,000,000 per year or 5% of gross income), pension/JHT contributions paid by the employee, and then adjusted for Non-Taxable Income (PTKP) according to marital status and number of dependents. The current progressive PPh 21 rates refer to PMK-168/PMK.03/2023, with rate brackets of 5%, 15%, 25%, 30%, up to 35% for income above Rp 5 billion.

Furthermore, BPJS Kesehatan contributions are regulated in Presidential Regulation Number 82 of 2018. For wage-receiving workers (PPU) such as hospital or clinic employees, the contribution is 5% of monthly salary or wages, with the highest calculated salary limit being Rp 12,000,000. Of that 5%, 4% is paid by the employer and 1% is deducted from the employee's salary. It is important to ensure the system can cap contribution calculations if an employee's salary exceeds that upper limit.

For BPJS Ketenagakerjaan, the components are more diverse and regulated in Government Regulation Number 45 of 2015. These include Old Age Security (JHT) totaling 5.7% (3.7% borne by the company, 2% deducted from the employee), Work Accident Security (JKK) fully borne by the company with rates varying between 0.24% and 1.74% depending on the occupational risk level, Death Security (JKM) at 0.3% also borne by the company, and Pension Security (JP) totaling 3% (2% borne by the company, 1% deducted from the employee). The accumulation of these calculations, plus other allowance and deduction components such as loans, attendance, or fines, requires a precise calculation engine. The automated system must be able to manage all these variables, perform repeated calculations each payroll period, and produce output ready for reporting to DJP Online and the BPJS portal.

As an example, an employee with a basic salary of Rp 8,000,000, meal allowance of Rp 1,000,000, and transportation allowance of Rp 500,000 will have gross income of Rp 9,500,000. The system must be able to calculate PPh 21 based on the appropriate PTKP, as well as BPJS Kesehatan contributions of 1% of Rp 9,500,000 and BPJS Ketenagakerjaan (JHT 2%, JP 1%) from the relevant salary. Accuracy in every detail is key to avoiding audits and maintaining employee satisfaction.

Architecture and Technical Implementation of an Automated Payroll System

Building a robust and compliant automated payroll system requires a well-planned architecture. As a foundation, we recommend using modern technologies that support scalability and maintainability. For the backend, Laravel 11.x with PHP 8.2+ is an excellent choice due to its rich ecosystem, powerful ORM (Eloquent), and task scheduling features (Laravel Scheduler/Horizon) that are essential for monthly payroll processes. Another alternative is Node.js 20 LTS with Express.js or NestJS, which offers high performance for APIs and real-time integration. A relational database such as PostgreSQL 16 is ideal for storing employee data, salary components, payroll history, and tax/BPJS configurations due to data consistency and complex query capabilities.

On the frontend side, frameworks such as React 18.x or Vue 3.x can be used to build an intuitive user interface for HR, finance, and employees to view payslips. Communication between frontend and backend will be through RESTful API. For integration with external systems, an API Gateway such as Nginx can be used to manage requests and security.

The crucial point in implementation is integration with other systems. The payroll system must be able to retrieve attendance data from the attendance system (for example, a custom API-based fingerprint machine or through standards such as HR-XML), employee master data from the existing HRIS (for example, via RESTful API), and send payment data to the banking system for salary auto-transfer. For reporting, the system must be able to produce files that comply with the DJP Online format (e-SPT PPh 21) and BPJS portals (SIPP for BPJS Ketenagakerjaan, e-Dabu for BPJS Kesehatan). The use of data standards such as FHIR R4 (Fast Healthcare Interoperability Resources) can be considered if employee data is also integrated with SIMRS or SIM Klinik, although this is more common for clinical data, FHIR has Person and Practitioner resources that can be adapted for basic demographic data.

Core modules that must exist in the system include: (1) Employee Master Module: stores details such as NPWP, NIK, BPJS No., PTKP status, basic salary, fixed allowances. (2) Salary Component Module: manages variable allowances, bonuses, deductions (loans, fines). (3) Tax & BPJS Configuration Module: stores PTKP table, PPh 21 rates, BPJS contribution percentages that can be updated. (4) Payroll Run Module: core calculation engine that executes payroll process. (5) Reporting Module: produces payslips, monthly PPh 21 reports, BPJS reports. It is important to always monitor the latest regulatory releases and updates from the government to ensure the system remains compliant. The mechanism for updating regulatory parameters must be designed to be flexible and easy to implement without significant code changes.

Example Implementation Code for PPh 21 and BPJS Algorithms

The following is a simple implementation example for calculating PPh 21 and BPJS using PHP (assuming the Laravel framework for structure).

<?php namespace App; use Illuminate; class PayrollCalculator { public function calculatePph21(array $employee, float $grossSalary): float { $ptkp = $this->getPTKP($employee['marital_status'], $employee['dependents']); $biayaJabatan = min(0.05 * $grossSalary, 500000); // Max Rp 500.000/bulan $neto = $grossSalary - $biayaJabatan - ($employee['bpjs_jht_contribution'] ?? 0) - ($employee['bpjs_jp_contribution'] ?? 0); $pkp = max(0, $neto - $ptkp); $pph21 = 0; // Tarif PPh 21 sesuai PMK-168/PMK.03/2023 $tarif = [ [0, 60000000, 0.05], [60000001, 250000000, 0.15], [250000001, 500000000, 0.25], [500000001, 5000000000, 0.30], [5000000001, INF, 0.35] ]; foreach ($tarif as $t) { list($min, $max, $rate) = $t; if ($pkp > $min) { $taxableAmount = min($pkp, $max) - $min; $pph21 += $taxableAmount * $rate; } else { break; } } return $pph21; } private function getPTKP(string $maritalStatus, int $dependents): float { $ptkp = 54000000; // TK/0 if ($maritalStatus === 'K') { $ptkp += 4500000; // K/0 } $ptkp += min($dependents, 3) * 4500000; // Max 3 tanggungan return $ptkp; } public function calculateBpjs(float $baseSalary): array { $bpjsKesLimit = 12000000; $bpjsJpLimit = 9559600; // Batas JP 2024 (contoh) $bpjsKesEmployee = min($baseSalary, $bpjsKesLimit) * 0.01; // 1% karyawan $bpjsKesCompany = min($baseSalary, $bpjsKesLimit) * 0.04; // 4% perusahaan $bpjsJhtEmployee = min($baseSalary, $bpjsJpLimit) * 0.02; // 2% karyawan $bpjsJhtCompany = min($baseSalary, $bpjsJpLimit) * 0.037; // 3.7% perusahaan $bpjsJkCompany = $baseSalary * 0.0024; // JKK risiko rendah, 0.24% perusahaan $bpjsJmCompany = $baseSalary * 0.003; // JKM, 0.3% perusahaan $bpjsJpEmployee = min($baseSalary, $bpjsJpLimit) * 0.01; // 1% karyawan $bpjsJpCompany = min($baseSalary, $bpjsJpLimit) * 0.02; // 2% perusahaan return [ 'bpjs_kes_employee' => $bpjsKesEmployee, 'bpjs_kes_company' => $bpjsKesCompany, 'bpjs_jht_employee' => $bpjsJhtEmployee, 'bpjs_jht_company' => $bpjsJhtCompany, 'bpjs_jk_company' => $bpjsJkCompany, 'bpjs_jm_company' => $bpjsJmCompany, 'bpjs_jp_employee' => $bpjsJpEmployee, 'bpjs_jp_company' => $bpjsJpCompany ]; } }

The code above shows two main functions. The calculatePph21 function calculates annual PPh 21 (to then be divided by 12 for monthly PPh 21) based on gross salary, occupational expense, contributions paid by employee, PTKP, and progressive rates according to PMK-168/PMK.03/2023. The getPTKP function is a helper to determine the PTKP amount based on marital status (TK/K) and number of dependents. The calculateBpjs function calculates BPJS Kesehatan and Ketenagakerjaan contributions (JHT, JKK, JKM, JP) for employee and company, taking into account the upper salary limits for BPJS Kesehatan and Jaminan Pensiun (JP) according to latest regulations. It is important to always update the upper limit values (such as bpjsJpLimit) and tax rates if there are regulatory changes.

Data Integration and Error Handling

Data integration is the backbone of an automated payroll system. Employee data must be consistent and accurate across systems (HRIS, attendance, payroll). A realistic JSON payload for payroll input data might look like this:

{  "employee_id": "EMP001",  "npwp": "01.234.567.8-901.234",  "bpjs_kes_id": "0001234567890",  "bpjs_tk_id": "12345678901",  "full_name": "Nugroho Setiawan",  "position": "Operations Manager",  "base_salary": 15000000,  "fixed_allowances": {    "transport": 1000000,    "meal": 500000  },  "variable_allowances": {    "performance_bonus": 2000000,    "overtime": 750000  },  "deductions": {    "loan_installment": 1000000,    "absenteeism_deduction": 200000  },  "marital_status": "K",  "dependents": 2,  "attendance_days": 22,  "jht_employee_contribution": 0,  "jp_employee_contribution": 0}

The payload above includes basic employee information, basic salary, allowances (fixed and variable), deductions, PTKP status, and attendance data. The payroll system will process this payload to calculate net salary, PPh 21, and BPJS contributions. However, in the integration and calculation process, errors can occur. An example of a frequently appearing error message is: {"code": "400", "message": "NPWP invalid format or BPJS Kesehatan ID not found for EMP001"}.

Effective error handling is very important. First, perform strict validation of input data on the server side (backend) using comprehensive validation rules (for example, NPWP format, validity of BPJS No., salary value range). If there is invalid data, the system must reject the input and provide a clear error message. Second, implement detailed logging for every payroll transaction, including input, calculation output, and every error that occurs. This log will be very helpful in the debugging and audit process. Third, provide an automatic notification mechanism to the HR/Finance team if there is a critical error or anomaly in the calculation. Fourth, consider a retry mechanism for integration with third parties (for example, banks or the BPJS portal) if a temporary connection failure occurs. Finally, data security is the main priority. Ensure all sensitive data (salary, NPWP, BPJS No.) is encrypted both at rest and in transit using protocols such as HTTPS/TLS 1.2+. Implement Role-Based Access Control to ensure only authorized users can access certain payroll data. Compliance with information security standards such as ISO 27001 and personal data protection regulations such as relevant PMK will strengthen the integrity of the system.

Best Practices

  1. Accurate and Comprehensive Data Validation: Ensure all employee data, from NPWP, NIK, BPJS No., PTKP status, to salary components, is strictly validated at every input point. Clean data is the foundation for accurate payroll calculations, reducing the risk of costly manual errors and sanctions.
  2. Code Modularity for Regulations: Design the payroll system with separate modules for PPh 21, BPJS Kesehatan, BPJS Ketenagakerjaan, and salary component calculations. This approach facilitates regulatory updates (for example, changes to PMK concerning PPh 21 or Perpres concerning BPJS) without having to overhaul the entire system.
  3. Extensive Automated Testing: Write unit tests and integration tests extensively for every calculation function, especially PPh 21 and BPJS. Provide test data with various scenarios (salary below/above threshold, various PTKP statuses) to ensure calculation accuracy under every possible condition.
  4. Detailed Logging and Monitoring: Implement a logging system that records every payroll process, data input, calculation result, and every anomaly or error. Use monitoring tools to monitor system performance and detect potential issues before they become critical, ensuring transparency and accountability.
  5. Strict Data Security: Implement end-to-end data encryption for sensitive employee information, both when stored in the database and when transferred between systems. Use role-based authorization (RBAC) to restrict access to payroll data and conduct regular audit trails to track every user activity.
  6. Scalability and Optimal Performance: Design a system architecture capable of handling growth in the number of employees and payroll transaction volume without performance degradation. Optimize database queries, use caching, and consider microservices architecture if needed for large-scale organizations.
  7. Automatic Regulatory Compliance: Build a mechanism to update PPh 21 and BPJS regulatory parameters automatically or semi-automatically from trusted sources. This ensures the system is always compliant with the latest regulations without time-consuming and error-prone manual intervention.
  8. User Acceptance Testing (UAT) with the HR/Finance Team: Actively involve the HR and Finance teams in system testing. UAT will ensure that the system meets their operational needs, calculation results are as expected, and the workflow is intuitive, thereby minimizing user rejection.
  9. Disaster Recovery Plan: Prepare a comprehensive data backup and system recovery plan to face worst-case scenarios such as server failure or cyber attack. Ensure payroll data can be recovered quickly and its integrity maintained to minimize the impact on operations.

FAQ

1. What are the main challenges in implementing an automated payroll system in a hospital/clinic?
The main challenges include the complexity of dynamic PPh 21 and BPJS regulations, the need for integration with existing HRIS or SIMRS systems, and ensuring employee data accuracy. In addition, the security aspect of sensitive data and adoption by the HR/Finance team are also crucial factors that must be considered from the start of the project.

2. How does this system handle changes to government PPh 21 or BPJS regulations?
The system is designed with a flexible configuration module for regulatory parameters (for example, PPh 21 rates, BPJS salary ceiling, PTKP). When there is a regulatory change (for example, a new PMK), the IT team or administrator can easily update these parameters through the admin interface without significant code changes, ensuring the system remains compliant.

3. Can this automated payroll system be integrated with an existing HRIS or SIMRS system?
Yes, this system is designed to be able to integrate with existing HRIS or SIMRS systems via RESTful API. We can build custom adapters or connectors to retrieve employee, attendance, and salary component data from the existing system, as well as send payroll data back if needed, ensuring seamless data flow.

4. How long does it take to fully implement an automated payroll system?
Implementation time varies depending on the scale of the organization, the complexity of internal regulations, and the level of integration required. For a medium-sized hospital or clinic, this project can take 3 to 6 months, including the requirements analysis, development, testing, and user training phases. More complex implementations with many integrations may take longer.

5. How is employee salary data security guaranteed in this automated system?
Data security is the top priority. We apply data encryption at the database (data at rest) and during transmission (data in transit) using the SSL/TLS protocol. Access to the system is strictly controlled through role-based access control (RBAC), and all user activities are recorded in an audit trail. We also ensure compliance with industry information security standards such as ISO 27001 and personal data protection regulations.

6. Does this system provide comprehensive reporting features for DJP and BPJS?
Of course. This automated payroll system is equipped with a reporting module capable of generating the various required reports. These include individual payslips, monthly salary recapitulation reports, CSV/XML files ready to be uploaded to DJP Online for PPh 21 (e-SPT), as well as files for the SIPP BPJS Ketenagakerjaan portal and e-Dabu BPJS Kesehatan, ensuring your reporting compliance.

Automating payroll with complex PPh 21 and BPJS calculations is a strategic step for any healthcare organization that wants to improve operational efficiency and minimize compliance risks. With proper implementation, this system not only reduces the administrative burden on HR and Finance teams, but also ensures payment accuracy, transparency, and employee satisfaction. As an Operations Manager & Full Stack Developer with extensive experience in systems such as SIMRS, SIM Klinik, and ERP, I fully understand the nuances and challenges of integrating complex technology solutions. If you are looking for a trusted partner to design, develop, or implement an automated payroll system tailored to the specific needs of your hospital or clinic, do not hesitate to contact me. Let's discuss how we can help you achieve the highest operational efficiency through innovative and integrated technology solutions.

This article is part of the education by Nugroho Setiawan, an IT consultant in Jogja. Related solutions: SIMRS SIM Klinik Integrator Bridging BPJS & SatuSehat. Need free consultation?

Terakhir diperbarui 18 Oct 2026

Komentar

Komentar ditinjau sebelum tampil.

Belum ada komentar. Jadilah yang pertama!

Butuh bantuan implementasi atau dashboard data?

Saya membantu konsultasi IT, pengembangan aplikasi, dan visualisasi data untuk rumah sakit, klinik, dan bisnis di Yogyakarta (DIY), Magelang, dan sekitarnya.

WhatsApp Jasa Visualisasi Data Demo VizStudio
Produk & Solusi SIMRS ERP Portfolio Konsultasi Gratis