@lendi/act-credit-decisions-transform 2.0.15 → 2.0.16
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/transform-employment.d.ts +1 -0
- package/lib/transform-events/transform-employment.js +4 -0
- package/lib/transform-events/transform-income.d.ts +4 -0
- package/lib/transform-events/transform-income.js +20 -7
- package/lib/types/events/public-income.d.ts +3 -0
- package/lib/utils/is-income-type.d.ts +7 -4
- package/lib/utils/is-income-type.js +21 -14
- package/package.json +2 -2
- package/CHANGELOG.md +0 -64
|
@@ -3,6 +3,7 @@ import { Payload } from '../types/events/public-employment';
|
|
|
3
3
|
* Generates a partial application from a employment event.
|
|
4
4
|
*
|
|
5
5
|
* @param employment a employment event payload.
|
|
6
|
+
* @param isSelfEmployed
|
|
6
7
|
* @returns partialApplication an incomplete application.
|
|
7
8
|
*/
|
|
8
9
|
export declare function transformEmployment(employment: Payload, isSelfEmployed: boolean): {};
|
|
@@ -11,6 +11,7 @@ const enum_mappings_1 = require("../types/enum-mappings");
|
|
|
11
11
|
* Generates a partial application from a employment event.
|
|
12
12
|
*
|
|
13
13
|
* @param employment a employment event payload.
|
|
14
|
+
* @param isSelfEmployed
|
|
14
15
|
* @returns partialApplication an incomplete application.
|
|
15
16
|
*/
|
|
16
17
|
function transformEmployment(employment, isSelfEmployed) {
|
|
@@ -32,6 +33,9 @@ function transformEmployment(employment, isSelfEmployed) {
|
|
|
32
33
|
break;
|
|
33
34
|
case public_employment_1.EmploymentType.SelfEmployed:
|
|
34
35
|
employmentPath = application_paths_1.paths.SelfEmployed;
|
|
36
|
+
/**
|
|
37
|
+
* @todo This is wrong but does not harm anything coz right now we dont call this function with `isSelfEmployed`
|
|
38
|
+
*/
|
|
35
39
|
if (companyId && isSelfEmployed) {
|
|
36
40
|
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.CompanyApplicant}.@UniqueID`, companyId);
|
|
37
41
|
(0, lodash_1.set)(partialApplication, `${employmentPath}.@x_Employer`, companyId);
|
|
@@ -17,6 +17,7 @@ export declare function getIncomeMapping(incomeType: IncomeType): Record<string,
|
|
|
17
17
|
*
|
|
18
18
|
* @param payload a partial income event.
|
|
19
19
|
* @param applicantId PersonApplicant uniqueId on the application.
|
|
20
|
+
* @param storedApplication The stored application version, to retrieve the applicant id when processing SelfEmployed Income
|
|
20
21
|
* @returns partialApplication an incomplete application.
|
|
21
22
|
*/
|
|
22
23
|
export declare function transformIncome(payload: IncomePayload, applicantId?: string): PartialApplication;
|
|
@@ -32,6 +33,9 @@ export interface SelfEmploymentIncomeMapping {
|
|
|
32
33
|
year: string;
|
|
33
34
|
companyProfitBeforeTax: string;
|
|
34
35
|
addback: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* @todo to map this field, currently no field in SelfEmployed to map this field to
|
|
38
|
+
*/
|
|
35
39
|
nonRecurringIncome: string;
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
@@ -76,16 +76,21 @@ function getIncomeMapping(incomeType) {
|
|
|
76
76
|
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
77
77
|
basePath = application_paths_1.paths.SelfEmployed;
|
|
78
78
|
return {
|
|
79
|
+
// Low Doc and Full Doc common fields
|
|
80
|
+
companyId: `${basePath}.@x_Employer`,
|
|
81
|
+
gross: `${basePath}.DeclaredIncome.@IncomeAmount`,
|
|
82
|
+
// Full Doc
|
|
83
|
+
incomes: `${basePath}.BusinessIncome`,
|
|
79
84
|
/**
|
|
80
|
-
* @todo
|
|
85
|
+
* @todo To map bas correctly. Currently there is no way to map bas to SelfEmployed
|
|
81
86
|
*/
|
|
82
|
-
bas: `${basePath}.Income[0].BusinessActivityStatement`,
|
|
83
|
-
incomes: `${basePath}.Income`,
|
|
84
|
-
// companyId: `${basePath}.@UniqueID`,
|
|
87
|
+
// bas: `${basePath}.Income[0].BusinessActivityStatement`,
|
|
85
88
|
//
|
|
86
|
-
gross: `${basePath}.DeclaredIncome.@IncomeAmount`,
|
|
87
89
|
};
|
|
88
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated This is legacy version and shall not be used
|
|
93
|
+
*/
|
|
89
94
|
if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
|
|
90
95
|
basePath = application_paths_1.paths.SelfEmployed;
|
|
91
96
|
const { amount } = exports.EmploymentIncomeTypeMapping[incomeType];
|
|
@@ -113,9 +118,10 @@ exports.getIncomeMapping = getIncomeMapping;
|
|
|
113
118
|
*
|
|
114
119
|
* @param payload a partial income event.
|
|
115
120
|
* @param applicantId PersonApplicant uniqueId on the application.
|
|
121
|
+
* @param storedApplication The stored application version, to retrieve the applicant id when processing SelfEmployed Income
|
|
116
122
|
* @returns partialApplication an incomplete application.
|
|
117
123
|
*/
|
|
118
|
-
function transformIncome(payload, applicantId) {
|
|
124
|
+
function transformIncome(payload, applicantId = undefined) {
|
|
119
125
|
const { applicationId, id, income } = payload;
|
|
120
126
|
const { amount: incomeAmount, type: incomeType, frequency: incomeFrequency } = income;
|
|
121
127
|
const partialApplication = {};
|
|
@@ -179,6 +185,9 @@ function transformIncome(payload, applicantId) {
|
|
|
179
185
|
}
|
|
180
186
|
}
|
|
181
187
|
}
|
|
188
|
+
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
189
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
190
|
+
}
|
|
182
191
|
return partialApplication;
|
|
183
192
|
}
|
|
184
193
|
exports.transformIncome = transformIncome;
|
|
@@ -209,7 +218,7 @@ function createRentalIncome(amount, frequency, ownership = []) {
|
|
|
209
218
|
exports.createRentalIncome = createRentalIncome;
|
|
210
219
|
const selfEmploymentIncomeMapping = {
|
|
211
220
|
year: '@StartDate',
|
|
212
|
-
companyProfitBeforeTax: '@
|
|
221
|
+
companyProfitBeforeTax: '@ProfitBeforeTax',
|
|
213
222
|
addback: {
|
|
214
223
|
depreciation: 'Addback.@Depreciation',
|
|
215
224
|
interest: 'Addback.@Interest',
|
|
@@ -219,6 +228,10 @@ const selfEmploymentIncomeMapping = {
|
|
|
219
228
|
salary: 'Addback.@Salary',
|
|
220
229
|
superannuationExcess: 'Addback.@SuperannuationExcess',
|
|
221
230
|
},
|
|
231
|
+
/**
|
|
232
|
+
* @todo to map this field, currently no field in SelfEmployed to map this field to
|
|
233
|
+
* Due to some limitation, leave this field here which will map the data wrongly but eventually will be removed by the validator
|
|
234
|
+
*/
|
|
222
235
|
nonRecurringIncome: 'NonRecurringIncome[0].@Amount',
|
|
223
236
|
};
|
|
224
237
|
/**
|
|
@@ -43,25 +43,28 @@ export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean
|
|
|
43
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
44
|
*
|
|
45
45
|
* @param {PersonApplicant} applicant - An applicant
|
|
46
|
-
* @param {string}
|
|
46
|
+
* @param {string} lookupId - Could be EmploymentId or x_EmployerId
|
|
47
|
+
* @param lookupField
|
|
47
48
|
* @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
|
|
48
49
|
*/
|
|
49
|
-
export declare const
|
|
50
|
+
export declare const hasMatchingEmployment: (lookupField: string) => (applicant: PersonApplicant, lookupId: string) => boolean;
|
|
50
51
|
/**
|
|
51
52
|
* Gets the applicant id using the employment id
|
|
52
53
|
*
|
|
53
54
|
* @param {PersonApplicant[]} applicants - An array of applicants.
|
|
54
55
|
* @param {string} employmentId - Employment ID
|
|
56
|
+
* @param lookupId
|
|
57
|
+
* @param lookupField
|
|
55
58
|
* @returns {string | undefined} - Applicant id or undefined
|
|
56
59
|
*/
|
|
57
|
-
export declare function
|
|
60
|
+
export declare function getApplicantIdFromEmployment(applicants: PersonApplicant[], lookupId: string, lookupField: string): string | undefined;
|
|
58
61
|
/**
|
|
59
62
|
* @description Get an applicantId from the event or the applicants.
|
|
60
63
|
* @param {Income} income Income.
|
|
61
64
|
* @param {PersonApplicant[]} applicants An array of LIXI applicants.
|
|
62
65
|
* @returns {string | undefined} An applicantId or undefined.
|
|
63
66
|
*/
|
|
64
|
-
export declare function getApplicantId({ percentOwned, employmentId }: Income, applicants?: PersonApplicant[]): string | undefined;
|
|
67
|
+
export declare function getApplicantId({ percentOwned, employmentId, companyId }: Income, applicants?: PersonApplicant[]): string | undefined;
|
|
65
68
|
/**
|
|
66
69
|
* @description Sort Business Income By Year.
|
|
67
70
|
* @param incomeA Income Details for Self Employed Full Doc.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortBusinessIncome = exports.getApplicantId = exports.
|
|
3
|
+
exports.sortBusinessIncome = exports.getApplicantId = exports.getApplicantIdFromEmployment = exports.hasMatchingEmployment = exports.isFullDocOrLowDocIncome = exports.isOtherIncomeWithDesc = exports.isOtherIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.otherIncomeList = exports.PAYGList = exports.descriptionOtherIncomeTypes = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const public_income_1 = require("../types/events/public-income");
|
|
6
6
|
exports.descriptionOtherIncomeTypes = [
|
|
@@ -86,40 +86,47 @@ exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
|
|
|
86
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
87
|
*
|
|
88
88
|
* @param {PersonApplicant} applicant - An applicant
|
|
89
|
-
* @param {string}
|
|
89
|
+
* @param {string} lookupId - Could be EmploymentId or x_EmployerId
|
|
90
|
+
* @param lookupField
|
|
90
91
|
* @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
|
|
91
92
|
*/
|
|
92
|
-
const
|
|
93
|
-
const id = (0, lodash_1.get)(employment,
|
|
94
|
-
(0, lodash_1.get)(employment,
|
|
95
|
-
(0, lodash_1.get)(employment,
|
|
96
|
-
return id ===
|
|
93
|
+
const hasMatchingEmployment = (lookupField) => (applicant, lookupId) => (applicant.Employment || []).some((employment) => {
|
|
94
|
+
const id = (0, lodash_1.get)(employment, `PAYG.${lookupField}`) ||
|
|
95
|
+
(0, lodash_1.get)(employment, `SelfEmployed.${lookupField}`) ||
|
|
96
|
+
(0, lodash_1.get)(employment, `NotEmployed.${lookupField}`);
|
|
97
|
+
return id === lookupId;
|
|
97
98
|
});
|
|
98
|
-
exports.
|
|
99
|
+
exports.hasMatchingEmployment = hasMatchingEmployment;
|
|
99
100
|
/**
|
|
100
101
|
* Gets the applicant id using the employment id
|
|
101
102
|
*
|
|
102
103
|
* @param {PersonApplicant[]} applicants - An array of applicants.
|
|
103
104
|
* @param {string} employmentId - Employment ID
|
|
105
|
+
* @param lookupId
|
|
106
|
+
* @param lookupField
|
|
104
107
|
* @returns {string | undefined} - Applicant id or undefined
|
|
105
108
|
*/
|
|
106
|
-
function
|
|
109
|
+
function getApplicantIdFromEmployment(applicants, lookupId, lookupField) {
|
|
107
110
|
let applicantId;
|
|
108
|
-
if (applicants &&
|
|
109
|
-
const applicant = applicants.find((applicant) => (0, exports.
|
|
111
|
+
if (applicants && lookupId) {
|
|
112
|
+
const applicant = applicants.find((applicant) => (0, exports.hasMatchingEmployment)(lookupField)(applicant, lookupId));
|
|
110
113
|
applicantId = applicant === null || applicant === void 0 ? void 0 : applicant['@UniqueID'];
|
|
111
114
|
}
|
|
112
115
|
return applicantId;
|
|
113
116
|
}
|
|
114
|
-
exports.
|
|
117
|
+
exports.getApplicantIdFromEmployment = getApplicantIdFromEmployment;
|
|
115
118
|
/**
|
|
116
119
|
* @description Get an applicantId from the event or the applicants.
|
|
117
120
|
* @param {Income} income Income.
|
|
118
121
|
* @param {PersonApplicant[]} applicants An array of LIXI applicants.
|
|
119
122
|
* @returns {string | undefined} An applicantId or undefined.
|
|
120
123
|
*/
|
|
121
|
-
function getApplicantId({ percentOwned, employmentId }, applicants = []) {
|
|
122
|
-
return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') ||
|
|
124
|
+
function getApplicantId({ percentOwned, employmentId, companyId }, applicants = []) {
|
|
125
|
+
return ((0, lodash_1.get)(percentOwned, 'owners[0].applicantId') ||
|
|
126
|
+
// for company applicant
|
|
127
|
+
getApplicantIdFromEmployment(applicants, employmentId, '@UniqueID') ||
|
|
128
|
+
// for selfemployed
|
|
129
|
+
getApplicantIdFromEmployment(applicants, companyId, '@x_Employer'));
|
|
123
130
|
}
|
|
124
131
|
exports.getApplicantId = getApplicantId;
|
|
125
132
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/act-credit-decisions-transform",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@lendi/integrations-credit-protocol": "1.18.8",
|
|
25
|
-
"@lendi/act-eac-integrations-protocol": "3.1.
|
|
25
|
+
"@lendi/act-eac-integrations-protocol": "3.1.6",
|
|
26
26
|
"clean-deep": "^3.4.0",
|
|
27
27
|
"date-fns": "2.19.0",
|
|
28
28
|
"lodash": "^4.17.15"
|
package/CHANGELOG.md
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# 1.9.0
|
|
2
|
-
|
|
3
|
-
Changes
|
|
4
|
-
|
|
5
|
-
- Clone from https://bitbucket.org/lendi-dev/integrations-shared-packages/commits/f1ac57093b49cc53f872cb3986d006ad90d49b10
|
|
6
|
-
|
|
7
|
-
# 1.8.6
|
|
8
|
-
|
|
9
|
-
Changes
|
|
10
|
-
|
|
11
|
-
- Update `merge-application` to merge the company applicant directors
|
|
12
|
-
|
|
13
|
-
# 1.8.5
|
|
14
|
-
|
|
15
|
-
Changes
|
|
16
|
-
|
|
17
|
-
- Update `transfrom-funding-position` to set pledge amount on application if it exists in property
|
|
18
|
-
|
|
19
|
-
# 1.8.4
|
|
20
|
-
|
|
21
|
-
Changes
|
|
22
|
-
|
|
23
|
-
- Update `applicant-event` to include SIMPLE_OR_BARE trust type and update mapping in transform
|
|
24
|
-
|
|
25
|
-
# 1.8.3
|
|
26
|
-
|
|
27
|
-
Changes
|
|
28
|
-
|
|
29
|
-
- Update `@lendi/transform-events` to support company applicant mappings
|
|
30
|
-
|
|
31
|
-
# 1.8.2
|
|
32
|
-
|
|
33
|
-
Changes
|
|
34
|
-
|
|
35
|
-
- Use `@lendi/integrations-protocol@2.7.4`
|
|
36
|
-
|
|
37
|
-
# 1.8.1
|
|
38
|
-
|
|
39
|
-
Changes
|
|
40
|
-
|
|
41
|
-
- Update `transformApplicationWorkflow` to support `applicationStatus`
|
|
42
|
-
- Use `@lendi/integrations-protocol@2.7.2`
|
|
43
|
-
|
|
44
|
-
# 1.7.3
|
|
45
|
-
|
|
46
|
-
Fix
|
|
47
|
-
|
|
48
|
-
- Remove some unnecessary `additionalProperties` from event schema to void AJV warning msg
|
|
49
|
-
|
|
50
|
-
# 1.7.0
|
|
51
|
-
|
|
52
|
-
BREAKING CHANGES
|
|
53
|
-
|
|
54
|
-
- Change to use `@lendi/integration-protocols@2.7.0` for better Identification fields support
|
|
55
|
-
|
|
56
|
-
# 1.6.0
|
|
57
|
-
|
|
58
|
-
BREAKING CHANGES
|
|
59
|
-
|
|
60
|
-
- Change to module `commonjs` to make it compatible with existing codebase
|
|
61
|
-
|
|
62
|
-
Changes
|
|
63
|
-
|
|
64
|
-
- Upgrade `@lendi/integrations-protocol` to `v2.6.4`
|