@lendi/act-credit-decisions-transform 2.0.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 (204) hide show
  1. package/README.md +31 -0
  2. package/lib/index.d.ts +11 -0
  3. package/lib/index.js +28 -0
  4. package/lib/logger.d.ts +1 -0
  5. package/lib/logger.js +5 -0
  6. package/lib/schemas/application-workflow-event.json +240 -0
  7. package/lib/schemas/credit-report-retrieved-event.json +57 -0
  8. package/lib/schemas/public-applicant-event.json +910 -0
  9. package/lib/schemas/public-application-event.json +250 -0
  10. package/lib/schemas/public-asset-event.json +679 -0
  11. package/lib/schemas/public-asset-liability-relation-delete-event.json +74 -0
  12. package/lib/schemas/public-asset-liability-relation-event.json +73 -0
  13. package/lib/schemas/public-create-applicant-event.json +609 -0
  14. package/lib/schemas/public-delete-applicant-event.json +66 -0
  15. package/lib/schemas/public-delete-asset-event.json +53 -0
  16. package/lib/schemas/public-delete-income-event.json +55 -0
  17. package/lib/schemas/public-employment-delete-event.json +31 -0
  18. package/lib/schemas/public-employment-event.json +278 -0
  19. package/lib/schemas/public-expense-delete-event.json +41 -0
  20. package/lib/schemas/public-expense-event.json +133 -0
  21. package/lib/schemas/public-funding-position-event.json +419 -0
  22. package/lib/schemas/public-income-event.json +242 -0
  23. package/lib/schemas/public-liability-delete-event.json +37 -0
  24. package/lib/schemas/public-liability-event.json +262 -0
  25. package/lib/schemas/public-required-document-event.json +366 -0
  26. package/lib/schemas/public-update-applicant-event.json +606 -0
  27. package/lib/schemas/sf-opportunity-event-out.json +138 -0
  28. package/lib/transform-events/generate-asset-liability-link.d.ts +10 -0
  29. package/lib/transform-events/generate-asset-liability-link.js +29 -0
  30. package/lib/transform-events/generate-credit-report-rebuilt.d.ts +8 -0
  31. package/lib/transform-events/generate-credit-report-rebuilt.js +41 -0
  32. package/lib/transform-events/transform-applicant.d.ts +8 -0
  33. package/lib/transform-events/transform-applicant.js +180 -0
  34. package/lib/transform-events/transform-application-workflow.d.ts +8 -0
  35. package/lib/transform-events/transform-application-workflow.js +30 -0
  36. package/lib/transform-events/transform-application.d.ts +20 -0
  37. package/lib/transform-events/transform-application.js +67 -0
  38. package/lib/transform-events/transform-asset-address.d.ts +25 -0
  39. package/lib/transform-events/transform-asset-address.js +87 -0
  40. package/lib/transform-events/transform-asset.d.ts +58 -0
  41. package/lib/transform-events/transform-asset.js +337 -0
  42. package/lib/transform-events/transform-employment.d.ts +9 -0
  43. package/lib/transform-events/transform-employment.js +107 -0
  44. package/lib/transform-events/transform-expenses.d.ts +41 -0
  45. package/lib/transform-events/transform-expenses.js +121 -0
  46. package/lib/transform-events/transform-funding-position.d.ts +21 -0
  47. package/lib/transform-events/transform-funding-position.js +107 -0
  48. package/lib/transform-events/transform-income.d.ts +48 -0
  49. package/lib/transform-events/transform-income.js +260 -0
  50. package/lib/transform-events/transform-liability.d.ts +12 -0
  51. package/lib/transform-events/transform-liability.js +117 -0
  52. package/lib/transform-events/transform-percent-owned.d.ts +10 -0
  53. package/lib/transform-events/transform-percent-owned.js +22 -0
  54. package/lib/transform-events/transform-required-document.d.ts +67 -0
  55. package/lib/transform-events/transform-required-document.js +148 -0
  56. package/lib/types/enum-mappings/alieo-frequency.d.ts +15 -0
  57. package/lib/types/enum-mappings/alieo-frequency.js +25 -0
  58. package/lib/types/enum-mappings/applicant-gender.d.ts +6 -0
  59. package/lib/types/enum-mappings/applicant-gender.js +11 -0
  60. package/lib/types/enum-mappings/applicant-type.d.ts +6 -0
  61. package/lib/types/enum-mappings/applicant-type.js +10 -0
  62. package/lib/types/enum-mappings/asset-type.d.ts +3 -0
  63. package/lib/types/enum-mappings/asset-type.js +17 -0
  64. package/lib/types/enum-mappings/builder-type.d.ts +7 -0
  65. package/lib/types/enum-mappings/builder-type.js +9 -0
  66. package/lib/types/enum-mappings/company-structure.d.ts +7 -0
  67. package/lib/types/enum-mappings/company-structure.js +10 -0
  68. package/lib/types/enum-mappings/company-type.d.ts +7 -0
  69. package/lib/types/enum-mappings/company-type.js +11 -0
  70. package/lib/types/enum-mappings/construction-type.d.ts +7 -0
  71. package/lib/types/enum-mappings/construction-type.js +10 -0
  72. package/lib/types/enum-mappings/country-code.d.ts +7 -0
  73. package/lib/types/enum-mappings/country-code.js +246 -0
  74. package/lib/types/enum-mappings/employment-basis.d.ts +7 -0
  75. package/lib/types/enum-mappings/employment-basis.js +12 -0
  76. package/lib/types/enum-mappings/expense-frequency.d.ts +7 -0
  77. package/lib/types/enum-mappings/expense-frequency.js +11 -0
  78. package/lib/types/enum-mappings/funding-position.d.ts +18 -0
  79. package/lib/types/enum-mappings/funding-position.js +36 -0
  80. package/lib/types/enum-mappings/government-benefits.d.ts +7 -0
  81. package/lib/types/enum-mappings/government-benefits.js +10 -0
  82. package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
  83. package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
  84. package/lib/types/enum-mappings/housing-status.d.ts +7 -0
  85. package/lib/types/enum-mappings/housing-status.js +15 -0
  86. package/lib/types/enum-mappings/income-type.d.ts +7 -0
  87. package/lib/types/enum-mappings/income-type.js +16 -0
  88. package/lib/types/enum-mappings/index.d.ts +27 -0
  89. package/lib/types/enum-mappings/index.js +43 -0
  90. package/lib/types/enum-mappings/liability-payment-type.d.ts +7 -0
  91. package/lib/types/enum-mappings/liability-payment-type.js +9 -0
  92. package/lib/types/enum-mappings/liability-type.d.ts +7 -0
  93. package/lib/types/enum-mappings/liability-type.js +21 -0
  94. package/lib/types/enum-mappings/living-expense.d.ts +7 -0
  95. package/lib/types/enum-mappings/living-expense.js +31 -0
  96. package/lib/types/enum-mappings/marital-status.d.ts +7 -0
  97. package/lib/types/enum-mappings/marital-status.js +12 -0
  98. package/lib/types/enum-mappings/postcode.d.ts +6 -0
  99. package/lib/types/enum-mappings/postcode.js +15 -0
  100. package/lib/types/enum-mappings/preferred-repayment.d.ts +7 -0
  101. package/lib/types/enum-mappings/preferred-repayment.js +10 -0
  102. package/lib/types/enum-mappings/proof-of-identity.d.ts +7 -0
  103. package/lib/types/enum-mappings/proof-of-identity.js +10 -0
  104. package/lib/types/enum-mappings/property-expense-category.d.ts +7 -0
  105. package/lib/types/enum-mappings/property-expense-category.js +11 -0
  106. package/lib/types/enum-mappings/public-financial-asset.d.ts +7 -0
  107. package/lib/types/enum-mappings/public-financial-asset.js +12 -0
  108. package/lib/types/enum-mappings/public-primary-purpose.d.ts +7 -0
  109. package/lib/types/enum-mappings/public-primary-purpose.js +9 -0
  110. package/lib/types/enum-mappings/public-property-status.d.ts +7 -0
  111. package/lib/types/enum-mappings/public-property-status.js +11 -0
  112. package/lib/types/enum-mappings/public-property-type.d.ts +7 -0
  113. package/lib/types/enum-mappings/public-property-type.js +23 -0
  114. package/lib/types/enum-mappings/residency-status.d.ts +7 -0
  115. package/lib/types/enum-mappings/residency-status.js +11 -0
  116. package/lib/types/enum-mappings/title-gender.d.ts +7 -0
  117. package/lib/types/enum-mappings/title-gender.js +13 -0
  118. package/lib/types/enum-mappings/title.d.ts +7 -0
  119. package/lib/types/enum-mappings/title.js +13 -0
  120. package/lib/types/enum-mappings/to-be-purchased.d.ts +5 -0
  121. package/lib/types/enum-mappings/to-be-purchased.js +8 -0
  122. package/lib/types/enum-mappings/to-be-used-as-security.d.ts +5 -0
  123. package/lib/types/enum-mappings/to-be-used-as-security.js +8 -0
  124. package/lib/types/enum-mappings/transaction-type.d.ts +7 -0
  125. package/lib/types/enum-mappings/transaction-type.js +9 -0
  126. package/lib/types/enum-mappings/trust.d.ts +7 -0
  127. package/lib/types/enum-mappings/trust.js +14 -0
  128. package/lib/types/enum-mappings/verification.d.ts +3 -0
  129. package/lib/types/enum-mappings/verification.js +13 -0
  130. package/lib/types/events/applicant-delete.d.ts +42 -0
  131. package/lib/types/events/applicant-delete.js +15 -0
  132. package/lib/types/events/application-workflow.d.ts +233 -0
  133. package/lib/types/events/application-workflow.js +172 -0
  134. package/lib/types/events/asset-delete.d.ts +33 -0
  135. package/lib/types/events/asset-delete.js +15 -0
  136. package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
  137. package/lib/types/events/asset-liability-relation-delete.js +15 -0
  138. package/lib/types/events/credit-report-retrieved.d.ts +36 -0
  139. package/lib/types/events/credit-report-retrieved.js +15 -0
  140. package/lib/types/events/employment-delete.d.ts +19 -0
  141. package/lib/types/events/employment-delete.js +7 -0
  142. package/lib/types/events/expense-delete.d.ts +21 -0
  143. package/lib/types/events/expense-delete.js +7 -0
  144. package/lib/types/events/funding-position.d.ts +116 -0
  145. package/lib/types/events/funding-position.js +34 -0
  146. package/lib/types/events/income-delete.d.ts +33 -0
  147. package/lib/types/events/income-delete.js +15 -0
  148. package/lib/types/events/liability-delete.d.ts +17 -0
  149. package/lib/types/events/liability-delete.js +7 -0
  150. package/lib/types/events/opportunity.d.ts +102 -0
  151. package/lib/types/events/opportunity.js +47 -0
  152. package/lib/types/events/public-applicant.d.ts +628 -0
  153. package/lib/types/events/public-applicant.js +411 -0
  154. package/lib/types/events/public-application.d.ts +151 -0
  155. package/lib/types/events/public-application.js +103 -0
  156. package/lib/types/events/public-asset-liability-relation.d.ts +52 -0
  157. package/lib/types/events/public-asset-liability-relation.js +15 -0
  158. package/lib/types/events/public-asset.d.ts +502 -0
  159. package/lib/types/events/public-asset.js +348 -0
  160. package/lib/types/events/public-employment.d.ts +121 -0
  161. package/lib/types/events/public-employment.js +46 -0
  162. package/lib/types/events/public-expense.d.ts +84 -0
  163. package/lib/types/events/public-expense.js +51 -0
  164. package/lib/types/events/public-funding-position.d.ts +341 -0
  165. package/lib/types/events/public-funding-position.js +20 -0
  166. package/lib/types/events/public-income.d.ts +144 -0
  167. package/lib/types/events/public-income.js +65 -0
  168. package/lib/types/events/public-liability.d.ts +140 -0
  169. package/lib/types/events/public-liability.js +68 -0
  170. package/lib/types/events/public-required-document.d.ts +374 -0
  171. package/lib/types/events/public-required-document.js +297 -0
  172. package/lib/types/partial-application.d.ts +3 -0
  173. package/lib/types/partial-application.js +2 -0
  174. package/lib/types/recursive-partial.d.ts +3 -0
  175. package/lib/types/recursive-partial.js +2 -0
  176. package/lib/update-application/merge-application.d.ts +14 -0
  177. package/lib/update-application/merge-application.js +175 -0
  178. package/lib/update-application/remove-ids-not-required.d.ts +11 -0
  179. package/lib/update-application/remove-ids-not-required.js +63 -0
  180. package/lib/update-application/update-primary-applicant.d.ts +27 -0
  181. package/lib/update-application/update-primary-applicant.js +46 -0
  182. package/lib/utils/address-tools.d.ts +84 -0
  183. package/lib/utils/address-tools.js +176 -0
  184. package/lib/utils/clean-up.d.ts +7 -0
  185. package/lib/utils/clean-up.js +24 -0
  186. package/lib/utils/errors.d.ts +28 -0
  187. package/lib/utils/errors.js +43 -0
  188. package/lib/utils/formatYesNo.d.ts +8 -0
  189. package/lib/utils/formatYesNo.js +12 -0
  190. package/lib/utils/generate-address.d.ts +19 -0
  191. package/lib/utils/generate-address.js +97 -0
  192. package/lib/utils/get-financial-institution.d.ts +8 -0
  193. package/lib/utils/get-financial-institution.js +17 -0
  194. package/lib/utils/is-asset-type.d.ts +25 -0
  195. package/lib/utils/is-asset-type.js +46 -0
  196. package/lib/utils/is-income-type.d.ts +73 -0
  197. package/lib/utils/is-income-type.js +134 -0
  198. package/lib/utils/iso-date.d.ts +7 -0
  199. package/lib/utils/iso-date.js +12 -0
  200. package/lib/utils/normalise-date.d.ts +8 -0
  201. package/lib/utils/normalise-date.js +17 -0
  202. package/lib/utils/round-decimal.d.ts +6 -0
  203. package/lib/utils/round-decimal.js +12 -0
  204. package/package.json +79 -0
