@lendi/integrations-transform 1.5.8 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -1
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +3 -3
- package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
- package/lib/transform-events/generate-asset-liability-link.js +12 -12
- package/lib/transform-events/generate-credit-report-rebuilt.js +13 -13
- package/lib/transform-events/generate-employment.d.ts +1 -1
- package/lib/transform-events/generate-employment.js +33 -34
- package/lib/transform-events/generate-required-document.d.ts +1 -7
- package/lib/transform-events/generate-required-document.js +37 -54
- package/lib/transform-events/transform-applicant.d.ts +2 -1
- package/lib/transform-events/transform-applicant.js +57 -63
- package/lib/transform-events/transform-application-workflow.d.ts +0 -1
- package/lib/transform-events/transform-application-workflow.js +7 -8
- package/lib/transform-events/transform-application.d.ts +3 -1
- package/lib/transform-events/transform-application.js +23 -24
- package/lib/transform-events/transform-asset-address.d.ts +8 -2
- package/lib/transform-events/transform-asset-address.js +22 -18
- package/lib/transform-events/transform-asset.d.ts +7 -1
- package/lib/transform-events/transform-asset.js +112 -122
- package/lib/transform-events/transform-expenses.d.ts +4 -0
- package/lib/transform-events/transform-expenses.js +31 -29
- package/lib/transform-events/transform-funding-position.d.ts +2 -2
- package/lib/transform-events/transform-funding-position.js +23 -26
- package/lib/transform-events/transform-income.d.ts +8 -1
- package/lib/transform-events/transform-income.js +87 -97
- package/lib/transform-events/transform-liability.d.ts +4 -1
- package/lib/transform-events/transform-liability.js +42 -41
- package/lib/transform-events/transform-percent-owned.d.ts +1 -0
- package/lib/transform-events/transform-percent-owned.js +8 -11
- package/lib/types/enum-mappings/alieo-frequency.js +23 -24
- package/lib/types/enum-mappings/asset-type.js +15 -16
- package/lib/types/enum-mappings/builder-type.js +7 -8
- package/lib/types/enum-mappings/construction-type.js +8 -9
- package/lib/types/enum-mappings/country-code.js +244 -245
- package/lib/types/enum-mappings/employment-basis.js +10 -11
- package/lib/types/enum-mappings/expense-frequency.js +9 -10
- package/lib/types/enum-mappings/funding-position.js +6 -6
- package/lib/types/enum-mappings/government-benefits.js +8 -9
- package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
- package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
- package/lib/types/enum-mappings/housing-status.js +13 -14
- package/lib/types/enum-mappings/income-type.js +14 -15
- package/lib/types/enum-mappings/index.js +1 -1
- package/lib/types/enum-mappings/liability-payment-type.js +7 -8
- package/lib/types/enum-mappings/liability-type.js +19 -20
- package/lib/types/enum-mappings/living-expense.js +28 -29
- package/lib/types/enum-mappings/marital-status.js +10 -11
- package/lib/types/enum-mappings/postcode.js +12 -13
- package/lib/types/enum-mappings/preferred-repayment.js +8 -9
- package/lib/types/enum-mappings/proof-of-identity.js +8 -9
- package/lib/types/enum-mappings/property-expense-category.js +9 -10
- package/lib/types/enum-mappings/public-financial-asset.js +10 -11
- package/lib/types/enum-mappings/public-primary-purpose.js +7 -8
- package/lib/types/enum-mappings/public-property-status.js +9 -10
- package/lib/types/enum-mappings/public-property-type.js +21 -22
- package/lib/types/enum-mappings/residency-status.js +9 -10
- package/lib/types/enum-mappings/title-gender.js +11 -12
- package/lib/types/enum-mappings/title.js +11 -12
- package/lib/types/enum-mappings/to-be-purchased.js +4 -4
- package/lib/types/enum-mappings/to-be-used-as-security.js +4 -4
- package/lib/types/enum-mappings/transaction-type.js +7 -8
- package/lib/types/enum-mappings/verification.js +11 -12
- package/lib/types/events/applicant-delete.js +1 -1
- package/lib/types/events/application-workflow.js +1 -1
- package/lib/types/events/asset-delete.js +1 -1
- package/lib/types/events/asset-liability-relation-delete.js +1 -1
- package/lib/types/events/credit-report-retrieved.js +1 -1
- package/lib/types/events/employment-delete.js +1 -1
- package/lib/types/events/expense-delete.js +1 -1
- package/lib/types/events/funding-position.js +1 -1
- package/lib/types/events/income-delete.js +1 -1
- package/lib/types/events/liability-delete.js +1 -1
- package/lib/types/events/opportunity.js +1 -1
- package/lib/types/events/public-applicant.js +1 -1
- package/lib/types/events/public-application.js +1 -1
- package/lib/types/events/public-asset-liability-relation.js +1 -1
- package/lib/types/events/public-asset.js +1 -1
- package/lib/types/events/public-employment.js +1 -1
- package/lib/types/events/public-expense.js +1 -1
- package/lib/types/events/public-funding-position.js +1 -1
- package/lib/types/events/public-income.js +1 -1
- package/lib/types/events/public-liability.js +1 -1
- package/lib/types/events/public-required-document.js +1 -1
- package/lib/types/partial-application.js +1 -1
- package/lib/types/recursive-partial.js +1 -1
- package/lib/update-application/merge-application.d.ts +1 -1
- package/lib/update-application/merge-application.js +41 -34
- package/lib/update-application/update-primary-applicant.d.ts +1 -4
- package/lib/update-application/update-primary-applicant.js +12 -31
- package/lib/utils/address-tools.d.ts +3 -1
- package/lib/utils/address-tools.js +40 -42
- package/lib/utils/clean-up.d.ts +1 -1
- package/lib/utils/clean-up.js +6 -6
- package/lib/utils/formatYesNo.d.ts +0 -1
- package/lib/utils/formatYesNo.js +3 -4
- package/lib/utils/generate-address.d.ts +3 -2
- package/lib/utils/generate-address.js +21 -25
- package/lib/utils/get-financial-institution.d.ts +1 -0
- package/lib/utils/get-financial-institution.js +6 -5
- package/lib/utils/is-asset-type.js +2 -2
- package/lib/utils/is-income-type.d.ts +2 -0
- package/lib/utils/is-income-type.js +15 -21
- package/lib/utils/iso-date.d.ts +0 -1
- package/lib/utils/iso-date.js +3 -4
- package/lib/utils/normalise-date.js +6 -6
- package/lib/utils/round-decimal.js +1 -1
- package/package.json +14 -17
|
@@ -1,99 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.normalizeAmounts = exports.determineOccupancy = exports.generatePropertyExpenses = exports.generateLivingExpenses = exports.getAssetMapping = exports.getPropertyType = exports.transformAsset = exports.residentialTypeList = exports.propertyTypeNameList = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
5
|
+
const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
6
|
+
const lixi_internal_request_2 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
7
|
+
const uuid_1 = require("uuid");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
11
|
+
const public_asset_1 = require("../types/events/public-asset");
|
|
12
|
+
const public_expense_1 = require("../types/events/public-expense");
|
|
13
|
+
const get_financial_institution_1 = require("../utils/get-financial-institution");
|
|
14
|
+
const is_asset_type_1 = require("../utils/is-asset-type");
|
|
15
|
+
const round_decimal_1 = require("../utils/round-decimal");
|
|
16
|
+
const transform_asset_address_1 = require("./transform-asset-address");
|
|
17
|
+
const transform_percent_owned_1 = require("./transform-percent-owned");
|
|
18
|
+
const builder_type_1 = require("../types/enum-mappings/builder-type");
|
|
19
|
+
const construction_type_1 = require("../types/enum-mappings/construction-type");
|
|
20
|
+
const __1 = require("..");
|
|
32
21
|
exports.propertyTypeNameList = Object.values(lixi_internal_request_2.Custom2PropertyTypeNameList);
|
|
33
22
|
exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
|
|
34
23
|
// will add this path to protocol
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
builderType:
|
|
38
|
-
buildPriceAmount:
|
|
39
|
-
constructionType:
|
|
40
|
-
estimatedValue:
|
|
41
|
-
isFixedPriceContract:
|
|
42
|
-
landEstimatedValue:
|
|
43
|
-
otherConstructionCosts:
|
|
24
|
+
const constructionDetailsPath = `${application_paths_1.paths.RealEstateAsset}.ConstructionDetails`;
|
|
25
|
+
const constructionDetailsMapping = {
|
|
26
|
+
builderType: `${constructionDetailsPath}.@BuilderType`,
|
|
27
|
+
buildPriceAmount: `${constructionDetailsPath}.@BuildPriceAmount`,
|
|
28
|
+
constructionType: `${constructionDetailsPath}.@Type`,
|
|
29
|
+
estimatedValue: `${constructionDetailsPath}.@TotalAmount`,
|
|
30
|
+
isFixedPriceContract: `${constructionDetailsPath}.@FixedPriceContract`,
|
|
31
|
+
landEstimatedValue: `${constructionDetailsPath}.@LandValue`,
|
|
32
|
+
otherConstructionCosts: `${constructionDetailsPath}.@OutOfContractItemsCost`,
|
|
44
33
|
};
|
|
45
34
|
/**
|
|
46
35
|
* Generates a partial internal request from a partial public asset event.
|
|
47
36
|
*
|
|
48
37
|
* @param {Payload} asset - A partial public asset.
|
|
49
|
-
* @
|
|
38
|
+
* @returns {PartialApplication} A partial InternalRequest.
|
|
50
39
|
*/
|
|
51
|
-
function transformAsset(
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var partialApplication = {};
|
|
40
|
+
function transformAsset({ asset, applicationId, id }) {
|
|
41
|
+
var _a;
|
|
42
|
+
const isPropertyAsset = (0, is_asset_type_1.isRealEstateAsset)(asset);
|
|
43
|
+
const idPath = isPropertyAsset ? `${application_paths_1.paths.RealEstateAsset}.@UniqueID` : `${application_paths_1.paths.NonRealEstateAsset}.@UniqueID`;
|
|
44
|
+
const addressId = `${id}-address`;
|
|
45
|
+
const assetMapping = getAssetMapping(asset);
|
|
46
|
+
const partialApplication = {};
|
|
59
47
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
60
48
|
(0, lodash_1.set)(partialApplication, idPath, id);
|
|
61
49
|
if (isPropertyAsset) {
|
|
62
|
-
(0, lodash_1.set)(partialApplication,
|
|
63
|
-
(0, lodash_1.set)(partialApplication,
|
|
50
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.@MultipleDwellings`, lixi_internal_request_1.YesNoList.No);
|
|
51
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.@x_Address`, addressId);
|
|
64
52
|
}
|
|
65
53
|
else {
|
|
66
|
-
(0, lodash_1.set)(partialApplication,
|
|
54
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, enum_mappings_1.assetTypeMapping[asset.type]);
|
|
67
55
|
}
|
|
68
56
|
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
69
|
-
(0, lodash_1.set)(partialApplication,
|
|
70
|
-
(0, lodash_1.set)(partialApplication,
|
|
57
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
|
|
58
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.@Type`, enum_mappings_1.financialAssetMapping[asset.type]);
|
|
71
59
|
}
|
|
72
60
|
if ((0, is_asset_type_1.isOtherAsset)(asset)) {
|
|
73
|
-
(0, lodash_1.set)(partialApplication,
|
|
61
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
|
|
74
62
|
}
|
|
75
63
|
switch (asset.type) {
|
|
76
64
|
case public_asset_1.AssetType.Vehicle:
|
|
77
|
-
(0, lodash_1.set)(partialApplication,
|
|
65
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
|
|
78
66
|
break;
|
|
79
67
|
case public_asset_1.AssetType.HomeContents:
|
|
80
|
-
(0, lodash_1.set)(partialApplication,
|
|
68
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.OtherAsset.@Type`, lixi_internal_request_1.OtherAssetTypeList.HomeContents);
|
|
81
69
|
break;
|
|
82
70
|
case public_asset_1.AssetType.Gifts:
|
|
83
|
-
(0, lodash_1.set)(partialApplication,
|
|
71
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description || 'Asset Gifts');
|
|
84
72
|
break;
|
|
85
73
|
case public_asset_1.AssetType.OtherAsset:
|
|
86
74
|
if (asset.description) {
|
|
87
|
-
(0, lodash_1.set)(partialApplication,
|
|
75
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description);
|
|
88
76
|
}
|
|
89
77
|
break;
|
|
90
78
|
}
|
|
91
|
-
for (
|
|
92
|
-
var _d = _c[_i], key = _d[0], value = _d[1];
|
|
79
|
+
for (const [key, value] of Object.entries(asset)) {
|
|
93
80
|
if (assetMapping[key]) {
|
|
94
81
|
switch (key) {
|
|
95
82
|
case 'contractDetails':
|
|
96
|
-
|
|
83
|
+
const { contractDate } = value;
|
|
97
84
|
if (contractDate)
|
|
98
85
|
(0, lodash_1.set)(partialApplication, assetMapping.contractDate, contractDate);
|
|
99
86
|
break;
|
|
@@ -104,14 +91,14 @@ function transformAsset(_a) {
|
|
|
104
91
|
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.toBePurchasedMapping[value]);
|
|
105
92
|
break;
|
|
106
93
|
case 'propertyExpenses':
|
|
107
|
-
if (!asset.percentOwned || (0, lodash_1.isEmpty)((
|
|
94
|
+
if (!asset.percentOwned || (0, lodash_1.isEmpty)((_a = asset.percentOwned) === null || _a === void 0 ? void 0 : _a.owners)) {
|
|
108
95
|
break;
|
|
109
96
|
}
|
|
110
|
-
|
|
111
|
-
(0, lodash_1.set)(partialApplication,
|
|
112
|
-
|
|
97
|
+
const propertyExpenses = generatePropertyExpenses(value);
|
|
98
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.PropertyExpense`, propertyExpenses);
|
|
99
|
+
const livingExpenses = generateLivingExpenses(asset.percentOwned, id, value);
|
|
113
100
|
(0, lodash_1.set)(partialApplication, assetMapping[key], livingExpenses);
|
|
114
|
-
(0, lodash_1.set)(partialApplication,
|
|
101
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.@Occupancy`, determineOccupancy(value));
|
|
115
102
|
break;
|
|
116
103
|
case 'propertyStatus':
|
|
117
104
|
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
|
|
@@ -121,16 +108,16 @@ function transformAsset(_a) {
|
|
|
121
108
|
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.toBeUsedAsSecurityMapping[value]);
|
|
122
109
|
break;
|
|
123
110
|
case 'propertyType':
|
|
124
|
-
|
|
125
|
-
if (!
|
|
126
|
-
logger_1.logger.warn({ message:
|
|
111
|
+
const propertyTypeMapping = getPropertyType(value);
|
|
112
|
+
if (!propertyTypeMapping) {
|
|
113
|
+
logger_1.logger.warn({ message: `Unknown propertyType ${value} for asset ${id}`, applicationId });
|
|
127
114
|
}
|
|
128
|
-
|
|
115
|
+
const { path, value: mappedValue } = propertyTypeMapping;
|
|
129
116
|
(0, lodash_1.set)(partialApplication, path, mappedValue);
|
|
130
117
|
break;
|
|
131
118
|
case 'zoneType':
|
|
132
119
|
if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
|
|
133
|
-
(0, lodash_1.set)(partialApplication,
|
|
120
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.Commercial.@Type`, lixi_internal_request_1.OtherAssetTypeList.Other);
|
|
134
121
|
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom6TypeList.Commercial);
|
|
135
122
|
}
|
|
136
123
|
else {
|
|
@@ -139,7 +126,7 @@ function transformAsset(_a) {
|
|
|
139
126
|
break;
|
|
140
127
|
case 'financialInstitution':
|
|
141
128
|
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
142
|
-
|
|
129
|
+
const financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
|
|
143
130
|
(0, lodash_1.set)(partialApplication, assetMapping[key], financialInstitution);
|
|
144
131
|
}
|
|
145
132
|
break;
|
|
@@ -153,26 +140,25 @@ function transformAsset(_a) {
|
|
|
153
140
|
(0, lodash_1.set)(partialApplication, assetMapping[key], (0, __1.booleanMapping)(value));
|
|
154
141
|
break;
|
|
155
142
|
case 'percentOwned':
|
|
156
|
-
|
|
143
|
+
const percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
|
|
157
144
|
if (percentOwned) {
|
|
158
145
|
(0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
|
|
159
146
|
}
|
|
160
147
|
break;
|
|
161
148
|
case 'constructionDetails':
|
|
162
|
-
for (
|
|
163
|
-
|
|
164
|
-
switch (key_1) {
|
|
149
|
+
for (const [key, constructionDetailsValue] of Object.entries(value)) {
|
|
150
|
+
switch (key) {
|
|
165
151
|
case 'builderType':
|
|
166
|
-
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[
|
|
152
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], builder_type_1.builderTypeMapping[constructionDetailsValue]);
|
|
167
153
|
break;
|
|
168
154
|
case 'constructionType':
|
|
169
|
-
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[
|
|
155
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], construction_type_1.constructionTypeMapping[constructionDetailsValue]);
|
|
170
156
|
break;
|
|
171
157
|
case 'isFixedPriceContract':
|
|
172
|
-
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[
|
|
158
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], (0, __1.booleanMapping)(constructionDetailsValue));
|
|
173
159
|
break;
|
|
174
160
|
default:
|
|
175
|
-
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[
|
|
161
|
+
(0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], constructionDetailsValue);
|
|
176
162
|
break;
|
|
177
163
|
}
|
|
178
164
|
}
|
|
@@ -198,22 +184,22 @@ exports.transformAsset = transformAsset;
|
|
|
198
184
|
* @returns {PropertyTypeMapping | null} A path and value to be used for property type mapping.
|
|
199
185
|
*/
|
|
200
186
|
function getPropertyType(propertyType) {
|
|
201
|
-
|
|
187
|
+
const value = enum_mappings_1.propertyTypeMapping[propertyType];
|
|
202
188
|
if (exports.residentialTypeList.includes(value)) {
|
|
203
189
|
return {
|
|
204
|
-
path:
|
|
190
|
+
path: `${application_paths_1.paths.RealEstateAsset}.Residential`,
|
|
205
191
|
value: {
|
|
206
|
-
'@Type': value
|
|
207
|
-
}
|
|
192
|
+
'@Type': value,
|
|
193
|
+
},
|
|
208
194
|
};
|
|
209
195
|
}
|
|
210
196
|
if (exports.propertyTypeNameList.includes(value)) {
|
|
211
197
|
return {
|
|
212
|
-
path:
|
|
198
|
+
path: `${application_paths_1.paths.RealEstateAsset}.PropertyType`,
|
|
213
199
|
value: {
|
|
214
200
|
'@PropertyTypeName': value,
|
|
215
|
-
'@CategoryTypeName': lixi_internal_request_2.Custom1CategoryTypeNameList.Residential
|
|
216
|
-
}
|
|
201
|
+
'@CategoryTypeName': lixi_internal_request_2.Custom1CategoryTypeNameList.Residential,
|
|
202
|
+
},
|
|
217
203
|
};
|
|
218
204
|
}
|
|
219
205
|
return null;
|
|
@@ -225,37 +211,37 @@ exports.getPropertyType = getPropertyType;
|
|
|
225
211
|
* @returns {Record<string, string>} Asset Transform Mapping.
|
|
226
212
|
*/
|
|
227
213
|
function getAssetMapping(asset) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
estimatedValue
|
|
232
|
-
percentOwned
|
|
214
|
+
let estimatedValue = `${application_paths_1.paths.NonRealEstateAsset}.EstimatedValue.@Value`;
|
|
215
|
+
let percentOwned = `${application_paths_1.paths.NonRealEstateAsset}.PercentOwned`;
|
|
216
|
+
const baseMapping = {
|
|
217
|
+
estimatedValue,
|
|
218
|
+
percentOwned,
|
|
233
219
|
};
|
|
234
220
|
if ((0, is_asset_type_1.isRealEstateAsset)(asset)) {
|
|
235
|
-
estimatedValue =
|
|
236
|
-
percentOwned =
|
|
221
|
+
estimatedValue = `${application_paths_1.paths.RealEstateAsset}.EstimatedValue.@Value`;
|
|
222
|
+
percentOwned = `${application_paths_1.paths.RealEstateAsset}.PercentOwned`;
|
|
237
223
|
return {
|
|
238
224
|
address: application_paths_1.paths.Address,
|
|
239
225
|
contractDetails: 'contractDetails',
|
|
240
|
-
contractDate:
|
|
241
|
-
estimatedValue
|
|
242
|
-
percentOwned
|
|
243
|
-
primaryPurpose:
|
|
226
|
+
contractDate: `${application_paths_1.paths.RealEstateAsset}.ContractDetails.@ContractDate`,
|
|
227
|
+
estimatedValue,
|
|
228
|
+
percentOwned,
|
|
229
|
+
primaryPurpose: `${application_paths_1.paths.RealEstateAsset}.@PrimaryPurpose`,
|
|
244
230
|
propertyExpenses: application_paths_1.paths.LivingExpenses,
|
|
245
|
-
propertyStatus:
|
|
246
|
-
propertyType:
|
|
247
|
-
toBePurchased:
|
|
248
|
-
toBeUsedAsSecurity:
|
|
249
|
-
zoneType:
|
|
250
|
-
isConstruction:
|
|
251
|
-
constructionDetails:
|
|
231
|
+
propertyStatus: `${application_paths_1.paths.RealEstateAsset}.@Status`,
|
|
232
|
+
propertyType: `${application_paths_1.paths.RealEstateAsset}.Residential`,
|
|
233
|
+
toBePurchased: `${application_paths_1.paths.RealEstateAsset}.@Transaction`,
|
|
234
|
+
toBeUsedAsSecurity: `${application_paths_1.paths.RealEstateAsset}.@ToBeUsedAsSecurity`,
|
|
235
|
+
zoneType: `${application_paths_1.paths.RealEstateAsset}.Zoning.@Type`,
|
|
236
|
+
isConstruction: `${application_paths_1.paths.RealEstateAsset}.@Construction`,
|
|
237
|
+
constructionDetails: `${application_paths_1.paths.RealEstateAsset}.ConstructionDetails`,
|
|
252
238
|
};
|
|
253
239
|
}
|
|
254
240
|
if ((0, is_asset_type_1.isMotorVehicle)(asset)) {
|
|
255
|
-
return
|
|
241
|
+
return Object.assign(Object.assign({}, baseMapping), { make: `${application_paths_1.paths.NonRealEstateAsset}.MotorVehicle.@Make`, model: `${application_paths_1.paths.NonRealEstateAsset}.MotorVehicle.@Model`, year: `${application_paths_1.paths.NonRealEstateAsset}.MotorVehicle.@Year` });
|
|
256
242
|
}
|
|
257
243
|
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
258
|
-
return
|
|
244
|
+
return Object.assign(Object.assign({}, baseMapping), { financialInstitution: `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.AccountNumber.@FinancialInstitution`, financialInstitutionAccountNumber: `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.AccountNumber.@AccountNumber`, financialInstitutionBsb: `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.AccountNumber.@BSB` });
|
|
259
245
|
}
|
|
260
246
|
return baseMapping;
|
|
261
247
|
}
|
|
@@ -266,26 +252,29 @@ exports.getAssetMapping = getAssetMapping;
|
|
|
266
252
|
* @param percentOwned: owners of the property
|
|
267
253
|
* @param assetId: Asset id
|
|
268
254
|
* @param propertyExpenses: propertyExpenses items
|
|
255
|
+
* @param percentOwned
|
|
256
|
+
* @param assetId
|
|
257
|
+
* @param propertyExpenses
|
|
269
258
|
*/
|
|
270
259
|
function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
percentOwned.owners.forEach(
|
|
274
|
-
|
|
260
|
+
let livingExpenses = [];
|
|
261
|
+
const filteredPropertyExpenses = propertyExpenses.filter((expense) => expense.amount !== undefined);
|
|
262
|
+
percentOwned.owners.forEach((owner) => {
|
|
263
|
+
const expenses = filteredPropertyExpenses.map((expense) => {
|
|
275
264
|
normalizeAmounts(expense);
|
|
276
265
|
return {
|
|
277
266
|
'@Amount': (0, round_decimal_1.roundDecimal)(expense.amount * owner.percent),
|
|
278
267
|
'@Category': enum_mappings_1.livingExpenseMapping[expense.type],
|
|
279
268
|
'@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency],
|
|
280
|
-
'@UniqueID':
|
|
269
|
+
'@UniqueID': `${(0, uuid_1.v4)()}--${assetId}`,
|
|
281
270
|
PercentResponsible: {
|
|
282
271
|
Owner: [
|
|
283
272
|
{
|
|
284
273
|
'@Percent': 100,
|
|
285
|
-
'@x_Party': owner.applicantId
|
|
274
|
+
'@x_Party': owner.applicantId,
|
|
286
275
|
},
|
|
287
|
-
]
|
|
288
|
-
}
|
|
276
|
+
],
|
|
277
|
+
},
|
|
289
278
|
};
|
|
290
279
|
});
|
|
291
280
|
livingExpenses = livingExpenses.concat(expenses);
|
|
@@ -295,43 +284,44 @@ function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
|
|
|
295
284
|
exports.generateLivingExpenses = generateLivingExpenses;
|
|
296
285
|
/**
|
|
297
286
|
* Creates PropertyExpense array on RealEstateAsset from the same array on the event.
|
|
287
|
+
*
|
|
298
288
|
* @param propertyExpenses
|
|
299
289
|
*/
|
|
300
290
|
function generatePropertyExpenses(propertyExpenses) {
|
|
301
291
|
return propertyExpenses
|
|
302
|
-
.filter(
|
|
303
|
-
.map(
|
|
292
|
+
.filter((expense) => expense.amount !== undefined)
|
|
293
|
+
.map((expense) => {
|
|
304
294
|
normalizeAmounts(expense);
|
|
305
295
|
return {
|
|
306
296
|
'@Amount': expense.amount,
|
|
307
297
|
'@Category': enum_mappings_1.propertyExpenseCategoryMapping[expense.type],
|
|
308
|
-
'@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency]
|
|
298
|
+
'@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency],
|
|
309
299
|
};
|
|
310
300
|
});
|
|
311
301
|
}
|
|
312
302
|
exports.generatePropertyExpenses = generatePropertyExpenses;
|
|
313
303
|
/**
|
|
314
304
|
* Determines the occupancy based on the list of property expense types available.
|
|
305
|
+
*
|
|
315
306
|
* @param propertyExpenses
|
|
316
307
|
*/
|
|
317
308
|
function determineOccupancy(propertyExpenses) {
|
|
318
|
-
|
|
309
|
+
const propertyExpenseCategoryList = propertyExpenses.map((expense) => expense.type);
|
|
319
310
|
if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.InvestmentPropertyRunningCosts)) {
|
|
320
311
|
return lixi_internal_request_1.OccupancyList.NonOwner;
|
|
321
312
|
}
|
|
322
313
|
else if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts && public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts)) {
|
|
323
314
|
return lixi_internal_request_1.OccupancyList.OwnerSecondary;
|
|
324
315
|
}
|
|
325
|
-
else if (propertyExpenseCategoryList.some(
|
|
326
|
-
|
|
327
|
-
item === public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts;
|
|
328
|
-
})) {
|
|
316
|
+
else if (propertyExpenseCategoryList.some((item) => item !== public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts &&
|
|
317
|
+
item === public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts)) {
|
|
329
318
|
return lixi_internal_request_1.OccupancyList.OwnerPrimary;
|
|
330
319
|
}
|
|
331
320
|
}
|
|
332
321
|
exports.determineOccupancy = determineOccupancy;
|
|
333
322
|
/**
|
|
334
323
|
* Calculates the correct amount and frequency.
|
|
324
|
+
*
|
|
335
325
|
* @param expense
|
|
336
326
|
*/
|
|
337
327
|
function normalizeAmounts(expense) {
|
|
@@ -15,6 +15,10 @@ export declare function transformExpenses(expense: ExpensePayload): PartialAppli
|
|
|
15
15
|
* @param applicantId: Event applicantId.
|
|
16
16
|
* @param index: Index of the map.
|
|
17
17
|
* @param id: Id of the event.
|
|
18
|
+
* @param expense
|
|
19
|
+
* @param applicantId
|
|
20
|
+
* @param index
|
|
21
|
+
* @param id
|
|
18
22
|
*/
|
|
19
23
|
export declare function transformExpense(expense: Expense, applicantId: string, index: number, id: string): LivingExpense | OtherCommitment;
|
|
20
24
|
/**
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isLivingExpenseEstimate = exports.isOtherCommitment = exports.normaliseExpenseAmount = exports.transformExpense = exports.transformExpenses = exports.otherCommitmentExpenseTypes = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const enum_mappings_1 = require("../types/enum-mappings/");
|
|
7
|
+
const public_expense_1 = require("../types/events/public-expense");
|
|
8
8
|
exports.otherCommitmentExpenseTypes = [
|
|
9
9
|
public_expense_1.ExpenseType.Board,
|
|
10
10
|
public_expense_1.ExpenseType.ChildAndSpousalMaintenance,
|
|
11
11
|
public_expense_1.ExpenseType.Rent,
|
|
12
12
|
];
|
|
13
|
-
|
|
13
|
+
const propertyExpenseCategories = [
|
|
14
14
|
public_expense_1.ExpenseType.InvestmentPropertyRunningCosts,
|
|
15
15
|
public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
|
|
16
16
|
public_expense_1.ExpenseType.SecondaryResidenceRunningCosts,
|
|
@@ -22,33 +22,31 @@ var propertyExpenseCategories = [
|
|
|
22
22
|
* @param expense
|
|
23
23
|
*/
|
|
24
24
|
function transformExpenses(expense) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (expenses.every(
|
|
25
|
+
const partialApplication = {};
|
|
26
|
+
const { applicantId, applicationId, expenses = [], id } = expense;
|
|
27
|
+
if (expenses.every((expense) => expense.amount === undefined || expense.amount === null)) {
|
|
28
28
|
return partialApplication;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const normalisedExpenses = expenses.map(normaliseExpenseAmount);
|
|
31
|
+
const filteredLivingExpensesWithAmount = normalisedExpenses.filter((expense) => expense.amount || !propertyExpenseCategories.includes(expense.type));
|
|
32
|
+
const livingExpenseEstimate = filteredLivingExpensesWithAmount.find(isLivingExpenseEstimate);
|
|
33
|
+
const otherCommitments = filteredLivingExpensesWithAmount.filter(isOtherCommitment);
|
|
34
|
+
const expenseBreakdown = filteredLivingExpensesWithAmount.filter((item) => !(isOtherCommitment(item) || isLivingExpenseEstimate(item)));
|
|
35
|
+
const livingExpenseEstimateExists = (0, lodash_1.get)(livingExpenseEstimate || {}, 'amount', 0) > 0;
|
|
36
|
+
const expenseBreakdownAmountSum = (0, lodash_1.sumBy)(expenseBreakdown, 'amount');
|
|
37
|
+
let lixiLivingExpenses;
|
|
38
38
|
// unless all individual expenses have a value of 0 and a living estimate exists, transform them without question.
|
|
39
39
|
if (expenseBreakdownAmountSum === 0 && livingExpenseEstimateExists) {
|
|
40
|
-
|
|
40
|
+
const estimate = transformExpense(livingExpenseEstimate, applicantId, 0, id);
|
|
41
41
|
lixiLivingExpenses = [estimate];
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
|
-
lixiLivingExpenses = expenseBreakdown.map(
|
|
45
|
-
return transformExpense(expense, applicantId, index, id);
|
|
46
|
-
});
|
|
44
|
+
lixiLivingExpenses = expenseBreakdown.map((expense, index) => transformExpense(expense, applicantId, index, id));
|
|
47
45
|
}
|
|
48
|
-
|
|
46
|
+
const lixiCommitmentExpenses = otherCommitments.map((expense, index) => transformExpense(expense, applicantId, index, id));
|
|
49
47
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
50
|
-
(0, lodash_1.set)(partialApplication,
|
|
51
|
-
(0, lodash_1.set)(partialApplication,
|
|
48
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Household}.@UniqueID`, `${applicationId}-household`);
|
|
49
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
52
50
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
53
51
|
if (lixiLivingExpenses.length > 0) {
|
|
54
52
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
@@ -63,22 +61,26 @@ exports.transformExpenses = transformExpenses;
|
|
|
63
61
|
* @param applicantId: Event applicantId.
|
|
64
62
|
* @param index: Index of the map.
|
|
65
63
|
* @param id: Id of the event.
|
|
64
|
+
* @param expense
|
|
65
|
+
* @param applicantId
|
|
66
|
+
* @param index
|
|
67
|
+
* @param id
|
|
66
68
|
*/
|
|
67
69
|
function transformExpense(expense, applicantId, index, id) {
|
|
68
70
|
return {
|
|
69
71
|
'@Amount': expense.amount,
|
|
70
72
|
'@Category': enum_mappings_1.livingExpenseMapping[expense.type],
|
|
71
73
|
'@Description': expense.type,
|
|
72
|
-
'@UniqueID': isOtherCommitment(expense) ?
|
|
74
|
+
'@UniqueID': isOtherCommitment(expense) ? `${id}-commitment-${index}` : `${id}-living-expense-${index}`,
|
|
73
75
|
'@Frequency': enum_mappings_1.frequencyMapping[expense.frequency],
|
|
74
76
|
PercentResponsible: {
|
|
75
77
|
Owner: [
|
|
76
78
|
{
|
|
77
79
|
'@Percent': 100,
|
|
78
|
-
'@x_Party': applicantId
|
|
80
|
+
'@x_Party': applicantId,
|
|
79
81
|
},
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
+
],
|
|
83
|
+
},
|
|
82
84
|
};
|
|
83
85
|
}
|
|
84
86
|
exports.transformExpense = transformExpense;
|
|
@@ -88,7 +90,7 @@ exports.transformExpense = transformExpense;
|
|
|
88
90
|
* @returns {Expense} An normalised expense.
|
|
89
91
|
*/
|
|
90
92
|
function normaliseExpenseAmount(expense) {
|
|
91
|
-
|
|
93
|
+
const { amount, frequency = public_expense_1.Frequency.Yearly, type: expenseType } = expense;
|
|
92
94
|
if (frequency === public_expense_1.Frequency.Quarterly) {
|
|
93
95
|
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
94
96
|
expense.amount *= 4;
|
|
@@ -6,7 +6,7 @@ import { PartialApplication } from '../types/partial-application';
|
|
|
6
6
|
*
|
|
7
7
|
* @param fundingPosition a partialFundingPosition.
|
|
8
8
|
* @param uniqueIdSuffix
|
|
9
|
-
* @
|
|
9
|
+
* @returns partialApplication with fees, grants and borrowers contributions added.
|
|
10
10
|
*/
|
|
11
11
|
export declare function transformFundingPosition(fundingPosition: FundingPositionPayload, uniqueIdSuffix?: string): PartialApplication;
|
|
12
12
|
/**
|
|
@@ -16,6 +16,6 @@ export declare function transformFundingPosition(fundingPosition: FundingPositio
|
|
|
16
16
|
* @param lmi
|
|
17
17
|
* @param lmiIncluded
|
|
18
18
|
* @param id
|
|
19
|
-
* @
|
|
19
|
+
* @returns Array of fees
|
|
20
20
|
*/
|
|
21
21
|
export declare function getFees(fundsRequiredBreakDown: FundsRequiredBreakdown, lmi: number, lmiIncluded: boolean, id: string): Fee[];
|