Start with the business event, not the printer.
The trigger should be a payroll state that the organization explicitly treats as final. A preview, recalculation, reopened payroll, or draft report is not the same event. The integration records the payroll identifier and finalized timestamp so a retry cannot quietly create a second set of shipments.
From that authorized payroll, the process identifies physical checks, groups them by delivery location, and counts the checks in each group. Locations with no physical checks do not receive a label. Locations missing a usable address, carrier, service level, or printer route become visible exceptions instead of guesses.
The operating path
Every step produces evidence that the next step can rely on.
- 01
Confirm the payroll is eligible
Read the finalized state, payroll identifier, check date, and authorized company or pay group. Stop if the state does not match the agreed trigger.
- 02
Find the physical checks
Filter out direct deposits, voids, test records, and any other excluded payment types using written rules. Preserve the source record identifiers used in the decision.
- 03
Group and count by location
Map each included check to its approved shipping location and calculate the count. An unmapped location is an exception; it is not silently assigned to headquarters.
- 04
Apply the shipping rule
Use the location default carrier and service unless an approved override applies. Validate address, package, cutoff, and service eligibility before purchasing.
- 05
Create and route the label
Place the location identifier and check count in the agreed label or reference fields, buy the shipment, and send the label to the correct print queue.
- 06
Record completion
Store the payroll, location, shipment, tracking, label, and timestamp together. Notify the owner of failures with enough context to recover without rebuilding the batch.
Rules to decide before development
These are operational choices, not implementation trivia.
| Decision | Example rule | Failure behavior |
|---|---|---|
| Eligible payroll state | Finalized and not reopened | Stop the run and alert payroll operations |
| Included payment type | Physical checks only | Quarantine unknown payment types |
| Location source | Employee work location at payroll finalization | Route unmapped records for review |
| Default shipment | Location carrier + service-level table | Do not select an unapproved service silently |
| Label reference | Location code and physical check count | Fail validation before purchase |
| Duplicate protection | Payroll ID + location ID | Return the existing shipment instead of buying another |
Acceptance tests worth writing
A location with zero physical checks produces no shipment.
Test this with a payroll containing direct deposits but no paper checks for that location.
A repeated event does not buy a second label.
Replay the same finalized-payroll event and verify that the original shipment is returned or the duplicate is rejected.
A missing location rule becomes an owned exception.
The alert should include the payroll, location, check count, missing field, and recovery instruction.
The printed label carries the agreed references.
Verify the human-readable location and count as well as any machine-readable reference fields.
A partial carrier outage can be recovered safely.
Confirm whether the system retries, uses an approved fallback, or pauses without duplicating successful locations.
Tracking and shipment evidence are retained.
A reviewer should be able to move from payroll to location to shipment without reconstructing the run from email.
