Feature/eliminate platform from order (#63)
* Eliminate platform from order * Update changelog
This commit is contained in:
parent
cf82066976
commit
a84256dc03
@ -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
|
||||
|
@ -17,10 +17,6 @@ export class CreateOrderDto {
|
||||
@IsNumber()
|
||||
fee: number;
|
||||
|
||||
@IsString()
|
||||
@ValidateIf((object, value) => value !== null)
|
||||
platformId: string | null;
|
||||
|
||||
@IsNumber()
|
||||
quantity: number;
|
||||
|
||||
|
@ -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 } }
|
||||
return this.orderService.createOrder(
|
||||
{
|
||||
...data,
|
||||
date,
|
||||
Account: {
|
||||
connect: {
|
||||
id_userId: { id: accountId, userId: 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 } }
|
||||
},
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,6 @@ export class UpdateOrderDto {
|
||||
@IsNumber()
|
||||
fee: number;
|
||||
|
||||
@IsString()
|
||||
@ValidateIf((object, value) => value !== null)
|
||||
platformId: string | null;
|
||||
|
||||
@IsString()
|
||||
id: string;
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user