@lendi/integrations-transform 1.0.7 → 1.1.1

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 (156) hide show
  1. package/lib/index.d.ts +7 -0
  2. package/lib/index.js +20 -0
  3. package/lib/logger.d.ts +2 -0
  4. package/lib/logger.js +5 -0
  5. package/lib/schemas/credit-report-retrieved-event.json +57 -0
  6. package/lib/schemas/public-applicant-event.json +652 -0
  7. package/lib/schemas/public-application-event.json +224 -0
  8. package/lib/schemas/public-asset-event.json +633 -0
  9. package/lib/schemas/public-asset-liability-relation-delete-event.json +74 -0
  10. package/lib/schemas/public-asset-liability-relation-event.json +73 -0
  11. package/lib/schemas/public-create-applicant-event.json +610 -0
  12. package/lib/schemas/public-delete-applicant-event.json +66 -0
  13. package/lib/schemas/public-delete-asset-event.json +53 -0
  14. package/lib/schemas/public-delete-income-event.json +55 -0
  15. package/lib/schemas/public-employment-delete-event.json +31 -0
  16. package/lib/schemas/public-employment-event.json +302 -0
  17. package/lib/schemas/public-expense-delete-event.json +41 -0
  18. package/lib/schemas/public-expense-event.json +132 -0
  19. package/lib/schemas/public-funding-position-event.json +289 -0
  20. package/lib/schemas/public-income-event.json +242 -0
  21. package/lib/schemas/public-liability-delete-event.json +37 -0
  22. package/lib/schemas/public-liability-event.json +234 -0
  23. package/lib/schemas/public-required-document-event.json +98 -0
  24. package/lib/schemas/public-update-applicant-event.json +607 -0
  25. package/lib/schemas/sf-opportunity-event-out.json +138 -0
  26. package/lib/transform-events/generate-asset-liability-link.d.ts +8 -0
  27. package/lib/transform-events/generate-asset-liability-link.js +29 -0
  28. package/lib/transform-events/generate-asset.d.ts +17 -0
  29. package/lib/transform-events/generate-asset.js +178 -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/generate-employment.d.ts +8 -0
  33. package/lib/transform-events/generate-employment.js +106 -0
  34. package/lib/transform-events/generate-funding-position.d.ts +18 -0
  35. package/lib/transform-events/generate-funding-position.js +82 -0
  36. package/lib/transform-events/generate-income.d.ts +37 -0
  37. package/lib/transform-events/generate-income.js +254 -0
  38. package/lib/transform-events/generate-liability.d.ts +8 -0
  39. package/lib/transform-events/generate-liability.js +87 -0
  40. package/lib/transform-events/generate-lixi-percentowned.d.ts +9 -0
  41. package/lib/transform-events/generate-lixi-percentowned.js +24 -0
  42. package/lib/transform-events/generate-opportunity.d.ts +8 -0
  43. package/lib/transform-events/generate-opportunity.js +32 -0
  44. package/lib/transform-events/generate-required-document.d.ts +8 -0
  45. package/lib/transform-events/generate-required-document.js +54 -0
  46. package/lib/transform-events/transform-applicant.d.ts +33 -0
  47. package/lib/transform-events/transform-applicant.js +189 -0
  48. package/lib/transform-events/transform-application.d.ts +8 -0
  49. package/lib/transform-events/transform-application.js +54 -0
  50. package/lib/transform-events/transform-expenses.d.ts +37 -0
  51. package/lib/transform-events/transform-expenses.js +121 -0
  52. package/lib/types/enum-mappings/alieo-frequency.d.ts +15 -0
  53. package/lib/types/enum-mappings/alieo-frequency.js +26 -0
  54. package/lib/types/enum-mappings/country-code.d.ts +7 -0
  55. package/lib/types/enum-mappings/country-code.js +247 -0
  56. package/lib/types/enum-mappings/employment-basis.d.ts +7 -0
  57. package/lib/types/enum-mappings/employment-basis.js +13 -0
  58. package/lib/types/enum-mappings/expense-frequency.d.ts +7 -0
  59. package/lib/types/enum-mappings/expense-frequency.js +12 -0
  60. package/lib/types/enum-mappings/funding-position.d.ts +18 -0
  61. package/lib/types/enum-mappings/funding-position.js +34 -0
  62. package/lib/types/enum-mappings/government-benefits.d.ts +7 -0
  63. package/lib/types/enum-mappings/government-benefits.js +11 -0
  64. package/lib/types/enum-mappings/housing-status.d.ts +7 -0
  65. package/lib/types/enum-mappings/housing-status.js +16 -0
  66. package/lib/types/enum-mappings/income-type.d.ts +7 -0
  67. package/lib/types/enum-mappings/income-type.js +17 -0
  68. package/lib/types/enum-mappings/liability-payment-type.d.ts +7 -0
  69. package/lib/types/enum-mappings/liability-payment-type.js +10 -0
  70. package/lib/types/enum-mappings/liability-type.d.ts +7 -0
  71. package/lib/types/enum-mappings/liability-type.js +22 -0
  72. package/lib/types/enum-mappings/living-expense.d.ts +7 -0
  73. package/lib/types/enum-mappings/living-expense.js +31 -0
  74. package/lib/types/enum-mappings/marital-status.d.ts +7 -0
  75. package/lib/types/enum-mappings/marital-status.js +13 -0
  76. package/lib/types/enum-mappings/postcode.d.ts +6 -0
  77. package/lib/types/enum-mappings/postcode.js +16 -0
  78. package/lib/types/enum-mappings/preferred-repayment.d.ts +7 -0
  79. package/lib/types/enum-mappings/preferred-repayment.js +11 -0
  80. package/lib/types/enum-mappings/proof-of-identity.d.ts +7 -0
  81. package/lib/types/enum-mappings/proof-of-identity.js +11 -0
  82. package/lib/types/enum-mappings/public-financial-asset.d.ts +7 -0
  83. package/lib/types/enum-mappings/public-financial-asset.js +13 -0
  84. package/lib/types/enum-mappings/public-primary-purpose.d.ts +7 -0
  85. package/lib/types/enum-mappings/public-primary-purpose.js +10 -0
  86. package/lib/types/enum-mappings/public-property-status.d.ts +7 -0
  87. package/lib/types/enum-mappings/public-property-status.js +12 -0
  88. package/lib/types/enum-mappings/public-property-type.d.ts +7 -0
  89. package/lib/types/enum-mappings/public-property-type.js +24 -0
  90. package/lib/types/enum-mappings/residency-status.d.ts +7 -0
  91. package/lib/types/enum-mappings/residency-status.js +12 -0
  92. package/lib/types/enum-mappings/title-gender.d.ts +7 -0
  93. package/lib/types/enum-mappings/title-gender.js +14 -0
  94. package/lib/types/enum-mappings/title.d.ts +7 -0
  95. package/lib/types/enum-mappings/title.js +14 -0
  96. package/lib/types/enum-mappings/transaction-type.d.ts +7 -0
  97. package/lib/types/enum-mappings/transaction-type.js +10 -0
  98. package/lib/types/events/applicant-delete.d.ts +42 -0
  99. package/lib/types/events/applicant-delete.js +15 -0
  100. package/lib/types/events/asset-delete.d.ts +33 -0
  101. package/lib/types/events/asset-delete.js +15 -0
  102. package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
  103. package/lib/types/events/asset-liability-relation-delete.js +15 -0
  104. package/lib/types/events/credit-report-retrieved.d.ts +36 -0
  105. package/lib/types/events/credit-report-retrieved.js +15 -0
  106. package/lib/types/events/employment-delete.d.ts +19 -0
  107. package/lib/types/events/employment-delete.js +7 -0
  108. package/lib/types/events/expense-delete.d.ts +21 -0
  109. package/lib/types/events/expense-delete.js +7 -0
  110. package/lib/types/events/funding-position.d.ts +116 -0
  111. package/lib/types/events/funding-position.js +34 -0
  112. package/lib/types/events/income-delete.d.ts +33 -0
  113. package/lib/types/events/income-delete.js +15 -0
  114. package/lib/types/events/liability-delete.d.ts +17 -0
  115. package/lib/types/events/liability-delete.js +7 -0
  116. package/lib/types/events/opportunity.d.ts +102 -0
  117. package/lib/types/events/opportunity.js +47 -0
  118. package/lib/types/events/public-applicant.d.ts +485 -0
  119. package/lib/types/events/public-applicant.js +343 -0
  120. package/lib/types/events/public-application.d.ts +145 -0
  121. package/lib/types/events/public-application.js +100 -0
  122. package/lib/types/events/public-asset-liability-relation.d.ts +52 -0
  123. package/lib/types/events/public-asset-liability-relation.js +15 -0
  124. package/lib/types/events/public-asset.d.ts +469 -0
  125. package/lib/types/events/public-asset.js +319 -0
  126. package/lib/types/events/public-employment.d.ts +190 -0
  127. package/lib/types/events/public-employment.js +69 -0
  128. package/lib/types/events/public-expense.d.ts +83 -0
  129. package/lib/types/events/public-expense.js +50 -0
  130. package/lib/types/events/public-funding-position.d.ts +226 -0
  131. package/lib/types/events/public-funding-position.js +7 -0
  132. package/lib/types/events/public-income.d.ts +144 -0
  133. package/lib/types/events/public-income.js +65 -0
  134. package/lib/types/events/public-liability.d.ts +133 -0
  135. package/lib/types/events/public-liability.js +68 -0
  136. package/lib/types/events/public-required-document.d.ts +99 -0
  137. package/lib/types/events/public-required-document.js +44 -0
  138. package/lib/types/partial-application.d.ts +3 -0
  139. package/lib/types/partial-application.js +2 -0
  140. package/lib/types/recursive-partial.d.ts +3 -0
  141. package/lib/types/recursive-partial.js +2 -0
  142. package/lib/utils/address-tools.d.ts +69 -0
  143. package/lib/utils/address-tools.js +146 -0
  144. package/lib/utils/clean-up.d.ts +7 -0
  145. package/lib/utils/clean-up.js +24 -0
  146. package/lib/utils/generate-address.d.ts +19 -0
  147. package/lib/utils/generate-address.js +102 -0
  148. package/lib/utils/get-financial-institution.d.ts +7 -0
  149. package/lib/utils/get-financial-institution.js +16 -0
  150. package/lib/utils/is-income-type.d.ts +83 -0
  151. package/lib/utils/is-income-type.js +166 -0
  152. package/lib/utils/normalise-date.d.ts +8 -0
  153. package/lib/utils/normalise-date.js +17 -0
  154. package/lib/utils/round-decimal.d.ts +6 -0
  155. package/lib/utils/round-decimal.js +12 -0
  156. package/package.json +10 -7
