85 lines
1.6 KiB
TypeScript
Raw Normal View History

import { Account, Currency, SymbolProfile } from '@prisma/client';
2021-04-13 21:53:58 +02:00
import { v4 as uuidv4 } from 'uuid';
import { IOrder } from '../services/interfaces/interfaces';
import { OrderType } from './order-type';
export class Order {
private account: Account;
2021-04-13 21:53:58 +02:00
private currency: Currency;
private fee: number;
private date: string;
private id: string;
private isDraft: boolean;
2021-04-13 21:53:58 +02:00
private quantity: number;
private symbol: string;
private symbolProfile: SymbolProfile;
2021-04-13 21:53:58 +02:00
private total: number;
private type: OrderType;
private unitPrice: number;
public constructor(data: IOrder) {
this.account = data.account;
2021-04-13 21:53:58 +02:00
this.currency = data.currency;
this.fee = data.fee;
this.date = data.date;
this.id = data.id || uuidv4();
this.isDraft = data.isDraft;
2021-04-13 21:53:58 +02:00
this.quantity = data.quantity;
this.symbol = data.symbol;
this.symbolProfile = data.symbolProfile;
2021-04-13 21:53:58 +02:00
this.type = data.type;
this.unitPrice = data.unitPrice;
this.total = this.quantity * data.unitPrice;
}
public getAccount() {
return this.account;
}
2021-04-13 21:53:58 +02:00
public getCurrency() {
return this.currency;
}
public getDate() {
return this.date;
}
public getFee() {
return this.fee;
}
public getId() {
return this.id;
}
public getIsDraft() {
return this.isDraft;
}
2021-04-13 21:53:58 +02:00
public getQuantity() {
return this.quantity;
}
public getSymbol() {
return this.symbol;
}
getSymbolProfile() {
return this.symbolProfile;
}
2021-04-13 21:53:58 +02:00
public getTotal() {
return this.total;
}
public getType() {
return this.type;
}
public getUnitPrice() {
return this.unitPrice;
}
}