From 97e730a8a81c77ca2e387574792233dc25fd88a7 Mon Sep 17 00:00:00 2001 From: Abhi Date: Tue, 24 Feb 2026 15:07:15 -0500 Subject: [PATCH] Fix X-ray rule exception when marketPrice is null When a holding has no market price data (e.g. newly added activity before price data is fetched), Big.js throws "[big.js] Invalid number" because null is passed to .mul(). This crashes the /api/v1/portfolio/report endpoint. Use nullish coalescing (marketPrice ?? 0) to treat missing prices as zero, consistent with the pattern already used in portfolio.service.ts. Fixes #4607 --- apps/api/src/models/rule.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/src/models/rule.ts b/apps/api/src/models/rule.ts index 9c27e0018..622375b5b 100644 --- a/apps/api/src/models/rule.ts +++ b/apps/api/src/models/rule.ts @@ -57,7 +57,7 @@ export abstract class Rule implements RuleInterface { previousValue + this.exchangeRateDataService.toCurrency( new Big(currentValue.quantity) - .mul(currentValue.marketPrice) + .mul(currentValue.marketPrice ?? 0) .toNumber(), currentValue.currency, baseCurrency