Feature/rename Account to account in Order database schema (#5052)
* Rename Account to account in Order database schema * Update changelog
This commit is contained in:
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed `Account` to `account` in the `Order` database schema
|
||||
|
||||
## 2.175.0 - 2025-06-28
|
||||
|
||||
### Added
|
||||
|
@ -71,14 +71,14 @@ export class ImportService {
|
||||
]);
|
||||
|
||||
const accounts = activities
|
||||
.filter(({ Account }) => {
|
||||
return !!Account;
|
||||
.filter(({ account }) => {
|
||||
return !!account;
|
||||
})
|
||||
.map(({ Account }) => {
|
||||
return Account;
|
||||
.map(({ account }) => {
|
||||
return account;
|
||||
});
|
||||
|
||||
const Account = this.isUniqueAccount(accounts) ? accounts[0] : undefined;
|
||||
const account = this.isUniqueAccount(accounts) ? accounts[0] : undefined;
|
||||
|
||||
return await Promise.all(
|
||||
Object.entries(dividends).map(async ([dateString, { marketPrice }]) => {
|
||||
@ -92,7 +92,7 @@ export class ImportService {
|
||||
const date = parseDate(dateString);
|
||||
const isDuplicate = activities.some((activity) => {
|
||||
return (
|
||||
activity.accountId === Account?.id &&
|
||||
activity.accountId === account?.id &&
|
||||
activity.SymbolProfile.currency === assetProfile.currency &&
|
||||
activity.SymbolProfile.dataSource === assetProfile.dataSource &&
|
||||
isSameSecond(activity.date, date) &&
|
||||
@ -108,12 +108,12 @@ export class ImportService {
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
Account,
|
||||
account,
|
||||
date,
|
||||
error,
|
||||
quantity,
|
||||
value,
|
||||
accountId: Account?.id,
|
||||
accountId: account?.id,
|
||||
accountUserId: undefined,
|
||||
comment: undefined,
|
||||
currency: undefined,
|
||||
@ -129,7 +129,7 @@ export class ImportService {
|
||||
unitPrice: marketPrice,
|
||||
unitPriceInAssetProfileCurrency: marketPrice,
|
||||
updatedAt: undefined,
|
||||
userId: Account?.userId,
|
||||
userId: account?.userId,
|
||||
valueInBaseCurrency: value
|
||||
};
|
||||
})
|
||||
|
@ -9,7 +9,7 @@ export interface Activities {
|
||||
}
|
||||
|
||||
export interface Activity extends Order {
|
||||
Account?: AccountWithPlatform;
|
||||
account?: AccountWithPlatform;
|
||||
error?: ActivityError;
|
||||
feeInAssetProfileCurrency: number;
|
||||
feeInBaseCurrency: number;
|
||||
|
@ -269,7 +269,7 @@ export class OrderController {
|
||||
data: {
|
||||
...data,
|
||||
date,
|
||||
Account: {
|
||||
account: {
|
||||
connect: {
|
||||
id_userId: { id: accountId, userId: this.request.user.id }
|
||||
}
|
||||
|
@ -100,10 +100,10 @@ export class OrderService {
|
||||
userId: string;
|
||||
}
|
||||
): Promise<Order> {
|
||||
let Account: Prisma.AccountCreateNestedOneWithoutActivitiesInput;
|
||||
let account: Prisma.AccountCreateNestedOneWithoutActivitiesInput;
|
||||
|
||||
if (data.accountId) {
|
||||
Account = {
|
||||
account = {
|
||||
connect: {
|
||||
id_userId: {
|
||||
userId: data.userId,
|
||||
@ -179,7 +179,7 @@ export class OrderService {
|
||||
const order = await this.prismaService.order.create({
|
||||
data: {
|
||||
...orderData,
|
||||
Account,
|
||||
account,
|
||||
isDraft,
|
||||
tags: {
|
||||
connect: tags.map(({ id }) => {
|
||||
@ -475,8 +475,8 @@ export class OrderService {
|
||||
|
||||
if (withExcludedAccounts === false) {
|
||||
where.OR = [
|
||||
{ Account: null },
|
||||
{ Account: { NOT: { isExcluded: true } } }
|
||||
{ account: null },
|
||||
{ account: { NOT: { isExcluded: true } } }
|
||||
];
|
||||
}
|
||||
|
||||
@ -487,8 +487,7 @@ export class OrderService {
|
||||
take,
|
||||
where,
|
||||
include: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
Account: {
|
||||
account: {
|
||||
include: {
|
||||
platform: true
|
||||
}
|
||||
@ -650,8 +649,8 @@ export class OrderService {
|
||||
if (['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(data.type)) {
|
||||
delete data.SymbolProfile.connect;
|
||||
|
||||
if (data.Account?.connect?.id_userId?.id === null) {
|
||||
data.Account = { disconnect: true };
|
||||
if (data.account?.connect?.id_userId?.id === null) {
|
||||
data.account = { disconnect: true };
|
||||
}
|
||||
} else {
|
||||
delete data.SymbolProfile.update;
|
||||
|
@ -1883,7 +1883,7 @@ export class PortfolioService {
|
||||
const nonExcludedActivities: Activity[] = [];
|
||||
|
||||
for (const activity of activities) {
|
||||
if (activity.Account?.isExcluded) {
|
||||
if (activity.account?.isExcluded) {
|
||||
excludedActivities.push(activity);
|
||||
} else {
|
||||
nonExcludedActivities.push(activity);
|
||||
@ -2190,7 +2190,7 @@ export class PortfolioService {
|
||||
}
|
||||
|
||||
for (const {
|
||||
Account,
|
||||
account,
|
||||
quantity,
|
||||
SymbolProfile,
|
||||
type
|
||||
@ -2201,27 +2201,27 @@ export class PortfolioService {
|
||||
(portfolioItemsNow[SymbolProfile.symbol]?.marketPriceInBaseCurrency ??
|
||||
0);
|
||||
|
||||
if (accounts[Account?.id || UNKNOWN_KEY]?.valueInBaseCurrency) {
|
||||
accounts[Account?.id || UNKNOWN_KEY].valueInBaseCurrency +=
|
||||
if (accounts[account?.id || UNKNOWN_KEY]?.valueInBaseCurrency) {
|
||||
accounts[account?.id || UNKNOWN_KEY].valueInBaseCurrency +=
|
||||
currentValueOfSymbolInBaseCurrency;
|
||||
} else {
|
||||
accounts[Account?.id || UNKNOWN_KEY] = {
|
||||
accounts[account?.id || UNKNOWN_KEY] = {
|
||||
balance: 0,
|
||||
currency: Account?.currency,
|
||||
currency: account?.currency,
|
||||
name: account.name,
|
||||
valueInBaseCurrency: currentValueOfSymbolInBaseCurrency
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
platforms[Account?.platformId || UNKNOWN_KEY]?.valueInBaseCurrency
|
||||
platforms[account?.platformId || UNKNOWN_KEY]?.valueInBaseCurrency
|
||||
) {
|
||||
platforms[Account?.platformId || UNKNOWN_KEY].valueInBaseCurrency +=
|
||||
platforms[account?.platformId || UNKNOWN_KEY].valueInBaseCurrency +=
|
||||
currentValueOfSymbolInBaseCurrency;
|
||||
} else {
|
||||
platforms[Account?.platformId || UNKNOWN_KEY] = {
|
||||
platforms[account?.platformId || UNKNOWN_KEY] = {
|
||||
balance: 0,
|
||||
currency: Account?.currency,
|
||||
currency: account?.currency,
|
||||
name: account.platform?.name,
|
||||
valueInBaseCurrency: currentValueOfSymbolInBaseCurrency
|
||||
};
|
||||
|
@ -3,7 +3,7 @@ import { Order, SymbolProfile, Tag } from '@prisma/client';
|
||||
import { AccountWithPlatform } from './account-with-platform.type';
|
||||
|
||||
export type OrderWithAccount = Order & {
|
||||
Account?: AccountWithPlatform;
|
||||
account?: AccountWithPlatform;
|
||||
SymbolProfile?: SymbolProfile;
|
||||
tags?: Tag[];
|
||||
};
|
||||
|
@ -38,7 +38,7 @@
|
||||
<gf-value
|
||||
[isCurrency]="true"
|
||||
[locale]="locale"
|
||||
[unit]="element?.Account?.currency"
|
||||
[unit]="element?.account?.currency"
|
||||
[value]="element?.value"
|
||||
/>
|
||||
</div>
|
||||
|
@ -309,14 +309,14 @@
|
||||
</th>
|
||||
<td *matCellDef="let element" class="px-1" mat-cell>
|
||||
<div class="d-flex">
|
||||
@if (element.Account?.platform?.url) {
|
||||
@if (element.account?.platform?.url) {
|
||||
<gf-entity-logo
|
||||
class="mr-1"
|
||||
[tooltip]="element.Account?.platform?.name"
|
||||
[url]="element.Account?.platform?.url"
|
||||
[tooltip]="element.account?.platform?.name"
|
||||
[url]="element.account?.platform?.url"
|
||||
/>
|
||||
}
|
||||
<span class="d-none d-lg-block">{{ element.Account?.name }}</span>
|
||||
<span class="d-none d-lg-block">{{ element.account?.name }}</span>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
@ -468,7 +468,7 @@
|
||||
[ngClass]="{
|
||||
'cursor-pointer':
|
||||
hasPermissionToOpenDetails &&
|
||||
row.Account?.isExcluded !== true &&
|
||||
row.account?.isExcluded !== true &&
|
||||
row.isDraft === false &&
|
||||
['BUY', 'DIVIDEND', 'SELL'].includes(row.type)
|
||||
}"
|
||||
|
@ -195,7 +195,7 @@ export class GfActivitiesTableComponent
|
||||
}
|
||||
} else if (
|
||||
this.hasPermissionToOpenDetails &&
|
||||
activity.Account?.isExcluded !== true &&
|
||||
activity.account?.isExcluded !== true &&
|
||||
activity.isDraft === false &&
|
||||
['BUY', 'DIVIDEND', 'SELL'].includes(activity.type)
|
||||
) {
|
||||
|
@ -120,6 +120,7 @@ model MarketData {
|
||||
}
|
||||
|
||||
model Order {
|
||||
account Account? @relation(fields: [accountId, accountUserId], references: [id, userId])
|
||||
accountId String?
|
||||
accountUserId String?
|
||||
comment String?
|
||||
@ -137,7 +138,6 @@ model Order {
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], onDelete: Cascade, references: [id])
|
||||
userId String
|
||||
Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId])
|
||||
SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], references: [id])
|
||||
|
||||
@@index([accountId])
|
||||
|
Reference in New Issue
Block a user