@lendi/integrations-transform 1.3.6 → 1.3.9
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/schemas/public-asset-event.json +20 -0
- package/lib/transform-events/generate-application.d.ts +8 -0
- package/lib/transform-events/generate-application.js +49 -0
- package/lib/transform-events/generate-asset.d.ts +17 -0
- package/lib/transform-events/generate-asset.js +178 -0
- package/lib/transform-events/generate-expenses.d.ts +28 -0
- package/lib/transform-events/generate-expenses.js +94 -0
- package/lib/transform-events/generate-income.d.ts +57 -0
- package/lib/transform-events/generate-income.js +247 -0
- package/lib/transform-events/generate-liability.d.ts +8 -0
- package/lib/transform-events/generate-liability.js +87 -0
- package/lib/transform-events/generate-lixi-percentowned.d.ts +12 -0
- package/lib/transform-events/generate-lixi-percentowned.js +23 -0
- package/lib/transform-events/generate-opportunity.d.ts +8 -0
- package/lib/transform-events/generate-opportunity.js +32 -0
- package/lib/transform-events/transform-asset.d.ts +17 -2
- package/lib/transform-events/transform-asset.js +103 -10
- package/lib/types/enum-mappings/builder-type.d.ts +7 -0
- package/lib/types/enum-mappings/builder-type.js +10 -0
- package/lib/types/enum-mappings/construction-type.d.ts +7 -0
- package/lib/types/enum-mappings/construction-type.js +11 -0
- package/lib/types/enum-mappings/index.d.ts +1 -0
- package/lib/types/enum-mappings/index.js +1 -0
- package/lib/types/enum-mappings/property-expense-category.d.ts +7 -0
- package/lib/types/enum-mappings/property-expense-category.js +12 -0
- package/lib/types/events/public-asset.d.ts +14 -0
- package/lib/types/events/public-asset.js +12 -1
- package/package.json +2 -2
|
@@ -442,6 +442,10 @@
|
|
|
442
442
|
"constructionDetails": {
|
|
443
443
|
"type": "object",
|
|
444
444
|
"properties": {
|
|
445
|
+
"constructionType": {
|
|
446
|
+
"type": "string",
|
|
447
|
+
"enum": ["STRUCTURAL_RENOVATIONS", "BUILD_A_PROPERTY", "KNOCKDOWN_REBUILD"]
|
|
448
|
+
},
|
|
445
449
|
"buildPriceAmount": {
|
|
446
450
|
"type": "number"
|
|
447
451
|
},
|
|
@@ -451,6 +455,16 @@
|
|
|
451
455
|
},
|
|
452
456
|
"landEstimatedValue": {
|
|
453
457
|
"type": "number"
|
|
458
|
+
},
|
|
459
|
+
"otherConstructionCosts": {
|
|
460
|
+
"type": "number"
|
|
461
|
+
},
|
|
462
|
+
"builderType": {
|
|
463
|
+
"type": "string",
|
|
464
|
+
"enum": ["LICENSED_BUILDER", "OWNER_BUILDER"]
|
|
465
|
+
},
|
|
466
|
+
"isFixedPriceContract": {
|
|
467
|
+
"type": "boolean"
|
|
454
468
|
}
|
|
455
469
|
}
|
|
456
470
|
},
|
|
@@ -479,6 +493,9 @@
|
|
|
479
493
|
"description": "The unique number assigned to the Financial Institution account",
|
|
480
494
|
"example": "999994"
|
|
481
495
|
},
|
|
496
|
+
"isConstruction": {
|
|
497
|
+
"type": "boolean"
|
|
498
|
+
},
|
|
482
499
|
"dataType": {
|
|
483
500
|
"type": "string"
|
|
484
501
|
},
|
|
@@ -602,6 +619,9 @@
|
|
|
602
619
|
"constructionDetails": {
|
|
603
620
|
"$ref": "#/definitions/constructionDetails"
|
|
604
621
|
},
|
|
622
|
+
"isConstruction": {
|
|
623
|
+
"$ref": "#/definitions/isConstruction"
|
|
624
|
+
},
|
|
605
625
|
"make": {
|
|
606
626
|
"$ref": "#/definitions/make"
|
|
607
627
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
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): {};
|
|
@@ -0,0 +1,49 @@
|
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,178 @@
|
|
|
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;
|
|
@@ -0,0 +1,28 @@
|
|
|
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[];
|
|
@@ -0,0 +1,94 @@
|
|
|
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;
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
}[];
|
|
@@ -0,0 +1,247 @@
|
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
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): {};
|
|
@@ -0,0 +1,87 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
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): {};
|
|
@@ -0,0 +1,32 @@
|
|
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LivingExpense } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
1
|
+
import { LivingExpense, PropertyExpense as LIXIPropertyExpense, OccupancyList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
2
|
import { PropertyType as LixiPropertyType, Residential } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
3
3
|
import { Asset, Payload, PercentOwned, PropertyExpense, PropertyType } from '../types/events/public-asset';
|
|
4
4
|
import { PartialApplication } from '../types/partial-application';
|
|
@@ -34,4 +34,19 @@ export declare function getAssetMapping(asset: Asset): Record<string, string>;
|
|
|
34
34
|
* @param assetId: Asset id
|
|
35
35
|
* @param propertyExpenses: propertyExpenses items
|
|
36
36
|
*/
|
|
37
|
-
export declare function
|
|
37
|
+
export declare function generateLivingExpenses(percentOwned: PercentOwned, assetId: string, propertyExpenses: PropertyExpense[]): LivingExpense[];
|
|
38
|
+
/**
|
|
39
|
+
* Creates PropertyExpense array on RealEstateAsset from the same array on the event.
|
|
40
|
+
* @param propertyExpenses
|
|
41
|
+
*/
|
|
42
|
+
export declare function generatePropertyExpenses(propertyExpenses: PropertyExpense[]): LIXIPropertyExpense[];
|
|
43
|
+
/**
|
|
44
|
+
* Determines the occupancy based on the list of property expense types available.
|
|
45
|
+
* @param propertyExpenses
|
|
46
|
+
*/
|
|
47
|
+
export declare function determineOccupancy(propertyExpenses: PropertyExpense[]): OccupancyList;
|
|
48
|
+
/**
|
|
49
|
+
* Calculates the correct amount and frequency.
|
|
50
|
+
* @param expense
|
|
51
|
+
*/
|
|
52
|
+
export declare function normalizeAmounts(expense: PropertyExpense): PropertyExpense;
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
exports.__esModule = true;
|
|
14
|
-
exports.generatePropertyExpenses = exports.getAssetMapping = exports.getPropertyType = exports.transformAsset = exports.residentialTypeList = exports.propertyTypeNameList = void 0;
|
|
14
|
+
exports.normalizeAmounts = exports.determineOccupancy = exports.generatePropertyExpenses = exports.generateLivingExpenses = exports.getAssetMapping = exports.getPropertyType = exports.transformAsset = exports.residentialTypeList = exports.propertyTypeNameList = void 0;
|
|
15
15
|
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
16
16
|
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
17
17
|
var lixi_internal_request_2 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
@@ -26,8 +26,22 @@ var is_asset_type_1 = require("../utils/is-asset-type");
|
|
|
26
26
|
var round_decimal_1 = require("../utils/round-decimal");
|
|
27
27
|
var transform_asset_address_1 = require("./transform-asset-address");
|
|
28
28
|
var transform_percent_owned_1 = require("./transform-percent-owned");
|
|
29
|
+
var builder_type_1 = require("../types/enum-mappings/builder-type");
|
|
30
|
+
var construction_type_1 = require("../types/enum-mappings/construction-type");
|
|
31
|
+
var __1 = require("..");
|
|
29
32
|
exports.propertyTypeNameList = Object.values(lixi_internal_request_2.Custom2PropertyTypeNameList);
|
|
30
33
|
exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
|
|
34
|
+
// will add this path to protocol
|
|
35
|
+
var constructionDetailsPath = "".concat(application_paths_1.paths.RealEstateAsset, ".ConstructionDetails");
|
|
36
|
+
var constructionDetailsMapping = {
|
|
37
|
+
builderType: "".concat(constructionDetailsPath, ".@BuilderType"),
|
|
38
|
+
buildPriceAmount: "".concat(constructionDetailsPath, ".@BuildPriceAmount"),
|
|
39
|
+
constructionType: "".concat(constructionDetailsPath, ".@Type"),
|
|
40
|
+
estimatedValue: "".concat(constructionDetailsPath, ".@TotalAmount"),
|
|
41
|
+
isFixedPriceContract: "".concat(constructionDetailsPath, ".@FixedPriceContract"),
|
|
42
|
+
landEstimatedValue: "".concat(constructionDetailsPath, ".@LandValue"),
|
|
43
|
+
otherConstructionCosts: "".concat(constructionDetailsPath, ".@OutOfContractItemsCost")
|
|
44
|
+
};
|
|
31
45
|
/**
|
|
32
46
|
* Generates a partial internal request from a partial public asset event.
|
|
33
47
|
*
|
|
@@ -92,8 +106,11 @@ function transformAsset(_a) {
|
|
|
92
106
|
if (!asset.percentOwned) {
|
|
93
107
|
break;
|
|
94
108
|
}
|
|
95
|
-
var propertyExpenses = generatePropertyExpenses(
|
|
96
|
-
(0, lodash_1.set)(partialApplication,
|
|
109
|
+
var propertyExpenses = generatePropertyExpenses(value);
|
|
110
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyExpense"), propertyExpenses);
|
|
111
|
+
var livingExpenses = generateLivingExpenses(asset.percentOwned, id, value);
|
|
112
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], livingExpenses);
|
|
113
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Occupancy"), determineOccupancy(value));
|
|
97
114
|
break;
|
|
98
115
|
case 'propertyStatus':
|
|
99
116
|
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
|
|
@@ -131,12 +148,40 @@ function transformAsset(_a) {
|
|
|
131
148
|
case 'address':
|
|
132
149
|
(0, lodash_1.set)(partialApplication, assetMapping[key], (0, transform_asset_address_1.transformAddress)(value, addressId));
|
|
133
150
|
break;
|
|
151
|
+
case 'isConstruction':
|
|
152
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], (0, __1.booleanMapping)(value));
|
|
153
|
+
break;
|
|
134
154
|
case 'percentOwned':
|
|
135
155
|
var percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
|
|
136
156
|
if (percentOwned) {
|
|
137
157
|
(0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
|
|
138
158
|
}
|
|
139
159
|
break;
|
|
160
|
+
case 'constructionDetails':
|
|
161
|
+
for (var _d = 0, _e = Object.entries(value); _d < _e.length; _d++) {
|
|
162
|
+
var _f = _e[_d], key_1 = _f[0], constructionDetailsValue = _f[1];
|
|
163
|
+
switch (key_1) {
|
|
164
|
+
case 'builderType':
|
|
165
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], builder_type_1.builderTypeMapping[constructionDetailsValue]);
|
|
166
|
+
break;
|
|
167
|
+
case 'constructionType':
|
|
168
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], construction_type_1.constructionTypeMapping[constructionDetailsValue]);
|
|
169
|
+
break;
|
|
170
|
+
case 'isFixedPriceContract':
|
|
171
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], (0, __1.booleanMapping)(constructionDetailsValue));
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], constructionDetailsValue);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
case 'estimatedValue':
|
|
180
|
+
if (asset.isConstruction) {
|
|
181
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], value);
|
|
182
|
+
}
|
|
183
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], value);
|
|
184
|
+
break;
|
|
140
185
|
default:
|
|
141
186
|
(0, lodash_1.set)(partialApplication, assetMapping[key], value);
|
|
142
187
|
break;
|
|
@@ -200,7 +245,9 @@ function getAssetMapping(asset) {
|
|
|
200
245
|
propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
|
|
201
246
|
toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
|
|
202
247
|
toBeUsedAsSecurity: "".concat(application_paths_1.paths.RealEstateAsset, ".@ToBeUsedAsSecurity"),
|
|
203
|
-
zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type")
|
|
248
|
+
zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type"),
|
|
249
|
+
isConstruction: "".concat(application_paths_1.paths.RealEstateAsset, ".@Construction"),
|
|
250
|
+
constructionDetails: "".concat(application_paths_1.paths.RealEstateAsset, ".ConstructionDetails")
|
|
204
251
|
};
|
|
205
252
|
}
|
|
206
253
|
if ((0, is_asset_type_1.isMotorVehicle)(asset)) {
|
|
@@ -219,20 +266,17 @@ exports.getAssetMapping = getAssetMapping;
|
|
|
219
266
|
* @param assetId: Asset id
|
|
220
267
|
* @param propertyExpenses: propertyExpenses items
|
|
221
268
|
*/
|
|
222
|
-
function
|
|
269
|
+
function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
|
|
223
270
|
var livingExpenses = [];
|
|
224
271
|
var filteredPropertyExpenses = propertyExpenses.filter(function (expense) { return expense.amount !== undefined; });
|
|
225
272
|
percentOwned.owners.forEach(function (owner) {
|
|
226
273
|
var expenses = filteredPropertyExpenses.map(function (expense) {
|
|
227
|
-
|
|
228
|
-
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
229
|
-
expense.amount *= 4;
|
|
230
|
-
}
|
|
274
|
+
normalizeAmounts(expense);
|
|
231
275
|
return {
|
|
232
276
|
'@Amount': (0, round_decimal_1.roundDecimal)(expense.amount * owner.percent),
|
|
233
277
|
'@Category': enum_mappings_1.livingExpenseMapping[expense.type],
|
|
234
278
|
'@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency],
|
|
235
|
-
'@UniqueID': "".concat((0, uuid_1.v4)(), "
|
|
279
|
+
'@UniqueID': "".concat((0, uuid_1.v4)(), "--").concat(assetId),
|
|
236
280
|
PercentResponsible: {
|
|
237
281
|
Owner: [
|
|
238
282
|
{
|
|
@@ -247,4 +291,53 @@ function generatePropertyExpenses(percentOwned, assetId, propertyExpenses) {
|
|
|
247
291
|
});
|
|
248
292
|
return livingExpenses;
|
|
249
293
|
}
|
|
294
|
+
exports.generateLivingExpenses = generateLivingExpenses;
|
|
295
|
+
/**
|
|
296
|
+
* Creates PropertyExpense array on RealEstateAsset from the same array on the event.
|
|
297
|
+
* @param propertyExpenses
|
|
298
|
+
*/
|
|
299
|
+
function generatePropertyExpenses(propertyExpenses) {
|
|
300
|
+
return propertyExpenses
|
|
301
|
+
.filter(function (expense) { return expense.amount !== undefined; })
|
|
302
|
+
.map(function (expense) {
|
|
303
|
+
normalizeAmounts(expense);
|
|
304
|
+
return {
|
|
305
|
+
'@Amount': expense.amount,
|
|
306
|
+
'@Category': enum_mappings_1.propertyExpenseCategoryMapping[expense.type],
|
|
307
|
+
'@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency]
|
|
308
|
+
};
|
|
309
|
+
});
|
|
310
|
+
}
|
|
250
311
|
exports.generatePropertyExpenses = generatePropertyExpenses;
|
|
312
|
+
/**
|
|
313
|
+
* Determines the occupancy based on the list of property expense types available.
|
|
314
|
+
* @param propertyExpenses
|
|
315
|
+
*/
|
|
316
|
+
function determineOccupancy(propertyExpenses) {
|
|
317
|
+
var propertyExpenseCategoryList = propertyExpenses.map(function (expense) { return expense.type; });
|
|
318
|
+
if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.InvestmentPropertyRunningCosts)) {
|
|
319
|
+
return lixi_internal_request_1.OccupancyList.NonOwner;
|
|
320
|
+
}
|
|
321
|
+
else if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts && public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts)) {
|
|
322
|
+
return lixi_internal_request_1.OccupancyList.OwnerSecondary;
|
|
323
|
+
}
|
|
324
|
+
else if (propertyExpenseCategoryList.some(function (item) {
|
|
325
|
+
return item !== public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts &&
|
|
326
|
+
item === public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts;
|
|
327
|
+
})) {
|
|
328
|
+
return lixi_internal_request_1.OccupancyList.OwnerPrimary;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
exports.determineOccupancy = determineOccupancy;
|
|
332
|
+
/**
|
|
333
|
+
* Calculates the correct amount and frequency.
|
|
334
|
+
* @param expense
|
|
335
|
+
*/
|
|
336
|
+
function normalizeAmounts(expense) {
|
|
337
|
+
if (expense.frequency === public_expense_1.Frequency.Quarterly) {
|
|
338
|
+
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
339
|
+
expense.amount *= 4;
|
|
340
|
+
}
|
|
341
|
+
return expense;
|
|
342
|
+
}
|
|
343
|
+
exports.normalizeAmounts = normalizeAmounts;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BuilderTypeList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
import { BuilderType } from '../events/public-asset';
|
|
3
|
+
declare type BuilderTypeMapping = {
|
|
4
|
+
[key in BuilderType]: BuilderTypeList;
|
|
5
|
+
};
|
|
6
|
+
export declare const builderTypeMapping: BuilderTypeMapping;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.builderTypeMapping = void 0;
|
|
5
|
+
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
6
|
+
var public_asset_1 = require("../events/public-asset");
|
|
7
|
+
exports.builderTypeMapping = (_a = {},
|
|
8
|
+
_a[public_asset_1.BuilderType.LicensedBuilder] = lixi_internal_request_1.BuilderTypeList.LicensedBuilder,
|
|
9
|
+
_a[public_asset_1.BuilderType.OwnerBuilder] = lixi_internal_request_1.BuilderTypeList.OwnerBuilder,
|
|
10
|
+
_a);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConstructionTypeList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
import { ConstructionType } from '../events/public-asset';
|
|
3
|
+
declare type ConstructionTypeMapping = {
|
|
4
|
+
[key in ConstructionType]: ConstructionTypeList;
|
|
5
|
+
};
|
|
6
|
+
export declare const constructionTypeMapping: ConstructionTypeMapping;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.constructionTypeMapping = void 0;
|
|
5
|
+
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
6
|
+
var public_asset_1 = require("../events/public-asset");
|
|
7
|
+
exports.constructionTypeMapping = (_a = {},
|
|
8
|
+
_a[public_asset_1.ConstructionType.BuildAProperty] = lixi_internal_request_1.ConstructionTypeList.FullConstruction,
|
|
9
|
+
_a[public_asset_1.ConstructionType.KnockdownRebuild] = lixi_internal_request_1.ConstructionTypeList.FullConstruction,
|
|
10
|
+
_a[public_asset_1.ConstructionType.StructuralRenovations] = lixi_internal_request_1.ConstructionTypeList.Renovation,
|
|
11
|
+
_a);
|
|
@@ -14,6 +14,7 @@ export * from './marital-status';
|
|
|
14
14
|
export * from './postcode';
|
|
15
15
|
export * from './preferred-repayment';
|
|
16
16
|
export * from './proof-of-identity';
|
|
17
|
+
export * from './property-expense-category';
|
|
17
18
|
export * from './public-financial-asset';
|
|
18
19
|
export * from './public-primary-purpose';
|
|
19
20
|
export * from './public-property-status';
|
|
@@ -26,6 +26,7 @@ __exportStar(require("./marital-status"), exports);
|
|
|
26
26
|
__exportStar(require("./postcode"), exports);
|
|
27
27
|
__exportStar(require("./preferred-repayment"), exports);
|
|
28
28
|
__exportStar(require("./proof-of-identity"), exports);
|
|
29
|
+
__exportStar(require("./property-expense-category"), exports);
|
|
29
30
|
__exportStar(require("./public-financial-asset"), exports);
|
|
30
31
|
__exportStar(require("./public-primary-purpose"), exports);
|
|
31
32
|
__exportStar(require("./public-property-status"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropertyExpenseCategoryList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
import { PropertyExpenseType } from '../events/public-asset';
|
|
3
|
+
declare type PropertyExpenseCategoryMapping = {
|
|
4
|
+
[key in PropertyExpenseType]: PropertyExpenseCategoryList;
|
|
5
|
+
};
|
|
6
|
+
export declare const propertyExpenseCategoryMapping: PropertyExpenseCategoryMapping;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.propertyExpenseCategoryMapping = void 0;
|
|
5
|
+
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
6
|
+
var public_asset_1 = require("../events/public-asset");
|
|
7
|
+
exports.propertyExpenseCategoryMapping = (_a = {},
|
|
8
|
+
_a[public_asset_1.PropertyExpenseType.BodyCorporateFeesStrataFeesAndLandTax] = lixi_internal_request_1.PropertyExpenseCategoryList.BodyCorporateFeesStrataFeesAndLandTax,
|
|
9
|
+
_a[public_asset_1.PropertyExpenseType.InvestmentPropertyRunningCosts] = lixi_internal_request_1.PropertyExpenseCategoryList.RunningCosts,
|
|
10
|
+
_a[public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts] = lixi_internal_request_1.PropertyExpenseCategoryList.RunningCosts,
|
|
11
|
+
_a[public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts] = lixi_internal_request_1.PropertyExpenseCategoryList.RunningCosts,
|
|
12
|
+
_a);
|
|
@@ -33,6 +33,7 @@ export interface Asset {
|
|
|
33
33
|
financialInstitutionAccountNumber?: string;
|
|
34
34
|
financialInstitutionBsb?: string;
|
|
35
35
|
financialInstitutionShortName?: string;
|
|
36
|
+
isConstruction?: boolean;
|
|
36
37
|
knockDownToRebuild?: boolean;
|
|
37
38
|
make?: string;
|
|
38
39
|
model?: string;
|
|
@@ -346,7 +347,20 @@ export interface ConstructionDetails {
|
|
|
346
347
|
*/
|
|
347
348
|
buildIn6Months?: boolean;
|
|
348
349
|
buildPriceAmount?: number;
|
|
350
|
+
builderType?: BuilderType;
|
|
351
|
+
constructionType?: ConstructionType;
|
|
352
|
+
isFixedPriceContract?: boolean;
|
|
349
353
|
landEstimatedValue?: number;
|
|
354
|
+
otherConstructionCosts?: number;
|
|
355
|
+
}
|
|
356
|
+
export declare enum BuilderType {
|
|
357
|
+
LicensedBuilder = "LICENSED_BUILDER",
|
|
358
|
+
OwnerBuilder = "OWNER_BUILDER"
|
|
359
|
+
}
|
|
360
|
+
export declare enum ConstructionType {
|
|
361
|
+
BuildAProperty = "BUILD_A_PROPERTY",
|
|
362
|
+
KnockdownRebuild = "KNOCKDOWN_REBUILD",
|
|
363
|
+
StructuralRenovations = "STRUCTURAL_RENOVATIONS"
|
|
350
364
|
}
|
|
351
365
|
/**
|
|
352
366
|
* Details of the purchase/sale price as specified in the Contract of Sale
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.PublicAssetType = exports.ActionedByRole = exports.ZoneType = exports.AssetType = exports.PropertyType = exports.PropertyStatus = exports.PropertyExpenseType = exports.Frequency = exports.PrimaryPurpose = exports.Proportions = exports.Countries = void 0;
|
|
3
|
+
exports.PublicAssetType = exports.ActionedByRole = exports.ZoneType = exports.AssetType = exports.PropertyType = exports.PropertyStatus = exports.PropertyExpenseType = exports.Frequency = exports.PrimaryPurpose = exports.Proportions = exports.ConstructionType = exports.BuilderType = exports.Countries = void 0;
|
|
4
4
|
var Countries;
|
|
5
5
|
(function (Countries) {
|
|
6
6
|
Countries["Afghanistan"] = "Afghanistan";
|
|
@@ -243,6 +243,17 @@ var Countries;
|
|
|
243
243
|
Countries["Zambia"] = "Zambia";
|
|
244
244
|
Countries["Zimbabwe"] = "Zimbabwe";
|
|
245
245
|
})(Countries = exports.Countries || (exports.Countries = {}));
|
|
246
|
+
var BuilderType;
|
|
247
|
+
(function (BuilderType) {
|
|
248
|
+
BuilderType["LicensedBuilder"] = "LICENSED_BUILDER";
|
|
249
|
+
BuilderType["OwnerBuilder"] = "OWNER_BUILDER";
|
|
250
|
+
})(BuilderType = exports.BuilderType || (exports.BuilderType = {}));
|
|
251
|
+
var ConstructionType;
|
|
252
|
+
(function (ConstructionType) {
|
|
253
|
+
ConstructionType["BuildAProperty"] = "BUILD_A_PROPERTY";
|
|
254
|
+
ConstructionType["KnockdownRebuild"] = "KNOCKDOWN_REBUILD";
|
|
255
|
+
ConstructionType["StructuralRenovations"] = "STRUCTURAL_RENOVATIONS";
|
|
256
|
+
})(ConstructionType = exports.ConstructionType || (exports.ConstructionType = {}));
|
|
246
257
|
/**
|
|
247
258
|
* Indicate whether ownership proportions are equal, specified individually for each one or
|
|
248
259
|
* not specified.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "Library for kafka event data transforming",
|
|
5
5
|
"author": "Integrations <integrations@lendi.com.au>",
|
|
6
6
|
"homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@lendi/integrations-credit-protocol": "1.
|
|
24
|
+
"@lendi/integrations-credit-protocol": "1.16.2",
|
|
25
25
|
"@lendi/integrations-protocol": "2.5.4",
|
|
26
26
|
"clean-deep": "^3.4.0",
|
|
27
27
|
"date-fns": "2.19.0",
|