@@ -0,0 +1,73 @@
1
+ import { PersonApplicant } from '@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request';
2
+ import { IncomeType, Income, IncomeBusinessDetails } from '../types/events/public-income';
3
+ export declare const descriptionOtherIncomeTypes: string[];
4
+ export declare const PAYGList: string[];
5
+ export declare const otherIncomeList: IncomeType[];
6
+ /**
7
+ * @description Is income type one of the PAYG income.
8
+ * @param {string} incomeType Income type.
9
+ * @returns {boolean} Returns true if Income type is a PAYG Income.
10
+ */
11
+ export declare function isPaygIncome(incomeType: string): boolean;
12
+ /**
13
+ * @description Is income type SelfEmployedBusinessIncome.
14
+ * @param {string} incomeType Income type.
15
+ * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
16
+ */
17
+ export declare function isSelfEmployedIncome(incomeType: string): boolean;
18
+ /**
19
+ * @description Is income type Rental Income.
20
+ * @param {IncomeType} incomeType Income type.
21
+ * @returns {boolean} true if Income type is Rental Income.
22
+ */
23
+ export declare function isRentalIncome(incomeType: string): boolean;
24
+ /**
25
+ * @description Is income type grouped as OtherIncome.
26
+ * @param {IncomeType} incomeType Income type.
27
+ * @returns {boolean} true if income is of type other income.
28
+ */
29
+ export declare function isOtherIncome(incomeType: IncomeType): boolean;
30
+ /**
31
+ * @description Is Income type one of OtherIncome types.
32
+ * @param {IncomeType} incomeType Income Type.
33
+ * @returns {boolean} returns true for other income.
34
+ */
35
+ export declare function isOtherIncomeWithDesc(incomeType: string): boolean;
36
+ /**
37
+ * @description Is Self Employed Full Doc or Low Doc Income
38
+ * @param incomeType Income Type from Event
39
+ * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
40
+ */
41
+ export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
42
+ /**
43
+ * Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
44
+ *
45
+ * @param {PersonApplicant} applicant - An applicant
46
+ * @param {string} employmentId - Employment id being searched for
47
+ * @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
48
+ */
49
+ export declare const hasMatchingEmploymentId: (applicant: PersonApplicant, employmentId: string) => boolean;
50
+ /**
51
+ * Gets the applicant id using the employment id
52
+ *
53
+ * @param {PersonApplicant[]} applicants - An array of applicants.
54
+ * @param {string} employmentId - Employment ID
55
+ * @returns {string | undefined} - Applicant id or undefined
56
+ */
57
+ export declare function getApplicantIdFromEmploymentId(applicants: PersonApplicant[], employmentId: string): string | undefined;
58
+ /**
59
+ * @description Get an applicantId from the event or the applicants.
60
+ * @param {Income} income Income.
61
+ * @param {PersonApplicant[]} applicants An array of LIXI applicants.
62
+ * @returns {string | undefined} An applicantId or undefined.
63
+ */
64
+ export declare function getApplicantId({ percentOwned, employmentId }: Income, applicants?: PersonApplicant[]): string | undefined;
65
+ /**
66
+ * @description Sort Business Income By Year.
67
+ * @param incomeA Income Details for Self Employed Full Doc.
68
+ * @param incomeA.year
69
+ * @param incomeB.year
70
+ * @param incomeB Income Details for Self Employed Full Doc.
71
+ * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
72
+ */
73
+ export declare const sortBusinessIncome: ({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails) => number;
@@ -0,0 +1,134 @@
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,
9
+ ];
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,
19
+ ];
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,
30
+ ];
31
+ /**
32
+ * @description Is income type one of the PAYG income.
33
+ * @param {string} incomeType Income type.
34
+ * @returns {boolean} Returns true if Income type is a PAYG Income.
35
+ */
36
+ function isPaygIncome(incomeType) {
37
+ return exports.PAYGList.includes(incomeType);
38
+ }
39
+ exports.isPaygIncome = isPaygIncome;
40
+ /**
41
+ * @description Is income type SelfEmployedBusinessIncome.
42
+ * @param {string} incomeType Income type.
43
+ * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
44
+ */
45
+ function isSelfEmployedIncome(incomeType) {
46
+ return incomeType === public_income_1.IncomeType.SelfEmployedBusinessIncome;
47
+ }
48
+ exports.isSelfEmployedIncome = isSelfEmployedIncome;
49
+ /**
50
+ * @description Is income type Rental Income.
51
+ * @param {IncomeType} incomeType Income type.
52
+ * @returns {boolean} true if Income type is Rental Income.
53
+ */
54
+ function isRentalIncome(incomeType) {
55
+ return incomeType === public_income_1.IncomeType.RentalIncome;
56
+ }
57
+ exports.isRentalIncome = isRentalIncome;
58
+ /**
59
+ * @description Is income type grouped as OtherIncome.
60
+ * @param {IncomeType} incomeType Income type.
61
+ * @returns {boolean} true if income is of type other income.
62
+ */
63
+ function isOtherIncome(incomeType) {
64
+ return exports.otherIncomeList.includes(incomeType);
65
+ }
66
+ exports.isOtherIncome = isOtherIncome;
67
+ /**
68
+ * @description Is Income type one of OtherIncome types.
69
+ * @param {IncomeType} incomeType Income Type.
70
+ * @returns {boolean} returns true for other income.
71
+ */
72
+ function isOtherIncomeWithDesc(incomeType) {
73
+ return exports.descriptionOtherIncomeTypes.includes(incomeType);
74
+ }
75
+ exports.isOtherIncomeWithDesc = isOtherIncomeWithDesc;
76
+ /**
77
+ * @description Is Self Employed Full Doc or Low Doc Income
78
+ * @param incomeType Income Type from Event
79
+ * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
80
+ */
81
+ function isFullDocOrLowDocIncome(incomeType) {
82
+ return [public_income_1.IncomeType.SelfEmployedBusinessIncomeFullDoc, public_income_1.IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
83
+ }
84
+ exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
85
+ /**
86
+ * Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
87
+ *
88
+ * @param {PersonApplicant} applicant - An applicant
89
+ * @param {string} employmentId - Employment id being searched for
90
+ * @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
91
+ */
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');
96
+ return id === employmentId;
97
+ });
98
+ exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
99
+ /**
100
+ * Gets the applicant id using the employment id
101
+ *
102
+ * @param {PersonApplicant[]} applicants - An array of applicants.
103
+ * @param {string} employmentId - Employment ID
104
+ * @returns {string | undefined} - Applicant id or undefined
105
+ */
106
+ function getApplicantIdFromEmploymentId(applicants, employmentId) {
107
+ let applicantId;
108
+ if (applicants && employmentId) {
109
+ const applicant = applicants.find((applicant) => (0, exports.hasMatchingEmploymentId)(applicant, employmentId));
110
+ applicantId = applicant === null || applicant === void 0 ? void 0 : applicant['@UniqueID'];
111
+ }
112
+ return applicantId;
113
+ }
114
+ exports.getApplicantIdFromEmploymentId = getApplicantIdFromEmploymentId;
115
+ /**
116
+ * @description Get an applicantId from the event or the applicants.
117
+ * @param {Income} income Income.
118
+ * @param {PersonApplicant[]} applicants An array of LIXI applicants.
119
+ * @returns {string | undefined} An applicantId or undefined.
120
+ */
121
+ function getApplicantId({ percentOwned, employmentId }, applicants = []) {
122
+ return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
123
+ }
124
+ exports.getApplicantId = getApplicantId;
125
+ /**
126
+ * @description Sort Business Income By Year.
127
+ * @param incomeA Income Details for Self Employed Full Doc.
128
+ * @param incomeA.year
129
+ * @param incomeB.year
130
+ * @param incomeB Income Details for Self Employed Full Doc.
131
+ * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
132
+ */
133
+ const sortBusinessIncome = ({ year: yearA = 0 }, { year: yearB = 0 }) => yearB - yearA;
134
+ exports.sortBusinessIncome = sortBusinessIncome;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Formats a date to ISO 8601 format with time
3
+ *
4
+ * @param {string | Date} str - A string that could be converted to a Date (or) a Date.
5
+ * @returns {string} - A ISO Date format without the time. (yyyy-MM-dd)
6
+ */
7
+ export declare const isoDate: (str: string | Date) => string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isoDate = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ /**
6
+ * Formats a date to ISO 8601 format with time
7
+ *
8
+ * @param {string | Date} str - A string that could be converted to a Date (or) a Date.
9
+ * @returns {string} - A ISO Date format without the time. (yyyy-MM-dd)
10
+ */
11
+ const isoDate = (str) => (0, date_fns_1.formatISO)(new Date(str), { representation: 'date' });
12
+ exports.isoDate = isoDate;
@@ -0,0 +1,8 @@
1
+ export type DateConstructorParam = ConstructorParameters<DateConstructor>[0];
2
+ /**
3
+ * Accepts any type of data format and normalises it into a consistent format
4
+ * as "2019-09-19".
5
+ *
6
+ * @param {any} dateOfBirth - Date string.
7
+ */
8
+ export declare function normaliseDate(dateOfBirth: DateConstructorParam): string;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normaliseDate = void 0;
4
+ /**
5
+ * Accepts any type of data format and normalises it into a consistent format
6
+ * as "2019-09-19".
7
+ *
8
+ * @param {any} dateOfBirth - Date string.
9
+ */
10
+ function normaliseDate(dateOfBirth) {
11
+ const date = new Date(dateOfBirth);
12
+ const year = date.getFullYear();
13
+ const month = ('0' + (date.getMonth() + 1)).slice(-2);
14
+ const day = ('0' + date.getDate()).slice(-2);
15
+ return `${year}-${month}-${day}`;
16
+ }
17
+ exports.normaliseDate = normaliseDate;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Rounds given value to 2 decimals.
3
+ *
4
+ * @param amount A number value.
5
+ */
6
+ export declare function roundDecimal(amount: number): number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.roundDecimal = void 0;
4
+ /**
5
+ * Rounds given value to 2 decimals.
6
+ *
7
+ * @param amount A number value.
8
+ */
9
+ function roundDecimal(amount) {
10
+ return parseFloat(amount.toFixed(2));
11
+ }
12
+ exports.roundDecimal = roundDecimal;
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@lendi/act-credit-decisions-transform",
3
+ "version": "2.0.0",
4
+ "description": "Library for kafka event data transforming",
5
+ "author": "Integrations <integrations@lendi.com.au>",
6
+ "homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
7
+ "license": "ISC",
8
+ "main": "./lib/index.js",
9
+ "directories": {
10
+ "lib": "lib",
11
+ "test": "test"
12
+ },
13
+ "files": [
14
+ "lib/**/*"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
22
+ },
23
+ "dependencies": {
24
+ "@lendi/integrations-credit-protocol": "1.18.7",
25
+ "@lendi/act-eac-integrations-protocol": "3.0.0",
26
+ "@lendi/logging": "^1.0.0",
27
+ "clean-deep": "^3.4.0",
28
+ "date-fns": "2.19.0",
29
+ "lodash": "^4.17.15"
30
+ },
31
+ "devDependencies": {
32
+ "@lendi/prettier-config": "^1.0.0",
33
+ "@lendi/typescript-config": "^2.0.0",
34
+ "@types/jest": "^28.1.4",
35
+ "@types/lodash": "^4.14.141",
36
+ "@types/node": "^16.11.7",
37
+ "@types/prettier": "^1.16.1",
38
+ "@types/sinon": "^7.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
+ "husky": "^3.0.8",
47
+ "jest": "^28.1.2",
48
+ "jest-buildkite-reporter": "^0.2.8",
49
+ "jest-sonar-reporter": "^2.0.0",
50
+ "path": "^0.12.7",
51
+ "quicktype": "^15.0.261",
52
+ "sinon": "^7.4.2",
53
+ "ts-jest": "^28.0.5",
54
+ "ts-node": "^8.4.1",
55
+ "typedoc": "^0.20.36",
56
+ "typescript": "^4.1.3"
57
+ },
58
+ "scripts": {
59
+ "build": "tsc && cp -r src/schemas lib",
60
+ "build:types": "yarn run build:types:events && yarn run format",
61
+ "build:types:events": "./src/scripts/build-event-types.sh",
62
+ "check:formatting": "prettier-check '**/*.{json,ts,md}'",
63
+ "check:typings:sources": "tsc --project tsconfig.json --noEmit",
64
+ "check:typings:tests": "tsc --project tsconfig.tests.json --noEmit",
65
+ "lint:types": "tsc --project tsconfig.json --noEmit",
66
+ "lint": "eslint './src/**/*.ts'; exit 0",
67
+ "lint:fix": "eslint './src/**/*.ts' --fix",
68
+ "format": "prettier --write '**/*.{json,ts,md}'",
69
+ "prepack": "npm run build",
70
+ "prepublishOnly": "npm run build",
71
+ "postpack": "rm -rf lib",
72
+ "test:unit": "jest --config jest.config.json",
73
+ "list:package-contents": "npm publish --dry-run",
74
+ "semver:patch": "npm version patch",
75
+ "semver:minor": "npm version minor",
76
+ "semver:major": "npm version major",
77
+ "current:version": "echo $npm_package_version"
78
+ }
79
+ }