@lendi/integrations-transform 1.3.2 → 1.3.6

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.
@@ -503,6 +503,36 @@
503
503
  "applicationId": {
504
504
  "type": "string"
505
505
  },
506
+ "PropertyExpenses": {
507
+ "type": "array",
508
+ "items": {
509
+ "type": "object",
510
+ "additionalProperties": false,
511
+ "required": ["type"],
512
+ "properties": {
513
+ "type": {
514
+ "type": "string",
515
+ "enum": [
516
+ "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
517
+ "PRIMARY_RESIDENCE_RUNNING_COSTS",
518
+ "INVESTMENT_PROPERTY_RUNNING_COSTS",
519
+ "SECONDARY_RESIDENCE_RUNNING_COSTS"
520
+ ]
521
+ },
522
+ "amount": {
523
+ "type": "number",
524
+ "example": 100000
525
+ },
526
+ "frequency": {
527
+ "type": "string",
528
+ "enum": ["FORTNIGHTLY", "MONTHLY", "QUARTERLY", "WEEKLY", "YEARLY"]
529
+ },
530
+ "comments": {
531
+ "type": "string"
532
+ }
533
+ }
534
+ }
535
+ },
506
536
  "asset": {
507
537
  "type": "object",
508
538
  "properties": {
@@ -580,6 +610,9 @@
580
610
  },
581
611
  "year": {
582
612
  "$ref": "#/definitions/year"
613
+ },
614
+ "propertyExpenses": {
615
+ "$ref": "#/definitions/PropertyExpenses"
583
616
  }
584
617
  },
585
618
  "additionalProperties": true,
@@ -1,5 +1,6 @@
1
+ import { LivingExpense } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
1
2
  import { PropertyType as LixiPropertyType, Residential } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
- import { Asset, Payload, PropertyType } from '../types/events/public-asset';
3
+ import { Asset, Payload, PercentOwned, PropertyExpense, PropertyType } from '../types/events/public-asset';
3
4
  import { PartialApplication } from '../types/partial-application';
