# Commission Statement Reconciliation

Parse carrier commission statements and reconcile them against expected commission amounts, opening a task for every discrepancy found.

## When to use

- A carrier has sent a new commission statement (PDF, scanned image, or CSV) that needs to be checked against expected payouts.
- You need to identify underpayments, overpayments, or missing policies on a statement before books are closed for the period.
- Recurring statement processing needs a consistent, repeatable reconciliation trail for audit purposes.

## Tools

- `parse-document`
- `shell-execute`
- `write-file`
- `create-task`

## Playbook

1. Receive the carrier statement file (PDF, scanned image, or CSV) and confirm the carrier name and statement period before processing.
2. Use `parse-document` to extract text and line-item data from the statement — policy numbers, insured names, premium amounts, and commission amounts paid.
3. Use `shell-execute` to normalize the extracted line items into a structured table (e.g. CSV or JSON) suitable for comparison, handling carrier-specific formatting quirks.
4. Use `shell-execute` to diff the normalized statement data against the expected commission figures (from the agency's own records) by policy number, computing the variance for each line.
5. Use `write-file` to save the full reconciliation output — matched lines, variances, and any policies present on one side but missing from the other — to a dated report file.
6. For each discrepancy above the agency's tolerance threshold (underpayment, overpayment, or missing policy), use `create-task` to open a discrepancy task with the policy number, expected amount, paid amount, and variance so a human can investigate.
7. If a statement line references coverage terms, binding status, or claims activity that requires interpretation, do not resolve it yourself — open a `create-task` handoff for a licensed agent instead.
8. Summarize the reconciliation run (total lines processed, discrepancies found, tasks opened) and attach the report location to the summary task or comment.

## Failure modes

- Statement formatting varies by carrier and `parse-document` may misread column alignment, especially on scanned images — always spot-check a sample of extracted lines before diffing.
- Policy numbers may be formatted inconsistently between the carrier statement and internal records (leading zeros, dashes) — normalize both sides before comparing, or you will generate false-positive discrepancies.
- Do not infer or state whether a discrepancy stems from a coverage or binding issue — treat every variance as a numbers-reconciliation fact and escalate any coverage-related question via `create-task` to a licensed agent.
- Large statements with hundreds of lines can exceed single-pass processing limits — chunk the reconciliation and confirm the total line count extracted matches the total on the statement before closing out.

## Done when

- Every line on the carrier statement has been matched, or flagged as missing, against expected commission records.
- A reconciliation report has been written via `write-file` and a discrepancy task has been opened via `create-task` for each variance beyond tolerance.
- No coverage, binding, or claims determinations were made — any such questions were routed to a human via `create-task`.