UNPKG

@tomei/rental

Version:
58 lines (51 loc) 1.58 kB
import { ObjectBase } from '@tomei/general'; import { AgreementHistoryRepository } from './agreement-history.repository'; import { AggrementStatusEnum } from '../../enum/aggrement-status.enum'; import { IAgreementHistoryAttr } from '../../interfaces/agreement-history-attr.interface'; export class AgreementHistory extends ObjectBase implements IAgreementHistoryAttr { ObjectId: string; ObjectName: string; ObjectType: string = 'AgreementHistory'; TableName = 'rental_AgreementHistory'; AgreementNo: string; ActivityCompleted: string; MediaId: string; CreatedAt: Date; private static _Repo = new AgreementHistoryRepository(); get HistoryId(): number { return parseInt(this.ObjectId); } set HistoryId(value: number) { this.ObjectId = value.toString(); } protected constructor(agreementAttr?: IAgreementHistoryAttr) { super(); if (agreementAttr) { this.HistoryId = agreementAttr.HistoryId; this.AgreementNo = agreementAttr.AgreementNo; this.ActivityCompleted = agreementAttr.ActivityCompleted; this.MediaId = agreementAttr.MediaId; this.CreatedAt = agreementAttr.CreatedAt; } } public static async init( historyId: number, dbTransaction?: any, ): Promise<AgreementHistory> { try { if (historyId) { const ah = await this._Repo.findByPk( historyId.toString(), dbTransaction, ); return new AgreementHistory(ah?.get({ plain: true })); } return new AgreementHistory(); } catch (error) { throw error; } } }