@lendi/integrations-transform 1.3.5 → 1.3.8

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.
@@ -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
  },
@@ -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';
@@ -31,6 +31,22 @@ export declare function getAssetMapping(asset: Asset): Record<string, string>;
31
31
  * Creates living expense items from a propertyExpense object.
32
32
  *
33
33
  * @param percentOwned: owners of the property
34
+ * @param assetId: Asset id
34
35
  * @param propertyExpenses: propertyExpenses items
35
36
  */
36
- export declare function generatePropertyExpenses(percentOwned: PercentOwned, propertyExpenses: PropertyExpense[]): LivingExpense[];
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(asset.percentOwned, value);
96
- (0, lodash_1.set)(partialApplication, assetMapping[key], propertyExpenses);
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]);
@@ -137,6 +154,31 @@ function transformAsset(_a) {
137
154
  (0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
138
155
  }
139
156
  break;
157
+ case 'constructionDetails':
158
+ for (var _d = 0, _e = Object.entries(value); _d < _e.length; _d++) {
159
+ var _f = _e[_d], key_1 = _f[0], constructionDetailsValue = _f[1];
160
+ switch (key_1) {
161
+ case 'builderType':
162
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], builder_type_1.builderTypeMapping[constructionDetailsValue]);
163
+ break;
164
+ case 'constructionType':
165
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], construction_type_1.constructionTypeMapping[constructionDetailsValue]);
166
+ break;
167
+ case 'isFixedPriceContract':
168
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], (0, __1.booleanMapping)(constructionDetailsValue));
169
+ break;
170
+ default:
171
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], constructionDetailsValue);
172
+ break;
173
+ }
174
+ }
175
+ break;
176
+ case 'estimatedValue':
177
+ if (asset.isConstruction) {
178
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], value);
179
+ }
180
+ (0, lodash_1.set)(partialApplication, assetMapping[key], value);
181
+ break;
140
182
  default:
141
183
  (0, lodash_1.set)(partialApplication, assetMapping[key], value);
142
184
  break;
@@ -200,7 +242,9 @@ function getAssetMapping(asset) {
200
242
  propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
201
243
  toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
202
244
  toBeUsedAsSecurity: "".concat(application_paths_1.paths.RealEstateAsset, ".@ToBeUsedAsSecurity"),
203
- zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type")
245
+ zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type"),
246
+ isConstruction: "".concat(application_paths_1.paths.RealEstateAsset, ".@Construction"),
247
+ constructionDetails: "".concat(application_paths_1.paths.RealEstateAsset, ".ConstructionDetails")
204
248
  };
205
249
  }
206
250
  if ((0, is_asset_type_1.isMotorVehicle)(asset)) {
@@ -216,22 +260,20 @@ exports.getAssetMapping = getAssetMapping;
216
260
  * Creates living expense items from a propertyExpense object.
217
261
  *
218
262
  * @param percentOwned: owners of the property
263
+ * @param assetId: Asset id
219
264
  * @param propertyExpenses: propertyExpenses items
220
265
  */
221
- function generatePropertyExpenses(percentOwned, propertyExpenses) {
266
+ function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
222
267
  var livingExpenses = [];
223
268
  var filteredPropertyExpenses = propertyExpenses.filter(function (expense) { return expense.amount !== undefined; });
224
269
  percentOwned.owners.forEach(function (owner) {
225
270
  var expenses = filteredPropertyExpenses.map(function (expense) {
226
- if (expense.frequency === public_expense_1.Frequency.Quarterly) {
227
- expense.frequency = public_expense_1.Frequency.Yearly;
228
- expense.amount *= 4;
229
- }
271
+ normalizeAmounts(expense);
230
272
  return {
231
273
  '@Amount': (0, round_decimal_1.roundDecimal)(expense.amount * owner.percent),
232
274
  '@Category': enum_mappings_1.livingExpenseMapping[expense.type],
233
275
  '@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency],
234
- '@UniqueID': (0, uuid_1.v4)(),
276
+ '@UniqueID': "".concat((0, uuid_1.v4)(), "--").concat(assetId),
235
277
  PercentResponsible: {
236
278
  Owner: [
237
279
  {
@@ -246,4 +288,53 @@ function generatePropertyExpenses(percentOwned, propertyExpenses) {
246
288
  });
247
289
  return livingExpenses;
248
290
  }
291
+ exports.generateLivingExpenses = generateLivingExpenses;
292
+ /**
293
+ * Creates PropertyExpense array on RealEstateAsset from the same array on the event.
294
+ * @param propertyExpenses
295
+ */
296
+ function generatePropertyExpenses(propertyExpenses) {
297
+ return propertyExpenses
298
+ .filter(function (expense) { return expense.amount !== undefined; })
299
+ .map(function (expense) {
300
+ normalizeAmounts(expense);
301
+ return {
302
+ '@Amount': expense.amount,
303
+ '@Category': enum_mappings_1.propertyExpenseCategoryMapping[expense.type],
304
+ '@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency]
305
+ };
306
+ });
307
+ }
249
308
  exports.generatePropertyExpenses = generatePropertyExpenses;
309
+ /**
310
+ * Determines the occupancy based on the list of property expense types available.
311
+ * @param propertyExpenses
312
+ */
313
+ function determineOccupancy(propertyExpenses) {
314
+ var propertyExpenseCategoryList = propertyExpenses.map(function (expense) { return expense.type; });
315
+ if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.InvestmentPropertyRunningCosts)) {
316
+ return lixi_internal_request_1.OccupancyList.NonOwner;
317
+ }
318
+ else if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts && public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts)) {
319
+ return lixi_internal_request_1.OccupancyList.OwnerSecondary;
320
+ }
321
+ else if (propertyExpenseCategoryList.some(function (item) {
322
+ return item !== public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts &&
323
+ item === public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts;
324
+ })) {
325
+ return lixi_internal_request_1.OccupancyList.OwnerPrimary;
326
+ }
327
+ }
328
+ exports.determineOccupancy = determineOccupancy;
329
+ /**
330
+ * Calculates the correct amount and frequency.
331
+ * @param expense
332
+ */
333
+ function normalizeAmounts(expense) {
334
+ if (expense.frequency === public_expense_1.Frequency.Quarterly) {
335
+ expense.frequency = public_expense_1.Frequency.Yearly;
336
+ expense.amount *= 4;
337
+ }
338
+ return expense;
339
+ }
340
+ 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.5",
3
+ "version": "1.3.8",
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.15.8",
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",