@lendi/integrations-transform 1.5.8 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -1
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +3 -3
- package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
- package/lib/transform-events/generate-asset-liability-link.js +12 -12
- package/lib/transform-events/generate-credit-report-rebuilt.js +13 -13
- package/lib/transform-events/generate-employment.d.ts +1 -1
- package/lib/transform-events/generate-employment.js +33 -34
- package/lib/transform-events/generate-required-document.d.ts +1 -7
- package/lib/transform-events/generate-required-document.js +37 -54
- package/lib/transform-events/transform-applicant.d.ts +2 -1
- package/lib/transform-events/transform-applicant.js +57 -63
- package/lib/transform-events/transform-application-workflow.d.ts +0 -1
- package/lib/transform-events/transform-application-workflow.js +7 -8
- package/lib/transform-events/transform-application.d.ts +3 -1
- package/lib/transform-events/transform-application.js +23 -24
- package/lib/transform-events/transform-asset-address.d.ts +8 -2
- package/lib/transform-events/transform-asset-address.js +22 -18
- package/lib/transform-events/transform-asset.d.ts +7 -1
- package/lib/transform-events/transform-asset.js +112 -122
- package/lib/transform-events/transform-expenses.d.ts +4 -0
- package/lib/transform-events/transform-expenses.js +31 -29
- package/lib/transform-events/transform-funding-position.d.ts +2 -2
- package/lib/transform-events/transform-funding-position.js +23 -26
- package/lib/transform-events/transform-income.d.ts +8 -1
- package/lib/transform-events/transform-income.js +87 -97
- package/lib/transform-events/transform-liability.d.ts +4 -1
- package/lib/transform-events/transform-liability.js +42 -41
- package/lib/transform-events/transform-percent-owned.d.ts +1 -0
- package/lib/transform-events/transform-percent-owned.js +8 -11
- package/lib/types/enum-mappings/alieo-frequency.js +23 -24
- package/lib/types/enum-mappings/asset-type.js +15 -16
- package/lib/types/enum-mappings/builder-type.js +7 -8
- package/lib/types/enum-mappings/construction-type.js +8 -9
- package/lib/types/enum-mappings/country-code.js +244 -245
- package/lib/types/enum-mappings/employment-basis.js +10 -11
- package/lib/types/enum-mappings/expense-frequency.js +9 -10
- package/lib/types/enum-mappings/funding-position.js +6 -6
- package/lib/types/enum-mappings/government-benefits.js +8 -9
- package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
- package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
- package/lib/types/enum-mappings/housing-status.js +13 -14
- package/lib/types/enum-mappings/income-type.js +14 -15
- package/lib/types/enum-mappings/index.js +1 -1
- package/lib/types/enum-mappings/liability-payment-type.js +7 -8
- package/lib/types/enum-mappings/liability-type.js +19 -20
- package/lib/types/enum-mappings/living-expense.js +28 -29
- package/lib/types/enum-mappings/marital-status.js +10 -11
- package/lib/types/enum-mappings/postcode.js +12 -13
- package/lib/types/enum-mappings/preferred-repayment.js +8 -9
- package/lib/types/enum-mappings/proof-of-identity.js +8 -9
- package/lib/types/enum-mappings/property-expense-category.js +9 -10
- package/lib/types/enum-mappings/public-financial-asset.js +10 -11
- package/lib/types/enum-mappings/public-primary-purpose.js +7 -8
- package/lib/types/enum-mappings/public-property-status.js +9 -10
- package/lib/types/enum-mappings/public-property-type.js +21 -22
- package/lib/types/enum-mappings/residency-status.js +9 -10
- package/lib/types/enum-mappings/title-gender.js +11 -12
- package/lib/types/enum-mappings/title.js +11 -12
- package/lib/types/enum-mappings/to-be-purchased.js +4 -4
- package/lib/types/enum-mappings/to-be-used-as-security.js +4 -4
- package/lib/types/enum-mappings/transaction-type.js +7 -8
- package/lib/types/enum-mappings/verification.js +11 -12
- package/lib/types/events/applicant-delete.js +1 -1
- package/lib/types/events/application-workflow.js +1 -1
- package/lib/types/events/asset-delete.js +1 -1
- package/lib/types/events/asset-liability-relation-delete.js +1 -1
- package/lib/types/events/credit-report-retrieved.js +1 -1
- package/lib/types/events/employment-delete.js +1 -1
- package/lib/types/events/expense-delete.js +1 -1
- package/lib/types/events/funding-position.js +1 -1
- package/lib/types/events/income-delete.js +1 -1
- package/lib/types/events/liability-delete.js +1 -1
- package/lib/types/events/opportunity.js +1 -1
- package/lib/types/events/public-applicant.js +1 -1
- package/lib/types/events/public-application.js +1 -1
- package/lib/types/events/public-asset-liability-relation.js +1 -1
- package/lib/types/events/public-asset.js +1 -1
- package/lib/types/events/public-employment.js +1 -1
- package/lib/types/events/public-expense.js +1 -1
- package/lib/types/events/public-funding-position.js +1 -1
- package/lib/types/events/public-income.js +1 -1
- package/lib/types/events/public-liability.js +1 -1
- package/lib/types/events/public-required-document.js +1 -1
- package/lib/types/partial-application.js +1 -1
- package/lib/types/recursive-partial.js +1 -1
- package/lib/update-application/merge-application.d.ts +1 -1
- package/lib/update-application/merge-application.js +41 -34
- package/lib/update-application/update-primary-applicant.d.ts +1 -4
- package/lib/update-application/update-primary-applicant.js +12 -31
- package/lib/utils/address-tools.d.ts +3 -1
- package/lib/utils/address-tools.js +40 -42
- package/lib/utils/clean-up.d.ts +1 -1
- package/lib/utils/clean-up.js +6 -6
- package/lib/utils/formatYesNo.d.ts +0 -1
- package/lib/utils/formatYesNo.js +3 -4
- package/lib/utils/generate-address.d.ts +3 -2
- package/lib/utils/generate-address.js +21 -25
- package/lib/utils/get-financial-institution.d.ts +1 -0
- package/lib/utils/get-financial-institution.js +6 -5
- package/lib/utils/is-asset-type.js +2 -2
- package/lib/utils/is-income-type.d.ts +2 -0
- package/lib/utils/is-income-type.js +15 -21
- package/lib/utils/iso-date.d.ts +0 -1
- package/lib/utils/iso-date.js +3 -4
- package/lib/utils/normalise-date.js +6 -6
- package/lib/utils/round-decimal.js +1 -1
- package/package.json +14 -17
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFees = exports.transformFundingPosition = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
8
8
|
/**
|
|
9
9
|
* GenerateFundingPosition
|
|
10
10
|
*
|
|
11
11
|
* @param fundingPosition a partialFundingPosition.
|
|
12
12
|
* @param uniqueIdSuffix
|
|
13
|
-
* @
|
|
13
|
+
* @returns partialApplication with fees, grants and borrowers contributions added.
|
|
14
14
|
*/
|
|
15
|
-
function transformFundingPosition(fundingPosition, uniqueIdSuffix) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var fundingPositionMapping = {
|
|
15
|
+
function transformFundingPosition(fundingPosition, uniqueIdSuffix = 'loanDetails') {
|
|
16
|
+
const partialApplication = {};
|
|
17
|
+
const contributionFunds = [];
|
|
18
|
+
const { applicationId, id, lmi = 0, lmiIncluded = false } = fundingPosition;
|
|
19
|
+
const fundingPositionMapping = {
|
|
21
20
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
22
|
-
fundsRequested:
|
|
23
|
-
lvr:
|
|
21
|
+
fundsRequested: `${application_paths_1.paths.RolledUpAmounts}.@TotalNewFunds`,
|
|
22
|
+
lvr: `${application_paths_1.paths.Summary}.LoanToValuationRatio.@ApplicationLVR`,
|
|
24
23
|
totalGovernmentContributions: application_paths_1.paths.ContributionFunds,
|
|
25
24
|
totalDeposit: application_paths_1.paths.ContributionFunds,
|
|
26
|
-
totalCashOut:
|
|
27
|
-
fundsRequiredBreakdown: application_paths_1.paths.SummaryFee
|
|
25
|
+
totalCashOut: `${application_paths_1.paths.EquityRelease}.Amount.@LumpSum`,
|
|
26
|
+
fundsRequiredBreakdown: application_paths_1.paths.SummaryFee,
|
|
28
27
|
};
|
|
29
|
-
for (
|
|
30
|
-
var _d = _c[_i], key = _d[0], value = _d[1];
|
|
28
|
+
for (const [key, value] of Object.entries(fundingPosition)) {
|
|
31
29
|
if (fundingPositionMapping[key]) {
|
|
32
30
|
switch (key) {
|
|
33
31
|
case 'totalGovernmentContributions':
|
|
@@ -35,7 +33,7 @@ function transformFundingPosition(fundingPosition, uniqueIdSuffix) {
|
|
|
35
33
|
contributionFunds.push({
|
|
36
34
|
'@Amount': value,
|
|
37
35
|
'@Type': enum_mappings_1.contributionMapping[key],
|
|
38
|
-
'@UniqueID':
|
|
36
|
+
'@UniqueID': `${id}-${key}`,
|
|
39
37
|
});
|
|
40
38
|
break;
|
|
41
39
|
case 'fundsRequiredBreakdown':
|
|
@@ -43,7 +41,7 @@ function transformFundingPosition(fundingPosition, uniqueIdSuffix) {
|
|
|
43
41
|
break;
|
|
44
42
|
case 'totalCashOut':
|
|
45
43
|
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
|
|
46
|
-
(0, lodash_1.set)(partialApplication,
|
|
44
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.LoanDetail}.@UniqueID`, `${applicationId}-${uniqueIdSuffix}`);
|
|
47
45
|
break;
|
|
48
46
|
case 'fundsRequested':
|
|
49
47
|
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], Math.round(value));
|
|
@@ -65,20 +63,19 @@ exports.transformFundingPosition = transformFundingPosition;
|
|
|
65
63
|
* @param lmi
|
|
66
64
|
* @param lmiIncluded
|
|
67
65
|
* @param id
|
|
68
|
-
* @
|
|
66
|
+
* @returns Array of fees
|
|
69
67
|
*/
|
|
70
68
|
function getFees(fundsRequiredBreakDown, lmi, lmiIncluded, id) {
|
|
71
69
|
// Adding lmi to fees to be transformed.
|
|
72
70
|
(0, lodash_1.set)(fundsRequiredBreakDown, 'lmi', lmi);
|
|
73
71
|
// Omitting constructionCosts as they don't belong in fees.
|
|
74
|
-
return Object.entries((0, lodash_1.omit)(fundsRequiredBreakDown, 'constructionCosts')).map(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var fee = {
|
|
72
|
+
return Object.entries((0, lodash_1.omit)(fundsRequiredBreakDown, 'constructionCosts')).map(([key, value]) => {
|
|
73
|
+
const descriptionList = ['accruedInterest', 'otherSundries'];
|
|
74
|
+
const fee = {
|
|
78
75
|
'@Amount': value,
|
|
79
76
|
'@Category': enum_mappings_1.categoryMapping[key],
|
|
80
77
|
'@Type': enum_mappings_1.typeMapping[key],
|
|
81
|
-
'@UniqueID':
|
|
78
|
+
'@UniqueID': `${id}-${key}`,
|
|
82
79
|
};
|
|
83
80
|
if (descriptionList.includes(key)) {
|
|
84
81
|
fee['@Description'] = enum_mappings_1.descriptionMapping[key];
|
|
@@ -7,17 +7,22 @@ export interface AmountFrequency {
|
|
|
7
7
|
frequency?: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const EmploymentIncomeTypeMapping: Record<string, AmountFrequency>;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param incomeType
|
|
13
|
+
*/
|
|
10
14
|
export declare function getIncomeMapping(incomeType: IncomeType): Record<string, string>;
|
|
11
15
|
/**
|
|
12
16
|
* Generates an partial application from a partial income event.
|
|
13
17
|
*
|
|
14
18
|
* @param payload a partial income event.
|
|
15
19
|
* @param applicantId PersonApplicant uniqueId on the application.
|
|
16
|
-
* @
|
|
20
|
+
* @returns partialApplication an incomplete application.
|
|
17
21
|
*/
|
|
18
22
|
export declare function transformIncome(payload: IncomePayload, applicantId?: string): PartialApplication;
|
|
19
23
|
/**
|
|
20
24
|
* Creates Rental Income array.
|
|
25
|
+
*
|
|
21
26
|
* @param amount Amount
|
|
22
27
|
* @param frequency Frequency
|
|
23
28
|
* @param ownership Owners.
|
|
@@ -37,5 +42,7 @@ export interface SelfEmploymentIncomeMapping {
|
|
|
37
42
|
export declare function generateIncomeBusinessDetails(data: IncomeBusinessDetails): IncomeElement;
|
|
38
43
|
/**
|
|
39
44
|
* Generates the BAS array from the bas definition on the event.
|
|
45
|
+
*
|
|
46
|
+
* @param bas
|
|
40
47
|
*/
|
|
41
48
|
export declare function generateBAS(bas: BASDefinition[]): IncomeBusinessActivityStatement[];
|
|
@@ -1,15 +1,4 @@
|
|
|
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
|
-
};
|
|
13
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
3
|
var t = {};
|
|
15
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -21,94 +10,97 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
10
|
}
|
|
22
11
|
return t;
|
|
23
12
|
};
|
|
24
|
-
|
|
25
|
-
exports.__esModule = true;
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
14
|
exports.generateBAS = exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.transformIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
16
|
+
const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
18
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
19
|
+
const public_income_1 = require("../types/events/public-income");
|
|
20
|
+
const is_income_type_1 = require("../utils/is-income-type");
|
|
21
|
+
const round_decimal_1 = require("../utils/round-decimal");
|
|
22
|
+
const transform_percent_owned_1 = require("./transform-percent-owned");
|
|
23
|
+
const netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
24
|
+
const netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
37
25
|
// Income types mapping from internal to LIXI types /paths.
|
|
38
|
-
exports.EmploymentIncomeTypeMapping =
|
|
39
|
-
|
|
26
|
+
exports.EmploymentIncomeTypeMapping = {
|
|
27
|
+
[public_income_1.IncomeType.PaygAllowancesNotTaxed]: {
|
|
40
28
|
amount: 'Income.@WorkAllowanceAmount',
|
|
41
|
-
frequency: 'Income.@WorkAllowanceFrequency'
|
|
29
|
+
frequency: 'Income.@WorkAllowanceFrequency',
|
|
42
30
|
},
|
|
43
|
-
|
|
31
|
+
[public_income_1.IncomeType.PaygAllowancesTaxed]: {
|
|
44
32
|
amount: netWorkAllowanceAmount,
|
|
45
|
-
frequency: netWorkAllowanceFrequency
|
|
33
|
+
frequency: netWorkAllowanceFrequency,
|
|
46
34
|
},
|
|
47
|
-
|
|
35
|
+
[public_income_1.IncomeType.PaygBaseSalary]: {
|
|
48
36
|
amount: 'Income.@GrossSalaryAmount',
|
|
49
|
-
frequency: 'Income.@GrossSalaryFrequency'
|
|
37
|
+
frequency: 'Income.@GrossSalaryFrequency',
|
|
50
38
|
},
|
|
51
|
-
|
|
39
|
+
[public_income_1.IncomeType.PaygBonusIncome]: {
|
|
52
40
|
amount: 'Income.@BonusAmount',
|
|
53
|
-
frequency: 'Income.@BonusFrequency'
|
|
41
|
+
frequency: 'Income.@BonusFrequency',
|
|
54
42
|
},
|
|
55
|
-
|
|
43
|
+
[public_income_1.IncomeType.PaygCommissionIncome]: {
|
|
56
44
|
amount: 'Income.@CommissionAmount',
|
|
57
|
-
frequency: 'Income.@CommissionFrequency'
|
|
45
|
+
frequency: 'Income.@CommissionFrequency',
|
|
58
46
|
},
|
|
59
|
-
|
|
47
|
+
[public_income_1.IncomeType.PaygCompanyCar]: {
|
|
60
48
|
amount: 'Income.@NetCarAllowanceAmount',
|
|
61
|
-
frequency: 'Income.@NetCarAllowanceFrequency'
|
|
49
|
+
frequency: 'Income.@NetCarAllowanceFrequency',
|
|
62
50
|
},
|
|
63
|
-
|
|
51
|
+
[public_income_1.IncomeType.PaygCarAllowance]: {
|
|
64
52
|
amount: 'Income.@CarAllowanceAmount',
|
|
65
|
-
frequency: 'Income.@CarAllowanceFrequency'
|
|
53
|
+
frequency: 'Income.@CarAllowanceFrequency',
|
|
66
54
|
},
|
|
67
|
-
|
|
55
|
+
[public_income_1.IncomeType.PaygOvertimeIncome]: {
|
|
68
56
|
amount: 'Income.@GrossRegularOvertimeAmount',
|
|
69
|
-
frequency: 'Income.@GrossRegularOvertimeFrequency'
|
|
57
|
+
frequency: 'Income.@GrossRegularOvertimeFrequency',
|
|
70
58
|
},
|
|
71
|
-
|
|
72
|
-
amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
|
|
59
|
+
[public_income_1.IncomeType.SelfEmployedBusinessIncome]: {
|
|
60
|
+
amount: 'BusinessIncomeRecent.@ProfitBeforeTax',
|
|
73
61
|
},
|
|
74
|
-
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param incomeType
|
|
66
|
+
*/
|
|
75
67
|
function getIncomeMapping(incomeType) {
|
|
76
|
-
|
|
68
|
+
let basePath = application_paths_1.paths.OtherIncome;
|
|
77
69
|
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
78
70
|
basePath = application_paths_1.paths.RealEstateAsset;
|
|
79
71
|
return {
|
|
80
|
-
assetId:
|
|
81
|
-
percentOwned:
|
|
72
|
+
assetId: `${basePath}.@UniqueID`,
|
|
73
|
+
percentOwned: `${basePath}.RentalIncome`,
|
|
82
74
|
};
|
|
83
75
|
}
|
|
84
76
|
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
85
77
|
basePath = application_paths_1.paths.CompanyApplicant;
|
|
86
78
|
return {
|
|
87
|
-
bas:
|
|
88
|
-
companyId:
|
|
89
|
-
incomes:
|
|
90
|
-
gross:
|
|
79
|
+
bas: `${basePath}.Income[0].BusinessActivityStatement`,
|
|
80
|
+
companyId: `${basePath}.@UniqueID`,
|
|
81
|
+
incomes: `${basePath}.Income`,
|
|
82
|
+
gross: `${basePath}.DeclaredIncome.@IncomeAmount`,
|
|
91
83
|
};
|
|
92
84
|
}
|
|
93
85
|
if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
|
|
94
86
|
basePath = application_paths_1.paths.SelfEmployed;
|
|
95
|
-
|
|
87
|
+
const { amount } = exports.EmploymentIncomeTypeMapping[incomeType];
|
|
96
88
|
return {
|
|
97
|
-
amount:
|
|
98
|
-
employmentId:
|
|
89
|
+
amount: `${basePath}.${amount}`,
|
|
90
|
+
employmentId: `${basePath}.@UniqueID`,
|
|
99
91
|
};
|
|
100
92
|
}
|
|
101
93
|
if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
102
94
|
basePath = application_paths_1.paths.PAYG;
|
|
103
|
-
|
|
104
|
-
return
|
|
95
|
+
const { amount, frequency } = exports.EmploymentIncomeTypeMapping[incomeType];
|
|
96
|
+
return Object.assign({ amount: `${basePath}.${amount}`, employmentId: `${basePath}.@UniqueID` }, (frequency && { frequency: `${basePath}.${frequency}` }));
|
|
105
97
|
}
|
|
106
98
|
return {
|
|
107
|
-
amount:
|
|
108
|
-
frequency:
|
|
109
|
-
percentOwned:
|
|
110
|
-
type:
|
|
111
|
-
benefitType:
|
|
99
|
+
amount: `${basePath}.@Amount`,
|
|
100
|
+
frequency: `${basePath}.@Frequency`,
|
|
101
|
+
percentOwned: `${basePath}.PercentOwned`,
|
|
102
|
+
type: `${basePath}.@Type`,
|
|
103
|
+
benefitType: `${basePath}.@GovernmentBenefitsType`,
|
|
112
104
|
};
|
|
113
105
|
}
|
|
114
106
|
exports.getIncomeMapping = getIncomeMapping;
|
|
@@ -117,30 +109,29 @@ exports.getIncomeMapping = getIncomeMapping;
|
|
|
117
109
|
*
|
|
118
110
|
* @param payload a partial income event.
|
|
119
111
|
* @param applicantId PersonApplicant uniqueId on the application.
|
|
120
|
-
* @
|
|
112
|
+
* @returns partialApplication an incomplete application.
|
|
121
113
|
*/
|
|
122
114
|
function transformIncome(payload, applicantId) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
115
|
+
const { applicationId, id, income } = payload;
|
|
116
|
+
const { amount: incomeAmount, type: incomeType, frequency: incomeFrequency } = income;
|
|
117
|
+
const partialApplication = {};
|
|
126
118
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
127
119
|
if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
|
|
128
|
-
(0, lodash_1.set)(partialApplication,
|
|
120
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
129
121
|
}
|
|
130
122
|
if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
|
|
131
|
-
(0, lodash_1.set)(partialApplication,
|
|
123
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.OtherIncome}.@UniqueID`, id);
|
|
132
124
|
}
|
|
133
|
-
|
|
134
|
-
for (
|
|
135
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
125
|
+
const incomeMapping = getIncomeMapping(incomeType);
|
|
126
|
+
for (const [key, value] of Object.entries(income)) {
|
|
136
127
|
if (incomeMapping[key]) {
|
|
137
128
|
switch (key) {
|
|
138
129
|
case 'amount':
|
|
139
|
-
|
|
130
|
+
const amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
|
|
140
131
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
|
|
141
132
|
break;
|
|
142
133
|
case 'bas':
|
|
143
|
-
|
|
134
|
+
const basWithAmount = value.filter((bas) => bas.salesAmount !== undefined || false);
|
|
144
135
|
if (!(0, lodash_1.isEmpty)(basWithAmount))
|
|
145
136
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], generateBAS(basWithAmount));
|
|
146
137
|
break;
|
|
@@ -148,8 +139,8 @@ function transformIncome(payload, applicantId) {
|
|
|
148
139
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], enum_mappings_1.incomeExpenseFrequencyMapping[value]);
|
|
149
140
|
break;
|
|
150
141
|
case 'percentOwned':
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
const ownership = value;
|
|
143
|
+
let percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(ownership);
|
|
153
144
|
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
154
145
|
percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
|
|
155
146
|
}
|
|
@@ -159,9 +150,9 @@ function transformIncome(payload, applicantId) {
|
|
|
159
150
|
break;
|
|
160
151
|
case 'type':
|
|
161
152
|
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
162
|
-
|
|
153
|
+
const mappedType = enum_mappings_1.otherIncomeMapping[value];
|
|
163
154
|
if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
|
|
164
|
-
(0, lodash_1.set)(partialApplication,
|
|
155
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.OtherIncome}.@Description`, mappedType);
|
|
165
156
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
166
157
|
}
|
|
167
158
|
else {
|
|
@@ -173,7 +164,7 @@ function transformIncome(payload, applicantId) {
|
|
|
173
164
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], enum_mappings_1.governmentBenefitsMapping[value]);
|
|
174
165
|
break;
|
|
175
166
|
case 'incomes':
|
|
176
|
-
|
|
167
|
+
const sortedIncomeList = value
|
|
177
168
|
.sort(is_income_type_1.sortBusinessIncome)
|
|
178
169
|
.map(generateIncomeBusinessDetails);
|
|
179
170
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], sortedIncomeList);
|
|
@@ -189,31 +180,30 @@ function transformIncome(payload, applicantId) {
|
|
|
189
180
|
exports.transformIncome = transformIncome;
|
|
190
181
|
/**
|
|
191
182
|
* Creates Rental Income array.
|
|
183
|
+
*
|
|
192
184
|
* @param amount Amount
|
|
193
185
|
* @param frequency Frequency
|
|
194
186
|
* @param ownership Owners.
|
|
195
187
|
*/
|
|
196
|
-
function createRentalIncome(amount, frequency, ownership) {
|
|
197
|
-
if (ownership === void 0) { ownership = []; }
|
|
188
|
+
function createRentalIncome(amount, frequency, ownership = []) {
|
|
198
189
|
if (frequency === public_income_1.Frequency.Quarterly) {
|
|
199
190
|
amount = Math.ceil(amount / 3);
|
|
200
191
|
frequency = public_income_1.Frequency.Monthly;
|
|
201
192
|
}
|
|
202
|
-
|
|
203
|
-
for (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
var ownerAmount = (0, round_decimal_1.roundDecimal)(amount * percent);
|
|
193
|
+
const rentalIncome = [];
|
|
194
|
+
for (const owner of ownership) {
|
|
195
|
+
const { percent, applicantId } = owner;
|
|
196
|
+
const ownerAmount = (0, round_decimal_1.roundDecimal)(amount * percent);
|
|
207
197
|
rentalIncome.push({
|
|
208
198
|
'@Frequency': enum_mappings_1.rentalIncomeFrequencyMapping[frequency],
|
|
209
199
|
'@RentalAmount': ownerAmount,
|
|
210
|
-
'@x_Owner': applicantId
|
|
200
|
+
'@x_Owner': applicantId,
|
|
211
201
|
});
|
|
212
202
|
}
|
|
213
203
|
return rentalIncome;
|
|
214
204
|
}
|
|
215
205
|
exports.createRentalIncome = createRentalIncome;
|
|
216
|
-
|
|
206
|
+
const selfEmploymentIncomeMapping = {
|
|
217
207
|
year: '@StartDate',
|
|
218
208
|
companyProfitBeforeTax: '@CompanyProfitBeforeTax',
|
|
219
209
|
addback: {
|
|
@@ -223,9 +213,9 @@ var selfEmploymentIncomeMapping = {
|
|
|
223
213
|
nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
|
|
224
214
|
other: 'Addback.OtherAddback[0].@Amount',
|
|
225
215
|
salary: 'Addback.@Salary',
|
|
226
|
-
superannuationExcess: 'Addback.@SuperannuationExcess'
|
|
216
|
+
superannuationExcess: 'Addback.@SuperannuationExcess',
|
|
227
217
|
},
|
|
228
|
-
nonRecurringIncome: 'NonRecurringIncome[0].@Amount'
|
|
218
|
+
nonRecurringIncome: 'NonRecurringIncome[0].@Amount',
|
|
229
219
|
};
|
|
230
220
|
/**
|
|
231
221
|
* @description Transform a Self Employed Income Details to LIXI
|
|
@@ -233,14 +223,12 @@ var selfEmploymentIncomeMapping = {
|
|
|
233
223
|
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
234
224
|
*/
|
|
235
225
|
function generateIncomeBusinessDetails(data) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
for (
|
|
239
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
226
|
+
const income = {};
|
|
227
|
+
const { addback: addbackMapping } = selfEmploymentIncomeMapping, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
|
|
228
|
+
for (const [key, value] of Object.entries(data)) {
|
|
240
229
|
if (selfEmploymentIncomeMapping[key] !== null) {
|
|
241
230
|
if (key === 'addback') {
|
|
242
|
-
for (
|
|
243
|
-
var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
|
|
231
|
+
for (const [addbackKey, addbackValue] of Object.entries(value)) {
|
|
244
232
|
if (addbackKey === 'other') {
|
|
245
233
|
(0, lodash_1.set)(income, 'Addback.OtherAddback[0].@Description', 'other');
|
|
246
234
|
}
|
|
@@ -248,7 +236,7 @@ function generateIncomeBusinessDetails(data) {
|
|
|
248
236
|
}
|
|
249
237
|
}
|
|
250
238
|
else if (key === 'year') {
|
|
251
|
-
(0, lodash_1.set)(income, dateAndIncomeMapping[key],
|
|
239
|
+
(0, lodash_1.set)(income, dateAndIncomeMapping[key], `${value}-01-01`);
|
|
252
240
|
}
|
|
253
241
|
else {
|
|
254
242
|
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
|
|
@@ -260,11 +248,13 @@ function generateIncomeBusinessDetails(data) {
|
|
|
260
248
|
exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
|
|
261
249
|
/**
|
|
262
250
|
* Generates the BAS array from the bas definition on the event.
|
|
251
|
+
*
|
|
252
|
+
* @param bas
|
|
263
253
|
*/
|
|
264
254
|
function generateBAS(bas) {
|
|
265
|
-
return bas.map(
|
|
255
|
+
return bas.map((bas) => ({
|
|
266
256
|
'@Quarter': bas.quarter,
|
|
267
|
-
'@SalesAmount': bas.salesAmount
|
|
268
|
-
})
|
|
257
|
+
'@SalesAmount': bas.salesAmount,
|
|
258
|
+
}));
|
|
269
259
|
}
|
|
270
260
|
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,45 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformLiability = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
7
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
8
|
+
const public_liability_1 = require("../types/events/public-liability");
|
|
9
|
+
const get_financial_institution_1 = require("../utils/get-financial-institution");
|
|
10
|
+
const round_decimal_1 = require("../utils/round-decimal");
|
|
11
|
+
const transform_percent_owned_1 = require("./transform-percent-owned");
|
|
12
|
+
const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
13
|
+
const lixi_internal_request_2 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
14
14
|
/**
|
|
15
15
|
* Generates a partial internal request from a liability event payload.
|
|
16
16
|
*
|
|
17
17
|
* @param liabilityPayload: A liability event payload.
|
|
18
|
-
* @
|
|
18
|
+
* @param liabilityPayload:.applicationId
|
|
19
|
+
* @param liabilityPayload:.id
|
|
20
|
+
* @param liabilityPayload:.liability
|
|
21
|
+
* @returns A partial InternalRequest.
|
|
19
22
|
*/
|
|
20
|
-
function transformLiability(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var liabilityMapping = {
|
|
23
|
+
function transformLiability({ applicationId, id, liability }) {
|
|
24
|
+
const partialApplication = {};
|
|
25
|
+
const liabilityMapping = {
|
|
24
26
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
25
|
-
annualInterestRate:
|
|
26
|
-
id:
|
|
27
|
-
clearingFromThisLoan:
|
|
28
|
-
clearingFromOtherSource:
|
|
29
|
-
description:
|
|
30
|
-
financialInstitution:
|
|
31
|
-
financialInstitutionAccountNumber:
|
|
32
|
-
financialInstitutionBsb:
|
|
33
|
-
interestOnlyRemainingTerm:
|
|
34
|
-
creditLimit:
|
|
35
|
-
newLimit:
|
|
36
|
-
repaymentAmount:
|
|
37
|
-
repaymentFrequency:
|
|
38
|
-
remainingTermDuration:
|
|
39
|
-
repaymentTypeDetails:
|
|
40
|
-
outstandingBalance:
|
|
41
|
-
type:
|
|
42
|
-
percentOwned:
|
|
27
|
+
annualInterestRate: `${application_paths_1.paths.Liability}.@AnnualInterestRate`,
|
|
28
|
+
id: `${application_paths_1.paths.Liability}.@UniqueID`,
|
|
29
|
+
clearingFromThisLoan: `${application_paths_1.paths.Liability}.@ClearingFromThisLoan`,
|
|
30
|
+
clearingFromOtherSource: `${application_paths_1.paths.Liability}.@ClearingFromOtherSource`,
|
|
31
|
+
description: `${application_paths_1.paths.Liability}.@Description`,
|
|
32
|
+
financialInstitution: `${application_paths_1.paths.Liability}.AccountNumber.@FinancialInstitution`,
|
|
33
|
+
financialInstitutionAccountNumber: `${application_paths_1.paths.Liability}.AccountNumber.@AccountNumber`,
|
|
34
|
+
financialInstitutionBsb: `${application_paths_1.paths.Liability}.AccountNumber.@BSB`,
|
|
35
|
+
interestOnlyRemainingTerm: `${application_paths_1.paths.Liability}.OriginalTerm.@PaymentTypeDuration`,
|
|
36
|
+
creditLimit: `${application_paths_1.paths.Liability}.@CreditLimit`,
|
|
37
|
+
newLimit: `${application_paths_1.paths.Liability}.@NewLimit`,
|
|
38
|
+
repaymentAmount: `${application_paths_1.paths.Liability}.Repayment[0].@RepaymentAmount`,
|
|
39
|
+
repaymentFrequency: `${application_paths_1.paths.Liability}.Repayment[0].@RepaymentFrequency`,
|
|
40
|
+
remainingTermDuration: `${application_paths_1.paths.Liability}.RemainingTerm.@Duration`,
|
|
41
|
+
repaymentTypeDetails: `${application_paths_1.paths.Liability}.Repayment[0].@PaymentType`,
|
|
42
|
+
outstandingBalance: `${application_paths_1.paths.Liability}.@OutstandingBalance`,
|
|
43
|
+
type: `${application_paths_1.paths.Liability}.@Type`,
|
|
44
|
+
percentOwned: `${application_paths_1.paths.Liability}.PercentOwned`,
|
|
43
45
|
};
|
|
44
46
|
(0, lodash_1.set)(partialApplication, liabilityMapping.applicationId, applicationId);
|
|
45
47
|
(0, lodash_1.set)(partialApplication, liabilityMapping.id, id);
|
|
@@ -54,8 +56,7 @@ function transformLiability(_a) {
|
|
|
54
56
|
}
|
|
55
57
|
// Default clearingFromThisLoan to No if the value is not present in the event.
|
|
56
58
|
(0, lodash_1.set)(partialApplication, liabilityMapping.clearingFromThisLoan, lixi_internal_request_1.YesNoList.No);
|
|
57
|
-
for (
|
|
58
|
-
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
59
|
+
for (const [key, value] of Object.entries(liability)) {
|
|
59
60
|
if (liabilityMapping[key]) {
|
|
60
61
|
switch (key) {
|
|
61
62
|
case 'outstandingBalance':
|
|
@@ -66,8 +67,8 @@ function transformLiability(_a) {
|
|
|
66
67
|
break;
|
|
67
68
|
case 'interestOnlyRemainingTerm':
|
|
68
69
|
(0, lodash_1.set)(partialApplication, liabilityMapping[key], (0, round_decimal_1.roundDecimal)(value));
|
|
69
|
-
(0, lodash_1.set)(partialApplication,
|
|
70
|
-
(0, lodash_1.set)(partialApplication,
|
|
70
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Liability}.OriginalTerm.@PaymentType`, lixi_internal_request_1.PaymentTypeList.InterestOnly);
|
|
71
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Liability}.OriginalTerm.@PaymentTypeUnits`, lixi_internal_request_1.LoanTermUnitsList.Years);
|
|
71
72
|
break;
|
|
72
73
|
case 'type':
|
|
73
74
|
(0, lodash_1.set)(partialApplication, liabilityMapping[key], enum_mappings_1.liabilityTypeMapping[value]);
|
|
@@ -87,14 +88,14 @@ function transformLiability(_a) {
|
|
|
87
88
|
break;
|
|
88
89
|
case 'remainingTermDuration':
|
|
89
90
|
(0, lodash_1.set)(partialApplication, liabilityMapping[key], Math.round(value * 12));
|
|
90
|
-
(0, lodash_1.set)(partialApplication,
|
|
91
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Liability}.RemainingTerm.@Units`, lixi_internal_request_2.UnitsList.Months);
|
|
91
92
|
break;
|
|
92
93
|
case 'financialInstitution':
|
|
93
|
-
|
|
94
|
+
const financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString()) || lixi_internal_request_2.FinancialInstitutionList.Other;
|
|
94
95
|
(0, lodash_1.set)(partialApplication, liabilityMapping[key], financialInstitution);
|
|
95
96
|
break;
|
|
96
97
|
case 'percentOwned':
|
|
97
|
-
|
|
98
|
+
const percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
|
|
98
99
|
if (percentOwned) {
|
|
99
100
|
(0, lodash_1.set)(partialApplication, liabilityMapping[key], percentOwned);
|
|
100
101
|
}
|
|
@@ -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;
|