@lendi/integrations-transform 1.0.7 → 1.1.1
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/lib/index.d.ts +7 -0
- package/lib/index.js +20 -0
- package/lib/logger.d.ts +2 -0
- package/lib/logger.js +5 -0
- package/lib/schemas/credit-report-retrieved-event.json +57 -0
- package/lib/schemas/public-applicant-event.json +652 -0
- package/lib/schemas/public-application-event.json +224 -0
- package/lib/schemas/public-asset-event.json +633 -0
- package/lib/schemas/public-asset-liability-relation-delete-event.json +74 -0
- package/lib/schemas/public-asset-liability-relation-event.json +73 -0
- package/lib/schemas/public-create-applicant-event.json +610 -0
- package/lib/schemas/public-delete-applicant-event.json +66 -0
- package/lib/schemas/public-delete-asset-event.json +53 -0
- package/lib/schemas/public-delete-income-event.json +55 -0
- package/lib/schemas/public-employment-delete-event.json +31 -0
- package/lib/schemas/public-employment-event.json +302 -0
- package/lib/schemas/public-expense-delete-event.json +41 -0
- package/lib/schemas/public-expense-event.json +132 -0
- package/lib/schemas/public-funding-position-event.json +289 -0
- package/lib/schemas/public-income-event.json +242 -0
- package/lib/schemas/public-liability-delete-event.json +37 -0
- package/lib/schemas/public-liability-event.json +234 -0
- package/lib/schemas/public-required-document-event.json +98 -0
- package/lib/schemas/public-update-applicant-event.json +607 -0
- package/lib/schemas/sf-opportunity-event-out.json +138 -0
- package/lib/transform-events/generate-asset-liability-link.d.ts +8 -0
- package/lib/transform-events/generate-asset-liability-link.js +29 -0
- package/lib/transform-events/generate-asset.d.ts +17 -0
- package/lib/transform-events/generate-asset.js +178 -0
- package/lib/transform-events/generate-credit-report-rebuilt.d.ts +8 -0
- package/lib/transform-events/generate-credit-report-rebuilt.js +41 -0
- package/lib/transform-events/generate-employment.d.ts +8 -0
- package/lib/transform-events/generate-employment.js +106 -0
- package/lib/transform-events/generate-funding-position.d.ts +18 -0
- package/lib/transform-events/generate-funding-position.js +82 -0
- package/lib/transform-events/generate-income.d.ts +37 -0
- package/lib/transform-events/generate-income.js +254 -0
- package/lib/transform-events/generate-liability.d.ts +8 -0
- package/lib/transform-events/generate-liability.js +87 -0
- package/lib/transform-events/generate-lixi-percentowned.d.ts +9 -0
- package/lib/transform-events/generate-lixi-percentowned.js +24 -0
- package/lib/transform-events/generate-opportunity.d.ts +8 -0
- package/lib/transform-events/generate-opportunity.js +32 -0
- package/lib/transform-events/generate-required-document.d.ts +8 -0
- package/lib/transform-events/generate-required-document.js +54 -0
- package/lib/transform-events/transform-applicant.d.ts +33 -0
- package/lib/transform-events/transform-applicant.js +189 -0
- package/lib/transform-events/transform-application.d.ts +8 -0
- package/lib/transform-events/transform-application.js +54 -0
- package/lib/transform-events/transform-expenses.d.ts +37 -0
- package/lib/transform-events/transform-expenses.js +121 -0
- package/lib/types/enum-mappings/alieo-frequency.d.ts +15 -0
- package/lib/types/enum-mappings/alieo-frequency.js +26 -0
- package/lib/types/enum-mappings/country-code.d.ts +7 -0
- package/lib/types/enum-mappings/country-code.js +247 -0
- package/lib/types/enum-mappings/employment-basis.d.ts +7 -0
- package/lib/types/enum-mappings/employment-basis.js +13 -0
- package/lib/types/enum-mappings/expense-frequency.d.ts +7 -0
- package/lib/types/enum-mappings/expense-frequency.js +12 -0
- package/lib/types/enum-mappings/funding-position.d.ts +18 -0
- package/lib/types/enum-mappings/funding-position.js +34 -0
- package/lib/types/enum-mappings/government-benefits.d.ts +7 -0
- package/lib/types/enum-mappings/government-benefits.js +11 -0
- package/lib/types/enum-mappings/housing-status.d.ts +7 -0
- package/lib/types/enum-mappings/housing-status.js +16 -0
- package/lib/types/enum-mappings/income-type.d.ts +7 -0
- package/lib/types/enum-mappings/income-type.js +17 -0
- package/lib/types/enum-mappings/liability-payment-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-payment-type.js +10 -0
- package/lib/types/enum-mappings/liability-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-type.js +22 -0
- package/lib/types/enum-mappings/living-expense.d.ts +7 -0
- package/lib/types/enum-mappings/living-expense.js +31 -0
- package/lib/types/enum-mappings/marital-status.d.ts +7 -0
- package/lib/types/enum-mappings/marital-status.js +13 -0
- package/lib/types/enum-mappings/postcode.d.ts +6 -0
- package/lib/types/enum-mappings/postcode.js +16 -0
- package/lib/types/enum-mappings/preferred-repayment.d.ts +7 -0
- package/lib/types/enum-mappings/preferred-repayment.js +11 -0
- package/lib/types/enum-mappings/proof-of-identity.d.ts +7 -0
- package/lib/types/enum-mappings/proof-of-identity.js +11 -0
- package/lib/types/enum-mappings/public-financial-asset.d.ts +7 -0
- package/lib/types/enum-mappings/public-financial-asset.js +13 -0
- package/lib/types/enum-mappings/public-primary-purpose.d.ts +7 -0
- package/lib/types/enum-mappings/public-primary-purpose.js +10 -0
- package/lib/types/enum-mappings/public-property-status.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-status.js +12 -0
- package/lib/types/enum-mappings/public-property-type.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-type.js +24 -0
- package/lib/types/enum-mappings/residency-status.d.ts +7 -0
- package/lib/types/enum-mappings/residency-status.js +12 -0
- package/lib/types/enum-mappings/title-gender.d.ts +7 -0
- package/lib/types/enum-mappings/title-gender.js +14 -0
- package/lib/types/enum-mappings/title.d.ts +7 -0
- package/lib/types/enum-mappings/title.js +14 -0
- package/lib/types/enum-mappings/transaction-type.d.ts +7 -0
- package/lib/types/enum-mappings/transaction-type.js +10 -0
- package/lib/types/events/applicant-delete.d.ts +42 -0
- package/lib/types/events/applicant-delete.js +15 -0
- package/lib/types/events/asset-delete.d.ts +33 -0
- package/lib/types/events/asset-delete.js +15 -0
- package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
- package/lib/types/events/asset-liability-relation-delete.js +15 -0
- package/lib/types/events/credit-report-retrieved.d.ts +36 -0
- package/lib/types/events/credit-report-retrieved.js +15 -0
- package/lib/types/events/employment-delete.d.ts +19 -0
- package/lib/types/events/employment-delete.js +7 -0
- package/lib/types/events/expense-delete.d.ts +21 -0
- package/lib/types/events/expense-delete.js +7 -0
- package/lib/types/events/funding-position.d.ts +116 -0
- package/lib/types/events/funding-position.js +34 -0
- package/lib/types/events/income-delete.d.ts +33 -0
- package/lib/types/events/income-delete.js +15 -0
- package/lib/types/events/liability-delete.d.ts +17 -0
- package/lib/types/events/liability-delete.js +7 -0
- package/lib/types/events/opportunity.d.ts +102 -0
- package/lib/types/events/opportunity.js +47 -0
- package/lib/types/events/public-applicant.d.ts +485 -0
- package/lib/types/events/public-applicant.js +343 -0
- package/lib/types/events/public-application.d.ts +145 -0
- package/lib/types/events/public-application.js +100 -0
- package/lib/types/events/public-asset-liability-relation.d.ts +52 -0
- package/lib/types/events/public-asset-liability-relation.js +15 -0
- package/lib/types/events/public-asset.d.ts +469 -0
- package/lib/types/events/public-asset.js +319 -0
- package/lib/types/events/public-employment.d.ts +190 -0
- package/lib/types/events/public-employment.js +69 -0
- package/lib/types/events/public-expense.d.ts +83 -0
- package/lib/types/events/public-expense.js +50 -0
- package/lib/types/events/public-funding-position.d.ts +226 -0
- package/lib/types/events/public-funding-position.js +7 -0
- package/lib/types/events/public-income.d.ts +144 -0
- package/lib/types/events/public-income.js +65 -0
- package/lib/types/events/public-liability.d.ts +133 -0
- package/lib/types/events/public-liability.js +68 -0
- package/lib/types/events/public-required-document.d.ts +99 -0
- package/lib/types/events/public-required-document.js +44 -0
- package/lib/types/partial-application.d.ts +3 -0
- package/lib/types/partial-application.js +2 -0
- package/lib/types/recursive-partial.d.ts +3 -0
- package/lib/types/recursive-partial.js +2 -0
- package/lib/utils/address-tools.d.ts +69 -0
- package/lib/utils/address-tools.js +146 -0
- package/lib/utils/clean-up.d.ts +7 -0
- package/lib/utils/clean-up.js +24 -0
- package/lib/utils/generate-address.d.ts +19 -0
- package/lib/utils/generate-address.js +102 -0
- package/lib/utils/get-financial-institution.d.ts +7 -0
- package/lib/utils/get-financial-institution.js +16 -0
- package/lib/utils/is-income-type.d.ts +83 -0
- package/lib/utils/is-income-type.js +166 -0
- package/lib/utils/normalise-date.d.ts +8 -0
- package/lib/utils/normalise-date.js +17 -0
- package/lib/utils/round-decimal.d.ts +6 -0
- package/lib/utils/round-decimal.js +12 -0
- package/package.json +10 -7
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.generateDependants = exports.generateContact = exports.transformApplicant = exports.booleanMapping = void 0;
|
|
4
|
+
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
|
+
var lodash_1 = require("lodash");
|
|
7
|
+
var address_tools_1 = require("../utils/address-tools");
|
|
8
|
+
var country_code_1 = require("../types/enum-mappings/country-code");
|
|
9
|
+
var marital_status_1 = require("../types/enum-mappings/marital-status");
|
|
10
|
+
var residency_status_1 = require("../types/enum-mappings/residency-status");
|
|
11
|
+
var title_1 = require("../types/enum-mappings/title");
|
|
12
|
+
var public_applicant_1 = require("../types/events/public-applicant");
|
|
13
|
+
var normalise_date_1 = require("../utils/normalise-date");
|
|
14
|
+
var booleanMapping = function (input) {
|
|
15
|
+
if (input === void 0) { input = false; }
|
|
16
|
+
return (input === true ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
|
|
17
|
+
};
|
|
18
|
+
exports.booleanMapping = booleanMapping;
|
|
19
|
+
var applicantMapping = {
|
|
20
|
+
applicationId: application_paths_1.paths.ApplicationId,
|
|
21
|
+
citizenship: "".concat(application_paths_1.paths.PersonApplicant, ".@Citizenship"),
|
|
22
|
+
contact: "".concat(application_paths_1.paths.PersonApplicant, ".Contact"),
|
|
23
|
+
dependants: 'dependants',
|
|
24
|
+
dateOfBirth: "".concat(application_paths_1.paths.PersonApplicant, ".@DateOfBirth"),
|
|
25
|
+
firstName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@FirstName"),
|
|
26
|
+
id: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
|
|
27
|
+
isFirstHomeBuyer: "".concat(application_paths_1.paths.PersonApplicant, ".@FirstHomeBuyer"),
|
|
28
|
+
isPrimaryApplicant: "".concat(application_paths_1.paths.PersonApplicant, ".@PrimaryApplicant"),
|
|
29
|
+
lastName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@Surname"),
|
|
30
|
+
maritalStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@MaritalStatus"),
|
|
31
|
+
maritalDetails: "".concat(application_paths_1.paths.PersonApplicant, ".MaritalStatusDetails.@x_Spouse"),
|
|
32
|
+
middleName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@MiddleNames"),
|
|
33
|
+
residencyStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@ResidencyStatus"),
|
|
34
|
+
title: "".concat(application_paths_1.paths.PersonName, ".@NameTitle")
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Transforms a partial Applicant event to a partial LIXI application.
|
|
38
|
+
*
|
|
39
|
+
* @param applicant: A partial applicant.
|
|
40
|
+
* @return partialApplication an incomplete application.
|
|
41
|
+
*/
|
|
42
|
+
function transformApplicant(applicant) {
|
|
43
|
+
var partialApplication = {};
|
|
44
|
+
var applicantId = applicant.id, applicationId = applicant.applicationId;
|
|
45
|
+
(0, lodash_1.set)(partialApplication, applicantMapping['isFirstHomeBuyer'], (0, exports.booleanMapping)(applicant.isFirstHomeBuyer));
|
|
46
|
+
(0, lodash_1.set)(partialApplication, applicantMapping['isPrimaryApplicant'], (0, exports.booleanMapping)(applicant.isPrimaryApplicant));
|
|
47
|
+
(0, lodash_1.set)(partialApplication, applicantMapping['title'], title_1.titleMapping[applicant.title || public_applicant_1.Title.Unknown]);
|
|
48
|
+
var applicantUpdated = (0, lodash_1.omit)(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
|
|
49
|
+
for (var _i = 0, _a = Object.entries(applicantUpdated); _i < _a.length; _i++) {
|
|
50
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
51
|
+
if (applicantMapping[key]) {
|
|
52
|
+
switch (key) {
|
|
53
|
+
case 'dateOfBirth':
|
|
54
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], (0, normalise_date_1.normaliseDate)(value));
|
|
55
|
+
break;
|
|
56
|
+
case 'maritalStatus':
|
|
57
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], marital_status_1.maritalStatusMapping[value]);
|
|
58
|
+
break;
|
|
59
|
+
case 'citizenship':
|
|
60
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], country_code_1.countryCodeMapping[value]);
|
|
61
|
+
break;
|
|
62
|
+
case 'residencyStatus':
|
|
63
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], residency_status_1.residencyStatusMapping[value]);
|
|
64
|
+
// Certain bank integrations require the ability to differentiate between permanentResident and Citizen
|
|
65
|
+
// As lixi does not have a citizen enum for residencyStatus citizen is mapped to permanentResident
|
|
66
|
+
// Adding a @Citizenship attribute to person applicant gives us the ability to determine citizenship status
|
|
67
|
+
// If citizen this field will be always added and value will be AU.
|
|
68
|
+
// @tsilva 21/11/19
|
|
69
|
+
if (value === public_applicant_1.ResidencyStatus.AustralianCitizen) {
|
|
70
|
+
(0, lodash_1.set)(partialApplication, applicantMapping.citizenship, lixi_internal_request_1.CountryCodeList.Au);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case 'maritalDetails':
|
|
74
|
+
var id = (0, lodash_1.get)(value, 'applicantId');
|
|
75
|
+
if (id)
|
|
76
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], id);
|
|
77
|
+
break;
|
|
78
|
+
case 'contact':
|
|
79
|
+
var _c = generateContact(value, applicantId), lixiContact = _c.lixiContact, lixiAddresses = _c.lixiAddresses;
|
|
80
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], lixiContact);
|
|
81
|
+
if (lixiAddresses.length > 0) {
|
|
82
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Addresses, lixiAddresses);
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case 'dependants':
|
|
86
|
+
var dependants = generateDependants(value, applicantId);
|
|
87
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
|
|
88
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".Dependant"), dependants);
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], value);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return partialApplication;
|
|
97
|
+
}
|
|
98
|
+
exports.transformApplicant = transformApplicant;
|
|
99
|
+
var contactMapping = {
|
|
100
|
+
emailAddress: 'EmailAddress.0.@Email',
|
|
101
|
+
mobileNumber: 'Mobile.@Number',
|
|
102
|
+
currentAddress: 'CurrentAddress',
|
|
103
|
+
previousAddresses: 'PreviousAddress',
|
|
104
|
+
priorAddress: 'PriorAddress',
|
|
105
|
+
mailingAddress: 'CurrentAddress.@x_MailingAddress',
|
|
106
|
+
postSettlementAddress: 'PostSettlementAddress'
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Generates a LIXI contact from given contact.
|
|
110
|
+
*
|
|
111
|
+
* @param contact
|
|
112
|
+
* @param id
|
|
113
|
+
*/
|
|
114
|
+
function generateContact(contact, id) {
|
|
115
|
+
var lixiContact = {};
|
|
116
|
+
var lixiAddresses = [];
|
|
117
|
+
for (var _i = 0, _a = Object.entries(contact); _i < _a.length; _i++) {
|
|
118
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
119
|
+
if (contactMapping[key]) {
|
|
120
|
+
switch (key) {
|
|
121
|
+
case 'currentAddress':
|
|
122
|
+
{
|
|
123
|
+
var addressId = "".concat(id, "-current");
|
|
124
|
+
var _c = (0, address_tools_1.rebuildAddress)(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
|
|
125
|
+
lixiAddresses.push(lixiAddress);
|
|
126
|
+
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
case 'postSettlementAddress':
|
|
130
|
+
{
|
|
131
|
+
var addressId = "".concat(id, "-postSettlement");
|
|
132
|
+
var _d = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
|
|
133
|
+
lixiAddresses.push(lixiAddress);
|
|
134
|
+
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case 'mailingAddress':
|
|
138
|
+
{
|
|
139
|
+
var addressId = "".concat(id, "-mailing");
|
|
140
|
+
var lixiAddress = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId).lixiAddress;
|
|
141
|
+
lixiAddresses.push(lixiAddress);
|
|
142
|
+
(0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case 'previousAddresses':
|
|
146
|
+
{
|
|
147
|
+
var addressId = "".concat(id, "-previous");
|
|
148
|
+
var previousAddresses = value.sort(function (lhs, rhs) {
|
|
149
|
+
return lhs.endDate.localeCompare(rhs.endDate);
|
|
150
|
+
});
|
|
151
|
+
var previousAddress = previousAddresses.pop();
|
|
152
|
+
var _e = (0, address_tools_1.rebuildAddress)(previousAddress, addressId), lixiAddress = _e.lixiAddress, lixiContactAddress = _e.lixiContactAddress;
|
|
153
|
+
lixiAddresses.push(lixiAddress);
|
|
154
|
+
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
155
|
+
// PriorAddresses
|
|
156
|
+
previousAddresses.forEach(function (address, index) {
|
|
157
|
+
var _a = (0, address_tools_1.rebuildAddress)(address, "".concat(id, "-prior-").concat(index)), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
|
|
158
|
+
lixiAddresses.push(lixiAddress);
|
|
159
|
+
(0, lodash_1.set)(lixiContact, "".concat(contactMapping['priorAddress'], ".").concat(index), lixiContactAddress);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
(0, lodash_1.set)(lixiContact, contactMapping[key], value);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return { lixiContact: lixiContact, lixiAddresses: lixiAddresses };
|
|
170
|
+
}
|
|
171
|
+
exports.generateContact = generateContact;
|
|
172
|
+
/**
|
|
173
|
+
* Generate dependants
|
|
174
|
+
*
|
|
175
|
+
* @param dependants
|
|
176
|
+
* @param id
|
|
177
|
+
*/
|
|
178
|
+
function generateDependants(dependants, id) {
|
|
179
|
+
return dependants.map(function (dependant) { return ({
|
|
180
|
+
'@Age': dependant.age,
|
|
181
|
+
'@UniqueID': dependant.id,
|
|
182
|
+
FinancialProvider: [
|
|
183
|
+
{
|
|
184
|
+
'@x_Party': id
|
|
185
|
+
},
|
|
186
|
+
]
|
|
187
|
+
}); });
|
|
188
|
+
}
|
|
189
|
+
exports.generateDependants = generateDependants;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Payload as ApplicationPayload } from '../types/events/public-application';
|
|
2
|
+
/**
|
|
3
|
+
* Transforms a partial opportunity event to a partial internal request.
|
|
4
|
+
*
|
|
5
|
+
* @param opportunity: Partial opportunity event.
|
|
6
|
+
* @return partialApplication: A partial internal request.
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformApplication(opportunity: ApplicationPayload): {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.transformApplication = void 0;
|
|
4
|
+
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
5
|
+
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
|
+
var application_paths_2 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
7
|
+
var lodash_1 = require("lodash");
|
|
8
|
+
var preferred_repayment_1 = require("../types/enum-mappings/preferred-repayment");
|
|
9
|
+
var transaction_type_1 = require("../types/enum-mappings/transaction-type");
|
|
10
|
+
/**
|
|
11
|
+
* Transforms a partial opportunity event to a partial internal request.
|
|
12
|
+
*
|
|
13
|
+
* @param opportunity: Partial opportunity event.
|
|
14
|
+
* @return partialApplication: A partial internal request.
|
|
15
|
+
*/
|
|
16
|
+
function transformApplication(opportunity) {
|
|
17
|
+
var partialApplication = {};
|
|
18
|
+
var opportunityMapping = {
|
|
19
|
+
brand: application_paths_1.paths.BusinessName,
|
|
20
|
+
id: application_paths_1.paths.ApplicationId,
|
|
21
|
+
paymentType: "".concat(application_paths_1.paths.LoanTerm, ".@PaymentType"),
|
|
22
|
+
preliminary: 'preliminary',
|
|
23
|
+
primaryPurpose: application_paths_1.paths.PurposeOfApplication,
|
|
24
|
+
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
|
|
25
|
+
};
|
|
26
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.LoanDetail, ".@UniqueID"), "".concat(opportunity.id, "-loanDetails"));
|
|
27
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
|
|
28
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.Instructions, ".@Name"), lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
|
|
29
|
+
for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
|
|
30
|
+
var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
|
|
31
|
+
if (opportunityMapping[opportunityKey]) {
|
|
32
|
+
if (opportunityKey === 'preliminary') {
|
|
33
|
+
for (var _c = 0, _d = Object.entries(opportunityValue); _c < _d.length; _c++) {
|
|
34
|
+
var _e = _d[_c], key = _e[0], value = _e[1];
|
|
35
|
+
if (opportunityMapping[key]) {
|
|
36
|
+
switch (key) {
|
|
37
|
+
case 'paymentType':
|
|
38
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], preferred_repayment_1.preferredRepaymentMapping[value]);
|
|
39
|
+
break;
|
|
40
|
+
case 'primaryPurpose':
|
|
41
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], transaction_type_1.transactionTypeMapping[value]);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return partialApplication;
|
|
53
|
+
}
|
|
54
|
+
exports.transformApplication = transformApplication;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LivingExpense, OtherCommitment } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { Expense, ExpenseType, Payload as ExpensePayload } from '../types/events/public-expense';
|
|
3
|
+
import { PartialApplication } from '../types/partial-application';
|
|
4
|
+
export declare const otherCommitmentExpenseTypes: ExpenseType[];
|
|
5
|
+
/**
|
|
6
|
+
* @description Transforms expense items on the application from the event.
|
|
7
|
+
* @returns {PartialApplication} A PartialApplication returned by transforming the expense event.
|
|
8
|
+
* @param expense
|
|
9
|
+
*/
|
|
10
|
+
export declare function transformExpenses(expense: ExpensePayload): PartialApplication;
|
|
11
|
+
/**
|
|
12
|
+
* transforms the living expense from the expense array on the event.
|
|
13
|
+
*
|
|
14
|
+
* @param expense: Array of expenses on the event.
|
|
15
|
+
* @param applicantId: Event applicantId.
|
|
16
|
+
* @param index: Index of the map.
|
|
17
|
+
* @param id: Id of the event.
|
|
18
|
+
*/
|
|
19
|
+
export declare function transformExpense(expense: Expense, applicantId: string, index: number, id: string): LivingExpense | OtherCommitment;
|
|
20
|
+
/**
|
|
21
|
+
* @description Normalises expense by amount to 0 if not provided and scales quarterly spending up to yearly.
|
|
22
|
+
* @param {Expense} expense An expense
|
|
23
|
+
* @returns {Expense} An normalised expense.
|
|
24
|
+
*/
|
|
25
|
+
export declare function normaliseExpenseAmount(expense: Expense): Expense;
|
|
26
|
+
/**
|
|
27
|
+
* @description Verify if expense is an OtherCommitment.
|
|
28
|
+
* @param {Expense} expense Any Expense item.
|
|
29
|
+
* @returns {boolean} Returns true if an expense type is one of other commitment expenses.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isOtherCommitment(expense: Expense): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @description Check if expense type is LivingExpenseEstimate.
|
|
34
|
+
* @param {Expense} expense An Expense item.
|
|
35
|
+
* @returns {boolean} Returns true if an expense type is LivingExpenseEstimate
|
|
36
|
+
*/
|
|
37
|
+
export declare function isLivingExpenseEstimate(expense: Expense): boolean;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
exports.__esModule = true;
|
|
14
|
+
exports.isLivingExpenseEstimate = exports.isOtherCommitment = exports.normaliseExpenseAmount = exports.transformExpense = exports.transformExpenses = exports.otherCommitmentExpenseTypes = void 0;
|
|
15
|
+
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
16
|
+
var lodash_1 = require("lodash");
|
|
17
|
+
var expense_frequency_1 = require("../types/enum-mappings/expense-frequency");
|
|
18
|
+
var living_expense_1 = require("../types/enum-mappings/living-expense");
|
|
19
|
+
var public_expense_1 = require("../types/events/public-expense");
|
|
20
|
+
exports.otherCommitmentExpenseTypes = [
|
|
21
|
+
public_expense_1.ExpenseType.Board,
|
|
22
|
+
public_expense_1.ExpenseType.ChildAndSpousalMaintenance,
|
|
23
|
+
public_expense_1.ExpenseType.Rent,
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* @description Transforms expense items on the application from the event.
|
|
27
|
+
* @returns {PartialApplication} A PartialApplication returned by transforming the expense event.
|
|
28
|
+
* @param expense
|
|
29
|
+
*/
|
|
30
|
+
function transformExpenses(expense) {
|
|
31
|
+
var partialApplication = {};
|
|
32
|
+
var applicantId = expense.applicantId, applicationId = expense.applicationId, _a = expense.expenses, expenses = _a === void 0 ? [] : _a, id = expense.id;
|
|
33
|
+
if (expenses.every(function (expense) { return expense.amount === undefined || expense.amount === null; })) {
|
|
34
|
+
return partialApplication;
|
|
35
|
+
}
|
|
36
|
+
var normalisedExpenses = expenses.map(normaliseExpenseAmount);
|
|
37
|
+
var livingExpenseEstimate = normalisedExpenses.find(isLivingExpenseEstimate);
|
|
38
|
+
var otherCommitments = normalisedExpenses.filter(isOtherCommitment);
|
|
39
|
+
var expenseBreakdown = normalisedExpenses.filter(function (item) { return !(isOtherCommitment(item) || isLivingExpenseEstimate(item)); });
|
|
40
|
+
var livingExpenseEstimateExists = (0, lodash_1.get)(livingExpenseEstimate || {}, 'amount', 0) > 0;
|
|
41
|
+
var expenseBreakdownAmountSum = (0, lodash_1.sumBy)(expenseBreakdown, 'amount');
|
|
42
|
+
var lixiLivingExpenses = [];
|
|
43
|
+
// unless all individual expenses have a value of 0 and a living estimate exists, transform them without question.
|
|
44
|
+
if (expenseBreakdownAmountSum === 0 && livingExpenseEstimateExists) {
|
|
45
|
+
var estimate = transformExpense(livingExpenseEstimate, applicantId, 0, id);
|
|
46
|
+
lixiLivingExpenses = [estimate];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
lixiLivingExpenses = expenseBreakdown.map(function (expense, index) {
|
|
50
|
+
return transformExpense(expense, applicantId, index, id);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
|
|
54
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
55
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
|
|
56
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
57
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
58
|
+
if (lixiLivingExpenses.length > 0) {
|
|
59
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
60
|
+
}
|
|
61
|
+
return partialApplication;
|
|
62
|
+
}
|
|
63
|
+
exports.transformExpenses = transformExpenses;
|
|
64
|
+
/**
|
|
65
|
+
* transforms the living expense from the expense array on the event.
|
|
66
|
+
*
|
|
67
|
+
* @param expense: Array of expenses on the event.
|
|
68
|
+
* @param applicantId: Event applicantId.
|
|
69
|
+
* @param index: Index of the map.
|
|
70
|
+
* @param id: Id of the event.
|
|
71
|
+
*/
|
|
72
|
+
function transformExpense(expense, applicantId, index, id) {
|
|
73
|
+
return {
|
|
74
|
+
'@Amount': expense.amount,
|
|
75
|
+
'@Category': living_expense_1.livingExpenseMapping[expense.type],
|
|
76
|
+
'@Description': expense.type,
|
|
77
|
+
'@UniqueID': isOtherCommitment(expense) ? "".concat(id, "-commitment-").concat(index) : "".concat(id, "-living-expense-").concat(index),
|
|
78
|
+
'@Frequency': expense_frequency_1.frequencyMapping[expense.frequency],
|
|
79
|
+
PercentResponsible: {
|
|
80
|
+
Owner: [
|
|
81
|
+
{
|
|
82
|
+
'@Percent': 100,
|
|
83
|
+
'@x_Party': applicantId
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
exports.transformExpense = transformExpense;
|
|
90
|
+
/**
|
|
91
|
+
* @description Normalises expense by amount to 0 if not provided and scales quarterly spending up to yearly.
|
|
92
|
+
* @param {Expense} expense An expense
|
|
93
|
+
* @returns {Expense} An normalised expense.
|
|
94
|
+
*/
|
|
95
|
+
function normaliseExpenseAmount(expense) {
|
|
96
|
+
var _a = (0, lodash_1.pick)(expense, 'amount', 'frequency'), _b = _a.amount, amount = _b === void 0 ? 0 : _b, _c = _a.frequency, frequency = _c === void 0 ? public_expense_1.Frequency.Yearly : _c;
|
|
97
|
+
if (frequency === public_expense_1.Frequency.Quarterly) {
|
|
98
|
+
frequency = public_expense_1.Frequency.Yearly;
|
|
99
|
+
amount = amount * 4;
|
|
100
|
+
}
|
|
101
|
+
return __assign(__assign({}, expense), { amount: amount, frequency: frequency });
|
|
102
|
+
}
|
|
103
|
+
exports.normaliseExpenseAmount = normaliseExpenseAmount;
|
|
104
|
+
/**
|
|
105
|
+
* @description Verify if expense is an OtherCommitment.
|
|
106
|
+
* @param {Expense} expense Any Expense item.
|
|
107
|
+
* @returns {boolean} Returns true if an expense type is one of other commitment expenses.
|
|
108
|
+
*/
|
|
109
|
+
function isOtherCommitment(expense) {
|
|
110
|
+
return exports.otherCommitmentExpenseTypes.includes(expense.type);
|
|
111
|
+
}
|
|
112
|
+
exports.isOtherCommitment = isOtherCommitment;
|
|
113
|
+
/**
|
|
114
|
+
* @description Check if expense type is LivingExpenseEstimate.
|
|
115
|
+
* @param {Expense} expense An Expense item.
|
|
116
|
+
* @returns {boolean} Returns true if an expense type is LivingExpenseEstimate
|
|
117
|
+
*/
|
|
118
|
+
function isLivingExpenseEstimate(expense) {
|
|
119
|
+
return expense.type === public_expense_1.ExpenseType.LivingExpensesEstimate;
|
|
120
|
+
}
|
|
121
|
+
exports.isLivingExpenseEstimate = isLivingExpenseEstimate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { List as LIXIFrequency } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { RepaymentFrequency } from '../events/public-liability';
|
|
3
|
+
import { Frequency } from '../events/public-income';
|
|
4
|
+
export declare type LiabilityFrequencyMapping = {
|
|
5
|
+
[key in RepaymentFrequency]: LIXIFrequency;
|
|
6
|
+
};
|
|
7
|
+
export declare type IncomeExpenseFrequencyMapping = {
|
|
8
|
+
[key in RepaymentFrequency | Frequency]: LIXIFrequency;
|
|
9
|
+
};
|
|
10
|
+
export declare type RentalIncomeFrequencyMapping = {
|
|
11
|
+
[key in Frequency]: LIXIFrequency;
|
|
12
|
+
};
|
|
13
|
+
export declare const incomeExpenseFrequencyMapping: IncomeExpenseFrequencyMapping;
|
|
14
|
+
export declare const liabilityFrequencyMapping: LiabilityFrequencyMapping;
|
|
15
|
+
export declare const rentalIncomeFrequencyMapping: Partial<RentalIncomeFrequencyMapping>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b, _c;
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.rentalIncomeFrequencyMapping = exports.liabilityFrequencyMapping = exports.incomeExpenseFrequencyMapping = void 0;
|
|
5
|
+
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
6
|
+
var public_liability_1 = require("../events/public-liability");
|
|
7
|
+
var public_income_1 = require("../events/public-income");
|
|
8
|
+
exports.incomeExpenseFrequencyMapping = (_a = {},
|
|
9
|
+
_a[public_income_1.Frequency.Fortnightly] = lixi_internal_request_1.List.Fortnightly,
|
|
10
|
+
_a[public_income_1.Frequency.Monthly] = lixi_internal_request_1.List.Monthly,
|
|
11
|
+
_a[public_income_1.Frequency.Weekly] = lixi_internal_request_1.List.Weekly,
|
|
12
|
+
_a[public_income_1.Frequency.Quarterly] = lixi_internal_request_1.List.Yearly,
|
|
13
|
+
_a[public_income_1.Frequency.Yearly] = lixi_internal_request_1.List.Yearly,
|
|
14
|
+
_a);
|
|
15
|
+
exports.liabilityFrequencyMapping = (_b = {},
|
|
16
|
+
_b[public_liability_1.RepaymentFrequency.Yearly] = lixi_internal_request_1.List.Yearly,
|
|
17
|
+
_b[public_liability_1.RepaymentFrequency.Monthly] = lixi_internal_request_1.List.Monthly,
|
|
18
|
+
_b[public_liability_1.RepaymentFrequency.Fortnightly] = lixi_internal_request_1.List.Fortnightly,
|
|
19
|
+
_b[public_liability_1.RepaymentFrequency.Weekly] = lixi_internal_request_1.List.Weekly,
|
|
20
|
+
_b);
|
|
21
|
+
exports.rentalIncomeFrequencyMapping = (_c = {},
|
|
22
|
+
_c[public_income_1.Frequency.Fortnightly] = lixi_internal_request_1.List.Fortnightly,
|
|
23
|
+
_c[public_income_1.Frequency.Monthly] = lixi_internal_request_1.List.Monthly,
|
|
24
|
+
_c[public_income_1.Frequency.Weekly] = lixi_internal_request_1.List.Weekly,
|
|
25
|
+
_c[public_income_1.Frequency.Yearly] = lixi_internal_request_1.List.Yearly,
|
|
26
|
+
_c);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Countries } from '../events/public-applicant';
|
|
2
|
+
import { CountryCodeList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
3
|
+
declare type CountryCodeMapping = {
|
|
4
|
+
[key in Countries]: CountryCodeList;
|
|
5
|
+
};
|
|
6
|
+
export declare const countryCodeMapping: Partial<CountryCodeMapping>;
|
|
7
|
+
export {};
|