fix(accounting): key buy-fiat owed cutover marks by the payout bank asset#4246
fix(accounting): key buy-fiat owed cutover marks by the payout bank asset#4246Danswar wants to merge 1 commit into
Conversation
…sset The mark cache is keyed by asset-table ids (FinanceLog.assets), but openBuyFiatOwed looked up the outputAsset Fiat id — a different keyspace that never matches (fiat 2/EUR reads asset 2/dBTC, a feedless DeFiChain token). Every non-CHF open buy_fiat row therefore hit the m6 fail-loud throw on each run and the cutover could never complete, with no retry able to heal it. Resolve the mark the way the forward consumer's outputMark does: the row's assigned fiatOutput bank asset first, falling back to any bank in the output currency from the bankByIban map already loaded per cutover.
|
Heads-up: While reviewing the So the two are two solutions to one problem, which is why they conflict (5 hunks in the service + 4 in the spec — not a mechanical merge):
Owner's call:
Either way #4256 is safe to ship as-is w.r.t. the wedge — flagging so this isn't merged as a "must-include" or force-resolved without the accounting context. |
|
Closing — superseded by #4253, which resolves the same buy_fiat-owed fiat-vs-asset keyspace bug via |
Problem
Since the #4239 deploy the prod cutover advances past
openAssetsand now aborts every 5-minute run inopenBuyFiatOwed:The retry can never succeed. The mark cache is keyed by asset-table ids (
FinanceLog.assets), butopenBuyFiatOwedresolved the non-CHF output mark with the Fiat-table id:BuyFiat.outputAssetis aFiat— for buy_fiat 67894 (EUR output) that id is 2, and asset id 2 is dBTC (DeFiChain), a feedless token that never appears in the FinancialDataLog. EUR only exists in the asset table as the per-bank Custody entries (Olkypay 269, MaerkiBaumann 267, …). So every non-CHF open buy_fiat row (currently 6 EUR rows in the 90d lookback) hits the m6 fail-loud throw on every run and the cutover wedges permanently.It fails loud only by luck: had the fiat id collided with a fed asset id, the opening would have been silently valued at a wrong price.
Fix
Resolve the output-currency mark from the correct keyspace, exactly like the forward consumer's
outputMark(buy-fiat.consumer §4.7) already does:fiatOutput.bank.assetfirst (same basis the eventual seq3 settlement uses), andbankByIbanmap the cutover already loads once per run, as fallback for rows without an assigned payout bank yet.CHF outputs keep mark 1; a genuinely feedless currency still fails loud (m6) — unchanged semantics.
Tests
fiatOutputbank wins over the same-currency fallback (opening and settlement share the valuation basis)