Browse Source

Refactoring

pull/4337/head
Thomas Kaul 2 months ago
parent
commit
4b9ff41358
  1. 26
      apps/api/src/app/export/export.service.ts

26
apps/api/src/app/export/export.service.ts

@ -46,9 +46,9 @@ export class ExportService {
} }
); );
const allTags = (await this.tagService.getTagsForUser(userId)) const tags = (await this.tagService.getTagsForUser(userId))
.filter((value) => { .filter(({ isUsed }) => {
return value.isUsed; return isUsed;
}) })
.map(({ id, name }) => { .map(({ id, name }) => {
return { return {
@ -76,6 +76,7 @@ export class ExportService {
return { return {
meta: { date: new Date().toISOString(), version: environment.version }, meta: { date: new Date().toISOString(), version: environment.version },
accounts, accounts,
tags,
activities: activities.map( activities: activities.map(
({ ({
accountId, accountId,
@ -85,7 +86,7 @@ export class ExportService {
id, id,
quantity, quantity,
SymbolProfile, SymbolProfile,
tags, tags: currentTags,
type, type,
unitPrice unitPrice
}) => { }) => {
@ -95,25 +96,20 @@ export class ExportService {
fee, fee,
id, id,
quantity, quantity,
tags: tags.map(({ id: tagId }) => {
return tagId;
}),
type, type,
unitPrice, unitPrice,
currency: SymbolProfile.currency, currency: SymbolProfile.currency,
dataSource: SymbolProfile.dataSource, dataSource: SymbolProfile.dataSource,
date: date.toISOString(), date: date.toISOString(),
symbol: symbol: ['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(type)
type === 'FEE' || ? SymbolProfile.name
type === 'INTEREST' || : SymbolProfile.symbol,
type === 'ITEM' || tags: currentTags.map(({ id: tagId }) => {
type === 'LIABILITY' return tagId;
? SymbolProfile.name })
: SymbolProfile.symbol
}; };
} }
), ),
tags: allTags,
user: { user: {
settings: { currency: userCurrency } settings: { currency: userCurrency }
} }

Loading…
Cancel
Save