# agent reconciled payouts in the wrong currency: balance transactions mismatched

## TL;DR
Your agent compared amounts across currencies as if they were the same money. Reconcile per currency: match each payout's balance transactions in their native currency first, then convert with the gateway's stated FX rate only for reporting. Mixed-currency math is how phantom mismatches appear.

```text
agent reconciled payouts in the wrong currency: balance transactions mismatched
```

## Steps

1. Split the reconciliation by currency: group balance transactions per currency before comparing anything. Success check: each group has one currency and one expected total.
2. Match each payout against its balance transactions in the payout's native currency. Success check: native-currency totals agree before any conversion.
3. For reporting currency, convert using the FX rate the gateway applied, not a daily market rate. Success check: converted totals match the gateway's own reporting.
4. Find where the agent mixed currencies: usually a sum across a multi-currency account or a hardcoded currency assumption. Success check: the bad assumption is named and removed.
5. Fix the job to carry currency on every amount through the whole pipeline and assert currency equality before any arithmetic. Success check: mixed-currency math throws instead of silently computing.

## When this applies

- Payout reconciliation mismatches caused by mixed currencies.
- An agent summed multi-currency amounts as one total.
- FX differences between your rate and the gateway's rate.

## When it doesn't

- Payouts that never arrived; track the transfer status.
- Fee or TDS disputes; reconcile those per currency too, but separately.
- Single-currency mismatches; those are a different bug.

## Tool + version compatibility

Stripe, Adyen, Razorpay, or any gateway with multi-currency balance transactions.

### "payout reconciliation currency mismatch"
Reconcile per currency first; convert only for reporting.

### "balance transactions wrong currency"
Carry currency on every amount; assert before arithmetic.

### "fx mismatch gateway reporting"
Use the gateway's applied FX rate, not a market rate.

## Why it happens

Gateways settle in multiple currencies, and each payout's balance transactions are denominated in the payout currency. Agents commonly sum everything into the home currency with a market rate, or worse, add dollars to euros as plain numbers. The gateway's books are per currency; your reconciliation must be too. FX only enters at the reporting layer, using the rate the gateway actually applied.

## Edge cases / pitfalls

- Always use the gateway's FX rate for reconciliation; market rates create permanent small mismatches.
- Refunds and disputes settle in the original currency; keep them in their currency group.
- A currency assertion that throws is better than a silent wrong total; make it loud.
- Test the job with a multi-currency fixture; single-currency tests never catch this bug.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_ZqygHjTi9W3nQJ-clOJzhA
