---
title: Premium Audit Batch overview
summary: Purpose, scheduling, parameters, and capabilities for the batch application.
status: draft
owner: Policy Systems Team
last_reviewed: 2026-02-18
---

# Premium Audit Batch overview

`SAIF.PremiumAudit.Batch` is a .NET Framework 4.8 console application that
recalculates workers' compensation policy premiums from submitted payroll audit
data. Each night it reads audits that underwriting has marked as ready, applies
the current payroll class code rates, writes the resulting premium adjustment
transactions back to the policy system, and produces success and error detail
reports for the operations team. The job is written in VB.NET and shares
validation logic with the `SAIF.Framework.Validation` library.

## Purpose
- Recalculate earned premium for policies with a completed payroll audit and
  post the resulting debit or credit transaction to the policy system.
- Apply the payroll class code rates in effect on the policy effective date so
  that audit adjustments match the rates the policy was rated with.
- Produce an auditable per-policy record of every adjustment, including the
  audits that were rejected and why, for the underwriting and premium accounting
  teams.

## Scheduling

| Attribute | Value |
| --- | --- |
| Frequency | Daily |
| Scheduler | Windows Task Scheduler on BATCHPRD01 |
| Expected runtime | 25-40 minutes for a typical nightly volume of 400-900 audits |
| Upstream dependencies | Payroll audit extract (`PayrollAuditExtract`, completes by 01:30) and the nightly policy system replication job |

## Command-line parameters

| Position | Name | Type | Required | Purpose |
| --- | --- | --- | --- | --- |
| 1 | Environment | String | Yes | Environment key (`DEV`, `TEST`, `PROD`) used to select the connection string and mail profile from `App.config`. |
| 2 | AuditDate | Date (`yyyy-MM-dd`) | Yes | Cut-off date; audits completed on or before this date are eligible. The scheduled task passes the previous calendar day. |
| 3 | BatchSize | Integer | No | Maximum number of audits to process in one run. Defaults to `1000`. Used to split an oversized backlog into several runs. |
| 4 | RestartCheckpoint | Integer | No | `PolicyAuditId` to resume from after a partial run. When supplied, audits with a lower id are skipped. |

## Capability summary

| Capability | Owning component | Description |
| --- | --- | --- |
| Pending audit retrieval | `AuditProcessor` (`src/SAIF.PremiumAudit.Batch/AuditProcessor.vb`) | Calls `dbo.usp_GetPendingAudits` to load the eligible `PolicyAudit` rows for the requested audit date and batch size. |
| Payroll validation | SAIF.Framework.Validation | Validates payroll amounts, class code format, and effective date ranges before any premium is calculated. |
| Premium recalculation | `AuditProcessor` (`src/SAIF.PremiumAudit.Batch/AuditProcessor.vb`) | Multiplies audited payroll by the `PayrollClassCode` rate in effect on the policy effective date and compares the result to the estimated premium. |
| Transaction posting | `AuditProcessor` (`src/SAIF.PremiumAudit.Batch/AuditProcessor.vb`) | Inserts the adjustment into `PremiumTransaction` and updates `PolicyAudit.Status` inside a single transaction per audit. |
| Batch reporting and notification | `Program` (`src/SAIF.PremiumAudit.Batch/Program.vb`) | Writes the File0/File1/File2 streams and sends the on-call notification when the error threshold is exceeded. |

## Related documentation
- Architecture
- [Batch lifecycle](batch-lifecycle.md)
- [Dependencies](dependencies.md)
- Operations and processes
- [Business rules](business-rules.md)
- [Operational runbook](operational-runbook.md)
- Tech debt

## Sources
- `src/SAIF.PremiumAudit.Batch/Program.vb`
- `src/SAIF.PremiumAudit.Batch/AuditProcessor.vb`
- `src/SAIF.PremiumAudit.Batch/App.config`
- `src/SAIF.PremiumAudit.Batch/SAIF.PremiumAudit.Batch.vbproj`
