@ -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 ? . length > 0 ) {
activities = activities . filter ( ( { id } ) = > {
return activityIds . includes ( id ) ;
} ) ;
}
const accounts = (
const accounts = (
await this . accountService . accounts ( {
await this . accountService . accounts ( {
include : {
include : {
@ -39,7 +55,15 @@ export class ExportService {
} ,
} ,
where : { userId }
where : { userId }
} )
} )
) . map (
)
. filter ( ( { id } ) = > {
return activities . length > 0
? activities . some ( ( { accountId } ) = > {
return accountId === id ;
} )
: true ;
} )
. map (
( {
( {
balance ,
balance ,
balances ,
balances ,
@ -70,26 +94,16 @@ 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 ;
( { id , isUsed } ) = >
isUsed &&
activities . some ( ( activity ) = > {
return activity . tags . some ( ( { id : tagId } ) = > {
return tagId === id ;
} ) ;
} )
} )
)
. map ( ( { id , name } ) = > {
. map ( ( { id , name } ) = > {
return {
return {
id ,
id ,