@lendi/integrations-transform 1.5.7 → 1.6.0
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 -26
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +2 -5
- package/lib/schemas/application-workflow-event.json +1 -1
- 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 -184
- 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 -65
- package/lib/transform-events/transform-percent-owned.d.ts +1 -0
- 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/guarantor-relationship-type.d.ts +3 -0
- package/lib/types/enum-mappings/guarantor-relationship-type.js +13 -0
- 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 -43
- 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.js +10 -13
- 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,15 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
2
|
var t = {};
|
|
15
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -21,199 +9,195 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
9
|
}
|
|
22
10
|
return t;
|
|
23
11
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var transform_percent_owned_1 = require("./transform-percent-owned");
|
|
35
|
-
var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
36
|
-
var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
12
|
+
import { OtherIncomeTypeList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
13
|
+
import { paths } from '@lendi/integrations-credit-protocol/utils/application-paths';
|
|
14
|
+
import { isEmpty, set } from 'lodash';
|
|
15
|
+
import { governmentBenefitsMapping, incomeExpenseFrequencyMapping as frequencyMapping, otherIncomeMapping, rentalIncomeFrequencyMapping, } from '../types/enum-mappings';
|
|
16
|
+
import { Frequency, IncomeType, } from '../types/events/public-income';
|
|
17
|
+
import { isFullDocOrLowDocIncome, isOtherIncomeWithDesc, isPaygIncome, isRentalIncome, sortBusinessIncome, isOtherIncome, isSelfEmployedIncome, } from '../utils/is-income-type';
|
|
18
|
+
import { roundDecimal } from '../utils/round-decimal';
|
|
19
|
+
import { transformPercentOwned } from './transform-percent-owned';
|
|
20
|
+
const netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
21
|
+
const netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
37
22
|
// Income types mapping from internal to LIXI types /paths.
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
export const EmploymentIncomeTypeMapping = {
|
|
24
|
+
[IncomeType.PaygAllowancesNotTaxed]: {
|
|
40
25
|
amount: 'Income.@WorkAllowanceAmount',
|
|
41
|
-
frequency: 'Income.@WorkAllowanceFrequency'
|
|
26
|
+
frequency: 'Income.@WorkAllowanceFrequency',
|
|
42
27
|
},
|
|
43
|
-
|
|
28
|
+
[IncomeType.PaygAllowancesTaxed]: {
|
|
44
29
|
amount: netWorkAllowanceAmount,
|
|
45
|
-
frequency: netWorkAllowanceFrequency
|
|
30
|
+
frequency: netWorkAllowanceFrequency,
|
|
46
31
|
},
|
|
47
|
-
|
|
32
|
+
[IncomeType.PaygBaseSalary]: {
|
|
48
33
|
amount: 'Income.@GrossSalaryAmount',
|
|
49
|
-
frequency: 'Income.@GrossSalaryFrequency'
|
|
34
|
+
frequency: 'Income.@GrossSalaryFrequency',
|
|
50
35
|
},
|
|
51
|
-
|
|
36
|
+
[IncomeType.PaygBonusIncome]: {
|
|
52
37
|
amount: 'Income.@BonusAmount',
|
|
53
|
-
frequency: 'Income.@BonusFrequency'
|
|
38
|
+
frequency: 'Income.@BonusFrequency',
|
|
54
39
|
},
|
|
55
|
-
|
|
40
|
+
[IncomeType.PaygCommissionIncome]: {
|
|
56
41
|
amount: 'Income.@CommissionAmount',
|
|
57
|
-
frequency: 'Income.@CommissionFrequency'
|
|
42
|
+
frequency: 'Income.@CommissionFrequency',
|
|
58
43
|
},
|
|
59
|
-
|
|
44
|
+
[IncomeType.PaygCompanyCar]: {
|
|
60
45
|
amount: 'Income.@NetCarAllowanceAmount',
|
|
61
|
-
frequency: 'Income.@NetCarAllowanceFrequency'
|
|
46
|
+
frequency: 'Income.@NetCarAllowanceFrequency',
|
|
62
47
|
},
|
|
63
|
-
|
|
48
|
+
[IncomeType.PaygCarAllowance]: {
|
|
64
49
|
amount: 'Income.@CarAllowanceAmount',
|
|
65
|
-
frequency: 'Income.@CarAllowanceFrequency'
|
|
50
|
+
frequency: 'Income.@CarAllowanceFrequency',
|
|
66
51
|
},
|
|
67
|
-
|
|
52
|
+
[IncomeType.PaygOvertimeIncome]: {
|
|
68
53
|
amount: 'Income.@GrossRegularOvertimeAmount',
|
|
69
|
-
frequency: 'Income.@GrossRegularOvertimeFrequency'
|
|
54
|
+
frequency: 'Income.@GrossRegularOvertimeFrequency',
|
|
70
55
|
},
|
|
71
|
-
|
|
72
|
-
amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
|
|
56
|
+
[IncomeType.SelfEmployedBusinessIncome]: {
|
|
57
|
+
amount: 'BusinessIncomeRecent.@ProfitBeforeTax',
|
|
73
58
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @param incomeType
|
|
63
|
+
*/
|
|
64
|
+
export function getIncomeMapping(incomeType) {
|
|
65
|
+
let basePath = paths.OtherIncome;
|
|
66
|
+
if (isRentalIncome(incomeType)) {
|
|
67
|
+
basePath = paths.RealEstateAsset;
|
|
79
68
|
return {
|
|
80
|
-
assetId:
|
|
81
|
-
percentOwned:
|
|
69
|
+
assetId: `${basePath}.@UniqueID`,
|
|
70
|
+
percentOwned: `${basePath}.RentalIncome`,
|
|
82
71
|
};
|
|
83
72
|
}
|
|
84
|
-
if (
|
|
85
|
-
basePath =
|
|
73
|
+
if (isFullDocOrLowDocIncome(incomeType)) {
|
|
74
|
+
basePath = paths.CompanyApplicant;
|
|
86
75
|
return {
|
|
87
|
-
bas:
|
|
88
|
-
companyId:
|
|
89
|
-
incomes:
|
|
90
|
-
gross:
|
|
76
|
+
bas: `${basePath}.Income[0].BusinessActivityStatement`,
|
|
77
|
+
companyId: `${basePath}.@UniqueID`,
|
|
78
|
+
incomes: `${basePath}.Income`,
|
|
79
|
+
gross: `${basePath}.DeclaredIncome.@IncomeAmount`,
|
|
91
80
|
};
|
|
92
81
|
}
|
|
93
|
-
if (
|
|
94
|
-
basePath =
|
|
95
|
-
|
|
82
|
+
if (isSelfEmployedIncome(incomeType)) {
|
|
83
|
+
basePath = paths.SelfEmployed;
|
|
84
|
+
const { amount } = EmploymentIncomeTypeMapping[incomeType];
|
|
96
85
|
return {
|
|
97
|
-
amount:
|
|
98
|
-
employmentId:
|
|
86
|
+
amount: `${basePath}.${amount}`,
|
|
87
|
+
employmentId: `${basePath}.@UniqueID`,
|
|
99
88
|
};
|
|
100
89
|
}
|
|
101
|
-
if (
|
|
102
|
-
basePath =
|
|
103
|
-
|
|
104
|
-
return
|
|
90
|
+
if (isPaygIncome(incomeType)) {
|
|
91
|
+
basePath = paths.PAYG;
|
|
92
|
+
const { amount, frequency } = EmploymentIncomeTypeMapping[incomeType];
|
|
93
|
+
return Object.assign({ amount: `${basePath}.${amount}`, employmentId: `${basePath}.@UniqueID` }, (frequency && { frequency: `${basePath}.${frequency}` }));
|
|
105
94
|
}
|
|
106
95
|
return {
|
|
107
|
-
amount:
|
|
108
|
-
frequency:
|
|
109
|
-
percentOwned:
|
|
110
|
-
type:
|
|
111
|
-
benefitType:
|
|
96
|
+
amount: `${basePath}.@Amount`,
|
|
97
|
+
frequency: `${basePath}.@Frequency`,
|
|
98
|
+
percentOwned: `${basePath}.PercentOwned`,
|
|
99
|
+
type: `${basePath}.@Type`,
|
|
100
|
+
benefitType: `${basePath}.@GovernmentBenefitsType`,
|
|
112
101
|
};
|
|
113
102
|
}
|
|
114
|
-
exports.getIncomeMapping = getIncomeMapping;
|
|
115
103
|
/**
|
|
116
104
|
* Generates an partial application from a partial income event.
|
|
117
105
|
*
|
|
118
106
|
* @param payload a partial income event.
|
|
119
107
|
* @param applicantId PersonApplicant uniqueId on the application.
|
|
120
|
-
* @
|
|
108
|
+
* @returns partialApplication an incomplete application.
|
|
121
109
|
*/
|
|
122
|
-
function transformIncome(payload, applicantId) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (!
|
|
128
|
-
|
|
110
|
+
export function transformIncome(payload, applicantId) {
|
|
111
|
+
const { applicationId, id, income } = payload;
|
|
112
|
+
const { amount: incomeAmount, type: incomeType, frequency: incomeFrequency } = income;
|
|
113
|
+
const partialApplication = {};
|
|
114
|
+
set(partialApplication, paths.ApplicationId, applicationId);
|
|
115
|
+
if (!isRentalIncome(incomeType) && applicantId) {
|
|
116
|
+
set(partialApplication, `${paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
129
117
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
118
|
+
if (isOtherIncome(incomeType)) {
|
|
119
|
+
set(partialApplication, `${paths.OtherIncome}.@UniqueID`, id);
|
|
132
120
|
}
|
|
133
|
-
|
|
134
|
-
for (
|
|
135
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
121
|
+
const incomeMapping = getIncomeMapping(incomeType);
|
|
122
|
+
for (const [key, value] of Object.entries(income)) {
|
|
136
123
|
if (incomeMapping[key]) {
|
|
137
124
|
switch (key) {
|
|
138
125
|
case 'amount':
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
const amount = incomeFrequency === Frequency.Quarterly ? value * 4 : value;
|
|
127
|
+
set(partialApplication, incomeMapping[key], roundDecimal(amount));
|
|
141
128
|
break;
|
|
142
129
|
case 'bas':
|
|
143
|
-
|
|
144
|
-
if (!
|
|
145
|
-
|
|
130
|
+
const basWithAmount = value.filter((bas) => bas.salesAmount !== undefined || false);
|
|
131
|
+
if (!isEmpty(basWithAmount))
|
|
132
|
+
set(partialApplication, incomeMapping[key], generateBAS(basWithAmount));
|
|
146
133
|
break;
|
|
147
134
|
case 'frequency':
|
|
148
|
-
|
|
135
|
+
set(partialApplication, incomeMapping[key], frequencyMapping[value]);
|
|
149
136
|
break;
|
|
150
137
|
case 'percentOwned':
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (
|
|
138
|
+
const ownership = value;
|
|
139
|
+
let percentOwned = transformPercentOwned(ownership);
|
|
140
|
+
if (isRentalIncome(incomeType)) {
|
|
154
141
|
percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
|
|
155
142
|
}
|
|
156
143
|
if (percentOwned) {
|
|
157
|
-
|
|
144
|
+
set(partialApplication, incomeMapping[key], percentOwned);
|
|
158
145
|
}
|
|
159
146
|
break;
|
|
160
147
|
case 'type':
|
|
161
|
-
if (!
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
148
|
+
if (!isRentalIncome(incomeType)) {
|
|
149
|
+
const mappedType = otherIncomeMapping[value];
|
|
150
|
+
if (isOtherIncomeWithDesc(value)) {
|
|
151
|
+
set(partialApplication, `${paths.OtherIncome}.@Description`, mappedType);
|
|
152
|
+
set(partialApplication, incomeMapping[key], OtherIncomeTypeList.OtherIncome);
|
|
166
153
|
}
|
|
167
154
|
else {
|
|
168
|
-
|
|
155
|
+
set(partialApplication, incomeMapping[key], mappedType);
|
|
169
156
|
}
|
|
170
157
|
}
|
|
171
158
|
break;
|
|
172
159
|
case 'benefitType':
|
|
173
|
-
|
|
160
|
+
set(partialApplication, incomeMapping[key], governmentBenefitsMapping[value]);
|
|
174
161
|
break;
|
|
175
162
|
case 'incomes':
|
|
176
|
-
|
|
177
|
-
.sort(
|
|
163
|
+
const sortedIncomeList = value
|
|
164
|
+
.sort(sortBusinessIncome)
|
|
178
165
|
.map(generateIncomeBusinessDetails);
|
|
179
|
-
|
|
166
|
+
set(partialApplication, incomeMapping[key], sortedIncomeList);
|
|
180
167
|
break;
|
|
181
168
|
default:
|
|
182
|
-
|
|
169
|
+
set(partialApplication, incomeMapping[key], value);
|
|
183
170
|
break;
|
|
184
171
|
}
|
|
185
172
|
}
|
|
186
173
|
}
|
|
187
174
|
return partialApplication;
|
|
188
175
|
}
|
|
189
|
-
exports.transformIncome = transformIncome;
|
|
190
176
|
/**
|
|
191
177
|
* Creates Rental Income array.
|
|
178
|
+
*
|
|
192
179
|
* @param amount Amount
|
|
193
180
|
* @param frequency Frequency
|
|
194
181
|
* @param ownership Owners.
|
|
195
182
|
*/
|
|
196
|
-
function createRentalIncome(amount, frequency, ownership) {
|
|
197
|
-
if (
|
|
198
|
-
if (frequency === public_income_1.Frequency.Quarterly) {
|
|
183
|
+
export function createRentalIncome(amount, frequency, ownership = []) {
|
|
184
|
+
if (frequency === Frequency.Quarterly) {
|
|
199
185
|
amount = Math.ceil(amount / 3);
|
|
200
|
-
frequency =
|
|
186
|
+
frequency = Frequency.Monthly;
|
|
201
187
|
}
|
|
202
|
-
|
|
203
|
-
for (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
var ownerAmount = (0, round_decimal_1.roundDecimal)(amount * percent);
|
|
188
|
+
const rentalIncome = [];
|
|
189
|
+
for (const owner of ownership) {
|
|
190
|
+
const { percent, applicantId } = owner;
|
|
191
|
+
const ownerAmount = roundDecimal(amount * percent);
|
|
207
192
|
rentalIncome.push({
|
|
208
|
-
'@Frequency':
|
|
193
|
+
'@Frequency': rentalIncomeFrequencyMapping[frequency],
|
|
209
194
|
'@RentalAmount': ownerAmount,
|
|
210
|
-
'@x_Owner': applicantId
|
|
195
|
+
'@x_Owner': applicantId,
|
|
211
196
|
});
|
|
212
197
|
}
|
|
213
198
|
return rentalIncome;
|
|
214
199
|
}
|
|
215
|
-
|
|
216
|
-
var selfEmploymentIncomeMapping = {
|
|
200
|
+
const selfEmploymentIncomeMapping = {
|
|
217
201
|
year: '@StartDate',
|
|
218
202
|
companyProfitBeforeTax: '@CompanyProfitBeforeTax',
|
|
219
203
|
addback: {
|
|
@@ -223,48 +207,46 @@ var selfEmploymentIncomeMapping = {
|
|
|
223
207
|
nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
|
|
224
208
|
other: 'Addback.OtherAddback[0].@Amount',
|
|
225
209
|
salary: 'Addback.@Salary',
|
|
226
|
-
superannuationExcess: 'Addback.@SuperannuationExcess'
|
|
210
|
+
superannuationExcess: 'Addback.@SuperannuationExcess',
|
|
227
211
|
},
|
|
228
|
-
nonRecurringIncome: 'NonRecurringIncome[0].@Amount'
|
|
212
|
+
nonRecurringIncome: 'NonRecurringIncome[0].@Amount',
|
|
229
213
|
};
|
|
230
214
|
/**
|
|
231
215
|
* @description Transform a Self Employed Income Details to LIXI
|
|
232
216
|
* @param data Financial Year Income Details for Self Employed Income.
|
|
233
217
|
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
234
218
|
*/
|
|
235
|
-
function generateIncomeBusinessDetails(data) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
for (
|
|
239
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
219
|
+
export function generateIncomeBusinessDetails(data) {
|
|
220
|
+
const income = {};
|
|
221
|
+
const { addback: addbackMapping } = selfEmploymentIncomeMapping, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
|
|
222
|
+
for (const [key, value] of Object.entries(data)) {
|
|
240
223
|
if (selfEmploymentIncomeMapping[key] !== null) {
|
|
241
224
|
if (key === 'addback') {
|
|
242
|
-
for (
|
|
243
|
-
var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
|
|
225
|
+
for (const [addbackKey, addbackValue] of Object.entries(value)) {
|
|
244
226
|
if (addbackKey === 'other') {
|
|
245
|
-
|
|
227
|
+
set(income, 'Addback.OtherAddback[0].@Description', 'other');
|
|
246
228
|
}
|
|
247
|
-
|
|
229
|
+
set(income, addbackMapping[addbackKey], addbackValue);
|
|
248
230
|
}
|
|
249
231
|
}
|
|
250
232
|
else if (key === 'year') {
|
|
251
|
-
|
|
233
|
+
set(income, dateAndIncomeMapping[key], `${value}-01-01`);
|
|
252
234
|
}
|
|
253
235
|
else {
|
|
254
|
-
|
|
236
|
+
set(income, dateAndIncomeMapping[key], value);
|
|
255
237
|
}
|
|
256
238
|
}
|
|
257
239
|
}
|
|
258
240
|
return income;
|
|
259
241
|
}
|
|
260
|
-
exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
|
|
261
242
|
/**
|
|
262
243
|
* Generates the BAS array from the bas definition on the event.
|
|
244
|
+
*
|
|
245
|
+
* @param bas
|
|
263
246
|
*/
|
|
264
|
-
function generateBAS(bas) {
|
|
265
|
-
return bas.map(
|
|
247
|
+
export function generateBAS(bas) {
|
|
248
|
+
return bas.map((bas) => ({
|
|
266
249
|
'@Quarter': bas.quarter,
|
|
267
|
-
'@SalesAmount': bas.salesAmount
|
|
268
|
-
})
|
|
250
|
+
'@SalesAmount': bas.salesAmount,
|
|
251
|
+
}));
|
|
269
252
|
}
|
|
270
|
-
exports.generateBAS = generateBAS;
|
|
@@ -4,6 +4,9 @@ import { PartialApplication } from '../types/partial-application';
|
|
|
4
4
|
* Generates a partial internal request from a liability event payload.
|
|
5
5
|
*
|
|
6
6
|
* @param liabilityPayload: A liability event payload.
|
|
7
|
-
* @
|
|
7
|
+
* @param liabilityPayload:.applicationId
|
|
8
|
+
* @param liabilityPayload:.id
|
|
9
|
+
* @param liabilityPayload:.liability
|
|
10
|
+
* @returns A partial InternalRequest.
|
|
8
11
|
*/
|
|
9
12
|
export declare function transformLiability({ applicationId, id, liability }: LiabilityPayload): PartialApplication;
|
|
@@ -1,110 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var transform_percent_owned_1 = require("./transform-percent-owned");
|
|
12
|
-
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
13
|
-
var lixi_internal_request_2 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
1
|
+
import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
|
|
2
|
+
import { set } from 'lodash';
|
|
3
|
+
import { liabilityFrequencyMapping as frequencyMapping } from '../types/enum-mappings/alieo-frequency';
|
|
4
|
+
import { liabilityPaymentTypeMapping, liabilityTypeMapping } from '../types/enum-mappings';
|
|
5
|
+
import { ClearingFromOtherSource, LiabilityType, } from '../types/events/public-liability';
|
|
6
|
+
import { getFinancialInstitution } from '../utils/get-financial-institution';
|
|
7
|
+
import { roundDecimal } from '../utils/round-decimal';
|
|
8
|
+
import { transformPercentOwned } from './transform-percent-owned';
|
|
9
|
+
import { List as LIXIFrequency, LoanTermUnitsList, PaymentTypeList, YesNoList, } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
10
|
+
import { FinancialInstitutionList, UnitsList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
14
11
|
/**
|
|
15
12
|
* Generates a partial internal request from a liability event payload.
|
|
16
13
|
*
|
|
17
14
|
* @param liabilityPayload: A liability event payload.
|
|
18
|
-
* @
|
|
15
|
+
* @param liabilityPayload:.applicationId
|
|
16
|
+
* @param liabilityPayload:.id
|
|
17
|
+
* @param liabilityPayload:.liability
|
|
18
|
+
* @returns A partial InternalRequest.
|
|
19
19
|
*/
|
|
20
|
-
function transformLiability(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
percentOwned: "".concat(application_paths_1.paths.Liability, ".PercentOwned")
|
|
20
|
+
export function transformLiability({ applicationId, id, liability }) {
|
|
21
|
+
const partialApplication = {};
|
|
22
|
+
const liabilityMapping = {
|
|
23
|
+
applicationId: paths.ApplicationId,
|
|
24
|
+
annualInterestRate: `${paths.Liability}.@AnnualInterestRate`,
|
|
25
|
+
id: `${paths.Liability}.@UniqueID`,
|
|
26
|
+
clearingFromThisLoan: `${paths.Liability}.@ClearingFromThisLoan`,
|
|
27
|
+
clearingFromOtherSource: `${paths.Liability}.@ClearingFromOtherSource`,
|
|
28
|
+
description: `${paths.Liability}.@Description`,
|
|
29
|
+
financialInstitution: `${paths.Liability}.AccountNumber.@FinancialInstitution`,
|
|
30
|
+
financialInstitutionAccountNumber: `${paths.Liability}.AccountNumber.@AccountNumber`,
|
|
31
|
+
financialInstitutionBsb: `${paths.Liability}.AccountNumber.@BSB`,
|
|
32
|
+
interestOnlyRemainingTerm: `${paths.Liability}.OriginalTerm.@PaymentTypeDuration`,
|
|
33
|
+
creditLimit: `${paths.Liability}.@CreditLimit`,
|
|
34
|
+
newLimit: `${paths.Liability}.@NewLimit`,
|
|
35
|
+
repaymentAmount: `${paths.Liability}.Repayment[0].@RepaymentAmount`,
|
|
36
|
+
repaymentFrequency: `${paths.Liability}.Repayment[0].@RepaymentFrequency`,
|
|
37
|
+
remainingTermDuration: `${paths.Liability}.RemainingTerm.@Duration`,
|
|
38
|
+
repaymentTypeDetails: `${paths.Liability}.Repayment[0].@PaymentType`,
|
|
39
|
+
outstandingBalance: `${paths.Liability}.@OutstandingBalance`,
|
|
40
|
+
type: `${paths.Liability}.@Type`,
|
|
41
|
+
percentOwned: `${paths.Liability}.PercentOwned`,
|
|
43
42
|
};
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
set(partialApplication, liabilityMapping.applicationId, applicationId);
|
|
44
|
+
set(partialApplication, liabilityMapping.id, id);
|
|
46
45
|
// Default repayments to 0 and repaymentFrequency to weekly.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
set(partialApplication, liabilityMapping.repaymentAmount, 0);
|
|
47
|
+
set(partialApplication, liabilityMapping.repaymentFrequency, LIXIFrequency.Weekly);
|
|
49
48
|
// Currently repayments is not captured for store cards and credit cards, default the monthly repayment amount to
|
|
50
49
|
// the credit limit with interest rate of 3%.
|
|
51
|
-
if ([
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
if ([LiabilityType.CreditCard, LiabilityType.StoreCard].includes(liability.type) && liability.creditLimit) {
|
|
51
|
+
set(partialApplication, liabilityMapping.repaymentAmount, roundDecimal(liability.creditLimit * 0.03));
|
|
52
|
+
set(partialApplication, liabilityMapping.repaymentFrequency, LIXIFrequency.Monthly);
|
|
54
53
|
}
|
|
55
54
|
// Default clearingFromThisLoan to No if the value is not present in the event.
|
|
56
|
-
|
|
57
|
-
for (
|
|
58
|
-
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
55
|
+
set(partialApplication, liabilityMapping.clearingFromThisLoan, YesNoList.No);
|
|
56
|
+
for (const [key, value] of Object.entries(liability)) {
|
|
59
57
|
if (liabilityMapping[key]) {
|
|
60
58
|
switch (key) {
|
|
61
59
|
case 'outstandingBalance':
|
|
62
60
|
case 'creditLimit':
|
|
63
61
|
case 'newLimit':
|
|
64
62
|
case 'repaymentAmount':
|
|
65
|
-
|
|
63
|
+
set(partialApplication, liabilityMapping[key], roundDecimal(value));
|
|
66
64
|
break;
|
|
67
65
|
case 'interestOnlyRemainingTerm':
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
set(partialApplication, liabilityMapping[key], roundDecimal(value));
|
|
67
|
+
set(partialApplication, `${paths.Liability}.OriginalTerm.@PaymentType`, PaymentTypeList.InterestOnly);
|
|
68
|
+
set(partialApplication, `${paths.Liability}.OriginalTerm.@PaymentTypeUnits`, LoanTermUnitsList.Years);
|
|
71
69
|
break;
|
|
72
70
|
case 'type':
|
|
73
|
-
|
|
71
|
+
set(partialApplication, liabilityMapping[key], liabilityTypeMapping[value]);
|
|
74
72
|
break;
|
|
75
73
|
case 'clearingFromThisLoan':
|
|
76
|
-
|
|
74
|
+
set(partialApplication, liabilityMapping[key], value ? YesNoList.Yes : YesNoList.No);
|
|
77
75
|
break;
|
|
78
76
|
case 'clearingFromOtherSource':
|
|
79
|
-
if (value ===
|
|
80
|
-
|
|
77
|
+
if (value === ClearingFromOtherSource.PayingOut)
|
|
78
|
+
set(partialApplication, liabilityMapping[key], YesNoList.Yes);
|
|
81
79
|
break;
|
|
82
80
|
case 'repaymentFrequency':
|
|
83
|
-
|
|
81
|
+
set(partialApplication, liabilityMapping[key], frequencyMapping[value]);
|
|
84
82
|
break;
|
|
85
83
|
case 'repaymentTypeDetails':
|
|
86
|
-
|
|
84
|
+
set(partialApplication, liabilityMapping[key], liabilityPaymentTypeMapping[value]);
|
|
87
85
|
break;
|
|
88
86
|
case 'remainingTermDuration':
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
set(partialApplication, liabilityMapping[key], Math.round(value * 12));
|
|
88
|
+
set(partialApplication, `${paths.Liability}.RemainingTerm.@Units`, UnitsList.Months);
|
|
91
89
|
break;
|
|
92
90
|
case 'financialInstitution':
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
const financialInstitution = getFinancialInstitution(value.toString()) || FinancialInstitutionList.Other;
|
|
92
|
+
set(partialApplication, liabilityMapping[key], financialInstitution);
|
|
95
93
|
break;
|
|
96
94
|
case 'percentOwned':
|
|
97
|
-
|
|
95
|
+
const percentOwned = transformPercentOwned(value);
|
|
98
96
|
if (percentOwned) {
|
|
99
|
-
|
|
97
|
+
set(partialApplication, liabilityMapping[key], percentOwned);
|
|
100
98
|
}
|
|
101
99
|
break;
|
|
102
100
|
default:
|
|
103
|
-
|
|
101
|
+
set(partialApplication, liabilityMapping[key], value);
|
|
104
102
|
break;
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
105
|
}
|
|
108
106
|
return partialApplication;
|
|
109
107
|
}
|
|
110
|
-
exports.transformLiability = transformLiability;
|
|
@@ -4,6 +4,7 @@ import { PercentOwned as LIXIPercentOwned } from '@lendi/integrations-protocol/l
|
|
|
4
4
|
* Transform percentOwned to lixi's format.
|
|
5
5
|
*
|
|
6
6
|
* @param percentOwned PercentOwned for an asset or liability on public liability event.
|
|
7
|
+
* @param percentOwned.owners
|
|
7
8
|
* @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
|
|
8
9
|
*/
|
|
9
10
|
export declare function transformPercentOwned({ owners }: PercentOwned): LIXIPercentOwned;
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.transformPercentOwned = void 0;
|
|
4
|
-
var round_decimal_1 = require("../utils/round-decimal");
|
|
1
|
+
import { roundDecimal } from '../utils/round-decimal';
|
|
5
2
|
/**
|
|
6
3
|
* Transform percentOwned to lixi's format.
|
|
7
4
|
*
|
|
8
5
|
* @param percentOwned PercentOwned for an asset or liability on public liability event.
|
|
6
|
+
* @param percentOwned.owners
|
|
9
7
|
* @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
|
|
10
8
|
*/
|
|
11
|
-
function transformPercentOwned(
|
|
12
|
-
var _b = _a.owners, owners = _b === void 0 ? [] : _b;
|
|
9
|
+
export function transformPercentOwned({ owners = [] }) {
|
|
13
10
|
if (owners.length === 0)
|
|
14
11
|
return null;
|
|
15
12
|
return {
|
|
16
|
-
Owner: owners.map(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'@x_Party': applicantId
|
|
21
|
-
});
|
|
22
|
-
})
|
|
13
|
+
Owner: owners.map(({ percent, applicantId }) => ({
|
|
14
|
+
'@Percent': roundDecimal(percent * 100),
|
|
15
|
+
'@x_Party': applicantId,
|
|
16
|
+
})),
|
|
23
17
|
};
|
|
24
18
|
}
|
|
25
|
-
exports.transformPercentOwned = transformPercentOwned;
|