UNPKG

@tomei/finance

Version:

NestJS package for finance module

56 lines 2.71 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var AccountSystemEntity_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.AccountSystemEntity = void 0; const general_1 = require("@tomei/general"); const post_history_repository_1 = require("./post-history.repository"); const cuid2_1 = require("@paralleldrive/cuid2"); const common_1 = require("@nestjs/common"); let AccountSystemEntity = AccountSystemEntity_1 = class AccountSystemEntity extends general_1.ObjectBase { constructor() { super(...arguments); this.CompanyId = ''; this.PostedToAccSystemYN = 'N'; this.AccSystemRefId = 'REF'; this.PostedById = ''; } async postToAccSystem(dbTransaction, loginUser) { try { const company = 'test'; this.PostedToAccSystemYN = 'Y'; this.PostedById = loginUser.ObjectId; this.PostedDateTime = new Date(); const entity = await this.RepositoryBase.findByPk(this.ObjectId); const updated = await entity.update({ PostedToAccSystemYN: this.PostedToAccSystemYN, PostedById: this.PostedById, PostedDateTime: this.PostedDateTime, }, { transaction: dbTransaction }); await AccountSystemEntity_1.PostHistoryRepository.create({ PostId: (0, cuid2_1.createId)(), DateTime: this.PostedDateTime, ItemId: this.ObjectId, ItemType: this.TableName, ItemValue: JSON.stringify(updated), PostedById: this.PostedById, AccSystemCode: 'test', AccSystemRefId: this.AccSystemRefId, }, { transaction: dbTransaction }); } catch (err) { throw err; } } }; exports.AccountSystemEntity = AccountSystemEntity; AccountSystemEntity.PostHistoryRepository = new post_history_repository_1.PostHistoryRepository(); exports.AccountSystemEntity = AccountSystemEntity = AccountSystemEntity_1 = __decorate([ (0, common_1.Injectable)() ], AccountSystemEntity); //# sourceMappingURL=account-system-entity.js.map