refactor: centralize domain values and enforce numeric lint

This commit is contained in:
2026-09-13 14:37:39 +03:00
parent 8ba005346d
commit 8637ad2f34
44 changed files with 543 additions and 174 deletions
@@ -6,6 +6,9 @@ import {
import type { Money } from '../../../../common/money.types';
const SHARE_PERCENT_DECIMAL_PLACES = 6;
const PERCENT_SCALED_FACTOR = 100_000_000n;
const categoryTypes = ['STOCK', 'BOND', 'OTHER', 'CASH'] as const;
// Build from positions and cash, never from totals (which already include cash).
@@ -59,10 +62,10 @@ export function portfolioStructure(
value:
(value.value *
10n ** BigInt(total.scale - value.scale) *
100_000_000n +
PERCENT_SCALED_FACTOR +
total.value / 2n) /
total.value,
scale: 6,
scale: SHARE_PERCENT_DECIMAL_PLACES,
})
: null,
}));