@lendi/integrations-transform 1.5.10 → 1.6.2

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/index.js +26 -10
  3. package/lib/logger.js +5 -2
  4. package/lib/schemas/public-application-event.json +7 -0
  5. package/lib/transform-events/generate-asset-liability-link.js +12 -8
  6. package/lib/transform-events/generate-credit-report-rebuilt.js +12 -8
  7. package/lib/transform-events/generate-employment.js +41 -37
  8. package/lib/transform-events/generate-required-document.d.ts +1 -2
  9. package/lib/transform-events/generate-required-document.js +41 -32
  10. package/lib/transform-events/transform-applicant.js +60 -53
  11. package/lib/transform-events/transform-application-workflow.js +9 -5
  12. package/lib/transform-events/transform-application.d.ts +6 -8
  13. package/lib/transform-events/transform-application.js +30 -25
  14. package/lib/transform-events/transform-asset-address.js +25 -19
  15. package/lib/transform-events/transform-asset.js +128 -118
  16. package/lib/transform-events/transform-expenses.js +39 -31
  17. package/lib/transform-events/transform-funding-position.js +32 -27
  18. package/lib/transform-events/transform-income.js +73 -65
  19. package/lib/transform-events/transform-liability.js +59 -55
  20. package/lib/transform-events/transform-percent-owned.js +7 -3
  21. package/lib/types/enum-mappings/alieo-frequency.js +22 -19
  22. package/lib/types/enum-mappings/asset-type.js +16 -13
  23. package/lib/types/enum-mappings/builder-type.js +8 -5
  24. package/lib/types/enum-mappings/construction-type.js +9 -6
  25. package/lib/types/enum-mappings/country-code.js +245 -242
  26. package/lib/types/enum-mappings/employment-basis.js +11 -8
  27. package/lib/types/enum-mappings/expense-frequency.js +10 -7
  28. package/lib/types/enum-mappings/funding-position.js +32 -29
  29. package/lib/types/enum-mappings/government-benefits.js +9 -6
  30. package/lib/types/enum-mappings/housing-status.js +14 -11
  31. package/lib/types/enum-mappings/income-type.js +15 -12
  32. package/lib/types/enum-mappings/index.js +43 -27
  33. package/lib/types/enum-mappings/liability-payment-type.js +8 -5
  34. package/lib/types/enum-mappings/liability-type.js +20 -17
  35. package/lib/types/enum-mappings/living-expense.js +29 -26
  36. package/lib/types/enum-mappings/marital-status.js +11 -8
  37. package/lib/types/enum-mappings/postcode.js +13 -10
  38. package/lib/types/enum-mappings/preferred-repayment.js +9 -6
  39. package/lib/types/enum-mappings/proof-of-identity.js +9 -6
  40. package/lib/types/enum-mappings/property-expense-category.js +10 -7
  41. package/lib/types/enum-mappings/public-financial-asset.js +11 -8
  42. package/lib/types/enum-mappings/public-primary-purpose.js +8 -5
  43. package/lib/types/enum-mappings/public-property-status.js +10 -7
  44. package/lib/types/enum-mappings/public-property-type.js +22 -19
  45. package/lib/types/enum-mappings/residency-status.js +10 -7
  46. package/lib/types/enum-mappings/title-gender.js +12 -9
  47. package/lib/types/enum-mappings/title.js +12 -9
  48. package/lib/types/enum-mappings/to-be-purchased.js +7 -4
  49. package/lib/types/enum-mappings/to-be-used-as-security.js +7 -4
  50. package/lib/types/enum-mappings/transaction-type.js +8 -5
  51. package/lib/types/enum-mappings/verification.js +12 -9
  52. package/lib/types/events/applicant-delete.js +7 -4
  53. package/lib/types/events/application-workflow.js +13 -10
  54. package/lib/types/events/asset-delete.js +7 -4
  55. package/lib/types/events/asset-liability-relation-delete.js +7 -4
  56. package/lib/types/events/credit-report-retrieved.js +7 -4
  57. package/lib/types/events/employment-delete.js +5 -2
  58. package/lib/types/events/expense-delete.js +5 -2
  59. package/lib/types/events/funding-position.js +9 -6
  60. package/lib/types/events/income-delete.js +7 -4
  61. package/lib/types/events/liability-delete.js +5 -2
  62. package/lib/types/events/opportunity.js +9 -6
  63. package/lib/types/events/public-applicant.js +31 -28
  64. package/lib/types/events/public-application.d.ts +1 -0
  65. package/lib/types/events/public-application.js +29 -26
  66. package/lib/types/events/public-asset-liability-relation.js +7 -4
  67. package/lib/types/events/public-asset.js +29 -26
  68. package/lib/types/events/public-employment.js +21 -18
  69. package/lib/types/events/public-expense.js +11 -8
  70. package/lib/types/events/public-funding-position.js +5 -2
  71. package/lib/types/events/public-income.js +15 -12
  72. package/lib/types/events/public-liability.js +19 -16
  73. package/lib/types/events/public-required-document.js +17 -14
  74. package/lib/types/partial-application.js +2 -1
  75. package/lib/types/recursive-partial.js +2 -1
  76. package/lib/update-application/merge-application.js +6 -2
  77. package/lib/update-application/update-primary-applicant.js +17 -12
  78. package/lib/utils/address-tools.js +43 -33
  79. package/lib/utils/clean-up.js +7 -3
  80. package/lib/utils/formatYesNo.js +6 -2
  81. package/lib/utils/generate-address.js +26 -21
  82. package/lib/utils/get-financial-institution.js +8 -4
  83. package/lib/utils/is-asset-type.js +20 -13
  84. package/lib/utils/is-income-type.js +58 -45
  85. package/lib/utils/iso-date.js +6 -2
  86. package/lib/utils/normalise-date.js +5 -1
  87. package/lib/utils/round-decimal.js +5 -1
  88. package/package.json +3 -3
