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; orderBy?: Prisma.AccountOrderByWithRelationInput;
}): Promise< }): Promise<
(Account & { (Account & {
balances?: AccountBalance[];
Order?: Order[]; Order?: Order[];
Platform?: Platform; Platform?: Platform;
})[] })[]
@ -108,10 +107,7 @@ export class AccountService {
public async getAccounts(aUserId: string) { public async getAccounts(aUserId: string) {
const accounts = await this.accounts({ const accounts = await this.accounts({
include: { include: { Order: true, Platform: true },
Order: true,
Platform: true
},
orderBy: { name: 'asc' }, orderBy: { name: 'asc' },
where: { userId: aUserId } where: { userId: aUserId }
}); });
@ -170,9 +166,7 @@ export class AccountService {
}; };
} }
const accounts = await this.accounts({ const accounts = await this.accounts({ where });
where
});
for (const account of accounts) { for (const account of accounts) {
totalCashBalanceInBaseCurrency = totalCashBalanceInBaseCurrency.plus( 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([ const [accounts, details] = await Promise.all([
this.accountService.accounts({ this.accountService.accounts({
where, where,
include: { include: { Order: true, Platform: true },
Order: true,
Platform: true
},
orderBy: { name: 'asc' } orderBy: { name: 'asc' }
}), }),
this.getDetails({ this.getDetails({
@ -158,9 +155,8 @@ export class PortfolioService {
...account, ...account,
transactionCount, transactionCount,
valueInBaseCurrency, valueInBaseCurrency,
balance: details.accounts[account.id].balance,
balanceInBaseCurrency: this.exchangeRateDataService.toCurrency( balanceInBaseCurrency: this.exchangeRateDataService.toCurrency(
details.accounts[account.id].balance, account.balance,
account.currency, account.currency,
userCurrency userCurrency
), ),
@ -1800,7 +1796,6 @@ export class PortfolioService {
const platforms: PortfolioDetails['platforms'] = {}; const platforms: PortfolioDetails['platforms'] = {};
let currentAccounts: (Account & { let currentAccounts: (Account & {
balances?: AccountBalance[];
Order?: Order[]; Order?: Order[];
Platform?: Platform; Platform?: Platform;
})[] = []; })[] = [];
@ -1809,9 +1804,7 @@ export class PortfolioService {
currentAccounts = await this.accountService.getAccounts(userId); currentAccounts = await this.accountService.getAccounts(userId);
} else if (filters.length === 1 && filters[0].type === 'ACCOUNT') { } else if (filters.length === 1 && filters[0].type === 'ACCOUNT') {
currentAccounts = await this.accountService.accounts({ currentAccounts = await this.accountService.accounts({
include: { include: { Platform: true },
Platform: true
},
where: { id: filters[0].id } where: { id: filters[0].id }
}); });
} else { } else {

Loading…
Cancel
Save