@lendi/integrations-transform 1.0.2 → 1.0.3

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 CHANGED
@@ -1,5 +1,5 @@
1
- export * from './transform-events/generate-applicant';
2
- export * from './transform-events/generate-application';
1
+ export * from './transform-events/transform-applicant';
2
+ export * from './transform-events/transform-application';
3
3
  export * from './transform-events/generate-asset';
4
4
  export * from './transform-events/generate-expenses';
5
5
  export * from './transform-events/generate-liability';
package/lib/index.js CHANGED
@@ -11,8 +11,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  exports.__esModule = true;
13
13
  /* istanbul ignore file */
14
- __exportStar(require("./transform-events/generate-applicant"), exports);
15
- __exportStar(require("./transform-events/generate-application"), exports);
14
+ __exportStar(require("./transform-events/transform-applicant"), exports);
15
+ __exportStar(require("./transform-events/transform-application"), exports);
16
16
  __exportStar(require("./transform-events/generate-asset"), exports);
17
17
  __exportStar(require("./transform-events/generate-expenses"), exports);
18
18
  __exportStar(require("./transform-events/generate-liability"), exports);
@@ -6,6 +6,24 @@
6
6
  "description": "uuid of application",
7
7
  "type": "string"
8
8
  },
9
+ "brokerPrimaryPurpose": {
10
+ "description": "Additional data point for broker to capture primary purpose, other than the preliminary primary purpose associated with current user journey for new purchase or refinance",
11
+ "enum": [
12
+ "COMMERCIAL",
13
+ "CONSTRUCTION",
14
+ "CONSTRUCTION_AND_PURCHASE",
15
+ "CONSTRUCTION_AND_REFINANCE",
16
+ "INTERNAL_REFINANCE",
17
+ "NEW_PURCHASE",
18
+ "PRE_APPROVAL",
19
+ "PURCHASE",
20
+ "PURCHASE_AND_REFINANCE",
21
+ "REFINANCE",
22
+ "SLR",
23
+ "TOP_UP",
24
+ "VARIATION"
25
+ ]
26
+ },
9
27
  "customerId": {
10
28
  "description": "Id of the customer",
11
29
  "type": "string"
@@ -101,6 +119,9 @@
101
119
  "meta": {
102
120
  "$ref": "#/definitions/applicationMeta"
103
121
  },
122
+ "brokerPrimaryPurpose": {
123
+ "$ref": "#/definitions/brokerPrimaryPurpose"
124
+ },
104
125
  "customerId": {
105
126
  "$ref": "#/definitions/customerId"
106
127
  },
@@ -17,11 +17,11 @@ function generateAssetLiabilityLink(_a) {
17
17
  liabilityId: application_paths_1.paths.Liability + ".@UniqueID",
18
18
  assetId: application_paths_1.paths.Liability + ".Security[0].@x_Security"
19
19
  };
20
- lodash_1.set(partialApplication, assetLiabilityMapping.applicationId, applicationId);
20
+ (0, lodash_1.set)(partialApplication, assetLiabilityMapping.applicationId, applicationId);
21
21
  for (var _i = 0, _b = Object.entries(relation); _i < _b.length; _i++) {
22
22
  var _c = _b[_i], key = _c[0], value = _c[1];
23
23
  if (assetLiabilityMapping[key]) {
24
- lodash_1.set(partialApplication, assetLiabilityMapping[key], value);
24
+ (0, lodash_1.set)(partialApplication, assetLiabilityMapping[key], value);
25
25
  }
26
26
  }
27
27
  return partialApplication;
@@ -48,43 +48,43 @@ exports.propertyTypeNameList = Object.values(lixi_internal_request_1.Custom3Prop
48
48
  function generateAsset(_a) {
49
49
  var asset = _a.asset, applicationId = _a.applicationId, id = _a.id;
50
50
  var partialApplication = {};
51
- lodash_1.set(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
51
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
52
52
  var isPropertyAsset = asset.type === public_asset_1.AssetType.Property;
53
53
  switch (asset.type) {
54
54
  case public_asset_1.AssetType.Vehicle:
55
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
55
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
56
56
  break;
57
57
  case public_asset_1.AssetType.Property:
58
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".@MultipleDwellings", lixi_internal_request_1.YesNoList.No);
58
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@MultipleDwellings", lixi_internal_request_1.YesNoList.No);
59
59
  break;
60
60
  case public_asset_1.AssetType.HomeContents:
61
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
62
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Type", lixi_internal_request_1.OtherAssetTypeList.HomeContents);
61
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
62
+ (0, lodash_1.set)(partialApplication, 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
65
  case public_asset_1.AssetType.OtherAsset:
66
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
66
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
67
67
  if (asset.description)
68
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Description", asset.description);
68
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Description", asset.description);
69
69
  break;
70
70
  case public_asset_1.AssetType.Shares:
71
71
  case public_asset_1.AssetType.Superannuation:
72
72
  case public_asset_1.AssetType.TermDeposit:
73
73
  case public_asset_1.AssetType.SavingCheckAccount:
74
74
  case public_asset_1.AssetType.ManagedFunds:
75
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
76
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.@Type", public_financial_asset_1.financialAssetMapping[asset.type]);
75
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
76
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.@Type", public_financial_asset_1.financialAssetMapping[asset.type]);
77
77
  break;
78
78
  default:
79
79
  logger_1.logger.warn({ message: "Unhandled asset type: " + asset.type, applicationId: applicationId });
80
80
  return;
81
81
  }
82
82
  if (isPropertyAsset) {
83
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".@UniqueID", id);
83
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@UniqueID", id);
84
84
  assetMapping.percentOwned = application_paths_1.paths.RealEstateAsset + ".PercentOwned";
85
85
  }
86
86
  else {
87
- lodash_1.set(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@UniqueID", id);
87
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@UniqueID", id);
88
88
  assetMapping.percentOwned = application_paths_1.paths.NonRealEstateAsset + ".PercentOwned";
89
89
  }
90
90
  for (var _i = 0, _b = Object.entries(asset); _i < _b.length; _i++) {
@@ -92,34 +92,34 @@ function generateAsset(_a) {
92
92
  if (assetMapping[key]) {
93
93
  switch (key) {
94
94
  case 'primaryPurpose':
95
- lodash_1.set(partialApplication, assetMapping[key], public_primary_purpose_1.primaryPurposeMapping[value]);
95
+ (0, lodash_1.set)(partialApplication, assetMapping[key], public_primary_purpose_1.primaryPurposeMapping[value]);
96
96
  break;
97
97
  case 'toBePurchased':
98
- lodash_1.set(partialApplication, assetMapping[key], toBePurchasedMapping[value]);
98
+ (0, lodash_1.set)(partialApplication, assetMapping[key], toBePurchasedMapping[value]);
99
99
  break;
100
100
  case 'propertyStatus':
101
- lodash_1.set(partialApplication, assetMapping[key], public_property_status_1.propertyStatusMapping[value]);
101
+ (0, lodash_1.set)(partialApplication, assetMapping[key], public_property_status_1.propertyStatusMapping[value]);
102
102
  break;
103
103
  case 'toBeUsedAsSecurity':
104
104
  if (isPropertyAsset)
105
- lodash_1.set(partialApplication, assetMapping[key], toBeUsedAsSecurityMapping[value]);
105
+ (0, lodash_1.set)(partialApplication, assetMapping[key], toBeUsedAsSecurityMapping[value]);
106
106
  break;
107
107
  case 'estimatedValue':
108
108
  if (isPropertyAsset) {
109
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".EstimatedValue.@Value", value);
109
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".EstimatedValue.@Value", value);
110
110
  }
111
111
  else {
112
- lodash_1.set(partialApplication, assetMapping[key], value);
112
+ (0, lodash_1.set)(partialApplication, assetMapping[key], value);
113
113
  }
114
114
  break;
115
115
  case 'propertyType':
116
116
  var mappedValue = public_property_type_1.propertyTypeMapping[value];
117
117
  if (exports.residentialTypeList.includes(mappedValue)) {
118
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".Residential.@Type", mappedValue);
118
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".Residential.@Type", mappedValue);
119
119
  }
120
120
  else if (exports.propertyTypeNameList.includes(mappedValue)) {
121
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".PropertyType.@PropertyTypeName", mappedValue);
122
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".PropertyType.@CategoryTypeName", lixi_internal_request_1.Custom2CategoryTypeNameList.Residential);
121
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".PropertyType.@PropertyTypeName", mappedValue);
122
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".PropertyType.@CategoryTypeName", lixi_internal_request_1.Custom2CategoryTypeNameList.Residential);
123
123
  }
