@win2win/shared 1.0.289 → 1.0.290

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -581,6 +581,12 @@ export declare const COUNTRIES: {
581
581
  flag: string;
582
582
  flagLg: string;
583
583
  };
584
+ do: {
585
+ name: string;
586
+ nativeName: string;
587
+ flag: string;
588
+ flagLg: string;
589
+ };
584
590
  mk: {
585
591
  name: string;
586
592
  nativeName: string;
@@ -584,6 +584,12 @@ exports.COUNTRIES = {
584
584
  flag: "https://flagsapi.com/IM/flat/32.png",
585
585
  flagLg: "https://flagsapi.com/IM/flat/64.png",
586
586
  },
587
+ do: {
588
+ name: "Dominican Republic",
589
+ nativeName: "República Dominicana",
590
+ flag: "https://flagsapi.com/DO/flat/32.png",
591
+ flagLg: "https://flagsapi.com/DO/flat/64.png"
592
+ },
587
593
  mk: {
588
594
  name: "North Macedonia",
589
595
  nativeName: "Северна Македонија",
@@ -2,4 +2,3 @@ export * from './formatters';
2
2
  export * from './ProductPrice';
3
3
  export * from './validators';
4
4
  export * from './OrderPrice';
5
- export * from './OrderProductsBuilder';
@@ -18,4 +18,3 @@ __exportStar(require("./formatters"), exports);
18
18
  __exportStar(require("./ProductPrice"), exports);
19
19
  __exportStar(require("./validators"), exports);
20
20
  __exportStar(require("./OrderPrice"), exports);
21
- __exportStar(require("./OrderProductsBuilder"), exports);
@@ -58,10 +58,6 @@ export declare const GAMA_PROP_CONTROL_TYPES: readonly [{
58
58
  readonly code: "images";
59
59
  readonly icon: "o_image";
60
60
  readonly label: "Imágenes";
61
- }, {
62
- readonly code: "product_picker";
63
- readonly icon: "sym_o_shopping_cart";
64
- readonly label: "Selector de producto";
65
61
  }];
66
62
  export type GamaPropControlCode = (typeof GAMA_PROP_CONTROL_TYPES)[number]["code"];
67
63
  export declare enum ControlType {
@@ -79,6 +75,5 @@ export declare enum ControlType {
79
75
  OBJECT = "object",
80
76
  KEYS_COUNTER = "keys_counter",
81
77
  COLLECTION = "collection",
82
- IMAGES = "images",
83
- PRODUCT_PICKER = "product_picker"
78
+ IMAGES = "images"
84
79
  }
@@ -17,7 +17,6 @@ exports.GAMA_PROP_CONTROL_TYPES = [
17
17
  { code: "keys_counter", icon: "plus_one", label: "Contador de entradas" },
18
18
  { code: "collection", icon: "o_description", label: "Colección" },
19
19
  { code: "images", icon: "o_image", label: "Imágenes" },
20
- { code: "product_picker", icon: "sym_o_shopping_cart", label: "Selector de producto" },
21
20
  ];
22
21
  var ControlType;
23
22
  (function (ControlType) {
@@ -36,5 +35,4 @@ var ControlType;
36
35
  ControlType["KEYS_COUNTER"] = "keys_counter";
37
36
  ControlType["COLLECTION"] = "collection";
38
37
  ControlType["IMAGES"] = "images";
39
- ControlType["PRODUCT_PICKER"] = "product_picker";
40
38
  })(ControlType || (exports.ControlType = ControlType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@win2win/shared",
3
- "version": "1.0.289",
3
+ "version": "1.0.290",
4
4
  "description": "Tipos, interfaces, funciones, constantes, clases y enums compartidos por todos los proyectos de Win2Win",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,43 +0,0 @@
1
- import { TipoIVA } from "../enums";
2
- interface PayloadProductoPedido {
3
- ID_PRODUCTO: number;
4
- CANTIDAD: number;
5
- PRECIO?: number;
6
- PROPS?: Record<string, unknown>;
7
- ID_PRECIO?: number;
8
- ID_DIVISA?: number;
9
- PRINCIPAL?: boolean;
10
- DESCUENTO?: number;
11
- IVA?: number;
12
- RECARGO_EQUIVALENCIA?: number;
13
- PRODUCTO: ProductoDetalle;
14
- }
15
- interface ProductoDetalle {
16
- ID_PRODUCTO: number;
17
- DETALLE_PACK?: PackDetalle[];
18
- PACK?: boolean;
19
- PRECIO: number;
20
- TIPO_IVA: TipoIVA;
21
- DESCUENTO?: number;
22
- }
23
- interface PackDetalle {
24
- CANTIDAD: number;
25
- DESCUENTO?: number;
26
- DETALLE: {
27
- PRECIO: number;
28
- TIPO_IVA: TipoIVA;
29
- };
30
- }
31
- export declare class OrderProductsBuilder {
32
- private readonly orderProducts;
33
- private readonly aplicaRecargoEquivalencia;
34
- constructor(data: PayloadProductoPedido[], aplicaRecargoEquivalencia?: boolean);
35
- build(): PayloadProductoPedido[];
36
- private buildProduct;
37
- private buildSimpleProducto;
38
- private buildPackProducto;
39
- private calculatePackTotals;
40
- private getPrecioFinal;
41
- private extractTotalsFromProductPrice;
42
- }
43
- export {};
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OrderProductsBuilder = void 0;
4
- const enums_1 = require("../enums");
5
- const ProductPrice_1 = require("./ProductPrice");
6
- class OrderProductsBuilder {
7
- constructor(data, aplicaRecargoEquivalencia = false) {
8
- if (!Array.isArray(data)) {
9
- throw new Error("Data must be an array of products");
10
- }
11
- this.orderProducts = data;
12
- this.aplicaRecargoEquivalencia = aplicaRecargoEquivalencia;
13
- }
14
- build() {
15
- return this.orderProducts.map((item) => this.buildProduct(item));
16
- }
17
- buildProduct(item) {
18
- if (!item?.PRODUCTO) {
19
- throw new Error(`Product data is missing for item with ID: ${item?.ID_PRODUCTO}`);
20
- }
21
- if (item.PRODUCTO.PACK) {
22
- return this.buildPackProducto(item);
23
- }
24
- else {
25
- return this.buildSimpleProducto(item);
26
- }
27
- }
28
- buildSimpleProducto(item) {
29
- const precioFinal = this.getPrecioFinal(item);
30
- const cantidad = Math.max(1, item.CANTIDAD || 1);
31
- const productPrice = new ProductPrice_1.ProductPrice({
32
- PRECIO: precioFinal * cantidad,
33
- TIPO_IVA: item.PRODUCTO.TIPO_IVA || enums_1.TipoIVA.EXENTO,
34
- DESCUENTO: item.PRODUCTO.DESCUENTO || 0,
35
- APLICA_RECARGO_EQUIVALENCIA: this.aplicaRecargoEquivalencia,
36
- });
37
- const totals = this.extractTotalsFromProductPrice(productPrice);
38
- return {
39
- ...item,
40
- ...totals,
41
- ID_PRECIO: item.ID_PRECIO || undefined,
42
- };
43
- }
44
- buildPackProducto(item) {
45
- const packDetails = item.PRODUCTO.DETALLE_PACK || [];
46
- if (packDetails.length === 0) {
47
- console.warn(`Pack product ${item.PRODUCTO.ID_PRODUCTO} has no pack details`);
48
- }
49
- const totals = this.calculatePackTotals(packDetails);
50
- return {
51
- ...item,
52
- ...totals,
53
- };
54
- }
55
- calculatePackTotals(packDetails) {
56
- const initialTotals = {
57
- PRECIO: 0,
58
- IVA: 0,
59
- DESCUENTO: 0,
60
- RECARGO_EQUIVALENCIA: 0,
61
- };
62
- return packDetails.reduce((totals, packDetail) => {
63
- const precio = Number(packDetail.DETALLE?.PRECIO || 0);
64
- const cantidad = Math.max(1, packDetail.CANTIDAD || 1);
65
- const descuento = Number(packDetail.DESCUENTO || 0);
66
- if (precio <= 0) {
67
- console.warn("Pack detail has invalid price:", packDetail);
68
- return totals;
69
- }
70
- const productPrice = new ProductPrice_1.ProductPrice({
71
- PRECIO: precio * cantidad,
72
- TIPO_IVA: packDetail.DETALLE?.TIPO_IVA || enums_1.TipoIVA.EXENTO,
73
- DESCUENTO: descuento,
74
- APLICA_RECARGO_EQUIVALENCIA: this.aplicaRecargoEquivalencia,
75
- });
76
- const detailTotals = this.extractTotalsFromProductPrice(productPrice);
77
- return {
78
- PRECIO: totals.PRECIO + detailTotals.PRECIO,
79
- IVA: totals.IVA + detailTotals.IVA,
80
- DESCUENTO: totals.DESCUENTO + detailTotals.DESCUENTO,
81
- RECARGO_EQUIVALENCIA: totals.RECARGO_EQUIVALENCIA + detailTotals.RECARGO_EQUIVALENCIA,
82
- };
83
- }, initialTotals);
84
- }
85
- getPrecioFinal(item) {
86
- const precio = Number(item.PRECIO ?? item.PRODUCTO?.PRECIO ?? 0);
87
- if (precio < 0) {
88
- throw new Error(`Invalid negative price for product ${item.PRODUCTO.ID_PRODUCTO}`);
89
- }
90
- return precio;
91
- }
92
- extractTotalsFromProductPrice(productPrice) {
93
- return {
94
- PRECIO: productPrice.getPrice(),
95
- IVA: productPrice.getIVAPrice(),
96
- DESCUENTO: productPrice.getDiscountPrice(),
97
- RECARGO_EQUIVALENCIA: productPrice.getREPrice(),
98
- };
99
- }
100
- }
101
- exports.OrderProductsBuilder = OrderProductsBuilder;