@@ -1,78 +1,87 @@
1
- import { get } from 'lodash';
2
- import { IncomeType } from '../types/events/public-income';
3
- export const descriptionOtherIncomeTypes = [
4
- IncomeType.InvestmentIncome,
5
- IncomeType.PaygNonVoluntaryDeductionsPreTax,
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortBusinessIncome = exports.getApplicantId = exports.getApplicantIdFromEmploymentId = exports.hasMatchingEmploymentId = exports.isFullDocOrLowDocIncome = exports.isOtherIncomeWithDesc = exports.isOtherIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.otherIncomeList = exports.PAYGList = exports.descriptionOtherIncomeTypes = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const public_income_1 = require("../types/events/public-income");
6
+ exports.descriptionOtherIncomeTypes = [
7
+ public_income_1.IncomeType.InvestmentIncome,
8
+ public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
6
9
  ];
7
- export const PAYGList = [
8
- IncomeType.PaygAllowancesNotTaxed,
9
- IncomeType.PaygAllowancesTaxed,
10
- IncomeType.PaygBaseSalary,
11
- IncomeType.PaygBonusIncome,
12
- IncomeType.PaygCarAllowance,
13
- IncomeType.PaygCommissionIncome,
14
- IncomeType.PaygCompanyCar,
15
- IncomeType.PaygOvertimeIncome,
10
+ exports.PAYGList = [
11
+ public_income_1.IncomeType.PaygAllowancesNotTaxed,
12
+ public_income_1.IncomeType.PaygAllowancesTaxed,
13
+ public_income_1.IncomeType.PaygBaseSalary,
14
+ public_income_1.IncomeType.PaygBonusIncome,
15
+ public_income_1.IncomeType.PaygCarAllowance,
16
+ public_income_1.IncomeType.PaygCommissionIncome,
17
+ public_income_1.IncomeType.PaygCompanyCar,
18
+ public_income_1.IncomeType.PaygOvertimeIncome,
16
19
  ];
17
- export const otherIncomeList = [
18
- IncomeType.ChildMaintenance,
19
- IncomeType.ForeignIncome,
20
- IncomeType.GovtBenefit,
21
- IncomeType.InvestmentIncome,
22
- IncomeType.OtherIncome,
23
- IncomeType.PaygNonVoluntaryDeductionsPreTax,
24
- IncomeType.PaygSalarySacrifice,
25
- IncomeType.SuperAnnuityPension,
26
- IncomeType.WorkersCompensation,
20
+ exports.otherIncomeList = [
21
+ public_income_1.IncomeType.ChildMaintenance,
22
+ public_income_1.IncomeType.ForeignIncome,
23
+ public_income_1.IncomeType.GovtBenefit,
24
+ public_income_1.IncomeType.InvestmentIncome,
25
+ public_income_1.IncomeType.OtherIncome,
26
+ public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
27
+ public_income_1.IncomeType.PaygSalarySacrifice,
28
+ public_income_1.IncomeType.SuperAnnuityPension,
29
+ public_income_1.IncomeType.WorkersCompensation,
27
30
  ];
28
31
  /**
29
32
  * @description Is income type one of the PAYG income.
30
33
  * @param {string} incomeType Income type.
31
34
  * @returns {boolean} Returns true if Income type is a PAYG Income.
32
35
  */
33
- export function isPaygIncome(incomeType) {
34
- return PAYGList.includes(incomeType);
36
+ function isPaygIncome(incomeType) {
37
+ return exports.PAYGList.includes(incomeType);
35
38
  }
39
+ exports.isPaygIncome = isPaygIncome;
36
40
  /**
37
41
  * @description Is income type SelfEmployedBusinessIncome.
38
42
  * @param {string} incomeType Income type.
39
43
  * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
40
44
  */
41
- export function isSelfEmployedIncome(incomeType) {
42
- return incomeType === IncomeType.SelfEmployedBusinessIncome;
45
+ function isSelfEmployedIncome(incomeType) {
46
+ return incomeType === public_income_1.IncomeType.SelfEmployedBusinessIncome;
43
47
  }
48
+ exports.isSelfEmployedIncome = isSelfEmployedIncome;
44
49
  /**
45
50
  * @description Is income type Rental Income.
46
51
  * @param {IncomeType} incomeType Income type.
47
52
  * @returns {boolean} true if Income type is Rental Income.
48
53
  */
49
- export function isRentalIncome(incomeType) {
50
- return incomeType === IncomeType.RentalIncome;
54
+ function isRentalIncome(incomeType) {
55
+ return incomeType === public_income_1.IncomeType.RentalIncome;
51
56
  }
57
+ exports.isRentalIncome = isRentalIncome;
52
58
  /**
53
59
  * @description Is income type grouped as OtherIncome.
54
60
  * @param {IncomeType} incomeType Income type.
55
61
  * @returns {boolean} true if income is of type other income.
56
62
  */
57
- export function isOtherIncome(incomeType) {
58
- return otherIncomeList.includes(incomeType);
63
+ function isOtherIncome(incomeType) {
64
+ return exports.otherIncomeList.includes(incomeType);
59
65
  }
66
+ exports.isOtherIncome = isOtherIncome;
60
67
  /**
61
68
  * @description Is Income type one of OtherIncome types.
62
69
  * @param {IncomeType} incomeType Income Type.
63
70
  * @returns {boolean} returns true for other income.
64
71
  */
65
- export function isOtherIncomeWithDesc(incomeType) {
66
- return descriptionOtherIncomeTypes.includes(incomeType);
72
+ function isOtherIncomeWithDesc(incomeType) {
73
+ return exports.descriptionOtherIncomeTypes.includes(incomeType);
67
74
  }
75
+ exports.isOtherIncomeWithDesc = isOtherIncomeWithDesc;
68
76
  /**
69
77
  * @description Is Self Employed Full Doc or Low Doc Income
70
78
  * @param incomeType Income Type from Event
71
79
  * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
72
80
  */
73
- export function isFullDocOrLowDocIncome(incomeType) {
74
- return [IncomeType.SelfEmployedBusinessIncomeFullDoc, IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
81
+ function isFullDocOrLowDocIncome(incomeType) {
82
+ return [public_income_1.IncomeType.SelfEmployedBusinessIncomeFullDoc, public_income_1.IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
75
83
  }
84
+ exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
76
85
  /**
77
86
  * Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
78
87
  *
@@ -80,12 +89,13 @@ export function isFullDocOrLowDocIncome(incomeType) {
80
89
  * @param {string} employmentId - Employment id being searched for
81
90
  * @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
82
91
  */
83
- export const hasMatchingEmploymentId = (applicant, employmentId) => (applicant.Employment || []).some((employment) => {
84
- const id = get(employment, 'PAYG.@UniqueID') ||
85
- get(employment, 'SelfEmployed.@UniqueID') ||
86
- get(employment, 'NotEmployed.@UniqueID');
92
+ const hasMatchingEmploymentId = (applicant, employmentId) => (applicant.Employment || []).some((employment) => {
93
+ const id = (0, lodash_1.get)(employment, 'PAYG.@UniqueID') ||
94
+ (0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') ||
95
+ (0, lodash_1.get)(employment, 'NotEmployed.@UniqueID');
87
96
  return id === employmentId;
88
97
  });
98
+ exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
89
99
  /**
90
100
  * Gets the applicant id using the employment id
91
101
  *
@@ -93,23 +103,25 @@ export const hasMatchingEmploymentId = (applicant, employmentId) => (applicant.E
93
103
  * @param {string} employmentId - Employment ID
94
104
  * @returns {string | undefined} - Applicant id or undefined
95
105
  */
96
- export function getApplicantIdFromEmploymentId(applicants, employmentId) {
106
+ function getApplicantIdFromEmploymentId(applicants, employmentId) {
97
107
  let applicantId;
98
108
  if (applicants && employmentId) {
99
- const applicant = applicants.find((applicant) => hasMatchingEmploymentId(applicant, employmentId));
109
+ const applicant = applicants.find((applicant) => (0, exports.hasMatchingEmploymentId)(applicant, employmentId));
100
110
  applicantId = applicant === null || applicant === void 0 ? void 0 : applicant['@UniqueID'];
101
111
  }
102
112
  return applicantId;
103
113
  }
114
+ exports.getApplicantIdFromEmploymentId = getApplicantIdFromEmploymentId;
104
115
  /**
105
116
  * @description Get an applicantId from the event or the applicants.
106
117
  * @param {Income} income Income.
107
118
  * @param {PersonApplicant[]} applicants An array of LIXI applicants.
108
119
  * @returns {string | undefined} An applicantId or undefined.
109
120
  */
110
- export function getApplicantId({ percentOwned, employmentId }, applicants = []) {
111
- return get(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
121
+ function getApplicantId({ percentOwned, employmentId }, applicants = []) {
122
+ return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
112
123
  }
124
+ exports.getApplicantId = getApplicantId;
113
125
  /**
114
126
  * @description Sort Business Income By Year.
115
127
  * @param incomeA Income Details for Self Employed Full Doc.
@@ -118,4 +130,5 @@ export function getApplicantId({ percentOwned, employmentId }, applicants = [])
118
130
  * @param incomeB Income Details for Self Employed Full Doc.
119
131
  * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
120
132
  */
121
- export const sortBusinessIncome = ({ year: yearA = 0 }, { year: yearB = 0 }) => yearB - yearA;
133
+ const sortBusinessIncome = ({ year: yearA = 0 }, { year: yearB = 0 }) => yearB - yearA;
134
+ exports.sortBusinessIncome = sortBusinessIncome;
@@ -1,8 +1,12 @@
1
- import { formatISO } from 'date-fns';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isoDate = void 0;
4
+ const date_fns_1 = require("date-fns");
2
5
  /**
3
6
  * Formats a date to ISO 8601 format with time
4
7
  *
5
8
  * @param {string | Date} str - A string that could be converted to a Date (or) a Date.
6
9
  * @returns {string} - A ISO Date format without the time. (yyyy-MM-dd)
7
10
  */
8
- export const isoDate = (str) => formatISO(new Date(str), { representation: 'date' });
11
+ const isoDate = (str) => (0, date_fns_1.formatISO)(new Date(str), { representation: 'date' });
12
+ exports.isoDate = isoDate;
@@ -1,13 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normaliseDate = void 0;
1
4
  /**
2
5
  * Accepts any type of data format and normalises it into a consistent format
3
6
  * as "2019-09-19".
4
7
  *
5
8
  * @param {any} dateOfBirth - Date string.
6
9
  */
7
- export function normaliseDate(dateOfBirth) {
10
+ function normaliseDate(dateOfBirth) {
8
11
  const date = new Date(dateOfBirth);
9
12
  const year = date.getFullYear();
10
13
  const month = ('0' + (date.getMonth() + 1)).slice(-2);
11
14
  const day = ('0' + date.getDate()).slice(-2);
12
15
  return `${year}-${month}-${day}`;
13
16
  }
17
+ exports.normaliseDate = normaliseDate;
@@ -1,8 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.roundDecimal = void 0;
1
4
  /**
2
5
  * Rounds given value to 2 decimals.
3
6
  *
4
7
  * @param amount A number value.
5
8
  */
6
- export function roundDecimal(amount) {
9
+ function roundDecimal(amount) {
7
10
  return parseFloat(amount.toFixed(2));
8
11
  }
12
+ exports.roundDecimal = roundDecimal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.5.10",
3
+ "version": "1.6.2",
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",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@lendi/integrations-credit-protocol": "^1.17.3",
25
- "@lendi/integrations-protocol": "2.6.1",
25
+ "@lendi/integrations-protocol": "^2.6.4",
26
26
  "@lendi/logging": "^1.0.0",
27
27
  "clean-deep": "^3.4.0",
28
28
  "date-fns": "2.19.0",
@@ -44,12 +44,12 @@
44
44
  "eslint-plugin-prettier": "^4.0.0",
45
45
  "eslint-plugin-sonarjs": "^0.13.0",
46
46
  "husky": "^3.0.8",
47
+ "jest": "^28.1.2",
47
48
  "jest-buildkite-reporter": "^0.2.8",
48
49
  "jest-sonar-reporter": "^2.0.0",
49
50
  "path": "^0.12.7",
50
51
  "quicktype": "^15.0.261",
51
52
  "sinon": "^7.4.2",
52
- "jest": "^28.1.2",
53
53
  "ts-jest": "^28.0.5",
54
54
  "ts-node": "^8.4.1",
55
55
  "typedoc": "^0.20.36",