@lendi/integrations-transform 1.4.7 → 1.5.0
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.d.ts +1 -1
- package/lib/index.js +2 -6
- package/lib/schemas/public-application-event.json +6 -0
- package/lib/transform-events/transform-application.js +16 -10
- package/lib/transform-events/transform-funding-position.d.ts +21 -0
- package/lib/transform-events/{generate-funding-position.js → transform-funding-position.js} +30 -15
- package/lib/types/enum-mappings/funding-position.js +4 -2
- package/lib/types/enum-mappings/index.js +1 -5
- package/lib/types/events/public-application.d.ts +1 -0
- package/package.json +2 -2
- package/lib/transform-events/generate-funding-position.d.ts +0 -18
package/lib/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export * from './transform-events/transform-asset';
|
|
|
6
6
|
export * from './transform-events/transform-expenses';
|
|
7
7
|
export * from './transform-events/transform-liability';
|
|
8
8
|
export * from './transform-events/generate-required-document';
|
|
9
|
-
export * from './transform-events/
|
|
9
|
+
export * from './transform-events/transform-funding-position';
|
|
10
10
|
export * from './update-application/merge-application';
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
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
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -23,5 +19,5 @@ __exportStar(require("./transform-events/transform-asset"), exports);
|
|
|
23
19
|
__exportStar(require("./transform-events/transform-expenses"), exports);
|
|
24
20
|
__exportStar(require("./transform-events/transform-liability"), exports);
|
|
25
21
|
__exportStar(require("./transform-events/generate-required-document"), exports);
|
|
26
|
-
__exportStar(require("./transform-events/
|
|
22
|
+
__exportStar(require("./transform-events/transform-funding-position"), exports);
|
|
27
23
|
__exportStar(require("./update-application/merge-application"), exports);
|
|
@@ -119,6 +119,9 @@
|
|
|
119
119
|
"description": "Indication that this application carries high customer intent",
|
|
120
120
|
"type": "boolean"
|
|
121
121
|
},
|
|
122
|
+
"hasOptedInRateLock": {
|
|
123
|
+
"type": "boolean"
|
|
124
|
+
},
|
|
122
125
|
"payload": {
|
|
123
126
|
"type": "object",
|
|
124
127
|
"additionalProperties": false,
|
|
@@ -147,6 +150,9 @@
|
|
|
147
150
|
"brand": {
|
|
148
151
|
"enum": ["lendi", "domain", "domain variation", "lendi variation"]
|
|
149
152
|
},
|
|
153
|
+
"hasOptedInRateLock": {
|
|
154
|
+
"$ref": "#/definitions/hasOptedInRateLock"
|
|
155
|
+
},
|
|
150
156
|
"preliminary": {
|
|
151
157
|
"type": "object",
|
|
152
158
|
"additionalProperties": false,
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.transformApplication = void 0;
|
|
4
4
|
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
5
|
-
var application_paths_1 = require("@lendi/integrations-protocol/
|
|
6
|
-
var application_paths_2 = require("@lendi/integrations-
|
|
5
|
+
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
6
|
+
var application_paths_2 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
7
7
|
var lodash_1 = require("lodash");
|
|
8
8
|
var enum_mappings_1 = require("../types/enum-mappings/");
|
|
9
|
+
var transform_applicant_1 = require("./transform-applicant");
|
|
9
10
|
/**
|
|
10
11
|
* Transforms a partial opportunity event to a partial internal request.
|
|
11
12
|
*
|
|
@@ -15,16 +16,18 @@ var enum_mappings_1 = require("../types/enum-mappings/");
|
|
|
15
16
|
function transformApplication(opportunity) {
|
|
16
17
|
var partialApplication = {};
|
|
17
18
|
var opportunityMapping = {
|
|
18
|
-
brand:
|
|
19
|
-
id:
|
|
20
|
-
paymentType: "".concat(
|
|
19
|
+
brand: application_paths_2.paths.BusinessName,
|
|
20
|
+
id: application_paths_2.paths.ApplicationId,
|
|
21
|
+
paymentType: "".concat(application_paths_2.paths.LoanTerm, ".@PaymentType"),
|
|
21
22
|
preliminary: 'preliminary',
|
|
22
|
-
primaryPurpose:
|
|
23
|
-
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
|
|
23
|
+
primaryPurpose: application_paths_2.paths.PurposeOfApplication,
|
|
24
|
+
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description',
|
|
25
|
+
hasOptedInRateLock: "".concat(application_paths_1.paths.FeaturesSelected, ".@RateLock")
|
|
24
26
|
};
|
|
25
|
-
(0, lodash_1.set)(partialApplication, "".concat(
|
|
26
|
-
(0, lodash_1.set)(partialApplication, "".concat(
|
|
27
|
-
(0, lodash_1.set)(partialApplication, "".concat(
|
|
27
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.LoanDetail, ".@UniqueID"), "".concat(opportunity.id, "-loanDetails"));
|
|
28
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
|
|
29
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@Name"), lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
|
|
30
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.FeaturesSelected, ".@RateLock"), lixi_internal_request_1.YesNoList.No);
|
|
28
31
|
for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
|
|
29
32
|
var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
|
|
30
33
|
if (opportunityMapping[opportunityKey]) {
|
|
@@ -43,6 +46,9 @@ function transformApplication(opportunity) {
|
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
}
|
|
49
|
+
else if (opportunityKey === 'hasOptedInRateLock') {
|
|
50
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], (0, transform_applicant_1.booleanMapping)(opportunityValue));
|
|
51
|
+
}
|
|
46
52
|
else {
|
|
47
53
|
(0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
|
|
48
54
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fee } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { FundsRequiredBreakdown, Payload as FundingPositionPayload } from '../types/events/public-funding-position';
|
|
3
|
+
import { PartialApplication } from '../types/partial-application';
|
|
4
|
+
/**
|
|
5
|
+
* GenerateFundingPosition
|
|
6
|
+
*
|
|
7
|
+
* @param fundingPosition a partialFundingPosition.
|
|
8
|
+
* @param uniqueIdSuffix
|
|
9
|
+
* @return partialApplication with fees, grants and borrowers contributions added.
|
|
10
|
+
*/
|
|
11
|
+
export declare function transformFundingPosition(fundingPosition: FundingPositionPayload, uniqueIdSuffix?: string): PartialApplication;
|
|
12
|
+
/**
|
|
13
|
+
* getFee
|
|
14
|
+
*
|
|
15
|
+
* @param fundsRequiredBreakDown a FundsRequiredBreakdown.
|
|
16
|
+
* @param lmi
|
|
17
|
+
* @param lmiIncluded
|
|
18
|
+
* @param id
|
|
19
|
+
* @return Array of fees
|
|
20
|
+
*/
|
|
21
|
+
export declare function getFees(fundsRequiredBreakDown: FundsRequiredBreakdown, lmi: number, lmiIncluded: boolean, id: string): Fee[];
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.getFees = exports.
|
|
4
|
-
var
|
|
3
|
+
exports.getFees = exports.transformFundingPosition = void 0;
|
|
4
|
+
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
5
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
|
-
var
|
|
6
|
+
var lodash_1 = require("lodash");
|
|
7
|
+
var enum_mappings_1 = require("../types/enum-mappings");
|
|
7
8
|
/**
|
|
8
9
|
* GenerateFundingPosition
|
|
9
10
|
*
|
|
10
11
|
* @param fundingPosition a partialFundingPosition.
|
|
12
|
+
* @param uniqueIdSuffix
|
|
11
13
|
* @return partialApplication with fees, grants and borrowers contributions added.
|
|
12
14
|
*/
|
|
13
|
-
function
|
|
15
|
+
function transformFundingPosition(fundingPosition, uniqueIdSuffix) {
|
|
16
|
+
if (uniqueIdSuffix === void 0) { uniqueIdSuffix = 'loanDetails'; }
|
|
14
17
|
var partialApplication = {};
|
|
15
18
|
var contributionFunds = [];
|
|
16
|
-
var applicationId = fundingPosition.applicationId, id = fundingPosition.id;
|
|
19
|
+
var applicationId = fundingPosition.applicationId, id = fundingPosition.id, _a = fundingPosition.lmi, lmi = _a === void 0 ? 0 : _a, _b = fundingPosition.lmiIncluded, lmiIncluded = _b === void 0 ? false : _b;
|
|
17
20
|
var fundingPositionMapping = {
|
|
18
21
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
19
22
|
fundsRequested: "".concat(application_paths_1.paths.RolledUpAmounts, ".@TotalNewFunds"),
|
|
@@ -23,24 +26,24 @@ function generateFundingPosition(fundingPosition) {
|
|
|
23
26
|
totalCashOut: "".concat(application_paths_1.paths.EquityRelease, ".Amount.@LumpSum"),
|
|
24
27
|
fundsRequiredBreakdown: application_paths_1.paths.SummaryFee
|
|
25
28
|
};
|
|
26
|
-
for (var _i = 0,
|
|
27
|
-
var
|
|
29
|
+
for (var _i = 0, _c = Object.entries(fundingPosition); _i < _c.length; _i++) {
|
|
30
|
+
var _d = _c[_i], key = _d[0], value = _d[1];
|
|
28
31
|
if (fundingPositionMapping[key]) {
|
|
29
32
|
switch (key) {
|
|
30
33
|
case 'totalGovernmentContributions':
|
|
31
34
|
case 'totalDeposit':
|
|
32
35
|
contributionFunds.push({
|
|
33
36
|
'@Amount': value,
|
|
34
|
-
'@Type':
|
|
37
|
+
'@Type': enum_mappings_1.contributionMapping[key],
|
|
35
38
|
'@UniqueID': "".concat(id, "-").concat(key)
|
|
36
39
|
});
|
|
37
40
|
break;
|
|
38
41
|
case 'fundsRequiredBreakdown':
|
|
39
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.SummaryFee, getFees(value, id));
|
|
42
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.SummaryFee, getFees(value, lmi, lmiIncluded, id));
|
|
40
43
|
break;
|
|
41
44
|
case 'totalCashOut':
|
|
42
45
|
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
|
|
43
|
-
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.LoanDetail, ".@UniqueID"), "".concat(applicationId, "-
|
|
46
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.LoanDetail, ".@UniqueID"), "".concat(applicationId, "-").concat(uniqueIdSuffix));
|
|
44
47
|
break;
|
|
45
48
|
case 'fundsRequested':
|
|
46
49
|
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], Math.round(value));
|
|
@@ -54,27 +57,39 @@ function generateFundingPosition(fundingPosition) {
|
|
|
54
57
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ContributionFunds, contributionFunds);
|
|
55
58
|
return partialApplication;
|
|
56
59
|
}
|
|
57
|
-
exports.
|
|
60
|
+
exports.transformFundingPosition = transformFundingPosition;
|
|
58
61
|
/**
|
|
59
62
|
* getFee
|
|
60
63
|
*
|
|
61
64
|
* @param fundsRequiredBreakDown a FundsRequiredBreakdown.
|
|
65
|
+
* @param lmi
|
|
66
|
+
* @param lmiIncluded
|
|
62
67
|
* @param id
|
|
63
68
|
* @return Array of fees
|
|
64
69
|
*/
|
|
65
|
-
function getFees(fundsRequiredBreakDown, id) {
|
|
70
|
+
function getFees(fundsRequiredBreakDown, lmi, lmiIncluded, id) {
|
|
71
|
+
// Adding lmi to fees to be transformed.
|
|
72
|
+
(0, lodash_1.set)(fundsRequiredBreakDown, 'lmi', lmi);
|
|
66
73
|
// Omitting constructionCosts as they don't belong in fees.
|
|
67
74
|
return Object.entries((0, lodash_1.omit)(fundsRequiredBreakDown, 'constructionCosts')).map(function (_a) {
|
|
68
75
|
var key = _a[0], value = _a[1];
|
|
69
76
|
var descriptionList = ['accruedInterest', 'otherSundries'];
|
|
70
77
|
var fee = {
|
|
71
78
|
'@Amount': value,
|
|
72
|
-
'@Category':
|
|
73
|
-
'@Type':
|
|
79
|
+
'@Category': enum_mappings_1.categoryMapping[key],
|
|
80
|
+
'@Type': enum_mappings_1.typeMapping[key],
|
|
74
81
|
'@UniqueID': "".concat(id, "-").concat(key)
|
|
75
82
|
};
|
|
76
83
|
if (descriptionList.includes(key)) {
|
|
77
|
-
fee['@Description'] =
|
|
84
|
+
fee['@Description'] = enum_mappings_1.descriptionMapping[key];
|
|
85
|
+
}
|
|
86
|
+
if (key === 'lmi') {
|
|
87
|
+
if (lmiIncluded)
|
|
88
|
+
fee['@CapitaliseFee'] = lixi_internal_request_1.YesNoList.Yes;
|
|
89
|
+
// If lmiIncluded is undefined we do not want to set '@CapitaliseFee'
|
|
90
|
+
// only if it is false as this will affect how we handle migration.
|
|
91
|
+
if (lmiIncluded === false)
|
|
92
|
+
fee['@CapitaliseFee'] = lixi_internal_request_1.YesNoList.No;
|
|
78
93
|
}
|
|
79
94
|
return fee;
|
|
80
95
|
});
|
|
@@ -11,7 +11,8 @@ exports.categoryMapping = {
|
|
|
11
11
|
otherSundries: lixi_internal_request_1.FeeCategoryList.Other,
|
|
12
12
|
stampDuty: lixi_internal_request_1.FeeCategoryList.Government,
|
|
13
13
|
transferFee: lixi_internal_request_1.FeeCategoryList.Government,
|
|
14
|
-
foreignBuyerSurcharge: lixi_internal_request_1.FeeCategoryList.Government
|
|
14
|
+
foreignBuyerSurcharge: lixi_internal_request_1.FeeCategoryList.Government,
|
|
15
|
+
lmi: lixi_internal_request_1.FeeCategoryList.Bank
|
|
15
16
|
};
|
|
16
17
|
exports.typeMapping = {
|
|
17
18
|
accruedInterest: lixi_internal_request_1.FeeTypeList.Other,
|
|
@@ -22,7 +23,8 @@ exports.typeMapping = {
|
|
|
22
23
|
otherSundries: lixi_internal_request_1.FeeTypeList.Other,
|
|
23
24
|
stampDuty: lixi_internal_request_1.FeeTypeList.StampDutyOnMortgage,
|
|
24
25
|
transferFee: lixi_internal_request_1.FeeTypeList.TitleTransferFee,
|
|
25
|
-
foreignBuyerSurcharge: lixi_internal_request_1.FeeTypeList.Other
|
|
26
|
+
foreignBuyerSurcharge: lixi_internal_request_1.FeeTypeList.Other,
|
|
27
|
+
lmi: lixi_internal_request_1.FeeTypeList.Lmi
|
|
26
28
|
};
|
|
27
29
|
exports.descriptionMapping = {
|
|
28
30
|
accruedInterest: lixi_internal_request_1.Custom4DescriptionList.PotentialAccruedInterest,
|
|
@@ -1,11 +1,7 @@
|
|
|
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
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Library for kafka event data transforming",
|
|
5
5
|
"author": "Integrations <integrations@lendi.com.au>",
|
|
6
6
|
"homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@lendi/integrations-credit-protocol": "1.17.
|
|
24
|
+
"@lendi/integrations-credit-protocol": "1.17.1",
|
|
25
25
|
"@lendi/integrations-protocol": "2.5.4",
|
|
26
26
|
"clean-deep": "^3.4.0",
|
|
27
27
|
"date-fns": "2.19.0",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Fee } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
-
import { FundsRequiredBreakdown } from '../types/events/public-funding-position';
|
|
3
|
-
import { Payload as FundingPositionPayload } from '../types/events/public-funding-position';
|
|
4
|
-
/**
|
|
5
|
-
* GenerateFundingPosition
|
|
6
|
-
*
|
|
7
|
-
* @param fundingPosition a partialFundingPosition.
|
|
8
|
-
* @return partialApplication with fees, grants and borrowers contributions added.
|
|
9
|
-
*/
|
|
10
|
-
export declare function generateFundingPosition(fundingPosition: FundingPositionPayload): {};
|
|
11
|
-
/**
|
|
12
|
-
* getFee
|
|
13
|
-
*
|
|
14
|
-
* @param fundsRequiredBreakDown a FundsRequiredBreakdown.
|
|
15
|
-
* @param id
|
|
16
|
-
* @return Array of fees
|
|
17
|
-
*/
|
|
18
|
-
export declare function getFees(fundsRequiredBreakDown: FundsRequiredBreakdown, id: string): Fee[];
|