@lendi/integrations-transform 1.5.6 → 1.5.9
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.js +10 -22
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +2 -5
- package/lib/schemas/application-workflow-event.json +1 -30
- package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
- package/lib/transform-events/generate-asset-liability-link.js +14 -18
- package/lib/transform-events/generate-credit-report-rebuilt.js +17 -21
- package/lib/transform-events/generate-employment.d.ts +1 -1
- package/lib/transform-events/generate-employment.js +51 -56
- package/lib/transform-events/generate-required-document.d.ts +1 -7
- package/lib/transform-events/generate-required-document.js +43 -69
- package/lib/transform-events/transform-applicant.d.ts +2 -1
- package/lib/transform-events/transform-applicant.js +78 -91
- package/lib/transform-events/transform-application-workflow.d.ts +0 -1
- package/lib/transform-events/transform-application-workflow.js +9 -14
- package/lib/transform-events/transform-application.d.ts +3 -1
- package/lib/transform-events/transform-application.js +28 -33
- package/lib/transform-events/transform-asset-address.d.ts +8 -2
- package/lib/transform-events/transform-asset-address.js +35 -37
- package/lib/transform-events/transform-asset.d.ts +7 -1
- package/lib/transform-events/transform-asset.js +164 -183
- package/lib/transform-events/transform-expenses.d.ts +4 -0
- package/lib/transform-events/transform-expenses.js +52 -58
- package/lib/transform-events/transform-funding-position.d.ts +2 -2
- package/lib/transform-events/transform-funding-position.js +38 -46
- package/lib/transform-events/transform-income.d.ts +8 -1
- package/lib/transform-events/transform-income.js +121 -139
- package/lib/transform-events/transform-liability.d.ts +4 -1
- package/lib/transform-events/transform-liability.js +62 -66
- package/lib/transform-events/transform-percent-owned.d.ts +2 -1
- package/lib/transform-events/transform-percent-owned.js +7 -14
- package/lib/types/enum-mappings/alieo-frequency.js +22 -26
- package/lib/types/enum-mappings/asset-type.js +14 -18
- package/lib/types/enum-mappings/builder-type.js +6 -10
- package/lib/types/enum-mappings/construction-type.js +7 -11
- package/lib/types/enum-mappings/country-code.js +243 -247
- package/lib/types/enum-mappings/employment-basis.js +9 -13
- package/lib/types/enum-mappings/expense-frequency.js +8 -12
- package/lib/types/enum-mappings/funding-position.js +29 -32
- package/lib/types/enum-mappings/government-benefits.js +7 -11
- package/lib/types/enum-mappings/housing-status.js +12 -16
- package/lib/types/enum-mappings/income-type.js +13 -17
- package/lib/types/enum-mappings/index.js +27 -39
- package/lib/types/enum-mappings/liability-payment-type.js +6 -10
- package/lib/types/enum-mappings/liability-type.js +18 -22
- package/lib/types/enum-mappings/living-expense.js +27 -31
- package/lib/types/enum-mappings/marital-status.js +9 -13
- package/lib/types/enum-mappings/postcode.js +11 -15
- package/lib/types/enum-mappings/preferred-repayment.js +7 -11
- package/lib/types/enum-mappings/proof-of-identity.js +7 -11
- package/lib/types/enum-mappings/property-expense-category.js +8 -12
- package/lib/types/enum-mappings/public-financial-asset.js +9 -13
- package/lib/types/enum-mappings/public-primary-purpose.js +6 -10
- package/lib/types/enum-mappings/public-property-status.js +8 -12
- package/lib/types/enum-mappings/public-property-type.js +20 -24
- package/lib/types/enum-mappings/residency-status.js +8 -12
- package/lib/types/enum-mappings/title-gender.js +10 -14
- package/lib/types/enum-mappings/title.js +10 -14
- package/lib/types/enum-mappings/to-be-purchased.js +4 -7
- package/lib/types/enum-mappings/to-be-used-as-security.js +4 -7
- package/lib/types/enum-mappings/transaction-type.js +6 -10
- package/lib/types/enum-mappings/verification.js +10 -14
- package/lib/types/events/applicant-delete.js +4 -7
- package/lib/types/events/application-workflow.d.ts +1 -33
- package/lib/types/events/application-workflow.js +10 -46
- package/lib/types/events/asset-delete.js +4 -7
- package/lib/types/events/asset-liability-relation-delete.js +4 -7
- package/lib/types/events/credit-report-retrieved.js +4 -7
- package/lib/types/events/employment-delete.js +2 -5
- package/lib/types/events/expense-delete.js +2 -5
- package/lib/types/events/funding-position.js +6 -9
- package/lib/types/events/income-delete.js +4 -7
- package/lib/types/events/liability-delete.js +2 -5
- package/lib/types/events/opportunity.js +6 -9
- package/lib/types/events/public-applicant.js +28 -31
- package/lib/types/events/public-application.js +26 -29
- package/lib/types/events/public-asset-liability-relation.js +4 -7
- package/lib/types/events/public-asset.js +26 -29
- package/lib/types/events/public-employment.js +18 -21
- package/lib/types/events/public-expense.js +8 -11
- package/lib/types/events/public-funding-position.js +2 -5
- package/lib/types/events/public-income.js +12 -15
- package/lib/types/events/public-liability.js +16 -19
- package/lib/types/events/public-required-document.js +14 -17
- package/lib/types/partial-application.js +1 -2
- package/lib/types/recursive-partial.js +1 -2
- package/lib/update-application/merge-application.d.ts +1 -1
- package/lib/update-application/merge-application.js +41 -38
- package/lib/update-application/update-primary-applicant.d.ts +1 -4
- package/lib/update-application/update-primary-applicant.js +14 -38
- package/lib/utils/address-tools.d.ts +3 -1
- package/lib/utils/address-tools.js +56 -68
- package/lib/utils/clean-up.d.ts +1 -1
- package/lib/utils/clean-up.js +6 -10
- package/lib/utils/formatYesNo.d.ts +0 -1
- package/lib/utils/formatYesNo.js +2 -7
- package/lib/utils/generate-address.d.ts +3 -2
- package/lib/utils/generate-address.js +33 -42
- package/lib/utils/get-financial-institution.d.ts +1 -0
- package/lib/utils/get-financial-institution.js +7 -10
- package/lib/utils/is-asset-type.js +13 -20
- package/lib/utils/is-income-type.d.ts +2 -0
- package/lib/utils/is-income-type.js +50 -69
- package/lib/utils/iso-date.d.ts +0 -1
- package/lib/utils/iso-date.js +2 -7
- package/lib/utils/normalise-date.js +6 -10
- package/lib/utils/round-decimal.js +1 -5
- package/package.json +14 -17
|
@@ -1,106 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return (input === true ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
|
|
14
|
-
};
|
|
15
|
-
exports.booleanMapping = booleanMapping;
|
|
16
|
-
var applicantMapping = {
|
|
17
|
-
applicationId: application_paths_1.paths.ApplicationId,
|
|
18
|
-
citizenship: "".concat(application_paths_1.paths.PersonApplicant, ".@Citizenship"),
|
|
19
|
-
contact: "".concat(application_paths_1.paths.PersonApplicant, ".Contact"),
|
|
1
|
+
import { CountryCodeList, YesNoList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
|
|
3
|
+
import { get, omit, set } from 'lodash';
|
|
4
|
+
import { rebuildAddress } from '../utils/address-tools';
|
|
5
|
+
import { countryCodeMapping, maritalStatusMapping, residencyStatusMapping, titleMapping } from '../types/enum-mappings';
|
|
6
|
+
import { ResidencyStatus, Title, } from '../types/events/public-applicant';
|
|
7
|
+
import { normaliseDate } from '../utils/normalise-date';
|
|
8
|
+
export const booleanMapping = (input = false) => (input === true ? YesNoList.Yes : YesNoList.No);
|
|
9
|
+
const applicantMapping = {
|
|
10
|
+
applicationId: paths.ApplicationId,
|
|
11
|
+
citizenship: `${paths.PersonApplicant}.@Citizenship`,
|
|
12
|
+
contact: `${paths.PersonApplicant}.Contact`,
|
|
20
13
|
dependants: 'dependants',
|
|
21
|
-
dateOfBirth:
|
|
22
|
-
firstName:
|
|
23
|
-
id:
|
|
24
|
-
isFirstHomeBuyer:
|
|
25
|
-
isPrimaryApplicant:
|
|
26
|
-
lastName:
|
|
27
|
-
maritalStatus:
|
|
28
|
-
maritalDetails:
|
|
29
|
-
middleName:
|
|
30
|
-
residencyStatus:
|
|
31
|
-
title:
|
|
14
|
+
dateOfBirth: `${paths.PersonApplicant}.@DateOfBirth`,
|
|
15
|
+
firstName: `${paths.PersonApplicant}.PersonName.@FirstName`,
|
|
16
|
+
id: `${paths.PersonApplicant}.@UniqueID`,
|
|
17
|
+
isFirstHomeBuyer: `${paths.PersonApplicant}.@FirstHomeBuyer`,
|
|
18
|
+
isPrimaryApplicant: `${paths.PersonApplicant}.@PrimaryApplicant`,
|
|
19
|
+
lastName: `${paths.PersonApplicant}.PersonName.@Surname`,
|
|
20
|
+
maritalStatus: `${paths.PersonApplicant}.@MaritalStatus`,
|
|
21
|
+
maritalDetails: `${paths.PersonApplicant}.MaritalStatusDetails.@x_Spouse`,
|
|
22
|
+
middleName: `${paths.PersonApplicant}.PersonName.@MiddleNames`,
|
|
23
|
+
residencyStatus: `${paths.PersonApplicant}.@ResidencyStatus`,
|
|
24
|
+
title: `${paths.PersonName}.@NameTitle`,
|
|
32
25
|
};
|
|
33
26
|
/**
|
|
34
27
|
* Transforms a partial Applicant event to a partial LIXI application.
|
|
35
28
|
*
|
|
36
29
|
* @param applicant: A partial applicant.
|
|
37
|
-
* @
|
|
30
|
+
* @param applicant
|
|
31
|
+
* @returns partialApplication an incomplete application.
|
|
38
32
|
*/
|
|
39
|
-
function transformApplicant(applicant) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
for (
|
|
47
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
33
|
+
export function transformApplicant(applicant) {
|
|
34
|
+
const partialApplication = {};
|
|
35
|
+
const { id: applicantId, applicationId } = applicant;
|
|
36
|
+
set(partialApplication, applicantMapping['isFirstHomeBuyer'], booleanMapping(applicant.isFirstHomeBuyer));
|
|
37
|
+
set(partialApplication, applicantMapping['isPrimaryApplicant'], booleanMapping(applicant.isPrimaryApplicant));
|
|
38
|
+
set(partialApplication, applicantMapping['title'], titleMapping[applicant.title || Title.Unknown]);
|
|
39
|
+
const applicantUpdated = omit(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
|
|
40
|
+
for (const [key, value] of Object.entries(applicantUpdated)) {
|
|
48
41
|
if (applicantMapping[key]) {
|
|
49
42
|
switch (key) {
|
|
50
43
|
case 'dateOfBirth':
|
|
51
|
-
|
|
44
|
+
set(partialApplication, applicantMapping[key], normaliseDate(value));
|
|
52
45
|
break;
|
|
53
46
|
case 'maritalStatus':
|
|
54
|
-
|
|
47
|
+
set(partialApplication, applicantMapping[key], maritalStatusMapping[value]);
|
|
55
48
|
break;
|
|
56
49
|
case 'citizenship':
|
|
57
|
-
|
|
50
|
+
set(partialApplication, applicantMapping[key], countryCodeMapping[value]);
|
|
58
51
|
break;
|
|
59
52
|
case 'residencyStatus':
|
|
60
|
-
|
|
53
|
+
set(partialApplication, applicantMapping[key], residencyStatusMapping[value]);
|
|
61
54
|
// Certain bank integrations require the ability to differentiate between permanentResident and Citizen
|
|
62
55
|
// As lixi does not have a citizen enum for residencyStatus citizen is mapped to permanentResident
|
|
63
56
|
// Adding a @Citizenship attribute to person applicant gives us the ability to determine citizenship status
|
|
64
57
|
// If citizen this field will be always added and value will be AU.
|
|
65
58
|
// @tsilva 21/11/19
|
|
66
|
-
if (value ===
|
|
67
|
-
|
|
59
|
+
if (value === ResidencyStatus.AustralianCitizen) {
|
|
60
|
+
set(partialApplication, applicantMapping.citizenship, CountryCodeList.Au);
|
|
68
61
|
}
|
|
69
62
|
break;
|
|
70
63
|
case 'maritalDetails':
|
|
71
|
-
|
|
64
|
+
const id = get(value, 'applicantId');
|
|
72
65
|
if (id)
|
|
73
|
-
|
|
66
|
+
set(partialApplication, applicantMapping[key], id);
|
|
74
67
|
break;
|
|
75
68
|
case 'contact':
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
const { lixiContact, lixiAddresses } = generateContact(value, applicantId);
|
|
70
|
+
set(partialApplication, applicantMapping[key], lixiContact);
|
|
78
71
|
if (lixiAddresses.length > 0) {
|
|
79
|
-
|
|
72
|
+
set(partialApplication, paths.Addresses, lixiAddresses);
|
|
80
73
|
}
|
|
81
74
|
break;
|
|
82
75
|
case 'dependants':
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
const dependants = generateDependants(value, applicantId);
|
|
77
|
+
set(partialApplication, `${paths.Household}.@UniqueID`, `${applicationId}-household`);
|
|
78
|
+
set(partialApplication, `${paths.Household}.Dependant`, dependants);
|
|
86
79
|
break;
|
|
87
80
|
default:
|
|
88
|
-
|
|
81
|
+
set(partialApplication, applicantMapping[key], value);
|
|
89
82
|
break;
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
86
|
return partialApplication;
|
|
94
87
|
}
|
|
95
|
-
|
|
96
|
-
var contactMapping = {
|
|
88
|
+
const contactMapping = {
|
|
97
89
|
emailAddress: 'EmailAddress.0.@Email',
|
|
98
90
|
mobileNumber: 'Mobile.@Number',
|
|
99
91
|
currentAddress: 'CurrentAddress',
|
|
100
92
|
previousAddresses: 'PreviousAddress',
|
|
101
93
|
priorAddress: 'PriorAddress',
|
|
102
94
|
mailingAddress: 'CurrentAddress.@x_MailingAddress',
|
|
103
|
-
postSettlementAddress: 'PostSettlementAddress'
|
|
95
|
+
postSettlementAddress: 'PostSettlementAddress',
|
|
104
96
|
};
|
|
105
97
|
/**
|
|
106
98
|
* Generates a LIXI contact from given contact.
|
|
@@ -108,79 +100,74 @@ var contactMapping = {
|
|
|
108
100
|
* @param contact
|
|
109
101
|
* @param id
|
|
110
102
|
*/
|
|
111
|
-
function generateContact(contact, id) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
for (
|
|
115
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
103
|
+
export function generateContact(contact, id) {
|
|
104
|
+
const lixiContact = {};
|
|
105
|
+
const lixiAddresses = [];
|
|
106
|
+
for (const [key, value] of Object.entries(contact)) {
|
|
116
107
|
if (contactMapping[key]) {
|
|
117
108
|
switch (key) {
|
|
118
109
|
case 'currentAddress':
|
|
119
110
|
{
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
const addressId = `${id}-current`;
|
|
112
|
+
const { lixiAddress, lixiContactAddress } = rebuildAddress(value, addressId);
|
|
122
113
|
lixiAddresses.push(lixiAddress);
|
|
123
|
-
|
|
114
|
+
set(lixiContact, contactMapping[key], lixiContactAddress);
|
|
124
115
|
}
|
|
125
116
|
break;
|
|
126
117
|
case 'postSettlementAddress':
|
|
127
118
|
{
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
const addressId = `${id}-postSettlement`;
|
|
120
|
+
const { lixiAddress, lixiContactAddress } = rebuildAddress({ residentialAddress: value }, addressId);
|
|
130
121
|
lixiAddresses.push(lixiAddress);
|
|
131
|
-
|
|
122
|
+
set(lixiContact, contactMapping[key], lixiContactAddress);
|
|
132
123
|
}
|
|
133
124
|
break;
|
|
134
125
|
case 'mailingAddress':
|
|
135
126
|
{
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
const addressId = `${id}-mailing`;
|
|
128
|
+
const { lixiAddress } = rebuildAddress({ residentialAddress: value }, addressId);
|
|
138
129
|
lixiAddresses.push(lixiAddress);
|
|
139
|
-
|
|
130
|
+
set(lixiContact, contactMapping[key], addressId);
|
|
140
131
|
}
|
|
141
132
|
break;
|
|
142
133
|
case 'previousAddresses':
|
|
143
134
|
{
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
var previousAddress = previousAddresses.pop();
|
|
149
|
-
var _e = (0, address_tools_1.rebuildAddress)(previousAddress, addressId), lixiAddress = _e.lixiAddress, lixiContactAddress = _e.lixiContactAddress;
|
|
135
|
+
const addressId = `${id}-previous`;
|
|
136
|
+
const previousAddresses = value.sort((lhs, rhs) => lhs.endDate.localeCompare(rhs.endDate));
|
|
137
|
+
const previousAddress = previousAddresses.pop();
|
|
138
|
+
const { lixiAddress, lixiContactAddress } = rebuildAddress(previousAddress, addressId);
|
|
150
139
|
lixiAddresses.push(lixiAddress);
|
|
151
|
-
|
|
140
|
+
set(lixiContact, contactMapping[key], lixiContactAddress);
|
|
152
141
|
// PriorAddresses
|
|
153
|
-
previousAddresses.forEach(
|
|
154
|
-
|
|
142
|
+
previousAddresses.forEach((address, index) => {
|
|
143
|
+
const { lixiAddress, lixiContactAddress } = rebuildAddress(address, `${id}-prior-${index}`);
|
|
155
144
|
lixiAddresses.push(lixiAddress);
|
|
156
|
-
|
|
145
|
+
set(lixiContact, `${contactMapping['priorAddress']}.${index}`, lixiContactAddress);
|
|
157
146
|
});
|
|
158
147
|
}
|
|
159
148
|
break;
|
|
160
149
|
default:
|
|
161
|
-
|
|
150
|
+
set(lixiContact, contactMapping[key], value);
|
|
162
151
|
break;
|
|
163
152
|
}
|
|
164
153
|
}
|
|
165
154
|
}
|
|
166
|
-
return { lixiContact
|
|
155
|
+
return { lixiContact, lixiAddresses };
|
|
167
156
|
}
|
|
168
|
-
exports.generateContact = generateContact;
|
|
169
157
|
/**
|
|
170
158
|
* Generate dependants
|
|
171
159
|
*
|
|
172
160
|
* @param dependants
|
|
173
161
|
* @param id
|
|
174
162
|
*/
|
|
175
|
-
function generateDependants(dependants, id) {
|
|
176
|
-
return dependants.map(
|
|
163
|
+
export function generateDependants(dependants, id) {
|
|
164
|
+
return dependants.map((dependant) => ({
|
|
177
165
|
'@Age': dependant.age,
|
|
178
166
|
'@UniqueID': dependant.id,
|
|
179
167
|
FinancialProvider: [
|
|
180
168
|
{
|
|
181
|
-
'@x_Party': id
|
|
169
|
+
'@x_Party': id,
|
|
182
170
|
},
|
|
183
|
-
]
|
|
184
|
-
})
|
|
171
|
+
],
|
|
172
|
+
}));
|
|
185
173
|
}
|
|
186
|
-
exports.generateDependants = generateDependants;
|
|
@@ -3,7 +3,6 @@ import { PayloadClass as ApplicationWorkflowEventPayload } from '../types/events
|
|
|
3
3
|
* Generates a partial application from an ApplicationWorkflow event
|
|
4
4
|
*
|
|
5
5
|
* @param applicationWorkflowEventPayload ApplicationWorkflow event payload
|
|
6
|
-
*
|
|
7
6
|
* @returns A partial application
|
|
8
7
|
*/
|
|
9
8
|
export declare function transformApplicationWorkflow(applicationWorkflowEventPayload: ApplicationWorkflowEventPayload): {};
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.transformApplicationWorkflow = void 0;
|
|
4
|
-
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
-
var lodash_1 = require("lodash");
|
|
1
|
+
import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
|
|
2
|
+
import { set } from 'lodash';
|
|
6
3
|
/**
|
|
7
4
|
* Generates a partial application from an ApplicationWorkflow event
|
|
8
5
|
*
|
|
9
6
|
* @param applicationWorkflowEventPayload ApplicationWorkflow event payload
|
|
10
|
-
*
|
|
11
7
|
* @returns A partial application
|
|
12
8
|
*/
|
|
13
|
-
function transformApplicationWorkflow(applicationWorkflowEventPayload) {
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export function transformApplicationWorkflow(applicationWorkflowEventPayload) {
|
|
10
|
+
const { stage, applicationStage, applicationId } = applicationWorkflowEventPayload, partialApplication = {};
|
|
11
|
+
set(partialApplication, paths.ApplicationId, applicationId);
|
|
16
12
|
// The stage being defaulted to Unknown caters for LGSF application workflow events having stage as an optional attribute in the future
|
|
17
|
-
|
|
18
|
-
'@UniqueID':
|
|
19
|
-
'@Details': applicationStage || stage || 'Unknown'
|
|
13
|
+
const instructionDetails = {
|
|
14
|
+
'@UniqueID': `${applicationId}-stage`,
|
|
15
|
+
'@Details': applicationStage || stage || 'Unknown',
|
|
20
16
|
};
|
|
21
|
-
|
|
17
|
+
set(partialApplication, paths.Instructions, instructionDetails);
|
|
22
18
|
return partialApplication;
|
|
23
19
|
}
|
|
24
|
-
exports.transformApplicationWorkflow = transformApplicationWorkflow;
|
|
@@ -8,7 +8,9 @@ interface transformApplicationOptions {
|
|
|
8
8
|
*
|
|
9
9
|
* @param opportunity: Partial opportunity event.
|
|
10
10
|
* @param uniqueIdSuffix: Suffix for uniquerId
|
|
11
|
-
* @
|
|
11
|
+
* @param opportunity
|
|
12
|
+
* @param options
|
|
13
|
+
* @returns partialApplication: A partial internal request.
|
|
12
14
|
*/
|
|
13
15
|
export declare function transformApplication(opportunity: ApplicationPayload, options?: transformApplicationOptions): {};
|
|
14
16
|
export {};
|
|
@@ -1,61 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var lodash_1 = require("lodash");
|
|
8
|
-
var enum_mappings_1 = require("../types/enum-mappings/");
|
|
9
|
-
var transform_applicant_1 = require("./transform-applicant");
|
|
1
|
+
import { EventNameApplicationInstructionsList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
import { paths as creditProtocolPaths } from '@lendi/integrations-credit-protocol/utils/application-paths';
|
|
3
|
+
import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
|
|
4
|
+
import { set } from 'lodash';
|
|
5
|
+
import { preferredRepaymentMapping, transactionTypeMapping } from '../types/enum-mappings/';
|
|
6
|
+
import { booleanMapping } from './transform-applicant';
|
|
10
7
|
/**
|
|
11
8
|
* Transforms a partial opportunity event to a partial internal request.
|
|
12
9
|
*
|
|
13
10
|
* @param opportunity: Partial opportunity event.
|
|
14
11
|
* @param uniqueIdSuffix: Suffix for uniquerId
|
|
15
|
-
* @
|
|
12
|
+
* @param opportunity
|
|
13
|
+
* @param options
|
|
14
|
+
* @returns partialApplication: A partial internal request.
|
|
16
15
|
*/
|
|
17
|
-
function transformApplication(opportunity, options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
paymentType: "".concat(application_paths_2.paths.LoanTerm, ".@PaymentType"),
|
|
16
|
+
export function transformApplication(opportunity, options = {}) {
|
|
17
|
+
const { uniqueIdSuffix = 'loanDetails', enableRateLock = false } = options;
|
|
18
|
+
const partialApplication = {};
|
|
19
|
+
const opportunityMapping = {
|
|
20
|
+
brand: paths.BusinessName,
|
|
21
|
+
id: paths.ApplicationId,
|
|
22
|
+
paymentType: `${paths.LoanTerm}.@PaymentType`,
|
|
25
23
|
preliminary: 'preliminary',
|
|
26
|
-
primaryPurpose:
|
|
27
|
-
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
|
|
24
|
+
primaryPurpose: paths.PurposeOfApplication,
|
|
25
|
+
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description',
|
|
28
26
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
set(partialApplication, `${paths.LoanDetail}.@UniqueID`, `${opportunity.id}-${uniqueIdSuffix}`);
|
|
28
|
+
set(partialApplication, `${creditProtocolPaths.Instructions}.@UniqueID`, `${opportunity.id}-stage`);
|
|
29
|
+
set(partialApplication, `${creditProtocolPaths.Instructions}.@Name`, EventNameApplicationInstructionsList.ApplicationReceived);
|
|
32
30
|
if (enableRateLock) {
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const { hasOptedInRateLock = false } = opportunity;
|
|
32
|
+
set(partialApplication, `${creditProtocolPaths.FeaturesSelected}.@RateLock`, booleanMapping(hasOptedInRateLock));
|
|
35
33
|
}
|
|
36
|
-
for (
|
|
37
|
-
var _e = _d[_i], opportunityKey = _e[0], opportunityValue = _e[1];
|
|
34
|
+
for (const [opportunityKey, opportunityValue] of Object.entries(opportunity)) {
|
|
38
35
|
if (opportunityMapping[opportunityKey]) {
|
|
39
36
|
if (opportunityKey === 'preliminary') {
|
|
40
|
-
for (
|
|
41
|
-
var _h = _g[_f], key = _h[0], value = _h[1];
|
|
37
|
+
for (const [key, value] of Object.entries(opportunityValue)) {
|
|
42
38
|
if (opportunityMapping[key]) {
|
|
43
39
|
switch (key) {
|
|
44
40
|
case 'paymentType':
|
|
45
|
-
|
|
41
|
+
set(partialApplication, opportunityMapping[key], preferredRepaymentMapping[value]);
|
|
46
42
|
break;
|
|
47
43
|
case 'primaryPurpose':
|
|
48
|
-
|
|
44
|
+
set(partialApplication, opportunityMapping[key], transactionTypeMapping[value]);
|
|
49
45
|
break;
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
else {
|
|
55
|
-
|
|
51
|
+
set(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
55
|
return partialApplication;
|
|
60
56
|
}
|
|
61
|
-
exports.transformApplication = transformApplication;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { AddressType, Standard } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
2
|
import { Address, AddressStandard } from '../types/events/public-asset';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param address
|
|
6
|
+
*/
|
|
3
7
|
export declare function getAddressMapping(address: Address): Record<string, string>;
|
|
4
8
|
export declare const standardMapping: Record<string, string>;
|
|
5
9
|
/**
|
|
@@ -8,12 +12,14 @@ export declare const standardMapping: Record<string, string>;
|
|
|
8
12
|
* @param address: An address object.
|
|
9
13
|
* @param id: address event id.
|
|
10
14
|
* @param toBeUsedAsSecurity
|
|
11
|
-
* @
|
|
15
|
+
* @param address
|
|
16
|
+
* @param id
|
|
17
|
+
* @returns A transformed address object.
|
|
12
18
|
*/
|
|
13
19
|
export declare function transformAddress(address: Address, id: string): Partial<AddressType>;
|
|
14
20
|
/**
|
|
15
21
|
* @description Generates an address standard.
|
|
16
22
|
* @param {AddressStandard} addressStandard An address standard object.
|
|
17
|
-
* @
|
|
23
|
+
* @returns {Partial<Standard>} A transformed standard object.
|
|
18
24
|
*/
|
|
19
25
|
export declare function transformStandard(addressStandard: AddressStandard): Partial<Standard>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { CountryCodeList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { set } from 'lodash';
|
|
3
|
+
import { countryCodeMapping, postcodeMapping } from '../types/enum-mappings';
|
|
4
|
+
import { extractCountryFromFormatted, isOverseasAddress } from '../utils/address-tools';
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param address
|
|
8
|
+
*/
|
|
9
|
+
export function getAddressMapping(address) {
|
|
9
10
|
return {
|
|
10
11
|
city: '@Suburb',
|
|
11
12
|
country: '@Country',
|
|
12
|
-
postcode:
|
|
13
|
-
state:
|
|
13
|
+
postcode: isOverseasAddress(address) ? '@OverseasPostCode' : '@AustralianPostCode',
|
|
14
|
+
state: isOverseasAddress(address) ? '@OverseasState' : '@AustralianState',
|
|
14
15
|
standard: 'Standard',
|
|
15
|
-
formatted: '@Country'
|
|
16
|
+
formatted: '@Country',
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
exports.standardMapping = {
|
|
19
|
+
export const standardMapping = {
|
|
20
20
|
streetName: '@StreetName',
|
|
21
21
|
streetType: '@StreetType',
|
|
22
22
|
streetNumber: '@StreetNumber',
|
|
23
23
|
level: '@Level',
|
|
24
|
-
unit: '@Unit'
|
|
24
|
+
unit: '@Unit',
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
27
|
* Generates an address for an asset.
|
|
@@ -29,55 +29,53 @@ exports.standardMapping = {
|
|
|
29
29
|
* @param address: An address object.
|
|
30
30
|
* @param id: address event id.
|
|
31
31
|
* @param toBeUsedAsSecurity
|
|
32
|
-
* @
|
|
32
|
+
* @param address
|
|
33
|
+
* @param id
|
|
34
|
+
* @returns A transformed address object.
|
|
33
35
|
*/
|
|
34
|
-
function transformAddress(address, id) {
|
|
35
|
-
|
|
36
|
-
'@UniqueID': id
|
|
36
|
+
export function transformAddress(address, id) {
|
|
37
|
+
const transformedAddress = {
|
|
38
|
+
'@UniqueID': id,
|
|
37
39
|
};
|
|
38
|
-
|
|
40
|
+
const addressMapping = getAddressMapping(address);
|
|
39
41
|
// for an Australian address: if no postcode is provided, infer one from the state:
|
|
40
|
-
if (!
|
|
41
|
-
address.postcode =
|
|
42
|
+
if (!isOverseasAddress(address) && address.state && !address.postcode) {
|
|
43
|
+
address.postcode = postcodeMapping[address.state];
|
|
42
44
|
}
|
|
43
|
-
for (
|
|
44
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
45
|
+
for (const [key, value] of Object.entries(address)) {
|
|
45
46
|
if (addressMapping[key]) {
|
|
46
47
|
switch (key) {
|
|
47
48
|
case 'standard':
|
|
48
|
-
|
|
49
|
+
set(transformedAddress, addressMapping[key], transformStandard(value));
|
|
49
50
|
break;
|
|
50
51
|
case 'country':
|
|
51
|
-
|
|
52
|
+
set(transformedAddress, addressMapping[key], isOverseasAddress(address) ? countryCodeMapping[value] : CountryCodeList.Au);
|
|
52
53
|
break;
|
|
53
54
|
case 'formatted':
|
|
54
55
|
if (!address.country) {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const country = extractCountryFromFormatted(value);
|
|
57
|
+
set(transformedAddress, addressMapping[key], countryCodeMapping[country]);
|
|
57
58
|
}
|
|
58
59
|
break;
|
|
59
60
|
default:
|
|
60
|
-
|
|
61
|
+
set(transformedAddress, addressMapping[key], value);
|
|
61
62
|
break;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
return transformedAddress;
|
|
66
67
|
}
|
|
67
|
-
exports.transformAddress = transformAddress;
|
|
68
68
|
/**
|
|
69
69
|
* @description Generates an address standard.
|
|
70
70
|
* @param {AddressStandard} addressStandard An address standard object.
|
|
71
|
-
* @
|
|
71
|
+
* @returns {Partial<Standard>} A transformed standard object.
|
|
72
72
|
*/
|
|
73
|
-
function transformStandard(addressStandard) {
|
|
74
|
-
|
|
75
|
-
for (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(0, lodash_1.set)(transformedStandard, exports.standardMapping[key], value);
|
|
73
|
+
export function transformStandard(addressStandard) {
|
|
74
|
+
const transformedStandard = {};
|
|
75
|
+
for (const [key, value] of Object.entries(addressStandard)) {
|
|
76
|
+
if (standardMapping[key]) {
|
|
77
|
+
set(transformedStandard, standardMapping[key], value);
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
return transformedStandard;
|
|
82
81
|
}
|
|
83
|
-
exports.transformStandard = transformStandard;
|
|
@@ -12,7 +12,7 @@ export declare const residentialTypeList: string[];
|
|
|
12
12
|
* Generates a partial internal request from a partial public asset event.
|
|
13
13
|
*
|
|
14
14
|
* @param {Payload} asset - A partial public asset.
|
|
15
|
-
* @
|
|
15
|
+
* @returns {PartialApplication} A partial InternalRequest.
|
|
16
16
|
*/
|
|
17
17
|
export declare function transformAsset({ asset, applicationId, id }: Payload): PartialApplication;
|
|
18
18
|
/**
|
|
@@ -33,20 +33,26 @@ export declare function getAssetMapping(asset: Asset): Record<string, string>;
|
|
|
33
33
|
* @param percentOwned: owners of the property
|
|
34
34
|
* @param assetId: Asset id
|
|
35
35
|
* @param propertyExpenses: propertyExpenses items
|
|
36
|
+
* @param percentOwned
|
|
37
|
+
* @param assetId
|
|
38
|
+
* @param propertyExpenses
|
|
36
39
|
*/
|
|
37
40
|
export declare function generateLivingExpenses(percentOwned: PercentOwned, assetId: string, propertyExpenses: PropertyExpense[]): LivingExpense[];
|
|
38
41
|
/**
|
|
39
42
|
* Creates PropertyExpense array on RealEstateAsset from the same array on the event.
|
|
43
|
+
*
|
|
40
44
|
* @param propertyExpenses
|
|
41
45
|
*/
|
|
42
46
|
export declare function generatePropertyExpenses(propertyExpenses: PropertyExpense[]): LIXIPropertyExpense[];
|
|
43
47
|
/**
|
|
44
48
|
* Determines the occupancy based on the list of property expense types available.
|
|
49
|
+
*
|
|
45
50
|
* @param propertyExpenses
|
|
46
51
|
*/
|
|
47
52
|
export declare function determineOccupancy(propertyExpenses: PropertyExpense[]): OccupancyList;
|
|
48
53
|
/**
|
|
49
54
|
* Calculates the correct amount and frequency.
|
|
55
|
+
*
|
|
50
56
|
* @param expense
|
|
51
57
|
*/
|
|
52
58
|
export declare function normalizeAmounts(expense: PropertyExpense): PropertyExpense;
|