@lendi/integrations-transform 1.1.0 → 1.1.5

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 (38) hide show
  1. package/lib/schemas/public-income-event.json +99 -1
  2. package/lib/transform-events/generate-asset-liability-link.js +2 -2
  3. package/lib/transform-events/generate-asset.js +32 -32
  4. package/lib/transform-events/generate-credit-report-rebuilt.js +1 -1
  5. package/lib/transform-events/generate-employment.js +17 -17
  6. package/lib/transform-events/generate-funding-position.js +6 -6
  7. package/lib/transform-events/generate-income.d.ts +20 -32
  8. package/lib/transform-events/generate-income.js +145 -146
  9. package/lib/transform-events/generate-liability.js +13 -13
  10. package/lib/transform-events/generate-lixi-percentowned.d.ts +3 -6
  11. package/lib/transform-events/generate-lixi-percentowned.js +1 -0
  12. package/lib/transform-events/generate-opportunity.js +2 -2
  13. package/lib/transform-events/generate-required-document.js +7 -7
  14. package/lib/transform-events/transform-applicant.js +21 -21
  15. package/lib/transform-events/transform-application.js +4 -4
  16. package/lib/transform-events/transform-expenses.js +3 -3
  17. package/lib/types/enum-mappings/alieo-frequency.d.ts +6 -3
  18. package/lib/types/enum-mappings/alieo-frequency.js +8 -2
  19. package/lib/types/events/applicant-delete.d.ts +42 -0
  20. package/lib/types/events/applicant-delete.js +15 -0
  21. package/lib/types/events/asset-delete.d.ts +33 -0
  22. package/lib/types/events/asset-delete.js +15 -0
  23. package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
  24. package/lib/types/events/asset-liability-relation-delete.js +15 -0
  25. package/lib/types/events/employment-delete.d.ts +19 -0
  26. package/lib/types/events/employment-delete.js +7 -0
  27. package/lib/types/events/expense-delete.d.ts +21 -0
  28. package/lib/types/events/expense-delete.js +7 -0
  29. package/lib/types/events/income-delete.d.ts +33 -0
  30. package/lib/types/events/income-delete.js +15 -0
  31. package/lib/types/events/liability-delete.d.ts +17 -0
  32. package/lib/types/events/liability-delete.js +7 -0
  33. package/lib/types/events/public-income.d.ts +37 -3
  34. package/lib/types/events/public-income.js +2 -0
  35. package/lib/utils/is-income-type.d.ts +72 -0
  36. package/lib/utils/is-income-type.js +138 -0
  37. package/lib/utils/normalise-date.js +1 -1
  38. package/package.json +2 -2
@@ -1,27 +1,39 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
2
24
  var _a;
3
25
  exports.__esModule = true;
4
- exports.createRentalIncome = exports.getEmploymentIdForIncome = exports.containsEmploymentId = exports.getApplicantIdForEmploymentId = exports.generateIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.EmploymentIncomeTypeMapping = void 0;
5
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
26
+ exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
27
+ var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
28
+ var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
6
29
  var lodash_1 = require("lodash");
7
- var logger_1 = require("../logger");
30
+ var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
31
+ var government_benefits_1 = require("../types/enum-mappings/government-benefits");
32
+ var income_type_1 = require("../types/enum-mappings/income-type");
8
33
  var public_income_1 = require("../types/events/public-income");
34
+ var is_income_type_1 = require("../utils/is-income-type");
9
35
  var round_decimal_1 = require("../utils/round-decimal");
10
- var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
11
36
  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
