@lendi/act-credit-decisions-transform 2.0.16 → 2.0.18

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/logger.d.ts CHANGED
@@ -1,4 +1 @@
1
- export declare const logger: import("pino").Logger<{
2
- name: string;
3
- messageKey: string;
4
- }>;
1
+ export declare const logger: import("pino").Logger<never>;
@@ -529,11 +529,14 @@
529
529
  "properties": {
530
530
  "type": {
531
531
  "type": "string",
532
+ "description": "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX is deprecated.",
532
533
  "enum": [
533
534
  "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
534
535
  "PRIMARY_RESIDENCE_RUNNING_COSTS",
535
536
  "INVESTMENT_PROPERTY_RUNNING_COSTS",
536
- "SECONDARY_RESIDENCE_RUNNING_COSTS"
537
+ "SECONDARY_RESIDENCE_RUNNING_COSTS",
538
+ "STRATA_BODY_CORPORATE_FEES",
539
+ "LAND_TAX"
537
540
  ]
538
541
  },
539
542
  "amount": {
@@ -67,6 +67,7 @@
67
67
  "properties": {
68
68
  "type": {
69
69
  "type": "string",
70
+ "description": "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX has been deprecated",
70
71
  "enum": [
71
72
  "RENT_UTILITIES",
72
73
  "LIVING_EXPENSES_ESTIMATE",
@@ -81,7 +82,6 @@
81
82
  "TELEPHONE_INTERNET_PAY_TV_AND_MEDIA_STREAMING_SUBSCRIPTIONS",
82
83
  "PET_CARE",
83
84
  "TRANSPORT",
84
- "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
85
85
  "PRIMARY_RESIDENCE_RUNNING_COSTS",
86
86
  "INVESTMENT_PROPERTY_RUNNING_COSTS",
87
87
  "SECONDARY_RESIDENCE_RUNNING_COSTS",
@@ -91,7 +91,10 @@
91
91
  "MEDICAL_AND_HEALTH",
92
92
  "RENT",
93
93
  "BOARD",
94
- "OTHER"
94
+ "OTHER",
95
+ "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
96
+ "STRATA_BODY_CORPORATE_FEES",
97
+ "LAND_TAX"
95
98
  ]
96
99
  },
97
100
  "amount": {
@@ -263,7 +263,7 @@ exports.getAssetMapping = getAssetMapping;
263
263
  */
264
264
  function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
265
265
  let livingExpenses = [];
266
- const filteredPropertyExpenses = propertyExpenses.filter((expense) => expense.amount !== undefined);
266
+ const filteredPropertyExpenses = preSumUpStrataExpense(propertyExpenses.filter((expense) => expense.amount !== undefined));
267
267
  percentOwned.owners.forEach((owner) => {
268
268
  const expenses = filteredPropertyExpenses.map((expense) => {
269
269
  normalizeAmounts(expense);
@@ -287,6 +287,32 @@ function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
287
287
  return livingExpenses;
288
288
  }
289
289
  exports.generateLivingExpenses = generateLivingExpenses;
290
+ /**
291
+ * Pre-sum the body strata and land tax amount into one record.
292
+ * When the BodyCorporateFeesStrataFeesAndLandTax is fully deprecated, we can remove this function to let the StrataBodyCorporateFees and LandTax to flow out as normal
293
+ *
294
+ * @param expenses
295
+ */
296
+ function preSumUpStrataExpense(expenses) {
297
+ const summingTypes = [
298
+ public_asset_1.PropertyExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
299
+ public_asset_1.PropertyExpenseType.StrataBodyCorporateFees,
300
+ public_asset_1.PropertyExpenseType.LandTax,
301
+ ];
302
+ const effectedExpenses = expenses.filter((expense) => summingTypes.includes(expense.type));
303
+ const unEffectedExpenses = expenses.filter((expense) => !summingTypes.includes(expense.type));
304
+ if (!effectedExpenses.length)
305
+ return unEffectedExpenses;
306
+ const sumEffectedExpenses = (0, lodash_1.sumBy)(effectedExpenses, 'amount');
307
+ return [
308
+ ...(sumEffectedExpenses > 0
309
+ ? [
310
+ Object.assign(Object.assign({}, effectedExpenses[0]), { type: public_asset_1.PropertyExpenseType.BodyCorporateFeesStrataFeesAndLandTax, amount: sumEffectedExpenses }),
311
+ ]
312
+ : []),
313
+ ...unEffectedExpenses,
314
+ ];
315
+ }
290
316
  /**
291
317
  * Creates PropertyExpense array on RealEstateAsset from the same array on the event.
292
318
  *
@@ -6,6 +6,7 @@ const application_paths_1 = require("@lendi/act-eac-integrations-protocol/lib/ut
6
6
  const lodash_1 = require("lodash");
7
7
  const enum_mappings_1 = require("../types/enum-mappings/");
8
8
  const public_expense_1 = require("../types/events/public-expense");
9
+ const uniqueid_tools_1 = require("../utils/uniqueid-tools");
9
10
  exports.otherCommitmentExpenseTypes = [
10
11
  public_expense_1.ExpenseType.Board,
11
12
  public_expense_1.ExpenseType.ChildAndSpousalMaintenance,
@@ -14,6 +15,8 @@ exports.otherCommitmentExpenseTypes = [
14
15
  const propertyExpenseCategories = [
15
16
  public_expense_1.ExpenseType.InvestmentPropertyRunningCosts,
16
17
  public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
18
+ public_expense_1.ExpenseType.StrataBodyCorporateFees,
19
+ public_expense_1.ExpenseType.LandTax,
17
20
  public_expense_1.ExpenseType.SecondaryResidenceRunningCosts,
18
21
  public_expense_1.ExpenseType.PrimaryResidenceRunningCosts,
19
22
  ];
@@ -29,7 +32,7 @@ function transformExpenses(expense) {
29
32
  return partialApplication;
30
33
  }
31
34
  const normalisedExpenses = expenses.map(normaliseExpenseAmount);
32
- const filteredLivingExpensesWithAmount = normalisedExpenses.filter((expense) => expense.amount || !propertyExpenseCategories.includes(expense.type));
35
+ const filteredLivingExpensesWithAmount = preSumUpStrataExpense(normalisedExpenses.filter((expense) => expense.amount || !propertyExpenseCategories.includes(expense.type)));
33
36
  const livingExpenseEstimate = filteredLivingExpensesWithAmount.find(isLivingExpenseEstimate);
34
37
  const otherCommitments = filteredLivingExpensesWithAmount.filter(isOtherCommitment);
35
38
  const expenseBreakdown = filteredLivingExpensesWithAmount.filter((item) => !(isOtherCommitment(item) || isLivingExpenseEstimate(item)));
@@ -73,7 +76,8 @@ function transformExpense(expense, applicantId, index, id) {
73
76
  '@Amount': expense.amount,
74
77
  '@Category': enum_mappings_1.livingExpenseMapping[expense.type],
75
78
  '@Description': expense.type,
76
- '@UniqueID': isOtherCommitment(expense) ? `${id}-commitment-${index}` : `${id}-living-expense-${index}`,
79
+ // '@UniqueID': isOtherCommitment(expense) ? `${id}-commitment-${index}` : `${id}-living-expense-${index}`,
80
+ '@UniqueID': (0, uniqueid_tools_1.truncateUniqueId)(id + '-' + applicantId + '-' + expense.type),
77
81
  '@Frequency': enum_mappings_1.frequencyMapping[expense.frequency],
78
82
  PercentResponsible: {
79
83
  Owner: [
@@ -103,6 +107,32 @@ function normaliseExpenseAmount(expense) {
103
107
  return expense;
104
108
  }
105
109
  exports.normaliseExpenseAmount = normaliseExpenseAmount;
110
+ /**
111
+ * Pre-sum the body strata and land tax amount into one record.
112
+ * When the BodyCorporateFeesStrataFeesAndLandTax is fully deprecated, we can remove this function to let the StrataBodyCorporateFees and LandTax to flow out as normal
113
+ *
114
+ * @param expenses
115
+ */
116
+ function preSumUpStrataExpense(expenses) {
117
+ const summingTypes = [
118
+ public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
119
+ public_expense_1.ExpenseType.StrataBodyCorporateFees,
120
+ public_expense_1.ExpenseType.LandTax,
121
+ ];
122
+ const effectedExpenses = expenses.filter((expense) => summingTypes.includes(expense.type));
123
+ const unEffectedExpenses = expenses.filter((expense) => !summingTypes.includes(expense.type));
124
+ if (!effectedExpenses.length)
125
+ return unEffectedExpenses;
126
+ const sumEffectedExpenses = (0, lodash_1.sumBy)(effectedExpenses, 'amount');
127
+ return [
128
+ ...(sumEffectedExpenses > 0
129
+ ? [
130
+ Object.assign(Object.assign({}, effectedExpenses[0]), { type: public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax, amount: (0, lodash_1.sumBy)(effectedExpenses, 'amount') }),
131
+ ]
132
+ : []),
133
+ ...unEffectedExpenses,
134
+ ];
135
+ }
106
136
  /**
107
137
  * @description Verify if expense is an OtherCommitment.
108
138
  * @param {Expense} expense Any Expense item.
@@ -5,7 +5,6 @@ const lixi_internal_request_1 = require("@lendi/act-eac-integrations-protocol/li
5
5
  const public_expense_1 = require("../events/public-expense");
6
6
  exports.livingExpenseMapping = {
7
7
  [public_expense_1.ExpenseType.Board]: lixi_internal_request_1.OtherCommitmentCategoryList.Board,
8
- [public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax]: lixi_internal_request_1.LivingExpenseCategoryList.BodyCorporateFeesStrataFeesAndLandTaxOnOwnerOccupiedPrincipalPlaceOfResidence,
9
8
  [public_expense_1.ExpenseType.ChildAndSpousalMaintenance]: lixi_internal_request_1.OtherCommitmentCategoryList.ChildAndSpousalMaintenance,
10
9
  [public_expense_1.ExpenseType.Childcare]: lixi_internal_request_1.LivingExpenseCategoryList.Childcare,
11
10
  [public_expense_1.ExpenseType.ClothingAndPersonalCare]: lixi_internal_request_1.LivingExpenseCategoryList.ClothingAndPersonalCare,
@@ -28,4 +27,7 @@ exports.livingExpenseMapping = {
28
27
  [public_expense_1.ExpenseType.SecondaryResidenceRunningCosts]: lixi_internal_request_1.LivingExpenseCategoryList.SecondaryResidenceRunningCosts,
29
28
  [public_expense_1.ExpenseType.TelephoneInternetPayTvAndMediaStreamingSubscriptions]: lixi_internal_request_1.LivingExpenseCategoryList.TelephoneInternetPayTVAndMediaStreamingSubscriptions,
30
29
  [public_expense_1.ExpenseType.Transport]: lixi_internal_request_1.LivingExpenseCategoryList.Transport,
30
+ [public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax]: lixi_internal_request_1.LivingExpenseCategoryList.BodyCorporateFeesStrataFeesAndLandTaxOnOwnerOccupiedPrincipalPlaceOfResidence,
31
+ [public_expense_1.ExpenseType.StrataBodyCorporateFees]: lixi_internal_request_1.LivingExpenseCategoryList.BodyCorporateFeesStrataFeesAndLandTaxOnOwnerOccupiedPrincipalPlaceOfResidence,
32
+ [public_expense_1.ExpenseType.LandTax]: lixi_internal_request_1.LivingExpenseCategoryList.BodyCorporateFeesStrataFeesAndLandTaxOnOwnerOccupiedPrincipalPlaceOfResidence,
31
33
  };
@@ -8,4 +8,6 @@ exports.propertyExpenseCategoryMapping = {
8
8
  [public_asset_1.PropertyExpenseType.InvestmentPropertyRunningCosts]: lixi_internal_request_1.PropertyExpenseCategoryList.RunningCosts,
9
9
  [public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts]: lixi_internal_request_1.PropertyExpenseCategoryList.RunningCosts,
10
10
  [public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts]: lixi_internal_request_1.PropertyExpenseCategoryList.RunningCosts,
11
+ [public_asset_1.PropertyExpenseType.StrataBodyCorporateFees]: lixi_internal_request_1.PropertyExpenseCategoryList.BodyCorporateFeesStrataFeesAndLandTax,
12
+ [public_asset_1.PropertyExpenseType.LandTax]: lixi_internal_request_1.PropertyExpenseCategoryList.BodyCorporateFeesStrataFeesAndLandTax,
11
13
  };
@@ -426,7 +426,12 @@ export declare enum Frequency {
426
426
  Yearly = "YEARLY"
427
427
  }
428
428
  export declare enum PropertyExpenseType {
429
+ /**
430
+ * @deprecated The field has been deprecated and replaced with StrataBodyCorporateFees and LandTax
431
+ */
429
432
  BodyCorporateFeesStrataFeesAndLandTax = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
433
+ StrataBodyCorporateFees = "STRATA_BODY_CORPORATE_FEES",
434
+ LandTax = "LAND_TAX",
430
435
  InvestmentPropertyRunningCosts = "INVESTMENT_PROPERTY_RUNNING_COSTS",
431
436
  PrimaryResidenceRunningCosts = "PRIMARY_RESIDENCE_RUNNING_COSTS",
432
437
  SecondaryResidenceRunningCosts = "SECONDARY_RESIDENCE_RUNNING_COSTS"
@@ -279,7 +279,12 @@ var Frequency;
279
279
  })(Frequency || (exports.Frequency = Frequency = {}));
280
280
  var PropertyExpenseType;
281
281
  (function (PropertyExpenseType) {
282
+ /**
283
+ * @deprecated The field has been deprecated and replaced with StrataBodyCorporateFees and LandTax
284
+ */
282
285
  PropertyExpenseType["BodyCorporateFeesStrataFeesAndLandTax"] = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX";
286
+ PropertyExpenseType["StrataBodyCorporateFees"] = "STRATA_BODY_CORPORATE_FEES";
287
+ PropertyExpenseType["LandTax"] = "LAND_TAX";
283
288
  PropertyExpenseType["InvestmentPropertyRunningCosts"] = "INVESTMENT_PROPERTY_RUNNING_COSTS";
284
289
  PropertyExpenseType["PrimaryResidenceRunningCosts"] = "PRIMARY_RESIDENCE_RUNNING_COSTS";
285
290
  PropertyExpenseType["SecondaryResidenceRunningCosts"] = "SECONDARY_RESIDENCE_RUNNING_COSTS";
@@ -34,7 +34,6 @@ export declare enum Frequency {
34
34
  }
35
35
  export declare enum ExpenseType {
36
36
  Board = "BOARD",
37
- BodyCorporateFeesStrataFeesAndLandTax = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
38
37
  ChildAndSpousalMaintenance = "CHILD_AND_SPOUSAL_MAINTENANCE",
39
38
  Childcare = "CHILDCARE",
40
39
  ClothingAndPersonalCare = "CLOTHING_AND_PERSONAL_CARE",
@@ -56,7 +55,13 @@ export declare enum ExpenseType {
56
55
  RentUtilities = "RENT_UTILITIES",
57
56
  SecondaryResidenceRunningCosts = "SECONDARY_RESIDENCE_RUNNING_COSTS",
58
57
  TelephoneInternetPayTvAndMediaStreamingSubscriptions = "TELEPHONE_INTERNET_PAY_TV_AND_MEDIA_STREAMING_SUBSCRIPTIONS",
59
- Transport = "TRANSPORT"
58
+ Transport = "TRANSPORT",
59
+ /**
60
+ * @deprecated The field has been deprecated and replaced with StrataBodyCorporateFees and LandTax
61
+ */
62
+ BodyCorporateFeesStrataFeesAndLandTax = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX",
63
+ StrataBodyCorporateFees = "STRATA_BODY_CORPORATE_FEES",
64
+ LandTax = "LAND_TAX"
60
65
  }
61
66
  /**
62
67
  * The metadata of the alieo
@@ -12,7 +12,6 @@ var Frequency;
12
12
  var ExpenseType;
13
13
  (function (ExpenseType) {
14
14
  ExpenseType["Board"] = "BOARD";
15
- ExpenseType["BodyCorporateFeesStrataFeesAndLandTax"] = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX";
16
15
  ExpenseType["ChildAndSpousalMaintenance"] = "CHILD_AND_SPOUSAL_MAINTENANCE";
17
16
  ExpenseType["Childcare"] = "CHILDCARE";
18
17
  ExpenseType["ClothingAndPersonalCare"] = "CLOTHING_AND_PERSONAL_CARE";
@@ -35,6 +34,12 @@ var ExpenseType;
35
34
  ExpenseType["SecondaryResidenceRunningCosts"] = "SECONDARY_RESIDENCE_RUNNING_COSTS";
36
35
  ExpenseType["TelephoneInternetPayTvAndMediaStreamingSubscriptions"] = "TELEPHONE_INTERNET_PAY_TV_AND_MEDIA_STREAMING_SUBSCRIPTIONS";
37
36
  ExpenseType["Transport"] = "TRANSPORT";
37
+ /**
38
+ * @deprecated The field has been deprecated and replaced with StrataBodyCorporateFees and LandTax
39
+ */
40
+ ExpenseType["BodyCorporateFeesStrataFeesAndLandTax"] = "BODY_CORPORATE_FEES_STRATA_FEES_AND_LAND_TAX";
41
+ ExpenseType["StrataBodyCorporateFees"] = "STRATA_BODY_CORPORATE_FEES";
42
+ ExpenseType["LandTax"] = "LAND_TAX";
38
43
  })(ExpenseType || (exports.ExpenseType = ExpenseType = {}));
39
44
  /**
40
45
  * role of the user that made the action
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Guarantee that the uniqueId is no more than maxLength length
3
+ *
4
+ * @param id
5
+ * @param maxLength Maximum length limit. For ANZ it should be 100.
6
+ * @returns
7
+ */
8
+ export declare const truncateUniqueId: (id: string, maxLength?: number) => string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truncateUniqueId = void 0;
4
+ /**
5
+ * Guarantee that the uniqueId is no more than maxLength length
6
+ *
7
+ * @param id
8
+ * @param maxLength Maximum length limit. For ANZ it should be 100.
9
+ * @returns
10
+ */
11
+ const truncateUniqueId = (id, maxLength = 100) => {
12
+ return id.length > maxLength ? id.substring(0, maxLength - 1) : id;
13
+ };
14
+ exports.truncateUniqueId = truncateUniqueId;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@lendi/act-credit-decisions-transform",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
+ "private": false,
4
5
  "description": "Library for kafka event data transforming",
5
6
  "author": "Integrations <integrations@lendi.com.au>",
6
7
  "homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
@@ -22,13 +23,14 @@
22
23
  },
23
24
  "dependencies": {
24
25
  "@lendi/integrations-credit-protocol": "1.18.8",
25
- "@lendi/act-eac-integrations-protocol": "3.1.6",
26
+ "@lendi/act-eac-integrations-protocol": "3.1.8",
26
27
  "clean-deep": "^3.4.0",
27
28
  "date-fns": "2.19.0",
28
29
  "lodash": "^4.17.15"
29
30
  },
30
31
  "peerDependencies": {
31
- "pino": "^8.1.0"
32
+ "pino": "^8.1.0",
33
+ "uuid": "^8.3.2"
32
34
  },
33
35
  "devDependencies": {
34
36
  "@lendi/prettier-config": "^1.0.0",