Browse Source

Clean up

pull/2166/head
Thomas 2 years ago
parent
commit
bfb9b49204
  1. 10
      apps/api/src/app/account/account.service.ts
  2. 13
      apps/api/src/app/portfolio/portfolio.service.ts

10
apps/api/src/app/account/account.service.ts

@ -52,7 +52,6 @@ export class AccountService {
orderBy?: Prisma.AccountOrderByWithRelationInput;
}): Promise<
(Account & {
balances?: AccountBalance[];
Order?: Order[];
Platform?: Platform;
})[]
@ -108,10 +107,7 @@ export class AccountService {
public async getAccounts(aUserId: string) {
const accounts = await this.accounts({
include: {
Order: true,
Platform: true
},
include: { Order: true, Platform: true },
orderBy: { name: 'asc' },
where: { userId: aUserId }
});
@ -170,9 +166,7 @@ export class AccountService {
};
}
const accounts = await this.accounts({
where
});
const accounts = await this.accounts({ where });
for (const account of accounts) {
totalCashBalanceInBaseCurrency = totalCashBalanceInBaseCurrency.plus(

13
apps/api/src/app/portfolio/portfolio.service.ts

@ -126,10 +126,7 @@ export class PortfolioService {
const [accounts, details] = await Promise.all([
this.accountService.accounts({
where,
include: {
Order: true,
Platform: true
},
include: { Order: true, Platform: true },
orderBy: { name: 'asc' }
}),
this.getDetails({
@ -158,9 +155,8 @@ export class PortfolioService {
...account,
transactionCount,
valueInBaseCurrency,
balance: details.accounts[account.id].balance,
balanceInBaseCurrency: this.exchangeRateDataService.toCurrency(
details.accounts[account.id].balance,
account.balance,
account.currency,
userCurrency
),
@ -1800,7 +1796,6 @@ export class PortfolioService {
const platforms: PortfolioDetails['platforms'] = {};
let currentAccounts: (Account & {
balances?: AccountBalance[];
Order?: Order[];
Platform?: Platform;
})[] = [];
@ -1809,9 +1804,7 @@ export class PortfolioService {
currentAccounts = await this.accountService.getAccounts(userId);
} else if (filters.length === 1 && filters[0].type === 'ACCOUNT') {
currentAccounts = await this.accountService.accounts({
include: {
Platform: true
},
include: { Platform: true },
where: { id: filters[0].id }
});
} else {

Loading…
Cancel
Save