@win2win/shared 1.0.165 → 1.0.167

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # README #
2
+ version 1.0.1
3
+
4
+ ### Como hacer deploy del repo
5
+
6
+ * Correr el comando
7
+ `npm run deploy`
8
+
9
+ * [Enlace al repo](https://www.npmjs.com/package/@win2win/shared)
10
+
11
+
@@ -16,3 +16,9 @@ export declare enum TipoIVA {
16
16
  SUPERREDUCIDO = "superreducido",
17
17
  EXENTO = "exento"
18
18
  }
19
+ export declare enum TipoRE {
20
+ GENERAL = "general",
21
+ REDUCIDO = "reducido",
22
+ SUPERREDUCIDO = "superreducido",
23
+ EXENTO = "exento"
24
+ }
@@ -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 '../enums';
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.GENERAL];
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.getNetPrice() * this.ivaRate);
49
+ return this.roundToDecimals(this.getDiscountedPrice() * this.ivaRate);
24
50
  }
25
51
  getTotalPrice() {
26
- return this.getNetPrice() + this.getIVA();
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.getNetPrice();
58
+ return this.getDiscountedPrice();
33
59
  }
34
60
  roundToDecimals(value, decimals = 2) {
35
61
  return Number(value.toFixed(decimals));
@@ -186,6 +186,7 @@ export interface SectionItem {
186
186
  file?: File;
187
187
  } | null;
188
188
  value: string | number | null;
189
+ key?: string;
189
190
  image2?: {
190
191
  src: string;
191
192
  file?: File;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@win2win/shared",
3
- "version": "1.0.165",
3
+ "version": "1.0.167",
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",