mobyo-interfaces
Version:
Interfaces de Projetos Mobyo
91 lines (90 loc) • 3.83 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductGlobalEntity = void 0;
var enums_1 = require("../enums");
var gtin_type_enum_1 = require("../enums/gtin-type.enum");
var product_brand_entity_1 = require("./product-brand.entity");
var product_ncm_entity_1 = require("./product-ncm.entity");
var ProductGlobalEntity = /** @class */ (function () {
// #endregion Properties (26)
// #region Constructors (1)
function ProductGlobalEntity(data, bluesoft) {
var _a, _b, _c, _d;
// #region Properties (26)
this.active = true;
this.avgPrice = 0;
this.barcodeImage = null;
this.brand = new product_brand_entity_1.ProductBrandEntity();
this.cest = null;
this.createdAt = new Date();
this.description = '';
this.grossWeight = 0;
this.gtin = null;
this.gtinType = enums_1.GTINTypeEnum.THIRTEEN;
this.height = 0;
this.id = '';
this.length = 0;
this.maxPrice = 0;
this.measureQuantity = 1;
this.measureUnit = 'UN';
this.minPrice = 0;
this.name = '';
this.ncm = new product_ncm_entity_1.ProductNcmEntity();
this.netWeight = 0;
this.createdBy = '';
this.price = 0;
this.tags = [];
this.thumbnail = null;
this.updatedAt = new Date();
this.width = 0;
if (bluesoft) {
this.active = true;
this.avgPrice = bluesoft.avgPrice;
this.barcodeImage = bluesoft.barcodeImage;
this.brand = new product_brand_entity_1.ProductBrandEntity(bluesoft.brand);
this.cest = '';
this.createdAt = new Date();
this.description = bluesoft.description;
this.grossWeight = bluesoft.grossWeight || 0;
this.gtin = bluesoft.gtin || null;
this.gtinType = gtin_type_enum_1.EGtintype.FOURTEEN;
this.height = bluesoft.height || 0;
this.id = '';
this.length = bluesoft.length || 0;
this.maxPrice = bluesoft.maxPrice || 0;
this.measureQuantity = ((_b = (_a = this.getGtinFromGtins(bluesoft.gtin || 0, bluesoft.gtins)) === null || _a === void 0 ? void 0 : _a.commercialUnit) === null || _b === void 0 ? void 0 : _b.quantityPackaging) || 1;
this.measureUnit = ((_d = (_c = this.getGtinFromGtins(bluesoft.gtin || 0, bluesoft.gtins)) === null || _c === void 0 ? void 0 : _c.commercialUnit) === null || _d === void 0 ? void 0 : _d.typePackaging) || 'Unidade';
this.minPrice = bluesoft.minPrice || 0;
this.name = bluesoft.description || '';
this.ncm = new product_ncm_entity_1.ProductNcmEntity(bluesoft.ncm);
this.netWeight = bluesoft.netWeight || 0;
this.price = this.currencyStringToNumber(bluesoft.price);
this.tags = [];
this.thumbnail = bluesoft.thumbnail || '';
this.updatedAt = new Date();
this.width = bluesoft.width || 0;
}
if (data) {
for (var key in data) {
if (data.hasOwnProperty(key) && key in this) {
this[key] = data[key];
}
}
}
}
// #endregion Constructors (1)
// #region Private Methods (1)
ProductGlobalEntity.prototype.getGtinFromGtins = function (ref, gtins) {
for (var i = 0; i < gtins.length; i++) {
if (gtins[i].gtin === ref) {
return gtins[i];
}
}
return null;
};
ProductGlobalEntity.prototype.currencyStringToNumber = function (value) {
return Number(value.replace(/[^0-9.-]+/g, ''));
};
return ProductGlobalEntity;
}());
exports.ProductGlobalEntity = ProductGlobalEntity;