@lendi/integrations-transform 1.3.7 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +5 -1
- package/lib/schemas/public-asset-event.json +20 -0
- package/lib/transform-events/transform-asset.js +46 -2
- package/lib/transform-events/transform-expenses.js +18 -19
- 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.js +5 -1
- package/lib/types/events/public-asset.d.ts +14 -0
- package/lib/types/events/public-asset.js +12 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -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
|
},
|
|
@@ -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
|
*
|
|
@@ -134,12 +148,40 @@ function transformAsset(_a) {
|
|
|
134
148
|
case 'address':
|
|
135
149
|
(0, lodash_1.set)(partialApplication, assetMapping[key], (0, transform_asset_address_1.transformAddress)(value, addressId));
|
|
136
150
|
break;
|
|
151
|
+
case 'isConstruction':
|
|
152
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], (0, __1.booleanMapping)(value));
|
|
153
|
+
break;
|
|
137
154
|
case 'percentOwned':
|
|
138
155
|
var percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
|
|
139
156
|
if (percentOwned) {
|
|
140
157
|
(0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
|
|
141
158
|
}
|
|
142
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;
|
|
143
185
|
default:
|
|
144
186
|
(0, lodash_1.set)(partialApplication, assetMapping[key], value);
|
|
145
187
|
break;
|
|
@@ -203,7 +245,9 @@ function getAssetMapping(asset) {
|
|
|
203
245
|
propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
|
|
204
246
|
toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
|
|
205
247
|
toBeUsedAsSecurity: "".concat(application_paths_1.paths.RealEstateAsset, ".@ToBeUsedAsSecurity"),
|
|
206
|
-
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")
|
|
207
251
|
};
|
|
208
252
|
}
|
|
209
253
|
if ((0, is_asset_type_1.isMotorVehicle)(asset)) {
|
|
@@ -232,7 +276,7 @@ function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
|
|
|
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
|
{
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
exports.__esModule = true;
|
|
14
3
|
exports.isLivingExpenseEstimate = exports.isOtherCommitment = exports.normaliseExpenseAmount = exports.transformExpense = exports.transformExpenses = exports.otherCommitmentExpenseTypes = void 0;
|
|
15
4
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
@@ -21,6 +10,12 @@ exports.otherCommitmentExpenseTypes = [
|
|
|
21
10
|
public_expense_1.ExpenseType.ChildAndSpousalMaintenance,
|
|
22
11
|
public_expense_1.ExpenseType.Rent,
|
|
23
12
|
];
|
|
13
|
+
var propertyExpenseCategories = [
|
|
14
|
+
public_expense_1.ExpenseType.InvestmentPropertyRunningCosts,
|
|
15
|
+
public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
|
|
16
|
+
public_expense_1.ExpenseType.SecondaryResidenceRunningCosts,
|
|
17
|
+
public_expense_1.ExpenseType.PrimaryResidenceRunningCosts,
|
|
18
|
+
];
|
|
24
19
|
/**
|
|
25
20
|
* @description Transforms expense items on the application from the event.
|
|
26
21
|
* @returns {PartialApplication} A PartialApplication returned by transforming the expense event.
|
|
@@ -33,12 +28,13 @@ function transformExpenses(expense) {
|
|
|
33
28
|
return partialApplication;
|
|
34
29
|
}
|
|
35
30
|
var normalisedExpenses = expenses.map(normaliseExpenseAmount);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
31
|
+
var filteredLivingExpensesWithAmount = normalisedExpenses.filter(function (expense) { return expense.amount || !propertyExpenseCategories.includes(expense.type); });
|
|
32
|
+
var livingExpenseEstimate = filteredLivingExpensesWithAmount.find(isLivingExpenseEstimate);
|
|
33
|
+
var otherCommitments = filteredLivingExpensesWithAmount.filter(isOtherCommitment);
|
|
34
|
+
var expenseBreakdown = filteredLivingExpensesWithAmount.filter(function (item) { return !(isOtherCommitment(item) || isLivingExpenseEstimate(item)); });
|
|
39
35
|
var livingExpenseEstimateExists = (0, lodash_1.get)(livingExpenseEstimate || {}, 'amount', 0) > 0;
|
|
40
36
|
var expenseBreakdownAmountSum = (0, lodash_1.sumBy)(expenseBreakdown, 'amount');
|
|
41
|
-
var lixiLivingExpenses
|
|
37
|
+
var lixiLivingExpenses;
|
|
42
38
|
// unless all individual expenses have a value of 0 and a living estimate exists, transform them without question.
|
|
43
39
|
if (expenseBreakdownAmountSum === 0 && livingExpenseEstimateExists) {
|
|
44
40
|
var estimate = transformExpense(livingExpenseEstimate, applicantId, 0, id);
|
|
@@ -92,12 +88,15 @@ exports.transformExpense = transformExpense;
|
|
|
92
88
|
* @returns {Expense} An normalised expense.
|
|
93
89
|
*/
|
|
94
90
|
function normaliseExpenseAmount(expense) {
|
|
95
|
-
var
|
|
91
|
+
var amount = expense.amount, _a = expense.frequency, frequency = _a === void 0 ? public_expense_1.Frequency.Yearly : _a, expenseType = expense.type;
|
|
96
92
|
if (frequency === public_expense_1.Frequency.Quarterly) {
|
|
97
|
-
frequency = public_expense_1.Frequency.Yearly;
|
|
98
|
-
amount
|
|
93
|
+
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
94
|
+
expense.amount *= 4;
|
|
95
|
+
}
|
|
96
|
+
if (!amount && !propertyExpenseCategories.includes(expenseType)) {
|
|
97
|
+
expense.amount = 0;
|
|
99
98
|
}
|
|
100
|
-
return
|
|
99
|
+
return expense;
|
|
101
100
|
}
|
|
102
101
|
exports.normaliseExpenseAmount = normaliseExpenseAmount;
|
|
103
102
|
/**
|
|
@@ -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);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -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
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Library for kafka event data transforming",
|
|
5
5
|
"author": "Integrations <integrations@lendi.com.au>",
|
|
6
6
|
"homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@lendi/integrations-credit-protocol": "1.16.
|
|
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",
|