124
124
  else {
125
125
  logger_1.logger.warn({ message: "Unknown propertyType " + value + " for asset " + id, applicationId: applicationId });
@@ -127,35 +127,35 @@ function generateAsset(_a) {
127
127
  break;
128
128
  case 'zoneType':
129
129
  if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
130
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".Commercial.@Type", lixi_internal_request_1.OtherAssetTypeList.Other);
131
- lodash_1.set(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Commercial);
130
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".Commercial.@Type", lixi_internal_request_1.OtherAssetTypeList.Other);
131
+ (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Commercial);
132
132
  }
133
133
  else {
134
- lodash_1.set(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Residential);
134
+ (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Residential);
135
135
  }
136
136
  break;
137
137
  case 'financialInstitution':
138
138
  if (isFinancialAsset(asset)) {
139
- var financialInstitution = get_financial_institution_1.getFinancialInstitution(value.toString());
140
- lodash_1.set(partialApplication, assetMapping[key], financialInstitution);
139
+ var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
140
+ (0, lodash_1.set)(partialApplication, assetMapping[key], financialInstitution);
141
141
  }
142
142
  break;
143
143
  case 'year':
144
- lodash_1.set(partialApplication, assetMapping[key], value.toString());
144
+ (0, lodash_1.set)(partialApplication, assetMapping[key], value.toString());
145
145
  break;
146
146
  case 'address':
147
147
  var addressId = id + "-address";
148
- lodash_1.set(partialApplication, application_paths_1.paths.RealEstateAsset + ".@x_Address", addressId);
149
- lodash_1.set(partialApplication, assetMapping[key], generate_address_1.generateAddress(value, addressId));
148
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@x_Address", addressId);
149
+ (0, lodash_1.set)(partialApplication, assetMapping[key], (0, generate_address_1.generateAddress)(value, addressId));
150
150
  break;
151
151
  case 'percentOwned':
152
- var percentOwned = generate_lixi_percentowned_1.generateLIXIPercentOwned(value);
152
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
153
153
  if (percentOwned) {
154
- lodash_1.set(partialApplication, assetMapping[key], percentOwned);
154
+ (0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
155
155
  }
156
156
  break;
157
157
  default:
158
- lodash_1.set(partialApplication, assetMapping[key], value);
158
+ (0, lodash_1.set)(partialApplication, assetMapping[key], value);
159
159
  }
160
160
  }
161
161
  }
@@ -33,9 +33,9 @@ function generateCreditReportRebuilt(creditReport) {
33
33
  };
34
34
  var partialApplication = {};
35
35
  // Set application id, attachment and credit assessment report.
36
- lodash_1.set(partialApplication, application_paths_1.paths.ApplicationId, creditReport.applicationId);
37
- lodash_1.set(partialApplication, application_paths_1.paths.Attachment, [attachment]);
38
- lodash_1.set(partialApplication, application_paths_1.paths.Report, [report]);
36
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, creditReport.applicationId);
37
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Attachment, [attachment]);
38
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Report, [report]);
39
39
  return partialApplication;
40
40
  }
41
41
  exports.generateCreditReportRebuilt = generateCreditReportRebuilt;
@@ -21,15 +21,15 @@ function generateEmployment(employment) {
21
21
  // Each one Employment object can only contain one of the three types. Set the three object to undefined so that the
22
22
  // other two types will be removed from the final result.
23
23
  // @pliu 19/11/19
24
- lodash_1.set(partialApplication, application_paths_1.paths.PAYG, undefined);
25
- lodash_1.set(partialApplication, application_paths_1.paths.SelfEmployed, undefined);
26
- lodash_1.set(partialApplication, application_paths_1.paths.NotEmployed, undefined);
24
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.PAYG, undefined);
25
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.SelfEmployed, undefined);
26
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NotEmployed, undefined);
27
27
  switch (employment.employmentType) {
28
28
  case public_employment_1.EmploymentType.Employee:
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
- lodash_1.set(partialApplication, employmentPath + ".@OnProbation", lixi_internal_request_1.YesNoList.No);
32
+ (0, lodash_1.set)(partialApplication, employmentPath + ".@OnProbation", lixi_internal_request_1.YesNoList.No);
33
33
  break;
34
34
  case public_employment_1.EmploymentType.SelfEmployed:
35
35
  isEmployed = true;
@@ -37,8 +37,8 @@ function generateEmployment(employment) {
37
37
  break;
38
38
  case public_employment_1.EmploymentType.NotWorking:
39
39
  employmentPath = application_paths_1.paths.NotEmployed;
40
- lodash_1.set(partialApplication, employmentPath + ".Income.@OtherIncomeAmount", 0);
41
- lodash_1.set(partialApplication, employmentPath + ".Income.@OtherIncomeFrequency", lixi_internal_request_1.List.Fortnightly);
40
+ (0, lodash_1.set)(partialApplication, employmentPath + ".Income.@OtherIncomeAmount", 0);
41
+ (0, lodash_1.set)(partialApplication, employmentPath + ".Income.@OtherIncomeFrequency", lixi_internal_request_1.List.Fortnightly);
42
42
  break;
43
43
  default:
44
44
  logger_1.logger.warn({ message: "Unknown EmploymentType " + employment.employmentType, applicationId: applicationId });
@@ -61,42 +61,42 @@ function generateEmployment(employment) {
61
61
  if (employmentMapping[key]) {
62
62
  switch (key) {
63
63
  case 'type':
64
- lodash_1.set(partialApplication, employmentMapping[key], lodash_1.capitalize(value));
64
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], (0, lodash_1.capitalize)(value));
65
65
  break;
66
66
  case 'abn':
67
67
  case 'businessName':
68
68
  // Only transform value in RelatedCompany for employed (self employed or employee) employment, otherwise RelatedCompany would missing UniqueID
69
69
  if (isEmployed) {
70
- lodash_1.set(partialApplication, employmentMapping[key], value.toString());
70
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value.toString());
71
71
  }
72
72
  break;
73
73
  case 'employmentBasis':
74
- lodash_1.set(partialApplication, employmentMapping[key], employment_basis_1.paygEmploymentBasisMapping[value]);
74
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], employment_basis_1.paygEmploymentBasisMapping[value]);
75
75
  break;
