sysone-api-mapper 1.0.111 → 1.0.113

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sysone-api-mapper",
3
- "version": "1.0.111",
3
+ "version": "1.0.113",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  // Import modules organized by functionality
2
+ import { getBillingsParams } from "./modules/billing";
2
3
  import { getClaims_CNP } from "./modules/claim";
3
4
  import { getModules, getModules_Request } from "./modules/general";
4
5
  import {
@@ -76,6 +77,27 @@ const configurationModule = {
76
77
  }
77
78
  };
78
79
 
80
+
81
+ // ============================================================================
82
+ // BILLING MODULE
83
+ // ============================================================================
84
+ const billingModule = {
85
+ GET_BILLINGS: {
86
+ default: {
87
+ url: 'billing/v1/billing',
88
+ method: methods.GET,
89
+ requestMapper: (request) => ({ mappedParams: request }),
90
+ responseMapper: (response) => response.data,
91
+ },
92
+ cnp: {
93
+ url: 'policy/v1/policy/{0}/{1}/payments',
94
+ method: methods.GET,
95
+ requestMapper: request => ({ mappedParams: getBillingsParams(request) }),
96
+ responseMapper: (response) => response.data,
97
+ },
98
+ },
99
+ }
100
+
79
101
  // ============================================================================
80
102
  // INTERMEDIARY MODULE
81
103
  // ============================================================================
@@ -816,4 +838,5 @@ export const tenantsConfig = {
816
838
  ...claimModule,
817
839
  ...quotationModule,
818
840
  ...requestModule,
841
+ ...billingModule,
819
842
  };
@@ -0,0 +1,43 @@
1
+ export const getBillingsParams = (i) => {
2
+ return {}
3
+ }
4
+
5
+ export const getBillingsResponse = (data) => {
6
+ const values = data.paymentsEndorsement.map((endorsement, index) => {
7
+
8
+ return endorsement.payments.map((payment, pIndex) => ({
9
+ id: `${index + 1}-${pIndex + 1}`, // No tiene ID propio, uso el index + 1
10
+ code: `${index + 1}-${pIndex + 1}`, // No tiene código propio, uso el index + 1
11
+ billingNumber: payment.installmentNumber,
12
+ billingDate: payment.paymentDate,
13
+ billingExpirationDate: payment.expirationDate ?? payment.expiration,
14
+ totalAmount: payment.amount,
15
+ remainingAmount: payment.debt,
16
+ paymentStatus: {
17
+ code: payment.amount < 0 ? "UNPAID" : "PAID", // ---- Si el monto es negativo esta pago???
18
+ name: payment.amount < 0 ? "Sin Pagar" : "Pagado" // ---- Si el monto es negativo esta pago???
19
+ },
20
+ status: {}, // ----- NO HAY STATUS
21
+ name: "Sin nombre del pagador", // ----- NO HAY NOMBRE DEL PAGADOR
22
+ policy: {}, // ----- NO HAY DATOS DE POLIZA
23
+ billingValuesGrouping: [
24
+ {
25
+ type: { name: "Prima", code: "PRIME" },
26
+ value: payment.amount // ----- SOLO LLEGA LA PRIMA ??? NO HAY PREMIO, GASTOS, IMPUESTOS, OTROS ?
27
+ }
28
+ ],
29
+ type: {}, // ----- NO HAY TIPO DE FACTURACION
30
+ subtype: {},
31
+ exchangeRate: null,
32
+ billingDateFrom: "N/A",
33
+ billingDateTo: "N/A",
34
+ invoiceBarcode: payment.invoiceBarcode || null
35
+ }));
36
+ });
37
+
38
+ return {
39
+ values,
40
+ total: values.length
41
+ };
42
+ };
43
+
@@ -436,7 +436,7 @@ export const getProductsBySubsections = async (response) => {
436
436
  version: item.version,
437
437
  subsection: item?.subsection || null,
438
438
  fieldExclusions: item?.fieldExclusions || null,
439
- fieldValues: item?.fieldValues || null
439
+ fields: item?.fieldValues || item?.fields || null
440
440
  })),
441
441
  };
442
442
  return objectMapped;