Skip to main content

Payroll Calculation Engine

Summary​

The calculation service resolves an editable run, loads tenant-period projections and configuration, calculates eligible employees, replaces outcomes, and persists totals, audit, timeline, and outbox records.

Audience​

Backend and frontend developers, QA and DevOps engineers, support and security engineers, and solution architects.

Overview​

The calculation service resolves an editable run, loads tenant-period projections and configuration, calculates eligible employees, replaces outcomes, and persists totals, audit, timeline, and outbox records.

Technical Detail​

Inputs​

Inputs are the period request, active workforce profiles, Attendance and Leave snapshots, active/effective salary components, advance summaries, adjustments, manual overtime, enabled statutory settings, and approved Expense snapshots.

Pipeline​

The service validates the period, resolves or creates the period and editable run, blocks frozen-period recalculation, replaces prior editable outcomes, loads inputs in sets, calculates each employee with an Attendance snapshot, aggregates totals, and stages technical evidence and an integration event.

Outputs and state​

Outputs are run details, calculation records, run totals, JSON breakdowns, audit/timeline records, and an outbox message. The service is stateful through EF Core; individual calculation helpers are static and deterministic for supplied records.

Missing inputs and errors​

An employee missing an Attendance snapshot is skipped. Missing Leave, overtime, Expense, adjustments, statutory settings, or advance data is treated as empty/zero. There is no per-employee error result or partial-success report; exceptions fail the request before the final save.

Extension and limitations​

Extension currently means changing the service and persisted models; no strategy/plugin interface is present. Formula governance, explicit validation objects, and large-run partitioning are not implemented.

Source References​

  • microservices/src/payroll-service/Application/PayrollCalculationService.cs
  • microservices/src/payroll-service/Domain/PayrollEntities.cs
  • microservices/src/payroll-service/Infrastructure/PayrollDbContext.cs

See Also​

Keywords​

  • Payroll Service
  • Payroll Calculation Engine
  • Technical architecture

Revision Information​

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly