Feature/rename Order to activities in account database schema (#4577)
* Rename Order to activities * Update changelog
This commit is contained in:
parent
8df9667979
commit
8fbdcac66c
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed `Order` to `activities` in the `Account` database schema
|
||||
- Improved the language localization for German (`de`)
|
||||
|
||||
## 2.157.1 - 2025-04-29
|
||||
|
@ -57,17 +57,17 @@ export class AccountController {
|
||||
@HasPermission(permissions.deleteAccount)
|
||||
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
||||
public async deleteAccount(@Param('id') id: string): Promise<AccountModel> {
|
||||
const account = await this.accountService.accountWithOrders(
|
||||
const account = await this.accountService.accountWithActivities(
|
||||
{
|
||||
id_userId: {
|
||||
id,
|
||||
userId: this.request.user.id
|
||||
}
|
||||
},
|
||||
{ Order: true }
|
||||
{ activities: true }
|
||||
);
|
||||
|
||||
if (!account || account?.Order.length > 0) {
|
||||
if (!account || account?.activities.length > 0) {
|
||||
throw new HttpException(
|
||||
getReasonPhrase(StatusCodes.FORBIDDEN),
|
||||
StatusCodes.FORBIDDEN
|
||||
|
@ -39,12 +39,12 @@ export class AccountService {
|
||||
return account;
|
||||
}
|
||||
|
||||
public async accountWithOrders(
|
||||
public async accountWithActivities(
|
||||
accountWhereUniqueInput: Prisma.AccountWhereUniqueInput,
|
||||
accountInclude: Prisma.AccountInclude
|
||||
): Promise<
|
||||
Account & {
|
||||
Order?: Order[];
|
||||
activities?: Order[];
|
||||
}
|
||||
> {
|
||||
return this.prismaService.account.findUnique({
|
||||
@ -62,8 +62,8 @@ export class AccountService {
|
||||
orderBy?: Prisma.AccountOrderByWithRelationInput;
|
||||
}): Promise<
|
||||
(Account & {
|
||||
activities?: Order[];
|
||||
balances?: AccountBalance[];
|
||||
Order?: Order[];
|
||||
Platform?: Platform;
|
||||
})[]
|
||||
> {
|
||||
@ -140,7 +140,7 @@ export class AccountService {
|
||||
|
||||
public async getAccounts(aUserId: string): Promise<Account[]> {
|
||||
const accounts = await this.accounts({
|
||||
include: { Order: true, Platform: true },
|
||||
include: { activities: true, Platform: true },
|
||||
orderBy: { name: 'asc' },
|
||||
where: { userId: aUserId }
|
||||
});
|
||||
@ -148,15 +148,15 @@ export class AccountService {
|
||||
return accounts.map((account) => {
|
||||
let transactionCount = 0;
|
||||
|
||||
for (const order of account.Order) {
|
||||
if (!order.isDraft) {
|
||||
for (const { isDraft } of account.activities) {
|
||||
if (!isDraft) {
|
||||
transactionCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
const result = { ...account, transactionCount };
|
||||
|
||||
delete result.Order;
|
||||
delete result.activities;
|
||||
|
||||
return result;
|
||||
});
|
||||
|
@ -100,7 +100,7 @@ export class OrderService {
|
||||
userId: string;
|
||||
}
|
||||
): Promise<Order> {
|
||||
let Account: Prisma.AccountCreateNestedOneWithoutOrderInput;
|
||||
let Account: Prisma.AccountCreateNestedOneWithoutActivitiesInput;
|
||||
|
||||
if (data.accountId) {
|
||||
Account = {
|
||||
|
@ -139,7 +139,7 @@ export class PortfolioService {
|
||||
}
|
||||
|
||||
if (filterByDataSource && filterBySymbol) {
|
||||
where.Order = {
|
||||
where.activities = {
|
||||
some: {
|
||||
SymbolProfile: {
|
||||
AND: [
|
||||
@ -154,7 +154,7 @@ export class PortfolioService {
|
||||
const [accounts, details] = await Promise.all([
|
||||
this.accountService.accounts({
|
||||
where,
|
||||
include: { Order: true, Platform: true },
|
||||
include: { activities: true, Platform: true },
|
||||
orderBy: { name: 'asc' }
|
||||
}),
|
||||
this.getDetails({
|
||||
@ -170,8 +170,8 @@ export class PortfolioService {
|
||||
return accounts.map((account) => {
|
||||
let transactionCount = 0;
|
||||
|
||||
for (const order of account.Order) {
|
||||
if (!order.isDraft) {
|
||||
for (const { isDraft } of account.activities) {
|
||||
if (!isDraft) {
|
||||
transactionCount += 1;
|
||||
}
|
||||
}
|
||||
@ -195,7 +195,7 @@ export class PortfolioService {
|
||||
)
|
||||
};
|
||||
|
||||
delete result.Order;
|
||||
delete result.activities;
|
||||
|
||||
return result;
|
||||
});
|
||||
|
@ -26,6 +26,7 @@ model Access {
|
||||
}
|
||||
|
||||
model Account {
|
||||
activities Order[]
|
||||
balance Float @default(0)
|
||||
balances AccountBalance[]
|
||||
comment String?
|
||||
@ -39,7 +40,6 @@ model Account {
|
||||
userId String
|
||||
Platform Platform? @relation(fields: [platformId], references: [id])
|
||||
User User @relation(fields: [userId], onDelete: Cascade, references: [id])
|
||||
Order Order[]
|
||||
|
||||
@@id([id, userId])
|
||||
@@index([currency])
|
||||
|
Loading…
x
Reference in New Issue
Block a user