@lendi/integrations-transform 1.0.9-alpha.0 → 1.1.3
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/schemas/public-income-event.json +99 -1
- package/lib/transform-events/generate-asset-liability-link.js +2 -2
- package/lib/transform-events/generate-asset.js +32 -32
- package/lib/transform-events/generate-credit-report-rebuilt.js +1 -1
- package/lib/transform-events/generate-employment.js +17 -17
- package/lib/transform-events/generate-funding-position.js +6 -6
- package/lib/transform-events/generate-income.d.ts +20 -32
- package/lib/transform-events/generate-income.js +135 -146
- package/lib/transform-events/generate-liability.js +13 -13
- package/lib/transform-events/generate-lixi-percentowned.d.ts +3 -6
- package/lib/transform-events/generate-lixi-percentowned.js +1 -0
- package/lib/transform-events/generate-opportunity.js +2 -2
- package/lib/transform-events/generate-required-document.js +7 -7
- package/lib/transform-events/transform-applicant.js +21 -21
- package/lib/transform-events/transform-application.js +4 -4
- package/lib/transform-events/transform-expenses.js +7 -4
- package/lib/types/enum-mappings/alieo-frequency.d.ts +6 -3
- package/lib/types/enum-mappings/alieo-frequency.js +8 -2
- 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/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/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/public-income.d.ts +37 -3
- package/lib/types/events/public-income.js +2 -0
- package/lib/utils/is-income-type.d.ts +70 -0
- package/lib/utils/is-income-type.js +141 -0
- package/lib/utils/normalise-date.js +1 -1
- package/package.json +4 -7
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var _a;
|
|
3
14
|
exports.__esModule = true;
|
|
4
|
-
exports.
|
|
5
|
-
var
|
|
15
|
+
exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
|
|
16
|
+
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
17
|
+
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
6
18
|
var lodash_1 = require("lodash");
|
|
7
|
-
var
|
|
19
|
+
var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
20
|
+
var government_benefits_1 = require("../types/enum-mappings/government-benefits");
|
|
21
|
+
var income_type_1 = require("../types/enum-mappings/income-type");
|
|
8
22
|
var public_income_1 = require("../types/events/public-income");
|
|
23
|
+
var is_income_type_1 = require("../utils/is-income-type");
|
|
9
24
|
var round_decimal_1 = require("../utils/round-decimal");
|
|
10
|
-
var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
11
25
|
var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
|
|
12
|
-
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
13
|
-
var income_type_1 = require("../types/enum-mappings/income-type");
|
|
14
|
-
var government_benefits_1 = require("../types/enum-mappings/government-benefits");
|
|
15
|
-
var PAYGList = [
|
|
16
|
-
public_income_1.IncomeType.PaygAllowancesNotTaxed,
|
|
17
|
-
public_income_1.IncomeType.PaygAllowancesTaxed,
|
|
18
|
-
public_income_1.IncomeType.PaygBaseSalary,
|
|
19
|
-
public_income_1.IncomeType.PaygBonusIncome,
|
|
20
|
-
public_income_1.IncomeType.PaygCarAllowance,
|
|
21
|
-
public_income_1.IncomeType.PaygCommissionIncome,
|
|
22
|
-
public_income_1.IncomeType.PaygCompanyCar,
|
|
23
|
-
public_income_1.IncomeType.PaygOvertimeIncome,
|
|
24
|
-
];
|
|
25
26
|
var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
26
27
|
var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
27
28
|
// Income types mapping from internal to LIXI types /paths.
|
|
@@ -58,30 +59,47 @@ exports.EmploymentIncomeTypeMapping = (_a = {},
|
|
|
58
59
|
amount: 'Income.@GrossRegularOvertimeAmount',
|
|
59
60
|
frequency: 'Income.@GrossRegularOvertimeFrequency'
|
|
60
61
|
},
|
|
61
|
-
_a[public_income_1.IncomeType.SelfEmployedBusinessIncome] = {
|
|
62
|
-
amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
|
|
63
|
-
},
|
|
64
62
|
_a);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
function getIncomeMapping(incomeType) {
|
|
64
|
+
var basePath = application_paths_1.paths.OtherIncome;
|
|
65
|
+
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
66
|
+
basePath = application_paths_1.paths.RealEstateAsset;
|
|
67
|
+
return {
|
|
68
|
+
assetId: "".concat(basePath, ".@UniqueID"),
|
|
69
|
+
percentOwned: "".concat(basePath, ".RentalIncome")
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
73
|
+
basePath = application_paths_1.paths.CompanyApplicant;
|
|
74
|
+
return {
|
|
75
|
+
companyId: "".concat(basePath, ".@UniqueID"),
|
|
76
|
+
incomes: "".concat(basePath, ".IncomeRecent"),
|
|
77
|
+
incomeRecent: "".concat(basePath, ".IncomeRecent"),
|
|
78
|
+
incomePrevious: "".concat(basePath, ".IncomePrevious"),
|
|
79
|
+
gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
83
|
+
basePath = application_paths_1.paths.PAYG;
|
|
84
|
+
var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
|
|
85
|
+
var mapping = {
|
|
86
|
+
amount: "".concat(basePath, ".").concat(amount),
|
|
87
|
+
employmentId: "".concat(basePath, ".@UniqueID")
|
|
88
|
+
};
|
|
89
|
+
if (frequency) {
|
|
90
|
+
mapping.frequency = "".concat(basePath, ".").concat(frequency);
|
|
91
|
+
}
|
|
92
|
+
return mapping;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
amount: "".concat(basePath, ".@Amount"),
|
|
96
|
+
frequency: "".concat(basePath, ".@Frequency"),
|
|
97
|
+
percentOwned: "".concat(basePath, ".PercentOwned"),
|
|
98
|
+
type: "".concat(basePath, ".@Type"),
|
|
99
|
+
benefitType: "".concat(basePath, ".@GovernmentBenefitsType")
|
|
100
|
+
};
|
|
83
101
|
}
|
|
84
|
-
exports.
|
|
102
|
+
exports.getIncomeMapping = getIncomeMapping;
|
|
85
103
|
/**
|
|
86
104
|
* Generates an partial application from a partial income event.
|
|
87
105
|
*
|
|
@@ -89,58 +107,20 @@ exports.isRentalIncome = isRentalIncome;
|
|
|
89
107
|
* @param storedApplication: Current state of the application.
|
|
90
108
|
* @return partialApplication an incomplete application.
|
|
91
109
|
*/
|
|
92
|
-
function generateIncome(payload,
|
|
110
|
+
function generateIncome(payload, applicantId) {
|
|
93
111
|
var applicationId = payload.applicationId, id = payload.id, income = payload.income;
|
|
94
|
-
var applicantId = (0, lodash_1.get)(income, 'percentOwned.owners[0].applicantId');
|
|
95
|
-
if (!applicantId) {
|
|
96
|
-
var employmentId = getEmploymentIdForIncome(payload);
|
|
97
|
-
applicantId = getApplicantIdForEmploymentId(storedApplication, employmentId);
|
|
98
|
-
}
|
|
99
112
|
var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
|
|
100
113
|
var partialApplication = {};
|
|
101
|
-
var incomeMapping;
|
|
102
114
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
103
|
-
if (
|
|
104
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
logger_1.logger.warn({
|
|
108
|
-
message: "No applicantId found for income event with id : " + id + " and type " + incomeType + " for application: " + applicationId
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (isPaygIncome(incomeType)) {
|
|
112
|
-
var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
|
|
113
|
-
incomeMapping = {
|
|
114
|
-
amount: application_paths_1.paths.PAYG + "." + amount,
|
|
115
|
-
frequency: application_paths_1.paths.PAYG + "." + frequency,
|
|
116
|
-
employmentId: application_paths_1.paths.PAYG + ".@UniqueID"
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
else if (isSelfEmployedIncome(incomeType)) {
|
|
120
|
-
var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
|
|
121
|
-
incomeMapping = {
|
|
122
|
-
amount: application_paths_1.paths.SelfEmployed + "." + amount,
|
|
123
|
-
employmentId: application_paths_1.paths.SelfEmployed + ".@UniqueID"
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
else if (isRentalIncome(incomeType)) {
|
|
127
|
-
incomeMapping = {
|
|
128
|
-
assetId: application_paths_1.paths.RealEstateAsset + ".@UniqueID",
|
|
129
|
-
percentOwned: application_paths_1.paths.RealEstateAsset + ".RentalIncome"
|
|
130
|
-
};
|
|
115
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
|
|
116
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
131
117
|
}
|
|
132
|
-
|
|
133
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome
|
|
134
|
-
incomeMapping = {
|
|
135
|
-
amount: application_paths_1.paths.OtherIncome + ".@Amount",
|
|
136
|
-
frequency: application_paths_1.paths.OtherIncome + ".@Frequency",
|
|
137
|
-
percentOwned: application_paths_1.paths.OtherIncome + ".PercentOwned",
|
|
138
|
-
type: application_paths_1.paths.OtherIncome + ".@Type",
|
|
139
|
-
benefitType: application_paths_1.paths.OtherIncome + ".@GovernmentBenefitsType"
|
|
140
|
-
};
|
|
118
|
+
if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
|
|
119
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
|
|
141
120
|
}
|
|
142
|
-
|
|
143
|
-
|
|
121
|
+
var incomeMapping = getIncomeMapping(incomeType);
|
|
122
|
+
for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
|
|
123
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
144
124
|
if (incomeMapping[key]) {
|
|
145
125
|
switch (key) {
|
|
146
126
|
case 'amount':
|
|
@@ -151,27 +131,36 @@ function generateIncome(payload, storedApplication) {
|
|
|
151
131
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
|
|
152
132
|
break;
|
|
153
133
|
case 'percentOwned':
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
134
|
+
var ownership = value;
|
|
135
|
+
var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(ownership);
|
|
136
|
+
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
137
|
+
percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
|
|
157
138
|
}
|
|
158
139
|
if (percentOwned) {
|
|
159
140
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
|
|
160
141
|
}
|
|
161
142
|
break;
|
|
162
143
|
case 'type':
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
(0,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
144
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
145
|
+
var mappedType = income_type_1.otherIncomeMapping[value];
|
|
146
|
+
if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
|
|
147
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
|
|
148
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
|
|
152
|
+
}
|
|
170
153
|
}
|
|
171
154
|
break;
|
|
172
155
|
case 'benefitType':
|
|
173
156
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
|
|
174
157
|
break;
|
|
158
|
+
case 'incomes':
|
|
159
|
+
var sortedIncomeList = value
|
|
160
|
+
.sort(is_income_type_1.sortBusinessIncome)
|
|
161
|
+
.map(generateIncomeBusinessDetails);
|
|
162
|
+
(0, lodash_1.set)(partialApplication, 'Package.Content.Application.CompanyApplicant[0].Income', sortedIncomeList);
|
|
163
|
+
break;
|
|
175
164
|
default:
|
|
176
165
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], value);
|
|
177
166
|
break;
|
|
@@ -181,67 +170,67 @@ function generateIncome(payload, storedApplication) {
|
|
|
181
170
|
return partialApplication;
|
|
182
171
|
}
|
|
183
172
|
exports.generateIncome = generateIncome;
|
|
184
|
-
/**
|
|
185
|
-
* Gets the applicant id if given employmentId belongs to it.
|
|
186
|
-
*
|
|
187
|
-
* @param application
|
|
188
|
-
* @param employmentId
|
|
189
|
-
*/
|
|
190
|
-
function getApplicantIdForEmploymentId(application, employmentId) {
|
|
191
|
-
if (!employmentId || !application)
|
|
192
|
-
return null;
|
|
193
|
-
var applicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
|
|
194
|
-
var applicant = applicants.find(function (applicant) { return containsEmploymentId(applicant, employmentId); });
|
|
195
|
-
return applicant ? applicant['@UniqueID'] : null;
|
|
196
|
-
}
|
|
197
|
-
exports.getApplicantIdForEmploymentId = getApplicantIdForEmploymentId;
|
|
198
|
-
/**
|
|
199
|
-
* Checks if given employment id belongs to given applicant.
|
|
200
|
-
*
|
|
201
|
-
* @param applicant
|
|
202
|
-
* @param employmentId
|
|
203
|
-
*/
|
|
204
|
-
function containsEmploymentId(applicant, employmentId) {
|
|
205
|
-
return (applicant.Employment || []).some(function (employment) {
|
|
206
|
-
return (0, lodash_1.get)(employment, 'PAYG.@UniqueID') === employmentId ||
|
|
207
|
-
(0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') === employmentId ||
|
|
208
|
-
(0, lodash_1.get)(employment, 'NotEmployed.@UniqueID') === employmentId;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
exports.containsEmploymentId = containsEmploymentId;
|
|
212
|
-
/**
|
|
213
|
-
* Gets the employmentId if given income is employment income.
|
|
214
|
-
*
|
|
215
|
-
* @param payload
|
|
216
|
-
*/
|
|
217
|
-
function getEmploymentIdForIncome(payload) {
|
|
218
|
-
var _a = payload.income, incomeType = _a.type, employmentId = _a.employmentId;
|
|
219
|
-
if (isPaygIncome(incomeType) || isSelfEmployedIncome(incomeType))
|
|
220
|
-
return employmentId;
|
|
221
|
-
return undefined;
|
|
222
|
-
}
|
|
223
|
-
exports.getEmploymentIdForIncome = getEmploymentIdForIncome;
|
|
224
173
|
/**
|
|
225
174
|
* Creates Rental Income array.
|
|
226
|
-
* @param owners List of owners.
|
|
227
175
|
* @param amount Amount
|
|
228
176
|
* @param frequency Frequency
|
|
177
|
+
* @param ownership Owners.
|
|
229
178
|
*/
|
|
230
|
-
function createRentalIncome(
|
|
231
|
-
var _b = _a.owners, owners = _b === void 0 ? [] : _b;
|
|
232
|
-
if (owners.length === 0)
|
|
233
|
-
return null;
|
|
179
|
+
function createRentalIncome(amount, frequency, ownership) {
|
|
234
180
|
if (frequency === public_income_1.Frequency.Quarterly) {
|
|
235
181
|
amount = Math.ceil(amount / 3);
|
|
236
182
|
frequency = public_income_1.Frequency.Monthly;
|
|
237
183
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
184
|
+
var rentalIncome = [];
|
|
185
|
+
for (var _i = 0, ownership_1 = ownership; _i < ownership_1.length; _i++) {
|
|
186
|
+
var owner = ownership_1[_i];
|
|
187
|
+
var percent = owner.percent, applicantId = owner.applicantId;
|
|
188
|
+
var ownerAmount = amount * percent;
|
|
189
|
+
rentalIncome.push({
|
|
190
|
+
'@Frequency': alieo_frequency_1.rentalIncomeFrequencyMapping[frequency],
|
|
191
|
+
'@RentalAmount': ownerAmount,
|
|
243
192
|
'@x_Owner': applicantId
|
|
244
193
|
});
|
|
245
|
-
}
|
|
194
|
+
}
|
|
195
|
+
return rentalIncome;
|
|
246
196
|
}
|
|
247
197
|
exports.createRentalIncome = createRentalIncome;
|
|
198
|
+
var selfEmploymentIncomeMapping = {
|
|
199
|
+
year: '@StartDate',
|
|
200
|
+
companyProfitBeforeTax: '@CompanyProfitBeforeTax',
|
|
201
|
+
addback: {
|
|
202
|
+
depreciation: 'Addback.@Depreciation',
|
|
203
|
+
interest: 'Addback.@Interest',
|
|
204
|
+
lease: 'Addback.@Lease',
|
|
205
|
+
nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
|
|
206
|
+
other: 'Addback.@Other',
|
|
207
|
+
salary: 'Addback.@Salary',
|
|
208
|
+
superannuationExcess: 'Addback.@SuperannuationExcess'
|
|
209
|
+
},
|
|
210
|
+
nonRecurringIncome: 'NonRecurringIncome[0].@Amount'
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* @description Transform a Self Employed Income Details to LIXI
|
|
214
|
+
* @param data Financial Year Income Details for Self Employed Income.
|
|
215
|
+
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
216
|
+
*/
|
|
217
|
+
function generateIncomeBusinessDetails(data) {
|
|
218
|
+
var income = {};
|
|
219
|
+
var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
|
|
220
|
+
for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
|
|
221
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
222
|
+
if (selfEmploymentIncomeMapping[key] != null) {
|
|
223
|
+
if (key === 'addback') {
|
|
224
|
+
for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
|
|
225
|
+
var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
|
|
226
|
+
(0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return income;
|
|
235
|
+
}
|
|
236
|
+
exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
|
|
@@ -21,19 +21,19 @@ function generateLiability(_a) {
|
|
|
21
21
|
var partialApplication = {};
|
|
22
22
|
var liabilityMapping = {
|
|
23
23
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
24
|
-
annualInterestRate: application_paths_1.paths.Liability
|
|
25
|
-
id: application_paths_1.paths.Liability
|
|
26
|
-
clearingFromThisLoan: application_paths_1.paths.Liability
|
|
27
|
-
description: application_paths_1.paths.Liability
|
|
28
|
-
financialInstitution: application_paths_1.paths.Liability
|
|
29
|
-
newLimit: application_paths_1.paths.Liability
|
|
30
|
-
repaymentAmount: application_paths_1.paths.Liability
|
|
31
|
-
repaymentFrequency: application_paths_1.paths.Liability
|
|
32
|
-
remainingTermDuration: application_paths_1.paths.Liability
|
|
33
|
-
repaymentTypeDetails: application_paths_1.paths.Liability
|
|
34
|
-
outstandingBalance: application_paths_1.paths.Liability
|
|
35
|
-
type: application_paths_1.paths.Liability
|
|
36
|
-
percentOwned: application_paths_1.paths.Liability
|
|
24
|
+
annualInterestRate: "".concat(application_paths_1.paths.Liability, ".@AnnualInterestRate"),
|
|
25
|
+
id: "".concat(application_paths_1.paths.Liability, ".@UniqueID"),
|
|
26
|
+
clearingFromThisLoan: "".concat(application_paths_1.paths.Liability, ".@ClearingFromThisLoan"),
|
|
27
|
+
description: "".concat(application_paths_1.paths.Liability, ".@Description"),
|
|
28
|
+
financialInstitution: "".concat(application_paths_1.paths.Liability, ".AccountNumber.@FinancialInstitution"),
|
|
29
|
+
newLimit: "".concat(application_paths_1.paths.Liability, ".@CreditLimit"),
|
|
30
|
+
repaymentAmount: "".concat(application_paths_1.paths.Liability, ".Repayment[0].@RepaymentAmount"),
|
|
31
|
+
repaymentFrequency: "".concat(application_paths_1.paths.Liability, ".Repayment[0].@RepaymentFrequency"),
|
|
32
|
+
remainingTermDuration: "".concat(application_paths_1.paths.Liability, ".RemainingTerm.@Duration"),
|
|
33
|
+
repaymentTypeDetails: "".concat(application_paths_1.paths.Liability, ".Repayment[0].@PaymentType"),
|
|
34
|
+
outstandingBalance: "".concat(application_paths_1.paths.Liability, ".@OutstandingBalance"),
|
|
35
|
+
type: "".concat(application_paths_1.paths.Liability, ".@Type"),
|
|
36
|
+
percentOwned: "".concat(application_paths_1.paths.Liability, ".PercentOwned")
|
|
37
37
|
};
|
|
38
38
|
(0, lodash_1.set)(partialApplication, liabilityMapping.applicationId, applicationId);
|
|
39
39
|
(0, lodash_1.set)(partialApplication, liabilityMapping.id, id);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { PercentOwned } from '../types/events/public-liability';
|
|
2
|
+
import { PercentOwned as LIXIPercentOwned } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
3
|
/**
|
|
3
4
|
* Transform percentOwned to lixi's format.
|
|
4
5
|
*
|
|
5
6
|
* @param percentOwned PercentOwned for an asset or liability on public liability event.
|
|
7
|
+
* @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
|
|
6
8
|
*/
|
|
7
|
-
export declare function generateLIXIPercentOwned({ owners }: PercentOwned):
|
|
8
|
-
Owner: {
|
|
9
|
-
'@Percent': number;
|
|
10
|
-
'@x_Party': string;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
9
|
+
export declare function generateLIXIPercentOwned({ owners }: PercentOwned): LIXIPercentOwned;
|
|
@@ -5,6 +5,7 @@ exports.generateLIXIPercentOwned = void 0;
|
|
|
5
5
|
* Transform percentOwned to lixi's format.
|
|
6
6
|
*
|
|
7
7
|
* @param percentOwned PercentOwned for an asset or liability on public liability event.
|
|
8
|
+
* @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
|
|
8
9
|
*/
|
|
9
10
|
function generateLIXIPercentOwned(_a) {
|
|
10
11
|
var _b = _a.owners, owners = _b === void 0 ? [] : _b;
|
|
@@ -19,8 +19,8 @@ function generateOpportunity(opportunity) {
|
|
|
19
19
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
20
20
|
if (opportunityMapping[key]) {
|
|
21
21
|
if (key === 'stage') {
|
|
22
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions
|
|
23
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key]
|
|
22
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
|
|
23
|
+
(0, lodash_1.set)(partialApplication, "".concat(opportunityMapping[key], ".@Details"), value || 'Unknown');
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
(0, lodash_1.set)(partialApplication, opportunityMapping[key], value);
|
|
@@ -17,7 +17,7 @@ var public_required_document_1 = require("../types/events/public-required-docume
|
|
|
17
17
|
function generateRequiredDocument(requiredDocument) {
|
|
18
18
|
var partialApplication = {};
|
|
19
19
|
var requiredDocsMapping = {
|
|
20
|
-
applicantId: application_paths_1.paths.PersonApplicant
|
|
20
|
+
applicantId: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
|
|
21
21
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
22
22
|
eConsent: application_paths_1.paths.Privacy,
|
|
23
23
|
identification: application_paths_1.paths.ProofOfIdentity
|
|
@@ -28,20 +28,20 @@ function generateRequiredDocument(requiredDocument) {
|
|
|
28
28
|
switch (key) {
|
|
29
29
|
case 'identification':
|
|
30
30
|
var _c = value, idType = _c.idType, idNumber = _c.idNumber, _d = _c.idTitle, idTitle = _d === void 0 ? public_required_document_1.IDTitle.Unknown : _d, gender = _c.gender;
|
|
31
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ProofOfIdentity
|
|
32
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ProofOfIdentity
|
|
31
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.ProofOfIdentity, ".@DocumentType"), proof_of_identity_1.proofOfIdentityMapping[idType]);
|
|
32
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.ProofOfIdentity, ".@DocumentNumber"), idNumber);
|
|
33
33
|
if (gender) {
|
|
34
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant
|
|
34
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@Gender"), (0, lodash_1.capitalize)(gender));
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant
|
|
37
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@Gender"), title_gender_1.titleGenderMapping[idTitle]);
|
|
38
38
|
}
|
|
39
39
|
break;
|
|
40
40
|
case 'eConsent':
|
|
41
41
|
var _e = requiredDocument.eConsent.consentedAt, consentedAt = _e === void 0 ? new Date() : _e;
|
|
42
42
|
var hasValidConsent = requiredDocument.status === public_required_document_1.Status.Verified ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No;
|
|
43
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Privacy
|
|
44
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Privacy
|
|
43
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Privacy, ".@CreditAuthoritySigned"), hasValidConsent);
|
|
44
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Privacy, ".@DateSigned"), (0, date_fns_1.format)(new Date(consentedAt), 'yyyy-MM-dd'));
|
|
45
45
|
break;
|
|
46
46
|
default:
|
|
47
47
|
(0, lodash_1.set)(partialApplication, requiredDocsMapping[key], value);
|
|
@@ -18,20 +18,20 @@ var booleanMapping = function (input) {
|
|
|
18
18
|
exports.booleanMapping = booleanMapping;
|
|
19
19
|
var applicantMapping = {
|
|
20
20
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
21
|
-
citizenship: application_paths_1.paths.PersonApplicant
|
|
22
|
-
contact: application_paths_1.paths.PersonApplicant
|
|
21
|
+
citizenship: "".concat(application_paths_1.paths.PersonApplicant, ".@Citizenship"),
|
|
22
|
+
contact: "".concat(application_paths_1.paths.PersonApplicant, ".Contact"),
|
|
23
23
|
dependants: 'dependants',
|
|
24
|
-
dateOfBirth: application_paths_1.paths.PersonApplicant
|
|
25
|
-
firstName: application_paths_1.paths.PersonApplicant
|
|
26
|
-
id: application_paths_1.paths.PersonApplicant
|
|
27
|
-
isFirstHomeBuyer: application_paths_1.paths.PersonApplicant
|
|
28
|
-
isPrimaryApplicant: application_paths_1.paths.PersonApplicant
|
|
29
|
-
lastName: application_paths_1.paths.PersonApplicant
|
|
30
|
-
maritalStatus: application_paths_1.paths.PersonApplicant
|
|
31
|
-
maritalDetails: application_paths_1.paths.PersonApplicant
|
|
32
|
-
middleName: application_paths_1.paths.PersonApplicant
|
|
33
|
-
residencyStatus: application_paths_1.paths.PersonApplicant
|
|
34
|
-
title: application_paths_1.paths.PersonName
|
|
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
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Transforms a partial Applicant event to a partial LIXI application.
|
|
@@ -84,8 +84,8 @@ function transformApplicant(applicant) {
|
|
|
84
84
|
break;
|
|
85
85
|
case 'dependants':
|
|
86
86
|
var dependants = generateDependants(value, applicantId);
|
|
87
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household
|
|
88
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household
|
|
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
89
|
break;
|
|
90
90
|
default:
|
|
91
91
|
(0, lodash_1.set)(partialApplication, applicantMapping[key], value);
|
|
@@ -120,7 +120,7 @@ function generateContact(contact, id) {
|
|
|
120
120
|
switch (key) {
|
|
121
121
|
case 'currentAddress':
|
|
122
122
|
{
|
|
123
|
-
var addressId = id
|
|
123
|
+
var addressId = "".concat(id, "-current");
|
|
124
124
|
var _c = (0, address_tools_1.rebuildAddress)(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
|
|
125
125
|
lixiAddresses.push(lixiAddress);
|
|
126
126
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
@@ -128,7 +128,7 @@ function generateContact(contact, id) {
|
|
|
128
128
|
break;
|
|
129
129
|
case 'postSettlementAddress':
|
|
130
130
|
{
|
|
131
|
-
var addressId = id
|
|
131
|
+
var addressId = "".concat(id, "-postSettlement");
|
|
132
132
|
var _d = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
|
|
133
133
|
lixiAddresses.push(lixiAddress);
|
|
134
134
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
@@ -136,7 +136,7 @@ function generateContact(contact, id) {
|
|
|
136
136
|
break;
|
|
137
137
|
case 'mailingAddress':
|
|
138
138
|
{
|
|
139
|
-
var addressId = id
|
|
139
|
+
var addressId = "".concat(id, "-mailing");
|
|
140
140
|
var lixiAddress = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId).lixiAddress;
|
|
141
141
|
lixiAddresses.push(lixiAddress);
|
|
142
142
|
(0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
|
|
@@ -144,7 +144,7 @@ function generateContact(contact, id) {
|
|
|
144
144
|
break;
|
|
145
145
|
case 'previousAddresses':
|
|
146
146
|
{
|
|
147
|
-
var addressId = id
|
|
147
|
+
var addressId = "".concat(id, "-previous");
|
|
148
148
|
var previousAddresses = value.sort(function (lhs, rhs) {
|
|
149
149
|
return lhs.endDate.localeCompare(rhs.endDate);
|
|
150
150
|
});
|
|
@@ -154,9 +154,9 @@ function generateContact(contact, id) {
|
|
|
154
154
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
155
155
|
// PriorAddresses
|
|
156
156
|
previousAddresses.forEach(function (address, index) {
|
|
157
|
-
var _a = (0, address_tools_1.rebuildAddress)(address, id
|
|
157
|
+
var _a = (0, address_tools_1.rebuildAddress)(address, "".concat(id, "-prior-").concat(index)), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
|
|
158
158
|
lixiAddresses.push(lixiAddress);
|
|
159
|
-
(0, lodash_1.set)(lixiContact, contactMapping['priorAddress']
|
|
159
|
+
(0, lodash_1.set)(lixiContact, "".concat(contactMapping['priorAddress'], ".").concat(index), lixiContactAddress);
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
break;
|
|
@@ -18,14 +18,14 @@ function transformApplication(opportunity) {
|
|
|
18
18
|
var opportunityMapping = {
|
|
19
19
|
brand: application_paths_1.paths.BusinessName,
|
|
20
20
|
id: application_paths_1.paths.ApplicationId,
|
|
21
|
-
paymentType: application_paths_1.paths.LoanTerm
|
|
21
|
+
paymentType: "".concat(application_paths_1.paths.LoanTerm, ".@PaymentType"),
|
|
22
22
|
preliminary: 'preliminary',
|
|
23
23
|
primaryPurpose: application_paths_1.paths.PurposeOfApplication,
|
|
24
24
|
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
|
|
25
25
|
};
|
|
26
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail
|
|
27
|
-
(0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions
|
|
28
|
-
(0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions
|
|
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
29
|
for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
|
|
30
30
|
var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
|
|
31
31
|
if (opportunityMapping[opportunityKey]) {
|
|
@@ -29,7 +29,10 @@ exports.otherCommitmentExpenseTypes = [
|
|
|
29
29
|
*/
|
|
30
30
|
function transformExpenses(expense) {
|
|
31
31
|
var partialApplication = {};
|
|
32
|
-
var applicantId = expense.applicantId, applicationId = expense.applicationId,
|
|
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
|
+
}
|
|
33
36
|
var normalisedExpenses = expenses.map(normaliseExpenseAmount);
|
|
34
37
|
var livingExpenseEstimate = normalisedExpenses.find(isLivingExpenseEstimate);
|
|
35
38
|
var otherCommitments = normalisedExpenses.filter(isOtherCommitment);
|
|
@@ -49,8 +52,8 @@ function transformExpenses(expense) {
|
|
|
49
52
|
}
|
|
50
53
|
var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
|
|
51
54
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
52
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household
|
|
53
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant
|
|
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);
|
|
54
57
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
55
58
|
if (lixiLivingExpenses.length > 0) {
|
|
56
59
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
@@ -71,7 +74,7 @@ function transformExpense(expense, applicantId, index, id) {
|
|
|
71
74
|
'@Amount': expense.amount,
|
|
72
75
|
'@Category': living_expense_1.livingExpenseMapping[expense.type],
|
|
73
76
|
'@Description': expense.type,
|
|
74
|
-
'@UniqueID': isOtherCommitment(expense) ? id
|
|
77
|
+
'@UniqueID': isOtherCommitment(expense) ? "".concat(id, "-commitment-").concat(index) : "".concat(id, "-living-expense-").concat(index),
|
|
75
78
|
'@Frequency': expense_frequency_1.frequencyMapping[expense.frequency],
|
|
76
79
|
PercentResponsible: {
|
|
77
80
|
Owner: [
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { List as LIXIFrequency } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
2
|
import { RepaymentFrequency } from '../events/public-liability';
|
|
3
3
|
import { Frequency } from '../events/public-income';
|
|
4
|
-
declare type LiabilityFrequencyMapping = {
|
|
4
|
+
export declare type LiabilityFrequencyMapping = {
|
|
5
5
|
[key in RepaymentFrequency]: LIXIFrequency;
|
|
6
6
|
};
|
|
7
|
-
declare type IncomeExpenseFrequencyMapping = {
|
|
7
|
+
export declare type IncomeExpenseFrequencyMapping = {
|
|
8
8
|
[key in RepaymentFrequency | Frequency]: LIXIFrequency;
|
|
9
9
|
};
|
|
10
|
+
export declare type RentalIncomeFrequencyMapping = {
|
|
11
|
+
[key in Frequency]: LIXIFrequency;
|
|
12
|
+
};
|
|
10
13
|
export declare const incomeExpenseFrequencyMapping: IncomeExpenseFrequencyMapping;
|
|
11
14
|
export declare const liabilityFrequencyMapping: LiabilityFrequencyMapping;
|
|
12
|
-
export
|
|
15
|
+
export declare const rentalIncomeFrequencyMapping: Partial<RentalIncomeFrequencyMapping>;
|