From d83578e2232a7ada99f2a9798b2baa0decfb2bbe Mon Sep 17 00:00:00 2001 From: Arham Amin <132888838+arhxam@users.noreply.github.com> Date: Mon, 20 Jul 2026 06:42:56 +0530 Subject: [PATCH] fix(portfolio): tolerate unconvertible fees in the calculator `toCurrencyAtDate()` resolves to undefined when no exchange rate exists for an activity's date, so `feeInAssetProfileCurrency` and `feeInBaseCurrency` can reach the calculator unset. Passing those straight into `new Big()` threw "[big.js] Invalid number" and failed the whole portfolio request, so the Overview, Portfolio and Holdings pages rendered "Oops! Something went wrong". Fees are only ever accumulated, so 0 is the identity here and the snapshot stays computable while the exchange rate data is still being gathered. Refs ghostfolio/ghostfolio#6482 --- .../src/app/portfolio/calculator/portfolio-calculator.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts index cee94f020..75dda5cf2 100644 --- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts @@ -145,8 +145,13 @@ export abstract class PortfolioCalculator { tags, type, date: format(date, DATE_FORMAT), - fee: new Big(feeInAssetProfileCurrency), - feeInBaseCurrency: new Big(feeInBaseCurrency), + // Fees are converted via the exchange rate data service, which + // yields undefined when no rate is available for the activity’s + // date. Fees are only ever accumulated, so falling back to 0 keeps + // the portfolio computable instead of failing the whole request + // with “[big.js] Invalid number”. + fee: new Big(feeInAssetProfileCurrency ?? 0), + feeInBaseCurrency: new Big(feeInBaseCurrency ?? 0), quantity: new Big(quantity), unitPrice: new Big(unitPriceInAssetProfileCurrency) };