76
76
  case 'id':
77
- lodash_1.set(partialApplication, employmentMapping[key], value);
77
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
78
78
  if (isEmployed) {
79
- lodash_1.set(partialApplication, employmentPath + ".@x_Employer", value + "-businessName");
80
- lodash_1.set(partialApplication, application_paths_1.paths.RelatedCompany + ".@UniqueID", value + "-businessName");
79
+ (0, lodash_1.set)(partialApplication, employmentPath + ".@x_Employer", value + "-businessName");
80
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.RelatedCompany + ".@UniqueID", value + "-businessName");
81
81
  }
82
82
  break;
83
83
  case 'onProbation':
84
84
  if (employment.employmentType === public_employment_1.EmploymentType.Employee) {
85
85
  var onProbation = value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No;
86
- lodash_1.set(partialApplication, employmentMapping[key], onProbation);
86
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], onProbation);
87
87
  }
88
88
  break;
89
89
  case 'role':
90
90
  var _c = value.anzsco, anzsco = _c === void 0 ? {} : _c;
91
91
  if (anzsco.code) {
92
- lodash_1.set(partialApplication, employmentPath + ".@ANZSCOOccupationCode", anzsco.code.toString());
92
+ (0, lodash_1.set)(partialApplication, employmentPath + ".@ANZSCOOccupationCode", anzsco.code.toString());
93
93
  }
94
94
  if (anzsco.occupation) {
95
- lodash_1.set(partialApplication, employmentMapping[key], anzsco.occupation);
95
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], anzsco.occupation);
96
96
  }
97
97
  break;
98
98
  default:
99
- lodash_1.set(partialApplication, employmentMapping[key], value);
99
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
100
100
  break;
101
101
  }
102
102
  }
@@ -26,7 +26,7 @@ function generateExpenses(expense) {
26
26
  var expenseEstimate = expenses.find(function (expense) { return expense.type === public_expense_1.ExpenseType.LivingExpensesEstimate; });
27
27
  var livingExpenseEstimateExists = expenseEstimate && expenseEstimate.amount && expenseEstimate.amount > 0;
28
28
  var expensesWithoutEstimate = livingExpenses.filter(function (expense) { return expense.type !== public_expense_1.ExpenseType.LivingExpensesEstimate; });
29
- var expensesAmountSum = lodash_1.sumBy(expensesWithoutEstimate, 'amount');
29
+ var expensesAmountSum = (0, lodash_1.sumBy)(expensesWithoutEstimate, 'amount');
30
30
  if (expensesAmountSum === 0 && livingExpenseEstimateExists) {
31
31
  lixiLivingExpenses = [generateExpense(expenseEstimate, applicantId, 0, id)];
32
32
  }
@@ -36,12 +36,12 @@ function generateExpenses(expense) {
36
36
  });
37
37
  }
38
38
  if (lixiLivingExpenses.length > 0) {
39
- lodash_1.set(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
39
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
40
40
  }
41
- lodash_1.set(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
42
- lodash_1.set(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
43
- lodash_1.set(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
44
- lodash_1.set(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
41
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
42
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
43
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
44
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
45
45
  return partialApplication;
46
46
  }
47
47
  exports.generateExpenses = generateExpenses;
@@ -36,22 +36,22 @@ function generateFundingPosition(fundingPosition) {
36
36
  });
37
37
  break;
38
38
  case 'fundsRequiredBreakdown':
39
- lodash_1.set(partialApplication, application_paths_1.paths.SummaryFee, getFees(value, id));
39
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.SummaryFee, getFees(value, id));
40
40
  break;
41
41
  case 'totalCashOut':
42
- lodash_1.set(partialApplication, fundingPositionMapping[key], value);
43
- lodash_1.set(partialApplication, application_paths_1.paths.LoanDetail + ".@UniqueID", applicationId + "-loanDetails");
42
+ (0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
43
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail + ".@UniqueID", applicationId + "-loanDetails");
44
44
  break;
45
45
  case 'fundsRequested':
46
- lodash_1.set(partialApplication, fundingPositionMapping[key], Math.round(value));
46
+ (0, lodash_1.set)(partialApplication, fundingPositionMapping[key], Math.round(value));
47
47
  break;
48
48
  default:
49
- lodash_1.set(partialApplication, fundingPositionMapping[key], value);
49
+ (0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
50
50
  break;
51
51
  }
52
52
  }
53
53
  }
54
- lodash_1.set(partialApplication, application_paths_1.paths.ContributionFunds, contributionFunds);
54
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ContributionFunds, contributionFunds);
55
55
  return partialApplication;
56
56
  }
57
57
  exports.generateFundingPosition = generateFundingPosition;
@@ -64,7 +64,7 @@ exports.generateFundingPosition = generateFundingPosition;
64
64
  */
