ERP Finance Review
Core Workflow
- Read the prompt, answer template, and all local payload files for the task. Extract the requested IDs, period/as-of date, entity, account scope, thresholds, and required output ordering.
- Treat the API as the system of record. Use local CSV/JSON payloads only for scope, stale context, and output schema.
- Use the runner-provided base URL. Prefer
/api/...endpoints, falling back to non-/apivariants named in the prompt./endpointslists available paths; exact-match query parameters by field name are supported. - Query only records needed for the scoped IDs. Paginate with
limitandoffsetif a collection result reportstotal > count. - Preserve the answer template exactly: required keys only when
additional_properties_allowedis false, correct enum values, requested top-level order, and list ordering. - Use decimal arithmetic for money. Report USD amounts to two decimals unless the template asks for cents. Compare money after rounding to cents, but keep source amounts as authoritative.
- Return JSON only unless the user explicitly requests explanation.
API Map
- Claims:
/api/claims,/api/claims/{claim_id}. - AP bills:
/api/ap/bills. - AP payments:
/api/ap/payments. - AP aging:
/api/ap/aging. - Close logs:
/api/close/logs. - Vendors:
/api/vendors. - Compliance object rollups:
/api/compliance/objects. - Compliance details:
/api/compliance/ownership/{business_id},/api/compliance/registry/{business_id},/api/compliance/screening/{business_id},/api/compliance/bank/{business_id}. - Prepaid invoices:
/api/prepaids/invoices. - Prepaid GL balances:
/api/prepaids/gl-balances.
Reimbursement And AP Batch Rules
Use these rules for reimbursement close, AP release, and stale snapshot tasks.
- For each candidate claim, fetch the current claim, all bills with that
claim_id, payments for relevant bill IDs, and any close logs requested by the template. - A claim is owner-clean only when the current claim status is releasable and support is complete. Treat
approvedwithreceipt_status: attachedas releasable for unpaid claims. Treatsubmitted,needs_receipt,rejected, missing approval, missing receipts, or partial receipts as not owner-clean unless the claim is already paid with matching paid AP evidence. - A bill is valid AP evidence for a claim only when it is not
voidordraft, the amount equals the claim amount, currency matches, and the vendor matches when the claim has a vendor. Ignore bills with amount or vendor mismatches even if they carry the candidate claim ID. - A claim is paid only when a valid bill has
status: paidand a cleared payment for the same bill/vendor/amount. Scheduled or processing payments do not make a claim paid. - A claim is open payable when it is owner-clean, has a valid unpaid bill in
approvedorscheduledstatus, and has no matching cleared full payment. Open AP balance is valid bill amount minus cleared payments only; do not subtract scheduled or processing payments. - A claim is blocked/not ready when owner cleanup is needed, no valid AP bill exists, only void/draft AP rows exist, or AP rows mismatch amount/vendor. Keep owner cleanup fields separate from AP/payment evidence fields when the template distinguishes them.
- For stale AP snapshots, classify each candidate from current API data, not from the snapshot. Use snapshot rows only to explain correction codes:
current_snapshot_ok: stale row still agrees with current claim, bill, and payment state.mark_in_flight_payment: current valid bill has a non-cleared payment or the stale row misses current in-flight payment evidence.replace_with_matched_paid_bill: stale row points at old AP evidence but current data has a different matched paid bill with cleared payment.exclude_amount_or_vendor_mismatch: current AP rows for the claim do not match the claim amount/vendor.ignore_void_bill: the relevant AP row is void.block_unapproved_claim: the current claim itself is not releasable.
- For close-log fields, inspect
/api/close/logsfor records whose area, period, and message match the prompt's requested AP refresh, cleanup, or close support context. Return matching IDs sorted as the template requires. - Overall status depends on the template. For close-status templates, use
blockedif any scoped item is blocked, otherwiseopen_payablesif valid unpaid bills remain, otherwiseready_to_close. For stale snapshot release templates, useneeds_ap_refreshwhen current reconciliation requires snapshot corrections or close-log support; useready_to_sendonly when all current rows are clean and unchanged; reserveblockedfor batches with no releasable path or when the prompt defines any not-ready item as blocking.
Vendor Onboarding Release Control
Use these rules for onboarding decisions with approve, awaiting_information, and escalate.
- For each scoped business ID, fetch the compliance object and, when needed, the ownership, registry, screening, bank, and vendor records.
- Count reportable UBOs as unique owner names with
ownership_pct >= 25. Duplicate rows for the same name count once. - Build hard-stop flags from current fields:
bank_closed: bank account status isclosed.bank_name_mismatch: bank account status isname_mismatch.confirmed_pep: PEP status isconfirmed_pep.expired_license: license expiry is before the applicable review/as-of date. For monthly onboarding close prompts, treat licenses expiring during the same calendar month as the as-of date as current unless the prompt asks for strict daily comparison.missing_required_documents:missing_fieldsis non-empty.sanctions_confirmed: sanctions status indicates a confirmed match or hit.screening_not_run: PEP or sanctions screening status isnot_run.shell_company_suspected: ownership record indicates shell-company suspicion.vendor_on_hold: vendor status ison_hold.
- Sort each business's hard-stop flags alphabetically by enum value.
- Decision:
approvewhen no hard-stop flags apply.awaiting_informationwhen only information-gathering flags apply, especially missing required documents or screening not run, and no severe escalation flag is present.escalatewhen any severe flag is present: bank closed, bank name mismatch, confirmed PEP, sanctions confirmed, shell-company suspicion, vendor on hold, or expired license.
- Follow-up business IDs are all non-approved businesses, sorted ascending. Overall release is ready only when every business is approved.
Account-Change Payment Release
Use these rules for account-change or payment-release risk reviews with release, hold, and escalate.
- Use the local account-change payload for target business IDs, ticket/vendor IDs, requested bank last-four values, requested release amounts, and review date.
- Fetch the vendor by
vendor_idand current compliance records bybusiness_id. - Sort
target_business_idsand all output ID lists ascending by business ID unless the template says otherwise. - Populate diagnostic lists directly from source evidence:
bank_mismatch_ids: compliance bank status isname_mismatch; do not includeclosedhere unless the template says to.invalid_tax_ids: registry/compliance tax ID is missing, malformed, or differs from the vendor tax ID.expired_license_ids: license expiry is strictly before the review/as-of date.risk_score_override_flags:risk_score >= 70.review_queue_ids: every business whose decision is notrelease.
- Treat requested bank last-four mismatches, closed bank accounts, missing required documents, not-run screening, expired licenses, bank-name mismatches, and high risk scores as review blockers.
- Decision:
releaseonly when vendor is active, requested bank details match the vendor record, bank status is verified, tax ID is valid and consistent, license is current, screening is clear or none, no shell/sanctions/PEP escalation exists, and risk score is below the override threshold.escalatefor identity/compliance severity such as invalid tax ID, confirmed or possible PEP requiring review, sanctions confirmed, vendor on hold, shell-company suspicion, or a combination of severe blockers.holdfor remediable operational blockers such as closed/name-mismatched bank status, requested bank mismatch, missing documents, not-run screening, expired license, or risk override when no escalation trigger is present.
Prepaid Close Reconciliation
Use these rules for prepaid close tasks.
- Read the scope payload for entity, close period, account list, selected prepaid invoice IDs, and variance threshold. Keep
selected_invoice_idsandinvoice_resultsin the same order as the scope payload. - Fetch selected invoices from
/api/prepaids/invoicesand GL balances from/api/prepaids/gl-balancesfor the close period and entity. - Reconcile only scoped accounts. Ignore non-scoped invoices or GL accounts unless the prompt asks to report them as exceptions.
- For straight-line records, use the source
monthly_amortizationamount. A service month counts when the close month overlaps the invoice service period; do not prorate partial first or last months unless the prompt explicitly says to. - Cumulative amortization through the close period is
monthly_amortization * number_of_service_months_through_close, bounded by the service start and service end months. Round to two decimals. Ending balance isoriginal_amount - cumulative_amortization_through_close, rounded to two decimals. march_amortizationor equivalent period amortization is the monthly amount when the close month is in the service period; otherwise it is zero.exception_flagis true when sourcedata_quality_flagsis non-empty or required schedule fields are missing/inconsistent.default_missing_term_flagis true for defaulted or missing-term/date flags such asmissing_contract_dates, missing terms, or default-term indicators.- Account rollups sum only selected invoices by account:
- selected invoice count
- original amount total
- period amortization total
- cumulative amortization total
- schedule ending balance
- GL ending balance
- variance amount as schedule ending balance minus GL ending balance
variance_flagis true whenabs(variance_amount)exceeds the scope threshold.has_default_missing_term_flagis true when any selected invoice in the account has a default/missing-term flag.- Account status: use
requires_reconciliationwhen variance is over threshold or default/missing-term issues exist; usevariance_reviewfor non-default invoice exceptions with no material GL variance; otherwise usereconciled.
Output Hygiene
- Sort IDs by the exact key requested, usually lexical ascending by claim ID, business ID, invoice ID, or close-log ID.
- Use empty lists and zero amounts when the schema requires keys but no evidence applies.
- Do not copy source review statuses into decisions. Decisions must reflect release/close control based on current evidence.
- Do not include training IDs, answer records, or unexplained narrative in final JSON.