refactor: centralize domain values and enforce numeric lint
This commit is contained in:
@@ -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,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user