- var income_type_1 = require("../types/enum-mappings/income-type");
14
- var government_benefits_1 = require("../types/enum-mappings/government-benefits");
15
- var PAYGList = [
16
- public_income_1.IncomeType.PaygAllowancesNotTaxed,
17
- public_income_1.IncomeType.PaygAllowancesTaxed,
18
- public_income_1.IncomeType.PaygBaseSalary,
19
- public_income_1.IncomeType.PaygBonusIncome,
20
- public_income_1.IncomeType.PaygCarAllowance,
21
- public_income_1.IncomeType.PaygCommissionIncome,
22
- public_income_1.IncomeType.PaygCompanyCar,
23
- public_income_1.IncomeType.PaygOvertimeIncome,
24
- ];
25
37
  var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
26
38
  var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
27
39
  // Income types mapping from internal to LIXI types /paths.
@@ -58,30 +70,46 @@ exports.EmploymentIncomeTypeMapping = (_a = {},
58
70
  amount: 'Income.@GrossRegularOvertimeAmount',
59
71
  frequency: 'Income.@GrossRegularOvertimeFrequency'
60
72
  },
61
- _a[public_income_1.IncomeType.SelfEmployedBusinessIncome] = {
62
- amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
63
- },
64
73
  _a);
65
- var descriptionOtherIncomeTypes = [
66
- public_income_1.IncomeType.InvestmentIncome,
67
- public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
68
- public_income_1.IncomeType.RentalIncome,
69
- ];
70
- // Check if given income type is a PAYG income type.
71
- function isPaygIncome(incomeType) {
72
- return PAYGList.includes(incomeType);
73
- }
74
- exports.isPaygIncome = isPaygIncome;
75
- // Check if given income type is a self employment income type.
76
- function isSelfEmployedIncome(incomeType) {
77
- return incomeType === public_income_1.IncomeType.SelfEmployedBusinessIncome;
78
- }
79
- exports.isSelfEmployedIncome = isSelfEmployedIncome;
80
- // Check if given income type is a rental income type.
81
- function isRentalIncome(incomeType) {
82
- return incomeType === public_income_1.IncomeType.RentalIncome;
74
+ function getIncomeMapping(incomeType) {
75
+ var basePath = application_paths_1.paths.OtherIncome;
76
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
77
+ basePath = application_paths_1.paths.RealEstateAsset;
78
+ return {
79
+ assetId: "".concat(basePath, ".@UniqueID"),
80
+ percentOwned: "".concat(basePath, ".RentalIncome")
81
+ };
82
+ }
83
+ if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
84
+ basePath = application_paths_1.paths.CompanyApplicant;
85
+ return {
86
+ companyId: "".concat(basePath, ".@UniqueID"),
87
+ incomes: "".concat(basePath, ".Income"),
88
+ gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
89
+ };
90
+ }
91
+ if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
92
+ basePath = application_paths_1.paths.SelfEmployed;
93
+ var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
94
+ return {
95
+ amount: "".concat(basePath, ".").concat(amount),
96
+ employmentId: "".concat(basePath, ".@UniqueID")
97
+ };
98
+ }
99
+ if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
100
+ basePath = application_paths_1.paths.PAYG;
101
+ var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
102
+ return __assign({ amount: "".concat(basePath, ".").concat(amount), employmentId: "".concat(basePath, ".@UniqueID") }, (frequency && { frequency: "".concat(basePath, ".").concat(frequency) }));
103
+ }
104
+ return {
105
+ amount: "".concat(basePath, ".@Amount"),
106
+ frequency: "".concat(basePath, ".@Frequency"),
107
+ percentOwned: "".concat(basePath, ".PercentOwned"),
108
+ type: "".concat(basePath, ".@Type"),
109
+ benefitType: "".concat(basePath, ".@GovernmentBenefitsType")
110
+ };
83
111
  }
84
- exports.isRentalIncome = isRentalIncome;
112
+ exports.getIncomeMapping = getIncomeMapping;
85
113
  /**
86
114
  * Generates an partial application from a partial income event.
87
115
  *
@@ -89,58 +117,20 @@ exports.isRentalIncome = isRentalIncome;
89
117
  * @param storedApplication: Current state of the application.
90
118
  * @return partialApplication an incomplete application.
91
119
  */
