Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/eliminate platform from order (#63)

Thomasa84256dc03cb
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32f6806f15..76892389a8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
+
+- Eliminated the platform attribute from the transaction model
+
## 0.98.0 - 02.05.2021
### Added
diff --git a/apps/api/src/app/order/create-order.dto.ts b/apps/api/src/app/order/create-order.dto.ts
index f330eb0275..0f5daea3a5 100644
--- a/apps/api/src/app/order/create-order.dto.ts
+++ b/apps/api/src/app/order/create-order.dto.ts
@@ -17,10 +17,6 @@ export class CreateOrderDto {
@IsNumber()
fee: number;
- @IsString()
- @ValidateIf((object, value) => value !== null)
- platformId: string | null;
-
@IsNumber()
quantity: number;
diff --git a/apps/api/src/app/order/order.controller.ts b/apps/api/src/app/order/order.controller.ts
index fa6d2724d5..c51a7ffe68 100644
--- a/apps/api/src/app/order/order.controller.ts
+++ b/apps/api/src/app/order/order.controller.ts
@@ -125,41 +125,19 @@ export class OrderController {
const accountId = data.accountId;
delete data.accountId;
- if (data.platformId) {
- const platformId = data.platformId;
- delete data.platformId;
-
- return this.orderService.createOrder(
- {
- ...data,
- date,
- Account: {
- connect: {
- id_userId: { id: accountId, userId: this.request.user.id }
- }
- },
- Platform: { connect: { id: platformId } },
- User: { connect: { id: this.request.user.id } }
- },
- this.request.user.id
- );
- } else {
- delete data.platformId;
-
- return this.orderService.createOrder(
- {
- ...data,
- date,
- Account: {
- connect: {
- id_userId: { id: accountId, userId: this.request.user.id }
- }
- },
- User: { connect: { id: this.request.user.id } }
+ return this.orderService.createOrder(
+ {
+ ...data,
+ date,
+ Account: {
+ connect: {
+ id_userId: { id: accountId, userId: this.request.user.id }
+ }
},
- this.request.user.id
- );
- }
+ User: { connect: { id: this.request.user.id } }
+ },
+ this.request.user.id
+ );
}
@Put(':id')
@@ -196,60 +174,26 @@ export class OrderController {
const accountId = data.accountId;
delete data.accountId;
- if (data.platformId) {
- const platformId = data.platformId;
- delete data.platformId;
-
- return this.orderService.updateOrder(
- {
- data: {
- ...data,
- date,
- Account: {
- connect: {
- id_userId: { id: accountId, userId: this.request.user.id }
- }
- },
- Platform: { connect: { id: platformId } },
- User: { connect: { id: this.request.user.id } }
- },
- where: {
- id_userId: {
- id,
- userId: this.request.user.id
+ return this.orderService.updateOrder(
+ {
+ data: {
+ ...data,
+ date,
+ Account: {
+ connect: {
+ id_userId: { id: accountId, userId: this.request.user.id }
}
- }
- },
- this.request.user.id
- );
- } else {
- // platformId is null, remove it
- delete data.platformId;
-
- return this.orderService.updateOrder(
- {
- data: {
- ...data,
- date,
- Account: {
- connect: {
- id_userId: { id: accountId, userId: this.request.user.id }
- }
- },
- Platform: originalOrder.platformId
- ? { disconnect: true }
- : undefined,
- User: { connect: { id: this.request.user.id } }
},
- where: {
- id_userId: {
- id,
- userId: this.request.user.id
- }
- }
+ User: { connect: { id: this.request.user.id } }
},
- this.request.user.id
- );
- }
+ where: {
+ id_userId: {
+ id,
+ userId: this.request.user.id
+ }
+ }
+ },
+ this.request.user.id
+ );
}
}
diff --git a/apps/api/src/app/order/update-order.dto.ts b/apps/api/src/app/order/update-order.dto.ts
index 26f1fa08d1..115ca3c1dd 100644
--- a/apps/api/src/app/order/update-order.dto.ts
+++ b/apps/api/src/app/order/update-order.dto.ts
@@ -17,10 +17,6 @@ export class UpdateOrderDto {
@IsNumber()
fee: number;
- @IsString()
- @ValidateIf((object, value) => value !== null)
- platformId: string | null;
-
@IsString()
id: string;
diff --git a/apps/api/src/models/portfolio.spec.ts b/apps/api/src/models/portfolio.spec.ts
index 066ba16fe5..874ea08172 100644
--- a/apps/api/src/models/portfolio.spec.ts
+++ b/apps/api/src/models/portfolio.spec.ts
@@ -149,7 +149,6 @@ describe('Portfolio', () => {
fee: 0,
date: new Date(),
id: '8d999347-dee2-46ee-88e1-26b344e71fcc',
- platformId: null,
quantity: 1,
symbol: 'BTCUSD',
type: Type.BUY,
@@ -200,7 +199,7 @@ describe('Portfolio', () => {
// shareCurrent: 0.9999999559148652,
shareInvestment: 1,
symbol: 'BTCUSD',
- transactionCount: 0,
+ transactionCount: 1,
type: 'Cryptocurrency'
}
});
@@ -251,7 +250,6 @@ describe('Portfolio', () => {
fee: 0,
date: new Date(getUtc('2018-01-05')),
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
- platformId: null,
quantity: 0.2,
symbol: 'ETHUSD',
type: Type.BUY,
@@ -347,7 +345,6 @@ describe('Portfolio', () => {
fee: 0,
date: new Date(getUtc('2018-01-05')),
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
- platformId: null,
quantity: 0.2,
symbol: 'ETHUSD',
type: Type.BUY,
@@ -364,7 +361,6 @@ describe('Portfolio', () => {
fee: 0,
date: new Date(getUtc('2018-01-28')),
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
- platformId: null,
quantity: 0.3,
symbol: 'ETHUSD',
type: Type.BUY,
@@ -425,7 +421,6 @@ describe('Portfolio', () => {
date: new Date(getUtc('2017-08-16')),
fee: 2.99,
id: 'd96795b2-6ae6-420e-aa21-fabe5e45d475',
- platformId: null,
quantity: 0.05614682,
symbol: 'BTCUSD',
type: Type.BUY,
@@ -442,7 +437,6 @@ describe('Portfolio', () => {
fee: 2.99,
date: new Date(getUtc('2018-01-05')),
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
- platformId: null,
quantity: 0.2,
symbol: 'ETHUSD',
type: Type.BUY,
@@ -516,7 +510,6 @@ describe('Portfolio', () => {
fee: 1.0,
date: new Date(getUtc('2018-01-05')),
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
- platformId: null,
quantity: 0.2,
symbol: 'ETHUSD',
type: Type.BUY,
@@ -533,7 +526,6 @@ describe('Portfolio', () => {
fee: 1.0,
date: new Date(getUtc('2018-01-28')),
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
- platformId: null,
quantity: 0.1,
symbol: 'ETHUSD',
type: Type.SELL,
@@ -550,7 +542,6 @@ describe('Portfolio', () => {
fee: 1.0,
date: new Date(getUtc('2018-01-31')),
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
- platformId: null,
quantity: 0.2,
symbol: 'ETHUSD',
type: Type.BUY,
diff --git a/apps/client/src/app/pages/transactions/transactions-page.component.ts b/apps/client/src/app/pages/transactions/transactions-page.component.ts
index 7e9304d2b9..ef02e49c0c 100644
--- a/apps/client/src/app/pages/transactions/transactions-page.component.ts
+++ b/apps/client/src/app/pages/transactions/transactions-page.component.ts
@@ -130,7 +130,6 @@ export class TransactionsPageComponent implements OnInit {
date,
fee,
id,
- platformId,
quantity,
symbol,
type,
@@ -146,7 +145,6 @@ export class TransactionsPageComponent implements OnInit {
date,
fee,
id,
- platformId,
quantity,
symbol,
type,
@@ -188,7 +186,6 @@ export class TransactionsPageComponent implements OnInit {
currency: null,
date: new Date(),
fee: 0,
- platformId: null,
quantity: null,
symbol: null,
type: 'BUY',
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 43d688c3b2..4f173a39ab 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -68,8 +68,6 @@ model Order {
date DateTime
fee Float
id String @default(uuid())
- Platform Platform? @relation(fields: [platformId], references: [id])
- platformId String?
quantity Float
symbol String
type Type
@@ -85,7 +83,6 @@ model Platform {
Account Account[]
id String @id @default(uuid())
name String?
- Order Order[]
url String @unique
}