@@ -0,0 +1,37 @@
1
+ import { RentalIncome } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { PartialApplication } from '../types/partial-application';
3
+ import { Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
4
+ import { IncomeRecent } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
5
+ export interface AmountFrequency {
6
+ amount: string;
7
+ frequency?: string;
8
+ }
9
+ export declare const EmploymentIncomeTypeMapping: Record<string, AmountFrequency>;
10
+ export declare function getIncomeMapping(incomeType: IncomeType, basePath?: string): Record<string, string>;
11
+ /**
12
+ * Generates an partial application from a partial income event.
13
+ *
14
+ * @param payload a partial income event.
15
+ * @param storedApplication: Current state of the application.
16
+ * @return partialApplication an incomplete application.
17
+ */
18
+ export declare function generateIncome(payload: IncomePayload, storedApplication: PartialApplication): PartialApplication;
19
+ /**
20
+ * Creates Rental Income array.
21
+ * @param amount Amount
22
+ * @param frequency Frequency
23
+ * @param ownership Owners.
24
+ */
25
+ export declare function createRentalIncome(amount: number, frequency: Frequency, ownership: Ownership[]): RentalIncome[];
26
+ export interface SelfEmploymentIncomeMapping {
27
+ year: string;
28
+ companyProfitBeforeTax: string;
29
+ addback: Record<string, string>;
30
+ nonRecurringIncome: string;
31
+ }
32
+ /**
33
+ * @description Transform a Self Employed Income Details to LIXI
34
+ * @param data Financial Year Income Details for Self Employed Income.
35
+ * @returns {IncomeRecent} LIXI Income for the Self Employed.
36
+ */
37
+ export declare function generateIncomeBusinessDetails(data: IncomeBusinessDetails): IncomeRecent;
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var _a;
14
+ exports.__esModule = true;
15
+ exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
16
+ var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
17
+ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
18
+ var lodash_1 = require("lodash");
19
+ var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
20
+ var government_benefits_1 = require("../types/enum-mappings/government-benefits");
21
+ var income_type_1 = require("../types/enum-mappings/income-type");
22
+ var public_income_1 = require("../types/events/public-income");
23
+ var round_decimal_1 = require("../utils/round-decimal");
24
+ var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
25
+ var is_income_type_1 = require("../utils/is-income-type");
26
+ var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
27
+ var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
28
+ // Income types mapping from internal to LIXI types /paths.
29
+ exports.EmploymentIncomeTypeMapping = (_a = {},
30
+ _a[public_income_1.IncomeType.PaygAllowancesNotTaxed] = {
31
+ amount: 'Income.@WorkAllowanceAmount',
32
+ frequency: 'Income.@WorkAllowanceFrequency'
33
+ },
34
+ _a[public_income_1.IncomeType.PaygAllowancesTaxed] = {
35
+ amount: netWorkAllowanceAmount,
36
+ frequency: netWorkAllowanceFrequency
37
+ },
38
+ _a[public_income_1.IncomeType.PaygBaseSalary] = {
39
+ amount: 'Income.@GrossSalaryAmount',
40
+ frequency: 'Income.@GrossSalaryFrequency'
41
+ },
42
+ _a[public_income_1.IncomeType.PaygBonusIncome] = {
43
+ amount: 'Income.@BonusAmount',
44
+ frequency: 'Income.@BonusFrequency'
45
+ },
46
+ _a[public_income_1.IncomeType.PaygCommissionIncome] = {
47
+ amount: 'Income.@CommissionAmount',
48
+ frequency: 'Income.@CommissionFrequency'
49
+ },
50
+ _a[public_income_1.IncomeType.PaygCompanyCar] = {
51
+ amount: 'Income.@NetCarAllowanceAmount',
52
+ frequency: 'Income.@NetCarAllowanceFrequency'
53
+ },
54
+ _a[public_income_1.IncomeType.PaygCarAllowance] = {
55
+ amount: 'Income.@CarAllowanceAmount',
56
+ frequency: 'Income.@CarAllowanceFrequency'
57
+ },
58
+ _a[public_income_1.IncomeType.PaygOvertimeIncome] = {
59
+ amount: 'Income.@GrossRegularOvertimeAmount',
60
+ frequency: 'Income.@GrossRegularOvertimeFrequency'
61
+ },
62
+ _a[public_income_1.IncomeType.SelfEmployedBusinessIncome] = {
63
+ amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
64
+ },
65
+ _a);
66
+ function getIncomeMapping(incomeType, basePath) {
67
+ if (basePath === void 0) { basePath = application_paths_1.paths.PAYG; }
68
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
69
+ return {
70
+ assetId: "".concat(basePath, ".@UniqueID"),
71
+ percentOwned: "".concat(basePath, ".RentalIncome")
72
+ };
73
+ }
74
+ if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
75
+ return {
76
+ incomes: "".concat(basePath, ".IncomeRecent"),
77
+ companyId: "".concat(basePath, ".@UniqueID"),
78
+ incomeRecent: "".concat(basePath, ".IncomeRecent"),
79
+ incomePrevious: "".concat(basePath, ".IncomePrevious"),
80
+ gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
81
+ };
82
+ }
83
+ if ((0, is_income_type_1.isPaygIncome)(incomeType) || (0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
84
+ var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
85
+ var mapping = {
86
+ amount: "".concat(basePath, ".").concat(amount),
87
+ employmentId: "".concat(basePath, ".@UniqueID")
88
+ };
89
+ if (frequency) {
90
+ mapping.frequency = "".concat(basePath, ".").concat(frequency);
91
+ }
92
+ return mapping;
93
+ }
94
+ return {
95
+ amount: "".concat(basePath, ".@Amount"),
96
+ frequency: "".concat(basePath, ".@Frequency"),
97
+ percentOwned: "".concat(basePath, ".PercentOwned"),
98
+ type: "".concat(basePath, ".@Type"),
99
+ benefitType: "".concat(basePath, ".@GovernmentBenefitsType")
100
+ };
101
+ }
102
+ exports.getIncomeMapping = getIncomeMapping;
103
+ /**
104
+ * Generates an partial application from a partial income event.
105
+ *
106
+ * @param payload a partial income event.
107
+ * @param storedApplication: Current state of the application.
108
+ * @return partialApplication an incomplete application.
109
+ */
110
+ function generateIncome(payload, storedApplication) {
111
+ var applicationId = payload.applicationId, id = payload.id, income = payload.income;
112
+ var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
113
+ var partialApplication = {};
114
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
115
+ if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
116
+ var applicants = (0, lodash_1.get)(storedApplication, application_paths_1.paths.PersonApplicants);
117
+ var applicantId = (0, is_income_type_1.getApplicantId)(income, applicants);
118
+ if (applicantId) {
119
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
120
+ }
121
+ }
122
+ var incomeMapping;
123
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
124
+ incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.RealEstateAsset);
125
+ }
126
+ else if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
127
+ incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.PAYG);
128
+ }
129
+ else if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
130
+ incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.SelfEmployed);
131
+ }
132
+ else if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
133
+ var basePath = 'Package.Content.Application.CompanyApplicant[0]';
134
+ incomeMapping = getIncomeMapping(incomeType, basePath);
135
+ }
136
+ else {
137
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
138
+ incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.OtherIncome);
139
+ }
140
+ for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
141
+ var _b = _a[_i], key = _b[0], value = _b[1];
142
+ if (incomeMapping[key]) {
143
+ switch (key) {
144
+ case 'amount':
145
+ var amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
146
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
147
+ break;
148
+ case 'frequency':
149
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
150
+ break;
151
+ case 'percentOwned':
152
+ var ownership = value;
153
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(ownership);
154
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
155
+ percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
156
+ }
157
+ if (percentOwned) {
158
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
159
+ }
160
+ break;
161
+ case 'type':
162
+ if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
163
+ var mappedType = income_type_1.otherIncomeMapping[value];
164
+ if ((0, is_income_type_1.isOtherIncome)(value)) {
165
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
166
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
167
+ }
168
+ else {
169
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
170
+ }
171
+ }
172
+ break;
173
+ case 'benefitType':
174
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
175
+ break;
176
+ case 'incomes':
177
+ var sortedIncomeList = value
178
+ .sort(is_income_type_1.sortBusinessIncome)
179
+ .map(generateIncomeBusinessDetails);
180
+ (0, lodash_1.set)(partialApplication, 'Package.Content.Application.CompanyApplicant[0].Income', sortedIncomeList);
181
+ break;
182
+ default:
183
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], value);
184
+ break;
185
+ }
186
+ }
187
+ }
188
+ return partialApplication;
189
+ }
190
+ exports.generateIncome = generateIncome;
191
+ /**
192
+ * Creates Rental Income array.
193
+ * @param amount Amount
194
+ * @param frequency Frequency
195
+ * @param ownership Owners.
196
+ */
197
+ function createRentalIncome(amount, frequency, ownership) {
198
+ if (frequency === public_income_1.Frequency.Quarterly) {
199
+ amount = Math.ceil(amount / 3);
200
+ frequency = public_income_1.Frequency.Monthly;
201
+ }
202
+ var rentalIncome = [];
203
+ for (var _i = 0, ownership_1 = ownership; _i < ownership_1.length; _i++) {
204
+ var owner = ownership_1[_i];
205
+ var percent = owner.percent, applicantId = owner.applicantId;
206
+ var ownerAmount = amount * percent;
207
+ rentalIncome.push({
208
+ '@Frequency': alieo_frequency_1.rentalIncomeFrequencyMapping[frequency],
209
+ '@RentalAmount': ownerAmount,
210
+ '@x_Owner': applicantId
211
+ });
212
+ }
213
+ return rentalIncome;
214
+ }
215
+ exports.createRentalIncome = createRentalIncome;
216
+ var selfEmploymentIncomeMapping = {
217
+ year: '@StartDate',
218
+ companyProfitBeforeTax: '@CompanyProfitBeforeTax',
219
+ addback: {
220
+ depreciation: 'Addback.@Depreciation',
221
+ interest: 'Addback.@Interest',
222
+ lease: 'Addback.@Lease',
223
+ nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
224
+ other: 'Addback.@Other',
225
+ salary: 'Addback.@Salary',
226
+ superannuationExcess: 'Addback.@SuperannuationExcess'
227
+ },
228
+ nonRecurringIncome: 'NonRecurringIncome[0].@Amount'
229
+ };
230
+ /**
231
+ * @description Transform a Self Employed Income Details to LIXI
232
+ * @param data Financial Year Income Details for Self Employed Income.
233
+ * @returns {IncomeRecent} LIXI Income for the Self Employed.
234
+ */
235
+ function generateIncomeBusinessDetails(data) {
236
+ var income = {};
237
+ var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
238
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
239
+ var _b = _a[_i], key = _b[0], value = _b[1];
240
+ if (selfEmploymentIncomeMapping[key] != null) {
241
+ if (key === 'addback') {
242
+ for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
243
+ var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
244
+ (0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
245
+ }
246
+ }
247
+ else {
248
+ (0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
249
+ }
250
+ }
251
+ }
252
+ return income;
253
+ }
254
+ exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
@@ -0,0 +1,8 @@
1
+ import { LiabilityPayload } from '../types/events/public-liability';
2
+ /**
3
+ * Generates a partial internal request from a liability event payload.
4
+ *
5
+ * @param liabilityPayload: A liability event payload.
6
+ * @return A partial InternalRequest.
7
+ */
8
+ export declare function generateLiability({ applicationId, id, liability }: LiabilityPayload): {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.generateLiability = void 0;
4
+ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
+ var lodash_1 = require("lodash");
6
+ var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
7
+ var liability_payment_type_1 = require("../types/enum-mappings/liability-payment-type");
8
+ var liability_type_1 = require("../types/enum-mappings/liability-type");
9
+ var get_financial_institution_1 = require("../utils/get-financial-institution");
10
+ var round_decimal_1 = require("../utils/round-decimal");
11
+ var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
12
+ var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
13
+ /**
14
+ * Generates a partial internal request from a liability event payload.
15
+ *
16
+ * @param liabilityPayload: A liability event payload.
17
+ * @return A partial InternalRequest.
18
+ */
19
+ function generateLiability(_a) {
20
+ var applicationId = _a.applicationId, id = _a.id, liability = _a.liability;
21
+ var partialApplication = {};
22
+ var liabilityMapping = {
23
+ applicationId: application_paths_1.paths.ApplicationId,
24
+ annualInterestRate: "".concat(application_paths_1.paths.Liability, ".@AnnualInterestRate"),
25
+ id: "".concat(application_paths_1.paths.Liability, ".@UniqueID"),
26
+ clearingFromThisLoan: "".concat(application_paths_1.paths.Liability, ".@ClearingFromThisLoan"),
27
+ description: "".concat(application_paths_1.paths.Liability, ".@Description"),
28
+ financialInstitution: "".concat(application_paths_1.paths.Liability, ".AccountNumber.@FinancialInstitution"),
29
+ newLimit: "".concat(application_paths_1.paths.Liability, ".@CreditLimit"),
30
+ repaymentAmount: "".concat(application_paths_1.paths.Liability, ".Repayment[0].@RepaymentAmount"),
31
+ repaymentFrequency: "".concat(application_paths_1.paths.Liability, ".Repayment[0].@RepaymentFrequency"),
32
+ remainingTermDuration: "".concat(application_paths_1.paths.Liability, ".RemainingTerm.@Duration"),
33
+ repaymentTypeDetails: "".concat(application_paths_1.paths.Liability, ".Repayment[0].@PaymentType"),
34
+ outstandingBalance: "".concat(application_paths_1.paths.Liability, ".@OutstandingBalance"),
35
+ type: "".concat(application_paths_1.paths.Liability, ".@Type"),
36
+ percentOwned: "".concat(application_paths_1.paths.Liability, ".PercentOwned")
37
+ };
38
+ (0, lodash_1.set)(partialApplication, liabilityMapping.applicationId, applicationId);
39
+ (0, lodash_1.set)(partialApplication, liabilityMapping.id, id);
40
+ // Default repayments to 0 and repaymentFrequency to weekly.
41
+ (0, lodash_1.set)(partialApplication, liabilityMapping.repaymentAmount, 0);
42
+ (0, lodash_1.set)(partialApplication, liabilityMapping.repaymentFrequency, lixi_internal_request_1.List.Weekly);
43
+ // Default clearingFromThisLoan to No if the value is not present in the event.
44
+ (0, lodash_1.set)(partialApplication, liabilityMapping.clearingFromThisLoan, lixi_internal_request_1.YesNoList.No);
45
+ for (var _i = 0, _b = Object.entries(liability); _i < _b.length; _i++) {
46
+ var _c = _b[_i], key = _c[0], value = _c[1];
47
+ if (liabilityMapping[key]) {
48
+ switch (key) {
49
+ case 'outstandingBalance':
50
+ case 'newLimit':
51
+ case 'repaymentAmount':
52
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], (0, round_decimal_1.roundDecimal)(value));
53
+ break;
54
+ case 'type':
55
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], liability_type_1.liabilityTypeMapping[value]);
56
+ break;
57
+ case 'clearingFromThisLoan':
58
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
59
+ break;
60
+ case 'repaymentFrequency':
61
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], alieo_frequency_1.liabilityFrequencyMapping[value]);
62
+ break;
63
+ case 'repaymentTypeDetails':
64
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], liability_payment_type_1.liabilityPaymentTypeMapping[value]);
65
+ break;
66
+ case 'remainingTermDuration':
67
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], Math.round(+value));
68
+ break;
69
+ case 'financialInstitution':
70
+ var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
71
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], financialInstitution);
72
+ break;
73
+ case 'percentOwned':
74
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
75
+ if (percentOwned) {
76
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], percentOwned);
77
+ }
78
+ break;
79
+ default:
80
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], value);
81
+ break;
82
+ }
83
+ }
84
+ }
85
+ return partialApplication;
86
+ }
87
+ exports.generateLiability = generateLiability;
@@ -0,0 +1,9 @@
1
+ import { PercentOwned } from '../types/events/public-liability';
2
+ import { PercentOwned as LIXIPercentOwned } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
3
+ /**
4
+ * Transform percentOwned to lixi's format.
5
+ *
6
+ * @param percentOwned PercentOwned for an asset or liability on public liability event.
7
+ * @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
8
+ */
9
+ export declare function generateLIXIPercentOwned({ owners }: PercentOwned): LIXIPercentOwned;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.generateLIXIPercentOwned = void 0;
4
+ /**
5
+ * Transform percentOwned to lixi's format.
6
+ *
7
+ * @param percentOwned PercentOwned for an asset or liability on public liability event.
8
+ * @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
9
+ */
10
+ function generateLIXIPercentOwned(_a) {
11
+ var _b = _a.owners, owners = _b === void 0 ? [] : _b;
12
+ if (owners.length === 0)
13
+ return null;
14
+ return {
15
+ Owner: owners.map(function (_a) {
16
+ var percent = _a.percent, applicantId = _a.applicantId;
17
+ return ({
18
+ '@Percent': percent * 100,
19
+ '@x_Party': applicantId
20
+ });
21
+ })
22
+ };
23
+ }
24
+ exports.generateLIXIPercentOwned = generateLIXIPercentOwned;
@@ -0,0 +1,8 @@
1
+ import { PayloadObject as OpportunityPayload } from '../types/events/opportunity';
2
+ /**
3
+ * Generates a partial internal request from a partial opportunity event.
4
+ *
5
+ * @param opportunity: Partial opportunity event.
6
+ * @return partialApplication: A partial internal request.
7
+ */
8
+ export declare function generateOpportunity(opportunity: OpportunityPayload): {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.generateOpportunity = void 0;
4
+ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
+ var lodash_1 = require("lodash");
6
+ /**
7
+ * Generates a partial internal request from a partial opportunity event.
8
+ *
9
+ * @param opportunity: Partial opportunity event.
10
+ * @return partialApplication: A partial internal request.
11
+ */
12
+ function generateOpportunity(opportunity) {
13
+ var partialApplication = {};
14
+ var opportunityMapping = {
15
+ id: application_paths_1.paths.ApplicationId,
16
+ stage: application_paths_1.paths.Instructions
17
+ };
18
+ for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
19
+ var _b = _a[_i], key = _b[0], value = _b[1];
20
+ if (opportunityMapping[key]) {
21
+ if (key === 'stage') {
22
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
23
+ (0, lodash_1.set)(partialApplication, "".concat(opportunityMapping[key], ".@Details"), value || 'Unknown');
24
+ }
25
+ else {
26
+ (0, lodash_1.set)(partialApplication, opportunityMapping[key], value);
27
+ }
28
+ }
29
+ }
30
+ return partialApplication;
31
+ }
32
+ exports.generateOpportunity = generateOpportunity;
@@ -0,0 +1,8 @@
1
+ import { Payload as RequiredDocumentPayload } from '../types/events/public-required-document';
2
+ /**
3
+ * Generates a partial internal request from a partial required document event.
4
+ *
5
+ * @param requiredDocument: A partial required document event.
6
+ * @return A partial InternalRequest.
7
+ */
8
+ export declare function generateRequiredDocument(requiredDocument: RequiredDocumentPayload): {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.generateRequiredDocument = void 0;
4
+ var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
+ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
+ var date_fns_1 = require("date-fns");
7
+ var lodash_1 = require("lodash");
8
+ var proof_of_identity_1 = require("../types/enum-mappings/proof-of-identity");
9
+ var title_gender_1 = require("../types/enum-mappings/title-gender");
10
+ var public_required_document_1 = require("../types/events/public-required-document");
11
+ /**
12
+ * Generates a partial internal request from a partial required document event.
13
+ *
14
+ * @param requiredDocument: A partial required document event.
15
+ * @return A partial InternalRequest.
16
+ */
17
+ function generateRequiredDocument(requiredDocument) {
18
+ var partialApplication = {};
19
+ var requiredDocsMapping = {
20
+ applicantId: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
21
+ applicationId: application_paths_1.paths.ApplicationId,
22
+ eConsent: application_paths_1.paths.Privacy,
23
+ identification: application_paths_1.paths.ProofOfIdentity
24
+ };
25
+ for (var _i = 0, _a = Object.entries(requiredDocument); _i < _a.length; _i++) {
26
+ var _b = _a[_i], key = _b[0], value = _b[1];
27
+ if (requiredDocsMapping[key]) {
28
+ switch (key) {
29
+ case 'identification':
30
+ var _c = value, idType = _c.idType, idNumber = _c.idNumber, _d = _c.idTitle, idTitle = _d === void 0 ? public_required_document_1.IDTitle.Unknown : _d, gender = _c.gender;
31
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.ProofOfIdentity, ".@DocumentType"), proof_of_identity_1.proofOfIdentityMapping[idType]);
32
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.ProofOfIdentity, ".@DocumentNumber"), idNumber);
33
+ if (gender) {
34
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@Gender"), (0, lodash_1.capitalize)(gender));
35
+ }
36
+ else {
37
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@Gender"), title_gender_1.titleGenderMapping[idTitle]);
38
+ }
39
+ break;
40
+ case 'eConsent':
41
+ var _e = requiredDocument.eConsent.consentedAt, consentedAt = _e === void 0 ? new Date() : _e;
42
+ var hasValidConsent = requiredDocument.status === public_required_document_1.Status.Verified ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No;
43
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Privacy, ".@CreditAuthoritySigned"), hasValidConsent);
44
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Privacy, ".@DateSigned"), (0, date_fns_1.format)(new Date(consentedAt), 'yyyy-MM-dd'));
45
+ break;
46
+ default:
47
+ (0, lodash_1.set)(partialApplication, requiredDocsMapping[key], value);
48
+ break;
49
+ }
50
+ }
51
+ }
52
+ return partialApplication;
53
+ }
54
+ exports.generateRequiredDocument = generateRequiredDocument;
@@ -0,0 +1,33 @@
1
+ import { YesNoList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { Contact, Dependant, Payload as ApplicantPayload } from '../types/events/public-applicant';
3
+ export declare const booleanMapping: (input?: boolean) => YesNoList;
4
+ /**
5
+ * Transforms a partial Applicant event to a partial LIXI application.
6
+ *
7
+ * @param applicant: A partial applicant.
8
+ * @return partialApplication an incomplete application.
9
+ */
10
+ export declare function transformApplicant(applicant: ApplicantPayload): {};
11
+ /**
12
+ * Generates a LIXI contact from given contact.
13
+ *
14
+ * @param contact
15
+ * @param id
16
+ */
17
+ export declare function generateContact(contact: Contact, id: string): {
18
+ lixiContact: {};
19
+ lixiAddresses: any[];
20
+ };
21
+ /**
22
+ * Generate dependants
23
+ *
24
+ * @param dependants
25
+ * @param id
26
+ */
27
+ export declare function generateDependants(dependants: Dependant[], id: string): {
28
+ '@Age': number;
29
+ '@UniqueID': string;
30
+ FinancialProvider: {
31
+ '@x_Party': string;
32
+ }[];
33
+ }[];