sysone-api-mapper 1.0.118 → 1.0.120
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,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) =>
|
|
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 = () => {
|
|
@@ -388,8 +388,8 @@ export const getQuotationByCode_Request = (inputParams) => {
|
|
|
388
388
|
export const getQuotations_Request = (inputParams) => {
|
|
389
389
|
return {
|
|
390
390
|
number: inputParams.quotationNumber || undefined,
|
|
391
|
-
from: inputParams.
|
|
392
|
-
to: inputParams.
|
|
391
|
+
from: inputParams.dateFrom || undefined,
|
|
392
|
+
to: inputParams.dateTo || undefined,
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
|
|
@@ -436,7 +436,7 @@ export const getProductsBySubsections = async (response) => {
|
|
|
436
436
|
version: item.version,
|
|
437
437
|
subsection: item?.subsection || null,
|
|
438
438
|
fieldExclusions: item?.exclusions || null,
|
|
439
|
-
fields: item?.fieldValues || item?.fields || null
|
|
439
|
+
fields: item?.fieldValues || item?.fields || null
|
|
440
440
|
})),
|
|
441
441
|
};
|
|
442
442
|
return objectMapped;
|