UNPKG

@tomei/rental

Version:
79 lines 3.48 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RentalPrice = void 0; const general_1 = require("@tomei/general"); const rental_price_repository_1 = require("./rental-price.repository"); const config_1 = require("@tomei/config"); class RentalPrice extends general_1.ObjectBase { get PriceId() { return this.ObjectId; } set PriceId(value) { this.ObjectId = value; } constructor(rentalPriceAttr) { super(); this.ObjectType = 'RentalPrice'; if (rentalPriceAttr) { this.PriceId = rentalPriceAttr.PriceId; this.RetailPrice = rentalPriceAttr.RetailPrice; this.Currency = rentalPriceAttr.Currency; this.PromoCode = rentalPriceAttr.PromoCode; this.Remarks = rentalPriceAttr.Remarks; } } static init(dbTransaction, priceId) { return __awaiter(this, void 0, void 0, function* () { try { if (priceId) { const rentalPrice = yield RentalPrice._Repo.findByPk(priceId, dbTransaction); if (rentalPrice) { return new RentalPrice(rentalPrice); } else { throw new general_1.ClassError('RentalPrice', 'RentalPriceErrMsg', 'RentalPrice Not Found'); } } return new RentalPrice(); } catch (error) { throw new general_1.ClassError('RentalPrice', 'RentalPriceErrMsg', 'Failed To Initialize RentalPrice'); } }); } create(loginUser, dbTransaction) { return __awaiter(this, void 0, void 0, function* () { try { const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code'); const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'Rental - Create'); if (!isPrivileged) { throw new general_1.ClassError('RentalPrice', 'RentalPriceErrMsg01', "You do not have 'Rental - Create' privilege."); } this.PriceId = this.createId(); yield RentalPrice._Repo.create({ PriceId: this.PriceId, RetailPrice: this.RetailPrice, Currency: this.Currency, PromoCode: this.PromoCode, Remarks: this.Remarks, }, dbTransaction); return this; } catch (error) { throw error; } }); } } exports.RentalPrice = RentalPrice; RentalPrice._Repo = new rental_price_repository_1.RentalPriceRepository(); //# sourceMappingURL=rental-price.js.map