Skip to content

Value envelope activity at amounts recorded in its currency - #214

Open
oviron wants to merge 1 commit into
ardov:masterfrom
oviron:fx-recorded-amounts
Open

oviron wants to merge 1 commit into
ardov:masterfrom
oviron:fx-recorded-amounts

Conversation

@oviron

@oviron oviron commented Nov 20, 2026

Copy link
Copy Markdown

Refs #206

An expense from a GEL card often records its original price, for example 91 RUB, in opOutcome. A RUB envelope still valued it at the month rate of the GEL posting, so the envelope showed a different amount than was actually paid. The same happens with a transfer to an off-budget account whose other leg is in the envelope currency.

Now an envelope takes an amount the transaction itself records in the envelope currency, in this order:

  1. the routed posting is already in the envelope currency: unchanged;
  2. a transfer across the budget boundary whose other leg is in that currency: that leg (never the technical leg of a debt);
  3. the original amount in that currency (opOutcome for outcomes, opIncome for incomes), if positive and finite;
  4. otherwise the posting, converted at the month rate as today.

Only envelope values change: Available, carryover, overspend, goals, the burndown trend and the envelope rows in activity. Account postings, funds, general income, transfer fees and the month reconciliation stay native. The exchange difference ends up in To Be Assigned through fundsEnd - available, with no extra posting.

The envelope amounts are kept next to the native ones (EnvActivity.envelope), created only when a transaction has a recorded amount. Envelope currencies reach raw activity as a memoized map, so rate refreshes and color or name edits keep the activity references.

Independent of #213. Together they remove most of the drift: recorded amounts fix each transaction, saved tables fix the rest.

Tests: rawActivity.test.ts for the precedence and invalid alternates; recordedActivity.test.ts for a GEL card expense in a RUB envelope (funds change stays in GEL), an off-budget transfer both ways, debt repayments staying native, and a keepIncome tag with a sign flip; graph.test.ts for reference reuse. pnpm verify passes; storybook tests were not run locally.

An expense from a GEL card that records its RUB price, or a transfer to an
off-budget account whose other leg is in the envelope currency, was valued
at the month rate of the account posting. The envelope now keeps the
recorded amount. Account postings, funds and month reconciliation stay
native; the exchange difference reaches To Be Assigned.
@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

@oviron is attempting to deploy a commit to the Alexey Ardov's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant