@lendi/act-credit-decisions-transform 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +28 -0
- package/lib/logger.d.ts +1 -0
- package/lib/logger.js +5 -0
- package/lib/schemas/application-workflow-event.json +240 -0
- package/lib/schemas/credit-report-retrieved-event.json +57 -0
- package/lib/schemas/public-applicant-event.json +910 -0
- package/lib/schemas/public-application-event.json +250 -0
- package/lib/schemas/public-asset-event.json +679 -0
- package/lib/schemas/public-asset-liability-relation-delete-event.json +74 -0
- package/lib/schemas/public-asset-liability-relation-event.json +73 -0
- package/lib/schemas/public-create-applicant-event.json +609 -0
- package/lib/schemas/public-delete-applicant-event.json +66 -0
- package/lib/schemas/public-delete-asset-event.json +53 -0
- package/lib/schemas/public-delete-income-event.json +55 -0
- package/lib/schemas/public-employment-delete-event.json +31 -0
- package/lib/schemas/public-employment-event.json +278 -0
- package/lib/schemas/public-expense-delete-event.json +41 -0
- package/lib/schemas/public-expense-event.json +133 -0
- package/lib/schemas/public-funding-position-event.json +419 -0
- package/lib/schemas/public-income-event.json +242 -0
- package/lib/schemas/public-liability-delete-event.json +37 -0
- package/lib/schemas/public-liability-event.json +262 -0
- package/lib/schemas/public-required-document-event.json +366 -0
- package/lib/schemas/public-update-applicant-event.json +606 -0
- package/lib/schemas/sf-opportunity-event-out.json +138 -0
- package/lib/transform-events/generate-asset-liability-link.d.ts +10 -0
- package/lib/transform-events/generate-asset-liability-link.js +29 -0
- package/lib/transform-events/generate-credit-report-rebuilt.d.ts +8 -0
- package/lib/transform-events/generate-credit-report-rebuilt.js +41 -0
- package/lib/transform-events/transform-applicant.d.ts +8 -0
- package/lib/transform-events/transform-applicant.js +180 -0
- package/lib/transform-events/transform-application-workflow.d.ts +8 -0
- package/lib/transform-events/transform-application-workflow.js +30 -0
- package/lib/transform-events/transform-application.d.ts +20 -0
- package/lib/transform-events/transform-application.js +67 -0
- package/lib/transform-events/transform-asset-address.d.ts +25 -0
- package/lib/transform-events/transform-asset-address.js +87 -0
- package/lib/transform-events/transform-asset.d.ts +58 -0
- package/lib/transform-events/transform-asset.js +337 -0
- package/lib/transform-events/transform-employment.d.ts +9 -0
- package/lib/transform-events/transform-employment.js +107 -0
- package/lib/transform-events/transform-expenses.d.ts +41 -0
- package/lib/transform-events/transform-expenses.js +121 -0
- package/lib/transform-events/transform-funding-position.d.ts +21 -0
- package/lib/transform-events/transform-funding-position.js +107 -0
- package/lib/transform-events/transform-income.d.ts +48 -0
- package/lib/transform-events/transform-income.js +260 -0
- package/lib/transform-events/transform-liability.d.ts +12 -0
- package/lib/transform-events/transform-liability.js +117 -0
- package/lib/transform-events/transform-percent-owned.d.ts +10 -0
- package/lib/transform-events/transform-percent-owned.js +22 -0
- package/lib/transform-events/transform-required-document.d.ts +67 -0
- package/lib/transform-events/transform-required-document.js +148 -0
- package/lib/types/enum-mappings/alieo-frequency.d.ts +15 -0
- package/lib/types/enum-mappings/alieo-frequency.js +25 -0
- package/lib/types/enum-mappings/applicant-gender.d.ts +6 -0
- package/lib/types/enum-mappings/applicant-gender.js +11 -0
- package/lib/types/enum-mappings/applicant-type.d.ts +6 -0
- package/lib/types/enum-mappings/applicant-type.js +10 -0
- package/lib/types/enum-mappings/asset-type.d.ts +3 -0
- package/lib/types/enum-mappings/asset-type.js +17 -0
- package/lib/types/enum-mappings/builder-type.d.ts +7 -0
- package/lib/types/enum-mappings/builder-type.js +9 -0
- package/lib/types/enum-mappings/company-structure.d.ts +7 -0
- package/lib/types/enum-mappings/company-structure.js +10 -0
- package/lib/types/enum-mappings/company-type.d.ts +7 -0
- package/lib/types/enum-mappings/company-type.js +11 -0
- package/lib/types/enum-mappings/construction-type.d.ts +7 -0
- package/lib/types/enum-mappings/construction-type.js +10 -0
- package/lib/types/enum-mappings/country-code.d.ts +7 -0
- package/lib/types/enum-mappings/country-code.js +246 -0
- package/lib/types/enum-mappings/employment-basis.d.ts +7 -0
- package/lib/types/enum-mappings/employment-basis.js +12 -0
- package/lib/types/enum-mappings/expense-frequency.d.ts +7 -0
- package/lib/types/enum-mappings/expense-frequency.js +11 -0
- package/lib/types/enum-mappings/funding-position.d.ts +18 -0
- package/lib/types/enum-mappings/funding-position.js +36 -0
- package/lib/types/enum-mappings/government-benefits.d.ts +7 -0
- package/lib/types/enum-mappings/government-benefits.js +10 -0
- package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
- package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
- package/lib/types/enum-mappings/housing-status.d.ts +7 -0
- package/lib/types/enum-mappings/housing-status.js +15 -0
- package/lib/types/enum-mappings/income-type.d.ts +7 -0
- package/lib/types/enum-mappings/income-type.js +16 -0
- package/lib/types/enum-mappings/index.d.ts +27 -0
- package/lib/types/enum-mappings/index.js +43 -0
- package/lib/types/enum-mappings/liability-payment-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-payment-type.js +9 -0
- package/lib/types/enum-mappings/liability-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-type.js +21 -0
- package/lib/types/enum-mappings/living-expense.d.ts +7 -0
- package/lib/types/enum-mappings/living-expense.js +31 -0
- package/lib/types/enum-mappings/marital-status.d.ts +7 -0
- package/lib/types/enum-mappings/marital-status.js +12 -0
- package/lib/types/enum-mappings/postcode.d.ts +6 -0
- package/lib/types/enum-mappings/postcode.js +15 -0
- package/lib/types/enum-mappings/preferred-repayment.d.ts +7 -0
- package/lib/types/enum-mappings/preferred-repayment.js +10 -0
- package/lib/types/enum-mappings/proof-of-identity.d.ts +7 -0
- package/lib/types/enum-mappings/proof-of-identity.js +10 -0
- package/lib/types/enum-mappings/property-expense-category.d.ts +7 -0
- package/lib/types/enum-mappings/property-expense-category.js +11 -0
- package/lib/types/enum-mappings/public-financial-asset.d.ts +7 -0
- package/lib/types/enum-mappings/public-financial-asset.js +12 -0
- package/lib/types/enum-mappings/public-primary-purpose.d.ts +7 -0
- package/lib/types/enum-mappings/public-primary-purpose.js +9 -0
- package/lib/types/enum-mappings/public-property-status.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-status.js +11 -0
- package/lib/types/enum-mappings/public-property-type.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-type.js +23 -0
- package/lib/types/enum-mappings/residency-status.d.ts +7 -0
- package/lib/types/enum-mappings/residency-status.js +11 -0
- package/lib/types/enum-mappings/title-gender.d.ts +7 -0
- package/lib/types/enum-mappings/title-gender.js +13 -0
- package/lib/types/enum-mappings/title.d.ts +7 -0
- package/lib/types/enum-mappings/title.js +13 -0
- package/lib/types/enum-mappings/to-be-purchased.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-purchased.js +8 -0
- package/lib/types/enum-mappings/to-be-used-as-security.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-used-as-security.js +8 -0
- package/lib/types/enum-mappings/transaction-type.d.ts +7 -0
- package/lib/types/enum-mappings/transaction-type.js +9 -0
- package/lib/types/enum-mappings/trust.d.ts +7 -0
- package/lib/types/enum-mappings/trust.js +14 -0
- package/lib/types/enum-mappings/verification.d.ts +3 -0
- package/lib/types/enum-mappings/verification.js +13 -0
- package/lib/types/events/applicant-delete.d.ts +42 -0
- package/lib/types/events/applicant-delete.js +15 -0
- package/lib/types/events/application-workflow.d.ts +233 -0
- package/lib/types/events/application-workflow.js +172 -0
- package/lib/types/events/asset-delete.d.ts +33 -0
- package/lib/types/events/asset-delete.js +15 -0
- package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
- package/lib/types/events/asset-liability-relation-delete.js +15 -0
- package/lib/types/events/credit-report-retrieved.d.ts +36 -0
- package/lib/types/events/credit-report-retrieved.js +15 -0
- package/lib/types/events/employment-delete.d.ts +19 -0
- package/lib/types/events/employment-delete.js +7 -0
- package/lib/types/events/expense-delete.d.ts +21 -0
- package/lib/types/events/expense-delete.js +7 -0
- package/lib/types/events/funding-position.d.ts +116 -0
- package/lib/types/events/funding-position.js +34 -0
- package/lib/types/events/income-delete.d.ts +33 -0
- package/lib/types/events/income-delete.js +15 -0
- package/lib/types/events/liability-delete.d.ts +17 -0
- package/lib/types/events/liability-delete.js +7 -0
- package/lib/types/events/opportunity.d.ts +102 -0
- package/lib/types/events/opportunity.js +47 -0
- package/lib/types/events/public-applicant.d.ts +628 -0
- package/lib/types/events/public-applicant.js +411 -0
- package/lib/types/events/public-application.d.ts +151 -0
- package/lib/types/events/public-application.js +103 -0
- package/lib/types/events/public-asset-liability-relation.d.ts +52 -0
- package/lib/types/events/public-asset-liability-relation.js +15 -0
- package/lib/types/events/public-asset.d.ts +502 -0
- package/lib/types/events/public-asset.js +348 -0
- package/lib/types/events/public-employment.d.ts +121 -0
- package/lib/types/events/public-employment.js +46 -0
- package/lib/types/events/public-expense.d.ts +84 -0
- package/lib/types/events/public-expense.js +51 -0
- package/lib/types/events/public-funding-position.d.ts +341 -0
- package/lib/types/events/public-funding-position.js +20 -0
- package/lib/types/events/public-income.d.ts +144 -0
- package/lib/types/events/public-income.js +65 -0
- package/lib/types/events/public-liability.d.ts +140 -0
- package/lib/types/events/public-liability.js +68 -0
- package/lib/types/events/public-required-document.d.ts +374 -0
- package/lib/types/events/public-required-document.js +297 -0
- package/lib/types/partial-application.d.ts +3 -0
- package/lib/types/partial-application.js +2 -0
- package/lib/types/recursive-partial.d.ts +3 -0
- package/lib/types/recursive-partial.js +2 -0
- package/lib/update-application/merge-application.d.ts +14 -0
- package/lib/update-application/merge-application.js +175 -0
- package/lib/update-application/remove-ids-not-required.d.ts +11 -0
- package/lib/update-application/remove-ids-not-required.js +63 -0
- package/lib/update-application/update-primary-applicant.d.ts +27 -0
- package/lib/update-application/update-primary-applicant.js +46 -0
- package/lib/utils/address-tools.d.ts +84 -0
- package/lib/utils/address-tools.js +176 -0
- package/lib/utils/clean-up.d.ts +7 -0
- package/lib/utils/clean-up.js +24 -0
- package/lib/utils/errors.d.ts +28 -0
- package/lib/utils/errors.js +43 -0
- package/lib/utils/formatYesNo.d.ts +8 -0
- package/lib/utils/formatYesNo.js +12 -0
- package/lib/utils/generate-address.d.ts +19 -0
- package/lib/utils/generate-address.js +97 -0
- package/lib/utils/get-financial-institution.d.ts +8 -0
- package/lib/utils/get-financial-institution.js +17 -0
- package/lib/utils/is-asset-type.d.ts +25 -0
- package/lib/utils/is-asset-type.js +46 -0
- package/lib/utils/is-income-type.d.ts +73 -0
- package/lib/utils/is-income-type.js +134 -0
- package/lib/utils/iso-date.d.ts +7 -0
- package/lib/utils/iso-date.js +12 -0
- package/lib/utils/normalise-date.d.ts +8 -0
- package/lib/utils/normalise-date.js +17 -0
- package/lib/utils/round-decimal.d.ts +6 -0
- package/lib/utils/round-decimal.js +12 -0
- package/package.json +79 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLivingExpenseEstimate = exports.isOtherCommitment = exports.normaliseExpenseAmount = exports.transformExpense = exports.transformExpenses = exports.otherCommitmentExpenseTypes = void 0;
|
|
4
|
+
const application_paths_1 = require("@lendi/act-eac-integrations-protocol/lib/utils/application-paths");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const enum_mappings_1 = require("../types/enum-mappings/");
|
|
7
|
+
const public_expense_1 = require("../types/events/public-expense");
|
|
8
|
+
exports.otherCommitmentExpenseTypes = [
|
|
9
|
+
public_expense_1.ExpenseType.Board,
|
|
10
|
+
public_expense_1.ExpenseType.ChildAndSpousalMaintenance,
|
|
11
|
+
public_expense_1.ExpenseType.Rent,
|
|
12
|
+
];
|
|
13
|
+
const propertyExpenseCategories = [
|
|
14
|
+
public_expense_1.ExpenseType.InvestmentPropertyRunningCosts,
|
|
15
|
+
public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
|
|
16
|
+
public_expense_1.ExpenseType.SecondaryResidenceRunningCosts,
|
|
17
|
+
public_expense_1.ExpenseType.PrimaryResidenceRunningCosts,
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* @description Transforms expense items on the application from the event.
|
|
21
|
+
* @returns {PartialApplication} A PartialApplication returned by transforming the expense event.
|
|
22
|
+
* @param expense
|
|
23
|
+
*/
|
|
24
|
+
function transformExpenses(expense) {
|
|
25
|
+
const partialApplication = {};
|
|
26
|
+
const { applicantId, applicationId, expenses = [], id } = expense;
|
|
27
|
+
if (expenses.every((expense) => expense.amount === undefined || expense.amount === null)) {
|
|
28
|
+
return partialApplication;
|
|
29
|
+
}
|
|
30
|
+
const normalisedExpenses = expenses.map(normaliseExpenseAmount);
|
|
31
|
+
const filteredLivingExpensesWithAmount = normalisedExpenses.filter((expense) => expense.amount || !propertyExpenseCategories.includes(expense.type));
|
|
32
|
+
const livingExpenseEstimate = filteredLivingExpensesWithAmount.find(isLivingExpenseEstimate);
|
|
33
|
+
const otherCommitments = filteredLivingExpensesWithAmount.filter(isOtherCommitment);
|
|
34
|
+
const expenseBreakdown = filteredLivingExpensesWithAmount.filter((item) => !(isOtherCommitment(item) || isLivingExpenseEstimate(item)));
|
|
35
|
+
const livingExpenseEstimateExists = (0, lodash_1.get)(livingExpenseEstimate || {}, 'amount', 0) > 0;
|
|
36
|
+
const expenseBreakdownAmountSum = (0, lodash_1.sumBy)(expenseBreakdown, 'amount');
|
|
37
|
+
let lixiLivingExpenses;
|
|
38
|
+
// unless all individual expenses have a value of 0 and a living estimate exists, transform them without question.
|
|
39
|
+
if (expenseBreakdownAmountSum === 0 && livingExpenseEstimateExists) {
|
|
40
|
+
const estimate = transformExpense(livingExpenseEstimate, applicantId, 0, id);
|
|
41
|
+
lixiLivingExpenses = [estimate];
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
lixiLivingExpenses = expenseBreakdown.map((expense, index) => transformExpense(expense, applicantId, index, id));
|
|
45
|
+
}
|
|
46
|
+
const lixiCommitmentExpenses = otherCommitments.map((expense, index) => transformExpense(expense, applicantId, index, id));
|
|
47
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
48
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Household}.@UniqueID`, `${applicationId}-household`);
|
|
49
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
50
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
51
|
+
if (lixiLivingExpenses.length > 0) {
|
|
52
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
53
|
+
}
|
|
54
|
+
return partialApplication;
|
|
55
|
+
}
|
|
56
|
+
exports.transformExpenses = transformExpenses;
|
|
57
|
+
/**
|
|
58
|
+
* transforms the living expense from the expense array on the event.
|
|
59
|
+
*
|
|
60
|
+
* @param expense: Array of expenses on the event.
|
|
61
|
+
* @param applicantId: Event applicantId.
|
|
62
|
+
* @param index: Index of the map.
|
|
63
|
+
* @param id: Id of the event.
|
|
64
|
+
* @param expense
|
|
65
|
+
* @param applicantId
|
|
66
|
+
* @param index
|
|
67
|
+
* @param id
|
|
68
|
+
*/
|
|
69
|
+
function transformExpense(expense, applicantId, index, id) {
|
|
70
|
+
return {
|
|
71
|
+
'@Amount': expense.amount,
|
|
72
|
+
'@Category': enum_mappings_1.livingExpenseMapping[expense.type],
|
|
73
|
+
'@Description': expense.type,
|
|
74
|
+
'@UniqueID': isOtherCommitment(expense) ? `${id}-commitment-${index}` : `${id}-living-expense-${index}`,
|
|
75
|
+
'@Frequency': enum_mappings_1.frequencyMapping[expense.frequency],
|
|
76
|
+
PercentResponsible: {
|
|
77
|
+
Owner: [
|
|
78
|
+
{
|
|
79
|
+
'@Percent': 100,
|
|
80
|
+
'@x_Party': applicantId,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
exports.transformExpense = transformExpense;
|
|
87
|
+
/**
|
|
88
|
+
* @description Normalises expense by amount to 0 if not provided and scales quarterly spending up to yearly.
|
|
89
|
+
* @param {Expense} expense An expense
|
|
90
|
+
* @returns {Expense} An normalised expense.
|
|
91
|
+
*/
|
|
92
|
+
function normaliseExpenseAmount(expense) {
|
|
93
|
+
const { amount, frequency = public_expense_1.Frequency.Yearly, type: expenseType } = expense;
|
|
94
|
+
if (frequency === public_expense_1.Frequency.Quarterly) {
|
|
95
|
+
expense.frequency = public_expense_1.Frequency.Yearly;
|
|
96
|
+
expense.amount *= 4;
|
|
97
|
+
}
|
|
98
|
+
if (!amount && !propertyExpenseCategories.includes(expenseType)) {
|
|
99
|
+
expense.amount = 0;
|
|
100
|
+
}
|
|
101
|
+
return expense;
|
|
102
|
+
}
|
|
103
|
+
exports.normaliseExpenseAmount = normaliseExpenseAmount;
|
|
104
|
+
/**
|
|
105
|
+
* @description Verify if expense is an OtherCommitment.
|
|
106
|
+
* @param {Expense} expense Any Expense item.
|
|
107
|
+
* @returns {boolean} Returns true if an expense type is one of other commitment expenses.
|
|
108
|
+
*/
|
|
109
|
+
function isOtherCommitment(expense) {
|
|
110
|
+
return exports.otherCommitmentExpenseTypes.includes(expense.type);
|
|
111
|
+
}
|
|
112
|
+
exports.isOtherCommitment = isOtherCommitment;
|
|
113
|
+
/**
|
|
114
|
+
* @description Check if expense type is LivingExpenseEstimate.
|
|
115
|
+
* @param {Expense} expense An Expense item.
|
|
116
|
+
* @returns {boolean} Returns true if an expense type is LivingExpenseEstimate
|
|
117
|
+
*/
|
|
118
|
+
function isLivingExpenseEstimate(expense) {
|
|
119
|
+
return expense.type === public_expense_1.ExpenseType.LivingExpensesEstimate;
|
|
120
|
+
}
|
|
121
|
+
exports.isLivingExpenseEstimate = isLivingExpenseEstimate;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fee } from '@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { FundsRequiredBreakdown, Payload as FundingPositionPayload } from '../types/events/public-funding-position';
|
|
3
|
+
import { PartialApplication } from '../types/partial-application';
|
|
4
|
+
/**
|
|
5
|
+
* GenerateFundingPosition
|
|
6
|
+
*
|
|
7
|
+
* @param fundingPosition a partialFundingPosition.
|
|
8
|
+
* @param uniqueIdSuffix
|
|
9
|
+
* @returns partialApplication with fees, grants and borrowers contributions added.
|
|
10
|
+
*/
|
|
11
|
+
export declare function transformFundingPosition(fundingPosition: FundingPositionPayload, uniqueIdSuffix?: string): PartialApplication;
|
|
12
|
+
/**
|
|
13
|
+
* getFee
|
|
14
|
+
*
|
|
15
|
+
* @param fundsRequiredBreakDown a FundsRequiredBreakdown.
|
|
16
|
+
* @param lmi
|
|
17
|
+
* @param lmiIncluded
|
|
18
|
+
* @param id
|
|
19
|
+
* @returns Array of fees
|
|
20
|
+
*/
|
|
21
|
+
export declare function getFees(fundsRequiredBreakDown: FundsRequiredBreakdown, lmi: number, lmiIncluded: boolean, id: string): Fee[];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFees = exports.transformFundingPosition = void 0;
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
const application_paths_1 = require("@lendi/act-eac-integrations-protocol/lib/utils/application-paths");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const uuid_1 = require("uuid");
|
|
8
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
9
|
+
/**
|
|
10
|
+
* GenerateFundingPosition
|
|
11
|
+
*
|
|
12
|
+
* @param fundingPosition a partialFundingPosition.
|
|
13
|
+
* @param uniqueIdSuffix
|
|
14
|
+
* @returns partialApplication with fees, grants and borrowers contributions added.
|
|
15
|
+
*/
|
|
16
|
+
function transformFundingPosition(fundingPosition, uniqueIdSuffix = 'loanDetails') {
|
|
17
|
+
const partialApplication = {};
|
|
18
|
+
const contributionFunds = [];
|
|
19
|
+
const { applicationId, id, lmi = 0, lmiIncluded = false } = fundingPosition;
|
|
20
|
+
const fundingPositionMapping = {
|
|
21
|
+
applicationId: application_paths_1.paths.ApplicationId,
|
|
22
|
+
fundsRequested: `${application_paths_1.paths.RolledUpAmounts}.@TotalNewFunds`,
|
|
23
|
+
lvr: `${application_paths_1.paths.Summary}.LoanToValuationRatio.@ApplicationLVR`,
|
|
24
|
+
totalGovernmentContributions: application_paths_1.paths.ContributionFunds,
|
|
25
|
+
totalDeposit: application_paths_1.paths.ContributionFunds,
|
|
26
|
+
totalCashOut: `${application_paths_1.paths.EquityRelease}.Amount.@LumpSum`,
|
|
27
|
+
fundsRequiredBreakdown: application_paths_1.paths.SummaryFee,
|
|
28
|
+
properties: 'properties',
|
|
29
|
+
};
|
|
30
|
+
for (const [key, value] of Object.entries(fundingPosition)) {
|
|
31
|
+
if (fundingPositionMapping[key]) {
|
|
32
|
+
switch (key) {
|
|
33
|
+
case 'totalGovernmentContributions':
|
|
34
|
+
case 'totalDeposit':
|
|
35
|
+
contributionFunds.push({
|
|
36
|
+
'@Amount': value,
|
|
37
|
+
'@Type': enum_mappings_1.contributionMapping[key],
|
|
38
|
+
'@UniqueID': `${id}-${key}`,
|
|
39
|
+
});
|
|
40
|
+
break;
|
|
41
|
+
case 'fundsRequiredBreakdown':
|
|
42
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.SummaryFee, getFees(value, lmi, lmiIncluded, id));
|
|
43
|
+
break;
|
|
44
|
+
case 'totalCashOut':
|
|
45
|
+
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
|
|
46
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.LoanDetail}.@UniqueID`, `${applicationId}-${uniqueIdSuffix}`);
|
|
47
|
+
break;
|
|
48
|
+
case 'fundsRequested':
|
|
49
|
+
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], Math.round(value));
|
|
50
|
+
break;
|
|
51
|
+
case 'properties':
|
|
52
|
+
const securities = value
|
|
53
|
+
.filter((property) => property.pledgeAmount)
|
|
54
|
+
.map((property) => ({
|
|
55
|
+
'@Limit': property.pledgeAmount,
|
|
56
|
+
'@UniqueID': (0, uuid_1.v4)(),
|
|
57
|
+
'@x_Security': property.id,
|
|
58
|
+
}));
|
|
59
|
+
if (securities.length > 0)
|
|
60
|
+
(0, lodash_1.set)(partialApplication, 'Package.Content.Application.LendingGuarantee[0].Security', securities);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ContributionFunds, contributionFunds);
|
|
69
|
+
return partialApplication;
|
|
70
|
+
}
|
|
71
|
+
exports.transformFundingPosition = transformFundingPosition;
|
|
72
|
+
/**
|
|
73
|
+
* getFee
|
|
74
|
+
*
|
|
75
|
+
* @param fundsRequiredBreakDown a FundsRequiredBreakdown.
|
|
76
|
+
* @param lmi
|
|
77
|
+
* @param lmiIncluded
|
|
78
|
+
* @param id
|
|
79
|
+
* @returns Array of fees
|
|
80
|
+
*/
|
|
81
|
+
function getFees(fundsRequiredBreakDown, lmi, lmiIncluded, id) {
|
|
82
|
+
// Adding lmi to fees to be transformed.
|
|
83
|
+
(0, lodash_1.set)(fundsRequiredBreakDown, 'lmi', lmi);
|
|
84
|
+
// Omitting constructionCosts as they don't belong in fees.
|
|
85
|
+
return Object.entries((0, lodash_1.omit)(fundsRequiredBreakDown, 'constructionCosts')).map(([key, value]) => {
|
|
86
|
+
const descriptionList = ['accruedInterest', 'otherSundries'];
|
|
87
|
+
const fee = {
|
|
88
|
+
'@Amount': value,
|
|
89
|
+
'@Category': enum_mappings_1.categoryMapping[key],
|
|
90
|
+
'@Type': enum_mappings_1.typeMapping[key],
|
|
91
|
+
'@UniqueID': `${id}-${key}`,
|
|
92
|
+
};
|
|
93
|
+
if (descriptionList.includes(key)) {
|
|
94
|
+
fee['@Description'] = enum_mappings_1.descriptionMapping[key];
|
|
95
|
+
}
|
|
96
|
+
if (key === 'lmi') {
|
|
97
|
+
if (lmiIncluded)
|
|
98
|
+
fee['@CapitaliseFee'] = lixi_internal_request_1.YesNoList.Yes;
|
|
99
|
+
// If lmiIncluded is undefined we do not want to set '@CapitaliseFee'
|
|
100
|
+
// only if it is false as this will affect how we handle migration.
|
|
101
|
+
if (lmiIncluded === false)
|
|
102
|
+
fee['@CapitaliseFee'] = lixi_internal_request_1.YesNoList.No;
|
|
103
|
+
}
|
|
104
|
+
return fee;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.getFees = getFees;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IncomeBusinessActivityStatement, IncomeElement } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
import { RentalIncome } from '@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request';
|
|
3
|
+
import { BASDefinition, Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
|
|
4
|
+
import { PartialApplication } from '../types/partial-application';
|
|
5
|
+
export interface AmountFrequency {
|
|
6
|
+
amount: string;
|
|
7
|
+
frequency?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const EmploymentIncomeTypeMapping: Record<string, AmountFrequency>;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param incomeType
|
|
13
|
+
*/
|
|
14
|
+
export declare function getIncomeMapping(incomeType: IncomeType): Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Generates an partial application from a partial income event.
|
|
17
|
+
*
|
|
18
|
+
* @param payload a partial income event.
|
|
19
|
+
* @param applicantId PersonApplicant uniqueId on the application.
|
|
20
|
+
* @returns partialApplication an incomplete application.
|
|
21
|
+
*/
|
|
22
|
+
export declare function transformIncome(payload: IncomePayload, applicantId?: string): PartialApplication;
|
|
23
|
+
/**
|
|
24
|
+
* Creates Rental Income array.
|
|
25
|
+
*
|
|
26
|
+
* @param amount Amount
|
|
27
|
+
* @param frequency Frequency
|
|
28
|
+
* @param ownership Owners.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createRentalIncome(amount: number, frequency: Frequency, ownership?: Ownership[]): RentalIncome[];
|
|
31
|
+
export interface SelfEmploymentIncomeMapping {
|
|
32
|
+
year: string;
|
|
33
|
+
companyProfitBeforeTax: string;
|
|
34
|
+
addback: Record<string, string>;
|
|
35
|
+
nonRecurringIncome: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @description Transform a Self Employed Income Details to LIXI
|
|
39
|
+
* @param data Financial Year Income Details for Self Employed Income.
|
|
40
|
+
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
41
|
+
*/
|
|
42
|
+
export declare function generateIncomeBusinessDetails(data: IncomeBusinessDetails): IncomeElement;
|
|
43
|
+
/**
|
|
44
|
+
* Generates the BAS array from the bas definition on the event.
|
|
45
|
+
*
|
|
46
|
+
* @param bas
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateBAS(bas: BASDefinition[]): IncomeBusinessActivityStatement[];
|
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.generateBAS = exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.transformIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
|
|
15
|
+
const lixi_internal_request_1 = require("@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request");
|
|
16
|
+
const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
18
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
19
|
+
const public_income_1 = require("../types/events/public-income");
|
|
20
|
+
const is_income_type_1 = require("../utils/is-income-type");
|
|
21
|
+
const round_decimal_1 = require("../utils/round-decimal");
|
|
22
|
+
const transform_percent_owned_1 = require("./transform-percent-owned");
|
|
23
|
+
const netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
|
|
24
|
+
const netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
|
|
25
|
+
// Income types mapping from internal to LIXI types /paths.
|
|
26
|
+
exports.EmploymentIncomeTypeMapping = {
|
|
27
|
+
[public_income_1.IncomeType.PaygAllowancesNotTaxed]: {
|
|
28
|
+
amount: 'Income.@WorkAllowanceAmount',
|
|
29
|
+
frequency: 'Income.@WorkAllowanceFrequency',
|
|
30
|
+
},
|
|
31
|
+
[public_income_1.IncomeType.PaygAllowancesTaxed]: {
|
|
32
|
+
amount: netWorkAllowanceAmount,
|
|
33
|
+
frequency: netWorkAllowanceFrequency,
|
|
34
|
+
},
|
|
35
|
+
[public_income_1.IncomeType.PaygBaseSalary]: {
|
|
36
|
+
amount: 'Income.@GrossSalaryAmount',
|
|
37
|
+
frequency: 'Income.@GrossSalaryFrequency',
|
|
38
|
+
},
|
|
39
|
+
[public_income_1.IncomeType.PaygBonusIncome]: {
|
|
40
|
+
amount: 'Income.@BonusAmount',
|
|
41
|
+
frequency: 'Income.@BonusFrequency',
|
|
42
|
+
},
|
|
43
|
+
[public_income_1.IncomeType.PaygCommissionIncome]: {
|
|
44
|
+
amount: 'Income.@CommissionAmount',
|
|
45
|
+
frequency: 'Income.@CommissionFrequency',
|
|
46
|
+
},
|
|
47
|
+
[public_income_1.IncomeType.PaygCompanyCar]: {
|
|
48
|
+
amount: 'Income.@NetCarAllowanceAmount',
|
|
49
|
+
frequency: 'Income.@NetCarAllowanceFrequency',
|
|
50
|
+
},
|
|
51
|
+
[public_income_1.IncomeType.PaygCarAllowance]: {
|
|
52
|
+
amount: 'Income.@CarAllowanceAmount',
|
|
53
|
+
frequency: 'Income.@CarAllowanceFrequency',
|
|
54
|
+
},
|
|
55
|
+
[public_income_1.IncomeType.PaygOvertimeIncome]: {
|
|
56
|
+
amount: 'Income.@GrossRegularOvertimeAmount',
|
|
57
|
+
frequency: 'Income.@GrossRegularOvertimeFrequency',
|
|
58
|
+
},
|
|
59
|
+
[public_income_1.IncomeType.SelfEmployedBusinessIncome]: {
|
|
60
|
+
amount: 'BusinessIncomeRecent.@ProfitBeforeTax',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param incomeType
|
|
66
|
+
*/
|
|
67
|
+
function getIncomeMapping(incomeType) {
|
|
68
|
+
let basePath = application_paths_1.paths.OtherIncome;
|
|
69
|
+
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
70
|
+
basePath = application_paths_1.paths.RealEstateAsset;
|
|
71
|
+
return {
|
|
72
|
+
assetId: `${basePath}.@UniqueID`,
|
|
73
|
+
percentOwned: `${basePath}.RentalIncome`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
77
|
+
basePath = application_paths_1.paths.CompanyApplicant;
|
|
78
|
+
return {
|
|
79
|
+
bas: `${basePath}.Income[0].BusinessActivityStatement`,
|
|
80
|
+
companyId: `${basePath}.@UniqueID`,
|
|
81
|
+
incomes: `${basePath}.Income`,
|
|
82
|
+
gross: `${basePath}.DeclaredIncome.@IncomeAmount`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
|
|
86
|
+
basePath = application_paths_1.paths.SelfEmployed;
|
|
87
|
+
const { amount } = exports.EmploymentIncomeTypeMapping[incomeType];
|
|
88
|
+
return {
|
|
89
|
+
amount: `${basePath}.${amount}`,
|
|
90
|
+
employmentId: `${basePath}.@UniqueID`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
94
|
+
basePath = application_paths_1.paths.PAYG;
|
|
95
|
+
const { amount, frequency } = exports.EmploymentIncomeTypeMapping[incomeType];
|
|
96
|
+
return Object.assign({ amount: `${basePath}.${amount}`, employmentId: `${basePath}.@UniqueID` }, (frequency && { frequency: `${basePath}.${frequency}` }));
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
amount: `${basePath}.@Amount`,
|
|
100
|
+
frequency: `${basePath}.@Frequency`,
|
|
101
|
+
percentOwned: `${basePath}.PercentOwned`,
|
|
102
|
+
type: `${basePath}.@Type`,
|
|
103
|
+
benefitType: `${basePath}.@GovernmentBenefitsType`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
exports.getIncomeMapping = getIncomeMapping;
|
|
107
|
+
/**
|
|
108
|
+
* Generates an partial application from a partial income event.
|
|
109
|
+
*
|
|
110
|
+
* @param payload a partial income event.
|
|
111
|
+
* @param applicantId PersonApplicant uniqueId on the application.
|
|
112
|
+
* @returns partialApplication an incomplete application.
|
|
113
|
+
*/
|
|
114
|
+
function transformIncome(payload, applicantId) {
|
|
115
|
+
const { applicationId, id, income } = payload;
|
|
116
|
+
const { amount: incomeAmount, type: incomeType, frequency: incomeFrequency } = income;
|
|
117
|
+
const partialApplication = {};
|
|
118
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
119
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
|
|
120
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
121
|
+
}
|
|
122
|
+
if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
|
|
123
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.OtherIncome}.@UniqueID`, id);
|
|
124
|
+
}
|
|
125
|
+
const incomeMapping = getIncomeMapping(incomeType);
|
|
126
|
+
for (const [key, value] of Object.entries(income)) {
|
|
127
|
+
if (incomeMapping[key]) {
|
|
128
|
+
switch (key) {
|
|
129
|
+
case 'amount':
|
|
130
|
+
const amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
|
|
131
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
|
|
132
|
+
break;
|
|
133
|
+
case 'bas':
|
|
134
|
+
const basWithAmount = value.filter((bas) => bas.salesAmount !== undefined || false);
|
|
135
|
+
if (!(0, lodash_1.isEmpty)(basWithAmount))
|
|
136
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], generateBAS(basWithAmount));
|
|
137
|
+
break;
|
|
138
|
+
case 'frequency':
|
|
139
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], enum_mappings_1.incomeExpenseFrequencyMapping[value]);
|
|
140
|
+
break;
|
|
141
|
+
case 'percentOwned':
|
|
142
|
+
const ownership = value;
|
|
143
|
+
let percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(ownership);
|
|
144
|
+
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
145
|
+
percentOwned = createRentalIncome(incomeAmount, incomeFrequency, ownership.owners);
|
|
146
|
+
}
|
|
147
|
+
if (percentOwned) {
|
|
148
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
case 'type':
|
|
152
|
+
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
153
|
+
const mappedType = enum_mappings_1.otherIncomeMapping[value];
|
|
154
|
+
if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
|
|
155
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.OtherIncome}.@Description`, mappedType);
|
|
156
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case 'benefitType':
|
|
164
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], enum_mappings_1.governmentBenefitsMapping[value]);
|
|
165
|
+
break;
|
|
166
|
+
case 'incomes':
|
|
167
|
+
const sortedIncomeList = value
|
|
168
|
+
.sort(is_income_type_1.sortBusinessIncome)
|
|
169
|
+
.map(generateIncomeBusinessDetails);
|
|
170
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], sortedIncomeList);
|
|
171
|
+
break;
|
|
172
|
+
default:
|
|
173
|
+
(0, lodash_1.set)(partialApplication, incomeMapping[key], value);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return partialApplication;
|
|
179
|
+
}
|
|
180
|
+
exports.transformIncome = transformIncome;
|
|
181
|
+
/**
|
|
182
|
+
* Creates Rental Income array.
|
|
183
|
+
*
|
|
184
|
+
* @param amount Amount
|
|
185
|
+
* @param frequency Frequency
|
|
186
|
+
* @param ownership Owners.
|
|
187
|
+
*/
|
|
188
|
+
function createRentalIncome(amount, frequency, ownership = []) {
|
|
189
|
+
if (frequency === public_income_1.Frequency.Quarterly) {
|
|
190
|
+
amount = Math.ceil(amount / 3);
|
|
191
|
+
frequency = public_income_1.Frequency.Monthly;
|
|
192
|
+
}
|
|
193
|
+
const rentalIncome = [];
|
|
194
|
+
for (const owner of ownership) {
|
|
195
|
+
const { percent, applicantId } = owner;
|
|
196
|
+
const ownerAmount = (0, round_decimal_1.roundDecimal)(amount * percent);
|
|
197
|
+
rentalIncome.push({
|
|
198
|
+
'@Frequency': enum_mappings_1.rentalIncomeFrequencyMapping[frequency],
|
|
199
|
+
'@RentalAmount': ownerAmount,
|
|
200
|
+
'@x_Owner': applicantId,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return rentalIncome;
|
|
204
|
+
}
|
|
205
|
+
exports.createRentalIncome = createRentalIncome;
|
|
206
|
+
const selfEmploymentIncomeMapping = {
|
|
207
|
+
year: '@StartDate',
|
|
208
|
+
companyProfitBeforeTax: '@CompanyProfitBeforeTax',
|
|
209
|
+
addback: {
|
|
210
|
+
depreciation: 'Addback.@Depreciation',
|
|
211
|
+
interest: 'Addback.@Interest',
|
|
212
|
+
lease: 'Addback.@Lease',
|
|
213
|
+
nonRecurringExpenses: 'Addback.@NonRecurringExpenses',
|
|
214
|
+
other: 'Addback.OtherAddback[0].@Amount',
|
|
215
|
+
salary: 'Addback.@Salary',
|
|
216
|
+
superannuationExcess: 'Addback.@SuperannuationExcess',
|
|
217
|
+
},
|
|
218
|
+
nonRecurringIncome: 'NonRecurringIncome[0].@Amount',
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* @description Transform a Self Employed Income Details to LIXI
|
|
222
|
+
* @param data Financial Year Income Details for Self Employed Income.
|
|
223
|
+
* @returns {IncomeElement} LIXI Income for the Self Employed.
|
|
224
|
+
*/
|
|
225
|
+
function generateIncomeBusinessDetails(data) {
|
|
226
|
+
const income = {};
|
|
227
|
+
const { addback: addbackMapping } = selfEmploymentIncomeMapping, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
|
|
228
|
+
for (const [key, value] of Object.entries(data)) {
|
|
229
|
+
if (selfEmploymentIncomeMapping[key] !== null) {
|
|
230
|
+
if (key === 'addback') {
|
|
231
|
+
for (const [addbackKey, addbackValue] of Object.entries(value)) {
|
|
232
|
+
if (addbackKey === 'other') {
|
|
233
|
+
(0, lodash_1.set)(income, 'Addback.OtherAddback[0].@Description', 'other');
|
|
234
|
+
}
|
|
235
|
+
(0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else if (key === 'year') {
|
|
239
|
+
(0, lodash_1.set)(income, dateAndIncomeMapping[key], `${value}-01-01`);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return income;
|
|
247
|
+
}
|
|
248
|
+
exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
|
|
249
|
+
/**
|
|
250
|
+
* Generates the BAS array from the bas definition on the event.
|
|
251
|
+
*
|
|
252
|
+
* @param bas
|
|
253
|
+
*/
|
|
254
|
+
function generateBAS(bas) {
|
|
255
|
+
return bas.map((bas) => ({
|
|
256
|
+
'@Quarter': bas.quarter,
|
|
257
|
+
'@SalesAmount': bas.salesAmount,
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
exports.generateBAS = generateBAS;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LiabilityPayload } from '../types/events/public-liability';
|
|
2
|
+
import { PartialApplication } from '../types/partial-application';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a partial internal request from a liability event payload.
|
|
5
|
+
*
|
|
6
|
+
* @param liabilityPayload: A liability event payload.
|
|
7
|
+
* @param liabilityPayload:.applicationId
|
|
8
|
+
* @param liabilityPayload:.id
|
|
9
|
+
* @param liabilityPayload:.liability
|
|
10
|
+
* @returns A partial InternalRequest.
|
|
11
|
+
*/
|
|
12
|
+
export declare function transformLiability({ applicationId, id, liability }: LiabilityPayload): PartialApplication;
|