92
- function generateIncome(payload, storedApplication) {
120
+ function generateIncome(payload, applicantId) {
93
121
  var applicationId = payload.applicationId, id = payload.id, income = payload.income;
94
- var applicantId = (0, lodash_1.get)(income, 'percentOwned.owners[0].applicantId');
95
- if (!applicantId) {
96
- var employmentId = getEmploymentIdForIncome(payload);
97
- applicantId = getApplicantIdForEmploymentId(storedApplication, employmentId);
98
- }
99
122
  var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
100
123
  var partialApplication = {};
101
- var incomeMapping;
102
124
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
103
- if (applicantId && !isRentalIncome(incomeType)) {
104
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
125
+ if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
126
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
105
127
  }
106
- else {
107
- logger_1.logger.warn({
108
- message: "No applicantId found for income event with id : " + id + " and type " + incomeType + " for application: " + applicationId
109
- });
128
+ if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
129
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
110
130
  }
111
- if (isPaygIncome(incomeType)) {
112
- var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
113
- incomeMapping = {
114
- amount: application_paths_1.paths.PAYG + "." + amount,
115
- frequency: application_paths_1.paths.PAYG + "." + frequency,
116
- employmentId: application_paths_1.paths.PAYG + ".@UniqueID"
117
- };
118
- }
119
- else if (isSelfEmployedIncome(incomeType)) {
120
- var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
121
- incomeMapping = {
122
- amount: application_paths_1.paths.SelfEmployed + "." + amount,
123
- employmentId: application_paths_1.paths.SelfEmployed + ".@UniqueID"
124
- };
125
- }
126
- else if (isRentalIncome(incomeType)) {
127
- incomeMapping = {
128
- assetId: application_paths_1.paths.RealEstateAsset + ".@UniqueID",
129
- percentOwned: application_paths_1.paths.RealEstateAsset + ".RentalIncome"
130
- };
131
- }
132
- else {
133
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome + ".@UniqueID", id);
134
- incomeMapping = {
135
- amount: application_paths_1.paths.OtherIncome + ".@Amount",
136
- frequency: application_paths_1.paths.OtherIncome + ".@Frequency",
137
- percentOwned: application_paths_1.paths.OtherIncome + ".PercentOwned",
138
- type: application_paths_1.paths.OtherIncome + ".@Type",
139
- benefitType: application_paths_1.paths.OtherIncome + ".@GovernmentBenefitsType"
140
- };
141
- }
142
- for (var _i = 0, _b = Object.entries(income); _i < _b.length; _i++) {
143
- var _c = _b[_i], key = _c[0], value = _c[1];
131
+ var incomeMapping = getIncomeMapping(incomeType);
132
+ for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
133
+ var _b = _a[_i], key = _b[0], value = _b[1];
144
134
  if (incomeMapping[key]) {
145
135
  switch (key) {
146
136
  case 'amount':
@@ -151,27 +141,36 @@ function generateIncome(payload, storedApplication) {
151
141
  (0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
152
142
  break;
153
143
  case 'percentOwned':
154
- var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
155
- if (isRentalIncome(incomeType)) {
156
- percentOwned = createRentalIncome(value, incomeAmount, incomeFrequency);
144
+ var ownership = value;
145
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(ownership);
146
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
147
+ percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
157
148
  }
158
149
  if (percentOwned) {
159
150
  (0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
160
151
  }
161
152
  break;
162
153
  case 'type':
163
- var mappedType = income_type_1.otherIncomeMapping[value];
164
- if (descriptionOtherIncomeTypes.includes(value)) {
165
- (0, lodash_1.set)(partialApplication, 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);
154
+ if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
155
+ var mappedType = income_type_1.otherIncomeMapping[value];
156
+ if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
157
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
158
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
159
+ }
160
+ else {
161
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
162
+ }
170
163
  }
171
164
  break;
172
165
  case 'benefitType':
173
166
  (0, lodash_1.set)(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
174
167
  break;
168
+ case 'incomes':
169
+ var sortedIncomeList = value
170
+ .sort(is_income_type_1.sortBusinessIncome)
171
+ .map(generateIncomeBusinessDetails);
172
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], sortedIncomeList);
173
+ break;
175
174
  default:
176
175
  (0, lodash_1.set)(partialApplication, incomeMapping[key], value);
177
176
  break;
@@ -181,67 +180,67 @@ function generateIncome(payload, storedApplication) {
181
180
  return partialApplication;
182
181
  }
183
182
  exports.generateIncome = generateIncome;
184
- /**
185
- * Gets the applicant id if given employmentId belongs to it.
186
- *
187
- * @param application
188
- * @param employmentId
189
- */
190
- function getApplicantIdForEmploymentId(application, employmentId) {
191
- if (!employmentId || !application)
192
- return null;
193
- var applicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
194
- var applicant = applicants.find(function (applicant) { return containsEmploymentId(applicant, employmentId); });
195
- return applicant ? applicant['@UniqueID'] : null;
196
- }
197
- exports.getApplicantIdForEmploymentId = getApplicantIdForEmploymentId;
198
- /**
199
- * Checks if given employment id belongs to given applicant.
200
- *
201
- * @param applicant
202
- * @param employmentId
203
- */
204
- function containsEmploymentId(applicant, employmentId) {
205
- return (applicant.Employment || []).some(function (employment) {
206
- return (0, lodash_1.get)(employment, 'PAYG.@UniqueID') === employmentId ||
207
- (0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') === employmentId ||
208
- (0, lodash_1.get)(employment, 'NotEmployed.@UniqueID') === employmentId;
209
- });
210
- }
211
- exports.containsEmploymentId = containsEmploymentId;
212
- /**
213
- * Gets the employmentId if given income is employment income.
214
- *
215
- * @param payload
216
- */
217
- function getEmploymentIdForIncome(payload) {
218
- var _a = payload.income, incomeType = _a.type, employmentId = _a.employmentId;
219
- if (isPaygIncome(incomeType) || isSelfEmployedIncome(incomeType))
220
- return employmentId;
221
- return undefined;
222
- }
223
- exports.getEmploymentIdForIncome = getEmploymentIdForIncome;
224
183
  /**
225
184
  * Creates Rental Income array.
226
- * @param owners List of owners.
227
185
  * @param amount Amount
228
186
  * @param frequency Frequency
187
+ * @param ownership Owners.
229
188
  */
230
- function createRentalIncome(_a, amount, frequency) {
231
- var _b = _a.owners, owners = _b === void 0 ? [] : _b;
232
- if (owners.length === 0)
233
- return null;
189
+ function createRentalIncome(amount, frequency, ownership) {
234
190
  if (frequency === public_income_1.Frequency.Quarterly) {
235
191
  amount = Math.ceil(amount / 3);
236
192
  frequency = public_income_1.Frequency.Monthly;
237
193
  }
238
- return owners.map(function (_a) {
239
- var percent = _a.percent, applicantId = _a.applicantId;
240
- return ({
241
- '@Frequency': alieo_frequency_1.incomeExpenseFrequencyMapping[frequency],
242
- '@RentalIncome': percent * amount,
194
+ var rentalIncome = [];
195
+ for (var _i = 0, ownership_1 = ownership; _i < ownership_1.length; _i++) {
196
+ var owner = ownership_1[_i];
197
+ var percent = owner.percent, applicantId = owner.applicantId;
198
+ var ownerAmount = amount * percent;
199
+ rentalIncome.push({
200
+ '@Frequency': alieo_frequency_1.rentalIncomeFrequencyMapping[frequency],
201
+ '@RentalAmount': ownerAmount,
243
202
  '@x_Owner': applicantId
244
203
  });
245
- });
204
+ }
205
+ return rentalIncome;
246
206
  }
247
207
  exports.createRentalIncome = createRentalIncome;
208
+ var selfEmploymentIncomeMapping = {
209
+ year: '@StartDate',
210
+ companyProfitBeforeTax: '@CompanyProfitBeforeTax',
211
+ addback: {
212
+ depreciation: 'Addback.@Depreciation',
213
+ interest: 'Addback.@Interest',
214
+ lease: 'Addback.@Lease',
215
+ nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
216
+ other: 'Addback.@Other',
217
+ salary: 'Addback.@Salary',
218
+ superannuationExcess: 'Addback.@SuperannuationExcess'
219
+ },
220
+ nonRecurringIncome: 'NonRecurringIncome[0].@Amount'
221
+ };
222
+ /**
223
+ * @description Transform a Self Employed Income Details to LIXI
224
+ * @param data Financial Year Income Details for Self Employed Income.
225
+ * @returns {IncomeElement} LIXI Income for the Self Employed.
226
+ */
227
+ function generateIncomeBusinessDetails(data) {
228
+ var income = {};
229
+ var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
230
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
231
+ var _b = _a[_i], key = _b[0], value = _b[1];
232
+ if (selfEmploymentIncomeMapping[key] != null) {
233
+ if (key === 'addback') {
234
+ for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
235
+ var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
236
+ (0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
237
+ }
238
+ }
239
+ else {
240
+ (0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
241
+ }
242
+ }
243
+ }
244
+ return income;
245
+ }
246
+ exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
@@ -21,19 +21,19 @@ function generateLiability(_a) {
21
21
  var partialApplication = {};
22
22
  var liabilityMapping = {
23
23
  applicationId: application_paths_1.paths.ApplicationId,
24
- annualInterestRate: application_paths_1.paths.Liability + ".@AnnualInterestRate",
25
- id: application_paths_1.paths.Liability + ".@UniqueID",
26
- clearingFromThisLoan: application_paths_1.paths.Liability + ".@ClearingFromThisLoan",
27
- description: application_paths_1.paths.Liability + ".@Description",
28
- financialInstitution: application_paths_1.paths.Liability + ".AccountNumber.@FinancialInstitution",
29
- newLimit: application_paths_1.paths.Liability + ".@CreditLimit",
30
- repaymentAmount: application_paths_1.paths.Liability + ".Repayment[0].@RepaymentAmount",
31
- repaymentFrequency: application_paths_1.paths.Liability + ".Repayment[0].@RepaymentFrequency",
32
- remainingTermDuration: application_paths_1.paths.Liability + ".RemainingTerm.@Duration",
33
- repaymentTypeDetails: application_paths_1.paths.Liability + ".Repayment[0].@PaymentType",
34
- outstandingBalance: application_paths_1.paths.Liability + ".@OutstandingBalance",
35
- type: application_paths_1.paths.Liability + ".@Type",
36
- percentOwned: application_paths_1.paths.Liability + ".PercentOwned"
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
37
  };
38
38
  (0, lodash_1.set)(partialApplication, liabilityMapping.applicationId, applicationId);
39
39
  (0, lodash_1.set)(partialApplication, liabilityMapping.id, id);
@@ -1,12 +1,9 @@
1
1
  import { PercentOwned } from '../types/events/public-liability';
2
+ import { PercentOwned as LIXIPercentOwned } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
3
  /**
3
4
  * Transform percentOwned to lixi's format.
4
5
  *
5
6
  * @param percentOwned PercentOwned for an asset or liability on public liability event.
7
+ * @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
6
8
  */
7
- export declare function generateLIXIPercentOwned({ owners }: PercentOwned): {
8
- Owner: {
9
- '@Percent': number;
10
- '@x_Party': string;
11
- }[];
12
- };
9
+ export declare function generateLIXIPercentOwned({ owners }: PercentOwned): LIXIPercentOwned;
@@ -5,6 +5,7 @@ exports.generateLIXIPercentOwned = void 0;
5
5
  * Transform percentOwned to lixi's format.
6
6
  *
7
7
  * @param percentOwned PercentOwned for an asset or liability on public liability event.
8
+ * @returns {LIXIPercentOwned} transformed Lixi PercentOwned.
8
9
  */
9
10
  function generateLIXIPercentOwned(_a) {
10
11
  var _b = _a.owners, owners = _b === void 0 ? [] : _b;
@@ -19,8 +19,8 @@ function generateOpportunity(opportunity) {
19
19
  var _b = _a[_i], key = _b[0], value = _b[1];
20
20
  if (opportunityMapping[key]) {
21
21
  if (key === 'stage') {
22
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions + ".@UniqueID", opportunity.id + "-stage");
23
- (0, lodash_1.set)(partialApplication, opportunityMapping[key] + ".@Details", value || 'Unknown');
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
24
  }
25
25
  else {
26
26
  (0, lodash_1.set)(partialApplication, opportunityMapping[key], value);
@@ -17,7 +17,7 @@ var public_required_document_1 = require("../types/events/public-required-docume
17
17
  function generateRequiredDocument(requiredDocument) {
18
18
  var partialApplication = {};
19
19
  var requiredDocsMapping = {
20
- applicantId: application_paths_1.paths.PersonApplicant + ".@UniqueID",
20
+ applicantId: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
21
21
  applicationId: application_paths_1.paths.ApplicationId,
22
22
  eConsent: application_paths_1.paths.Privacy,
23
23
  identification: application_paths_1.paths.ProofOfIdentity
@@ -28,20 +28,20 @@ function generateRequiredDocument(requiredDocument) {
28
28
  switch (key) {
29
29
  case 'identification':
30
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, application_paths_1.paths.ProofOfIdentity + ".@DocumentType", proof_of_identity_1.proofOfIdentityMapping[idType]);
32
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.ProofOfIdentity + ".@DocumentNumber", idNumber);
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
33
  if (gender) {
34
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@Gender", (0, lodash_1.capitalize)(gender));
34
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@Gender"), (0, lodash_1.capitalize)(gender));
35
35
  }
36
36
  else {
37
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@Gender", title_gender_1.titleGenderMapping[idTitle]);
37
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@Gender"), title_gender_1.titleGenderMapping[idTitle]);
38
38
  }
39
39
  break;
40
40
  case 'eConsent':
41
41
  var _e = requiredDocument.eConsent.consentedAt, consentedAt = _e === void 0 ? new Date() : _e;
42
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, application_paths_1.paths.Privacy + ".@CreditAuthoritySigned", hasValidConsent);
44
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Privacy + ".@DateSigned", (0, date_fns_1.format)(new Date(consentedAt), 'yyyy-MM-dd'));
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
45
  break;
46
46
  default:
47
47
  (0, lodash_1.set)(partialApplication, requiredDocsMapping[key], value);
@@ -18,20 +18,20 @@ var booleanMapping = function (input) {
18
18
  exports.booleanMapping = booleanMapping;
19
19
  var applicantMapping = {
20
20
  applicationId: application_paths_1.paths.ApplicationId,
21
- citizenship: application_paths_1.paths.PersonApplicant + ".@Citizenship",
22
- contact: application_paths_1.paths.PersonApplicant + ".Contact",
21
+ citizenship: "".concat(application_paths_1.paths.PersonApplicant, ".@Citizenship"),
22
+ contact: "".concat(application_paths_1.paths.PersonApplicant, ".Contact"),
23
23
  dependants: 'dependants',
24
- dateOfBirth: application_paths_1.paths.PersonApplicant + ".@DateOfBirth",
25
- firstName: application_paths_1.paths.PersonApplicant + ".PersonName.@FirstName",
26
- id: application_paths_1.paths.PersonApplicant + ".@UniqueID",
27
- isFirstHomeBuyer: application_paths_1.paths.PersonApplicant + ".@FirstHomeBuyer",
28
- isPrimaryApplicant: application_paths_1.paths.PersonApplicant + ".@PrimaryApplicant",
29
- lastName: application_paths_1.paths.PersonApplicant + ".PersonName.@Surname",
30
- maritalStatus: application_paths_1.paths.PersonApplicant + ".@MaritalStatus",
31
- maritalDetails: application_paths_1.paths.PersonApplicant + ".MaritalStatusDetails.@x_Spouse",
32
- middleName: application_paths_1.paths.PersonApplicant + ".PersonName.@MiddleNames",
33
- residencyStatus: application_paths_1.paths.PersonApplicant + ".@ResidencyStatus",
34
- title: application_paths_1.paths.PersonName + ".@NameTitle"
24
+ dateOfBirth: "".concat(application_paths_1.paths.PersonApplicant, ".@DateOfBirth"),
25
+ firstName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@FirstName"),
26
+ id: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
27
+ isFirstHomeBuyer: "".concat(application_paths_1.paths.PersonApplicant, ".@FirstHomeBuyer"),
28
+ isPrimaryApplicant: "".concat(application_paths_1.paths.PersonApplicant, ".@PrimaryApplicant"),
29
+ lastName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@Surname"),
30
+ maritalStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@MaritalStatus"),
31
+ maritalDetails: "".concat(application_paths_1.paths.PersonApplicant, ".MaritalStatusDetails.@x_Spouse"),
32
+ middleName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@MiddleNames"),
33
+ residencyStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@ResidencyStatus"),
34
+ title: "".concat(application_paths_1.paths.PersonName, ".@NameTitle")
35
35
  };
36
36
  /**
37
37
  * Transforms a partial Applicant event to a partial LIXI application.
@@ -84,8 +84,8 @@ function transformApplicant(applicant) {
84
84
  break;
85
85
  case 'dependants':
86
86
  var dependants = generateDependants(value, applicantId);
87
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
88
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".Dependant", dependants);
87
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
88
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".Dependant"), dependants);
89
89
  break;
90
90
  default:
91
91
  (0, lodash_1.set)(partialApplication, applicantMapping[key], value);
@@ -120,7 +120,7 @@ function generateContact(contact, id) {
120
120
  switch (key) {
121
121
  case 'currentAddress':
122
122
  {
123
- var addressId = id + "-current";
123
+ var addressId = "".concat(id, "-current");
124
124
  var _c = (0, address_tools_1.rebuildAddress)(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
125
125
  lixiAddresses.push(lixiAddress);
126
126
  (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
@@ -128,7 +128,7 @@ function generateContact(contact, id) {
128
128
  break;
129
129
  case 'postSettlementAddress':
130
130
  {
131
- var addressId = id + "-postSettlement";
131
+ var addressId = "".concat(id, "-postSettlement");
132
132
  var _d = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
133
133
  lixiAddresses.push(lixiAddress);
134
134
  (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
@@ -136,7 +136,7 @@ function generateContact(contact, id) {
136
136
  break;
137
137
  case 'mailingAddress':
138
138
  {
139
- var addressId = id + "-mailing";
139
+ var addressId = "".concat(id, "-mailing");
140
140
  var lixiAddress = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId).lixiAddress;
141
141
  lixiAddresses.push(lixiAddress);
142
142
  (0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
@@ -144,7 +144,7 @@ function generateContact(contact, id) {
144
144
  break;
145
145
  case 'previousAddresses':
146
146
  {
147
- var addressId = id + "-previous";
147
+ var addressId = "".concat(id, "-previous");
148
148
  var previousAddresses = value.sort(function (lhs, rhs) {
149
149
  return lhs.endDate.localeCompare(rhs.endDate);
150
150
  });
@@ -154,9 +154,9 @@ function generateContact(contact, id) {
154
154
  (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
155
155
  // PriorAddresses
156
156
  previousAddresses.forEach(function (address, index) {
157
- var _a = (0, address_tools_1.rebuildAddress)(address, id + "-prior-" + index), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
157
+ var _a = (0, address_tools_1.rebuildAddress)(address, "".concat(id, "-prior-").concat(index)), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
158
158
  lixiAddresses.push(lixiAddress);
159
- (0, lodash_1.set)(lixiContact, contactMapping['priorAddress'] + "." + index, lixiContactAddress);
159
+ (0, lodash_1.set)(lixiContact, "".concat(contactMapping['priorAddress'], ".").concat(index), lixiContactAddress);
160
160
  });
161
161
  }
162
162
  break;
@@ -18,14 +18,14 @@ function transformApplication(opportunity) {
18
18
  var opportunityMapping = {
19
19
  brand: application_paths_1.paths.BusinessName,
20
20
  id: application_paths_1.paths.ApplicationId,
21
- paymentType: application_paths_1.paths.LoanTerm + ".@PaymentType",
21
+ paymentType: "".concat(application_paths_1.paths.LoanTerm, ".@PaymentType"),
22
22
  preliminary: 'preliminary',
23
23
  primaryPurpose: application_paths_1.paths.PurposeOfApplication,
24
24
  brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
25
25
  };
26
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail + ".@UniqueID", opportunity.id + "-loanDetails");
27
- (0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions + ".@UniqueID", opportunity.id + "-stage");
28
- (0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions + ".@Name", lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
26
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.LoanDetail, ".@UniqueID"), "".concat(opportunity.id, "-loanDetails"));
27
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
28
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.Instructions, ".@Name"), lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
29
29
  for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
30
30
  var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
31
31
  if (opportunityMapping[opportunityKey]) {
@@ -52,8 +52,8 @@ function transformExpenses(expense) {
52
52
  }
53
53
  var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
54
54
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
55
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
56
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
55
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
56
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
57
57
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
58
58
  if (lixiLivingExpenses.length > 0) {
59
59
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
@@ -74,7 +74,7 @@ function transformExpense(expense, applicantId, index, id) {
74
74
  '@Amount': expense.amount,
75
75
  '@Category': living_expense_1.livingExpenseMapping[expense.type],
76
76
  '@Description': expense.type,
77
- '@UniqueID': isOtherCommitment(expense) ? id + "-commitment-" + index : id + "-living-expense-" + index,
77
+ '@UniqueID': isOtherCommitment(expense) ? "".concat(id, "-commitment-").concat(index) : "".concat(id, "-living-expense-").concat(index),
78
78
  '@Frequency': expense_frequency_1.frequencyMapping[expense.frequency],
79
79
  PercentResponsible: {
80
80
  Owner: [
@@ -1,12 +1,15 @@
1
1
  import { List as LIXIFrequency } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
2
  import { RepaymentFrequency } from '../events/public-liability';
3
3
  import { Frequency } from '../events/public-income';
4
- declare type LiabilityFrequencyMapping = {
4
+ export declare type LiabilityFrequencyMapping = {
5
5
  [key in RepaymentFrequency]: LIXIFrequency;
6
6
  };
7
- declare type IncomeExpenseFrequencyMapping = {
7
+ export declare type IncomeExpenseFrequencyMapping = {
8
8
  [key in RepaymentFrequency | Frequency]: LIXIFrequency;
9
9
  };
10
+ export declare type RentalIncomeFrequencyMapping = {
11
+ [key in Frequency]: LIXIFrequency;
12
+ };
10
13
  export declare const incomeExpenseFrequencyMapping: IncomeExpenseFrequencyMapping;
11
14
  export declare const liabilityFrequencyMapping: LiabilityFrequencyMapping;
12
- export {};
15
+ export declare const rentalIncomeFrequencyMapping: Partial<RentalIncomeFrequencyMapping>;