From 10c01ec630294d79ae1dcfb78197bebe8ce5a394 Mon Sep 17 00:00:00 2001 From: Kenrick Tandrian <60643640+KenTandrian@users.noreply.github.com> Date: Sat, 25 Jul 2026 18:58:37 +0700 Subject: [PATCH] Task/improve type safety in access and account balance services (#7416) * fix(common): update Access interface and type definitions * fix(api): resolve type errors in access controller * feat(api): default to user currency in account balance service --- apps/api/src/app/access/access.controller.ts | 4 ++-- apps/api/src/app/account-balance/account-balance.service.ts | 2 +- libs/common/src/lib/interfaces/access.interface.ts | 2 +- libs/common/src/lib/types/access-with-grantee-user.type.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/api/src/app/access/access.controller.ts b/apps/api/src/app/access/access.controller.ts index d692f358d..3bad0e171 100644 --- a/apps/api/src/app/access/access.controller.ts +++ b/apps/api/src/app/access/access.controller.ts @@ -78,7 +78,7 @@ export class AccessController { ): Promise { if ( this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && - this.request.user.subscription.type === SubscriptionType.Basic + this.request.user.subscription?.type === SubscriptionType.Basic ) { throw new HttpException( getReasonPhrase(StatusCodes.FORBIDDEN), @@ -134,7 +134,7 @@ export class AccessController { ): Promise { if ( this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && - this.request.user.subscription.type === SubscriptionType.Basic + this.request.user.subscription?.type === SubscriptionType.Basic ) { throw new HttpException( getReasonPhrase(StatusCodes.FORBIDDEN), diff --git a/apps/api/src/app/account-balance/account-balance.service.ts b/apps/api/src/app/account-balance/account-balance.service.ts index 656fc2f63..84932f429 100644 --- a/apps/api/src/app/account-balance/account-balance.service.ts +++ b/apps/api/src/app/account-balance/account-balance.service.ts @@ -178,7 +178,7 @@ export class AccountBalanceService { accountId: balance.account.id, valueInBaseCurrency: this.exchangeRateDataService.toCurrency( balance.value, - balance.account.currency, + balance.account.currency ?? userCurrency, userCurrency ) }; diff --git a/libs/common/src/lib/interfaces/access.interface.ts b/libs/common/src/lib/interfaces/access.interface.ts index f3e74e756..6b361d0b9 100644 --- a/libs/common/src/lib/interfaces/access.interface.ts +++ b/libs/common/src/lib/interfaces/access.interface.ts @@ -5,7 +5,7 @@ import { AccessPermission } from '@prisma/client'; import { AccessSettings } from './access-settings.interface'; export interface Access { - alias?: string; + alias: string | null; grantee?: string; id: string; permissions: AccessPermission[]; diff --git a/libs/common/src/lib/types/access-with-grantee-user.type.ts b/libs/common/src/lib/types/access-with-grantee-user.type.ts index 98551e0fd..2fc2488ee 100644 --- a/libs/common/src/lib/types/access-with-grantee-user.type.ts +++ b/libs/common/src/lib/types/access-with-grantee-user.type.ts @@ -1,3 +1,3 @@ import { Access, User } from '@prisma/client'; -export type AccessWithGranteeUser = Access & { granteeUser?: User }; +export type AccessWithGranteeUser = Access & { granteeUser?: User | null };