ERP Finance Reconciliation
Reconcile batches of claims, bills, payments, vendor compliance records, prepaid
invoices, and GL balances from a shared task-environment ERP API. Produce
strictly typed JSON output that conforms to an answer_template.json payload.
Environment
The runner supplies the API base URL as <TASK_ENV_BASE_URL>. Do not use local
files as the system of record. The API supports these conventions on every
endpoint:
- Exact-match query parameters by field name (e.g.
?claim_id=CLM-2025-0090,?business_id=BUS-2025-0009) - Pagination with
limitandoffset /api/...and bare paths are equivalent (e.g./claimsand/api/claims)
Step 1: Plan the answer space
Read the prompt, every payload file, and especially the answer template. Before calling any API endpoint, confirm:
- Which record IDs are in scope (claim IDs, business IDs, invoice IDs)
- What the template requires at top level and nested inside
- Which list fields must be sorted ascending by ID
- Which amount fields expect USD with two decimal places
- Which enum values are allowed for each field
- Whether any fields only accept specific hardcoded values
- Whether any field depends on the prompt metadata (period, entity, as-of date)
The template is the ground truth for output shape. Missing a required key or using a value outside the allowed enum set produces an invalid answer.
Step 2: Fetch all source data
Call every endpoint needed to build the answer, then cross-reference records.
Read references/api_endpoints.md for the complete endpoint table, field schemas, and filtering patterns.
Key principles:
- Fetch paginated results in one sweep for each endpoint. Use
limit=200(or larger if needed) and watch forcountexceeding the returned page size. - When the prompt gives a fixed set of claim IDs, business IDs, or invoice IDs, fetch the specific records by ID first, then pull the full reference tables (bills, payments, compliance objects, vendors) to match against them.
- Compliance data is available both as a bulk list
(
/api/compliance/objects) and per-business detail endpoints (/api/compliance/ownership/{id},/api/compliance/screening/{id},/api/compliance/bank/{id},/api/compliance/registry/{id}). The bulk object already contains all four sub-views merged; prefer it unless a detail endpoint adds data not present in the bulk object. - For prepaid close tasks, the GL balance endpoint returns balances keyed by
accountandperiod. Fetch only the period named in the prompt and the accounts in scope.
Step 3: Reconcile and classify
For each record in the batch, gather the evidence chain across endpoints and apply these rules.
Claims to AP bills to Payments
A claim lifecycle is: submitted to (approved, rejected, needs_receipt, or submitted) to AP bill created to payment scheduled/processing/cleared.
To classify a claim:
Paid: The claim has at least one matching AP bill where:
- The bill
claim_idequals the claimclaim_id. - The bill
statusispaid. - There is a payment record for that bill with
statusclearedand a non-zero amount. A claim can have multiple bills. If one bill is paid+cleared for the full claim amount and another bill on the same claim is in a different state, the claim can still be treated as paid provided the paid+cleared path covers the claim amount. When a claim already showsstatus: "paid"in the claims endpoint, verify against bills+payments rather than trusting it blindly.
- The bill
Payable: The claim status is
approved, and there is at least one non-void AP bill linked to the claim where the bill is not yet fully paid+cleared. The bill-linked vendor must match the claim vendor (or the claim must have no vendor requirement). The open balance is the billamountminus any cleared payment amounts.Blocked / CRM-required: The claim needs owner intervention because:
- Its
statusis notapproved(e.g.needs_receipt,rejected,submitted). - It has no AP bill at all.
- Its only linked bill is
void. - Its linked bill amount differs substantially from the claim amount AND no matching paid/cleared alternative bill exists for the correct amount.
- It has
receipt_status: "partial"combined with policy flags likeover_limit. - Its linked bill has a memo flag like
"Duplicate check required"without a compensating resolution.
- Its
Stale snapshot correction types:
current_snapshot_ok-- the snapshot row matches current ERP data.mark_in_flight_payment-- a bill is scheduled/approved with a pending payment; snapshot should note the in-flight status.replace_with_matched_paid_bill-- a different bill than the snapshot bill is the correct paid match.exclude_amount_or_vendor_mismatch-- bill amount or vendor does not match the claim.ignore_void_bill-- the snapshot bill is now void.block_unapproved_claim-- the claim is not approved in current ERP.
Close logs: When a close log references a period or account relevant to the
batch and its memo mentions export refresh, journal entries, or support
uploads that affect the batch, flag it. Use the close_log_required field
with ids sorted ascending.
Vendor compliance to decisions
Read each business compliance object from /api/compliance/objects. The object
contains all relevant fields: bank_account_status, license_expiry,
pep_status, sanctions_check_status, shell_company_suspected,
missing_fields, risk_score, tax_id, ubo_list, review_status.
Release decisions (release, hold, escalate):
release: Bank verified, license not expired by the review date, no PEP flags, no sanctions match, no shell company suspicion, no missing required documents (
licenseandbeneficial_owner_idinmissing_fieldsare material), screening has been run (not_runis a control gap), and tax ID is valid (9-digit format, no embedded letters likeTIN12X899).hold: Temporary blockers -- screening not run but otherwise clean, license recently expired with no other flags, bank name mismatch, risk score elevated but PEP/sanctions negative. These can likely resolve with follow-up.
escalate: Hard stops -- confirmed PEP, sanctions confirmed match, bank closed, shell company suspected, expired license combined with other flags, missing required documents combined with screening not run or PEP/sanctions flags, or dense combinations of risk factors.
Onboarding decisions (approve, awaiting_information, escalate):
Follow the same logic tuned for first-time onboarding rather than
post-change release. awaiting_information maps to hold.
Hard-stop flags: Use the exact enum values from the template. Sort
alphabetically. An empty list [] when none apply.
UBO counts: Count unique beneficial owner names whose ownership_pct meets
the reporting threshold. Read the template to confirm whether the threshold
applies at the individual entry level or aggregated by name. When the
template is silent, count entries where ownership_pct >= 25 individually.
Follow-up IDs: Any business whose decision is not approve. Sorted
ascending.
Overall release ready: True only when every business in scope is release
or approve.
Prepaid invoices to GL balances
For each prepaid invoice in scope, the invoice record provides
monthly_amortization, original_amount, service_start, service_end.
monthly_amortization: Use the value from the invoice record directly. Do not prorate when months are partial -- the API provides the monthly figure already adjusted.cumulative_amortization_through_period: Count the number of full months elapsed fromservice_startthrough the last day of the close period (inclusive). Multiply bymonthly_amortization.ending_balance=original_amount-cumulative_amortization_through_period. Clamp to 0.00 if negative.Per-account rollup: Sum invoice-level
original_amount,march_amortization,cumulative_amortization, andschedule_ending_balanceacross all invoices in that account. Then:schedule_ending_balance= sum of invoice ending balances.variance_amount=schedule_ending_balance-gl_ending_balance.variance_flag= true when|variance_amount| > variance_threshold_abs(use 0 when no threshold is provided).account_status:reconciledwhen no variance;variance_reviewwhen variance is small;requires_reconciliationotherwise.
Exception flag: Set true when:
ending_balancereaches exactly 0.00 at close (fully amortized on boundary).data_quality_flagscontainsmissing_contract_datesorrounded_amount.service_startis in the same month as the close period (first amortization).
Default/missing term flag: True when
data_quality_flagscontainsmissing_contract_datesor the amortization schedule relies on a default service period.
Account-change payment release
For post-account-change release decisions, cross-reference the compliance object with the account-change event:
bank_mismatch_ids: compliancebank_account_statusisname_mismatch.invalid_tax_ids:tax_idcontains non-digit characters (e.g. letters).expired_license_ids:license_expiryis before theas_of_date.review_queue_ids: any business with a risk flag or compliance issue.risk_score_override_flags:risk_score >= 70.
Step 4: Assemble and validate output
Populate every required key from the answer template, in the order the template specifies.
Sort all ID lists ascending by their natural string sort. Claim IDs, business IDs, and invoice IDs sort lexicographically. Close log IDs sort numerically by the embedded number.
Round every currency field to exactly two decimal places. Use the exact values from the API; compute differences only when the template defines a formula.
Use exactly the allowed enum strings from the template. No aliases, no abbreviations.
Set boolean fields to JSON
true/false, never strings.When a field is a list of IDs and none apply, return
[]notnull.Include every business ID key specified in the template even when the value is empty/zero.
Edge cases
Multiple bills for one claim: Match each bill independently. If one bill is paid+cleared and another is void or draft, ignore the void/draft for the paid determination. Compute open balance from non-void bills only.
Void bills: A bill with status void contributes nothing to AP balances
or paid determinations. Flag it in stale snapshot corrections if a snapshot
still references it.
Partial receipts: A claim with receipt_status: "partial" is still
processable if all other conditions are met, but raises risk. Combine with
policy flags when deciding blocked vs. payable.
Null vendor_id on claims: Some claims lack a vendor. This does not block payment -- the AP bill carries its own vendor. Only flag when the template requires vendor matching.
Duplicate amounts: A policy_flags entry of duplicate_amount signals
another claim may share the same amount. Verify whether it is a distinct
claim or a systemic duplicate.
Non-numeric tax IDs: Tax IDs containing letters (like TIN12X899) are
invalid for compliance purposes.
Screening not run: sanctions_check_status: "not_run" and
pep_status: "not_run" mean the check has not happened. This is a control
gap -- treat as a hold factor unless combined with other red flags.
Missing fields in compliance: missing_fields can include license,
website, bank_statement, beneficial_owner_id. license and
beneficial_owner_id are material for onboarding. website alone is not
hard-stop material.
API schema reference
For the complete endpoint table, field descriptions, and filtering details, read references/api_endpoints.md.
For detailed business rules with example decision flowcharts, read references/business_rules.md.