65
65
  function getFees(fundsRequiredBreakDown, id) {
66
66
  // Omitting constructionCosts as they don't belong in fees.
67
- return Object.entries(lodash_1.omit(fundsRequiredBreakDown, 'constructionCosts')).map(function (_a) {
67
+ return Object.entries((0, lodash_1.omit)(fundsRequiredBreakDown, 'constructionCosts')).map(function (_a) {
68
68
  var key = _a[0], value = _a[1];
69
69
  var descriptionList = ['accruedInterest', 'otherSundries'];
70
70
  var fee = {
@@ -91,7 +91,7 @@ exports.isRentalIncome = isRentalIncome;
91
91
  */
92
92
  function generateIncome(payload, storedApplication) {
93
93
  var applicationId = payload.applicationId, id = payload.id, income = payload.income;
94
- var applicantId = lodash_1.get(income, 'percentOwned.owners[0].applicantId');
94
+ var applicantId = (0, lodash_1.get)(income, 'percentOwned.owners[0].applicantId');
95
95
  if (!applicantId) {
96
96
  var employmentId = getEmploymentIdForIncome(payload);
97
97
  applicantId = getApplicantIdForEmploymentId(storedApplication, employmentId);
@@ -99,9 +99,9 @@ function generateIncome(payload, storedApplication) {
99
99
  var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
100
100
  var partialApplication = {};
101
101
  var incomeMapping;
102
- lodash_1.set(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
102
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
103
103
  if (applicantId && !isRentalIncome(incomeType)) {
104
- lodash_1.set(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
104
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
105
105
  }
106
106
  else {
107
107
  logger_1.logger.warn({
@@ -130,7 +130,7 @@ function generateIncome(payload, storedApplication) {
130
130
  };
131
131
  }
132
132
  else {
133
- lodash_1.set(partialApplication, application_paths_1.paths.OtherIncome + ".@UniqueID", id);
133
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome + ".@UniqueID", id);
134
134
  incomeMapping = {
135
135
  amount: application_paths_1.paths.OtherIncome + ".@Amount",
136
136
  frequency: application_paths_1.paths.OtherIncome + ".@Frequency",
@@ -145,35 +145,35 @@ function generateIncome(payload, storedApplication) {
145
145
  switch (key) {
146
146
  case 'amount':
147
147
  var amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
148
- lodash_1.set(partialApplication, incomeMapping[key], round_decimal_1.roundDecimal(amount));
148
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
149
149
  break;
150
150
  case 'frequency':
151
- lodash_1.set(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
151
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
152
152
  break;
153
153
  case 'percentOwned':
154
- var percentOwned = generate_lixi_percentowned_1.generateLIXIPercentOwned(value);
154
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
155
155
  if (isRentalIncome(incomeType)) {
156
156
  percentOwned = createRentalIncome(value, incomeAmount, incomeFrequency);
157
157
  }
158
158
  if (percentOwned) {
159
- lodash_1.set(partialApplication, incomeMapping[key], percentOwned);
159
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], percentOwned);
160
160
  }
161
161
  break;
162
162
  case 'type':
163
163
  var mappedType = income_type_1.otherIncomeMapping[value];
164
164
  if (descriptionOtherIncomeTypes.includes(value)) {
165
- lodash_1.set(partialApplication, application_paths_1.paths.OtherIncome + ".@Description", mappedType);
166
- lodash_1.set(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
165
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherIncome + ".@Description", mappedType);
166
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
167
167
  }
168
168
  else {
169
- lodash_1.set(partialApplication, incomeMapping[key], mappedType);
169
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], mappedType);
170
170
  }
171
171
  break;
172
172
  case 'benefitType':
173
- lodash_1.set(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
173
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], government_benefits_1.governmentBenefitsMapping[value]);
174
174
  break;
175
175
  default:
176
- lodash_1.set(partialApplication, incomeMapping[key], value);
176
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], value);
177
177
  break;
178
178
  }
179
179
  }
@@ -190,7 +190,7 @@ exports.generateIncome = generateIncome;
190
190
  function getApplicantIdForEmploymentId(application, employmentId) {
191
191
  if (!employmentId || !application)
192
192
  return null;
193
- var applicants = lodash_1.get(application, application_paths_1.paths.PersonApplicants, []);
193
+ var applicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
194
194
  var applicant = applicants.find(function (applicant) { return containsEmploymentId(applicant, employmentId); });
195
195
  return applicant ? applicant['@UniqueID'] : null;
196
196
  }
@@ -203,9 +203,9 @@ exports.getApplicantIdForEmploymentId = getApplicantIdForEmploymentId;
203
203
  */
204
204
  function containsEmploymentId(applicant, employmentId) {
205
205
  return (applicant.Employment || []).some(function (employment) {
206
- return lodash_1.get(employment, 'PAYG.@UniqueID') === employmentId ||
207
- lodash_1.get(employment, 'SelfEmployed.@UniqueID') === employmentId ||
208
- lodash_1.get(employment, 'NotEmployed.@UniqueID') === employmentId;
206
+ return (0, lodash_1.get)(employment, 'PAYG.@UniqueID') === employmentId ||
207
+ (0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') === employmentId ||
208
+ (0, lodash_1.get)(employment, 'NotEmployed.@UniqueID') === employmentId;
209
209
  });
210
210
  }
211
211
  exports.containsEmploymentId = containsEmploymentId;
@@ -35,13 +35,13 @@ function generateLiability(_a) {
35
35
  type: application_paths_1.paths.Liability + ".@Type",
36
36
  percentOwned: application_paths_1.paths.Liability + ".PercentOwned"
37
37
  };
38
- lodash_1.set(partialApplication, liabilityMapping.applicationId, applicationId);
39
- lodash_1.set(partialApplication, liabilityMapping.id, id);
38
+ (0, lodash_1.set)(partialApplication, liabilityMapping.applicationId, applicationId);
39
+ (0, lodash_1.set)(partialApplication, liabilityMapping.id, id);
40
40
  // Default repayments to 0 and repaymentFrequency to weekly.
41
- lodash_1.set(partialApplication, liabilityMapping.repaymentAmount, 0);
42
- lodash_1.set(partialApplication, liabilityMapping.repaymentFrequency, lixi_internal_request_1.List.Weekly);
41
+ (0, lodash_1.set)(partialApplication, liabilityMapping.repaymentAmount, 0);
42
+ (0, lodash_1.set)(partialApplication, liabilityMapping.repaymentFrequency, lixi_internal_request_1.List.Weekly);
43
43
  // Default clearingFromThisLoan to No if the value is not present in the event.
44
- lodash_1.set(partialApplication, liabilityMapping.clearingFromThisLoan, lixi_internal_request_1.YesNoList.No);
44
+ (0, lodash_1.set)(partialApplication, liabilityMapping.clearingFromThisLoan, lixi_internal_request_1.YesNoList.No);
45
45
  for (var _i = 0, _b = Object.entries(liability); _i < _b.length; _i++) {
46
46
  var _c = _b[_i], key = _c[0], value = _c[1];
47
47
  if (liabilityMapping[key]) {
@@ -49,35 +49,35 @@ function generateLiability(_a) {
49
49
  case 'outstandingBalance':
50
50
  case 'newLimit':
51
51
  case 'repaymentAmount':
52
- lodash_1.set(partialApplication, liabilityMapping[key], round_decimal_1.roundDecimal(value));
52
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], (0, round_decimal_1.roundDecimal)(value));
53
53
  break;
54
54
  case 'type':
55
- lodash_1.set(partialApplication, liabilityMapping[key], liability_type_1.liabilityTypeMapping[value]);
55
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], liability_type_1.liabilityTypeMapping[value]);
56
56
  break;
57
57
  case 'clearingFromThisLoan':
58
- lodash_1.set(partialApplication, liabilityMapping[key], value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
58
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
59
59
  break;
60
60
  case 'repaymentFrequency':
61
- lodash_1.set(partialApplication, liabilityMapping[key], alieo_frequency_1.liabilityFrequencyMapping[value]);
61
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], alieo_frequency_1.liabilityFrequencyMapping[value]);
62
62
  break;
63
63
  case 'repaymentTypeDetails':
64
- lodash_1.set(partialApplication, liabilityMapping[key], liability_payment_type_1.liabilityPaymentTypeMapping[value]);
64
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], liability_payment_type_1.liabilityPaymentTypeMapping[value]);
65
65
  break;
66
66
  case 'remainingTermDuration':
67
- lodash_1.set(partialApplication, liabilityMapping[key], Math.round(+value));
67
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], Math.round(+value));
68
68
  break;
69
69
  case 'financialInstitution':
70
- var financialInstitution = get_financial_institution_1.getFinancialInstitution(value.toString());
71
- lodash_1.set(partialApplication, liabilityMapping[key], financialInstitution);
70
+ var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
71
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], financialInstitution);
72
72
  break;
73
73
  case 'percentOwned':
74
- var percentOwned = generate_lixi_percentowned_1.generateLIXIPercentOwned(value);
74
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
75
75
  if (percentOwned) {
76
- lodash_1.set(partialApplication, liabilityMapping[key], percentOwned);
76
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], percentOwned);
77
77
  }
