@lendi/integrations-transform 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { IncomeElement } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
1
2
|
import { RentalIncome } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
-
import { PartialApplication } from '../types/partial-application';
|
|
3
3
|
import { Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
|
|
4
|
-
import {
|
|
4
|
+
import { PartialApplication } from '../types/partial-application';
|
|
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
|
*
|
|
@@ -15,7 +15,7 @@ export declare function getIncomeMapping(incomeType: IncomeType, basePath?: stri
|
|
|
15
15
|
* @param storedApplication: Current state of 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,6 @@ 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;
|
|
@@ -14,15 +14,15 @@ var _a;
|
|
|
14
14
|
exports.__esModule = true;
|
|
15
15
|
exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
|
|
16
16
|
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
17
|
-
var application_paths_1 = require("@lendi/integrations-protocol/
|
|
17
|
+
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
18
18
|
var lodash_1 = require("lodash");
|
|
19
19
|
var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
20
20
|
var government_benefits_1 = require("../types/enum-mappings/government-benefits");
|
|
21
21
|
var income_type_1 = require("../types/enum-mappings/income-type");
|
|
22
22
|
var public_income_1 = require("../types/events/public-income");
|
|
23
|
+
var is_income_type_1 = require("../utils/is-income-type");
|
|
23
24
|
var round_decimal_1 = require("../utils/round-decimal");
|
|
24
25
|
var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
|
|
25
|
-
var is_income_type_1 = require("../utils/is-income-type");
|
|
26
26
|
var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
27
27
|
var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
28
28
|
// Income types mapping from internal to LIXI types /paths.
|
|
@@ -60,15 +60,17 @@ exports.EmploymentIncomeTypeMapping = (_a = {},
|
|
|
60
60
|
frequency: 'Income.@GrossRegularOvertimeFrequency'
|
|
61
61
|
},
|
|
62
62
|
_a);
|
|
63
|
-
function getIncomeMapping(incomeType
|
|
64
|
-
|
|
63
|
+
function getIncomeMapping(incomeType) {
|
|
64
|
+
var basePath = application_paths_1.paths.OtherIncome;
|
|
65
65
|
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
66
|
+
basePath = application_paths_1.paths.RealEstateAsset;
|
|
66
67
|
return {
|
|
67
68
|
assetId: "".concat(basePath, ".@UniqueID"),
|
|
68
69
|
percentOwned: "".concat(basePath, ".RentalIncome")
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
73
|
+
basePath = application_paths_1.paths.CompanyApplicant;
|
|
72
74
|
return {
|
|
73
75
|
companyId: "".concat(basePath, ".@UniqueID"),
|
|
74
76
|
incomes: "".concat(basePath, ".IncomeRecent"),
|
|
@@ -78,6 +80,7 @@ function getIncomeMapping(incomeType, basePath) {
|
|
|
78
80
|
};
|
|
79
81
|
}
|
|
80
82
|
if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
83
|
+
basePath = application_paths_1.paths.PAYG;
|
|
81
84
|
var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
|
|
82
85
|
var mapping = {
|
|
83
86
|
amount: "".concat(basePath, ".").concat(amount),
|
|
@@ -104,33 +107,18 @@ exports.getIncomeMapping = getIncomeMapping;
|
|
|
104
107
|
* @param storedApplication: Current state of the application.
|
|
105
108
|
* @return partialApplication an incomplete application.
|
|
106
109
|
*/
|
|
107
|
-
function generateIncome(payload,
|
|
110
|
+
function generateIncome(payload, applicantId) {
|
|
108
111
|
var applicationId = payload.applicationId, id = payload.id, income = payload.income;
|
|
109
112
|
var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
|
|
110
113
|
var partialApplication = {};
|
|
111
114
|
(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);
|
|
122
|
-
}
|
|
123
|
-
else if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
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);
|
|
115
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
|
|
116
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
129
117
|
}
|
|
130
|
-
|
|
118
|
+
if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
|
|
131
119
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
|
|
132
|
-
incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.OtherIncome);
|
|
133
120
|
}
|
|
121
|
+
var incomeMapping = getIncomeMapping(incomeType);
|
|
134
122
|
for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
|
|
135
123
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
136
124
|
if (incomeMapping[key]) {
|
|
@@ -155,7 +143,7 @@ function generateIncome(payload, storedApplication) {
|
|
|
155
143
|
case 'type':
|
|
156
144
|
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
157
145
|
var mappedType = income_type_1.otherIncomeMapping[value];
|
|
158
|
-
if ((0, is_income_type_1.
|
|
146
|
+
if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
|
|
159
147
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
|
|
160
148
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
161
149
|
}
|
|
@@ -224,7 +212,7 @@ var selfEmploymentIncomeMapping = {
|
|
|
224
212
|
/**
|
|
225
213
|
* @description Transform a Self Employed Income Details to LIXI
|
|
226
214
|
* @param data Financial Year Income Details for Self Employed Income.
|
|
227
|
-
* @returns {
|
|
215
|
+
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
228
216
|
*/
|
|
229
217
|
function generateIncomeBusinessDetails(data) {
|
|
230
218
|
var income = {};
|
|
@@ -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,38 +21,24 @@ 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
|
|
32
39
|
* @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
|
|
33
40
|
*/
|
|
34
41
|
export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* @description Checks if an Income event is a valid rental income event.
|
|
37
|
-
* @param {Income} income Income.
|
|
38
|
-
* @returns {boolean} true if income type is RENTAL_INCOME and an assetId exists.
|
|
39
|
-
*/
|
|
40
|
-
export declare function isValidRentalIncomeEvent({ assetId, type: incomeType }: Income): boolean;
|
|
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
42
|
/**
|
|
56
43
|
* @description Get the employment ids for an applicant for a specific employment type.
|
|
57
44
|
* @param {PersonApplicant} applicant An applicant
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.sortBusinessIncome = exports.getApplicantId = exports.getStoredApplicantId = exports.getEmploymentIds = exports.
|
|
3
|
+
exports.sortBusinessIncome = exports.getApplicantId = exports.getStoredApplicantId = exports.getEmploymentIds = 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
|
|
@@ -63,50 +82,6 @@ function isFullDocOrLowDocIncome(incomeType) {
|
|
|
63
82
|
return [public_income_1.IncomeType.SelfEmployedBusinessIncomeFullDoc, public_income_1.IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
|
|
64
83
|
}
|
|
65
84
|
exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
|
|
66
|
-
/**
|
|
67
|
-
* @description Checks if an Income event is a valid rental income event.
|
|
68
|
-
* @param {Income} income Income.
|
|
69
|
-
* @returns {boolean} true if income type is RENTAL_INCOME and an assetId exists.
|
|
70
|
-
*/
|
|
71
|
-
function isValidRentalIncomeEvent(_a) {
|
|
72
|
-
var assetId = _a.assetId, incomeType = _a.type;
|
|
73
|
-
return isRentalIncome(incomeType) && !!assetId;
|
|
74
|
-
}
|
|
75
|
-
exports.isValidRentalIncomeEvent = isValidRentalIncomeEvent;
|
|
76
|
-
/**
|
|
77
|
-
* @description Is event valid PAYG income event.
|
|
78
|
-
* @param {Income} income Income.
|
|
79
|
-
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
80
|
-
* @returns {boolean} true if Income type is a PAYG value and event is valid PAYG event.
|
|
81
|
-
*/
|
|
82
|
-
function isValidPaygIncomeEvent(_a, applicants) {
|
|
83
|
-
var percentOwned = _a.percentOwned, employmentId = _a.employmentId, incomeType = _a.type;
|
|
84
|
-
if (applicants === void 0) { applicants = []; }
|
|
85
|
-
if (!isPaygIncome(incomeType))
|
|
86
|
-
return false;
|
|
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
85
|
/**
|
|
111
86
|
* @description Get the employment ids for an applicant for a specific employment type.
|
|
112
87
|
* @param {PersonApplicant} applicant An applicant
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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,7 +21,7 @@
|
|
|
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.
|
|
24
|
+
"@lendi/integrations-credit-protocol": "1.14.4",
|
|
25
25
|
"@lendi/integrations-protocol": "2.3.0",
|
|
26
26
|
"clean-deep": "^3.4.0",
|
|
27
27
|
"date-fns": "2.19.0",
|