4
5
  export interface PropertyTypeMapping {
5
6
  path: string;
@@ -26,3 +27,11 @@ export declare function getPropertyType(propertyType: PropertyType): PropertyTyp
26
27
  * @returns {Record<string, string>} Asset Transform Mapping.
27
28
  */
28
29
  export declare function getAssetMapping(asset: Asset): Record<string, string>;
30
+ /**
31
+ * Creates living expense items from a propertyExpense object.
32
+ *
33
+ * @param percentOwned: owners of the property
34
+ * @param assetId: Asset id
35
+ * @param propertyExpenses: propertyExpenses items
36
+ */
37
+ export declare function generatePropertyExpenses(percentOwned: PercentOwned, assetId: string, propertyExpenses: PropertyExpense[]): LivingExpense[];
@@ -11,16 +11,19 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  exports.__esModule = true;
14
- exports.getAssetMapping = exports.getPropertyType = exports.transformAsset = exports.residentialTypeList = exports.propertyTypeNameList = void 0;
14
+ exports.generatePropertyExpenses = 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");
18
+ var uuid_1 = require("uuid");
18
19
  var lodash_1 = require("lodash");
19
20
  var logger_1 = require("../logger");
20
21
  var enum_mappings_1 = require("../types/enum-mappings");
21
22
  var public_asset_1 = require("../types/events/public-asset");
23
+ var public_expense_1 = require("../types/events/public-expense");
22
24
  var get_financial_institution_1 = require("../utils/get-financial-institution");
23
25
  var is_asset_type_1 = require("../utils/is-asset-type");
26
+ var round_decimal_1 = require("../utils/round-decimal");
24
27
  var transform_asset_address_1 = require("./transform-asset-address");
25
28
  var transform_percent_owned_1 = require("./transform-percent-owned");
26
29
  exports.propertyTypeNameList = Object.values(lixi_internal_request_2.Custom2PropertyTypeNameList);
@@ -85,6 +88,13 @@ function transformAsset(_a) {
85
88
  case 'toBePurchased':
86
89
  (0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.toBePurchasedMapping[value]);
87
90
  break;
91
+ case 'propertyExpenses':
92
+ if (!asset.percentOwned) {
93
+ break;
94
+ }
95
+ var propertyExpenses = generatePropertyExpenses(asset.percentOwned, id, value);
96
+ (0, lodash_1.set)(partialApplication, assetMapping[key], propertyExpenses);
97
+ break;
88
98
  case 'propertyStatus':
89
99
  (0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
90
100
  break;
@@ -185,6 +195,7 @@ function getAssetMapping(asset) {
185
195
  estimatedValue: estimatedValue,
186
196
  percentOwned: percentOwned,
187
197
  primaryPurpose: "".concat(application_paths_1.paths.RealEstateAsset, ".@PrimaryPurpose"),
198
+ propertyExpenses: application_paths_1.paths.LivingExpenses,
188
199
  propertyStatus: "".concat(application_paths_1.paths.RealEstateAsset, ".@Status"),
189
200
  propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
190
201
  toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
@@ -201,3 +212,39 @@ function getAssetMapping(asset) {
201
212
  return baseMapping;
202
213
  }
203
214
  exports.getAssetMapping = getAssetMapping;
215
+ /**
216
+ * Creates living expense items from a propertyExpense object.
217
+ *
218
+ * @param percentOwned: owners of the property
219
+ * @param assetId: Asset id
220
+ * @param propertyExpenses: propertyExpenses items
221
+ */
222
+ function generatePropertyExpenses(percentOwned, assetId, propertyExpenses) {
223
+ var livingExpenses = [];
224
+ var filteredPropertyExpenses = propertyExpenses.filter(function (expense) { return expense.amount !== undefined; });
225
+ percentOwned.owners.forEach(function (owner) {
226
+ var expenses = filteredPropertyExpenses.map(function (expense) {
227
+ if (expense.frequency === public_expense_1.Frequency.Quarterly) {
228
+ expense.frequency = public_expense_1.Frequency.Yearly;
229
+ expense.amount *= 4;
230
+ }
231
+ return {
232
+ '@Amount': (0, round_decimal_1.roundDecimal)(expense.amount * owner.percent),
233
+ '@Category': enum_mappings_1.livingExpenseMapping[expense.type],
234
+ '@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency],
235
+ '@UniqueID': "".concat((0, uuid_1.v4)(), "-").concat(assetId),
236
+ PercentResponsible: {
237
+ Owner: [
238
+ {
239
+ '@Percent': 100,
240
+ '@x_Party': owner.applicantId
241
+ },
242
+ ]
243
+ }
244
+ };
245
+ });
246
+ livingExpenses = livingExpenses.concat(expenses);
247
+ });
248
+ return livingExpenses;
249
+ }
250
+ exports.generatePropertyExpenses = generatePropertyExpenses;
@@ -50,7 +50,7 @@ function transformLiability(_a) {
50
50
  // Currently repayments is not captured for store cards and credit cards, default the monthly repayment amount to
51
51
  // the credit limit with interest rate of 3%.
52
52
  if ([public_liability_1.LiabilityType.CreditCard, public_liability_1.LiabilityType.StoreCard].includes(liability.type) && liability.creditLimit) {
53
- (0, lodash_1.set)(partialApplication, liabilityMapping.repaymentAmount, liability.creditLimit * 0.03);
53
+ (0, lodash_1.set)(partialApplication, liabilityMapping.repaymentAmount, (0, round_decimal_1.roundDecimal)(liability.creditLimit * 0.03));
54
54
  (0, lodash_1.set)(partialApplication, liabilityMapping.repaymentFrequency, lixi_internal_request_1.List.Monthly);
55
55
  }
56
56
  // Default clearingFromThisLoan to No if the value is not present in the event.
@@ -6,7 +6,7 @@ export interface PublicAsset {
6
6
  /**
7
7
  * schema version
8
8
  */
9
- type: Type;
9
+ type: PublicAssetType;
10
10
  version: string;
11
11
  }
12
12
  /**
@@ -38,6 +38,7 @@ export interface Asset {
38
38
  model?: string;
39
39
  percentOwned?: PercentOwned;
40
40
  primaryPurpose?: PrimaryPurpose;
41
+ propertyExpenses?: PropertyExpense[];
41
42
  propertyStatus?: PropertyStatus;
42
43
  propertyType?: PropertyType;
43
44
  relationId?: string;
@@ -397,6 +398,25 @@ export declare enum PrimaryPurpose {
397
398
  Investment = "INVESTMENT",
398
399
  OwnerOccupied = "OWNER_OCCUPIED"
399
400
  }
401
+ export interface PropertyExpense {
402
+ amount?: number;
403
+ comments?: string;
404
+ frequency?: Frequency;
405
+ type: PropertyExpenseType;
406
+ }
407
+ export declare enum Frequency {
408
+ Fortnightly = "FORTNIGHTLY",
409
+ Monthly = "MONTHLY",
410
+ Quarterly = "QUARTERLY",
411
+ Weekly = "WEEKLY",
412
+ Yearly = "YEARLY"
413
+ }
414
+ export declare enum PropertyExpenseType {
415
+ BodyCorporateFeesStrataFeesAndLandTax = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
416
+ InvestmentPropertyRunningCosts = "INVESTMENT_PROPERTY_RUNNING_COSTS",
417
+ PrimaryResidenceRunningCosts = "PRIMARY_RESIDENCE_RUNNING_COSTS",
418
+ SecondaryResidenceRunningCosts = "SECONDARY_RESIDENCE_RUNNING_COSTS"
419
+ }
400
420
  export declare enum PropertyStatus {
401
421
  Established = "ESTABLISHED",
402
422
  NewBuilding = "NEW_BUILDING",
@@ -462,7 +482,7 @@ export declare enum ActionedByRole {
462
482
  /**
463
483
  * schema version
464
484
  */
465
- export declare enum Type {
485
+ export declare enum PublicAssetType {
466
486
  AssetCreated = "AssetCreated",
467
487
  AssetUpdated = "AssetUpdated"
468
488
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.Type = exports.ActionedByRole = exports.ZoneType = exports.AssetType = exports.PropertyType = exports.PropertyStatus = 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.Countries = void 0;
4
4
  var Countries;
5
5
  (function (Countries) {
6
6
  Countries["Afghanistan"] = "Afghanistan";
@@ -258,6 +258,21 @@ var PrimaryPurpose;
258
258
  PrimaryPurpose["Investment"] = "INVESTMENT";
259
259
  PrimaryPurpose["OwnerOccupied"] = "OWNER_OCCUPIED";
260
260
  })(PrimaryPurpose = exports.PrimaryPurpose || (exports.PrimaryPurpose = {}));
261
+ var Frequency;
262
+ (function (Frequency) {
263
+ Frequency["Fortnightly"] = "FORTNIGHTLY";
264
+ Frequency["Monthly"] = "MONTHLY";
265
+ Frequency["Quarterly"] = "QUARTERLY";
266
+ Frequency["Weekly"] = "WEEKLY";
267
+ Frequency["Yearly"] = "YEARLY";
268
+ })(Frequency = exports.Frequency || (exports.Frequency = {}));
269
+ var PropertyExpenseType;
270
+ (function (PropertyExpenseType) {
271
+ PropertyExpenseType["BodyCorporateFeesStrataFeesAndLandTax"] = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX";
272
+ PropertyExpenseType["InvestmentPropertyRunningCosts"] = "INVESTMENT_PROPERTY_RUNNING_COSTS";
273
+ PropertyExpenseType["PrimaryResidenceRunningCosts"] = "PRIMARY_RESIDENCE_RUNNING_COSTS";
274
+ PropertyExpenseType["SecondaryResidenceRunningCosts"] = "SECONDARY_RESIDENCE_RUNNING_COSTS";
275
+ })(PropertyExpenseType = exports.PropertyExpenseType || (exports.PropertyExpenseType = {}));
261
276
  var PropertyStatus;
262
277
  (function (PropertyStatus) {
263
278
  PropertyStatus["Established"] = "ESTABLISHED";
@@ -315,8 +330,8 @@ var ActionedByRole;
315
330
  /**
316
331
  * schema version
317
332
  */
318
- var Type;
319
- (function (Type) {
320
- Type["AssetCreated"] = "AssetCreated";
321
- Type["AssetUpdated"] = "AssetUpdated";
322
- })(Type = exports.Type || (exports.Type = {}));
333
+ var PublicAssetType;
334
+ (function (PublicAssetType) {
335
+ PublicAssetType["AssetCreated"] = "AssetCreated";
336
+ PublicAssetType["AssetUpdated"] = "AssetUpdated";
337
+ })(PublicAssetType = exports.PublicAssetType || (exports.PublicAssetType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.3.2",
3
+ "version": "1.3.6",
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.6",
24
+ "@lendi/integrations-credit-protocol": "1.15.8",
25
25
  "@lendi/integrations-protocol": "2.5.4",
26
26
  "clean-deep": "^3.4.0",
27
27
  "date-fns": "2.19.0",
@@ -30,11 +30,8 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@lendi/prettier-config": "^1.0.0",
33
- "@lendi/tslint-config": "^1.1.0",
34
33
  "@lendi/typescript-config": "^2.0.0",
35
- "@types/convict": "^4.2.1",
36
- "@types/delay": "^3.1.0",
37
- "@types/jest": "^24.0.21",
34
+ "@types/jest": "^26.0.14",
38
35
  "@types/lodash": "^4.14.141",
39
36
  "@types/node": "^12.12.5",
40
37
  "@types/pino": "^6.3.3",
@@ -50,7 +47,6 @@
50
47
  "jest": "^26.6.3",
51
48
  "jest-buildkite-reporter": "^0.2.8",
52
49
  "jest-sonar-reporter": "^2.0.0",
53
- "lint-staged": "^9.4.1",
54
50
  "path": "^0.12.7",
55
51
  "prettier": "^2.2.1",
56
52
  "prettier-check": "^2.0.0",
@@ -59,8 +55,6 @@
59
55
  "sinon": "^7.4.2",
60
56
  "ts-jest": "^26.5.0",
61
57
  "ts-node": "^8.4.1",
62
- "tslint": "^5.20.0",
63
- "tslint-config-prettier": "^1.18.0",
64
58
  "typedoc": "^0.20.36",
65
59
  "typescript": "^4.1.3"
66
60
  },