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/),
|
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).
|
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
|
## 0.98.0 - 02.05.2021
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -17,10 +17,6 @@ export class CreateOrderDto {
|
|||||||
@IsNumber()
|
@IsNumber()
|
||||||
fee: number;
|
fee: number;
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@ValidateIf((object, value) => value !== null)
|
|
||||||
platformId: string | null;
|
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
|
||||||
|
@ -125,41 +125,19 @@ export class OrderController {
|
|||||||
const accountId = data.accountId;
|
const accountId = data.accountId;
|
||||||
delete data.accountId;
|
delete data.accountId;
|
||||||
|
|
||||||
if (data.platformId) {
|
return this.orderService.createOrder(
|
||||||
const platformId = data.platformId;
|
{
|
||||||
delete data.platformId;
|
...data,
|
||||||
|
date,
|
||||||
return this.orderService.createOrder(
|
Account: {
|
||||||
{
|
connect: {
|
||||||
...data,
|
id_userId: { id: accountId, userId: this.request.user.id }
|
||||||
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
|
User: { connect: { id: this.request.user.id } }
|
||||||
);
|
},
|
||||||
} else {
|
this.request.user.id
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
@ -196,60 +174,26 @@ export class OrderController {
|
|||||||
const accountId = data.accountId;
|
const accountId = data.accountId;
|
||||||
delete data.accountId;
|
delete data.accountId;
|
||||||
|
|
||||||
if (data.platformId) {
|
return this.orderService.updateOrder(
|
||||||
const platformId = data.platformId;
|
{
|
||||||
delete data.platformId;
|
data: {
|
||||||
|
...data,
|
||||||
return this.orderService.updateOrder(
|
date,
|
||||||
{
|
Account: {
|
||||||
data: {
|
connect: {
|
||||||
...data,
|
id_userId: { id: accountId, userId: this.request.user.id }
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
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: {
|
User: { connect: { id: this.request.user.id } }
|
||||||
id_userId: {
|
|
||||||
id,
|
|
||||||
userId: 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()
|
@IsNumber()
|
||||||
fee: number;
|
fee: number;
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@ValidateIf((object, value) => value !== null)
|
|
||||||
platformId: string | null;
|
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
@ -149,7 +149,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 0,
|
fee: 0,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
id: '8d999347-dee2-46ee-88e1-26b344e71fcc',
|
id: '8d999347-dee2-46ee-88e1-26b344e71fcc',
|
||||||
platformId: null,
|
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
symbol: 'BTCUSD',
|
symbol: 'BTCUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
@ -200,7 +199,7 @@ describe('Portfolio', () => {
|
|||||||
// shareCurrent: 0.9999999559148652,
|
// shareCurrent: 0.9999999559148652,
|
||||||
shareInvestment: 1,
|
shareInvestment: 1,
|
||||||
symbol: 'BTCUSD',
|
symbol: 'BTCUSD',
|
||||||
transactionCount: 0,
|
transactionCount: 1,
|
||||||
type: 'Cryptocurrency'
|
type: 'Cryptocurrency'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -251,7 +250,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 0,
|
fee: 0,
|
||||||
date: new Date(getUtc('2018-01-05')),
|
date: new Date(getUtc('2018-01-05')),
|
||||||
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.2,
|
quantity: 0.2,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
@ -347,7 +345,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 0,
|
fee: 0,
|
||||||
date: new Date(getUtc('2018-01-05')),
|
date: new Date(getUtc('2018-01-05')),
|
||||||
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.2,
|
quantity: 0.2,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
@ -364,7 +361,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 0,
|
fee: 0,
|
||||||
date: new Date(getUtc('2018-01-28')),
|
date: new Date(getUtc('2018-01-28')),
|
||||||
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
|
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.3,
|
quantity: 0.3,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
@ -425,7 +421,6 @@ describe('Portfolio', () => {
|
|||||||
date: new Date(getUtc('2017-08-16')),
|
date: new Date(getUtc('2017-08-16')),
|
||||||
fee: 2.99,
|
fee: 2.99,
|
||||||
id: 'd96795b2-6ae6-420e-aa21-fabe5e45d475',
|
id: 'd96795b2-6ae6-420e-aa21-fabe5e45d475',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.05614682,
|
quantity: 0.05614682,
|
||||||
symbol: 'BTCUSD',
|
symbol: 'BTCUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
@ -442,7 +437,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 2.99,
|
fee: 2.99,
|
||||||
date: new Date(getUtc('2018-01-05')),
|
date: new Date(getUtc('2018-01-05')),
|
||||||
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.2,
|
quantity: 0.2,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
@ -516,7 +510,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 1.0,
|
fee: 1.0,
|
||||||
date: new Date(getUtc('2018-01-05')),
|
date: new Date(getUtc('2018-01-05')),
|
||||||
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fb',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.2,
|
quantity: 0.2,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
@ -533,7 +526,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 1.0,
|
fee: 1.0,
|
||||||
date: new Date(getUtc('2018-01-28')),
|
date: new Date(getUtc('2018-01-28')),
|
||||||
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
|
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.1,
|
quantity: 0.1,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: Type.SELL,
|
type: Type.SELL,
|
||||||
@ -550,7 +542,6 @@ describe('Portfolio', () => {
|
|||||||
fee: 1.0,
|
fee: 1.0,
|
||||||
date: new Date(getUtc('2018-01-31')),
|
date: new Date(getUtc('2018-01-31')),
|
||||||
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
|
id: '4a5a5c6e-659d-45cc-9fd4-fd6c873b50fc',
|
||||||
platformId: null,
|
|
||||||
quantity: 0.2,
|
quantity: 0.2,
|
||||||
symbol: 'ETHUSD',
|
symbol: 'ETHUSD',
|
||||||
type: Type.BUY,
|
type: Type.BUY,
|
||||||
|
@ -130,7 +130,6 @@ export class TransactionsPageComponent implements OnInit {
|
|||||||
date,
|
date,
|
||||||
fee,
|
fee,
|
||||||
id,
|
id,
|
||||||
platformId,
|
|
||||||
quantity,
|
quantity,
|
||||||
symbol,
|
symbol,
|
||||||
type,
|
type,
|
||||||
@ -146,7 +145,6 @@ export class TransactionsPageComponent implements OnInit {
|
|||||||
date,
|
date,
|
||||||
fee,
|
fee,
|
||||||
id,
|
id,
|
||||||
platformId,
|
|
||||||
quantity,
|
quantity,
|
||||||
symbol,
|
symbol,
|
||||||
type,
|
type,
|
||||||
@ -188,7 +186,6 @@ export class TransactionsPageComponent implements OnInit {
|
|||||||
currency: null,
|
currency: null,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
fee: 0,
|
fee: 0,
|
||||||
platformId: null,
|
|
||||||
quantity: null,
|
quantity: null,
|
||||||
symbol: null,
|
symbol: null,
|
||||||
type: 'BUY',
|
type: 'BUY',
|
||||||
|
@ -68,8 +68,6 @@ model Order {
|
|||||||
date DateTime
|
date DateTime
|
||||||
fee Float
|
fee Float
|
||||||
id String @default(uuid())
|
id String @default(uuid())
|
||||||
Platform Platform? @relation(fields: [platformId], references: [id])
|
|
||||||
platformId String?
|
|
||||||
quantity Float
|
quantity Float
|
||||||
symbol String
|
symbol String
|
||||||
type Type
|
type Type
|
||||||
@ -85,7 +83,6 @@ model Platform {
|
|||||||
Account Account[]
|
Account Account[]
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
name String?
|
name String?
|
||||||
Order Order[]
|
|
||||||
url String @unique
|
url String @unique
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user