sysone-api-mapper 1.0.118 → 1.0.119

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.118",
3
+ "version": "1.0.119",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  // Import modules organized by functionality
2
- import { getBillingsParams, getBillingsResponse, getBillingTypeResponse } from "./modules/billing";
2
+ import { getBillingsParams, getBillingsResponse, getBillingTypeResponse, getCollecionsResponse, getDebtorsResponse } from "./modules/billing";
3
3
  import { getClaims_CNP } from "./modules/claim";
4
4
  import { getModules, getModules_Request } from "./modules/general";
5
5
  import {
@@ -107,7 +107,21 @@ const billingModule = {
107
107
  url: 'policy/v1/policy/{0}/{1}/payments',
108
108
  method: methods.GET,
109
109
  requestMapper: request => ({ mappedParams: getBillingsParams(request) }),
110
- responseMapper: (response) => getBillingsResponse(response.data),
110
+ responseMapper: (response) => getCollecionsResponse(response.data),
111
+ },
112
+ },
113
+ GET_DEBTORS: {
114
+ default: {
115
+ url: 'billing/v1/billing',
116
+ method: methods.GET,
117
+ requestMapper: (request) => ({ mappedParams: request }),
118
+ responseMapper: (response) => response.data,
119
+ },
120
+ cnp: {
121
+ url: 'policy/v1/policy/{0}/{1}/payments',
122
+ method: methods.GET,
123
+ requestMapper: request => ({ mappedParams: getBillingsParams(request) }),
124
+ responseMapper: (response) => getDebtorsResponse(response.data),
111
125
  },
112
126
  },
113
127
 
@@ -43,6 +43,79 @@ export const getBillingsResponse = (data) => {
43
43
  total: values.length
44
44
  };
45
45
  };
46
+ export const getDebtorsResponse = (data) => {
47
+ const values = data.paymentsEndorsement
48
+ .flatMap((endorsement, index) => {
49
+ return endorsement.payments.map((payment, pIndex) => ({
50
+ id: `${index + 1}-${pIndex + 1}`,
51
+ code: `${index + 1}-${pIndex + 1}`,
52
+ billingNumber: payment.installmentNumber,
53
+ billingDate: payment.paymentDate,
54
+ billingExpirationDate: payment.expiration ?? payment.expirationDate,
55
+ totalAmount: payment.amount,
56
+ remainingAmount: payment.debt,
57
+ paymentStatus: {
58
+ code: payment.debt < 0 ? "UNPAID" : "PAID",
59
+ name: payment.debt < 0 ? "Sin Pagar" : "Pagado"
60
+ },
61
+ status: {},
62
+ name: "Sin nombre del pagador",
63
+ policy: {},
64
+ billingValuesGrouping: [
65
+ {
66
+ type: { name: "Prima", code: "PRIME" },
67
+ value: payment.amount
68
+ }
69
+ ],
70
+ type: {
71
+ name: "Factura",
72
+ code: "INVOICE",
73
+ },
74
+ subtype: {},
75
+ exchangeRate: null,
76
+ billingDateFrom: "N/A",
77
+ billingDateTo: "N/A",
78
+ invoiceBarcode: payment.invoiceBarcode || null
79
+ }));
80
+ })
81
+ .filter(payment => payment?.debt > 0 || payment?.remainingAmount > 0);
82
+
83
+ return {
84
+ values,
85
+ total: values.length
86
+ };
87
+ };
88
+
89
+ export const getCollecionsResponse = (data) => {
90
+ const values = data.paymentsEndorsement.flatMap((endorsement, index) => {
91
+
92
+ return endorsement.payments.map((payment, pIndex) => ({
93
+ code: `${index + 1}-${pIndex + 1}`,
94
+ amount: payment.amount,
95
+ applyAmount: payment.debt,
96
+ collectionDate: payment.paymentDate,
97
+ collectionNumber: payment.installmentNumber,
98
+ currency: {
99
+ name: "Peso Argentino",
100
+ code: "PESO_ARG",
101
+ mnemonic: "ARS",
102
+ symbol: "$"
103
+ },
104
+ name: "Sin nombre del pagador",
105
+ paymentType: null,
106
+ policy: {},
107
+ status: {},
108
+ invoiceBarcode: payment.invoiceBarcode || null,
109
+ rejectionReason: payment.rejectionReason || null,
110
+ expirationDate: payment.expirationDate || null,
111
+ }));
112
+ });
113
+
114
+ return {
115
+ values,
116
+ total: values.length
117
+ };
118
+ };
46
119
 
47
120
 
48
121
  export const getBillingTypeResponse = () => {