|
@ -1,6 +1,7 @@ |
|
|
import { AccountService } from '@ghostfolio/api/app/account/account.service'; |
|
|
import { AccountService } from '@ghostfolio/api/app/account/account.service'; |
|
|
import { OrderService } from '@ghostfolio/api/app/order/order.service'; |
|
|
import { OrderService } from '@ghostfolio/api/app/order/order.service'; |
|
|
import { environment } from '@ghostfolio/api/environments/environment'; |
|
|
import { environment } from '@ghostfolio/api/environments/environment'; |
|
|
|
|
|
import { TagService } from '@ghostfolio/api/services/tag/tag.service'; |
|
|
import { Filter, Export } from '@ghostfolio/common/interfaces'; |
|
|
import { Filter, Export } from '@ghostfolio/common/interfaces'; |
|
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
@ -9,7 +10,8 @@ import { Injectable } from '@nestjs/common'; |
|
|
export class ExportService { |
|
|
export class ExportService { |
|
|
public constructor( |
|
|
public constructor( |
|
|
private readonly accountService: AccountService, |
|
|
private readonly accountService: AccountService, |
|
|
private readonly orderService: OrderService |
|
|
private readonly orderService: OrderService, |
|
|
|
|
|
private readonly tagService: TagService |
|
|
) {} |
|
|
) {} |
|
|
|
|
|
|
|
|
public async export({ |
|
|
public async export({ |
|
@ -43,6 +45,19 @@ export class ExportService { |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
|
|
|
const allTags = ( |
|
|
|
|
|
await this.tagService.getTags({ |
|
|
|
|
|
orderBy: { |
|
|
|
|
|
name: 'asc' |
|
|
|
|
|
}, |
|
|
|
|
|
where: { userId } |
|
|
|
|
|
}) |
|
|
|
|
|
).map(({ id, name }) => { |
|
|
|
|
|
return { |
|
|
|
|
|
id, |
|
|
|
|
|
name |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
let { activities } = await this.orderService.getOrders({ |
|
|
let { activities } = await this.orderService.getOrders({ |
|
|
filters, |
|
|
filters, |
|
@ -72,9 +87,9 @@ export class ExportService { |
|
|
id, |
|
|
id, |
|
|
quantity, |
|
|
quantity, |
|
|
SymbolProfile, |
|
|
SymbolProfile, |
|
|
|
|
|
tags, |
|
|
type, |
|
|
type, |
|
|
unitPrice, |
|
|
unitPrice |
|
|
tags |
|
|
|
|
|
}) => { |
|
|
}) => { |
|
|
return { |
|
|
return { |
|
|
accountId, |
|
|
accountId, |
|
@ -82,6 +97,9 @@ 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, |
|
@ -93,11 +111,11 @@ export class ExportService { |
|
|
type === 'ITEM' || |
|
|
type === 'ITEM' || |
|
|
type === 'LIABILITY' |
|
|
type === 'LIABILITY' |
|
|
? SymbolProfile.name |
|
|
? SymbolProfile.name |
|
|
: SymbolProfile.symbol, |
|
|
: SymbolProfile.symbol |
|
|
tags: tags.map(({ id: tagId }) => tagId) |
|
|
|
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
), |
|
|
), |
|
|
|
|
|
tags: allTags, |
|
|
user: { |
|
|
user: { |
|
|
settings: { currency: userCurrency } |
|
|
settings: { currency: userCurrency } |
|
|
} |
|
|
} |
|
|