@tomei/product
Version:
NestJS package for product module
335 lines • 10.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductWithInventoryBase = void 0;
const product_base_1 = require("../product/product.base");
const product_with_inventory_repository_1 = require("./product-with-inventory.repository");
const activity_history_1 = require("@tomei/activity-history");
const cuid_1 = require("../../helpers/cuid");
class ProductWithInventoryBase extends product_base_1.ProductBase {
constructor(product) {
super(product);
this.ObjectType = 'ProductWithInventory';
this._TotalUnits = 0;
this._TotalUnitsAvailable = 0;
this._TotalUnitsInCurrentOrder = 0;
this._TotalUnitsSold = 0;
this._TotalUnitsReserved = 0;
this._TotalUnitsOnConsignment = 0;
this._TotalUnitsUnderMaintenance = 0;
this._TotalUnitsVoid = 0;
this._TotalUnitsInTransit = 0;
this._TotalUnitsBackOrdered = 0;
this._TotalUnitsPreOrdered = 0;
this._StockLowAlertLevel = 0;
this._StockReorderLevel = 0;
this._BufferStockLevel = 0;
if (product) {
this._UOM = product.UOM;
this._TotalUnits = product.TotalUnits;
this._TotalUnitsAvailable = product.TotalUnitsAvailable;
this._TotalUnitsInCurrentOrder = product.TotalUnitsInCurrentOrder;
this._TotalUnitsSold = product.TotalUnitsSold;
this._TotalUnitsReserved = product.TotalUnitsReserved;
this._TotalUnitsOnConsignment = product.TotalUnitsOnConsignment;
this._TotalUnitsUnderMaintenance = product.TotalUnitsUnderMaintenance;
this._TotalUnitsVoid = product.TotalUnitsVoid;
this._TotalUnitsInTransit = product.TotalUnitsInTransit;
this._TotalUnitsBackOrdered = product.TotalUnitsBackOrdered;
this._TotalUnitsPreOrdered = product.TotalUnitsPreOrdered;
this._StockLowAlertLevel = product.StockLowAlertLevel;
this._StockReorderLevel = product.StockReorderLevel;
this._BufferStockLevel = product.BufferStockLevel;
}
}
get ProductId() {
return super.ProductId;
}
set ProductId(value) {
super.ProductId = value;
}
get Name() {
return super.Name;
}
set Name(value) {
super.Name = value;
}
get Description() {
return super.Description;
}
set Description(value) {
super.Description = value;
}
get SKU() {
return super.SKU;
}
set SKU(value) {
super.SKU = value;
}
get Type() {
return super.Type;
}
set Type(value) {
super.Type = value;
}
get Remark() {
return super.Remark;
}
set Remark(value) {
super.Remark = value;
}
get IsTaxableYN() {
return super.IsTaxableYN;
}
set IsTaxableYN(value) {
super.IsTaxableYN = value;
}
get TaxCode() {
return super.TaxCode;
}
set TaxCode(value) {
super.TaxCode = value;
}
get IsPriceInclusiveTaxYN() {
return super.IsPriceInclusiveTaxYN;
}
set IsPriceInclusiveTaxYN(value) {
super.IsPriceInclusiveTaxYN = value;
}
get Status() {
return super.Status;
}
set Status(value) {
super.Status = value;
}
get VerifiedYN() {
return super.VerifiedYN;
}
set VerifiedYN(value) {
super.VerifiedYN = value;
}
get VerifiedAt() {
return super.VerifiedAt;
}
set VerifiedAt(value) {
super.VerifiedAt = value;
}
get VerifiedById() {
return super.VerifiedById;
}
set VerifiedById(value) {
super.VerifiedById = value;
}
get VariantLevels() {
return super.VariantLevels;
}
set VariantLevels(value) {
super.VariantLevels = value;
}
get VariantTypeLevel1() {
return super.VariantTypeLevel1;
}
set VariantTypeLevel1(value) {
super.VariantTypeLevel1 = value;
}
get VariantTypeLevel2() {
return super.VariantTypeLevel2;
}
set VariantTypeLevel2(value) {
super.VariantTypeLevel2 = value;
}
get VariantTypeLevel3() {
return super.VariantTypeLevel3;
}
set VariantTypeLevel3(value) {
super.VariantTypeLevel3 = value;
}
get CreatedAt() {
return super.CreatedAt;
}
set CreatedAt(value) {
super.CreatedAt = value;
}
get CreatedById() {
return super.CreatedById;
}
set CreatedById(value) {
super.CreatedById = value;
}
get UpdatedAt() {
return super.UpdatedAt;
}
set UpdatedAt(value) {
super.UpdatedAt = value;
}
get UpdatedById() {
return super.UpdatedById;
}
set UpdatedById(value) {
super.UpdatedById = value;
}
get UpdatedSSYN() {
return super.UpdatedSSYN;
}
set UpdatedSSYN(value) {
super.UpdatedSSYN = value;
}
get UOM() {
return this._UOM;
}
set UOM(value) {
this._UOM = value;
}
get TotalUnits() {
return this._TotalUnits;
}
set TotalUnits(value) {
this._TotalUnits = value;
}
get TotalUnitsAvailable() {
return this._TotalUnitsAvailable;
}
set TotalUnitsAvailable(value) {
this._TotalUnitsAvailable = value;
}
get TotalUnitsInCurrentOrder() {
return this._TotalUnitsInCurrentOrder;
}
set TotalUnitsInCurrentOrder(value) {
this._TotalUnitsInCurrentOrder = value;
}
get TotalUnitsSold() {
return this._TotalUnitsSold;
}
set TotalUnitsSold(value) {
this._TotalUnitsSold = value;
}
get TotalUnitsReserved() {
return this._TotalUnitsReserved;
}
set TotalUnitsReserved(value) {
this._TotalUnitsReserved = value;
}
get TotalUnitsOnConsignment() {
return this._TotalUnitsOnConsignment;
}
set TotalUnitsOnConsignment(value) {
this._TotalUnitsOnConsignment = value;
}
get TotalUnitsUnderMaintenance() {
return this._TotalUnitsUnderMaintenance;
}
set TotalUnitsUnderMaintenance(value) {
this._TotalUnitsUnderMaintenance = value;
}
get TotalUnitsVoid() {
return this._TotalUnitsVoid;
}
set TotalUnitsVoid(value) {
this._TotalUnitsVoid = value;
}
get TotalUnitsInTransit() {
return this._TotalUnitsInTransit;
}
set TotalUnitsInTransit(value) {
this._TotalUnitsInTransit = value;
}
get TotalUnitsBackOrdered() {
return this._TotalUnitsBackOrdered;
}
set TotalUnitsBackOrdered(value) {
this._TotalUnitsBackOrdered = value;
}
get TotalUnitsPreOrdered() {
return this._TotalUnitsPreOrdered;
}
set TotalUnitsPreOrdered(value) {
this._TotalUnitsPreOrdered = value;
}
get StockLowAlertLevel() {
return this._StockLowAlertLevel;
}
set StockLowAlertLevel(value) {
this._StockLowAlertLevel = value;
}
get StockReorderLevel() {
return this._StockReorderLevel;
}
set StockReorderLevel(value) {
this._StockReorderLevel = value;
}
get BufferStockLevel() {
return this._BufferStockLevel;
}
set BufferStockLevel(value) {
this._BufferStockLevel = value;
}
async create(loginUser, dbTransaction) {
try {
const productCreated = await super.create(loginUser, dbTransaction);
const data = {
ProductId: productCreated.ProductId,
UOM: this.UOM,
TotalUnits: this.TotalUnits,
TotalUnitsAvailable: this.TotalUnitsAvailable,
TotalUnitsInCurrentOrder: this.TotalUnitsInCurrentOrder,
TotalUnitsSold: this.TotalUnitsSold,
TotalUnitsReserved: this.TotalUnitsReserved,
TotalUnitsOnConsignment: this.TotalUnitsOnConsignment,
TotalUnitsUnderMaintenance: this.TotalUnitsUnderMaintenance,
TotalUnitsVoid: this.TotalUnitsVoid,
TotalUnitsInTransit: this.TotalUnitsInTransit,
TotalUnitsBackOrdered: this.TotalUnitsBackOrdered,
TotalUnitsPreOrdered: this.TotalUnitsPreOrdered,
StockLowAlertLevel: this.StockLowAlertLevel,
StockReorderLevel: this.StockReorderLevel,
BufferStockLevel: this.BufferStockLevel,
};
const productWithInventoryCreated = await ProductWithInventoryBase._ProductWithInventoryRepository.create(data, {
transaction: dbTransaction,
});
const activity = new activity_history_1.Activity();
activity.ActivityId = (0, cuid_1.default)();
activity.Action = activity_history_1.ActionEnum.CREATE;
activity.Description = 'Add new product with inventory';
activity.EntityType = 'ProductWithInventory';
activity.EntityId = data.ProductId;
activity.EntityValueBefore = JSON.stringify({});
activity.EntityValueAfter = JSON.stringify(productWithInventoryCreated.get({ plain: true }));
await activity.create(loginUser.ObjectId, dbTransaction);
return Object.assign(Object.assign({}, productCreated.get({ plain: true })), productWithInventoryCreated.get({ plain: true }));
}
catch (err) {
throw err;
}
}
async deactivate(loginUser, dbTransaction) {
super.deactivate(loginUser, dbTransaction);
}
async verify(loginUser, dbTransaction) {
try {
await super.verify(loginUser, dbTransaction);
}
catch (error) {
throw error;
}
}
async delete(loginUser, dbTransaction) {
try {
await super.delete(loginUser, dbTransaction);
}
catch (error) {
throw error;
}
}
async activate(loginUser, dbTransaction) {
try {
await super.activate(loginUser, dbTransaction);
}
catch (error) {
throw error;
}
}
}
exports.ProductWithInventoryBase = ProductWithInventoryBase;
ProductWithInventoryBase._ProductWithInventoryRepository = new product_with_inventory_repository_1.ProductWithInventoryRepository();
//# sourceMappingURL=product-with-inventory.base.js.map