Skip to main content

Expense to Payroll Events

Summary

Payroll subscribes to all three Expense lifecycle contracts and maintains a payroll-owned approved-expense projection. It never reads the Expense store during calculation.

Projection behavior

Expense contractPayroll projection result
ExpenseApprovedEventCreates or updates the claim projection as Approved
ExpenseRejectedEventUpdates the claim projection as Rejected
ExpensePaidEventUpdates the claim projection as Paid

Only Approved projections for the calculation period contribute to reimbursement totals. Rejected and Paid projections remain as records but are excluded from approved reimbursement calculation.

Payroll ignores duplicate event identities. For the same projected claim, an event older than the projection's last occurrence is ignored. Processing errors are negatively acknowledged and requeued.

Frozen-period behavior

The consumer continues to maintain its projection independently of payroll-run state. A frozen run cannot be recalculated, so later projection changes do not rewrite that frozen run through this consumer. Their effect on a future calculation depends on the run being eligible for calculation.

Requires confirmation

Projection reconciliation, late-event operational handling, frozen-period business policy, and ownership of corrections require confirmation.

Source References

  • microservices/src/payroll-service/Messaging/PayrollReadModelConsumer.cs
  • microservices/src/payroll-service/Domain/PayrollEntities.cs
  • microservices/src/payroll-service/Application/PayrollCalculationService.cs
  • microservices/scripts/smoke-payroll.ps1

See Also

Keywords

  • Expense events
  • Payroll Events
  • Integration contracts

Revision Information

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