UNPKG

@tomei/finance

Version:

NestJS package for finance module

69 lines 2.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentTag = void 0; const general_1 = require("@tomei/general"); class DocumentTag extends general_1.ObjectBase { get DocumentTagId() { return this.ObjectId; } set DocumentTagId(value) { this.ObjectId = value; } constructor(tagGroupAttr) { super(); this.ObjectType = 'DocumentTag'; this.TableName = 'finance_DocumentTag'; if (tagGroupAttr) { this.DocumentTagId = tagGroupAttr.DocumentTagId; this.TagId = tagGroupAttr.TagId; this.DocNo = tagGroupAttr.DocNo; this.AssignedById = tagGroupAttr.AssignedById; this.AssignedAt = tagGroupAttr.AssignedAt; } } static async init(dbTransaction, repository, documentTagId) { try { let instance; if (!dbTransaction || !repository) { throw new Error('Repository and dbTransaction are required for initialization.'); } if (documentTagId) { const data = await repository.findByPk(documentTagId); if (!data) { throw new general_1.ClassError('Document', 'DocumentErrMsg01', 'Document Tag not found.', 'init', 404); } instance = new DocumentTag(data); } else { instance = new DocumentTag(); } instance.initializeRepository(repository); return instance; } catch (error) { throw new general_1.ClassError('DocumentTag', 'DocumentTagErrMsg02', 'Failed to initialize document tag instance.', 'init', 500); } } async create(loginUser, dbTransaction) { try { this.DocumentTagId = this.createId(); this.AssignedById = loginUser.ObjectId; this.AssignedAt = new Date(); const payload = { DocumentTagId: this.DocumentTagId, TagId: this.TagId, DocNo: this.DocNo, AssignedById: this.AssignedById, AssignedAt: this.AssignedAt, }; await this._repository.create(payload, { transaction: dbTransaction, }); } catch (error) { throw error; } } } exports.DocumentTag = DocumentTag; //# sourceMappingURL=document-tag.js.map