78
78
  break;
79
79
  default:
80
- lodash_1.set(partialApplication, liabilityMapping[key], value);
80
+ (0, lodash_1.set)(partialApplication, liabilityMapping[key], value);
81
81
  break;
82
82
  }
83
83
  }
@@ -19,11 +19,11 @@ 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
- lodash_1.set(partialApplication, application_paths_1.paths.Instructions + ".@UniqueID", opportunity.id + "-stage");
23
- lodash_1.set(partialApplication, opportunityMapping[key] + ".@Details", value || 'Unknown');
22
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions + ".@UniqueID", opportunity.id + "-stage");
23
+ (0, lodash_1.set)(partialApplication, opportunityMapping[key] + ".@Details", value || 'Unknown');
24
24
  }
25
25
  else {
26
- lodash_1.set(partialApplication, opportunityMapping[key], value);
26
+ (0, lodash_1.set)(partialApplication, opportunityMapping[key], value);
27
27
  }
28
28
  }
29
29
  }
@@ -28,23 +28,23 @@ 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
- lodash_1.set(partialApplication, application_paths_1.paths.ProofOfIdentity + ".@DocumentType", proof_of_identity_1.proofOfIdentityMapping[idType]);
32
- lodash_1.set(partialApplication, application_paths_1.paths.ProofOfIdentity + ".@DocumentNumber", idNumber);
31
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ProofOfIdentity + ".@DocumentType", proof_of_identity_1.proofOfIdentityMapping[idType]);
32
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ProofOfIdentity + ".@DocumentNumber", idNumber);
33
33
  if (gender) {
34
- lodash_1.set(partialApplication, application_paths_1.paths.PersonApplicant + ".@Gender", lodash_1.capitalize(gender));
34
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@Gender", (0, lodash_1.capitalize)(gender));
35
35
  }
36
36
  else {
37
- lodash_1.set(partialApplication, application_paths_1.paths.PersonApplicant + ".@Gender", title_gender_1.titleGenderMapping[idTitle]);
37
+ (0, lodash_1.set)(partialApplication, 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
- lodash_1.set(partialApplication, application_paths_1.paths.Privacy + ".@CreditAuthoritySigned", hasValidConsent);
44
- lodash_1.set(partialApplication, application_paths_1.paths.Privacy + ".@DateSigned", date_fns_1.format(new Date(consentedAt), 'yyyy-MM-dd'));
43
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Privacy + ".@CreditAuthoritySigned", hasValidConsent);
44
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Privacy + ".@DateSigned", (0, date_fns_1.format)(new Date(consentedAt), 'yyyy-MM-dd'));
45
45
  break;
46
46
  default:
47
- lodash_1.set(partialApplication, requiredDocsMapping[key], value);
47
+ (0, lodash_1.set)(partialApplication, requiredDocsMapping[key], value);
48
48
  break;
49
49
  }
50
50
  }
@@ -2,12 +2,12 @@ import { YesNoList } from '@lendi/integrations-protocol/lib/types/lixi-internal-
2
2
  import { Contact, Dependant, Payload as ApplicantPayload } from '../types/events/public-applicant';
3
3
  export declare const booleanMapping: (input?: boolean) => YesNoList;
4
4
  /**
5
- * Generates a partial LIXI application from a partial Applicant event.
5
+ * Transforms a partial Applicant event to a partial LIXI application.
6
6
  *
7
7
  * @param applicant: A partial applicant.
8
8
  * @return partialApplication an incomplete application.
9
9
  */
10
- export declare function generateApplicant(applicant: ApplicantPayload): {};
10
+ export declare function transformApplicant(applicant: ApplicantPayload): {};
11
11
  /**
12
12
  * Generates a LIXI contact from given contact.
13
13
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.generateDependants = exports.generateContact = exports.generateApplicant = exports.booleanMapping = void 0;
3
+ exports.generateDependants = exports.generateContact = exports.transformApplicant = exports.booleanMapping = void 0;
4
4
  var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
5
  var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
6
  var lodash_1 = require("lodash");
@@ -34,75 +34,75 @@ var applicantMapping = {
34
34
  title: application_paths_1.paths.PersonName + ".@NameTitle"
35
35
  };
36
36
  /**
37
- * Generates a partial LIXI application from a partial Applicant event.
37
+ * Transforms a partial Applicant event to a partial LIXI application.
38
38
  *
39
39
  * @param applicant: A partial applicant.
40
40
  * @return partialApplication an incomplete application.
41
41
  */
