@lendi/integrations-transform 1.2.1 → 1.2.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.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/transform-events/generate-asset-liability-link.js +2 -2
- package/lib/transform-events/generate-credit-report-rebuilt.js +1 -1
- package/lib/transform-events/generate-employment.js +17 -17
- package/lib/transform-events/generate-funding-position.js +6 -6
- package/lib/transform-events/generate-liability.js +13 -13
- package/lib/transform-events/generate-opportunity.js +2 -2
- package/lib/transform-events/generate-required-document.js +7 -7
- package/lib/transform-events/transform-applicant.js +21 -21
- package/lib/transform-events/transform-application.js +4 -4
- package/lib/transform-events/transform-asset-address.d.ts +19 -0
- package/lib/transform-events/transform-asset-address.js +83 -0
- package/lib/transform-events/transform-asset.d.ts +2 -18
- package/lib/transform-events/transform-asset.js +38 -106
- package/lib/transform-events/transform-expenses.js +3 -3
- package/lib/transform-events/transform-income.js +18 -18
- package/lib/transform-events/transform-percent-owned.js +2 -1
- package/lib/update-application/merge-application.d.ts +8 -0
- package/lib/update-application/merge-application.js +132 -0
- package/lib/utils/normalise-date.js +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export * from './transform-events/transform-expenses';
|
|
|
6
6
|
export * from './transform-events/generate-liability';
|
|
7
7
|
export * from './transform-events/generate-required-document';
|
|
8
8
|
export * from './transform-events/generate-funding-position';
|
|
9
|
+
export * from './update-application/merge-application';
|
package/lib/index.js
CHANGED
|
@@ -19,3 +19,4 @@ __exportStar(require("./transform-events/transform-expenses"), exports);
|
|
|
19
19
|
__exportStar(require("./transform-events/generate-liability"), exports);
|
|
20
20
|
__exportStar(require("./transform-events/generate-required-document"), exports);
|
|
21
21
|
__exportStar(require("./transform-events/generate-funding-position"), exports);
|
|
22
|
+
__exportStar(require("./update-application/merge-application"), exports);
|
|
@@ -14,8 +14,8 @@ function generateAssetLiabilityLink(_a) {
|
|
|
14
14
|
var partialApplication = {};
|
|
15
15
|
var assetLiabilityMapping = {
|
|
16
16
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
17
|
-
liabilityId: application_paths_1.paths.Liability
|
|
18
|
-
assetId: application_paths_1.paths.Liability
|
|
17
|
+
liabilityId: "".concat(application_paths_1.paths.Liability, ".@UniqueID"),
|
|
18
|
+
assetId: "".concat(application_paths_1.paths.Liability, ".Security[0].@x_Security")
|
|
19
19
|
};
|
|
20
20
|
(0, lodash_1.set)(partialApplication, assetLiabilityMapping.applicationId, applicationId);
|
|
21
21
|
for (var _i = 0, _b = Object.entries(relation); _i < _b.length; _i++) {
|
|
@@ -12,7 +12,7 @@ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/applic
|
|
|
12
12
|
*/
|
|
13
13
|
function generateCreditReportRebuilt(creditReport) {
|
|
14
14
|
var applicantId = creditReport.applicantId, raw = creditReport.raw, source = creditReport.source;
|
|
15
|
-
var id = applicantId
|
|
15
|
+
var id = "".concat(applicantId, "-creditReport");
|
|
16
16
|
var attachment = {
|
|
17
17
|
'@Filename': 'Credit Report',
|
|
18
18
|
'@UniqueID': id,
|
|
@@ -29,7 +29,7 @@ function generateEmployment(employment) {
|
|
|
29
29
|
isEmployed = true;
|
|
30
30
|
employmentPath = application_paths_1.paths.PAYG;
|
|
31
31
|
// Setting default for onProbation. If field exists in event value will get overwritten.
|
|
32
|
-
(0, lodash_1.set)(partialApplication, employmentPath
|
|
32
|
+
(0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@OnProbation"), lixi_internal_request_1.YesNoList.No);
|
|
33
33
|
break;
|
|
34
34
|
case public_employment_1.EmploymentType.SelfEmployed:
|
|
35
35
|
isEmployed = true;
|
|
@@ -37,24 +37,24 @@ function generateEmployment(employment) {
|
|
|
37
37
|
break;
|
|
38
38
|
case public_employment_1.EmploymentType.NotWorking:
|
|
39
39
|
employmentPath = application_paths_1.paths.NotEmployed;
|
|
40
|
-
(0, lodash_1.set)(partialApplication, employmentPath
|
|
41
|
-
(0, lodash_1.set)(partialApplication, employmentPath
|
|
40
|
+
(0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".Income.@OtherIncomeAmount"), 0);
|
|
41
|
+
(0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".Income.@OtherIncomeFrequency"), lixi_internal_request_1.List.Fortnightly);
|
|
42
42
|
break;
|
|
43
43
|
default:
|
|
44
|
-
logger_1.logger.warn({ message: "Unknown EmploymentType "
|
|
44
|
+
logger_1.logger.warn({ message: "Unknown EmploymentType ".concat(employment.employmentType), applicationId: applicationId });
|
|
45
45
|
}
|
|
46
46
|
var employmentMapping = {
|
|
47
47
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
48
|
-
applicantId: application_paths_1.paths.PersonApplicant
|
|
49
|
-
id: employmentPath
|
|
50
|
-
abn: application_paths_1.paths.RelatedCompany
|
|
51
|
-
businessName: application_paths_1.paths.RelatedCompany
|
|
52
|
-
type: employmentPath
|
|
53
|
-
employmentBasis: employmentPath
|
|
54
|
-
startDate: employmentPath
|
|
55
|
-
endDate: employmentPath
|
|
56
|
-
role: employmentPath
|
|
57
|
-
onProbation: employmentPath
|
|
48
|
+
applicantId: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
|
|
49
|
+
id: "".concat(employmentPath, ".@UniqueID"),
|
|
50
|
+
abn: "".concat(application_paths_1.paths.RelatedCompany, ".@ABN"),
|
|
51
|
+
businessName: "".concat(application_paths_1.paths.RelatedCompany, ".@BusinessName"),
|
|
52
|
+
type: "".concat(employmentPath, ".@Status"),
|
|
53
|
+
employmentBasis: "".concat(employmentPath, ".@Basis"),
|
|
54
|
+
startDate: "".concat(employmentPath, ".@StartDate"),
|
|
55
|
+
endDate: "".concat(employmentPath, ".@EndDate"),
|
|
56
|
+
role: "".concat(employmentPath, ".@Occupation"),
|
|
57
|
+
onProbation: "".concat(employmentPath, ".@OnProbation")
|
|
58
58
|
};
|
|
59
59
|
for (var _i = 0, _a = Object.entries(employment); _i < _a.length; _i++) {
|
|
60
60
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
@@ -76,8 +76,8 @@ function generateEmployment(employment) {
|
|
|
76
76
|
case 'id':
|
|
77
77
|
(0, lodash_1.set)(partialApplication, employmentMapping[key], value);
|
|
78
78
|
if (isEmployed) {
|
|
79
|
-
(0, lodash_1.set)(partialApplication, employmentPath
|
|
80
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RelatedCompany
|
|
79
|
+
(0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@x_Employer"), "".concat(value, "-businessName"));
|
|
80
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RelatedCompany, ".@UniqueID"), "".concat(value, "-businessName"));
|
|
81
81
|
}
|
|
82
82
|
break;
|
|
83
83
|
case 'onProbation':
|
|
@@ -89,7 +89,7 @@ function generateEmployment(employment) {
|
|
|
89
89
|
case 'role':
|
|
90
90
|
var _c = value.anzsco, anzsco = _c === void 0 ? {} : _c;
|
|
91
91
|
if (anzsco.code) {
|
|
92
|
-
(0, lodash_1.set)(partialApplication, employmentPath
|
|
92
|
+
(0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@ANZSCOOccupationCode"), anzsco.code.toString());
|
|
93
93
|
}
|
|
94
94
|
if (anzsco.occupation) {
|
|
95
95
|
(0, lodash_1.set)(partialApplication, employmentMapping[key], anzsco.occupation);
|
|
@@ -16,11 +16,11 @@ function generateFundingPosition(fundingPosition) {
|
|
|
16
16
|
var applicationId = fundingPosition.applicationId, id = fundingPosition.id;
|
|
17
17
|
var fundingPositionMapping = {
|
|
18
18
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
19
|
-
fundsRequested: application_paths_1.paths.RolledUpAmounts
|
|
20
|
-
lvr: application_paths_1.paths.Summary
|
|
19
|
+
fundsRequested: "".concat(application_paths_1.paths.RolledUpAmounts, ".@TotalNewFunds"),
|
|
20
|
+
lvr: "".concat(application_paths_1.paths.Summary, ".LoanToValuationRatio.@ApplicationLVR"),
|
|
21
21
|
totalGovernmentContributions: application_paths_1.paths.ContributionFunds,
|
|
22
22
|
totalDeposit: application_paths_1.paths.ContributionFunds,
|
|
23
|
-
totalCashOut: application_paths_1.paths.EquityRelease
|
|
23
|
+
totalCashOut: "".concat(application_paths_1.paths.EquityRelease, ".Amount.@LumpSum"),
|
|
24
24
|
fundsRequiredBreakdown: application_paths_1.paths.SummaryFee
|
|
25
25
|
};
|
|
26
26
|
for (var _i = 0, _a = Object.entries(fundingPosition); _i < _a.length; _i++) {
|
|
@@ -32,7 +32,7 @@ function generateFundingPosition(fundingPosition) {
|
|
|
32
32
|
contributionFunds.push({
|
|
33
33
|
'@Amount': value,
|
|
34
34
|
'@Type': funding_position_1.contributionMapping[key],
|
|
35
|
-
'@UniqueID': id
|
|
35
|
+
'@UniqueID': "".concat(id, "-").concat(key)
|
|
36
36
|
});
|
|
37
37
|
break;
|
|
38
38
|
case 'fundsRequiredBreakdown':
|
|
@@ -40,7 +40,7 @@ function generateFundingPosition(fundingPosition) {
|
|
|
40
40
|
break;
|
|
41
41
|
case 'totalCashOut':
|
|
42
42
|
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
|
|
43
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail
|
|
43
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.LoanDetail, ".@UniqueID"), "".concat(applicationId, "-loanDetails"));
|
|
44
44
|
break;
|
|
45
45
|
case 'fundsRequested':
|
|
46
46
|
(0, lodash_1.set)(partialApplication, fundingPositionMapping[key], Math.round(value));
|
|
@@ -71,7 +71,7 @@ function getFees(fundsRequiredBreakDown, id) {
|
|
|
71
71
|
'@Amount': value,
|
|
72
72
|
'@Category': funding_position_1.categoryMapping[key],
|
|
73
73
|
'@Type': funding_position_1.typeMapping[key],
|
|
74
|
-
'@UniqueID': id
|
|
74
|
+
'@UniqueID': "".concat(id, "-").concat(key)
|
|
75
75
|
};
|
|
76
76
|
if (descriptionList.includes(key)) {
|
|
77
77
|
fee['@Description'] = funding_position_1.descriptionMapping[key];
|
|
@@ -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
|
|
25
|
-
id: application_paths_1.paths.Liability
|
|
26
|
-
clearingFromThisLoan: application_paths_1.paths.Liability
|
|
27
|
-
description: application_paths_1.paths.Liability
|
|
28
|
-
financialInstitution: application_paths_1.paths.Liability
|
|
29
|
-
newLimit: application_paths_1.paths.Liability
|
|
30
|
-
repaymentAmount: application_paths_1.paths.Liability
|
|
31
|
-
repaymentFrequency: application_paths_1.paths.Liability
|
|
32
|
-
remainingTermDuration: application_paths_1.paths.Liability
|
|
33
|
-
repaymentTypeDetails: application_paths_1.paths.Liability
|
|
34
|
-
outstandingBalance: application_paths_1.paths.Liability
|
|
35
|
-
type: application_paths_1.paths.Liability
|
|
36
|
-
percentOwned: application_paths_1.paths.Liability
|
|
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);
|
|
@@ -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
|
|
23
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key]
|
|
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
|
|
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
|
|
32
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ProofOfIdentity
|
|
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
|
|
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
|
|
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
|
|
44
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Privacy
|
|
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);
|
|
@@ -15,20 +15,20 @@ var booleanMapping = function (input) {
|
|
|
15
15
|
exports.booleanMapping = booleanMapping;
|
|
16
16
|
var applicantMapping = {
|
|
17
17
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
18
|
-
citizenship: application_paths_1.paths.PersonApplicant
|
|
19
|
-
contact: application_paths_1.paths.PersonApplicant
|
|
18
|
+
citizenship: "".concat(application_paths_1.paths.PersonApplicant, ".@Citizenship"),
|
|
19
|
+
contact: "".concat(application_paths_1.paths.PersonApplicant, ".Contact"),
|
|
20
20
|
dependants: 'dependants',
|
|
21
|
-
dateOfBirth: application_paths_1.paths.PersonApplicant
|
|
22
|
-
firstName: application_paths_1.paths.PersonApplicant
|
|
23
|
-
id: application_paths_1.paths.PersonApplicant
|
|
24
|
-
isFirstHomeBuyer: application_paths_1.paths.PersonApplicant
|
|
25
|
-
isPrimaryApplicant: application_paths_1.paths.PersonApplicant
|
|
26
|
-
lastName: application_paths_1.paths.PersonApplicant
|
|
27
|
-
maritalStatus: application_paths_1.paths.PersonApplicant
|
|
28
|
-
maritalDetails: application_paths_1.paths.PersonApplicant
|
|
29
|
-
middleName: application_paths_1.paths.PersonApplicant
|
|
30
|
-
residencyStatus: application_paths_1.paths.PersonApplicant
|
|
31
|
-
title: application_paths_1.paths.PersonName
|
|
21
|
+
dateOfBirth: "".concat(application_paths_1.paths.PersonApplicant, ".@DateOfBirth"),
|
|
22
|
+
firstName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@FirstName"),
|
|
23
|
+
id: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
|
|
24
|
+
isFirstHomeBuyer: "".concat(application_paths_1.paths.PersonApplicant, ".@FirstHomeBuyer"),
|
|
25
|
+
isPrimaryApplicant: "".concat(application_paths_1.paths.PersonApplicant, ".@PrimaryApplicant"),
|
|
26
|
+
lastName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@Surname"),
|
|
27
|
+
maritalStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@MaritalStatus"),
|
|
28
|
+
maritalDetails: "".concat(application_paths_1.paths.PersonApplicant, ".MaritalStatusDetails.@x_Spouse"),
|
|
29
|
+
middleName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@MiddleNames"),
|
|
30
|
+
residencyStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@ResidencyStatus"),
|
|
31
|
+
title: "".concat(application_paths_1.paths.PersonName, ".@NameTitle")
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* Transforms a partial Applicant event to a partial LIXI application.
|
|
@@ -81,8 +81,8 @@ function transformApplicant(applicant) {
|
|
|
81
81
|
break;
|
|
82
82
|
case 'dependants':
|
|
83
83
|
var dependants = generateDependants(value, applicantId);
|
|
84
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household
|
|
85
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household
|
|
84
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
|
|
85
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".Dependant"), dependants);
|
|
86
86
|
break;
|
|
87
87
|
default:
|
|
88
88
|
(0, lodash_1.set)(partialApplication, applicantMapping[key], value);
|
|
@@ -117,7 +117,7 @@ function generateContact(contact, id) {
|
|
|
117
117
|
switch (key) {
|
|
118
118
|
case 'currentAddress':
|
|
119
119
|
{
|
|
120
|
-
var addressId = id
|
|
120
|
+
var addressId = "".concat(id, "-current");
|
|
121
121
|
var _c = (0, address_tools_1.rebuildAddress)(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
|
|
122
122
|
lixiAddresses.push(lixiAddress);
|
|
123
123
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
@@ -125,7 +125,7 @@ function generateContact(contact, id) {
|
|
|
125
125
|
break;
|
|
126
126
|
case 'postSettlementAddress':
|
|
127
127
|
{
|
|
128
|
-
var addressId = id
|
|
128
|
+
var addressId = "".concat(id, "-postSettlement");
|
|
129
129
|
var _d = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
|
|
130
130
|
lixiAddresses.push(lixiAddress);
|
|
131
131
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
@@ -133,7 +133,7 @@ function generateContact(contact, id) {
|
|
|
133
133
|
break;
|
|
134
134
|
case 'mailingAddress':
|
|
135
135
|
{
|
|
136
|
-
var addressId = id
|
|
136
|
+
var addressId = "".concat(id, "-mailing");
|
|
137
137
|
var lixiAddress = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId).lixiAddress;
|
|
138
138
|
lixiAddresses.push(lixiAddress);
|
|
139
139
|
(0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
|
|
@@ -141,7 +141,7 @@ function generateContact(contact, id) {
|
|
|
141
141
|
break;
|
|
142
142
|
case 'previousAddresses':
|
|
143
143
|
{
|
|
144
|
-
var addressId = id
|
|
144
|
+
var addressId = "".concat(id, "-previous");
|
|
145
145
|
var previousAddresses = value.sort(function (lhs, rhs) {
|
|
146
146
|
return lhs.endDate.localeCompare(rhs.endDate);
|
|
147
147
|
});
|
|
@@ -151,9 +151,9 @@ function generateContact(contact, id) {
|
|
|
151
151
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
152
152
|
// PriorAddresses
|
|
153
153
|
previousAddresses.forEach(function (address, index) {
|
|
154
|
-
var _a = (0, address_tools_1.rebuildAddress)(address, id
|
|
154
|
+
var _a = (0, address_tools_1.rebuildAddress)(address, "".concat(id, "-prior-").concat(index)), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
|
|
155
155
|
lixiAddresses.push(lixiAddress);
|
|
156
|
-
(0, lodash_1.set)(lixiContact, contactMapping['priorAddress']
|
|
156
|
+
(0, lodash_1.set)(lixiContact, "".concat(contactMapping['priorAddress'], ".").concat(index), lixiContactAddress);
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
break;
|
|
@@ -17,14 +17,14 @@ function transformApplication(opportunity) {
|
|
|
17
17
|
var opportunityMapping = {
|
|
18
18
|
brand: application_paths_1.paths.BusinessName,
|
|
19
19
|
id: application_paths_1.paths.ApplicationId,
|
|
20
|
-
paymentType: application_paths_1.paths.LoanTerm
|
|
20
|
+
paymentType: "".concat(application_paths_1.paths.LoanTerm, ".@PaymentType"),
|
|
21
21
|
preliminary: 'preliminary',
|
|
22
22
|
primaryPurpose: application_paths_1.paths.PurposeOfApplication,
|
|
23
23
|
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
|
|
24
24
|
};
|
|
25
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail
|
|
26
|
-
(0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions
|
|
27
|
-
(0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions
|
|
25
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.LoanDetail, ".@UniqueID"), "".concat(opportunity.id, "-loanDetails"));
|
|
26
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
|
|
27
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.Instructions, ".@Name"), lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
|
|
28
28
|
for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
|
|
29
29
|
var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
|
|
30
30
|
if (opportunityMapping[opportunityKey]) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AddressType, Standard } from "@lendi/integrations-protocol/lib/types/lixi-internal-request";
|
|
2
|
+
import { Address, AddressStandard } from "../types/events/public-asset";
|
|
3
|
+
export declare function getAddressMapping(address: Address): Record<string, string>;
|
|
4
|
+
export declare const standardMapping: Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Generates an address for an asset.
|
|
7
|
+
*
|
|
8
|
+
* @param address: An address object.
|
|
9
|
+
* @param id: address event id.
|
|
10
|
+
* @param toBeUsedAsSecurity
|
|
11
|
+
* @return A transformed address object.
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformAddress(address: Address, id: string): Partial<AddressType>;
|
|
14
|
+
/**
|
|
15
|
+
* @description Generates an address standard.
|
|
16
|
+
* @param {AddressStandard} addressStandard An address standard object.
|
|
17
|
+
* @return {Partial<Standard>} A transformed standard object.
|
|
18
|
+
*/
|
|
19
|
+
export declare function transformStandard(addressStandard: AddressStandard): Partial<Standard>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.transformStandard = exports.transformAddress = exports.standardMapping = exports.getAddressMapping = void 0;
|
|
4
|
+
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
var enum_mappings_1 = require("../types/enum-mappings");
|
|
7
|
+
var address_tools_1 = require("../utils/address-tools");
|
|
8
|
+
function getAddressMapping(address) {
|
|
9
|
+
return {
|
|
10
|
+
city: '@Suburb',
|
|
11
|
+
country: '@Country',
|
|
12
|
+
postcode: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasPostCode' : '@AustralianPostCode',
|
|
13
|
+
state: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasState' : '@AustralianState',
|
|
14
|
+
standard: 'Standard',
|
|
15
|
+
formatted: '@Country'
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.getAddressMapping = getAddressMapping;
|
|
19
|
+
exports.standardMapping = {
|
|
20
|
+
streetName: '@StreetName',
|
|
21
|
+
streetType: '@StreetType',
|
|
22
|
+
streetNumber: '@StreetNumber',
|
|
23
|
+
level: '@Level',
|
|
24
|
+
unit: '@Unit'
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Generates an address for an asset.
|
|
28
|
+
*
|
|
29
|
+
* @param address: An address object.
|
|
30
|
+
* @param id: address event id.
|
|
31
|
+
* @param toBeUsedAsSecurity
|
|
32
|
+
* @return A transformed address object.
|
|
33
|
+
*/
|
|
34
|
+
function transformAddress(address, id) {
|
|
35
|
+
var transformedAddress = {
|
|
36
|
+
'@UniqueID': id
|
|
37
|
+
};
|
|
38
|
+
var addressMapping = getAddressMapping(address);
|
|
39
|
+
// for an Australian address: if no postcode is provided, infer one from the state:
|
|
40
|
+
if (!(0, address_tools_1.isOverseasAddress)(address) && address.state && !address.postcode) {
|
|
41
|
+
address.postcode = enum_mappings_1.postcodeMapping[address.state];
|
|
42
|
+
}
|
|
43
|
+
for (var _i = 0, _a = Object.entries(address); _i < _a.length; _i++) {
|
|
44
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
45
|
+
if (addressMapping[key]) {
|
|
46
|
+
switch (key) {
|
|
47
|
+
case 'standard':
|
|
48
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], transformStandard(value));
|
|
49
|
+
break;
|
|
50
|
+
case 'country':
|
|
51
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], (0, address_tools_1.isOverseasAddress)(address) ? enum_mappings_1.countryCodeMapping[value] : lixi_internal_request_1.CountryCodeList.Au);
|
|
52
|
+
break;
|
|
53
|
+
case 'formatted':
|
|
54
|
+
if (!address.country) {
|
|
55
|
+
var country = (0, address_tools_1.extractCountryFromFormatted)(value);
|
|
56
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], enum_mappings_1.countryCodeMapping[country]);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return transformedAddress;
|
|
66
|
+
}
|
|
67
|
+
exports.transformAddress = transformAddress;
|
|
68
|
+
/**
|
|
69
|
+
* @description Generates an address standard.
|
|
70
|
+
* @param {AddressStandard} addressStandard An address standard object.
|
|
71
|
+
* @return {Partial<Standard>} A transformed standard object.
|
|
72
|
+
*/
|
|
73
|
+
function transformStandard(addressStandard) {
|
|
74
|
+
var transformedStandard = {};
|
|
75
|
+
for (var _i = 0, _a = Object.entries(addressStandard); _i < _a.length; _i++) {
|
|
76
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
77
|
+
if (exports.standardMapping[key]) {
|
|
78
|
+
(0, lodash_1.set)(transformedStandard, exports.standardMapping[key], value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return transformedStandard;
|
|
82
|
+
}
|
|
83
|
+
exports.transformStandard = transformStandard;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyType as LixiPropertyType, Residential } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { Asset, Payload, PropertyType } from '../types/events/public-asset';
|
|
2
3
|
import { PartialApplication } from '../types/partial-application';
|
|
3
|
-
import { AddressType, Standard } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
4
|
-
import { Residential, PropertyType as LixiPropertyType } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
5
4
|
export interface PropertyTypeMapping {
|
|
6
5
|
path: string;
|
|
7
6
|
value: Residential | LixiPropertyType;
|
|
@@ -15,21 +14,6 @@ export declare const residentialTypeList: string[];
|
|
|
15
14
|
* @return {PartialApplication} A partial InternalRequest.
|
|
16
15
|
*/
|
|
17
16
|
export declare function transformAsset({ asset, applicationId, id }: Payload): PartialApplication;
|
|
18
|
-
/**
|
|
19
|
-
* Generates an address for an asset.
|
|
20
|
-
*
|
|
21
|
-
* @param address: An address object.
|
|
22
|
-
* @param id: address event id.
|
|
23
|
-
* @param toBeUsedAsSecurity
|
|
24
|
-
* @return A transformed address object.
|
|
25
|
-
*/
|
|
26
|
-
export declare function generateAddress(address: Address, id: string): Partial<AddressType>;
|
|
27
|
-
/**
|
|
28
|
-
* @description Generates an address standard.
|
|
29
|
-
* @param {AddressStandard} addressStandard An address standard object.
|
|
30
|
-
* @return {Partial<Standard>} A transformed standard object.
|
|
31
|
-
*/
|
|
32
|
-
export declare function generateStandard(addressStandard: AddressStandard): Partial<Standard>;
|
|
33
17
|
/**
|
|
34
18
|
* @description Map the propertyType to a RealEstateAsset path and the value.
|
|
35
19
|
* @param {PropertyType} propertyType - A propertyType.
|
|
@@ -11,18 +11,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
exports.__esModule = true;
|
|
14
|
-
exports.getAssetMapping = exports.getPropertyType = exports.
|
|
15
|
-
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
16
|
-
var public_asset_1 = require("../types/events/public-asset");
|
|
14
|
+
exports.getAssetMapping = exports.getPropertyType = exports.transformAsset = exports.residentialTypeList = exports.propertyTypeNameList = void 0;
|
|
17
15
|
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
16
|
+
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
17
|
+
var lixi_internal_request_2 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
18
18
|
var lodash_1 = require("lodash");
|
|
19
|
-
var
|
|
20
|
-
var transform_percent_owned_1 = require("./transform-percent-owned");
|
|
19
|
+
var logger_1 = require("../logger");
|
|
21
20
|
var enum_mappings_1 = require("../types/enum-mappings");
|
|
21
|
+
var public_asset_1 = require("../types/events/public-asset");
|
|
22
|
+
var get_financial_institution_1 = require("../utils/get-financial-institution");
|
|
22
23
|
var is_asset_type_1 = require("../utils/is-asset-type");
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var address_tools_1 = require("../utils/address-tools");
|
|
24
|
+
var transform_asset_address_1 = require("./transform-asset-address");
|
|
25
|
+
var transform_percent_owned_1 = require("./transform-percent-owned");
|
|
26
26
|
exports.propertyTypeNameList = Object.values(lixi_internal_request_2.Custom2PropertyTypeNameList);
|
|
27
27
|
exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
|
|
28
28
|
/**
|
|
@@ -34,39 +34,39 @@ exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialT
|
|
|
34
34
|
function transformAsset(_a) {
|
|
35
35
|
var asset = _a.asset, applicationId = _a.applicationId, id = _a.id;
|
|
36
36
|
var isPropertyAsset = (0, is_asset_type_1.isRealEstateAsset)(asset);
|
|
37
|
-
var idPath = isPropertyAsset ? application_paths_1.paths.RealEstateAsset
|
|
38
|
-
var addressId = id
|
|
37
|
+
var idPath = isPropertyAsset ? "".concat(application_paths_1.paths.RealEstateAsset, ".@UniqueID") : "".concat(application_paths_1.paths.NonRealEstateAsset, ".@UniqueID");
|
|
38
|
+
var addressId = "".concat(id, "-address");
|
|
39
39
|
var assetMapping = getAssetMapping(asset);
|
|
40
40
|
var partialApplication = {};
|
|
41
41
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
42
42
|
(0, lodash_1.set)(partialApplication, idPath, id);
|
|
43
43
|
if (isPropertyAsset) {
|
|
44
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset
|
|
45
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset
|
|
44
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@MultipleDwellings"), lixi_internal_request_1.YesNoList.No);
|
|
45
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@x_Address"), addressId);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
48
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), enum_mappings_1.assetTypeMapping[asset.type]);
|
|
49
49
|
}
|
|
50
50
|
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
51
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
52
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
51
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
|
|
52
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.@Type"), enum_mappings_1.financialAssetMapping[asset.type]);
|
|
53
53
|
}
|
|
54
54
|
if ((0, is_asset_type_1.isOtherAsset)(asset)) {
|
|
55
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
55
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
|
|
56
56
|
}
|
|
57
57
|
switch (asset.type) {
|
|
58
58
|
case public_asset_1.AssetType.Vehicle:
|
|
59
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
59
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
|
|
60
60
|
break;
|
|
61
61
|
case public_asset_1.AssetType.HomeContents:
|
|
62
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
62
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Type"), lixi_internal_request_1.OtherAssetTypeList.HomeContents);
|
|
63
63
|
break;
|
|
64
64
|
case public_asset_1.AssetType.Gifts:
|
|
65
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
65
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Description"), asset.description || 'Asset Gifts');
|
|
66
66
|
break;
|
|
67
67
|
case public_asset_1.AssetType.OtherAsset:
|
|
68
68
|
if (asset.description) {
|
|
69
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset
|
|
69
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Description"), asset.description);
|
|
70
70
|
}
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
@@ -95,14 +95,14 @@ function transformAsset(_a) {
|
|
|
95
95
|
case 'propertyType':
|
|
96
96
|
var propertyTypeMapping_1 = getPropertyType(value);
|
|
97
97
|
if (!propertyTypeMapping_1) {
|
|
98
|
-
logger_1.logger.warn({ message: "Unknown propertyType "
|
|
98
|
+
logger_1.logger.warn({ message: "Unknown propertyType ".concat(value, " for asset ").concat(id), applicationId: applicationId });
|
|
99
99
|
}
|
|
100
100
|
var path = propertyTypeMapping_1.path, mappedValue = propertyTypeMapping_1.value;
|
|
101
101
|
(0, lodash_1.set)(partialApplication, path, mappedValue);
|
|
102
102
|
break;
|
|
103
103
|
case 'zoneType':
|
|
104
104
|
if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
|
|
105
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset
|
|
105
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Commercial.@Type"), lixi_internal_request_1.OtherAssetTypeList.Other);
|
|
106
106
|
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom6TypeList.Commercial);
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
@@ -119,7 +119,7 @@ function transformAsset(_a) {
|
|
|
119
119
|
(0, lodash_1.set)(partialApplication, assetMapping[key], value.toString());
|
|
120
120
|
break;
|
|
121
121
|
case 'address':
|
|
122
|
-
(0, lodash_1.set)(partialApplication, assetMapping[key],
|
|
122
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], (0, transform_asset_address_1.transformAddress)(value, addressId));
|
|
123
123
|
break;
|
|
124
124
|
case 'percentOwned':
|
|
125
125
|
var percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
|
|
@@ -136,74 +136,6 @@ function transformAsset(_a) {
|
|
|
136
136
|
return partialApplication;
|
|
137
137
|
}
|
|
138
138
|
exports.transformAsset = transformAsset;
|
|
139
|
-
/**
|
|
140
|
-
* Generates an address for an asset.
|
|
141
|
-
*
|
|
142
|
-
* @param address: An address object.
|
|
143
|
-
* @param id: address event id.
|
|
144
|
-
* @param toBeUsedAsSecurity
|
|
145
|
-
* @return A transformed address object.
|
|
146
|
-
*/
|
|
147
|
-
function generateAddress(address, id) {
|
|
148
|
-
var transformedAddress = {
|
|
149
|
-
'@UniqueID': id
|
|
150
|
-
};
|
|
151
|
-
var addressMapping = {
|
|
152
|
-
city: '@Suburb',
|
|
153
|
-
country: '@Country',
|
|
154
|
-
postcode: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasPostCode' : '@AustralianPostCode',
|
|
155
|
-
state: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasState' : '@AustralianState',
|
|
156
|
-
standard: 'Standard',
|
|
157
|
-
formatted: '@Country'
|
|
158
|
-
};
|
|
159
|
-
for (var _i = 0, _a = Object.entries(address); _i < _a.length; _i++) {
|
|
160
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
161
|
-
if (addressMapping[key]) {
|
|
162
|
-
switch (key) {
|
|
163
|
-
case 'standard':
|
|
164
|
-
(0, lodash_1.set)(transformedAddress, addressMapping[key], generateStandard(value));
|
|
165
|
-
break;
|
|
166
|
-
case 'country':
|
|
167
|
-
(0, lodash_1.set)(transformedAddress, addressMapping[key], (0, address_tools_1.isOverseasAddress)(address) ? enum_mappings_1.countryCodeMapping[value] : lixi_internal_request_1.CountryCodeList.Au);
|
|
168
|
-
break;
|
|
169
|
-
case 'formatted':
|
|
170
|
-
if (!address.country) {
|
|
171
|
-
var country = (0, address_tools_1.extractCountryFromFormatted)(value);
|
|
172
|
-
(0, lodash_1.set)(transformedAddress, addressMapping[key], enum_mappings_1.countryCodeMapping[country]);
|
|
173
|
-
}
|
|
174
|
-
break;
|
|
175
|
-
default:
|
|
176
|
-
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return transformedAddress;
|
|
182
|
-
}
|
|
183
|
-
exports.generateAddress = generateAddress;
|
|
184
|
-
/**
|
|
185
|
-
* @description Generates an address standard.
|
|
186
|
-
* @param {AddressStandard} addressStandard An address standard object.
|
|
187
|
-
* @return {Partial<Standard>} A transformed standard object.
|
|
188
|
-
*/
|
|
189
|
-
function generateStandard(addressStandard) {
|
|
190
|
-
var transformedStandard = {};
|
|
191
|
-
var standardMapping = {
|
|
192
|
-
streetName: '@StreetName',
|
|
193
|
-
streetType: '@StreetType',
|
|
194
|
-
streetNumber: '@StreetNumber',
|
|
195
|
-
level: '@Level',
|
|
196
|
-
unit: '@Unit'
|
|
197
|
-
};
|
|
198
|
-
for (var _i = 0, _a = Object.entries(addressStandard); _i < _a.length; _i++) {
|
|
199
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
200
|
-
if (standardMapping[key]) {
|
|
201
|
-
(0, lodash_1.set)(transformedStandard, standardMapping[key], value);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return transformedStandard;
|
|
205
|
-
}
|
|
206
|
-
exports.generateStandard = generateStandard;
|
|
207
139
|
/**
|
|
208
140
|
* @description Map the propertyType to a RealEstateAsset path and the value.
|
|
209
141
|
* @param {PropertyType} propertyType - A propertyType.
|
|
@@ -213,7 +145,7 @@ function getPropertyType(propertyType) {
|
|
|
213
145
|
var value = enum_mappings_1.propertyTypeMapping[propertyType];
|
|
214
146
|
if (exports.residentialTypeList.includes(value)) {
|
|
215
147
|
return {
|
|
216
|
-
path: application_paths_1.paths.RealEstateAsset
|
|
148
|
+
path: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
|
|
217
149
|
value: {
|
|
218
150
|
'@Type': value
|
|
219
151
|
}
|
|
@@ -221,7 +153,7 @@ function getPropertyType(propertyType) {
|
|
|
221
153
|
}
|
|
222
154
|
if (exports.propertyTypeNameList.includes(value)) {
|
|
223
155
|
return {
|
|
224
|
-
path: application_paths_1.paths.RealEstateAsset
|
|
156
|
+
path: "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType"),
|
|
225
157
|
value: {
|
|
226
158
|
'@PropertyTypeName': value,
|
|
227
159
|
'@CategoryTypeName': lixi_internal_request_2.Custom1CategoryTypeNameList.Residential
|
|
@@ -237,34 +169,34 @@ exports.getPropertyType = getPropertyType;
|
|
|
237
169
|
* @returns {Record<string, string>} Asset Transform Mapping.
|
|
238
170
|
*/
|
|
239
171
|
function getAssetMapping(asset) {
|
|
240
|
-
var estimatedValue = application_paths_1.paths.NonRealEstateAsset
|
|
241
|
-
var percentOwned = application_paths_1.paths.NonRealEstateAsset
|
|
172
|
+
var estimatedValue = "".concat(application_paths_1.paths.NonRealEstateAsset, ".EstimatedValue.@Value");
|
|
173
|
+
var percentOwned = "".concat(application_paths_1.paths.NonRealEstateAsset, ".PercentOwned");
|
|
242
174
|
var baseMapping = {
|
|
243
175
|
estimatedValue: estimatedValue,
|
|
244
176
|
percentOwned: percentOwned
|
|
245
177
|
};
|
|
246
178
|
if ((0, is_asset_type_1.isRealEstateAsset)(asset)) {
|
|
247
|
-
estimatedValue = application_paths_1.paths.RealEstateAsset
|
|
248
|
-
percentOwned = application_paths_1.paths.RealEstateAsset
|
|
179
|
+
estimatedValue = "".concat(application_paths_1.paths.RealEstateAsset, ".EstimatedValue.@Value");
|
|
180
|
+
percentOwned = "".concat(application_paths_1.paths.RealEstateAsset, ".PercentOwned");
|
|
249
181
|
return {
|
|
250
182
|
address: application_paths_1.paths.Address,
|
|
251
183
|
contractDetails: 'contractDetails',
|
|
252
|
-
contractDate: application_paths_1.paths.RealEstateAsset
|
|
184
|
+
contractDate: "".concat(application_paths_1.paths.RealEstateAsset, ".ContractDetails.@ContractDate"),
|
|
253
185
|
estimatedValue: estimatedValue,
|
|
254
186
|
percentOwned: percentOwned,
|
|
255
|
-
primaryPurpose: application_paths_1.paths.RealEstateAsset
|
|
256
|
-
propertyStatus: application_paths_1.paths.RealEstateAsset
|
|
257
|
-
propertyType: application_paths_1.paths.RealEstateAsset
|
|
258
|
-
toBePurchased: application_paths_1.paths.RealEstateAsset
|
|
259
|
-
toBeUsedAsSecurity: application_paths_1.paths.RealEstateAsset
|
|
260
|
-
zoneType: application_paths_1.paths.RealEstateAsset
|
|
187
|
+
primaryPurpose: "".concat(application_paths_1.paths.RealEstateAsset, ".@PrimaryPurpose"),
|
|
188
|
+
propertyStatus: "".concat(application_paths_1.paths.RealEstateAsset, ".@Status"),
|
|
189
|
+
propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
|
|
190
|
+
toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
|
|
191
|
+
toBeUsedAsSecurity: "".concat(application_paths_1.paths.RealEstateAsset, ".@ToBeUsedAsSecurity"),
|
|
192
|
+
zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type")
|
|
261
193
|
};
|
|
262
194
|
}
|
|
263
195
|
if ((0, is_asset_type_1.isMotorVehicle)(asset)) {
|
|
264
|
-
return __assign(__assign({}, baseMapping), { make: application_paths_1.paths.NonRealEstateAsset
|
|
196
|
+
return __assign(__assign({}, baseMapping), { make: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Make"), model: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Model"), year: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Year") });
|
|
265
197
|
}
|
|
266
198
|
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
267
|
-
return __assign(__assign({}, baseMapping), { financialInstitution: application_paths_1.paths.NonRealEstateAsset
|
|
199
|
+
return __assign(__assign({}, baseMapping), { financialInstitution: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@FinancialInstitution"), financialInstitutionAccountNumber: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@AccountNumber"), financialInstitutionBsb: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@BSB") });
|
|
268
200
|
}
|
|
269
201
|
return baseMapping;
|
|
270
202
|
}
|
|
@@ -51,8 +51,8 @@ function transformExpenses(expense) {
|
|
|
51
51
|
}
|
|
52
52
|
var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
|
|
53
53
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
54
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household
|
|
55
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant
|
|
54
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
|
|
55
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
56
56
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
57
57
|
if (lixiLivingExpenses.length > 0) {
|
|
58
58
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
@@ -73,7 +73,7 @@ function transformExpense(expense, applicantId, index, id) {
|
|
|
73
73
|
'@Amount': expense.amount,
|
|
74
74
|
'@Category': enum_mappings_1.livingExpenseMapping[expense.type],
|
|
75
75
|
'@Description': expense.type,
|
|
76
|
-
'@UniqueID': isOtherCommitment(expense) ? id
|
|
76
|
+
'@UniqueID': isOtherCommitment(expense) ? "".concat(id, "-commitment-").concat(index) : "".concat(id, "-living-expense-").concat(index),
|
|
77
77
|
'@Frequency': enum_mappings_1.frequencyMapping[expense.frequency],
|
|
78
78
|
PercentResponsible: {
|
|
79
79
|
Owner: [
|
|
@@ -77,38 +77,38 @@ function getIncomeMapping(incomeType) {
|
|
|
77
77
|
if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
78
78
|
basePath = application_paths_1.paths.RealEstateAsset;
|
|
79
79
|
return {
|
|
80
|
-
assetId: basePath
|
|
81
|
-
percentOwned: basePath
|
|
80
|
+
assetId: "".concat(basePath, ".@UniqueID"),
|
|
81
|
+
percentOwned: "".concat(basePath, ".RentalIncome")
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
|
|
85
85
|
basePath = application_paths_1.paths.CompanyApplicant;
|
|
86
86
|
return {
|
|
87
|
-
bas: basePath
|
|
88
|
-
companyId: basePath
|
|
89
|
-
incomes: basePath
|
|
90
|
-
gross: basePath
|
|
87
|
+
bas: "".concat(basePath, ".Income[0].BusinessActivityStatement"),
|
|
88
|
+
companyId: "".concat(basePath, ".@UniqueID"),
|
|
89
|
+
incomes: "".concat(basePath, ".Income"),
|
|
90
|
+
gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
|
|
94
94
|
basePath = application_paths_1.paths.SelfEmployed;
|
|
95
95
|
var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
|
|
96
96
|
return {
|
|
97
|
-
amount: basePath
|
|
98
|
-
employmentId: basePath
|
|
97
|
+
amount: "".concat(basePath, ".").concat(amount),
|
|
98
|
+
employmentId: "".concat(basePath, ".@UniqueID")
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
|
|
102
102
|
basePath = application_paths_1.paths.PAYG;
|
|
103
103
|
var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
|
|
104
|
-
return __assign({ amount: basePath
|
|
104
|
+
return __assign({ amount: "".concat(basePath, ".").concat(amount), employmentId: "".concat(basePath, ".@UniqueID") }, (frequency && { frequency: "".concat(basePath, ".").concat(frequency) }));
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
-
amount: basePath
|
|
108
|
-
frequency: basePath
|
|
109
|
-
percentOwned: basePath
|
|
110
|
-
type: basePath
|
|
111
|
-
benefitType: basePath
|
|
107
|
+
amount: "".concat(basePath, ".@Amount"),
|
|
108
|
+
frequency: "".concat(basePath, ".@Frequency"),
|
|
109
|
+
percentOwned: "".concat(basePath, ".PercentOwned"),
|
|
110
|
+
type: "".concat(basePath, ".@Type"),
|
|
111
|
+
benefitType: "".concat(basePath, ".@GovernmentBenefitsType")
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
exports.getIncomeMapping = getIncomeMapping;
|
|
@@ -125,10 +125,10 @@ function transformIncome(payload, applicantId) {
|
|
|
125
125
|
var partialApplication = {};
|
|
126
126
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
127
127
|
if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
|
|
128
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant
|
|
128
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
|
|
129
129
|
}
|
|
130
130
|
if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
|
|
131
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome
|
|
131
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
|
|
132
132
|
}
|
|
133
133
|
var incomeMapping = getIncomeMapping(incomeType);
|
|
134
134
|
for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
|
|
@@ -161,7 +161,7 @@ function transformIncome(payload, applicantId) {
|
|
|
161
161
|
if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
|
|
162
162
|
var mappedType = enum_mappings_1.otherIncomeMapping[value];
|
|
163
163
|
if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
|
|
164
|
-
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome
|
|
164
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
|
|
165
165
|
(0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
|
|
166
166
|
}
|
|
167
167
|
else {
|
|
@@ -247,7 +247,7 @@ function generateIncomeBusinessDetails(data) {
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
else if (key === 'year') {
|
|
250
|
-
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value
|
|
250
|
+
(0, lodash_1.set)(income, dateAndIncomeMapping[key], "".concat(value, "-01-01"));
|
|
251
251
|
}
|
|
252
252
|
else {
|
|
253
253
|
(0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.transformPercentOwned = void 0;
|
|
4
|
+
var round_decimal_1 = require("../utils/round-decimal");
|
|
4
5
|
/**
|
|
5
6
|
* Transform percentOwned to lixi's format.
|
|
6
7
|
*
|
|
@@ -15,7 +16,7 @@ function transformPercentOwned(_a) {
|
|
|
15
16
|
Owner: owners.map(function (_a) {
|
|
16
17
|
var percent = _a.percent, applicantId = _a.applicantId;
|
|
17
18
|
return ({
|
|
18
|
-
'@Percent': percent * 100,
|
|
19
|
+
'@Percent': (0, round_decimal_1.roundDecimal)(percent * 100),
|
|
19
20
|
'@x_Party': applicantId
|
|
20
21
|
});
|
|
21
22
|
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep merges the application and custom handles specific arrays
|
|
3
|
+
*
|
|
4
|
+
* @param newApplication new application coming from events.
|
|
5
|
+
* @param existingApplication a saved dynamo application.
|
|
6
|
+
* @return merged application.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deepMergeApplication(existingApplication: object | undefined, newApplication: object): any;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.deepMergeApplication = void 0;
|
|
4
|
+
var merge = require("deepmerge");
|
|
5
|
+
var cleanDeep = require('clean-deep');
|
|
6
|
+
/**
|
|
7
|
+
* Deep merges the application and custom handles specific arrays
|
|
8
|
+
*
|
|
9
|
+
* @param newApplication new application coming from events.
|
|
10
|
+
* @param existingApplication a saved dynamo application.
|
|
11
|
+
* @return merged application.
|
|
12
|
+
*/
|
|
13
|
+
function deepMergeApplication(existingApplication, newApplication) {
|
|
14
|
+
// Array fields with @UniqueIDs
|
|
15
|
+
var listsWithUniqueIds = [
|
|
16
|
+
'Attachment',
|
|
17
|
+
'Address',
|
|
18
|
+
'CompanyApplicant',
|
|
19
|
+
'Dependant',
|
|
20
|
+
'Liability',
|
|
21
|
+
'LivingExpense',
|
|
22
|
+
'LoanDetails',
|
|
23
|
+
'NonRealEstateAsset',
|
|
24
|
+
'OtherCommitment',
|
|
25
|
+
'OtherIncome',
|
|
26
|
+
'PersonApplicant',
|
|
27
|
+
'RealEstateAsset',
|
|
28
|
+
'RelatedCompany',
|
|
29
|
+
'RelatedPerson',
|
|
30
|
+
];
|
|
31
|
+
// Array fields with @x_Party
|
|
32
|
+
var listsWithXParty = ['Report'];
|
|
33
|
+
// Array fields with @x_Owner
|
|
34
|
+
var listsWithXOwner = ['RentalIncome'];
|
|
35
|
+
// Array fields with @x_Applicant
|
|
36
|
+
var listsWithXApplicant = ['Applicant'];
|
|
37
|
+
// Array fields with @x_ResidentialAddress
|
|
38
|
+
var listsWithXResidentialAddress = ['PriorAddress'];
|
|
39
|
+
// Curried function which takes a uniqueKey and returns a function which will either replace
|
|
40
|
+
// or merge the item in the array based on the uniqueKey
|
|
41
|
+
if (!existingApplication) {
|
|
42
|
+
return newApplication;
|
|
43
|
+
}
|
|
44
|
+
var mergeItems = function (uniqueKey) {
|
|
45
|
+
return function (existingItem, newItem) {
|
|
46
|
+
// if not array continue with merge
|
|
47
|
+
if (!Array.isArray(newItem)) {
|
|
48
|
+
return merge(existingItem, newItem, options);
|
|
49
|
+
}
|
|
50
|
+
return findArrayItemAndMerge(existingItem, newItem, uniqueKey, options);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
var options = {
|
|
54
|
+
customMerge: function (key) {
|
|
55
|
+
if (listsWithUniqueIds.find(function (item) { return item === key; })) {
|
|
56
|
+
return mergeItems('@UniqueID');
|
|
57
|
+
}
|
|
58
|
+
if (listsWithXParty.find(function (item) { return item === key; })) {
|
|
59
|
+
return mergeItems('@x_Party');
|
|
60
|
+
}
|
|
61
|
+
if (listsWithXOwner.find(function (item) { return item === key; })) {
|
|
62
|
+
return mergeItems('@x_Owner');
|
|
63
|
+
}
|
|
64
|
+
if (listsWithXResidentialAddress.find(function (item) { return item === key; })) {
|
|
65
|
+
return mergeItems('@x_ResidentialAddress');
|
|
66
|
+
}
|
|
67
|
+
if (listsWithXApplicant.find(function (item) { return item === key; })) {
|
|
68
|
+
return mergeItems('@x_Applicant');
|
|
69
|
+
}
|
|
70
|
+
return mergeItems(key);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var mergedApplication = merge(existingApplication, newApplication, options);
|
|
74
|
+
// Default configurations of cleanDeep for reference.
|
|
75
|
+
var params = {
|
|
76
|
+
cleanValues: [],
|
|
77
|
+
emptyArrays: true,
|
|
78
|
+
emptyObjects: true,
|
|
79
|
+
emptyStrings: true,
|
|
80
|
+
NaNValues: true,
|
|
81
|
+
nullValues: true,
|
|
82
|
+
undefinedValues: true
|
|
83
|
+
};
|
|
84
|
+
return cleanDeep(mergedApplication, params);
|
|
85
|
+
}
|
|
86
|
+
exports.deepMergeApplication = deepMergeApplication;
|
|
87
|
+
var arrayItemToReplaceKeys = ['Owner', 'Attendee', 'Shareholder', 'Fee', 'ContributionFunds', 'RentalIncome'];
|
|
88
|
+
function findArrayItemAndMerge(existingItem, newItem, uniqueKey, options) {
|
|
89
|
+
// For some Key, overwritten the old value with the new data so no merge is happening.
|
|
90
|
+
if (arrayItemToReplaceKeys.includes(uniqueKey))
|
|
91
|
+
return newItem;
|
|
92
|
+
if (uniqueKey === 'Income' && existingItem && existingItem.some(function (item) { return item['@StartDate']; })) {
|
|
93
|
+
// Income array in CompanyApplicant
|
|
94
|
+
return newItem;
|
|
95
|
+
}
|
|
96
|
+
// Copying existing array
|
|
97
|
+
var mergedArray = existingItem.slice();
|
|
98
|
+
// Searching whether item in the new array exists in existing array
|
|
99
|
+
newItem.forEach(function (item) {
|
|
100
|
+
var indexOfItem = mergedArray.findIndex(function (existingItem) {
|
|
101
|
+
// TODO [CORE-2160] how to identify employment without go a level down.
|
|
102
|
+
// Employment needs to go one level deeper to check if the @UniqueID already exist.
|
|
103
|
+
if (uniqueKey === 'Employment') {
|
|
104
|
+
var currentEmploymentKeys = Object.keys(item);
|
|
105
|
+
var existingEmploymentKeys = Object.keys(existingItem);
|
|
106
|
+
if (currentEmploymentKeys.length && existingEmploymentKeys.length) {
|
|
107
|
+
// Get the unique id from the field with proper value for current employment. The types with undefined value
|
|
108
|
+
// are present in order to remove the related types from existing application. These undefined types will be
|
|
109
|
+
// removed from payload immediately after deep merging.
|
|
110
|
+
// @pliu 19/11/19
|
|
111
|
+
var currentEmployment = currentEmploymentKeys.find(function (key) { return item[key]; });
|
|
112
|
+
// Each employment can only have one of three types.
|
|
113
|
+
// @pliu 19/11/19
|
|
114
|
+
var existingEmployment = existingEmploymentKeys[0];
|
|
115
|
+
if (currentEmployment && existingEmployment) {
|
|
116
|
+
return existingItem[existingEmployment]['@UniqueID'] === item[currentEmployment]['@UniqueID'];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return -1;
|
|
120
|
+
}
|
|
121
|
+
return existingItem[uniqueKey] === item[uniqueKey];
|
|
122
|
+
});
|
|
123
|
+
// Checks if item should be added or merged
|
|
124
|
+
if (indexOfItem === -1) {
|
|
125
|
+
mergedArray.push(item);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
mergedArray[indexOfItem] = merge(mergedArray[indexOfItem], item, options);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return mergedArray;
|
|
132
|
+
}
|
|
@@ -12,6 +12,6 @@ function normaliseDate(dateOfBirth) {
|
|
|
12
12
|
var year = date.getFullYear();
|
|
13
13
|
var month = ('0' + (date.getMonth() + 1)).slice(-2);
|
|
14
14
|
var day = ('0' + date.getDate()).slice(-2);
|
|
15
|
-
return year
|
|
15
|
+
return "".concat(year, "-").concat(month, "-").concat(day);
|
|
16
16
|
}
|
|
17
17
|
exports.normaliseDate = normaliseDate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Library for kafka event data transforming",
|
|
5
5
|
"author": "Integrations <integrations@lendi.com.au>",
|
|
6
6
|
"homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
|
|
@@ -89,4 +89,4 @@
|
|
|
89
89
|
"semver:major": "npm version major",
|
|
90
90
|
"current:version": "echo $npm_package_version"
|
|
91
91
|
}
|
|
92
|
-
}
|
|
92
|
+
}
|