@win2win/shared 1.0.164 → 1.0.166
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.
- package/dist/enums/producto.d.ts +6 -0
- package/dist/enums/producto.js +8 -1
- package/dist/helpers/ProductPrice.d.ts +11 -1
- package/dist/helpers/ProductPrice.js +30 -4
- package/dist/interfaces/landings/page_sections.d.ts +2 -1
- package/dist/interfaces/landings/page_sections.js +15 -1
- package/package.json +1 -1
- package/README.md +0 -11
package/dist/enums/producto.d.ts
CHANGED
package/dist/enums/producto.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TipoIVA = exports.TipoProducto = exports.EstadoProducto = void 0;
|
|
3
|
+
exports.TipoRE = exports.TipoIVA = exports.TipoProducto = exports.EstadoProducto = void 0;
|
|
4
4
|
var EstadoProducto;
|
|
5
5
|
(function (EstadoProducto) {
|
|
6
6
|
EstadoProducto["DESHABILITADO"] = "0";
|
|
@@ -22,3 +22,10 @@ var TipoIVA;
|
|
|
22
22
|
TipoIVA["SUPERREDUCIDO"] = "superreducido";
|
|
23
23
|
TipoIVA["EXENTO"] = "exento";
|
|
24
24
|
})(TipoIVA || (exports.TipoIVA = TipoIVA = {}));
|
|
25
|
+
var TipoRE;
|
|
26
|
+
(function (TipoRE) {
|
|
27
|
+
TipoRE["GENERAL"] = "general";
|
|
28
|
+
TipoRE["REDUCIDO"] = "reducido";
|
|
29
|
+
TipoRE["SUPERREDUCIDO"] = "superreducido";
|
|
30
|
+
TipoRE["EXENTO"] = "exento";
|
|
31
|
+
})(TipoRE || (exports.TipoRE = TipoRE = {}));
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import { TipoIVA } from
|
|
1
|
+
import { TipoIVA, TipoRE } from "../enums";
|
|
2
2
|
interface PartialProduct {
|
|
3
3
|
TIPO_IVA?: TipoIVA;
|
|
4
4
|
PRECIO?: number;
|
|
5
|
+
DESCUENTO?: number;
|
|
6
|
+
TIPO_RE?: TipoRE;
|
|
5
7
|
}
|
|
6
8
|
export declare class ProductPrice {
|
|
7
9
|
private ivaRate;
|
|
8
10
|
private netPrice;
|
|
11
|
+
private discountRate;
|
|
12
|
+
private reRate;
|
|
9
13
|
constructor(product: PartialProduct);
|
|
10
14
|
getNetPrice(): number;
|
|
15
|
+
getDiscountPercent(): number;
|
|
16
|
+
getDiscountAmount(): number;
|
|
17
|
+
getDiscountedPrice(): number;
|
|
11
18
|
getIVAPercent(): number;
|
|
19
|
+
getREPercent(): number;
|
|
20
|
+
getRE(): number;
|
|
21
|
+
getTotalTaxes(): number;
|
|
12
22
|
getIVA(): number;
|
|
13
23
|
getTotalPrice(): number;
|
|
14
24
|
getPVP(includeIVA?: boolean): number;
|
|
@@ -8,28 +8,54 @@ const IVA_RATE = {
|
|
|
8
8
|
[enums_1.TipoIVA.SUPERREDUCIDO]: 0.04,
|
|
9
9
|
[enums_1.TipoIVA.EXENTO]: 0,
|
|
10
10
|
};
|
|
11
|
+
const RE_RATE = {
|
|
12
|
+
[enums_1.TipoRE.GENERAL]: 0.052,
|
|
13
|
+
[enums_1.TipoRE.REDUCIDO]: 0.014,
|
|
14
|
+
[enums_1.TipoRE.SUPERREDUCIDO]: 0.005,
|
|
15
|
+
[enums_1.TipoRE.EXENTO]: 0,
|
|
16
|
+
};
|
|
11
17
|
class ProductPrice {
|
|
12
18
|
constructor(product) {
|
|
13
|
-
this.ivaRate = IVA_RATE[product.TIPO_IVA || enums_1.TipoIVA.
|
|
19
|
+
this.ivaRate = IVA_RATE[product.TIPO_IVA || enums_1.TipoIVA.EXENTO];
|
|
20
|
+
this.reRate = RE_RATE[product?.TIPO_RE || enums_1.TipoRE.EXENTO];
|
|
14
21
|
this.netPrice = Number(product.PRECIO || 0);
|
|
22
|
+
this.discountRate = Number(product.DESCUENTO || 0) / 100;
|
|
15
23
|
}
|
|
16
24
|
getNetPrice() {
|
|
17
25
|
return this.roundToDecimals(this.netPrice);
|
|
18
26
|
}
|
|
27
|
+
getDiscountPercent() {
|
|
28
|
+
return this.discountRate * 100;
|
|
29
|
+
}
|
|
30
|
+
getDiscountAmount() {
|
|
31
|
+
return this.roundToDecimals(this.getNetPrice() * this.discountRate);
|
|
32
|
+
}
|
|
33
|
+
getDiscountedPrice() {
|
|
34
|
+
return this.roundToDecimals(this.getNetPrice() - this.getDiscountAmount());
|
|
35
|
+
}
|
|
19
36
|
getIVAPercent() {
|
|
20
37
|
return this.ivaRate * 100;
|
|
21
38
|
}
|
|
39
|
+
getREPercent() {
|
|
40
|
+
return this.reRate * 100;
|
|
41
|
+
}
|
|
42
|
+
getRE() {
|
|
43
|
+
return this.roundToDecimals(this.getDiscountedPrice() * this.reRate);
|
|
44
|
+
}
|
|
45
|
+
getTotalTaxes() {
|
|
46
|
+
return this.roundToDecimals(this.getIVA() + this.getRE());
|
|
47
|
+
}
|
|
22
48
|
getIVA() {
|
|
23
|
-
return this.roundToDecimals(this.
|
|
49
|
+
return this.roundToDecimals(this.getDiscountedPrice() * this.ivaRate);
|
|
24
50
|
}
|
|
25
51
|
getTotalPrice() {
|
|
26
|
-
return this.
|
|
52
|
+
return this.getDiscountedPrice() + this.getIVA() + this.getRE();
|
|
27
53
|
}
|
|
28
54
|
getPVP(includeIVA = true) {
|
|
29
55
|
if (includeIVA) {
|
|
30
56
|
return this.getTotalPrice();
|
|
31
57
|
}
|
|
32
|
-
return this.
|
|
58
|
+
return this.getDiscountedPrice();
|
|
33
59
|
}
|
|
34
60
|
roundToDecimals(value, decimals = 2) {
|
|
35
61
|
return Number(value.toFixed(decimals));
|
|
@@ -117,7 +117,8 @@ export declare const TEMPLATES: Readonly<{
|
|
|
117
117
|
};
|
|
118
118
|
readonly "ecommerce-banner": {
|
|
119
119
|
readonly label: "Banner para Ecommerce";
|
|
120
|
-
readonly params: readonly ["title", "text", "background", "image", "height", "custom"];
|
|
120
|
+
readonly params: readonly ["title", "text", "background", "image", "height", "custom", "button"];
|
|
121
|
+
readonly variants: readonly ["default", "text-image", "text-centered", "text-image-background"];
|
|
121
122
|
};
|
|
122
123
|
readonly "ecommerce-filters": {
|
|
123
124
|
readonly label: "Filtros para Ecommerce";
|
|
@@ -161,7 +161,21 @@ exports.TEMPLATES = Object.freeze({
|
|
|
161
161
|
},
|
|
162
162
|
"ecommerce-banner": {
|
|
163
163
|
label: "Banner para Ecommerce",
|
|
164
|
-
params: [
|
|
164
|
+
params: [
|
|
165
|
+
"title",
|
|
166
|
+
"text",
|
|
167
|
+
"background",
|
|
168
|
+
"image",
|
|
169
|
+
"height",
|
|
170
|
+
"custom",
|
|
171
|
+
"button",
|
|
172
|
+
],
|
|
173
|
+
variants: [
|
|
174
|
+
"default",
|
|
175
|
+
"text-image",
|
|
176
|
+
"text-centered",
|
|
177
|
+
"text-image-background",
|
|
178
|
+
],
|
|
165
179
|
},
|
|
166
180
|
"ecommerce-filters": {
|
|
167
181
|
label: "Filtros para Ecommerce",
|
package/package.json
CHANGED