From 4b9ff413581690f74c76b0ebb0ebdae25b8a59d8 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 21 Feb 2025 20:32:26 +0100 Subject: [PATCH] Refactoring --- apps/api/src/app/export/export.service.ts | 26 ++++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/apps/api/src/app/export/export.service.ts b/apps/api/src/app/export/export.service.ts index 040962bf9..b43c6d4eb 100644 --- a/apps/api/src/app/export/export.service.ts +++ b/apps/api/src/app/export/export.service.ts @@ -46,9 +46,9 @@ export class ExportService { } ); - const allTags = (await this.tagService.getTagsForUser(userId)) - .filter((value) => { - return value.isUsed; + const tags = (await this.tagService.getTagsForUser(userId)) + .filter(({ isUsed }) => { + return isUsed; }) .map(({ id, name }) => { return { @@ -76,6 +76,7 @@ export class ExportService { return { meta: { date: new Date().toISOString(), version: environment.version }, accounts, + tags, activities: activities.map( ({ accountId, @@ -85,7 +86,7 @@ export class ExportService { id, quantity, SymbolProfile, - tags, + tags: currentTags, type, unitPrice }) => { @@ -95,25 +96,20 @@ export class ExportService { fee, id, quantity, - tags: tags.map(({ id: tagId }) => { - return tagId; - }), type, unitPrice, currency: SymbolProfile.currency, dataSource: SymbolProfile.dataSource, date: date.toISOString(), - symbol: - type === 'FEE' || - type === 'INTEREST' || - type === 'ITEM' || - type === 'LIABILITY' - ? SymbolProfile.name - : SymbolProfile.symbol + symbol: ['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(type) + ? SymbolProfile.name + : SymbolProfile.symbol, + tags: currentTags.map(({ id: tagId }) => { + return tagId; + }) }; } ), - tags: allTags, user: { settings: { currency: userCurrency } }