42
- function generateApplicant(applicant) {
42
+ function transformApplicant(applicant) {
43
43
  var partialApplication = {};
44
44
  var applicantId = applicant.id, applicationId = applicant.applicationId;
45
- lodash_1.set(partialApplication, applicantMapping['isFirstHomeBuyer'], exports.booleanMapping(applicant.isFirstHomeBuyer));
46
- lodash_1.set(partialApplication, applicantMapping['isPrimaryApplicant'], exports.booleanMapping(applicant.isPrimaryApplicant));
47
- lodash_1.set(partialApplication, applicantMapping['title'], title_1.titleMapping[applicant.title || public_applicant_1.Title.Unknown]);
48
- var applicantUpdated = lodash_1.omit(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
45
+ (0, lodash_1.set)(partialApplication, applicantMapping['isFirstHomeBuyer'], (0, exports.booleanMapping)(applicant.isFirstHomeBuyer));
46
+ (0, lodash_1.set)(partialApplication, applicantMapping['isPrimaryApplicant'], (0, exports.booleanMapping)(applicant.isPrimaryApplicant));
47
+ (0, lodash_1.set)(partialApplication, applicantMapping['title'], title_1.titleMapping[applicant.title || public_applicant_1.Title.Unknown]);
48
+ var applicantUpdated = (0, lodash_1.omit)(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
49
49
  for (var _i = 0, _a = Object.entries(applicantUpdated); _i < _a.length; _i++) {
50
50
  var _b = _a[_i], key = _b[0], value = _b[1];
51
51
  if (applicantMapping[key]) {
52
52
  switch (key) {
53
53
  case 'dateOfBirth':
54
- lodash_1.set(partialApplication, applicantMapping[key], normalise_date_1.normaliseDate(value));
54
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], (0, normalise_date_1.normaliseDate)(value));
55
55
  break;
56
56
  case 'maritalStatus':
57
- lodash_1.set(partialApplication, applicantMapping[key], marital_status_1.maritalStatusMapping[value]);
57
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], marital_status_1.maritalStatusMapping[value]);
58
58
  break;
59
59
  case 'citizenship':
60
- lodash_1.set(partialApplication, applicantMapping[key], country_code_1.countryCodeMapping[value]);
60
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], country_code_1.countryCodeMapping[value]);
61
61
  break;
62
62
  case 'residencyStatus':
63
- lodash_1.set(partialApplication, applicantMapping[key], residency_status_1.residencyStatusMapping[value]);
63
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], residency_status_1.residencyStatusMapping[value]);
64
64
  // Certain bank integrations require the ability to differentiate between permanentResident and Citizen
65
65
  // As lixi does not have a citizen enum for residencyStatus citizen is mapped to permanentResident
66
66
  // Adding a @Citizenship attribute to person applicant gives us the ability to determine citizenship status
67
67
  // If citizen this field will be always added and value will be AU.
68
68
  // @tsilva 21/11/19
69
69
  if (value === public_applicant_1.ResidencyStatus.AustralianCitizen) {
70
- lodash_1.set(partialApplication, applicantMapping.citizenship, lixi_internal_request_1.CountryCodeList.Au);
70
+ (0, lodash_1.set)(partialApplication, applicantMapping.citizenship, lixi_internal_request_1.CountryCodeList.Au);
71
71
  }
72
72
  break;
73
73
  case 'maritalDetails':
74
- var id = lodash_1.get(value, 'applicantId');
74
+ var id = (0, lodash_1.get)(value, 'applicantId');
75
75
  if (id)
76
- lodash_1.set(partialApplication, applicantMapping[key], id);
76
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], id);
77
77
  break;
78
78
  case 'contact':
79
79
  var _c = generateContact(value, applicantId), lixiContact = _c.lixiContact, lixiAddresses = _c.lixiAddresses;
80
- lodash_1.set(partialApplication, applicantMapping[key], lixiContact);
80
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], lixiContact);
81
81
  if (lixiAddresses.length > 0) {
82
- lodash_1.set(partialApplication, application_paths_1.paths.Addresses, lixiAddresses);
82
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Addresses, lixiAddresses);
83
83
  }
84
84
  break;
85
85
  case 'dependants':
86
86
  var dependants = generateDependants(value, applicantId);
87
- lodash_1.set(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
88
- lodash_1.set(partialApplication, application_paths_1.paths.Household + ".Dependant", dependants);
87
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
88
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".Dependant", dependants);
89
89
  break;
90
90
  default:
91
- lodash_1.set(partialApplication, applicantMapping[key], value);
91
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], value);
92
92
  break;
93
93
  }
94
94
  }
95
95
  }
96
96
  return partialApplication;
97
97
  }
98
- exports.generateApplicant = generateApplicant;
98
+ exports.transformApplicant = transformApplicant;
99
99
  var contactMapping = {
100
100
  emailAddress: 'EmailAddress.0.@Email',
101
101
  mobileNumber: 'Mobile.@Number',
102
102
  currentAddress: 'CurrentAddress',
103
103
  previousAddresses: 'PreviousAddress',
104
104
  priorAddress: 'PriorAddress',
105
- mailingAddress: 'CurrentAddress.x_MailingAddress',
105
+ mailingAddress: 'CurrentAddress.@x_MailingAddress',
106
106
  postSettlementAddress: 'PostSettlementAddress'
107
107
  };
108
108
  /**
@@ -121,25 +121,25 @@ function generateContact(contact, id) {
121
121
  case 'currentAddress':
122
122
  {
123
123
  var addressId = id + "-current";
124
- var _c = address_tools_1.rebuildAddress(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
124
+ var _c = (0, address_tools_1.rebuildAddress)(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
125
125
  lixiAddresses.push(lixiAddress);
126
- lodash_1.set(lixiContact, contactMapping[key], lixiContactAddress);
126
+ (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
127
127
  }
128
128
  break;
129
129
  case 'postSettlementAddress':
130
130
  {
131
131
  var addressId = id + "-postSettlement";
132
- var _d = address_tools_1.rebuildAddress({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
132
+ var _d = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
133
133
  lixiAddresses.push(lixiAddress);
134
- lodash_1.set(lixiContact, contactMapping[key], lixiContactAddress);
134
+ (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
135
135
  }
136
136
  break;
137
137
  case 'mailingAddress':
138
138
  {
139
139
  var addressId = id + "-mailing";
140
- var _e = address_tools_1.rebuildAddress({ residentialAddress: value }, addressId), lixiAddress = _e.lixiAddress, lixiContactAddress = _e.lixiContactAddress;
140
+ var lixiAddress = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId).lixiAddress;
141
141
  lixiAddresses.push(lixiAddress);
142
- lodash_1.set(lixiContact, contactMapping[key], addressId);
142
+ (0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
143
143
  }
144
144
  break;
145
145
  case 'previousAddresses':
@@ -149,19 +149,19 @@ function generateContact(contact, id) {
149
149
  return lhs.endDate.localeCompare(rhs.endDate);
150
150
  });
151
151
  var previousAddress = previousAddresses.pop();
152
- var _f = address_tools_1.rebuildAddress(previousAddress, addressId), lixiAddress = _f.lixiAddress, lixiContactAddress = _f.lixiContactAddress;
152
+ var _e = (0, address_tools_1.rebuildAddress)(previousAddress, addressId), lixiAddress = _e.lixiAddress, lixiContactAddress = _e.lixiContactAddress;
153
153
  lixiAddresses.push(lixiAddress);
154
- lodash_1.set(lixiContact, contactMapping[key], lixiContactAddress);
154
+ (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
155
155
  // PriorAddresses
156
156
  previousAddresses.forEach(function (address, index) {
157
- var _a = address_tools_1.rebuildAddress(address, id + "-prior-" + index), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
157
+ var _a = (0, address_tools_1.rebuildAddress)(address, id + "-prior-" + index), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
158
158
  lixiAddresses.push(lixiAddress);
159
- lodash_1.set(lixiContact, contactMapping['priorAddress'] + "." + index, lixiContactAddress);
159
+ (0, lodash_1.set)(lixiContact, contactMapping['priorAddress'] + "." + index, lixiContactAddress);
160
160
  });
161
161
  }
162
162
  break;
163
163
  default:
164
- lodash_1.set(lixiContact, contactMapping[key], value);
164
+ (0, lodash_1.set)(lixiContact, contactMapping[key], value);
165
165
  break;
166
166
  }
167
167
  }
@@ -1,8 +1,8 @@
1
1
  import { Payload as ApplicationPayload } from '../types/events/public-application';
2
2
  /**
3
- * Generates a partial internal request from a partial opportunity event.
3
+ * Transforms a partial opportunity event to a partial internal request.
4
4
  *
5
5
  * @param opportunity: Partial opportunity event.
6
6
  * @return partialApplication: A partial internal request.
7
7
  */
