@lendi/integrations-transform 1.5.7 → 1.6.0

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 (109) hide show
  1. package/lib/index.js +10 -26
  2. package/lib/logger.d.ts +1 -2
  3. package/lib/logger.js +2 -5
  4. package/lib/schemas/application-workflow-event.json +1 -1
  5. package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
  6. package/lib/transform-events/generate-asset-liability-link.js +14 -18
  7. package/lib/transform-events/generate-credit-report-rebuilt.js +17 -21
  8. package/lib/transform-events/generate-employment.d.ts +1 -1
  9. package/lib/transform-events/generate-employment.js +51 -56
  10. package/lib/transform-events/generate-required-document.d.ts +1 -7
  11. package/lib/transform-events/generate-required-document.js +43 -69
  12. package/lib/transform-events/transform-applicant.d.ts +2 -1
  13. package/lib/transform-events/transform-applicant.js +78 -91
  14. package/lib/transform-events/transform-application-workflow.d.ts +0 -1
  15. package/lib/transform-events/transform-application-workflow.js +9 -14
  16. package/lib/transform-events/transform-application.d.ts +3 -1
  17. package/lib/transform-events/transform-application.js +28 -33
  18. package/lib/transform-events/transform-asset-address.d.ts +8 -2
  19. package/lib/transform-events/transform-asset-address.js +35 -37
  20. package/lib/transform-events/transform-asset.d.ts +7 -1
  21. package/lib/transform-events/transform-asset.js +164 -184
  22. package/lib/transform-events/transform-expenses.d.ts +4 -0
  23. package/lib/transform-events/transform-expenses.js +52 -58
  24. package/lib/transform-events/transform-funding-position.d.ts +2 -2
  25. package/lib/transform-events/transform-funding-position.js +38 -46
  26. package/lib/transform-events/transform-income.d.ts +8 -1
  27. package/lib/transform-events/transform-income.js +121 -139
  28. package/lib/transform-events/transform-liability.d.ts +4 -1
  29. package/lib/transform-events/transform-liability.js +62 -65
  30. package/lib/transform-events/transform-percent-owned.d.ts +1 -0
  31. package/lib/transform-events/transform-percent-owned.js +7 -14
  32. package/lib/types/enum-mappings/alieo-frequency.js +22 -26
  33. package/lib/types/enum-mappings/asset-type.js +14 -18
  34. package/lib/types/enum-mappings/builder-type.js +6 -10
  35. package/lib/types/enum-mappings/construction-type.js +7 -11
  36. package/lib/types/enum-mappings/country-code.js +243 -247
  37. package/lib/types/enum-mappings/employment-basis.js +9 -13
  38. package/lib/types/enum-mappings/expense-frequency.js +8 -12
  39. package/lib/types/enum-mappings/funding-position.js +29 -32
  40. package/lib/types/enum-mappings/government-benefits.js +7 -11
  41. package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
  42. package/lib/types/enum-mappings/guarantor-relationship-type.js +13 -0
  43. package/lib/types/enum-mappings/housing-status.js +12 -16
  44. package/lib/types/enum-mappings/income-type.js +13 -17
  45. package/lib/types/enum-mappings/index.js +27 -43
  46. package/lib/types/enum-mappings/liability-payment-type.js +6 -10
  47. package/lib/types/enum-mappings/liability-type.js +18 -22
  48. package/lib/types/enum-mappings/living-expense.js +27 -31
  49. package/lib/types/enum-mappings/marital-status.js +9 -13
  50. package/lib/types/enum-mappings/postcode.js +11 -15
  51. package/lib/types/enum-mappings/preferred-repayment.js +7 -11
  52. package/lib/types/enum-mappings/proof-of-identity.js +7 -11
  53. package/lib/types/enum-mappings/property-expense-category.js +8 -12
  54. package/lib/types/enum-mappings/public-financial-asset.js +9 -13
  55. package/lib/types/enum-mappings/public-primary-purpose.js +6 -10
  56. package/lib/types/enum-mappings/public-property-status.js +8 -12
  57. package/lib/types/enum-mappings/public-property-type.js +20 -24
  58. package/lib/types/enum-mappings/residency-status.js +8 -12
  59. package/lib/types/enum-mappings/title-gender.js +10 -14
  60. package/lib/types/enum-mappings/title.js +10 -14
  61. package/lib/types/enum-mappings/to-be-purchased.js +4 -7
  62. package/lib/types/enum-mappings/to-be-used-as-security.js +4 -7
  63. package/lib/types/enum-mappings/transaction-type.js +6 -10
  64. package/lib/types/enum-mappings/verification.js +10 -14
  65. package/lib/types/events/applicant-delete.js +4 -7
  66. package/lib/types/events/application-workflow.js +10 -13
  67. package/lib/types/events/asset-delete.js +4 -7
  68. package/lib/types/events/asset-liability-relation-delete.js +4 -7
  69. package/lib/types/events/credit-report-retrieved.js +4 -7
  70. package/lib/types/events/employment-delete.js +2 -5
  71. package/lib/types/events/expense-delete.js +2 -5
  72. package/lib/types/events/funding-position.js +6 -9
  73. package/lib/types/events/income-delete.js +4 -7
  74. package/lib/types/events/liability-delete.js +2 -5
  75. package/lib/types/events/opportunity.js +6 -9
  76. package/lib/types/events/public-applicant.js +28 -31
  77. package/lib/types/events/public-application.js +26 -29
  78. package/lib/types/events/public-asset-liability-relation.js +4 -7
  79. package/lib/types/events/public-asset.js +26 -29
  80. package/lib/types/events/public-employment.js +18 -21
  81. package/lib/types/events/public-expense.js +8 -11
  82. package/lib/types/events/public-funding-position.js +2 -5
  83. package/lib/types/events/public-income.js +12 -15
  84. package/lib/types/events/public-liability.js +16 -19
  85. package/lib/types/events/public-required-document.js +14 -17
  86. package/lib/types/partial-application.js +1 -2
  87. package/lib/types/recursive-partial.js +1 -2
  88. package/lib/update-application/merge-application.d.ts +1 -1
  89. package/lib/update-application/merge-application.js +41 -38
  90. package/lib/update-application/update-primary-applicant.d.ts +1 -4
  91. package/lib/update-application/update-primary-applicant.js +14 -38
  92. package/lib/utils/address-tools.d.ts +3 -1
  93. package/lib/utils/address-tools.js +56 -68
  94. package/lib/utils/clean-up.d.ts +1 -1
  95. package/lib/utils/clean-up.js +6 -10
  96. package/lib/utils/formatYesNo.d.ts +0 -1
  97. package/lib/utils/formatYesNo.js +2 -7
  98. package/lib/utils/generate-address.d.ts +3 -2
  99. package/lib/utils/generate-address.js +33 -42
  100. package/lib/utils/get-financial-institution.d.ts +1 -0
  101. package/lib/utils/get-financial-institution.js +7 -10
  102. package/lib/utils/is-asset-type.js +13 -20
  103. package/lib/utils/is-income-type.d.ts +2 -0
  104. package/lib/utils/is-income-type.js +50 -69
  105. package/lib/utils/iso-date.d.ts +0 -1
  106. package/lib/utils/iso-date.js +2 -7
  107. package/lib/utils/normalise-date.js +6 -10
  108. package/lib/utils/round-decimal.js +1 -5
  109. package/package.json +14 -17
