|
@ -28,6 +28,22 @@ export class ExportService { |
|
|
}): Promise<Export> { |
|
|
}): Promise<Export> { |
|
|
const platformsMap: { [platformId: string]: Platform } = {}; |
|
|
const platformsMap: { [platformId: string]: Platform } = {}; |
|
|
|
|
|
|
|
|
|
|
|
let { activities } = await this.orderService.getOrders({ |
|
|
|
|
|
filters, |
|
|
|
|
|
userCurrency, |
|
|
|
|
|
userId, |
|
|
|
|
|
includeDrafts: true, |
|
|
|
|
|
sortColumn: 'date', |
|
|
|
|
|
sortDirection: 'asc', |
|
|
|
|
|
withExcludedAccounts: true |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (activityIds) { |
|
|
|
|
|
activities = activities.filter((activity) => { |
|
|
|
|
|
return activityIds.includes(activity.id); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const accounts = ( |
|
|
const accounts = ( |
|
|
await this.accountService.accounts({ |
|
|
await this.accountService.accounts({ |
|
|
include: { |
|
|
include: { |
|
@ -39,7 +55,11 @@ export class ExportService { |
|
|
}, |
|
|
}, |
|
|
where: { userId } |
|
|
where: { userId } |
|
|
}) |
|
|
}) |
|
|
).map( |
|
|
) |
|
|
|
|
|
.filter((account) => |
|
|
|
|
|
activities.some(({ accountId }) => accountId === account.id) |
|
|
|
|
|
) |
|
|
|
|
|
.map( |
|
|
({ |
|
|
({ |
|
|
balance, |
|
|
balance, |
|
|
balances, |
|
|
balances, |
|
@ -70,26 +90,14 @@ export class ExportService { |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
let { activities } = await this.orderService.getOrders({ |
|
|
|
|
|
filters, |
|
|
|
|
|
userCurrency, |
|
|
|
|
|
userId, |
|
|
|
|
|
includeDrafts: true, |
|
|
|
|
|
sortColumn: 'date', |
|
|
|
|
|
sortDirection: 'asc', |
|
|
|
|
|
withExcludedAccounts: true |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (activityIds) { |
|
|
|
|
|
activities = activities.filter((activity) => { |
|
|
|
|
|
return activityIds.includes(activity.id); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const tags = (await this.tagService.getTagsForUser(userId)) |
|
|
const tags = (await this.tagService.getTagsForUser(userId)) |
|
|
.filter(({ isUsed }) => { |
|
|
.filter( |
|
|
return isUsed; |
|
|
(tag) => |
|
|
}) |
|
|
tag.isUsed && |
|
|
|
|
|
activities.some((activity) => |
|
|
|
|
|
activity.tags.some(({ id: tagId }) => tagId === tag.id) |
|
|
|
|
|
) |
|
|
|
|
|
) |
|
|
.map(({ id, name }) => { |
|
|
.map(({ id, name }) => { |
|
|
return { |
|
|
return { |
|
|
id, |
|
|
id, |
|
|