Introducing Payroll Engine
Tags: opensource, architecture, payroll, automation
Published: 2023-09-21 08:32:01

Payroll Engine is a multi-client payroll solution designed for use in different industries and countries. The software is aimed at payroll service providers and companies that need to comply with various regulations and rules. As an API-first cloud solution, Payroll Engine is the central source of payroll data and can be embedded into HR and ERP software.

The engine was designed with the following goals in mind.
- **HR and Employee** - Always up-to-date employee data and fault-tolerant data collection with special case coverage.
- **Payroll Management** - Continuous payroll and forecasting for predictive analytics.
- **Development and Implementation** - Payroll professionals can independently develop and test the payroll application.
- **Partners and Peripheral Systems** - Continuous integration of third-party data, such as tax and insurance data, and reporting of employee wages to government and partners.

### Payroll Application
To achieve the desired flexibility, the software is divided into two areas.
- **Backend server** with the basic services for calculating and storing payroll data.
- **Regulations** as payroll applications that are executed by the backend server at runtime.

> 👉 > The article [Building Domain Frameworks for Business Applications](https://dev.to/giannoudis/building-domain-frameworks-for-business-applications-307k) describes the implementation of this architectural model.

#### Backend Server
The backend server provides the model for collecting payroll data and divides the `Tenant` into `Divisions` for which `Payroll` is performed. Each `Employee` is assigned to one or more `Divisions` and can receive multiple pay slips per work period.

![Backend Model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqf6v74yznvyoiepaaan.png)

#### Regulations
The isolated payroll logic is managed as a regulation, a software module that collects, calculates, and reports payroll data.

![Regulation Objects](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtase4jw9c8onmmg5zl0.png)

Runtime behavior is controlled with Low-Code in `C#` and No-Code with `Actions`. `Clusters` provide an advanced tagging mechanism for grouping and filtering the regulation objects.

> 👉 See the article [No-Code and Low-Code for Payroll Software Development](https://dev.to/giannoudis/no-code-and-low-code-for-payroll-software-development-1c35) for more details on payroll automation.

Like image or CAD layers, regulations can be stacked in the `Payroll`. The sum of all regulation layers forms the *virtual image* of the payroll application. Following the principles of object orientation, overlay regulation layers can use, adapt and extend the objects and data of the underlying layers.

Regulations can be shared across divisions and tenants.

![Regulation Composition](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jp3zcm2n47righ14637f.png)

The structured design of the regulation layers enables centralized management and distribution of regulations and avoids data redundancy. Without affecting production data, future developments are carried out in additional regulations in a development payroll.

### Payroll Services
Payroll services are divided into three areas:
- **Setup** regulation development and tenant onboarding.
- **Daily business** recording employee and company cases.
- **Payroll** managing payroll runs.

![Payroll Services](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/681cl4wivjfxkwnq2sax.png)

The data stored in each area is assigned to a time calendar.

The **Culture Calendar** controls the date and number format, including the currency. The **Payroll Calendar** determines the pay cycle and pay period and how years, months and weeks are handled.

Based on the calendar, phase information is handled differently:
- Regulations are valid from the start date of the payroll period and cannot be changed during this period (Payroll Calendar).
- Case values are kept as time values for which the validity period is determined (Culture calendar).
- Payroll results are assigned to a specific payroll period (Payroll calendar).

> 👉 The handling of time data is described in the article [Travel through Time Data](https://dev.to/giannoudis/travel-through-time-data-2op1).

#### Regulation Development
The web application provides a regulation editor that takes into account payroll layers.

![Regulation Objects](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2057a6iisn75sw64hxjc.png)

#### Regulation Testing
Regulation testing is performed using the console application with the following areas of testing.
- Cases: availability, composition, and validation.
- Payroll
    - Collectors, wage types and user-defined results
    - Retroactive results
    - Multiple employees and pay periods
- Report generation data

> Automated business case testing enables test-driven development.

#### Case Management
When entering employee and business cases, the validity period is determined in addition to the value. This allows retroactive and future changes, as well as the unlimited undo of previous changes.

![Case Management](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q66a8dpo6hmzjoti2s80.png)

> 👉 For an introduction to the use case driven approach, see the article [Use Case Driven Development with Low-Code](https://dev.to/giannoudis/use-case-driven-development-with-low-code-4e4d).

#### Payroll Management
Payroll can be run at any time using the case values that affect the run period. Retroactive changes are detected and values are recalculated up to the current period.

![Payroll Management](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s26g7sa1lshfpn7u7unk.png)

Legal forecasts are multi-level and can be run more than once per payroll period. Only one legal forecast can be active per payroll period. Forecast payroll runs are unlimited and include case values entered for the current forecast.

### Technologies Used
The following technologies are used.

![Payroll Technologies](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6foor5ujb203dzriwbwe.png)

The backend server requires a SQL Server database and runs on Linux and Windows. The web and console application also run on Linux and Windows.

### Open-Source Project
The Payroll Engine is an Open Source project (MIT license) and is currently in pre-release. 

👉 Feedback and contributions are welcome.
👉 More information on the [Payroll Engine GitHub Wiki](https://github.com/Payroll-Engine/PayrollEngine/wiki).