@@ -1,44 +1,42 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.generateStandard = exports.generateAddress = exports.StreetTypeArray = exports.StreetNumberMaxLength = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
- var lodash_1 = require("lodash");
6
- var country_code_1 = require("..//types/enum-mappings/country-code");
7
- var postcode_1 = require("../types/enum-mappings/postcode");
8
- var public_asset_1 = require("../types/events/public-asset");
9
- var address_tools_1 = require("./address-tools");
10
- exports.StreetNumberMaxLength = 16;
11
- exports.StreetTypeArray = Object.values(lixi_internal_request_1.StreetTypeList);
12
- var addressMapping = {
1
+ import { CountryCodeList, StreetTypeList, } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { set } from 'lodash';
3
+ import { countryCodeMapping } from '..//types/enum-mappings/country-code';
4
+ import { postcodeMapping } from '../types/enum-mappings/postcode';
5
+ import { Countries } from '../types/events/public-asset';
6
+ import { extractCountryFromFormatted } from './address-tools';
7
+ export const StreetNumberMaxLength = 16;
8
+ export const StreetTypeArray = Object.values(StreetTypeList);
9
+ const addressMapping = {
13
10
  country: '@Country',
14
11
  city: '@Suburb',
15
12
  postcode: '@AustralianPostCode',
16
13
  state: '@AustralianState',
17
- standard: 'Standard'
14
+ standard: 'Standard',
18
15
  };
19
- var standardMapping = {
16
+ const standardMapping = {
20
17
  streetName: '@StreetName',
21
18
  streetType: '@StreetType',
22
19
  streetNumber: '@StreetNumber',
23
20
  level: '@Level',
24
- unit: '@Unit'
21
+ unit: '@Unit',
25
22
  };
26
23
  /**
27
24
  * Generates an address for an asset.
25
+ *
28
26
  * @param {Address} address - An address object.
29
27
  * @param {string} id - Id of asset object.
30
- * @return {Partial<AddressType>} A transformed address object.
28
+ * @returns {Partial<AddressType>} A transformed address object.
31
29
  */
32
- function generateAddress(address, id) {
33
- var transformedAddress = {
34
- '@Country': lixi_internal_request_1.CountryCodeList.Au,
35
- '@UniqueID': id
30
+ export function generateAddress(address, id) {
31
+ const transformedAddress = {
32
+ '@Country': CountryCodeList.Au,
33
+ '@UniqueID': id,
36
34
  };
37
- var country = (0, address_tools_1.extractCountryFromFormatted)(address.formatted);
35
+ const country = extractCountryFromFormatted(address.formatted);
38
36
  if (!address.country && country.length > 0) {
39
37
  address.country = country;
40
38
  }
41
- if (address.country && address.country !== public_asset_1.Countries.Australia) {
39
+ if (address.country && address.country !== Countries.Australia) {
42
40
  addressMapping.postcode = '@OverseasPostCode';
43
41
  addressMapping.state = '@OverseasState';
44
42
  }
@@ -46,56 +44,49 @@ function generateAddress(address, id) {
46
44
  addressMapping.postcode = '@AustralianPostCode';
47
45
  addressMapping.state = '@AustralianState';
48
46
  if (!address.postcode && address.state) {
49
- transformedAddress['@AustralianPostCode'] = postcode_1.postcodeMapping[address.state];
47
+ transformedAddress['@AustralianPostCode'] = postcodeMapping[address.state];
50
48
  }
51
49
  }
52
- for (var _i = 0, _a = Object.entries(address); _i < _a.length; _i++) {
53
- var _b = _a[_i], key = _b[0], value = _b[1];
50
+ for (const [key, value] of Object.entries(address)) {
54
51
  if (addressMapping[key]) {
55
52
  switch (key) {
56
53
  case 'standard':
57
- (0, lodash_1.set)(transformedAddress, addressMapping[key], generateStandard(value));
54
+ set(transformedAddress, addressMapping[key], generateStandard(value));
58
55
  break;
59
56
  case 'country':
60
- (0, lodash_1.set)(transformedAddress, addressMapping[key], country_code_1.countryCodeMapping[value]);
57
+ set(transformedAddress, addressMapping[key], countryCodeMapping[value]);
61
58
  break;
62
59
  default:
63
- (0, lodash_1.set)(transformedAddress, addressMapping[key], value);
60
+ set(transformedAddress, addressMapping[key], value);
64
61
  break;
65
62
  }
66
63
  }
67
64
  }
68
65
  return transformedAddress;
69
66
  }
70
- exports.generateAddress = generateAddress;
71
67
  /**
72
68
  * Generates an address standard.
73
69
  *
74
70
  * @param addressStandard An address standard object.
75
- * @return A transformed standard object.
71
+ * @returns A transformed standard object.
76
72
  */
77
- function generateStandard(addressStandard) {
78
- var transformedStandard = {};
79
- var _loop_1 = function (key, value) {
73
+ export function generateStandard(addressStandard) {
74
+ const transformedStandard = {};
75
+ for (const [key, value] of Object.entries(addressStandard)) {
80
76
  if (standardMapping[key]) {
81
77
  switch (key) {
82
78
  case 'streetNumber':
83
- (0, lodash_1.set)(transformedStandard, standardMapping[key], value.substring(0, exports.StreetNumberMaxLength));
79
+ set(transformedStandard, standardMapping[key], value.substring(0, StreetNumberMaxLength));
84
80
  break;
85
81
  case 'streetType':
86
- var streetType = exports.StreetTypeArray.find(function (type) { return type.toLowerCase() === value.toLowerCase(); });
87
- (0, lodash_1.set)(transformedStandard, standardMapping[key], streetType || lixi_internal_request_1.StreetTypeList.Street);
82
+ const streetType = StreetTypeArray.find((type) => type.toLowerCase() === value.toLowerCase());
83
+ set(transformedStandard, standardMapping[key], streetType || StreetTypeList.Street);
88
84
  break;
89
85
  default:
90
- (0, lodash_1.set)(transformedStandard, standardMapping[key], value);
86
+ set(transformedStandard, standardMapping[key], value);
91
87
  break;
92
88
  }
93
89
  }
94
- };
95
- for (var _i = 0, _a = Object.entries(addressStandard); _i < _a.length; _i++) {
96
- var _b = _a[_i], key = _b[0], value = _b[1];
97
- _loop_1(key, value);
98
90
  }
99
91
  return transformedStandard;
100
92
  }
101
- exports.generateStandard = generateStandard;
@@ -3,5 +3,6 @@ import { FinancialInstitutionList } from '@lendi/integrations-protocol/lib/types
3
3
  * Returns the financialInstitution value form the Enum based on the index where it was found.
4
4
  *
5
5
  * @param institution: Institution value from event.
6
+ * @param institution
6
7
  */
7
8
  export declare function getFinancialInstitution(institution: string): FinancialInstitutionList;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.getFinancialInstitution = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
- var financialInstitutions = Object.values(lixi_internal_request_1.FinancialInstitutionList);
1
+ import { FinancialInstitutionList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ const financialInstitutions = Object.values(FinancialInstitutionList);
6
3
  /**
7
4
  * Returns the financialInstitution value form the Enum based on the index where it was found.
8
5
  *
9
6
  * @param institution: Institution value from event.
7
+ * @param institution
10
8
  */
11
- function getFinancialInstitution(institution) {
12
- var institutionUpperCased = institution.toUpperCase();
13
- var financialInstitution = financialInstitutions.find(function (item) { return item.toUpperCase() === institutionUpperCased; });
14
- return financialInstitution || lixi_internal_request_1.FinancialInstitutionList.Other;
9
+ export function getFinancialInstitution(institution) {
10
+ const institutionUpperCased = institution.toUpperCase();
11
+ const financialInstitution = financialInstitutions.find((item) => item.toUpperCase() === institutionUpperCased);
12
+ return financialInstitution || FinancialInstitutionList.Other;
15
13
  }
16
- exports.getFinancialInstitution = getFinancialInstitution;
@@ -1,46 +1,39 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.isOtherAsset = exports.isMotorVehicle = exports.isRealEstateAsset = exports.isFinancialAsset = void 0;
4
- var public_asset_1 = require("../types/events/public-asset");
1
+ import { AssetType } from '../types/events/public-asset';
5
2
  /**
6
3
  * @description Checks if the asset is of financial type.
7
4
  * @param {Asset} asset asset payload.
8
5
  * @returns {boolean} returns true if asset is a financial asset.
9
6
  */
10
- function isFinancialAsset(asset) {
7
+ export function isFinancialAsset(asset) {
11
8
  return [
12
- public_asset_1.AssetType.Shares,
13
- public_asset_1.AssetType.Superannuation,
14
- public_asset_1.AssetType.TermDeposit,
15
- public_asset_1.AssetType.SavingCheckAccount,
16
- public_asset_1.AssetType.ManagedFunds,
9
+ AssetType.Shares,
10
+ AssetType.Superannuation,
11
+ AssetType.TermDeposit,
12
+ AssetType.SavingCheckAccount,
13
+ AssetType.ManagedFunds,
17
14
  ].includes(asset.type);
18
15
  }
19
- exports.isFinancialAsset = isFinancialAsset;
20
16
  /**
21
17
  * @description Is Asset a Real Estate Asset.
22
18
  * @param {Asset} asset An Asset.
23
19
  * @returns {boolean} returns true if Asset is a Real Estate Asset.
24
20
  */
25
- function isRealEstateAsset(asset) {
26
- return asset.type === public_asset_1.AssetType.Property;
21
+ export function isRealEstateAsset(asset) {
22
+ return asset.type === AssetType.Property;
27
23
  }
28
- exports.isRealEstateAsset = isRealEstateAsset;
29
24
  /**
30
25
  * @description Is Asset a Motor Vehicle.
31
26
  * @param {Asset} asset An Asset.
32
27
  * @returns {boolean} returns true if an Asset is a vehicle.
33
28
  */
34
- function isMotorVehicle(asset) {
35
- return asset.type === public_asset_1.AssetType.Vehicle;
29
+ export function isMotorVehicle(asset) {
30
+ return asset.type === AssetType.Vehicle;
36
31
  }
37
- exports.isMotorVehicle = isMotorVehicle;
38
32
  /**
39
33
  * @description Is Asset of LIXI type `OtherAsset`.
40
34
  * @param {Asset} asset An Asset.
41
35
  * @returns {boolean} returns true if asset is `OtherAsset`.
42
36
  */
43
- function isOtherAsset(asset) {
44
- return [public_asset_1.AssetType.HomeContents, public_asset_1.AssetType.Gifts, public_asset_1.AssetType.OtherAsset].includes(asset.type);
37
+ export function isOtherAsset(asset) {
38
+ return [AssetType.HomeContents, AssetType.Gifts, AssetType.OtherAsset].includes(asset.type);
45
39
  }
46
- exports.isOtherAsset = isOtherAsset;
@@ -65,6 +65,8 @@ export declare function getApplicantId({ percentOwned, employmentId }: Income, a
65
65
  /**
66
66
  * @description Sort Business Income By Year.
67
67
  * @param incomeA Income Details for Self Employed Full Doc.
68
+ * @param incomeA.year
69
+ * @param incomeB.year
68
70
  * @param incomeB Income Details for Self Employed Full Doc.
69
71
  * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
70
72
  */
@@ -1,87 +1,78 @@
1
- "use strict";
2
- exports.__esModule = 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
- var lodash_1 = require("lodash");
5
- var public_income_1 = require("../types/events/public-income");
6
- exports.descriptionOtherIncomeTypes = [
7
- public_income_1.IncomeType.InvestmentIncome,
8
- public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
1
+ import { get } from 'lodash';
2
+ import { IncomeType } from '../types/events/public-income';
3
+ export const descriptionOtherIncomeTypes = [
4
+ IncomeType.InvestmentIncome,
5
+ IncomeType.PaygNonVoluntaryDeductionsPreTax,
9
6
  ];
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,
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,
19
16
  ];
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,
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,
30
27
  ];
31
28
  /**
32
29
  * @description Is income type one of the PAYG income.
33
30
  * @param {string} incomeType Income type.
34
31
  * @returns {boolean} Returns true if Income type is a PAYG Income.
35
32
  */
36
- function isPaygIncome(incomeType) {
37
- return exports.PAYGList.includes(incomeType);
33
+ export function isPaygIncome(incomeType) {
34
+ return PAYGList.includes(incomeType);
38
35
  }
39
- exports.isPaygIncome = isPaygIncome;
40
36
  /**
41
37
  * @description Is income type SelfEmployedBusinessIncome.
42
38
  * @param {string} incomeType Income type.
43
39
  * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
44
40
  */
45
- function isSelfEmployedIncome(incomeType) {
46
- return incomeType === public_income_1.IncomeType.SelfEmployedBusinessIncome;
41
+ export function isSelfEmployedIncome(incomeType) {
42
+ return incomeType === IncomeType.SelfEmployedBusinessIncome;
47
43
  }
48
- exports.isSelfEmployedIncome = isSelfEmployedIncome;
49
44
  /**
50
45
  * @description Is income type Rental Income.
51
46
  * @param {IncomeType} incomeType Income type.
52
47
  * @returns {boolean} true if Income type is Rental Income.
53
48
  */
54
- function isRentalIncome(incomeType) {
55
- return incomeType === public_income_1.IncomeType.RentalIncome;
49
+ export function isRentalIncome(incomeType) {
50
+ return incomeType === IncomeType.RentalIncome;
56
51
  }
57
- exports.isRentalIncome = isRentalIncome;
58
52
  /**
59
53
  * @description Is income type grouped as OtherIncome.
60
54
  * @param {IncomeType} incomeType Income type.
61
55
  * @returns {boolean} true if income is of type other income.
62
56
  */
63
- function isOtherIncome(incomeType) {
64
- return exports.otherIncomeList.includes(incomeType);
57
+ export function isOtherIncome(incomeType) {
58
+ return otherIncomeList.includes(incomeType);
65
59
  }
66
- exports.isOtherIncome = isOtherIncome;
67
60
  /**
68
61
  * @description Is Income type one of OtherIncome types.
69
62
  * @param {IncomeType} incomeType Income Type.
70
63
  * @returns {boolean} returns true for other income.
71
64
  */
72
- function isOtherIncomeWithDesc(incomeType) {
73
- return exports.descriptionOtherIncomeTypes.includes(incomeType);
65
+ export function isOtherIncomeWithDesc(incomeType) {
66
+ return descriptionOtherIncomeTypes.includes(incomeType);
74
67
  }
75
- exports.isOtherIncomeWithDesc = isOtherIncomeWithDesc;
76
68
  /**
77
69
  * @description Is Self Employed Full Doc or Low Doc Income
78
70
  * @param incomeType Income Type from Event
79
71
  * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
80
72
  */
81
- function isFullDocOrLowDocIncome(incomeType) {
82
- return [public_income_1.IncomeType.SelfEmployedBusinessIncomeFullDoc, public_income_1.IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
73
+ export function isFullDocOrLowDocIncome(incomeType) {
74
+ return [IncomeType.SelfEmployedBusinessIncomeFullDoc, IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
83
75
  }
84
- exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
85
76
  /**
86
77
  * Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
87
78
  *
@@ -89,15 +80,12 @@ exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
89
80
  * @param {string} employmentId - Employment id being searched for
90
81
  * @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
91
82
  */
92
- var hasMatchingEmploymentId = function (applicant, employmentId) {
93
- return (applicant.Employment || []).some(function (employment) {
94
- var id = (0, lodash_1.get)(employment, 'PAYG.@UniqueID') ||
95
- (0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') ||
96
- (0, lodash_1.get)(employment, 'NotEmployed.@UniqueID');
97
- return id === employmentId;
98
- });
99
- };
100
- exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
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');
87
+ return id === employmentId;
88
+ });
101
89
  /**
102
90
  * Gets the applicant id using the employment id
103
91
  *
@@ -105,36 +93,29 @@ exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
105
93
  * @param {string} employmentId - Employment ID
106
94
  * @returns {string | undefined} - Applicant id or undefined
107
95
  */
108
- function getApplicantIdFromEmploymentId(applicants, employmentId) {
109
- var applicantId;
96
+ export function getApplicantIdFromEmploymentId(applicants, employmentId) {
97
+ let applicantId;
110
98
  if (applicants && employmentId) {
111
- var applicant = applicants.find(function (applicant) { return (0, exports.hasMatchingEmploymentId)(applicant, employmentId); });
99
+ const applicant = applicants.find((applicant) => hasMatchingEmploymentId(applicant, employmentId));
112
100
  applicantId = applicant === null || applicant === void 0 ? void 0 : applicant['@UniqueID'];
113
101
  }
114
102
  return applicantId;
115
103
  }
116
- exports.getApplicantIdFromEmploymentId = getApplicantIdFromEmploymentId;
117
104
  /**
118
105
  * @description Get an applicantId from the event or the applicants.
119
106
  * @param {Income} income Income.
120
107
  * @param {PersonApplicant[]} applicants An array of LIXI applicants.
121
108
  * @returns {string | undefined} An applicantId or undefined.
122
109
  */
123
- function getApplicantId(_a, applicants) {
124
- var percentOwned = _a.percentOwned, employmentId = _a.employmentId;
125
- if (applicants === void 0) { applicants = []; }
126
- return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
110
+ export function getApplicantId({ percentOwned, employmentId }, applicants = []) {
111
+ return get(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
127
112
  }
128
- exports.getApplicantId = getApplicantId;
129
113
  /**
130
114
  * @description Sort Business Income By Year.
131
115
  * @param incomeA Income Details for Self Employed Full Doc.
116
+ * @param incomeA.year
117
+ * @param incomeB.year
132
118
  * @param incomeB Income Details for Self Employed Full Doc.
133
119
  * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
134
120
  */
135
- var sortBusinessIncome = function (_a, _b) {
136
- var _c = _a.year, yearA = _c === void 0 ? 0 : _c;
137
- var _d = _b.year, yearB = _d === void 0 ? 0 : _d;
138
- return yearB - yearA;
139
- };
140
- exports.sortBusinessIncome = sortBusinessIncome;
121
+ export const sortBusinessIncome = ({ year: yearA = 0 }, { year: yearB = 0 }) => yearB - yearA;
@@ -2,7 +2,6 @@
2
2
  * Formats a date to ISO 8601 format with time
3
3
  *
4
4
  * @param {string | Date} str - A string that could be converted to a Date (or) a Date.
5
- *
6
5
  * @returns {string} - A ISO Date format without the time. (yyyy-MM-dd)
7
6
  */
8
7
  export declare const isoDate: (str: string | Date) => string;
@@ -1,13 +1,8 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.isoDate = void 0;
4
- var date_fns_1 = require("date-fns");
1
+ import { formatISO } from 'date-fns';
5
2
  /**
6
3
  * Formats a date to ISO 8601 format with time
7
4
  *
8
5
  * @param {string | Date} str - A string that could be converted to a Date (or) a Date.
9
- *
10
6
  * @returns {string} - A ISO Date format without the time. (yyyy-MM-dd)
11
7
  */
12
- var isoDate = function (str) { return (0, date_fns_1.formatISO)(new Date(str), { representation: 'date' }); };
13
- exports.isoDate = isoDate;
8
+ export const isoDate = (str) => formatISO(new Date(str), { representation: 'date' });
@@ -1,17 +1,13 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.normaliseDate = void 0;
4
1
  /**
5
2
  * Accepts any type of data format and normalises it into a consistent format
6
3
  * as "2019-09-19".
7
4
  *
8
5
  * @param {any} dateOfBirth - Date string.
9
6
  */
10
- function normaliseDate(dateOfBirth) {
11
- var date = new Date(dateOfBirth);
12
- var year = date.getFullYear();
13
- var month = ('0' + (date.getMonth() + 1)).slice(-2);
14
- var day = ('0' + date.getDate()).slice(-2);
15
- return "".concat(year, "-").concat(month, "-").concat(day);
7
+ export function normaliseDate(dateOfBirth) {
8
+ const date = new Date(dateOfBirth);
9
+ const year = date.getFullYear();
10
+ const month = ('0' + (date.getMonth() + 1)).slice(-2);
11
+ const day = ('0' + date.getDate()).slice(-2);
12
+ return `${year}-${month}-${day}`;
16
13
  }
17
- exports.normaliseDate = normaliseDate;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.roundDecimal = void 0;
4
1
  /**
5
2
  * Rounds given value to 2 decimals.
6
3
  *
7
4
  * @param amount A number value.
8
5
  */
9
- function roundDecimal(amount) {
6
+ export function roundDecimal(amount) {
10
7
  return parseFloat(amount.toFixed(2));
11
8
  }
12
- exports.roundDecimal = roundDecimal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.5.7",
3
+ "version": "1.6.0",
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,39 +21,36 @@
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.17.1",
24
+ "@lendi/integrations-credit-protocol": "^1.17.3",
25
25
  "@lendi/integrations-protocol": "2.6.1",
26
+ "@lendi/logging": "^1.0.0",
26
27
  "clean-deep": "^3.4.0",
27
28
  "date-fns": "2.19.0",
28
- "lodash": "^4.17.15",
29
- "pino": "^6.7.0"
29
+ "lodash": "^4.17.15"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@lendi/prettier-config": "^1.0.0",
33
33
  "@lendi/typescript-config": "^2.0.0",
34
- "@types/jest": "^27.4.1",
34
+ "@types/jest": "^28.1.4",
35
35
  "@types/lodash": "^4.14.141",
36
36
  "@types/node": "^12.12.5",
37
- "@types/pino": "^6.3.3",
38
37
  "@types/prettier": "^1.16.1",
39
38
  "@types/sinon": "^7.5.0",
40
- "@typescript-eslint/eslint-plugin": "^4.14.0",
41
- "@typescript-eslint/parser": "^4.14.0",
42
- "eslint-config-prettier": "^7.2.0",
43
- "eslint-plugin-import": "^2.22.1",
44
- "eslint-plugin-prettier": "^3.3.1",
45
- "eslint-plugin-sonarjs": "^0.5.0",
39
+ "@typescript-eslint/eslint-plugin": "^5.21.0",
40
+ "@typescript-eslint/parser": "^5.21.0",
41
+ "eslint": "^8.14.0",
42
+ "eslint-config-prettier": "^8.5.0",
43
+ "eslint-plugin-jsdoc": "^39.2.9",
44
+ "eslint-plugin-prettier": "^4.0.0",
45
+ "eslint-plugin-sonarjs": "^0.13.0",
46
46
  "husky": "^3.0.8",
47
- "jest": "^27.5.1",
48
47
  "jest-buildkite-reporter": "^0.2.8",
49
48
  "jest-sonar-reporter": "^2.0.0",
50
49
  "path": "^0.12.7",
51
- "prettier": "^2.2.1",
52
- "prettier-check": "^2.0.0",
53
- "prettier-eslint": "^12.0.0",
54
50
  "quicktype": "15.0.207",
55
51
  "sinon": "^7.4.2",
56
- "ts-jest": "^27.1.4",
52
+ "jest": "^28.1.2",
53
+ "ts-jest": "^28.0.5",
57
54
  "ts-node": "^8.4.1",
58
55
  "typedoc": "^0.20.36",
59
56
  "typescript": "^4.1.3"