8
- export declare function generateApplication(opportunity: ApplicationPayload): {};
8
+ export declare function transformApplication(opportunity: ApplicationPayload): {};
@@ -1,26 +1,31 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.generateApplication = void 0;
3
+ exports.transformApplication = void 0;
4
+ var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
4
5
  var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
+ var application_paths_2 = require("@lendi/integrations-credit-protocol/utils/application-paths");
5
7
  var lodash_1 = require("lodash");
6
8
  var preferred_repayment_1 = require("../types/enum-mappings/preferred-repayment");
7
9
  var transaction_type_1 = require("../types/enum-mappings/transaction-type");
8
10
  /**
9
- * Generates a partial internal request from a partial opportunity event.
11
+ * Transforms a partial opportunity event to a partial internal request.
10
12
  *
11
13
  * @param opportunity: Partial opportunity event.
12
14
  * @return partialApplication: A partial internal request.
13
15
  */
14
- function generateApplication(opportunity) {
16
+ function transformApplication(opportunity) {
15
17
  var partialApplication = {};
16
18
  var opportunityMapping = {
17
19
  brand: application_paths_1.paths.BusinessName,
18
20
  id: application_paths_1.paths.ApplicationId,
19
21
  paymentType: application_paths_1.paths.LoanTerm + ".@PaymentType",
20
22
  preliminary: 'preliminary',
21
- primaryPurpose: application_paths_1.paths.PurposeOfApplication
23
+ primaryPurpose: application_paths_1.paths.PurposeOfApplication,
24
+ brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
22
25
  };
23
- lodash_1.set(partialApplication, application_paths_1.paths.LoanDetail + ".@UniqueID", opportunity.id + "-loanDetails");
26
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail + ".@UniqueID", opportunity.id + "-loanDetails");
27
+ (0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions + ".@UniqueID", opportunity.id + "-stage");
28
+ (0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions + ".@Name", lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
24
29
  for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
25
30
  var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
26
31
  if (opportunityMapping[opportunityKey]) {
@@ -30,20 +35,20 @@ function generateApplication(opportunity) {
30
35
  if (opportunityMapping[key]) {
31
36
  switch (key) {
32
37
  case 'paymentType':
33
- lodash_1.set(partialApplication, opportunityMapping[key], preferred_repayment_1.preferredRepaymentMapping[value]);
38
+ (0, lodash_1.set)(partialApplication, opportunityMapping[key], preferred_repayment_1.preferredRepaymentMapping[value]);
34
39
  break;
35
40
  case 'primaryPurpose':
36
- lodash_1.set(partialApplication, opportunityMapping[key], transaction_type_1.transactionTypeMapping[value]);
41
+ (0, lodash_1.set)(partialApplication, opportunityMapping[key], transaction_type_1.transactionTypeMapping[value]);
37
42
  break;
38
43
  }
39
44
  }
40
45
  }
41
46
  }
42
47
  else {
43
- lodash_1.set(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
48
+ (0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
44
49
  }
45
50
  }
46
51
  }
47
52
  return partialApplication;
48
53
  }
49
- exports.generateApplication = generateApplication;
54
+ exports.transformApplication = transformApplication;
@@ -11,6 +11,7 @@ export interface PublicApplication {
11
11
  }
12
12
  export interface Payload {
13
13
  brand?: Brand;
14
+ brokerPrimaryPurpose?: BrokerPrimaryPurpose;
14
15
  clonedFromApplicationId?: string;
15
16
  customerId?: string;
16
17
  hidden?: boolean;
@@ -25,6 +26,25 @@ export declare enum Brand {
25
26
  Lendi = "lendi",
26
27
  LendiVariation = "lendi variation"
27
28
  }
29
+ /**
30
+ * Additional data point for broker to capture primary purpose, other than the preliminary
31
+ * primary purpose associated with current user journey for new purchase or refinance
32
+ */
33
+ export declare enum BrokerPrimaryPurpose {
34
+ Commercial = "COMMERCIAL",
35
+ Construction = "CONSTRUCTION",
36
+ ConstructionAndPurchase = "CONSTRUCTION_AND_PURCHASE",
37
+ ConstructionAndRefinance = "CONSTRUCTION_AND_REFINANCE",
38
+ InternalRefinance = "INTERNAL_REFINANCE",
39
+ NewPurchase = "NEW_PURCHASE",
40
+ PreApproval = "PRE_APPROVAL",
41
+ Purchase = "PURCHASE",
42
+ PurchaseAndRefinance = "PURCHASE_AND_REFINANCE",
43
+ Refinance = "REFINANCE",
44
+ Slr = "SLR",
45
+ TopUp = "TOP_UP",
46
+ Variation = "VARIATION"
47
+ }
28
48
  /**
29
49
  * The metadata of the application
30
50
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.PublicApplicationType = exports.Urgency = exports.RefinancingReason = exports.PurchaseSituation = exports.PurchaseReason = exports.PrimaryPurpose = exports.PaymentType = exports.EligibleForFHOG = exports.DesiredFeature = exports.ContributionType = exports.ActionedByRole = exports.Brand = void 0;
3
+ exports.PublicApplicationType = exports.Urgency = exports.RefinancingReason = exports.PurchaseSituation = exports.PurchaseReason = exports.PrimaryPurpose = exports.PaymentType = exports.EligibleForFHOG = exports.DesiredFeature = exports.ContributionType = exports.ActionedByRole = exports.BrokerPrimaryPurpose = exports.Brand = void 0;
4
4
  var Brand;
5
5
  (function (Brand) {
6
6
  Brand["Domain"] = "domain";
@@ -8,6 +8,26 @@ var Brand;
8
8
  Brand["Lendi"] = "lendi";
9
9
  Brand["LendiVariation"] = "lendi variation";
10
10
  })(Brand = exports.Brand || (exports.Brand = {}));
11
+ /**
12
+ * Additional data point for broker to capture primary purpose, other than the preliminary
13
+ * primary purpose associated with current user journey for new purchase or refinance
14
+ */
15
+ var BrokerPrimaryPurpose;
16
+ (function (BrokerPrimaryPurpose) {
17
+ BrokerPrimaryPurpose["Commercial"] = "COMMERCIAL";
18
+ BrokerPrimaryPurpose["Construction"] = "CONSTRUCTION";
19
+ BrokerPrimaryPurpose["ConstructionAndPurchase"] = "CONSTRUCTION_AND_PURCHASE";
20
+ BrokerPrimaryPurpose["ConstructionAndRefinance"] = "CONSTRUCTION_AND_REFINANCE";
21
+ BrokerPrimaryPurpose["InternalRefinance"] = "INTERNAL_REFINANCE";
22
+ BrokerPrimaryPurpose["NewPurchase"] = "NEW_PURCHASE";
23
+ BrokerPrimaryPurpose["PreApproval"] = "PRE_APPROVAL";
24
+ BrokerPrimaryPurpose["Purchase"] = "PURCHASE";
25
+ BrokerPrimaryPurpose["PurchaseAndRefinance"] = "PURCHASE_AND_REFINANCE";
26
+ BrokerPrimaryPurpose["Refinance"] = "REFINANCE";
27
+ BrokerPrimaryPurpose["Slr"] = "SLR";
28
+ BrokerPrimaryPurpose["TopUp"] = "TOP_UP";
29
+ BrokerPrimaryPurpose["Variation"] = "VARIATION";
30
+ })(BrokerPrimaryPurpose = exports.BrokerPrimaryPurpose || (exports.BrokerPrimaryPurpose = {}));
11
31
  /**
12
32
  * role of the user that made the action
13
33
  */
@@ -71,9 +71,9 @@ function mapTransform(source, pathMappedTransform) {
71
71
  var finalTransform = {};
72
72
  Object.entries(pathMappedTransform).forEach(function (_a) {
73
73
  var key = _a[0], _b = _a[1], transform = _b.transform, path = _b.path;
74
- var sourceValue = lodash_1.get(source, key);
74
+ var sourceValue = (0, lodash_1.get)(source, key);
75
75
  if (sourceValue) {
76
- lodash_1.set(finalTransform, path, (transform === null || transform === void 0 ? void 0 : transform(sourceValue)) || sourceValue);
76
+ (0, lodash_1.set)(finalTransform, path, (transform === null || transform === void 0 ? void 0 : transform(sourceValue)) || sourceValue);
77
77
  }
78
78
  });
79
79
  return finalTransform;
@@ -91,7 +91,7 @@ function rebuildAddress(eventAddress, addressId) {
91
91
  if (isMissingCountry(eventAddress)) {
92
92
  setCountry(eventAddress);
93
93
  }
94
- if (lodash_1.get(eventAddress, 'residentialAddress.country') !== public_applicant_1.Countries.Australia) {
94
+ if ((0, lodash_1.get)(eventAddress, 'residentialAddress.country') !== public_applicant_1.Countries.Australia) {
95
95
  exports.lixiAddressMapping[postcodePathString] = { path: '@OverseasPostCode' };
96
96
  exports.lixiAddressMapping[statePathString] = { path: '@OverseasState' };
97
97
  }
@@ -125,7 +125,7 @@ exports.rebuildPreviousAddress = rebuildPreviousAddress;
125
125
  */
126
126
  function isMissingCountry(addressEvent) {
127
127
  if (addressEvent.residentialAddress && addressEvent.residentialAddress.formatted) {
128
- return !lodash_1.get(addressEvent, 'residentialAddress.country');
128
+ return !(0, lodash_1.get)(addressEvent, 'residentialAddress.country');
129
129
  }
130
130
  return false;
131
131
  }
@@ -137,7 +137,7 @@ exports.isMissingCountry = isMissingCountry;
137
137
  */
138
138
  function setCountry(address) {
139
139
  var _a;
140
- var formatted = lodash_1.get(address, 'residentialAddress.formatted');
140
+ var formatted = (0, lodash_1.get)(address, 'residentialAddress.formatted');
141
141
  if (formatted && !address.residentialAddress.country) {
142
142
  address.residentialAddress.country = (_a = formatted.split(',').pop()) === null || _a === void 0 ? void 0 : _a.trim();
143
143
  }
@@ -55,13 +55,13 @@ function generateAddress(address, id) {
55
55
  if (addressMapping[key]) {
56
56
  switch (key) {
57
57
  case 'standard':
58
- lodash_1.set(transformedAddress, addressMapping[key], generateStandard(value));
58
+ (0, lodash_1.set)(transformedAddress, addressMapping[key], generateStandard(value));
59
59
  break;
60
60
  case 'country':
61
- lodash_1.set(transformedAddress, addressMapping[key], country_code_1.countryCodeMapping[value]);
61
+ (0, lodash_1.set)(transformedAddress, addressMapping[key], country_code_1.countryCodeMapping[value]);
62
62
  break;
63
63
  default:
64
- lodash_1.set(transformedAddress, addressMapping[key], value);
64
+ (0, lodash_1.set)(transformedAddress, addressMapping[key], value);
65
65
  break;
66
66
  }
67
67
  }
@@ -81,14 +81,14 @@ function generateStandard(addressStandard) {
81
81
  if (standardMapping[key]) {
82
82
  switch (key) {
83
83
  case 'streetNumber':
84
- lodash_1.set(transformedStandard, standardMapping[key], value.substring(0, exports.StreetNumberMaxLength));
84
+ (0, lodash_1.set)(transformedStandard, standardMapping[key], value.substring(0, exports.StreetNumberMaxLength));
85
85
  break;
86
86
  case 'streetType':
87
87
  var streetType = exports.StreetTypeArray.find(function (type) { return type.toLowerCase() === value.toLowerCase(); });
88
- lodash_1.set(transformedStandard, standardMapping[key], streetType || lixi_internal_request_1.StreetTypeList.Street);
88
+ (0, lodash_1.set)(transformedStandard, standardMapping[key], streetType || lixi_internal_request_1.StreetTypeList.Street);
89
89
  break;
90
90
  default:
91
- lodash_1.set(transformedStandard, standardMapping[key], value);
91
+ (0, lodash_1.set)(transformedStandard, standardMapping[key], value);
92
92
  break;
93
93
  }
94
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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",
@@ -22,6 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@lendi/integrations-protocol": "2.3.0",
25
+ "@lendi/integrations-credit-protocol": "1.13.9",
25
26
  "date-fns": "2.19.0",
26
27
  "dd-trace": "^0.28.1",
27
28
  "lodash": "^4.17.15",