@lendi/integrations-transform 1.3.9 → 1.4.2
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 +5 -1
- package/lib/schemas/public-applicant-event.json +31 -0
- package/lib/transform-events/transform-asset.js +1 -1
- package/lib/transform-events/transform-expenses.js +18 -19
- package/lib/types/enum-mappings/index.js +5 -1
- package/lib/types/events/public-applicant.d.ts +20 -0
- package/lib/types/events/public-applicant.js +16 -1
- package/lib/update-application/update-primary-applicant.d.ts +30 -0
- package/lib/update-application/update-primary-applicant.js +63 -0
- package/package.json +1 -1
- package/lib/transform-events/generate-application.d.ts +0 -8
- package/lib/transform-events/generate-application.js +0 -49
- package/lib/transform-events/generate-asset.d.ts +0 -17
- package/lib/transform-events/generate-asset.js +0 -178
- package/lib/transform-events/generate-expenses.d.ts +0 -28
- package/lib/transform-events/generate-expenses.js +0 -94
- package/lib/transform-events/generate-income.d.ts +0 -57
- package/lib/transform-events/generate-income.js +0 -247
- package/lib/transform-events/generate-liability.d.ts +0 -8
- package/lib/transform-events/generate-liability.js +0 -87
- package/lib/transform-events/generate-lixi-percentowned.d.ts +0 -12
- package/lib/transform-events/generate-lixi-percentowned.js +0 -23
- package/lib/transform-events/generate-opportunity.d.ts +0 -8
- package/lib/transform-events/generate-opportunity.js +0 -32
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -63,6 +63,34 @@
|
|
|
63
63
|
"enum": ["EMPLOYEE", "SELF_EMPLOYED", "UNKNOWN"],
|
|
64
64
|
"description": "applicant's employment type"
|
|
65
65
|
},
|
|
66
|
+
"guarantorRelationshipToBorrowerApplicantId": {
|
|
67
|
+
"$ref": "#/definitions/id",
|
|
68
|
+
"description": "Applicant Id of borrower that has relationship with guarantor."
|
|
69
|
+
},
|
|
70
|
+
"guarantorRelationshipToBorrowerType": {
|
|
71
|
+
"enum": ["Father", "Mother", "Spouse", "Brother", "Sister", "Son", "Daughter", "Other Relative", "Other"],
|
|
72
|
+
"description": "The relationship between borrower and guarantor."
|
|
73
|
+
},
|
|
74
|
+
"guarantorRelationshipToBorrowerTypeOther": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"description": "Description of relationship between borrower and guarantor when other."
|
|
77
|
+
},
|
|
78
|
+
"guarantorRelationshipToBorrowerDefinition": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"additionalProperties": false,
|
|
81
|
+
"properties": {
|
|
82
|
+
"applicantId": {
|
|
83
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerApplicantId"
|
|
84
|
+
},
|
|
85
|
+
"type": {
|
|
86
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerType"
|
|
87
|
+
},
|
|
88
|
+
"typeOther": {
|
|
89
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerTypeOther"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"required": ["applicantId", "type"]
|
|
93
|
+
},
|
|
66
94
|
"isPrimaryApplicant": {
|
|
67
95
|
"type": "boolean"
|
|
68
96
|
},
|
|
@@ -568,6 +596,9 @@
|
|
|
568
596
|
"employmentType": {
|
|
569
597
|
"$ref": "#/definitions/employmentType"
|
|
570
598
|
},
|
|
599
|
+
"guarantorRelationshipToBorrower": {
|
|
600
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerDefinition"
|
|
601
|
+
},
|
|
571
602
|
"isPrimaryApplicant": {
|
|
572
603
|
"$ref": "#/definitions/isPrimaryApplicant"
|
|
573
604
|
},
|
|
@@ -110,7 +110,7 @@ function transformAsset(_a) {
|
|
|
110
110
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyExpense"), propertyExpenses);
|
|
111
111
|
var livingExpenses = generateLivingExpenses(asset.percentOwned, id, value);
|
|
112
112
|
(0, lodash_1.set)(partialApplication, assetMapping[key], livingExpenses);
|
|
113
|
-
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, "
|
|
113
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@Occupancy"), determineOccupancy(value));
|
|
114
114
|
break;
|
|
115
115
|
case 'propertyStatus':
|
|
116
116
|
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
|
|
@@ -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
|
exports.__esModule = true;
|
|
14
3
|
exports.isLivingExpenseEstimate = exports.isOtherCommitment = exports.normaliseExpenseAmount = exports.transformExpense = exports.transformExpenses = exports.otherCommitmentExpenseTypes = void 0;
|
|
15
4
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
@@ -21,6 +10,12 @@ exports.otherCommitmentExpenseTypes = [
|
|
|
21
10
|
public_expense_1.ExpenseType.ChildAndSpousalMaintenance,
|
|
22
11
|
public_expense_1.ExpenseType.Rent,
|
|
23
12
|
];
|
|
13
|
+
var propertyExpenseCategories = [
|
|
14
|
+
public_expense_1.ExpenseType.InvestmentPropertyRunningCosts,
|
|
15
|
+
public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
|
|
16
|
+
public_expense_1.ExpenseType.SecondaryResidenceRunningCosts,
|
|
17
|
+
public_expense_1.ExpenseType.PrimaryResidenceRunningCosts,
|
|
18
|
+
];
|
|
24
19
|
/**
|
|
25
20
|
* @description Transforms expense items on the application from the event.
|
|
26
21
|
* @returns {PartialApplication} A PartialApplication returned by transforming the expense event.
|
|
@@ -33,12 +28,13 @@ function transformExpenses(expense) {
|
|
|
33
28
|
return partialApplication;
|
|
34
29
|
}
|
|
35
30
|
var normalisedExpenses = expenses.map(normaliseExpenseAmount);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
31
|
+
var filteredLivingExpensesWithAmount = normalisedExpenses.filter(function (expense) { return expense.amount || !propertyExpenseCategories.includes(expense.type); });
|
|
32
|
+
var livingExpenseEstimate = filteredLivingExpensesWithAmount.find(isLivingExpenseEstimate);
|
|
33
|
+
var otherCommitments = filteredLivingExpensesWithAmount.filter(isOtherCommitment);
|
|
34
|
+
var expenseBreakdown = filteredLivingExpensesWithAmount.filter(function (item) { return !(isOtherCommitment(item) || isLivingExpenseEstimate(item)); });
|
|
39
35
|
var livingExpenseEstimateExists = (0, lodash_1.get)(livingExpenseEstimate || {}, 'amount', 0) > 0;
|
|
40
36
|
var expenseBreakdownAmountSum = (0, lodash_1.sumBy)(expenseBreakdown, 'amount');
|
|
41
|
-
var lixiLivingExpenses
|
|
37
|
+
var lixiLivingExpenses;
|
|
42
38
|
// unless all individual expenses have a value of 0 and a living estimate exists, transform them without question.
|
|
43
39
|
if (expenseBreakdownAmountSum === 0 && livingExpenseEstimateExists) {
|
|
44
40
|
var estimate = transformExpense(livingExpenseEstimate, applicantId, 0, id);
|
|
@@ -92,12 +88,15 @@ exports.transformExpense = transformExpense;
|
|
|
92
88
|
* @returns {Expense} An normalised expense.
|
|
93
89
|
*/
|
|
94
90
|
function normaliseExpenseAmount(expense) {
|
|
95
|
-
var
|
|
91
|
+
var amount = expense.amount, _a = expense.frequency, frequency = _a === void 0 ? public_expense_1.Frequency.Yearly : _a, expenseType = expense.type;
|
|
96
92
|
if (frequency === public_expense_1.Frequency.Quarterly) {
|
|
97
|
-
frequency = public_expense_1.Frequency.Yearly;
|
|
98
|
-
amount
|
|
93
|
+
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
94
|
+
expense.amount *= 4;
|
|
95
|
+
}
|
|
96
|
+
if (!amount && !propertyExpenseCategories.includes(expenseType)) {
|
|
97
|
+
expense.amount = 0;
|
|
99
98
|
}
|
|
100
|
-
return
|
|
99
|
+
return expense;
|
|
101
100
|
}
|
|
102
101
|
exports.normaliseExpenseAmount = normaliseExpenseAmount;
|
|
103
102
|
/**
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -36,6 +36,7 @@ export interface Payload {
|
|
|
36
36
|
entity?: Entity;
|
|
37
37
|
firstName?: string;
|
|
38
38
|
gender?: Gender;
|
|
39
|
+
guarantorRelationshipToBorrower?: GuarantorRelationshipToBorrowerDefinition;
|
|
39
40
|
hasSelfEmploymentProof?: boolean;
|
|
40
41
|
/**
|
|
41
42
|
* uuid of applicant
|
|
@@ -429,6 +430,25 @@ export declare enum Gender {
|
|
|
429
430
|
Undisclosed = "UNDISCLOSED",
|
|
430
431
|
Unknown = "UNKNOWN"
|
|
431
432
|
}
|
|
433
|
+
export interface GuarantorRelationshipToBorrowerDefinition {
|
|
434
|
+
applicantId: string;
|
|
435
|
+
type: GuarantorRelationshipToBorrowerType;
|
|
436
|
+
typeOther?: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The relationship between borrower and guarantor.
|
|
440
|
+
*/
|
|
441
|
+
export declare enum GuarantorRelationshipToBorrowerType {
|
|
442
|
+
Brother = "Brother",
|
|
443
|
+
Daughter = "Daughter",
|
|
444
|
+
Father = "Father",
|
|
445
|
+
Mother = "Mother",
|
|
446
|
+
Other = "Other",
|
|
447
|
+
OtherRelative = "Other Relative",
|
|
448
|
+
Sister = "Sister",
|
|
449
|
+
Son = "Son",
|
|
450
|
+
Spouse = "Spouse"
|
|
451
|
+
}
|
|
432
452
|
/**
|
|
433
453
|
* different invitation statuses an applicant can have
|
|
434
454
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.Type = exports.Title = exports.ResidencyStatus = exports.ActionedByRole = exports.MaritalStatus = exports.InvitationStatus = exports.Gender = exports.Entity = exports.EmploymentType = exports.CreditStatus = exports.HousingStatusList = exports.Countries = exports.ApplicantType = void 0;
|
|
3
|
+
exports.Type = exports.Title = exports.ResidencyStatus = exports.ActionedByRole = exports.MaritalStatus = exports.InvitationStatus = exports.GuarantorRelationshipToBorrowerType = exports.Gender = exports.Entity = exports.EmploymentType = exports.CreditStatus = exports.HousingStatusList = exports.Countries = exports.ApplicantType = void 0;
|
|
4
4
|
var ApplicantType;
|
|
5
5
|
(function (ApplicantType) {
|
|
6
6
|
ApplicantType["Borrower"] = "BORROWER";
|
|
@@ -294,6 +294,21 @@ var Gender;
|
|
|
294
294
|
Gender["Undisclosed"] = "UNDISCLOSED";
|
|
295
295
|
Gender["Unknown"] = "UNKNOWN";
|
|
296
296
|
})(Gender = exports.Gender || (exports.Gender = {}));
|
|
297
|
+
/**
|
|
298
|
+
* The relationship between borrower and guarantor.
|
|
299
|
+
*/
|
|
300
|
+
var GuarantorRelationshipToBorrowerType;
|
|
301
|
+
(function (GuarantorRelationshipToBorrowerType) {
|
|
302
|
+
GuarantorRelationshipToBorrowerType["Brother"] = "Brother";
|
|
303
|
+
GuarantorRelationshipToBorrowerType["Daughter"] = "Daughter";
|
|
304
|
+
GuarantorRelationshipToBorrowerType["Father"] = "Father";
|
|
305
|
+
GuarantorRelationshipToBorrowerType["Mother"] = "Mother";
|
|
306
|
+
GuarantorRelationshipToBorrowerType["Other"] = "Other";
|
|
307
|
+
GuarantorRelationshipToBorrowerType["OtherRelative"] = "Other Relative";
|
|
308
|
+
GuarantorRelationshipToBorrowerType["Sister"] = "Sister";
|
|
309
|
+
GuarantorRelationshipToBorrowerType["Son"] = "Son";
|
|
310
|
+
GuarantorRelationshipToBorrowerType["Spouse"] = "Spouse";
|
|
311
|
+
})(GuarantorRelationshipToBorrowerType = exports.GuarantorRelationshipToBorrowerType || (exports.GuarantorRelationshipToBorrowerType = {}));
|
|
297
312
|
/**
|
|
298
313
|
* different invitation statuses an applicant can have
|
|
299
314
|
*/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PersonApplicant } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
import { PartialApplication } from '../types/partial-application';
|
|
3
|
+
import { Payload } from '../types/events/public-applicant';
|
|
4
|
+
/**
|
|
5
|
+
* Checks if there are more than one person applicants with applicant type borrower
|
|
6
|
+
*
|
|
7
|
+
* @param {PersonApplicants[]} personApplicants - Person applicants on the deep merged application
|
|
8
|
+
*
|
|
9
|
+
* @returns {boolean} - Whether or not there are more than one applicant with applicant type borrower
|
|
10
|
+
*/
|
|
11
|
+
export declare const isMultiplePersonApplicantBorrowers: (personApplicants: PersonApplicant[]) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Updates the primary applicant of the application based on the new primary applicant id
|
|
14
|
+
*
|
|
15
|
+
* @param {String} newPrimaryApplicantId - New primary applicant id
|
|
16
|
+
* @param {PersonApplicant[]} personApplicants - Person applicants from the updated application after deep merge
|
|
17
|
+
*
|
|
18
|
+
* @returns {PersonApplicant[]} - Updated person applicants
|
|
19
|
+
*/
|
|
20
|
+
export declare const updatePrimaryApplicant: (newPrimaryApplicantId: string, personApplicants: PersonApplicant[]) => PersonApplicant[];
|
|
21
|
+
/**
|
|
22
|
+
* Updates the primary applicant on the application based on the data in the guarantor applicant event
|
|
23
|
+
*
|
|
24
|
+
* @param {PartialApplication} application - Application after deep merge
|
|
25
|
+
* @param {Payload} applicantPayload - Public applicant event payload
|
|
26
|
+
*
|
|
27
|
+
* @returns {PartialApplication} - Updated application
|
|
28
|
+
*/
|
|
29
|
+
declare const updatePrimaryApplicantUsingGuarantor: (application: PartialApplication, applicantPayload: Payload) => PartialApplication;
|
|
30
|
+
export default updatePrimaryApplicantUsingGuarantor;
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
exports.__esModule = true;
|
|
14
|
+
exports.updatePrimaryApplicant = exports.isMultiplePersonApplicantBorrowers = void 0;
|
|
15
|
+
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
16
|
+
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
17
|
+
var lodash_1 = require("lodash");
|
|
18
|
+
var public_applicant_1 = require("../types/events/public-applicant");
|
|
19
|
+
/**
|
|
20
|
+
* Checks if there are more than one person applicants with applicant type borrower
|
|
21
|
+
*
|
|
22
|
+
* @param {PersonApplicants[]} personApplicants - Person applicants on the deep merged application
|
|
23
|
+
*
|
|
24
|
+
* @returns {boolean} - Whether or not there are more than one applicant with applicant type borrower
|
|
25
|
+
*/
|
|
26
|
+
var isMultiplePersonApplicantBorrowers = function (personApplicants) {
|
|
27
|
+
var totalBorrowerApplicants = personApplicants.filter(function (applicant) { return applicant['@ApplicantType'] === lixi_internal_request_1.ApplicantTypeList.Borrower; }).length;
|
|
28
|
+
return totalBorrowerApplicants > 1;
|
|
29
|
+
};
|
|
30
|
+
exports.isMultiplePersonApplicantBorrowers = isMultiplePersonApplicantBorrowers;
|
|
31
|
+
/**
|
|
32
|
+
* Updates the primary applicant of the application based on the new primary applicant id
|
|
33
|
+
*
|
|
34
|
+
* @param {String} newPrimaryApplicantId - New primary applicant id
|
|
35
|
+
* @param {PersonApplicant[]} personApplicants - Person applicants from the updated application after deep merge
|
|
36
|
+
*
|
|
37
|
+
* @returns {PersonApplicant[]} - Updated person applicants
|
|
38
|
+
*/
|
|
39
|
+
var updatePrimaryApplicant = function (newPrimaryApplicantId, personApplicants) {
|
|
40
|
+
return personApplicants.map(function (applicant) {
|
|
41
|
+
var _a;
|
|
42
|
+
return (__assign(__assign({}, applicant), (_a = {}, _a['@PrimaryApplicant'] = applicant['@UniqueID'] === newPrimaryApplicantId ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No, _a)));
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
exports.updatePrimaryApplicant = updatePrimaryApplicant;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the primary applicant on the application based on the data in the guarantor applicant event
|
|
48
|
+
*
|
|
49
|
+
* @param {PartialApplication} application - Application after deep merge
|
|
50
|
+
* @param {Payload} applicantPayload - Public applicant event payload
|
|
51
|
+
*
|
|
52
|
+
* @returns {PartialApplication} - Updated application
|
|
53
|
+
*/
|
|
54
|
+
var updatePrimaryApplicantUsingGuarantor = function (application, applicantPayload) {
|
|
55
|
+
var updatedApplication = application, personApplicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
|
|
56
|
+
// Checks if there are more than one borrower in the application and that the applicant type of the applicant event being processed is GUARANTOR
|
|
57
|
+
if ((0, exports.isMultiplePersonApplicantBorrowers)(personApplicants) &&
|
|
58
|
+
applicantPayload.applicantType === public_applicant_1.ApplicantType.Guarantor) {
|
|
59
|
+
(0, lodash_1.set)(updatedApplication, application_paths_1.paths.PersonApplicants, (0, exports.updatePrimaryApplicant)(applicantPayload.guarantorRelationshipToBorrower.applicantId, personApplicants));
|
|
60
|
+
}
|
|
61
|
+
return updatedApplication;
|
|
62
|
+
};
|
|
63
|
+
exports["default"] = updatePrimaryApplicantUsingGuarantor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
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",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Payload as ApplicationPayload } from '../types/events/public-application';
|
|
2
|
-
/**
|
|
3
|
-
* Generates a partial internal request from a partial opportunity event.
|
|
4
|
-
*
|
|
5
|
-
* @param opportunity: Partial opportunity event.
|
|
6
|
-
* @return partialApplication: A partial internal request.
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateApplication(opportunity: ApplicationPayload): {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.generateApplication = void 0;
|
|
4
|
-
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
-
var lodash_1 = require("lodash");
|
|
6
|
-
var preferred_repayment_1 = require("../types/enum-mappings/preferred-repayment");
|
|
7
|
-
var transaction_type_1 = require("../types/enum-mappings/transaction-type");
|
|
8
|
-
/**
|
|
9
|
-
* Generates a partial internal request from a partial opportunity event.
|
|
10
|
-
*
|
|
11
|
-
* @param opportunity: Partial opportunity event.
|
|
12
|
-
* @return partialApplication: A partial internal request.
|
|
13
|
-
*/
|
|
14
|
-
function generateApplication(opportunity) {
|
|
15
|
-
var partialApplication = {};
|
|
16
|
-
var opportunityMapping = {
|
|
17
|
-
brand: application_paths_1.paths.BusinessName,
|
|
18
|
-
id: application_paths_1.paths.ApplicationId,
|
|
19
|
-
paymentType: application_paths_1.paths.LoanTerm + ".@PaymentType",
|
|
20
|
-
preliminary: 'preliminary',
|
|
21
|
-
primaryPurpose: application_paths_1.paths.PurposeOfApplication
|
|
22
|
-
};
|
|
23
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail + ".@UniqueID", opportunity.id + "-loanDetails");
|
|
24
|
-
for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
|
|
25
|
-
var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
|
|
26
|
-
if (opportunityMapping[opportunityKey]) {
|
|
27
|
-
if (opportunityKey === 'preliminary') {
|
|
28
|
-
for (var _c = 0, _d = Object.entries(opportunityValue); _c < _d.length; _c++) {
|
|
29
|
-
var _e = _d[_c], key = _e[0], value = _e[1];
|
|
30
|
-
if (opportunityMapping[key]) {
|
|
31
|
-
switch (key) {
|
|
32
|
-
case 'paymentType':
|
|
33
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key], preferred_repayment_1.preferredRepaymentMapping[value]);
|
|
34
|
-
break;
|
|
35
|
-
case 'primaryPurpose':
|
|
36
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key], transaction_type_1.transactionTypeMapping[value]);
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return partialApplication;
|
|
48
|
-
}
|
|
49
|
-
exports.generateApplication = generateApplication;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Asset, AssetDefinition as Payload } from '../types/events/public-asset';
|
|
2
|
-
export declare const residentialTypeList: string[];
|
|
3
|
-
export declare const propertyTypeNameList: string[];
|
|
4
|
-
/**
|
|
5
|
-
* Generates a partial internal request from a partial public asset event.
|
|
6
|
-
*
|
|
7
|
-
* @param asset: A partial public asset.
|
|
8
|
-
* @param applicationId: Id of application.
|
|
9
|
-
* @param id: Id of asset entity.
|
|
10
|
-
* @return A partial InternalRequest.
|
|
11
|
-
*/
|
|
12
|
-
export declare function generateAsset({ asset, applicationId, id }: Payload): {};
|
|
13
|
-
/**
|
|
14
|
-
* Checks if the asset is of financial type.
|
|
15
|
-
* @param asset asset payload
|
|
16
|
-
*/
|
|
17
|
-
export declare function isFinancialAsset(asset: Asset): boolean;
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.isFinancialAsset = exports.generateAsset = exports.propertyTypeNameList = exports.residentialTypeList = void 0;
|
|
4
|
-
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
-
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
|
-
var lodash_1 = require("lodash");
|
|
7
|
-
var logger_1 = require("../logger");
|
|
8
|
-
var public_financial_asset_1 = require("../types/enum-mappings/public-financial-asset");
|
|
9
|
-
var public_primary_purpose_1 = require("../types/enum-mappings/public-primary-purpose");
|
|
10
|
-
var public_property_status_1 = require("../types/enum-mappings/public-property-status");
|
|
11
|
-
var public_property_type_1 = require("../types/enum-mappings/public-property-type");
|
|
12
|
-
var public_asset_1 = require("../types/events/public-asset");
|
|
13
|
-
var generate_address_1 = require("../utils/generate-address");
|
|
14
|
-
var get_financial_institution_1 = require("../utils/get-financial-institution");
|
|
15
|
-
var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
|
|
16
|
-
var toBeUsedAsSecurityMapping = {
|
|
17
|
-
"true": lixi_internal_request_1.YesNoList.Yes,
|
|
18
|
-
"false": lixi_internal_request_1.YesNoList.No
|
|
19
|
-
};
|
|
20
|
-
var toBePurchasedMapping = {
|
|
21
|
-
"true": lixi_internal_request_1.AssetTransactionList.Purchasing,
|
|
22
|
-
"false": lixi_internal_request_1.AssetTransactionList.Owns
|
|
23
|
-
};
|
|
24
|
-
var assetMapping = {
|
|
25
|
-
make: application_paths_1.paths.NonRealEstateAsset + ".MotorVehicle.@Make",
|
|
26
|
-
year: application_paths_1.paths.NonRealEstateAsset + ".MotorVehicle.@Year",
|
|
27
|
-
model: application_paths_1.paths.NonRealEstateAsset + ".MotorVehicle.@Model",
|
|
28
|
-
estimatedValue: application_paths_1.paths.NonRealEstateAsset + ".EstimatedValue.@Value",
|
|
29
|
-
zoneType: application_paths_1.paths.RealEstateAsset + ".Zoning.@Type",
|
|
30
|
-
toBeUsedAsSecurity: application_paths_1.paths.RealEstateAsset + ".@ToBeUsedAsSecurity",
|
|
31
|
-
toBePurchased: application_paths_1.paths.RealEstateAsset + ".@Transaction",
|
|
32
|
-
primaryPurpose: application_paths_1.paths.RealEstateAsset + ".@PrimaryPurpose",
|
|
33
|
-
propertyStatus: application_paths_1.paths.RealEstateAsset + ".@Status",
|
|
34
|
-
financialInstitution: application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.AccountNumber.@FinancialInstitution",
|
|
35
|
-
propertyType: application_paths_1.paths.RealEstateAsset + ".Residential.@Type",
|
|
36
|
-
address: application_paths_1.paths.Address
|
|
37
|
-
};
|
|
38
|
-
exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
|
|
39
|
-
exports.propertyTypeNameList = Object.values(lixi_internal_request_1.Custom3PropertyTypeNameList);
|
|
40
|
-
/**
|
|
41
|
-
* Generates a partial internal request from a partial public asset event.
|
|
42
|
-
*
|
|
43
|
-
* @param asset: A partial public asset.
|
|
44
|
-
* @param applicationId: Id of application.
|
|
45
|
-
* @param id: Id of asset entity.
|
|
46
|
-
* @return A partial InternalRequest.
|
|
47
|
-
*/
|
|
48
|
-
function generateAsset(_a) {
|
|
49
|
-
var asset = _a.asset, applicationId = _a.applicationId, id = _a.id;
|
|
50
|
-
var partialApplication = {};
|
|
51
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
52
|
-
var isPropertyAsset = asset.type === public_asset_1.AssetType.Property;
|
|
53
|
-
switch (asset.type) {
|
|
54
|
-
case public_asset_1.AssetType.Vehicle:
|
|
55
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
|
|
56
|
-
break;
|
|
57
|
-
case public_asset_1.AssetType.Property:
|
|
58
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@MultipleDwellings", lixi_internal_request_1.YesNoList.No);
|
|
59
|
-
break;
|
|
60
|
-
case public_asset_1.AssetType.HomeContents:
|
|
61
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
|
|
62
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Type", lixi_internal_request_1.OtherAssetTypeList.HomeContents);
|
|
63
|
-
break;
|
|
64
|
-
case public_asset_1.AssetType.Gifts:
|
|
65
|
-
case public_asset_1.AssetType.OtherAsset:
|
|
66
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
|
|
67
|
-
if (asset.description)
|
|
68
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Description", asset.description);
|
|
69
|
-
break;
|
|
70
|
-
case public_asset_1.AssetType.Shares:
|
|
71
|
-
case public_asset_1.AssetType.Superannuation:
|
|
72
|
-
case public_asset_1.AssetType.TermDeposit:
|
|
73
|
-
case public_asset_1.AssetType.SavingCheckAccount:
|
|
74
|
-
case public_asset_1.AssetType.ManagedFunds:
|
|
75
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
|
|
76
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.@Type", public_financial_asset_1.financialAssetMapping[asset.type]);
|
|
77
|
-
break;
|
|
78
|
-
default:
|
|
79
|
-
logger_1.logger.warn({ message: "Unhandled asset type: " + asset.type, applicationId: applicationId });
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (isPropertyAsset) {
|
|
83
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@UniqueID", id);
|
|
84
|
-
assetMapping.percentOwned = application_paths_1.paths.RealEstateAsset + ".PercentOwned";
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@UniqueID", id);
|
|
88
|
-
assetMapping.percentOwned = application_paths_1.paths.NonRealEstateAsset + ".PercentOwned";
|
|
89
|
-
}
|
|
90
|
-
for (var _i = 0, _b = Object.entries(asset); _i < _b.length; _i++) {
|
|
91
|
-
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
92
|
-
if (assetMapping[key]) {
|
|
93
|
-
switch (key) {
|
|
94
|
-
case 'primaryPurpose':
|
|
95
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], public_primary_purpose_1.primaryPurposeMapping[value]);
|
|
96
|
-
break;
|
|
97
|
-
case 'toBePurchased':
|
|
98
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], toBePurchasedMapping[value]);
|
|
99
|
-
break;
|
|
100
|
-
case 'propertyStatus':
|
|
101
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], public_property_status_1.propertyStatusMapping[value]);
|
|
102
|
-
break;
|
|
103
|
-
case 'toBeUsedAsSecurity':
|
|
104
|
-
if (isPropertyAsset)
|
|
105
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], toBeUsedAsSecurityMapping[value]);
|
|
106
|
-
break;
|
|
107
|
-
case 'estimatedValue':
|
|
108
|
-
if (isPropertyAsset) {
|
|
109
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".EstimatedValue.@Value", value);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], value);
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
case 'propertyType':
|
|
116
|
-
var mappedValue = public_property_type_1.propertyTypeMapping[value];
|
|
117
|
-
if (exports.residentialTypeList.includes(mappedValue)) {
|
|
118
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".Residential.@Type", mappedValue);
|
|
119
|
-
}
|
|
120
|
-
else if (exports.propertyTypeNameList.includes(mappedValue)) {
|
|
121
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".PropertyType.@PropertyTypeName", mappedValue);
|
|
122
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".PropertyType.@CategoryTypeName", lixi_internal_request_1.Custom2CategoryTypeNameList.Residential);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
logger_1.logger.warn({ message: "Unknown propertyType " + value + " for asset " + id, applicationId: applicationId });
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
case 'zoneType':
|
|
129
|
-
if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
|
|
130
|
-
(0, lodash_1.set)(partialApplication, 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.Custom4TypeList.Commercial);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Residential);
|
|
135
|
-
}
|
|
136
|
-
break;
|
|
137
|
-
case 'financialInstitution':
|
|
138
|
-
if (isFinancialAsset(asset)) {
|
|
139
|
-
var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
|
|
140
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], financialInstitution);
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
143
|
-
case 'year':
|
|
144
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], value.toString());
|
|
145
|
-
break;
|
|
146
|
-
case 'address':
|
|
147
|
-
var addressId = id + "-address";
|
|
148
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@x_Address", addressId);
|
|
149
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], (0, generate_address_1.generateAddress)(value, addressId));
|
|
150
|
-
break;
|
|
151
|
-
case 'percentOwned':
|
|
152
|
-
var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
|
|
153
|
-
if (percentOwned) {
|
|
154
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
default:
|
|
158
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key], value);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return partialApplication;
|
|
163
|
-
}
|
|
164
|
-
exports.generateAsset = generateAsset;
|
|
165
|
-
/**
|
|
166
|
-
* Checks if the asset is of financial type.
|
|
167
|
-
* @param asset asset payload
|
|
168
|
-
*/
|
|
169
|
-
function isFinancialAsset(asset) {
|
|
170
|
-
return [
|
|
171
|
-
public_asset_1.AssetType.Shares,
|
|
172
|
-
public_asset_1.AssetType.Superannuation,
|
|
173
|
-
public_asset_1.AssetType.TermDeposit,
|
|
174
|
-
public_asset_1.AssetType.SavingCheckAccount,
|
|
175
|
-
public_asset_1.AssetType.ManagedFunds,
|
|
176
|
-
].includes(asset.type);
|
|
177
|
-
}
|
|
178
|
-
exports.isFinancialAsset = isFinancialAsset;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { LivingExpense, OtherCommitment } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
-
import { Expense, Payload as ExpensePayload } from '../types/events/public-expense';
|
|
3
|
-
/**
|
|
4
|
-
* Generates expense items on the application from the event.
|
|
5
|
-
* @param expense event payload.
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateExpenses(expense: ExpensePayload): {};
|
|
8
|
-
/**
|
|
9
|
-
* Generates the living expense from the expense array on the event.
|
|
10
|
-
*
|
|
11
|
-
* @param expense: Array of expenses on the event.
|
|
12
|
-
* @param applicantId: Event applicantId.
|
|
13
|
-
* @param index: Index of the map.
|
|
14
|
-
* @param id: Id of the event.
|
|
15
|
-
*/
|
|
16
|
-
export declare function generateExpense(
|
|
17
|
-
expense: Expense,
|
|
18
|
-
applicantId: string,
|
|
19
|
-
index: number,
|
|
20
|
-
id: string
|
|
21
|
-
): LivingExpense | OtherCommitment;
|
|
22
|
-
/**
|
|
23
|
-
* Should change any expense with frequency as quarterly value to yearly and change the amount also set amount to 0
|
|
24
|
-
* if not available, also remove the type living_expenses_estimate.
|
|
25
|
-
*
|
|
26
|
-
* @param expenses: expenses array from the event.
|
|
27
|
-
*/
|
|
28
|
-
export declare function normaliseExpenseAmount(expenses: Expense[]): Expense[];
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.normaliseExpenseAmount = exports.generateExpense = exports.generateExpenses = void 0;
|
|
4
|
-
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
-
var lodash_1 = require("lodash");
|
|
6
|
-
var expense_frequency_1 = require("../types/enum-mappings/expense-frequency");
|
|
7
|
-
var living_expense_1 = require("../types/enum-mappings/living-expense");
|
|
8
|
-
var public_expense_1 = require("../types/events/public-expense");
|
|
9
|
-
var otherCommitmentExpenseTypes = [public_expense_1.ExpenseType.Board, public_expense_1.ExpenseType.ChildAndSpousalMaintenance, public_expense_1.ExpenseType.Rent];
|
|
10
|
-
/**
|
|
11
|
-
* Generates expense items on the application from the event.
|
|
12
|
-
* @param expense event payload.
|
|
13
|
-
*/
|
|
14
|
-
function generateExpenses(expense) {
|
|
15
|
-
var partialApplication = {};
|
|
16
|
-
var applicantId = expense.applicantId, applicationId = expense.applicationId, expenses = expense.expenses, id = expense.id;
|
|
17
|
-
var normalizedExpenses = normaliseExpenseAmount(expenses);
|
|
18
|
-
var otherCommitmentExpenses = normalizedExpenses.filter(function (expense) {
|
|
19
|
-
return otherCommitmentExpenseTypes.includes(expense.type);
|
|
20
|
-
});
|
|
21
|
-
var livingExpenses = normalizedExpenses.filter(function (expense) { return !otherCommitmentExpenseTypes.includes(expense.type); });
|
|
22
|
-
var lixiLivingExpenses = [];
|
|
23
|
-
var lixiCommitmentExpenses = otherCommitmentExpenses.map(function (expense, index) {
|
|
24
|
-
return generateExpense(expense, applicantId, index, id);
|
|
25
|
-
});
|
|
26
|
-
var expenseEstimate = expenses.find(function (expense) { return expense.type === public_expense_1.ExpenseType.LivingExpensesEstimate; });
|
|
27
|
-
var livingExpenseEstimateExists = expenseEstimate && expenseEstimate.amount && expenseEstimate.amount > 0;
|
|
28
|
-
var expensesWithoutEstimate = livingExpenses.filter(function (expense) { return expense.type !== public_expense_1.ExpenseType.LivingExpensesEstimate; });
|
|
29
|
-
var expensesAmountSum = (0, lodash_1.sumBy)(expensesWithoutEstimate, 'amount');
|
|
30
|
-
if (expensesAmountSum === 0 && livingExpenseEstimateExists) {
|
|
31
|
-
lixiLivingExpenses = [generateExpense(expenseEstimate, applicantId, 0, id)];
|
|
32
|
-
}
|
|
33
|
-
if (expensesAmountSum > 0) {
|
|
34
|
-
lixiLivingExpenses = expensesWithoutEstimate.map(function (expense, index) {
|
|
35
|
-
return generateExpense(expense, applicantId, index, id);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
if (lixiLivingExpenses.length > 0) {
|
|
39
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
40
|
-
}
|
|
41
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
42
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
|
|
43
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
|
|
44
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
45
|
-
return partialApplication;
|
|
46
|
-
}
|
|
47
|
-
exports.generateExpenses = generateExpenses;
|
|
48
|
-
/**
|
|
49
|
-
* Generates the living expense from the expense array on the event.
|
|
50
|
-
*
|
|
51
|
-
* @param expense: Array of expenses on the event.
|
|
52
|
-
* @param applicantId: Event applicantId.
|
|
53
|
-
* @param index: Index of the map.
|
|
54
|
-
* @param id: Id of the event.
|
|
55
|
-
*/
|
|
56
|
-
function generateExpense(expense, applicantId, index, id) {
|
|
57
|
-
return {
|
|
58
|
-
'@Amount': expense.amount,
|
|
59
|
-
'@Category': living_expense_1.livingExpenseMapping[expense.type],
|
|
60
|
-
'@Description': expense.type,
|
|
61
|
-
'@UniqueID': otherCommitmentExpenseTypes.includes(expense.type)
|
|
62
|
-
? id + "-commitment-" + index
|
|
63
|
-
: id + "-living-expense-" + index,
|
|
64
|
-
'@Frequency': expense_frequency_1.frequencyMapping[expense.frequency],
|
|
65
|
-
PercentResponsible: {
|
|
66
|
-
Owner: [
|
|
67
|
-
{
|
|
68
|
-
'@Percent': 100,
|
|
69
|
-
'@x_Party': applicantId
|
|
70
|
-
},
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
exports.generateExpense = generateExpense;
|
|
76
|
-
/**
|
|
77
|
-
* Should change any expense with frequency as quarterly value to yearly and change the amount also set amount to 0
|
|
78
|
-
* if not available, also remove the type living_expenses_estimate.
|
|
79
|
-
*
|
|
80
|
-
* @param expenses: expenses array from the event.
|
|
81
|
-
*/
|
|
82
|
-
function normaliseExpenseAmount(expenses) {
|
|
83
|
-
return expenses.map(function (expense) {
|
|
84
|
-
if (!expense.amount) {
|
|
85
|
-
expense.amount = 0;
|
|
86
|
-
}
|
|
87
|
-
if (expense.frequency === public_expense_1.Frequency.Quarterly) {
|
|
88
|
-
expense.amount *= 4;
|
|
89
|
-
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
90
|
-
}
|
|
91
|
-
return expense;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
exports.normaliseExpenseAmount = normaliseExpenseAmount;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Frequency,
|
|
3
|
-
OwnershipProportion as PercentOwned,
|
|
4
|
-
IncomeDefinition as IncomePayload,
|
|
5
|
-
} from '../types/events/public-income';
|
|
6
|
-
import { PersonApplicant } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
7
|
-
export interface AmountFrequency {
|
|
8
|
-
amount: string;
|
|
9
|
-
frequency?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const EmploymentIncomeTypeMapping: Record<string, AmountFrequency>;
|
|
12
|
-
export declare function isPaygIncome(incomeType: string): boolean;
|
|
13
|
-
export declare function isSelfEmployedIncome(incomeType: string): boolean;
|
|
14
|
-
export declare function isRentalIncome(incomeType: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Generates an partial application from a partial income event.
|
|
17
|
-
*
|
|
18
|
-
* @param payload a partial income event.
|
|
19
|
-
* @param storedApplication: Current state of the application.
|
|
20
|
-
* @return partialApplication an incomplete application.
|
|
21
|
-
*/
|
|
22
|
-
export declare function generateIncome(payload: IncomePayload, storedApplication: any): {};
|
|
23
|
-
/**
|
|
24
|
-
* Gets the applicant id if given employmentId belongs to it.
|
|
25
|
-
*
|
|
26
|
-
* @param application
|
|
27
|
-
* @param employmentId
|
|
28
|
-
*/
|
|
29
|
-
export declare function getApplicantIdForEmploymentId(application?: any, employmentId?: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Checks if given employment id belongs to given applicant.
|
|
32
|
-
*
|
|
33
|
-
* @param applicant
|
|
34
|
-
* @param employmentId
|
|
35
|
-
*/
|
|
36
|
-
export declare function containsEmploymentId(applicant: PersonApplicant, employmentId: string): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Gets the employmentId if given income is employment income.
|
|
39
|
-
*
|
|
40
|
-
* @param payload
|
|
41
|
-
*/
|
|
42
|
-
export declare function getEmploymentIdForIncome(payload: IncomePayload): string;
|
|
43
|
-
/**
|
|
44
|
-
* Creates Rental Income array.
|
|
45
|
-
* @param owners List of owners.
|
|
46
|
-
* @param amount Amount
|
|
47
|
-
* @param frequency Frequency
|
|
48
|
-
*/
|
|
49
|
-
export declare function createRentalIncome(
|
|
50
|
-
{ owners }: PercentOwned,
|
|
51
|
-
amount: number,
|
|
52
|
-
frequency: Frequency
|
|
53
|
-
): {
|
|
54
|
-
'@Frequency': import('@lendi/integrations-protocol/lib/types/lixi-internal-request').List;
|
|
55
|
-
'@RentalIncome': number;
|
|
56
|
-
'@x_Owner': string;
|
|
57
|
-
}[];
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.createRentalIncome = exports.getEmploymentIdForIncome = exports.containsEmploymentId = exports.getApplicantIdForEmploymentId = exports.generateIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.EmploymentIncomeTypeMapping = void 0;
|
|
5
|
-
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
|
-
var lodash_1 = require("lodash");
|
|
7
|
-
var logger_1 = require("../logger");
|
|
8
|
-
var public_income_1 = require("../types/events/public-income");
|
|
9
|
-
var round_decimal_1 = require("../utils/round-decimal");
|
|
10
|
-
var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
11
|
-
var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
|
|
12
|
-
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
13
|
-
var income_type_1 = require("../types/enum-mappings/income-type");
|
|
14
|
-
var government_benefits_1 = require("../types/enum-mappings/government-benefits");
|
|
15
|
-
var PAYGList = [
|
|
16
|
-
public_income_1.IncomeType.PaygAllowancesNotTaxed,
|
|
17
|
-
public_income_1.IncomeType.PaygAllowancesTaxed,
|
|
18
|
-
public_income_1.IncomeType.PaygBaseSalary,
|
|
19
|
-
public_income_1.IncomeType.PaygBonusIncome,
|
|
20
|
-
public_income_1.IncomeType.PaygCarAllowance,
|
|
21
|
-
public_income_1.IncomeType.PaygCommissionIncome,
|
|
22
|
-
public_income_1.IncomeType.PaygCompanyCar,
|
|
23
|
-
public_income_1.IncomeType.PaygOvertimeIncome,
|
|
24
|
-
];
|
|
25
|
-
var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
26
|
-
var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
27
|
-
// Income types mapping from internal to LIXI types /paths.
|
|
28
|
-
exports.EmploymentIncomeTypeMapping = (_a = {},
|
|
29
|
-
_a[public_income_1.IncomeType.PaygAllowancesNotTaxed] = {
|
|
30
|
-
amount: 'Income.@WorkAllowanceAmount',
|
|
31
|
-
frequency: 'Income.@WorkAllowanceFrequency'
|
|
32
|
-
},
|
|
33
|
-
_a[public_income_1.IncomeType.PaygAllowancesTaxed] = {
|
|
34
|
-
amount: netWorkAllowanceAmount,
|
|
35
|
-
frequency: netWorkAllowanceFrequency
|
|
36
|
-
},
|
|
37
|
-
_a[public_income_1.IncomeType.PaygBaseSalary] = {
|
|
38
|
-
amount: 'Income.@GrossSalaryAmount',
|
|
39
|
-
frequency: 'Income.@GrossSalaryFrequency'
|
|
40
|
-
},
|
|
41
|
-
_a[public_income_1.IncomeType.PaygBonusIncome] = {
|
|
42
|
-
amount: 'Income.@BonusAmount',
|
|
43
|
-
frequency: 'Income.@BonusFrequency'
|
|
44
|
-
},
|
|
45
|
-
_a[public_income_1.IncomeType.PaygCommissionIncome] = {
|
|
46
|
-
amount: 'Income.@CommissionAmount',
|
|
47
|
-
frequency: 'Income.@CommissionFrequency'
|
|
48
|
-
},
|
|
49
|
-
_a[public_income_1.IncomeType.PaygCompanyCar] = {
|
|
50
|
-
amount: 'Income.@NetCarAllowanceAmount',
|
|
51
|
-
frequency: 'Income.@NetCarAllowanceFrequency'
|
|
52
|
-
},
|
|
53
|
-
_a[public_income_1.IncomeType.PaygCarAllowance] = {
|
|
54
|
-
amount: 'Income.@CarAllowanceAmount',
|
|
55
|
-
frequency: 'Income.@CarAllowanceFrequency'
|
|
56
|
-
},
|
|
57
|
-
_a[public_income_1.IncomeType.PaygOvertimeIncome] = {
|
|
58
|
-
amount: 'Income.@GrossRegularOvertimeAmount',
|
|
59
|
-
frequency: 'Income.@GrossRegularOvertimeFrequency'
|
|
60
|
-
},
|
|
61
|
-
_a[public_income_1.IncomeType.SelfEmployedBusinessIncome] = {
|
|
62
|
-
amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
|
|
63
|
-
},
|
|
64
|
-
_a);
|
|
65
|
-
var descriptionOtherIncomeTypes = [
|
|
66
|
-
public_income_1.IncomeType.InvestmentIncome,
|
|
67
|
-
public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
|
|
68
|
-
public_income_1.IncomeType.RentalIncome,
|
|
69
|
-
];
|
|
70
|
-
// Check if given income type is a PAYG income type.
|
|
71
|
-
function isPaygIncome(incomeType) {
|
|
72
|
-
return PAYGList.includes(incomeType);
|
|
73
|
-
}
|
|
74
|
-
exports.isPaygIncome = isPaygIncome;
|
|
75
|
-
// Check if given income type is a self employment income type.
|
|
76
|
-
function isSelfEmployedIncome(incomeType) {
|
|
77
|
-
return incomeType === public_income_1.IncomeType.SelfEmployedBusinessIncome;
|
|
78
|
-
}
|
|
79
|
-
exports.isSelfEmployedIncome = isSelfEmployedIncome;
|
|
80
|
-
// Check if given income type is a rental income type.
|
|
81
|
-
function isRentalIncome(incomeType) {
|
|
82
|
-
return incomeType === public_income_1.IncomeType.RentalIncome;
|
|
83
|
-
}
|
|
84
|
-
exports.isRentalIncome = isRentalIncome;
|
|
85
|
-
/**
|
|
86
|
-
* Generates an partial application from a partial income event.
|
|
87
|
-
*
|
|
88
|
-
* @param payload a partial income event.
|
|
89
|
-
* @param storedApplication: Current state of the application.
|
|
90
|
-
* @return partialApplication an incomplete application.
|
|
91
|
-
*/
|
|
92
|
-
function generateIncome(payload, storedApplication) {
|
|
93
|
-
var applicationId = payload.applicationId, id = payload.id, income = payload.income;
|
|
94
|
-
var applicantId = (0, lodash_1.get)(income, 'percentOwned.owners[0].applicantId');
|
|
95
|
-
if (!applicantId) {
|
|
96
|
-
var employmentId = getEmploymentIdForIncome(payload);
|
|
97
|
-
applicantId = getApplicantIdForEmploymentId(storedApplication, employmentId);
|
|
98
|
-
}
|
|
99
|
-
var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
|
|
100
|
-
var partialApplication = {};
|
|
101
|
-
var incomeMapping;
|
|
102
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
103
|
-
if (applicantId && !isRentalIncome(incomeType)) {
|
|
104
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
logger_1.logger.warn({
|
|
108
|
-
message: "No applicantId found for income event with id : " + id + " and type " + incomeType + " for application: " + applicationId
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (isPaygIncome(incomeType)) {
|
|
112
|
-
var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
|
|
113
|
-
incomeMapping = {
|
|
114
|
-
amount: application_paths_1.paths.PAYG + "." + amount,
|
|
115
|
-
frequency: application_paths_1.paths.PAYG + "." + frequency,
|
|
116
|
-
employmentId: application_paths_1.paths.PAYG + ".@UniqueID"
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
else if (isSelfEmployedIncome(incomeType)) {
|
|
120
|
-
var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
|
|
121
|
-
incomeMapping = {
|
|
122
|
-
amount: application_paths_1.paths.SelfEmployed + "." + amount,
|
|
123
|
-
employmentId: application_paths_1.paths.SelfEmployed + ".@UniqueID"
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
else if (isRentalIncome(incomeType)) {
|
|
127
|
-
incomeMapping = {
|
|
128
|
-
assetId: application_paths_1.paths.RealEstateAsset + ".@UniqueID",
|
|
129
|
-
percentOwned: application_paths_1.paths.RealEstateAsset + ".RentalIncome"
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome + ".@UniqueID", id);
|
|
134
|
-
incomeMapping = {
|
|
135
|
-
amount: application_paths_1.paths.OtherIncome + ".@Amount",
|
|
136
|
-
frequency: application_paths_1.paths.OtherIncome + ".@Frequency",
|
|
137
|
-
percentOwned: application_paths_1.paths.OtherIncome + ".PercentOwned",
|
|
138
|
-
type: application_paths_1.paths.OtherIncome + ".@Type",
|
|
139
|
-
benefitType: application_paths_1.paths.OtherIncome + ".@GovernmentBenefitsType"
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
for (var _i = 0, _b = Object.entries(income); _i < _b.length; _i++) {
|
|
143
|
-
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
144
|
-
if (incomeMapping[key]) {
|
|
145
|
-
switch (key) {
|
|
146
|
-
case 'amount':
|
|
147
|
-
var amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
|
|
148
|
-
(0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
|
|
149
|
-
break;
|
|
150
|
-
case 'frequency':
|
|
151
|
-
(0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
|
|
152
|
-
break;
|
|
153
|
-
case 'percentOwned':
|
|
154
|
-
var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
|
|
155
|
-
if (isRentalIncome(incomeType)) {
|
|
156
|
-
percentOwned = createRentalIncome(value, incomeAmount, incomeFrequency);
|
|
157
|
-
}
|
|
158
|
-
if (percentOwned) {
|
|
159
|
-
(0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
|
|
160
|
-
}
|
|
161
|
-
break;
|
|
162
|
-
case 'type':
|
|
163
|
-
var mappedType = income_type_1.otherIncomeMapping[value];
|
|
164
|
-
if (descriptionOtherIncomeTypes.includes(value)) {
|
|
165
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome + ".@Description", mappedType);
|
|
166
|
-
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
(0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
|
|
170
|
-
}
|
|
171
|
-
break;
|
|
172
|
-
case 'benefitType':
|
|
173
|
-
(0, lodash_1.set)(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
|
|
174
|
-
break;
|
|
175
|
-
default:
|
|
176
|
-
(0, lodash_1.set)(partialApplication, incomeMapping[key], value);
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return partialApplication;
|
|
182
|
-
}
|
|
183
|
-
exports.generateIncome = generateIncome;
|
|
184
|
-
/**
|
|
185
|
-
* Gets the applicant id if given employmentId belongs to it.
|
|
186
|
-
*
|
|
187
|
-
* @param application
|
|
188
|
-
* @param employmentId
|
|
189
|
-
*/
|
|
190
|
-
function getApplicantIdForEmploymentId(application, employmentId) {
|
|
191
|
-
if (!employmentId || !application)
|
|
192
|
-
return null;
|
|
193
|
-
var applicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
|
|
194
|
-
var applicant = applicants.find(function (applicant) { return containsEmploymentId(applicant, employmentId); });
|
|
195
|
-
return applicant ? applicant['@UniqueID'] : null;
|
|
196
|
-
}
|
|
197
|
-
exports.getApplicantIdForEmploymentId = getApplicantIdForEmploymentId;
|
|
198
|
-
/**
|
|
199
|
-
* Checks if given employment id belongs to given applicant.
|
|
200
|
-
*
|
|
201
|
-
* @param applicant
|
|
202
|
-
* @param employmentId
|
|
203
|
-
*/
|
|
204
|
-
function containsEmploymentId(applicant, employmentId) {
|
|
205
|
-
return (applicant.Employment || []).some(function (employment) {
|
|
206
|
-
return (0, lodash_1.get)(employment, 'PAYG.@UniqueID') === employmentId ||
|
|
207
|
-
(0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') === employmentId ||
|
|
208
|
-
(0, lodash_1.get)(employment, 'NotEmployed.@UniqueID') === employmentId;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
exports.containsEmploymentId = containsEmploymentId;
|
|
212
|
-
/**
|
|
213
|
-
* Gets the employmentId if given income is employment income.
|
|
214
|
-
*
|
|
215
|
-
* @param payload
|
|
216
|
-
*/
|
|
217
|
-
function getEmploymentIdForIncome(payload) {
|
|
218
|
-
var _a = payload.income, incomeType = _a.type, employmentId = _a.employmentId;
|
|
219
|
-
if (isPaygIncome(incomeType) || isSelfEmployedIncome(incomeType))
|
|
220
|
-
return employmentId;
|
|
221
|
-
return undefined;
|
|
222
|
-
}
|
|
223
|
-
exports.getEmploymentIdForIncome = getEmploymentIdForIncome;
|
|
224
|
-
/**
|
|
225
|
-
* Creates Rental Income array.
|
|
226
|
-
* @param owners List of owners.
|
|
227
|
-
* @param amount Amount
|
|
228
|
-
* @param frequency Frequency
|
|
229
|
-
*/
|
|
230
|
-
function createRentalIncome(_a, amount, frequency) {
|
|
231
|
-
var _b = _a.owners, owners = _b === void 0 ? [] : _b;
|
|
232
|
-
if (owners.length === 0)
|
|
233
|
-
return null;
|
|
234
|
-
if (frequency === public_income_1.Frequency.Quarterly) {
|
|
235
|
-
amount = Math.ceil(amount / 3);
|
|
236
|
-
frequency = public_income_1.Frequency.Monthly;
|
|
237
|
-
}
|
|
238
|
-
return owners.map(function (_a) {
|
|
239
|
-
var percent = _a.percent, applicantId = _a.applicantId;
|
|
240
|
-
return ({
|
|
241
|
-
'@Frequency': alieo_frequency_1.incomeExpenseFrequencyMapping[frequency],
|
|
242
|
-
'@RentalIncome': percent * amount,
|
|
243
|
-
'@x_Owner': applicantId
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
exports.createRentalIncome = createRentalIncome;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { LiabilityPayload } from '../types/events/public-liability';
|
|
2
|
-
/**
|
|
3
|
-
* Generates a partial internal request from a liability event payload.
|
|
4
|
-
*
|
|
5
|
-
* @param liabilityPayload: A liability event payload.
|
|
6
|
-
* @return A partial InternalRequest.
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateLiability({ applicationId, id, liability }: LiabilityPayload): {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.generateLiability = void 0;
|
|
4
|
-
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
-
var lodash_1 = require("lodash");
|
|
6
|
-
var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
|
|
7
|
-
var liability_payment_type_1 = require("../types/enum-mappings/liability-payment-type");
|
|
8
|
-
var liability_type_1 = require("../types/enum-mappings/liability-type");
|
|
9
|
-
var get_financial_institution_1 = require("../utils/get-financial-institution");
|
|
10
|
-
var round_decimal_1 = require("../utils/round-decimal");
|
|
11
|
-
var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
|
|
12
|
-
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
13
|
-
/**
|
|
14
|
-
* Generates a partial internal request from a liability event payload.
|
|
15
|
-
*
|
|
16
|
-
* @param liabilityPayload: A liability event payload.
|
|
17
|
-
* @return A partial InternalRequest.
|
|
18
|
-
*/
|
|
19
|
-
function generateLiability(_a) {
|
|
20
|
-
var applicationId = _a.applicationId, id = _a.id, liability = _a.liability;
|
|
21
|
-
var partialApplication = {};
|
|
22
|
-
var liabilityMapping = {
|
|
23
|
-
applicationId: application_paths_1.paths.ApplicationId,
|
|
24
|
-
annualInterestRate: application_paths_1.paths.Liability + ".@AnnualInterestRate",
|
|
25
|
-
id: application_paths_1.paths.Liability + ".@UniqueID",
|
|
26
|
-
clearingFromThisLoan: application_paths_1.paths.Liability + ".@ClearingFromThisLoan",
|
|
27
|
-
description: application_paths_1.paths.Liability + ".@Description",
|
|
28
|
-
financialInstitution: application_paths_1.paths.Liability + ".AccountNumber.@FinancialInstitution",
|
|
29
|
-
newLimit: application_paths_1.paths.Liability + ".@CreditLimit",
|
|
30
|
-
repaymentAmount: application_paths_1.paths.Liability + ".Repayment[0].@RepaymentAmount",
|
|
31
|
-
repaymentFrequency: application_paths_1.paths.Liability + ".Repayment[0].@RepaymentFrequency",
|
|
32
|
-
remainingTermDuration: application_paths_1.paths.Liability + ".RemainingTerm.@Duration",
|
|
33
|
-
repaymentTypeDetails: application_paths_1.paths.Liability + ".Repayment[0].@PaymentType",
|
|
34
|
-
outstandingBalance: application_paths_1.paths.Liability + ".@OutstandingBalance",
|
|
35
|
-
type: application_paths_1.paths.Liability + ".@Type",
|
|
36
|
-
percentOwned: application_paths_1.paths.Liability + ".PercentOwned"
|
|
37
|
-
};
|
|
38
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping.applicationId, applicationId);
|
|
39
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping.id, id);
|
|
40
|
-
// Default repayments to 0 and repaymentFrequency to weekly.
|
|
41
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping.repaymentAmount, 0);
|
|
42
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping.repaymentFrequency, lixi_internal_request_1.List.Weekly);
|
|
43
|
-
// Default clearingFromThisLoan to No if the value is not present in the event.
|
|
44
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping.clearingFromThisLoan, lixi_internal_request_1.YesNoList.No);
|
|
45
|
-
for (var _i = 0, _b = Object.entries(liability); _i < _b.length; _i++) {
|
|
46
|
-
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
47
|
-
if (liabilityMapping[key]) {
|
|
48
|
-
switch (key) {
|
|
49
|
-
case 'outstandingBalance':
|
|
50
|
-
case 'newLimit':
|
|
51
|
-
case 'repaymentAmount':
|
|
52
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], (0, round_decimal_1.roundDecimal)(value));
|
|
53
|
-
break;
|
|
54
|
-
case 'type':
|
|
55
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], liability_type_1.liabilityTypeMapping[value]);
|
|
56
|
-
break;
|
|
57
|
-
case 'clearingFromThisLoan':
|
|
58
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
|
|
59
|
-
break;
|
|
60
|
-
case 'repaymentFrequency':
|
|
61
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], alieo_frequency_1.liabilityFrequencyMapping[value]);
|
|
62
|
-
break;
|
|
63
|
-
case 'repaymentTypeDetails':
|
|
64
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], liability_payment_type_1.liabilityPaymentTypeMapping[value]);
|
|
65
|
-
break;
|
|
66
|
-
case 'remainingTermDuration':
|
|
67
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], Math.round(+value));
|
|
68
|
-
break;
|
|
69
|
-
case 'financialInstitution':
|
|
70
|
-
var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
|
|
71
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], financialInstitution);
|
|
72
|
-
break;
|
|
73
|
-
case 'percentOwned':
|
|
74
|
-
var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
|
|
75
|
-
if (percentOwned) {
|
|
76
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], percentOwned);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
(0, lodash_1.set)(partialApplication, liabilityMapping[key], value);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return partialApplication;
|
|
86
|
-
}
|
|
87
|
-
exports.generateLiability = generateLiability;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PercentOwned } from '../types/events/public-liability';
|
|
2
|
-
/**
|
|
3
|
-
* Transform percentOwned to lixi's format.
|
|
4
|
-
*
|
|
5
|
-
* @param percentOwned PercentOwned for an asset or liability on public liability event.
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateLIXIPercentOwned({ owners }: PercentOwned): {
|
|
8
|
-
Owner: {
|
|
9
|
-
'@Percent': number;
|
|
10
|
-
'@x_Party': string;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.generateLIXIPercentOwned = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Transform percentOwned to lixi's format.
|
|
6
|
-
*
|
|
7
|
-
* @param percentOwned PercentOwned for an asset or liability on public liability event.
|
|
8
|
-
*/
|
|
9
|
-
function generateLIXIPercentOwned(_a) {
|
|
10
|
-
var _b = _a.owners, owners = _b === void 0 ? [] : _b;
|
|
11
|
-
if (owners.length === 0)
|
|
12
|
-
return null;
|
|
13
|
-
return {
|
|
14
|
-
Owner: owners.map(function (_a) {
|
|
15
|
-
var percent = _a.percent, applicantId = _a.applicantId;
|
|
16
|
-
return ({
|
|
17
|
-
'@Percent': percent * 100,
|
|
18
|
-
'@x_Party': applicantId
|
|
19
|
-
});
|
|
20
|
-
})
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.generateLIXIPercentOwned = generateLIXIPercentOwned;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PayloadObject as OpportunityPayload } from '../types/events/opportunity';
|
|
2
|
-
/**
|
|
3
|
-
* Generates a partial internal request from a partial opportunity event.
|
|
4
|
-
*
|
|
5
|
-
* @param opportunity: Partial opportunity event.
|
|
6
|
-
* @return partialApplication: A partial internal request.
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateOpportunity(opportunity: OpportunityPayload): {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.generateOpportunity = void 0;
|
|
4
|
-
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
-
var lodash_1 = require("lodash");
|
|
6
|
-
/**
|
|
7
|
-
* Generates a partial internal request from a partial opportunity event.
|
|
8
|
-
*
|
|
9
|
-
* @param opportunity: Partial opportunity event.
|
|
10
|
-
* @return partialApplication: A partial internal request.
|
|
11
|
-
*/
|
|
12
|
-
function generateOpportunity(opportunity) {
|
|
13
|
-
var partialApplication = {};
|
|
14
|
-
var opportunityMapping = {
|
|
15
|
-
id: application_paths_1.paths.ApplicationId,
|
|
16
|
-
stage: application_paths_1.paths.Instructions
|
|
17
|
-
};
|
|
18
|
-
for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
|
|
19
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
20
|
-
if (opportunityMapping[key]) {
|
|
21
|
-
if (key === 'stage') {
|
|
22
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions + ".@UniqueID", opportunity.id + "-stage");
|
|
23
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key] + ".@Details", value || 'Unknown');
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key], value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return partialApplication;
|
|
31
|
-
}
|
|
32
|
-
exports.generateOpportunity = generateOpportunity;
|