@lendi/integrations-transform 1.1.2 → 1.1.8
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/transform-events/generate-asset.js +4 -4
- package/lib/transform-events/generate-income.d.ts +11 -7
- package/lib/transform-events/generate-income.js +61 -41
- package/lib/types/enum-mappings/funding-position.d.ts +1 -1
- package/lib/types/enum-mappings/funding-position.js +2 -2
- package/lib/types/enum-mappings/income-type.d.ts +2 -2
- package/lib/types/enum-mappings/income-type.js +2 -2
- package/lib/types/enum-mappings/public-property-type.d.ts +2 -2
- package/lib/types/enum-mappings/public-property-type.js +2 -2
- package/lib/utils/is-income-type.d.ts +22 -34
- package/lib/utils/is-income-type.js +54 -80
- package/package.json +3 -3
|
@@ -36,7 +36,7 @@ var assetMapping = {
|
|
|
36
36
|
address: application_paths_1.paths.Address
|
|
37
37
|
};
|
|
38
38
|
exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
|
|
39
|
-
exports.propertyTypeNameList = Object.values(lixi_internal_request_1.
|
|
39
|
+
exports.propertyTypeNameList = Object.values(lixi_internal_request_1.Custom2PropertyTypeNameList);
|
|
40
40
|
/**
|
|
41
41
|
* Generates a partial internal request from a partial public asset event.
|
|
42
42
|
*
|
|
@@ -119,7 +119,7 @@ function generateAsset(_a) {
|
|
|
119
119
|
}
|
|
120
120
|
else if (exports.propertyTypeNameList.includes(mappedValue)) {
|
|
121
121
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@PropertyTypeName"), mappedValue);
|
|
122
|
-
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@CategoryTypeName"), lixi_internal_request_1.
|
|
122
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@CategoryTypeName"), lixi_internal_request_1.Custom1CategoryTypeNameList.Residential);
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
125
|
logger_1.logger.warn({ message: "Unknown propertyType ".concat(value, " for asset ").concat(id), applicationId: applicationId });
|
|
@@ -128,10 +128,10 @@ function generateAsset(_a) {
|
|
|
128
128
|
case 'zoneType':
|
|
129
129
|
if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
|
|
130
130
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Commercial.@Type"), lixi_internal_request_1.OtherAssetTypeList.Other);
|
|
131
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.
|
|
131
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom3TypeList.Commercial);
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
134
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.
|
|
134
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom3TypeList.Residential);
|
|
135
135
|
}
|
|
136
136
|
break;
|
|
137
137
|
case 'financialInstitution':
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
+
import { IncomeBusinessActivityStatement, IncomeElement } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
1
2
|
import { RentalIncome } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
3
|
+
import { BASDefinition, Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
|
|
2
4
|
import { PartialApplication } from '../types/partial-application';
|
|
3
|
-
import { Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
|
|
4
|
-
import { IncomeRecent } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
5
5
|
export interface AmountFrequency {
|
|
6
6
|
amount: string;
|
|
7
7
|
frequency?: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const EmploymentIncomeTypeMapping: Record<string, AmountFrequency>;
|
|
10
|
-
export declare function getIncomeMapping(incomeType: IncomeType
|
|
10
|
+
export declare function getIncomeMapping(incomeType: IncomeType): Record<string, string>;
|
|
11
11
|
/**
|
|
12
12
|
* Generates an partial application from a partial income event.
|
|
13
13
|
*
|
|
14
14
|
* @param payload a partial income event.
|
|
15
|
-
* @param
|
|
15
|
+
* @param applicantId PersonApplicant uniqueId on the application.
|
|
16
16
|
* @return partialApplication an incomplete application.
|
|
17
17
|
*/
|
|
18
|
-
export declare function generateIncome(payload: IncomePayload,
|
|
18
|
+
export declare function generateIncome(payload: IncomePayload, applicantId?: string): PartialApplication;
|
|
19
19
|
/**
|
|
20
20
|
* Creates Rental Income array.
|
|
21
21
|
* @param amount Amount
|
|
@@ -32,6 +32,10 @@ export interface SelfEmploymentIncomeMapping {
|
|
|
32
32
|
/**
|
|
33
33
|
* @description Transform a Self Employed Income Details to LIXI
|
|
34
34
|
* @param data Financial Year Income Details for Self Employed Income.
|
|
35
|
-
* @returns {
|
|
35
|
+
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
36
36
|
*/
|
|
37
|
-
export declare function generateIncomeBusinessDetails(data: IncomeBusinessDetails):
|
|
37
|
+
export declare function generateIncomeBusinessDetails(data: IncomeBusinessDetails): IncomeElement;
|
|
38
|
+
/**
|
|
39
|
+
* Generates the BAS array from the bas definition on the event.
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateBAS(bas: BASDefinition[]): IncomeBusinessActivityStatement[];
|
|
@@ -1,4 +1,15 @@
|
|
|
1
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
|
+
};
|
|
2
13
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
14
|
var t = {};
|
|
4
15
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -12,17 +23,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
23
|
};
|
|
13
24
|
var _a;
|
|
14
25
|
exports.__esModule = true;
|
|
15
|
-
exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
|
|
26
|
+
exports.generateBAS = exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
|
|
16
27
|
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
17
|
-
var application_paths_1 = require("@lendi/integrations-protocol/
|
|
28
|
+
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
18
29
|
var lodash_1 = require("lodash");
|
|
19
30
|
var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
20
31
|
var government_benefits_1 = require("../types/enum-mappings/government-benefits");
|
|
21
32
|
var income_type_1 = require("../types/enum-mappings/income-type");
|
|
22
33
|
var public_income_1 = require("../types/events/public-income");
|
|
34
|
+
var is_income_type_1 = require("../utils/is-income-type");
|
|
23
35
|
var round_decimal_1 = require("../utils/round-decimal");
|
|
24
36
|
var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
|
|
25
|
-
var is_income_type_1 = require("../utils/is-income-type");
|
|
26
37
|
var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
27
38
|
var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
28
39
|
// Income types mapping from internal to LIXI types /paths.
|
|
@@ -60,33 +71,36 @@ exports.EmploymentIncomeTypeMapping = (_a = {},
|
|
|
60
71
|
frequency: 'Income.@GrossRegularOvertimeFrequency'
|
|
61
72
|
},
|
|
62
73
|
_a);
|
|
63
|
-
function getIncomeMapping(incomeType
|
|
64
|
-
|
|
74
|
+
function getIncomeMapping(incomeType) {
|
|
75
|
+
var basePath = application_paths_1.paths.OtherIncome;
|
|
65
76
|
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
77
|
+
basePath = application_paths_1.paths.RealEstateAsset;
|
|
66
78
|
return {
|
|
67
79
|
assetId: "".concat(basePath, ".@UniqueID"),
|
|
68
80
|
percentOwned: "".concat(basePath, ".RentalIncome")
|
|
69
81
|
};
|
|
70
82
|
}
|
|
71
83
|
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
84
|
+
basePath = application_paths_1.paths.CompanyApplicant;
|
|
72
85
|
return {
|
|
86
|
+
bas: "".concat(basePath, ".Income[0].BusinessActivityStatement"),
|
|
73
87
|
companyId: "".concat(basePath, ".@UniqueID"),
|
|
74
|
-
incomes: "".concat(basePath, ".
|
|
75
|
-
incomeRecent: "".concat(basePath, ".IncomeRecent"),
|
|
76
|
-
incomePrevious: "".concat(basePath, ".IncomePrevious"),
|
|
88
|
+
incomes: "".concat(basePath, ".Income"),
|
|
77
89
|
gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
|
|
78
90
|
};
|
|
79
91
|
}
|
|
80
|
-
if ((0, is_income_type_1.
|
|
81
|
-
|
|
82
|
-
var
|
|
92
|
+
if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
|
|
93
|
+
basePath = application_paths_1.paths.SelfEmployed;
|
|
94
|
+
var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
|
|
95
|
+
return {
|
|
83
96
|
amount: "".concat(basePath, ".").concat(amount),
|
|
84
97
|
employmentId: "".concat(basePath, ".@UniqueID")
|
|
85
98
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
}
|
|
100
|
+
if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
101
|
+
basePath = application_paths_1.paths.PAYG;
|
|
102
|
+
var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
|
|
103
|
+
return __assign({ amount: "".concat(basePath, ".").concat(amount), employmentId: "".concat(basePath, ".@UniqueID") }, (frequency && { frequency: "".concat(basePath, ".").concat(frequency) }));
|
|
90
104
|
}
|
|
91
105
|
return {
|
|
92
106
|
amount: "".concat(basePath, ".@Amount"),
|
|
@@ -101,36 +115,21 @@ exports.getIncomeMapping = getIncomeMapping;
|
|
|
101
115
|
* Generates an partial application from a partial income event.
|
|
102
116
|
*
|
|
103
117
|
* @param payload a partial income event.
|
|
104
|
-
* @param
|
|
118
|
+
* @param applicantId PersonApplicant uniqueId on the application.
|
|
105
119
|
* @return partialApplication an incomplete application.
|
|
106
120
|
*/
|
|
107
|
-
function generateIncome(payload,
|
|
121
|
+
function generateIncome(payload, applicantId) {
|
|
108
122
|
var applicationId = payload.applicationId, id = payload.id, income = payload.income;
|
|
109
123
|
var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
|
|
110
124
|
var partialApplication = {};
|
|
111
125
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
112
|
-
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
113
|
-
|
|
114
|
-
var applicantId = (0, is_income_type_1.getApplicantId)(income, applicants);
|
|
115
|
-
if (applicantId) {
|
|
116
|
-
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
var incomeMapping;
|
|
120
|
-
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
121
|
-
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.RealEstateAsset);
|
|
126
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
|
|
127
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
122
128
|
}
|
|
123
|
-
|
|
124
|
-
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.PAYG);
|
|
125
|
-
}
|
|
126
|
-
else if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
127
|
-
var basePath = 'Package.Content.Application.CompanyApplicant[0]';
|
|
128
|
-
incomeMapping = getIncomeMapping(incomeType, basePath);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
129
|
+
if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
|
|
131
130
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
|
|
132
|
-
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.OtherIncome);
|
|
133
131
|
}
|
|
132
|
+
var incomeMapping = getIncomeMapping(incomeType);
|
|
134
133
|
for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
|
|
135
134
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
136
135
|
if (incomeMapping[key]) {
|
|
@@ -139,6 +138,11 @@ function generateIncome(payload, storedApplication) {
|
|
|
139
138
|
var amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
|
|
140
139
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
|
|
141
140
|
break;
|
|
141
|
+
case 'bas':
|
|
142
|
+
var basWithAmount = value.filter(function (bas) { return bas.salesAmount !== undefined || false; });
|
|
143
|
+
if (!(0, lodash_1.isEmpty)(basWithAmount))
|
|
144
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], generateBAS(basWithAmount));
|
|
145
|
+
break;
|
|
142
146
|
case 'frequency':
|
|
143
147
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
|
|
144
148
|
break;
|
|
@@ -155,7 +159,7 @@ function generateIncome(payload, storedApplication) {
|
|
|
155
159
|
case 'type':
|
|
156
160
|
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
157
161
|
var mappedType = income_type_1.otherIncomeMapping[value];
|
|
158
|
-
if ((0, is_income_type_1.
|
|
162
|
+
if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
|
|
159
163
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
|
|
160
164
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
161
165
|
}
|
|
@@ -171,7 +175,7 @@ function generateIncome(payload, storedApplication) {
|
|
|
171
175
|
var sortedIncomeList = value
|
|
172
176
|
.sort(is_income_type_1.sortBusinessIncome)
|
|
173
177
|
.map(generateIncomeBusinessDetails);
|
|
174
|
-
(0, lodash_1.set)(partialApplication,
|
|
178
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], sortedIncomeList);
|
|
175
179
|
break;
|
|
176
180
|
default:
|
|
177
181
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], value);
|
|
@@ -215,7 +219,7 @@ var selfEmploymentIncomeMapping = {
|
|
|
215
219
|
interest: 'Addback.@Interest',
|
|
216
220
|
lease: 'Addback.@Lease',
|
|
217
221
|
nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
|
|
218
|
-
other: 'Addback.@
|
|
222
|
+
other: 'Addback.OtherAddback[0].@Amount',
|
|
219
223
|
salary: 'Addback.@Salary',
|
|
220
224
|
superannuationExcess: 'Addback.@SuperannuationExcess'
|
|
221
225
|
},
|
|
@@ -224,20 +228,26 @@ var selfEmploymentIncomeMapping = {
|
|
|
224
228
|
/**
|
|
225
229
|
* @description Transform a Self Employed Income Details to LIXI
|
|
226
230
|
* @param data Financial Year Income Details for Self Employed Income.
|
|
227
|
-
* @returns {
|
|
231
|
+
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
228
232
|
*/
|
|
229
233
|
function generateIncomeBusinessDetails(data) {
|
|
230
234
|
var income = {};
|
|
231
235
|
var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
|
|
232
236
|
for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
|
|
233
237
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
234
|
-
if (selfEmploymentIncomeMapping[key]
|
|
238
|
+
if (selfEmploymentIncomeMapping[key] !== null) {
|
|
235
239
|
if (key === 'addback') {
|
|
236
240
|
for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
|
|
237
241
|
var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
|
|
242
|
+
if (addbackKey === 'other') {
|
|
243
|
+
(0, lodash_1.set)(income, 'Addback.OtherAddback[0].@Description', 'other');
|
|
244
|
+
}
|
|
238
245
|
(0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
|
|
239
246
|
}
|
|
240
247
|
}
|
|
248
|
+
else if (key === 'year') {
|
|
249
|
+
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value.toString());
|
|
250
|
+
}
|
|
241
251
|
else {
|
|
242
252
|
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
|
|
243
253
|
}
|
|
@@ -246,3 +256,13 @@ function generateIncomeBusinessDetails(data) {
|
|
|
246
256
|
return income;
|
|
247
257
|
}
|
|
248
258
|
exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
|
|
259
|
+
/**
|
|
260
|
+
* Generates the BAS array from the bas definition on the event.
|
|
261
|
+
*/
|
|
262
|
+
function generateBAS(bas) {
|
|
263
|
+
return bas.map(function (bas) { return ({
|
|
264
|
+
'@Quarter': bas.quarter,
|
|
265
|
+
'@SalesAmount': bas.salesAmount
|
|
266
|
+
}); });
|
|
267
|
+
}
|
|
268
|
+
exports.generateBAS = generateBAS;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeeCategoryList, FeeTypeList,
|
|
1
|
+
import { FeeCategoryList, FeeTypeList, Custom4DescriptionList as DescriptionList, ContributionFundsTypeList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
2
|
declare type CategoryMapping = {
|
|
3
3
|
[key: string]: FeeCategoryList;
|
|
4
4
|
};
|
|
@@ -25,8 +25,8 @@ exports.typeMapping = {
|
|
|
25
25
|
foreignBuyerSurcharge: lixi_internal_request_1.FeeTypeList.Other
|
|
26
26
|
};
|
|
27
27
|
exports.descriptionMapping = {
|
|
28
|
-
accruedInterest: lixi_internal_request_1.
|
|
29
|
-
otherSundries: lixi_internal_request_1.
|
|
28
|
+
accruedInterest: lixi_internal_request_1.Custom4DescriptionList.PotentialAccruedInterest,
|
|
29
|
+
otherSundries: lixi_internal_request_1.Custom4DescriptionList.OtherSundries
|
|
30
30
|
};
|
|
31
31
|
exports.contributionMapping = {
|
|
32
32
|
totalGovernmentContributions: lixi_internal_request_1.ContributionFundsTypeList.FirstHomeOwnerGrant,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OtherIncomeTypeList,
|
|
1
|
+
import { OtherIncomeTypeList, Custom0DescriptionList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
2
|
import { IncomeType } from '../events/public-income';
|
|
3
3
|
declare type OtherIncomeMapping = {
|
|
4
|
-
[key in IncomeType]: OtherIncomeTypeList |
|
|
4
|
+
[key in IncomeType]: OtherIncomeTypeList | Custom0DescriptionList;
|
|
5
5
|
};
|
|
6
6
|
export declare const otherIncomeMapping: Partial<OtherIncomeMapping>;
|
|
7
7
|
export {};
|
|
@@ -8,9 +8,9 @@ exports.otherIncomeMapping = (_a = {},
|
|
|
8
8
|
_a[public_income_1.IncomeType.ChildMaintenance] = lixi_internal_request_1.OtherIncomeTypeList.ChildMaintenance,
|
|
9
9
|
_a[public_income_1.IncomeType.ForeignIncome] = lixi_internal_request_1.OtherIncomeTypeList.ForeignSourced,
|
|
10
10
|
_a[public_income_1.IncomeType.GovtBenefit] = lixi_internal_request_1.OtherIncomeTypeList.GovernmentBenefits,
|
|
11
|
-
_a[public_income_1.IncomeType.InvestmentIncome] = lixi_internal_request_1.
|
|
11
|
+
_a[public_income_1.IncomeType.InvestmentIncome] = lixi_internal_request_1.Custom0DescriptionList.InvestmentIncome,
|
|
12
12
|
_a[public_income_1.IncomeType.OtherIncome] = lixi_internal_request_1.OtherIncomeTypeList.OtherIncome,
|
|
13
|
-
_a[public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax] = lixi_internal_request_1.
|
|
13
|
+
_a[public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax] = lixi_internal_request_1.Custom0DescriptionList.PAYGNonVoluntaryDeductionsPreTax,
|
|
14
14
|
_a[public_income_1.IncomeType.PaygSalarySacrifice] = lixi_internal_request_1.OtherIncomeTypeList.SalarySacrificeContribution,
|
|
15
15
|
_a[public_income_1.IncomeType.SuperAnnuityPension] = lixi_internal_request_1.OtherIncomeTypeList.Superannuation,
|
|
16
16
|
_a[public_income_1.IncomeType.WorkersCompensation] = lixi_internal_request_1.OtherIncomeTypeList.WorkersCompensation,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropertyType } from '../events/public-asset';
|
|
2
|
-
import { ResidentialTypeList,
|
|
2
|
+
import { ResidentialTypeList, Custom2PropertyTypeNameList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
3
3
|
declare type PropertyTypeMapping = {
|
|
4
|
-
[key in PropertyType]: ResidentialTypeList |
|
|
4
|
+
[key in PropertyType]: ResidentialTypeList | Custom2PropertyTypeNameList;
|
|
5
5
|
};
|
|
6
6
|
export declare const propertyTypeMapping: PropertyTypeMapping;
|
|
7
7
|
export {};
|
|
@@ -19,6 +19,6 @@ exports.propertyTypeMapping = (_a = {},
|
|
|
19
19
|
_a[public_asset_1.PropertyType.Townhouse] = lixi_internal_request_1.ResidentialTypeList.Townhouse,
|
|
20
20
|
_a[public_asset_1.PropertyType.Villa] = lixi_internal_request_1.ResidentialTypeList.Villa,
|
|
21
21
|
_a[public_asset_1.PropertyType.WarehouseApartment] = lixi_internal_request_1.ResidentialTypeList.StudioWarehouseApartment,
|
|
22
|
-
_a[public_asset_1.PropertyType.PropertyOver10_Ha] = lixi_internal_request_1.
|
|
23
|
-
_a[public_asset_1.PropertyType.MultiDwellingSingleTitle] = lixi_internal_request_1.
|
|
22
|
+
_a[public_asset_1.PropertyType.PropertyOver10_Ha] = lixi_internal_request_1.Custom2PropertyTypeNameList.PropertyOver10HA,
|
|
23
|
+
_a[public_asset_1.PropertyType.MultiDwellingSingleTitle] = lixi_internal_request_1.Custom2PropertyTypeNameList.MultiDwellingSingleTitle,
|
|
24
24
|
_a);
|
|
@@ -2,6 +2,7 @@ import { PersonApplicant } from '@lendi/integrations-protocol/lib/types/lixi-int
|
|
|
2
2
|
import { IncomeType, Income, IncomeBusinessDetails } from '../types/events/public-income';
|
|
3
3
|
export declare const descriptionOtherIncomeTypes: string[];
|
|
4
4
|
export declare const PAYGList: string[];
|
|
5
|
+
export declare const otherIncomeList: IncomeType[];
|
|
5
6
|
/**
|
|
6
7
|
* @description Is income type one of the PAYG income.
|
|
7
8
|
* @param {string} incomeType Income type.
|
|
@@ -20,12 +21,18 @@ export declare function isSelfEmployedIncome(incomeType: string): boolean;
|
|
|
20
21
|
* @returns {boolean} true if Income type is Rental Income.
|
|
21
22
|
*/
|
|
22
23
|
export declare function isRentalIncome(incomeType: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @description Is income type grouped as OtherIncome.
|
|
26
|
+
* @param {IncomeType} incomeType Income type.
|
|
27
|
+
* @returns {boolean} true if income is of type other income.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isOtherIncome(incomeType: IncomeType): boolean;
|
|
23
30
|
/**
|
|
24
31
|
* @description Is Income type one of OtherIncome types.
|
|
25
32
|
* @param {IncomeType} incomeType Income Type.
|
|
26
33
|
* @returns {boolean} returns true for other income.
|
|
27
34
|
*/
|
|
28
|
-
export declare function
|
|
35
|
+
export declare function isOtherIncomeWithDesc(incomeType: string): boolean;
|
|
29
36
|
/**
|
|
30
37
|
* @description Is Self Employed Full Doc or Low Doc Income
|
|
31
38
|
* @param incomeType Income Type from Event
|
|
@@ -33,40 +40,21 @@ export declare function isOtherIncome(incomeType: string): boolean;
|
|
|
33
40
|
*/
|
|
34
41
|
export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
|
|
35
42
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @description Is event valid PAYG income event.
|
|
43
|
-
* @param {Income} income Income.
|
|
44
|
-
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
45
|
-
* @returns {boolean} true if Income type is a PAYG value and event is valid PAYG event.
|
|
46
|
-
*/
|
|
47
|
-
export declare function isValidPaygIncomeEvent({ percentOwned, employmentId, type: incomeType }: Income, applicants?: PersonApplicant[]): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* @description Checks if an Income event is a valid self-employment income event.
|
|
50
|
-
* @param {Income} income Income.
|
|
51
|
-
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
52
|
-
* @returns {boolean} Returns true if event is a valid self employment income event.
|
|
53
|
-
*/
|
|
54
|
-
export declare function isValidSelfEmployedIncomeEvent({ percentOwned, employmentId, type: incomeType }: Income, applicants?: PersonApplicant[]): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* @description Get the employment ids for an applicant for a specific employment type.
|
|
57
|
-
* @param {PersonApplicant} applicant An applicant
|
|
58
|
-
* @param {string} key Employment type key: PAYG or SelfEmployed.
|
|
59
|
-
* @returns {string[]} An array of employment ids for the applicant of the specified type.
|
|
43
|
+
* Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
|
|
44
|
+
*
|
|
45
|
+
* @param {PersonApplicant} applicant - An applicant
|
|
46
|
+
* @param {string} employmentId - Employment id being searched for
|
|
47
|
+
* @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
|
|
60
48
|
*/
|
|
61
|
-
export declare
|
|
49
|
+
export declare const hasMatchingEmploymentId: (applicant: PersonApplicant, employmentId: string) => boolean;
|
|
62
50
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @param {
|
|
66
|
-
* @param {string}
|
|
67
|
-
* @returns {string | undefined}
|
|
51
|
+
* Gets the applicant id using the employment id
|
|
52
|
+
*
|
|
53
|
+
* @param {PersonApplicant[]} applicants - An array of applicants.
|
|
54
|
+
* @param {string} employmentId - Employment ID
|
|
55
|
+
* @returns {string | undefined} - Applicant id or undefined
|
|
68
56
|
*/
|
|
69
|
-
export declare function
|
|
57
|
+
export declare function getApplicantIdFromEmploymentId(applicants: PersonApplicant[], employmentId: string): string | undefined;
|
|
70
58
|
/**
|
|
71
59
|
* @description Get an applicantId from the event or the applicants.
|
|
72
60
|
* @param {Income} income Income.
|
|
@@ -78,6 +66,6 @@ export declare function getApplicantId({ percentOwned, employmentId }: Income, a
|
|
|
78
66
|
* @description Sort Business Income By Year.
|
|
79
67
|
* @param incomeA Income Details for Self Employed Full Doc.
|
|
80
68
|
* @param incomeB Income Details for Self Employed Full Doc.
|
|
81
|
-
* @returns {0 |
|
|
69
|
+
* @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
|
|
82
70
|
*/
|
|
83
|
-
export declare
|
|
71
|
+
export declare const sortBusinessIncome: ({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails) => number;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.sortBusinessIncome = exports.getApplicantId = exports.
|
|
3
|
+
exports.sortBusinessIncome = exports.getApplicantId = exports.getApplicantIdFromEmploymentId = exports.hasMatchingEmploymentId = exports.isFullDocOrLowDocIncome = exports.isOtherIncomeWithDesc = exports.isOtherIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.otherIncomeList = exports.PAYGList = exports.descriptionOtherIncomeTypes = void 0;
|
|
4
4
|
var lodash_1 = require("lodash");
|
|
5
5
|
var public_income_1 = require("../types/events/public-income");
|
|
6
6
|
exports.descriptionOtherIncomeTypes = [
|
|
7
7
|
public_income_1.IncomeType.InvestmentIncome,
|
|
8
8
|
public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
|
|
9
|
-
public_income_1.IncomeType.RentalIncome,
|
|
10
9
|
];
|
|
11
10
|
exports.PAYGList = [
|
|
12
11
|
public_income_1.IncomeType.PaygAllowancesNotTaxed,
|
|
@@ -18,6 +17,17 @@ exports.PAYGList = [
|
|
|
18
17
|
public_income_1.IncomeType.PaygCompanyCar,
|
|
19
18
|
public_income_1.IncomeType.PaygOvertimeIncome,
|
|
20
19
|
];
|
|
20
|
+
exports.otherIncomeList = [
|
|
21
|
+
public_income_1.IncomeType.ChildMaintenance,
|
|
22
|
+
public_income_1.IncomeType.ForeignIncome,
|
|
23
|
+
public_income_1.IncomeType.GovtBenefit,
|
|
24
|
+
public_income_1.IncomeType.InvestmentIncome,
|
|
25
|
+
public_income_1.IncomeType.OtherIncome,
|
|
26
|
+
public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
|
|
27
|
+
public_income_1.IncomeType.PaygSalarySacrifice,
|
|
28
|
+
public_income_1.IncomeType.SuperAnnuityPension,
|
|
29
|
+
public_income_1.IncomeType.WorkersCompensation,
|
|
30
|
+
];
|
|
21
31
|
/**
|
|
22
32
|
* @description Is income type one of the PAYG income.
|
|
23
33
|
* @param {string} incomeType Income type.
|
|
@@ -45,15 +55,24 @@ function isRentalIncome(incomeType) {
|
|
|
45
55
|
return incomeType === public_income_1.IncomeType.RentalIncome;
|
|
46
56
|
}
|
|
47
57
|
exports.isRentalIncome = isRentalIncome;
|
|
58
|
+
/**
|
|
59
|
+
* @description Is income type grouped as OtherIncome.
|
|
60
|
+
* @param {IncomeType} incomeType Income type.
|
|
61
|
+
* @returns {boolean} true if income is of type other income.
|
|
62
|
+
*/
|
|
63
|
+
function isOtherIncome(incomeType) {
|
|
64
|
+
return exports.otherIncomeList.includes(incomeType);
|
|
65
|
+
}
|
|
66
|
+
exports.isOtherIncome = isOtherIncome;
|
|
48
67
|
/**
|
|
49
68
|
* @description Is Income type one of OtherIncome types.
|
|
50
69
|
* @param {IncomeType} incomeType Income Type.
|
|
51
70
|
* @returns {boolean} returns true for other income.
|
|
52
71
|
*/
|
|
53
|
-
function
|
|
72
|
+
function isOtherIncomeWithDesc(incomeType) {
|
|
54
73
|
return exports.descriptionOtherIncomeTypes.includes(incomeType);
|
|
55
74
|
}
|
|
56
|
-
exports.
|
|
75
|
+
exports.isOtherIncomeWithDesc = isOtherIncomeWithDesc;
|
|
57
76
|
/**
|
|
58
77
|
* @description Is Self Employed Full Doc or Low Doc Income
|
|
59
78
|
* @param incomeType Income Type from Event
|
|
@@ -64,76 +83,37 @@ function isFullDocOrLowDocIncome(incomeType) {
|
|
|
64
83
|
}
|
|
65
84
|
exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
|
|
66
85
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
86
|
+
* Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
|
|
87
|
+
*
|
|
88
|
+
* @param {PersonApplicant} applicant - An applicant
|
|
89
|
+
* @param {string} employmentId - Employment id being searched for
|
|
90
|
+
* @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
|
|
70
91
|
*/
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
var hasMatchingEmploymentId = function (applicant, employmentId) {
|
|
93
|
+
return (applicant.Employment || []).some(function (employment) {
|
|
94
|
+
var id = (0, lodash_1.get)(employment, 'PAYG.@UniqueID') ||
|
|
95
|
+
(0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') ||
|
|
96
|
+
(0, lodash_1.get)(employment, 'NotEmployed.@UniqueID');
|
|
97
|
+
return id === employmentId;
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
|
|
76
101
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
80
|
-
* @
|
|
102
|
+
* Gets the applicant id using the employment id
|
|
103
|
+
*
|
|
104
|
+
* @param {PersonApplicant[]} applicants - An array of applicants.
|
|
105
|
+
* @param {string} employmentId - Employment ID
|
|
106
|
+
* @returns {string | undefined} - Applicant id or undefined
|
|
81
107
|
*/
|
|
82
|
-
function
|
|
83
|
-
var
|
|
84
|
-
if (applicants
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var applicantId = (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getStoredApplicantId(applicants, employmentId, 'PAYG');
|
|
88
|
-
if (!applicantId)
|
|
89
|
-
return false;
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
exports.isValidPaygIncomeEvent = isValidPaygIncomeEvent;
|
|
93
|
-
/**
|
|
94
|
-
* @description Checks if an Income event is a valid self-employment income event.
|
|
95
|
-
* @param {Income} income Income.
|
|
96
|
-
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
97
|
-
* @returns {boolean} Returns true if event is a valid self employment income event.
|
|
98
|
-
*/
|
|
99
|
-
function isValidSelfEmployedIncomeEvent(_a, applicants) {
|
|
100
|
-
var percentOwned = _a.percentOwned, employmentId = _a.employmentId, incomeType = _a.type;
|
|
101
|
-
if (applicants === void 0) { applicants = []; }
|
|
102
|
-
if (!isFullDocOrLowDocIncome(incomeType))
|
|
103
|
-
return false;
|
|
104
|
-
var applicantId = (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getStoredApplicantId(applicants, employmentId, 'PAYG');
|
|
105
|
-
if (!applicantId)
|
|
106
|
-
return false;
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
exports.isValidSelfEmployedIncomeEvent = isValidSelfEmployedIncomeEvent;
|
|
110
|
-
/**
|
|
111
|
-
* @description Get the employment ids for an applicant for a specific employment type.
|
|
112
|
-
* @param {PersonApplicant} applicant An applicant
|
|
113
|
-
* @param {string} key Employment type key: PAYG or SelfEmployed.
|
|
114
|
-
* @returns {string[]} An array of employment ids for the applicant of the specified type.
|
|
115
|
-
*/
|
|
116
|
-
function getEmploymentIds(applicant, key) {
|
|
117
|
-
return (0, lodash_1.compact)(applicant.Employment.flatMap(function (employment) { return (0, lodash_1.get)(employment, "".concat(key, ".@UniqueID")); }));
|
|
118
|
-
}
|
|
119
|
-
exports.getEmploymentIds = getEmploymentIds;
|
|
120
|
-
/**
|
|
121
|
-
* @description Get applicantId from an array of applicants given an employmentId and employmentType.
|
|
122
|
-
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
123
|
-
* @param {string} employmentId EmploymentId
|
|
124
|
-
* @param {string} key Employment type: PAYG or SelfEmployed
|
|
125
|
-
* @returns {string | undefined} Returns applicantId or undefined.
|
|
126
|
-
*/
|
|
127
|
-
function getStoredApplicantId(applicants, employmentId, key) {
|
|
128
|
-
for (var _i = 0, applicants_1 = applicants; _i < applicants_1.length; _i++) {
|
|
129
|
-
var applicant = applicants_1[_i];
|
|
130
|
-
var employmentIds = getEmploymentIds(applicant, key);
|
|
131
|
-
if (employmentIds.includes(employmentId))
|
|
132
|
-
return applicant['@UniqueID'];
|
|
108
|
+
function getApplicantIdFromEmploymentId(applicants, employmentId) {
|
|
109
|
+
var applicantId;
|
|
110
|
+
if (applicants && employmentId) {
|
|
111
|
+
var applicant = applicants.find(function (applicant) { return (0, exports.hasMatchingEmploymentId)(applicant, employmentId); });
|
|
112
|
+
applicantId = applicant === null || applicant === void 0 ? void 0 : applicant['@UniqueID'];
|
|
133
113
|
}
|
|
134
|
-
return
|
|
114
|
+
return applicantId;
|
|
135
115
|
}
|
|
136
|
-
exports.
|
|
116
|
+
exports.getApplicantIdFromEmploymentId = getApplicantIdFromEmploymentId;
|
|
137
117
|
/**
|
|
138
118
|
* @description Get an applicantId from the event or the applicants.
|
|
139
119
|
* @param {Income} income Income.
|
|
@@ -143,24 +123,18 @@ exports.getStoredApplicantId = getStoredApplicantId;
|
|
|
143
123
|
function getApplicantId(_a, applicants) {
|
|
144
124
|
var percentOwned = _a.percentOwned, employmentId = _a.employmentId;
|
|
145
125
|
if (applicants === void 0) { applicants = []; }
|
|
146
|
-
return (
|
|
147
|
-
getStoredApplicantId(applicants, employmentId, 'PAYG') ||
|
|
148
|
-
getStoredApplicantId(applicants, employmentId, 'SelfEmployed'));
|
|
126
|
+
return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
|
|
149
127
|
}
|
|
150
128
|
exports.getApplicantId = getApplicantId;
|
|
151
129
|
/**
|
|
152
130
|
* @description Sort Business Income By Year.
|
|
153
131
|
* @param incomeA Income Details for Self Employed Full Doc.
|
|
154
132
|
* @param incomeB Income Details for Self Employed Full Doc.
|
|
155
|
-
* @returns {0 |
|
|
133
|
+
* @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
|
|
156
134
|
*/
|
|
157
|
-
function
|
|
135
|
+
var sortBusinessIncome = function (_a, _b) {
|
|
158
136
|
var _c = _a.year, yearA = _c === void 0 ? 0 : _c;
|
|
159
137
|
var _d = _b.year, yearB = _d === void 0 ? 0 : _d;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (yearB > yearA)
|
|
163
|
-
return 1;
|
|
164
|
-
return 0;
|
|
165
|
-
}
|
|
138
|
+
return yearB - yearA;
|
|
139
|
+
};
|
|
166
140
|
exports.sortBusinessIncome = sortBusinessIncome;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Library for kafka event data transforming",
|
|
5
5
|
"author": "Integrations <integrations@lendi.com.au>",
|
|
6
6
|
"homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@lendi/integrations-credit-protocol": "1.
|
|
25
|
-
"@lendi/integrations-protocol": "2.
|
|
24
|
+
"@lendi/integrations-credit-protocol": "1.14.7",
|
|
25
|
+
"@lendi/integrations-protocol": "2.4.9",
|
|
26
26
|
"clean-deep": "^3.4.0",
|
|
27
27
|
"date-fns": "2.19.0",
|
|
28
28
|
"dd-trace": "^0.28.1",
|