@lendi/integrations-transform 1.0.8 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +141 -140
  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 +7 -4
  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 +83 -0
  36. package/lib/utils/is-income-type.js +166 -0
  37. package/lib/utils/normalise-date.js +1 -1
  38. package/package.json +3 -6
@@ -1,27 +1,28 @@
1
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
+ };
2
13
  var _a;
3
14
  exports.__esModule = true;
4
- exports.createRentalIncome = exports.getEmploymentIdForIncome = exports.containsEmploymentId = exports.getApplicantIdForEmploymentId = exports.generateIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.EmploymentIncomeTypeMapping = void 0;
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");
5
17
  var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
18
  var lodash_1 = require("lodash");
7
- var logger_1 = require("../logger");
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");
8
22
  var public_income_1 = require("../types/events/public-income");
9
23
  var round_decimal_1 = require("../utils/round-decimal");
10
- var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
11
24
  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
+ var is_income_type_1 = require("../utils/is-income-type");
25
26
  var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
26
27
  var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
27
28
  // Income types mapping from internal to LIXI types /paths.
@@ -58,30 +59,44 @@ exports.EmploymentIncomeTypeMapping = (_a = {},
58
59
  amount: 'Income.@GrossRegularOvertimeAmount',
59
60
  frequency: 'Income.@GrossRegularOvertimeFrequency'
60
61
  },
61
- _a[public_income_1.IncomeType.SelfEmployedBusinessIncome] = {
62
- amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
63
- },
64
62
  _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;
63
+ function getIncomeMapping(incomeType, basePath) {
64
+ if (basePath === void 0) { basePath = application_paths_1.paths.PAYG; }
65
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
66
+ return {
67
+ assetId: "".concat(basePath, ".@UniqueID"),
68
+ percentOwned: "".concat(basePath, ".RentalIncome")
69
+ };
70
+ }
71
+ if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
72
+ return {
73
+ companyId: "".concat(basePath, ".@UniqueID"),
74
+ incomes: "".concat(basePath, ".IncomeRecent"),
75
+ incomeRecent: "".concat(basePath, ".IncomeRecent"),
76
+ incomePrevious: "".concat(basePath, ".IncomePrevious"),
77
+ gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
78
+ };
79
+ }
80
+ if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
81
+ var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
82
+ var mapping = {
83
+ amount: "".concat(basePath, ".").concat(amount),
84
+ employmentId: "".concat(basePath, ".@UniqueID")
85
+ };
86
+ if (frequency) {
87
+ mapping.frequency = "".concat(basePath, ".").concat(frequency);
88
+ }
89
+ return mapping;
90
+ }
91
+ return {
92
+ amount: "".concat(basePath, ".@Amount"),
93
+ frequency: "".concat(basePath, ".@Frequency"),
94
+ percentOwned: "".concat(basePath, ".PercentOwned"),
95
+ type: "".concat(basePath, ".@Type"),
96
+ benefitType: "".concat(basePath, ".@GovernmentBenefitsType")
97
+ };
83
98
  }
84
- exports.isRentalIncome = isRentalIncome;
99
+ exports.getIncomeMapping = getIncomeMapping;
85
100
  /**
86
101
  * Generates an partial application from a partial income event.
87
102
  *
@@ -91,56 +106,33 @@ exports.isRentalIncome = isRentalIncome;
91
106
  */
92
107
  function generateIncome(payload, storedApplication) {
93
108
  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
109
  var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
100
110
  var partialApplication = {};
101
- var incomeMapping;
102
111
  (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);
105
- }
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
- });
112
+ if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
113
+ var applicants = (0, lodash_1.get)(storedApplication, application_paths_1.paths.PersonApplicants);
114
+ var applicantId = (0, is_income_type_1.getApplicantId)(income, applicants);
115
+ if (applicantId) {
116
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
117
+ }
110
118
  }
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
- };
119
+ var incomeMapping;
120
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
121
+ incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.RealEstateAsset);
118
122
  }
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
- };
123
+ else if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
124
+ incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.PAYG);
125
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
- };
126
+ else if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
127
+ var basePath = 'Package.Content.Application.CompanyApplicant[0]';
128
+ incomeMapping = getIncomeMapping(incomeType, basePath);
131
129
  }
132
130
  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
- };
131
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
132
+ incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.OtherIncome);
141
133
  }
