Multi-currency: corrections, data export, and pro-rata capture - #57
Open
ItsThompson wants to merge 7 commits into
Open
Multi-currency: corrections, data export, and pro-rata capture#57ItsThompson wants to merge 7 commits into
ItsThompson wants to merge 7 commits into
Conversation
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 15, 2026 22:49
1a01787 to
fe30b55
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 15, 2026 22:55
fe30b55 to
4353a82
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
3 times, most recently
from
August 15, 2026 23:28
3cc4c53 to
8e3c365
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 15, 2026 23:53
8e3c365 to
1bd065e
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 16, 2026 14:52
1bd065e to
70cd707
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
2 times, most recently
from
August 16, 2026 15:45
adf2d4c to
961d935
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 16, 2026 18:45
961d935 to
51754ec
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 18, 2026 23:36
51754ec to
af59ff5
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 18, 2026 23:45
af59ff5 to
4243590
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
2 times, most recently
from
August 19, 2026 06:30
77caf01 to
5a71a68
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 19, 2026 19:05
5a71a68 to
3d60268
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 20, 2026 13:48
3d60268 to
1c0409a
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 20, 2026 14:58
1c0409a to
e011c98
Compare
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 20, 2026 15:10
e011c98 to
a69e9f2
Compare
Format budget-period, default-settings, and expense export amounts using each currency's minor-unit digits, add reporting_currency to budget periods, and add transaction/reporting/FX columns to expenses. Legacy migration rows normalize to period reporting currency; incomplete version-1 snapshots fail the export safely.
Correction forms initialize from the active expense transaction amount and currency and submit the canonical transactionCurrency field instead of the deprecated currency alias.
Expense detail shows the period amount for same-currency rows and separates transaction amount, budget impact, exchange rate, and rate timestamp for foreign-currency rows. Correction history renders each row's own snapshot.
Increment a Prometheus counter when default settings use the two-decimal fallback for an unsupported stored currency, so the fallback is observable instead of silently discarding the formatting error.
…context Finance now creates pro-rata schedules against an explicit, validated creation period instead of the service clock. It captures one full USD-based provider snapshot before any write, writes the first installment through a new internal Expense contract carrying trusted period context and the captured snapshot, and stores future rows with the same snapshot plus the fields future application needs. - CreateProRataRequest requires periodYear/periodMonth (REST + gRPC proto). - CreateProRataExpense validates the creation period, resolves the currency alias (same rules as standard expense create, defaults to period currency), captures an FX snapshot, and writes no rows on capture failure. - Migration 000007 adds transaction_amount, transaction_currency, creation_reporting_currency, captured_rate_snapshot (JSONB), failure_reason, and a failed status to finance.pro_rata_schedules. - New Expense CreateProRataInstallment RPC/service method validates trusted context consistency, currency catalog membership, and snapshot coverage, then converts via FX ConvertWithSnapshot without calling Finance back. - Wires FX_SERVICE_ADDR into the finance service config/main/docker-compose.
…ias compatibility CorrectExpenseRequest accepts transactionCurrency and deprecated currency over REST and gRPC. Corrections resolve the currency alias (defaulting to the active expense transaction currency), convert against the original period reporting currency, write identity/provider snapshots, and call FX before any ledger mutation so a conversion outage leaves the original active. Review should-fix items addressed: - Parameterize the default-branch telemetry field name so the create flow keeps reporting_currency and the correction flow uses transaction_currency. - Add a gRPC handler test that sends differing transaction_currency/currency and asserts CURRENCY_FIELD_CONFLICT, locking in both field mappings.
ItsThompson
force-pushed
the
mc/05-corrections-export-prorata-capture
branch
from
August 20, 2026 16:04
a69e9f2 to
3bbcd78
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements three multi-currency epic tickets: currency-aware corrections with expense detail, enriched Datarights CSV export with currency snapshots, and pro-rata schedule capture with trusted period context.
What changed
Backend: Expense service
CorrectExpenseRequestacceptstransactionCurrencyover REST and gRPC.CreateProRataInstallmentinternal RPC acceptsTrustedPeriodContextandCapturedRateSnapshot. Expense validates context consistency, currency catalog membership, and snapshot coverage without calling Finance back.fx_client.goaddsConvertWithSnapshotfor snapshot-based conversion.CorrectExpenseRequestcurrency fields,CreateProRataInstallmentRPC,TrustedPeriodContext,CapturedRateSnapshot.Backend: Finance service
CreateProRataExpenserequires explicitperiodYearandperiodMonth. Service clock no longer selects the creation period.CaptureRateSnapshotruns before first installment and future schedule inserts. Capture failure returnsCONVERSION_UNAVAILABLEwith no writes.pro_rata_schedulesmigration adds transaction amount/currency, creation reporting currency, captured snapshot payload, and failure reason fields.FxClientinterface andGRPCFxClientfor rate capture.Backend: Datarights service
expenses.csvgains seven new columns:transaction_amount,transaction_currency,reporting_amount,reporting_currency,exchange_rate,exchange_rate_source,exchange_rate_timestamp.budget_periods.csvgainsreporting_currencyas the fifth column.formatMinorUnitsformats amounts using each currency minor-unit digits. JPY rows render as plain integers.export_currency_formatting_fallback_totalcounter tracks default-settings fallback renders.Frontend
transactionCurrency.moneyFacts.tsprovides pure helpers for snapshot resolution.Tests
go build ./...andgo test ./...pass. Coverage includes same-currency correction, foreign-currency correction, FX-failure no-write, trusted-context validation, and shared snapshot persistence.go build ./...andgo test ./...pass. Coverage includes missing period fields, FX capture failure, and gRPC handler error mapping.go build ./...andgo test ./...pass.go build ./...,go test ./..., andgo vet ./...pass. Coverage includes same-currency, foreign-currency, JPY, budget period reporting currency, pro-rata metadata rows, and fallback counter.vitest runpasses 54 files, 504 tests.eslintclean. Pro-rata frontend tests pass (10 tests).Notes
FX_SERVICE_ADDR=fx-service:9085added to finance-service for pro-rata capture.References