Repository navigation
feat(financial): financial quantification on the redesign layout (#904) - #932
Merged
Merged
Conversation
…#904) The redesigned financial page draws the probability that a year's loss exceeds an amount, before and after the treatment plans, and lists the plans by payback. The summary now carries: - loss_exceedance: total annual loss at every percentile 0..100 from the same shared Monte Carlo as the P10/P50/P90 band, inherent and residual. The residual run scales each risk's loss by (1 - effectiveness), the rule ALE-after already uses, with the same draws. The model is unchanged; SimulatePortfolio shares its sampling loop and returns the same band. - treatments: each risk plan with a cost and a measurable reduction, its annual loss avoided and payback in months, shortest first. - portfolio_rosi_3y and treated_risks for the KPI tiles. - risk_appetite_xaf, read through an optional port (stored next commit). An empty register returns no curve and no ROSI instead of zeros. Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
The appetite slider on the loss-exceedance curve was a local value in the mockup. It is the board's accepted annual loss, so it is now a tenant setting: PUT /analytics/financial/appetite (admin, XAF) stores it in the organization settings beside the display currency, and the financial summary returns it. No migration: settings is jsonb. The use case rejects zero, negative, non-finite and absurd amounts, and a session without an organization; an unknown organization is not found. Tests cover the use case, the handler and a round trip on the organization table that keeps the currency and leaves other organizations alone. OpenAPI updated with the new fields of the summary (ale_after from #903 was missing too) and the TS types regenerated. Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
…ign (#904) The register in money, laid out as the mockup: inherent ALE, targeted residual ALE, plan cost and 3-year ROSI; the loss-exceedance curve, inherent and after plan, with both exceedance probabilities read at the risk appetite; exposure by risk with its reduction bar; the treatment plans ranked by payback, each opening the risk's mitigations. The curve is drawn from the summary's percentiles and names both axes, which the mockup left out. The appetite slider saves the tenant's appetite after the pointer rests (optimistic, rolled back on refusal, no retry); members without admin rights see it read-only, and an unset appetite says so. The risk column of the exposure table gets the room the mockup's wrapped titles lacked. Kept from the previous page outside the mockup's layout: the methodology opens from the subtitle, the display currency sits in the header for admins, and the investment simulator follows the design's blocks. All copy moves to fr/en locale keys; the dialog uses the design-system modal. Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
This was referenced Oct 9, 2026
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.
Fifth screen of the redesign epic (#899). Stacked on #928 (executive view): the base is
feat/903-executive, so the diff shows only this issue.What changes for the user
The financial page now reads like the mockup:
Backend
pkg/crq:PortfolioQuantilesreturns the total annual loss at every percentile from the same Monte Carlo as the P10–P90 band.ScaleLossgives the residual run, which uses the same draws and the same rule as ALE-after.SimulatePortfolioshares the sampling loop and its output is unchanged (existing tests pass).loss_exceedance: the two percentile curves.treatments: risk plans with a cost and a reduction, shortest payback first.portfolio_rosi_3y: (3 × annual reduction − plan cost) / plan cost.treated_risksandrisk_appetite_xaf.PUT /analytics/financial/appetite(admin, XAF) stores the appetite in the organization settings, beside the display currency. No migration. A use case validates it and returns typed errors.ale_afterfrom feat(frontend): executive view on the redesign layout #903, which was missing) and TS types regenerated.Frontend
features/financial/split intoFinancialDashboard,LossExceedanceCard,MethodologyModal(design-system modal),SimulatorCard, and purelec.ts/methodology.ts. All copy moved to fr/en keys; the old page used inline FR/EN pairs.Verified
go test ./...: all packages pass. New tests:TestPortfolioQuantilesandTestScaleLoss.TestFinancialSummaryPage_*(curve, payback order, 3-year ROSI, empty register, failing appetite read).TestSetRiskAppetite_*(Success / NotFound / Unauthorized / Validation).TestSetAppetiteHandler_*.TestOrgRiskAppetite_RoundTrip: the currency is kept and other organizations are untouched.npx tsc -b --noEmitclean, eslint and prettier clean onfeatures/financial,npx vitest run114 files / 1030 tests.PUT {appetite_xaf: 80000000}, showed "Appétence enregistrée" and survived a reload.Deliberate differences from the mockup
Not done here
Closes #904