Repository navigation
v0.1.7 — account 7000 FX gain/loss on refunds
Added
-
Account 7000 FX Gain/Loss is now actually posted to. Realized FX
gain/loss is recognized on refunds when the FX rate moved between the
original charge and the refund. ThechargeRefundedhandler now reads
the original charge'sbalance_transaction(already expanded by the
receiver'sexpand.ts), computes the rate Stripe used at charge time,
and books each refund's three legs at the rates that match the
underlying movement:4900 Refunds Issueddebits the original-rate settlement
amount, so it cleanly offsets the original revenue booking (revenue
nets to zero on a full refund).2000 Sales Tax Payabledebits the proportional tax portion at the
same original-rate basis.1010 Stripe Clearingcredits the actual settlement (refund-rate)
that Stripe clawed back.7000 FX Gain/Lossabsorbs the difference — debit when the rate
moved against the operator (realized loss), credit when it moved in
their favor (realized gain).
See the
charge_refunded_fxfixture for a worked example:
$100 USD charge originally at rate 1.35 (CAD 135 booked), fully
refunded later at rate 1.40 (CAD 140 clawed back), producing
4900 debit CAD 135 / 7000 debit CAD 5 / 1010 credit CAD 140. -
New fixture
charge_refunded_fxplus QBO and Xero exporter goldens.
Changed
- README's currency caveat replaced with a precise scope statement:
refunds are recognized; multi-period recognition rate drift, disputes
settled at a different rate than the original charge, and
cross-currency payouts still post in BT settlement currency without
7000 lines (those would require state across events or additional
config).
Compatibility
Same-currency refunds are byte-identical to v0.1.6: when
charge.currency == bt.currency, both rates are exactly 1.0, the
expected and actual settlements match, and no 7000 line is emitted.
All 5 existing same-currency refund fixtures pass unchanged.
Callers bypassing expand.ts (where charge.balance_transaction is a
string ID rather than an expanded object) fall back to rate-1.0 and
skip the 7000 line — same-currency behavior unchanged; FX behavior in
that path just loses the FX recognition (not worse than v0.1.6).