142
- for (var _i = 0, _b = Object.entries(income); _i < _b.length; _i++) {
143
- var _c = _b[_i], key = _c[0], value = _c[1];
134
+ for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
135
+ var _b = _a[_i], key = _b[0], value = _b[1];
144
136
  if (incomeMapping[key]) {
145
137
  switch (key) {
146
138
  case 'amount':
@@ -151,27 +143,36 @@ function generateIncome(payload, storedApplication) {
151
143
  (0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
152
144
  break;
153
145
  case 'percentOwned':
154
- var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
155
- if (isRentalIncome(incomeType)) {
156
- percentOwned = createRentalIncome(value, incomeAmount, incomeFrequency);
146
+ var ownership = value;
147
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(ownership);
148
+ if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
149
+ percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
157
150
  }
158
151
  if (percentOwned) {
159
152
  (0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
160
153
  }
161
154
  break;
162
155
  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);
156
+ if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
157
+ var mappedType = income_type_1.otherIncomeMapping[value];
158
+ if ((0, is_income_type_1.isOtherIncome)(value)) {
159
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
160
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
161
+ }
162
+ else {
163
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
164
+ }
170
165
  }
171
166
  break;
172
167
  case 'benefitType':
173
168
  (0, lodash_1.set)(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
174
169
  break;
170
+ case 'incomes':
171
+ var sortedIncomeList = value
172
+ .sort(is_income_type_1.sortBusinessIncome)
173
+ .map(generateIncomeBusinessDetails);
174
+ (0, lodash_1.set)(partialApplication, 'Package.Content.Application.CompanyApplicant[0].Income', sortedIncomeList);
175
+ break;
175
176
  default:
176
177
  (0, lodash_1.set)(partialApplication, incomeMapping[key], value);
177
178
  break;
@@ -181,67 +182,67 @@ function generateIncome(payload, storedApplication) {
181
182
  return partialApplication;
182
183
  }
183
184
  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
185
  /**
225
186
  * Creates Rental Income array.
226
- * @param owners List of owners.
227
187
  * @param amount Amount
228
188
  * @param frequency Frequency
189
+ * @param ownership Owners.
229
190
  */
230
- function createRentalIncome(_a, amount, frequency) {
231
- var _b = _a.owners, owners = _b === void 0 ? [] : _b;
232
- if (owners.length === 0)
233
- return null;
191
+ function createRentalIncome(amount, frequency, ownership) {
234
192
  if (frequency === public_income_1.Frequency.Quarterly) {
235
193
  amount = Math.ceil(amount / 3);
236
194
  frequency = public_income_1.Frequency.Monthly;
237
195
  }
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,
196
+ var rentalIncome = [];
197
+ for (var _i = 0, ownership_1 = ownership; _i < ownership_1.length; _i++) {
198
+ var owner = ownership_1[_i];
199
+ var percent = owner.percent, applicantId = owner.applicantId;
200
+ var ownerAmount = amount * percent;
201
+ rentalIncome.push({
202
+ '@Frequency': alieo_frequency_1.rentalIncomeFrequencyMapping[frequency],
203
+ '@RentalAmount': ownerAmount,
243
204
  '@x_Owner': applicantId
244
205
  });
245
- });
206
+ }
207
+ return rentalIncome;
246
208
  }
247
209
  exports.createRentalIncome = createRentalIncome;
210
+ var selfEmploymentIncomeMapping = {
211
+ year: '@StartDate',
212
+ companyProfitBeforeTax: '@CompanyProfitBeforeTax',
213
+ addback: {
214
+ depreciation: 'Addback.@Depreciation',
215
+ interest: 'Addback.@Interest',
216
+ lease: 'Addback.@Lease',
217
+ nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
218
+ other: 'Addback.@Other',
219
+ salary: 'Addback.@Salary',
220
+ superannuationExcess: 'Addback.@SuperannuationExcess'
221
+ },
222
+ nonRecurringIncome: 'NonRecurringIncome[0].@Amount'
223
+ };
224
+ /**
225
+ * @description Transform a Self Employed Income Details to LIXI
226
+ * @param data Financial Year Income Details for Self Employed Income.
227
+ * @returns {IncomeRecent} LIXI Income for the Self Employed.
228
+ */
229
+ function generateIncomeBusinessDetails(data) {
230
+ var income = {};
231
+ var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
232
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
233
+ var _b = _a[_i], key = _b[0], value = _b[1];
234
+ if (selfEmploymentIncomeMapping[key] != null) {
235
+ if (key === 'addback') {
236
+ for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
237
+ var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
238
+ (0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
239
+ }
240
+ }
241
+ else {
242
+ (0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
243
+ }
244
+ }
245
+ }
246
+ return income;
247
+ }
248
+ 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]) {
@@ -29,7 +29,10 @@ exports.otherCommitmentExpenseTypes = [
29
29
  */
30
30
  function transformExpenses(expense) {
31
31
  var partialApplication = {};
32
- var applicantId = expense.applicantId, applicationId = expense.applicationId, expenses = expense.expenses, id = expense.id;
32
+ var applicantId = expense.applicantId, applicationId = expense.applicationId, _a = expense.expenses, expenses = _a === void 0 ? [] : _a, id = expense.id;
33
+ if (expenses.every(function (expense) { return expense.amount === undefined || expense.amount === null; })) {
34
+ return partialApplication;
35
+ }
33
36
  var normalisedExpenses = expenses.map(normaliseExpenseAmount);
34
37
  var livingExpenseEstimate = normalisedExpenses.find(isLivingExpenseEstimate);
35
38
  var otherCommitments = normalisedExpenses.filter(isOtherCommitment);
@@ -49,8 +52,8 @@ function transformExpenses(expense) {
49
52
  }
50
53
  var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
51
54
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
52
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
53
- (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);
54
57
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
55
58
  if (lixiLivingExpenses.length > 0) {
56
59
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
@@ -71,7 +74,7 @@ function transformExpense(expense, applicantId, index, id) {
71
74
  '@Amount': expense.amount,
72
75
  '@Category': living_expense_1.livingExpenseMapping[expense.type],
73
76
  '@Description': expense.type,
74
- '@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),
75
78
  '@Frequency': expense_frequency_1.frequencyMapping[expense.frequency],
76
79
  PercentResponsible: {
77
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>;