@lendi/integrations-transform 1.3.6 → 1.3.7
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/transform-events/transform-asset.d.ts +17 -2
- package/lib/transform-events/transform-asset.js +57 -8
- 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/package.json +2 -2
|
@@ -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");
|
|
@@ -92,8 +92,11 @@ function transformAsset(_a) {
|
|
|
92
92
|
if (!asset.percentOwned) {
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
|
-
var propertyExpenses = generatePropertyExpenses(
|
|
96
|
-
(0, lodash_1.set)(partialApplication,
|
|
95
|
+
var propertyExpenses = generatePropertyExpenses(value);
|
|
96
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyExpense"), propertyExpenses);
|
|
97
|
+
var livingExpenses = generateLivingExpenses(asset.percentOwned, id, value);
|
|
98
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], livingExpenses);
|
|
99
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Occupancy"), determineOccupancy(value));
|
|
97
100
|
break;
|
|
98
101
|
case 'propertyStatus':
|
|
99
102
|
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
|
|
@@ -219,15 +222,12 @@ exports.getAssetMapping = getAssetMapping;
|
|
|
219
222
|
* @param assetId: Asset id
|
|
220
223
|
* @param propertyExpenses: propertyExpenses items
|
|
221
224
|
*/
|
|
222
|
-
function
|
|
225
|
+
function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
|
|
223
226
|
var livingExpenses = [];
|
|
224
227
|
var filteredPropertyExpenses = propertyExpenses.filter(function (expense) { return expense.amount !== undefined; });
|
|
225
228
|
percentOwned.owners.forEach(function (owner) {
|
|
226
229
|
var expenses = filteredPropertyExpenses.map(function (expense) {
|
|
227
|
-
|
|
228
|
-
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
229
|
-
expense.amount *= 4;
|
|
230
|
-
}
|
|
230
|
+
normalizeAmounts(expense);
|
|
231
231
|
return {
|
|
232
232
|
'@Amount': (0, round_decimal_1.roundDecimal)(expense.amount * owner.percent),
|
|
233
233
|
'@Category': enum_mappings_1.livingExpenseMapping[expense.type],
|
|
@@ -247,4 +247,53 @@ function generatePropertyExpenses(percentOwned, assetId, propertyExpenses) {
|
|
|
247
247
|
});
|
|
248
248
|
return livingExpenses;
|
|
249
249
|
}
|
|
250
|
+
exports.generateLivingExpenses = generateLivingExpenses;
|
|
251
|
+
/**
|
|
252
|
+
* Creates PropertyExpense array on RealEstateAsset from the same array on the event.
|
|
253
|
+
* @param propertyExpenses
|
|
254
|
+
*/
|
|
255
|
+
function generatePropertyExpenses(propertyExpenses) {
|
|
256
|
+
return propertyExpenses
|
|
257
|
+
.filter(function (expense) { return expense.amount !== undefined; })
|
|
258
|
+
.map(function (expense) {
|
|
259
|
+
normalizeAmounts(expense);
|
|
260
|
+
return {
|
|
261
|
+
'@Amount': expense.amount,
|
|
262
|
+
'@Category': enum_mappings_1.propertyExpenseCategoryMapping[expense.type],
|
|
263
|
+
'@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency]
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
}
|
|
250
267
|
exports.generatePropertyExpenses = generatePropertyExpenses;
|
|
268
|
+
/**
|
|
269
|
+
* Determines the occupancy based on the list of property expense types available.
|
|
270
|
+
* @param propertyExpenses
|
|
271
|
+
*/
|
|
272
|
+
function determineOccupancy(propertyExpenses) {
|
|
273
|
+
var propertyExpenseCategoryList = propertyExpenses.map(function (expense) { return expense.type; });
|
|
274
|
+
if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.InvestmentPropertyRunningCosts)) {
|
|
275
|
+
return lixi_internal_request_1.OccupancyList.NonOwner;
|
|
276
|
+
}
|
|
277
|
+
else if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts && public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts)) {
|
|
278
|
+
return lixi_internal_request_1.OccupancyList.OwnerSecondary;
|
|
279
|
+
}
|
|
280
|
+
else if (propertyExpenseCategoryList.some(function (item) {
|
|
281
|
+
return item !== public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts &&
|
|
282
|
+
item === public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts;
|
|
283
|
+
})) {
|
|
284
|
+
return lixi_internal_request_1.OccupancyList.OwnerPrimary;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
exports.determineOccupancy = determineOccupancy;
|
|
288
|
+
/**
|
|
289
|
+
* Calculates the correct amount and frequency.
|
|
290
|
+
* @param expense
|
|
291
|
+
*/
|
|
292
|
+
function normalizeAmounts(expense) {
|
|
293
|
+
if (expense.frequency === public_expense_1.Frequency.Quarterly) {
|
|
294
|
+
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
295
|
+
expense.amount *= 4;
|
|
296
|
+
}
|
|
297
|
+
return expense;
|
|
298
|
+
}
|
|
299
|
+
exports.normalizeAmounts = normalizeAmounts;
|
|
@@ -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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
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.0",
|
|
25
25
|
"@lendi/integrations-protocol": "2.5.4",
|
|
26
26
|
"clean-deep": "^3.4.0",
|
|
27
27
|
"date-fns": "2.19.0",
|