sysone-api-mapper 1.0.112 → 1.0.114

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.112",
3
+ "version": "1.0.114",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -113,6 +113,12 @@ export const apiMapper = async (
113
113
  throw new Error(`Endpoint no configurado: ${endpointCode}`);
114
114
 
115
115
  const endpointData = configData[tenant] ?? configData.default;
116
+
117
+ if (endpointData === null) {
118
+ console.warn(`⚠️ No hay configuración para el endpoint ${endpointCode} y tenant ${tenant}, y no existe configuración por defecto.`);
119
+ throw new Error(`No hay configuración para el endpoint ${endpointCode} y tenant ${tenant}`);
120
+ }
121
+
116
122
  let config;
117
123
 
118
124
  if (!configs) {
@@ -1,4 +1,5 @@
1
1
  // Import modules organized by functionality
2
+ import { getBillingsParams, getBillingsResponse } 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,37 @@ 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) => getBillingsResponse(response.data),
97
+ },
98
+ },
99
+
100
+ GET_BILLING_TYPE: {
101
+ default: {
102
+ url: 'billing/v1/billing-types',
103
+ method: methods.GET,
104
+ requestMapper: (request) => ({ mappedParams: request }),
105
+ responseMapper: (response) => response.data,
106
+ },
107
+ cnp: null
108
+ },
109
+ };
110
+
79
111
  // ============================================================================
80
112
  // INTERMEDIARY MODULE
81
113
  // ============================================================================
@@ -816,4 +848,5 @@ export const tenantsConfig = {
816
848
  ...claimModule,
817
849
  ...quotationModule,
818
850
  ...requestModule,
851
+ ...billingModule,
819
852
  };
@@ -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
+