@lendi/integrations-transform 1.1.0 → 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/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 +143 -136
- 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 +3 -3
- 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 +83 -0
- package/lib/utils/is-income-type.js +166 -0
- package/lib/utils/normalise-date.js +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
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");
|
|
5
17
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/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");
|
|
9
23
|
var round_decimal_1 = require("../utils/round-decimal");
|
|
10
|
-
var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
11
24
|
var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
|
|
12
|
-
var
|
|
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
|
+
var is_income_type_1 = require("../utils/is-income-type");
|
|
25
26
|
var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
26
27
|
var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
27
28
|
// Income types mapping from internal to LIXI types /paths.
|
|
@@ -62,26 +63,43 @@ exports.EmploymentIncomeTypeMapping = (_a = {},
|
|
|
62
63
|
amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
|
|
63
64
|
},
|
|
64
65
|
_a);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
function getIncomeMapping(incomeType, basePath) {
|
|
67
|
+
if (basePath === void 0) { basePath = application_paths_1.paths.PAYG; }
|
|
68
|
+
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
69
|
+
return {
|
|
70
|
+
assetId: "".concat(basePath, ".@UniqueID"),
|
|
71
|
+
percentOwned: "".concat(basePath, ".RentalIncome")
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
75
|
+
return {
|
|
76
|
+
incomes: "".concat(basePath, ".IncomeRecent"),
|
|
77
|
+
companyId: "".concat(basePath, ".@UniqueID"),
|
|
78
|
+
incomeRecent: "".concat(basePath, ".IncomeRecent"),
|
|
79
|
+
incomePrevious: "".concat(basePath, ".IncomePrevious"),
|
|
80
|
+
gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if ((0, is_income_type_1.isPaygIncome)(incomeType) || (0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
|
|
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
|
*
|
|
@@ -91,56 +109,36 @@ exports.isRentalIncome = isRentalIncome;
|
|
|
91
109
|
*/
|
|
92
110
|
function generateIncome(payload, storedApplication) {
|
|
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.
|
|
115
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
116
|
+
var applicants = (0, lodash_1.get)(storedApplication, application_paths_1.paths.PersonApplicants);
|
|
117
|
+
var applicantId = (0, is_income_type_1.getApplicantId)(income, applicants);
|
|
118
|
+
if (applicantId) {
|
|
119
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
120
|
+
}
|
|
105
121
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
122
|
+
var incomeMapping;
|
|
123
|
+
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
124
|
+
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.RealEstateAsset);
|
|
110
125
|
}
|
|
111
|
-
if (isPaygIncome(incomeType)) {
|
|
112
|
-
|
|
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
|
-
};
|
|
126
|
+
else if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
127
|
+
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.PAYG);
|
|
118
128
|
}
|
|
119
|
-
else if (isSelfEmployedIncome(incomeType)) {
|
|
120
|
-
|
|
121
|
-
incomeMapping = {
|
|
122
|
-
amount: application_paths_1.paths.SelfEmployed + "." + amount,
|
|
123
|
-
employmentId: application_paths_1.paths.SelfEmployed + ".@UniqueID"
|
|
124
|
-
};
|
|
129
|
+
else if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
|
|
130
|
+
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.SelfEmployed);
|
|
125
131
|
}
|
|
126
|
-
else if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
percentOwned: application_paths_1.paths.RealEstateAsset + ".RentalIncome"
|
|
130
|
-
};
|
|
132
|
+
else if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
133
|
+
var basePath = 'Package.Content.Application.CompanyApplicant[0]';
|
|
134
|
+
incomeMapping = getIncomeMapping(incomeType, basePath);
|
|
131
135
|
}
|
|
132
136
|
else {
|
|
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
|
-
};
|
|
137
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
|
|
138
|
+
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.OtherIncome);
|
|
141
139
|
}
|
|
142
|
-
for (var _i = 0,
|
|
143
|
-
var
|
|
140
|
+
for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
|
|
141
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
144
142
|
if (incomeMapping[key]) {
|
|
145
143
|
switch (key) {
|
|
146
144
|
case 'amount':
|
|
@@ -151,27 +149,36 @@ function generateIncome(payload, storedApplication) {
|
|
|
151
149
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
|
|
152
150
|
break;
|
|
153
151
|
case 'percentOwned':
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
var ownership = value;
|
|
153
|
+
var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(ownership);
|
|
154
|
+
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
155
|
+
percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
|
|
157
156
|
}
|
|
158
157
|
if (percentOwned) {
|
|
159
158
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
|
|
160
159
|
}
|
|
161
160
|
break;
|
|
162
161
|
case 'type':
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
(0,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
162
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
163
|
+
var mappedType = income_type_1.otherIncomeMapping[value];
|
|
164
|
+
if ((0, is_income_type_1.isOtherIncome)(value)) {
|
|
165
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
|
|
166
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
|
|
170
|
+
}
|
|
170
171
|
}
|
|
171
172
|
break;
|
|
172
173
|
case 'benefitType':
|
|
173
174
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
|
|
174
175
|
break;
|
|
176
|
+
case 'incomes':
|
|
177
|
+
var sortedIncomeList = value
|
|
178
|
+
.sort(is_income_type_1.sortBusinessIncome)
|
|
179
|
+
.map(generateIncomeBusinessDetails);
|
|
180
|
+
(0, lodash_1.set)(partialApplication, 'Package.Content.Application.CompanyApplicant[0].Income', sortedIncomeList);
|
|
181
|
+
break;
|
|
175
182
|
default:
|
|
176
183
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], value);
|
|
177
184
|
break;
|
|
@@ -181,67 +188,67 @@ function generateIncome(payload, storedApplication) {
|
|
|
181
188
|
return partialApplication;
|
|
182
189
|
}
|
|
183
190
|
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
191
|
/**
|
|
225
192
|
* Creates Rental Income array.
|
|
226
|
-
* @param owners List of owners.
|
|
227
193
|
* @param amount Amount
|
|
228
194
|
* @param frequency Frequency
|
|
195
|
+
* @param ownership Owners.
|
|
229
196
|
*/
|
|
230
|
-
function createRentalIncome(
|
|
231
|
-
var _b = _a.owners, owners = _b === void 0 ? [] : _b;
|
|
232
|
-
if (owners.length === 0)
|
|
233
|
-
return null;
|
|
197
|
+
function createRentalIncome(amount, frequency, ownership) {
|
|
234
198
|
if (frequency === public_income_1.Frequency.Quarterly) {
|
|
235
199
|
amount = Math.ceil(amount / 3);
|
|
236
200
|
frequency = public_income_1.Frequency.Monthly;
|
|
237
201
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
202
|
+
var rentalIncome = [];
|
|
203
|
+
for (var _i = 0, ownership_1 = ownership; _i < ownership_1.length; _i++) {
|
|
204
|
+
var owner = ownership_1[_i];
|
|
205
|
+
var percent = owner.percent, applicantId = owner.applicantId;
|
|
206
|
+
var ownerAmount = amount * percent;
|
|
207
|
+
rentalIncome.push({
|
|
208
|
+
'@Frequency': alieo_frequency_1.rentalIncomeFrequencyMapping[frequency],
|
|
209
|
+
'@RentalAmount': ownerAmount,
|
|
243
210
|
'@x_Owner': applicantId
|
|
244
211
|
});
|
|
245
|
-
}
|
|
212
|
+
}
|
|
213
|
+
return rentalIncome;
|
|
246
214
|
}
|
|
247
215
|
exports.createRentalIncome = createRentalIncome;
|
|
216
|
+
var selfEmploymentIncomeMapping = {
|
|
217
|
+
year: '@StartDate',
|
|
218
|
+
companyProfitBeforeTax: '@CompanyProfitBeforeTax',
|
|
219
|
+
addback: {
|
|
220
|
+
depreciation: 'Addback.@Depreciation',
|
|
221
|
+
interest: 'Addback.@Interest',
|
|
222
|
+
lease: 'Addback.@Lease',
|
|
223
|
+
nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
|
|
224
|
+
other: 'Addback.@Other',
|
|
225
|
+
salary: 'Addback.@Salary',
|
|
226
|
+
superannuationExcess: 'Addback.@SuperannuationExcess'
|
|
227
|
+
},
|
|
228
|
+
nonRecurringIncome: 'NonRecurringIncome[0].@Amount'
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* @description Transform a Self Employed Income Details to LIXI
|
|
232
|
+
* @param data Financial Year Income Details for Self Employed Income.
|
|
233
|
+
* @returns {IncomeRecent} LIXI Income for the Self Employed.
|
|
234
|
+
*/
|
|
235
|
+
function generateIncomeBusinessDetails(data) {
|
|
236
|
+
var income = {};
|
|
237
|
+
var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
|
|
238
|
+
for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
|
|
239
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
240
|
+
if (selfEmploymentIncomeMapping[key] != null) {
|
|
241
|
+
if (key === 'addback') {
|
|
242
|
+
for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
|
|
243
|
+
var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
|
|
244
|
+
(0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return income;
|
|
253
|
+
}
|
|
254
|
+
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]) {
|
|
@@ -52,8 +52,8 @@ function transformExpenses(expense) {
|
|
|
52
52
|
}
|
|
53
53
|
var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
|
|
54
54
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
55
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household
|
|
56
|
-
(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);
|
|
57
57
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
58
58
|
if (lixiLivingExpenses.length > 0) {
|
|
59
59
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
@@ -74,7 +74,7 @@ function transformExpense(expense, applicantId, index, id) {
|
|
|
74
74
|
'@Amount': expense.amount,
|
|
75
75
|
'@Category': living_expense_1.livingExpenseMapping[expense.type],
|
|
76
76
|
'@Description': expense.type,
|
|
77
|
-
'@UniqueID': isOtherCommitment(expense) ? id
|
|
77
|
+
'@UniqueID': isOtherCommitment(expense) ? "".concat(id, "-commitment-").concat(index) : "".concat(id, "-living-expense-").concat(index),
|
|
78
78
|
'@Frequency': expense_frequency_1.frequencyMapping[expense.frequency],
|
|
79
79
|
PercentResponsible: {
|
|
80
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>;
|