import { ICurrency } from '~src/models/market/currency'; import { ITransaction } from './transaction'; import { IHoldingBase } from './holding/holding'; import { TransferType } from './transfer-type'; export interface ITransferBase { id: string; date: Date; type: TransferType; subtype: string; description: string; value: number; cost: number; status: ITransferStatus; } export interface ITransfer extends ITransferBase { holdingId: string; transactionId: string; currencyId: string; } export interface ITransferOutput extends ITransferBase { holding: IHoldingBase; transaction: ITransaction; currency: ICurrency; } export enum ITransferStatus { confirmed, expected, cancelled, } export interface ITransferInput extends ITransferBase { holdingId: string; transactionId: string; currencyId: string; } export interface ITransferDeleteInput { id: string; } export function parseTransfer(transfer: ITransferOutput): ITransfer { const itransfer: ITransfer = { id: transfer.id, date: new Date(transfer.date), value: +transfer.value, status: +transfer.status, cost: +transfer.cost, description: transfer.description, type: transfer.type, subtype: transfer.subtype, holdingId: transfer.holding ? transfer.holding.id : '', currencyId: transfer.currency ? transfer.currency.id : '', transactionId: transfer.transaction ? transfer.transaction.id : '', }; return itransfer; }