@lendi/integrations-transform 1.0.7 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/lib/index.d.ts +7 -0
  2. package/lib/index.js +20 -0
  3. package/lib/logger.d.ts +2 -0
  4. package/lib/logger.js +5 -0
  5. package/lib/schemas/credit-report-retrieved-event.json +57 -0
  6. package/lib/schemas/public-applicant-event.json +652 -0
  7. package/lib/schemas/public-application-event.json +224 -0
  8. package/lib/schemas/public-asset-event.json +633 -0
  9. package/lib/schemas/public-asset-liability-relation-delete-event.json +74 -0
  10. package/lib/schemas/public-asset-liability-relation-event.json +73 -0
  11. package/lib/schemas/public-create-applicant-event.json +610 -0
  12. package/lib/schemas/public-delete-applicant-event.json +66 -0
  13. package/lib/schemas/public-delete-asset-event.json +53 -0
  14. package/lib/schemas/public-delete-income-event.json +55 -0
  15. package/lib/schemas/public-employment-delete-event.json +31 -0
  16. package/lib/schemas/public-employment-event.json +302 -0
  17. package/lib/schemas/public-expense-delete-event.json +41 -0
  18. package/lib/schemas/public-expense-event.json +132 -0
  19. package/lib/schemas/public-funding-position-event.json +289 -0
  20. package/lib/schemas/public-income-event.json +242 -0
  21. package/lib/schemas/public-liability-delete-event.json +37 -0
  22. package/lib/schemas/public-liability-event.json +234 -0
  23. package/lib/schemas/public-required-document-event.json +98 -0
  24. package/lib/schemas/public-update-applicant-event.json +607 -0
  25. package/lib/schemas/sf-opportunity-event-out.json +138 -0
  26. package/lib/transform-events/generate-asset-liability-link.d.ts +8 -0
  27. package/lib/transform-events/generate-asset-liability-link.js +29 -0
  28. package/lib/transform-events/generate-asset.d.ts +17 -0
  29. package/lib/transform-events/generate-asset.js +178 -0
  30. package/lib/transform-events/generate-credit-report-rebuilt.d.ts +8 -0
  31. package/lib/transform-events/generate-credit-report-rebuilt.js +41 -0
  32. package/lib/transform-events/generate-employment.d.ts +8 -0
  33. package/lib/transform-events/generate-employment.js +106 -0
  34. package/lib/transform-events/generate-funding-position.d.ts +18 -0
  35. package/lib/transform-events/generate-funding-position.js +82 -0
  36. package/lib/transform-events/generate-income.d.ts +37 -0
  37. package/lib/transform-events/generate-income.js +254 -0
  38. package/lib/transform-events/generate-liability.d.ts +8 -0
  39. package/lib/transform-events/generate-liability.js +87 -0
  40. package/lib/transform-events/generate-lixi-percentowned.d.ts +9 -0
  41. package/lib/transform-events/generate-lixi-percentowned.js +24 -0
  42. package/lib/transform-events/generate-opportunity.d.ts +8 -0
  43. package/lib/transform-events/generate-opportunity.js +32 -0
  44. package/lib/transform-events/generate-required-document.d.ts +8 -0
  45. package/lib/transform-events/generate-required-document.js +54 -0
  46. package/lib/transform-events/transform-applicant.d.ts +33 -0
  47. package/lib/transform-events/transform-applicant.js +189 -0
  48. package/lib/transform-events/transform-application.d.ts +8 -0
  49. package/lib/transform-events/transform-application.js +54 -0
  50. package/lib/transform-events/transform-expenses.d.ts +37 -0
  51. package/lib/transform-events/transform-expenses.js +121 -0
  52. package/lib/types/enum-mappings/alieo-frequency.d.ts +15 -0
  53. package/lib/types/enum-mappings/alieo-frequency.js +26 -0
  54. package/lib/types/enum-mappings/country-code.d.ts +7 -0
  55. package/lib/types/enum-mappings/country-code.js +247 -0
  56. package/lib/types/enum-mappings/employment-basis.d.ts +7 -0
  57. package/lib/types/enum-mappings/employment-basis.js +13 -0
  58. package/lib/types/enum-mappings/expense-frequency.d.ts +7 -0
  59. package/lib/types/enum-mappings/expense-frequency.js +12 -0
  60. package/lib/types/enum-mappings/funding-position.d.ts +18 -0
  61. package/lib/types/enum-mappings/funding-position.js +34 -0
  62. package/lib/types/enum-mappings/government-benefits.d.ts +7 -0
  63. package/lib/types/enum-mappings/government-benefits.js +11 -0
  64. package/lib/types/enum-mappings/housing-status.d.ts +7 -0
  65. package/lib/types/enum-mappings/housing-status.js +16 -0
  66. package/lib/types/enum-mappings/income-type.d.ts +7 -0
  67. package/lib/types/enum-mappings/income-type.js +17 -0
  68. package/lib/types/enum-mappings/liability-payment-type.d.ts +7 -0
  69. package/lib/types/enum-mappings/liability-payment-type.js +10 -0
  70. package/lib/types/enum-mappings/liability-type.d.ts +7 -0
  71. package/lib/types/enum-mappings/liability-type.js +22 -0
  72. package/lib/types/enum-mappings/living-expense.d.ts +7 -0
  73. package/lib/types/enum-mappings/living-expense.js +31 -0
  74. package/lib/types/enum-mappings/marital-status.d.ts +7 -0
  75. package/lib/types/enum-mappings/marital-status.js +13 -0
  76. package/lib/types/enum-mappings/postcode.d.ts +6 -0
  77. package/lib/types/enum-mappings/postcode.js +16 -0
  78. package/lib/types/enum-mappings/preferred-repayment.d.ts +7 -0
  79. package/lib/types/enum-mappings/preferred-repayment.js +11 -0
  80. package/lib/types/enum-mappings/proof-of-identity.d.ts +7 -0
  81. package/lib/types/enum-mappings/proof-of-identity.js +11 -0
  82. package/lib/types/enum-mappings/public-financial-asset.d.ts +7 -0
  83. package/lib/types/enum-mappings/public-financial-asset.js +13 -0
  84. package/lib/types/enum-mappings/public-primary-purpose.d.ts +7 -0
  85. package/lib/types/enum-mappings/public-primary-purpose.js +10 -0
  86. package/lib/types/enum-mappings/public-property-status.d.ts +7 -0
  87. package/lib/types/enum-mappings/public-property-status.js +12 -0
  88. package/lib/types/enum-mappings/public-property-type.d.ts +7 -0
  89. package/lib/types/enum-mappings/public-property-type.js +24 -0
  90. package/lib/types/enum-mappings/residency-status.d.ts +7 -0
  91. package/lib/types/enum-mappings/residency-status.js +12 -0
  92. package/lib/types/enum-mappings/title-gender.d.ts +7 -0
  93. package/lib/types/enum-mappings/title-gender.js +14 -0
  94. package/lib/types/enum-mappings/title.d.ts +7 -0
  95. package/lib/types/enum-mappings/title.js +14 -0
  96. package/lib/types/enum-mappings/transaction-type.d.ts +7 -0
  97. package/lib/types/enum-mappings/transaction-type.js +10 -0
  98. package/lib/types/events/applicant-delete.d.ts +42 -0
  99. package/lib/types/events/applicant-delete.js +15 -0
  100. package/lib/types/events/asset-delete.d.ts +33 -0
  101. package/lib/types/events/asset-delete.js +15 -0
  102. package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
  103. package/lib/types/events/asset-liability-relation-delete.js +15 -0
  104. package/lib/types/events/credit-report-retrieved.d.ts +36 -0
  105. package/lib/types/events/credit-report-retrieved.js +15 -0
  106. package/lib/types/events/employment-delete.d.ts +19 -0
  107. package/lib/types/events/employment-delete.js +7 -0
  108. package/lib/types/events/expense-delete.d.ts +21 -0
  109. package/lib/types/events/expense-delete.js +7 -0
  110. package/lib/types/events/funding-position.d.ts +116 -0
  111. package/lib/types/events/funding-position.js +34 -0
  112. package/lib/types/events/income-delete.d.ts +33 -0
  113. package/lib/types/events/income-delete.js +15 -0
  114. package/lib/types/events/liability-delete.d.ts +17 -0
  115. package/lib/types/events/liability-delete.js +7 -0
  116. package/lib/types/events/opportunity.d.ts +102 -0
  117. package/lib/types/events/opportunity.js +47 -0
  118. package/lib/types/events/public-applicant.d.ts +485 -0
  119. package/lib/types/events/public-applicant.js +343 -0
  120. package/lib/types/events/public-application.d.ts +145 -0
  121. package/lib/types/events/public-application.js +100 -0
  122. package/lib/types/events/public-asset-liability-relation.d.ts +52 -0
  123. package/lib/types/events/public-asset-liability-relation.js +15 -0
  124. package/lib/types/events/public-asset.d.ts +469 -0
  125. package/lib/types/events/public-asset.js +319 -0
  126. package/lib/types/events/public-employment.d.ts +190 -0
  127. package/lib/types/events/public-employment.js +69 -0
  128. package/lib/types/events/public-expense.d.ts +83 -0
  129. package/lib/types/events/public-expense.js +50 -0
  130. package/lib/types/events/public-funding-position.d.ts +226 -0
  131. package/lib/types/events/public-funding-position.js +7 -0
  132. package/lib/types/events/public-income.d.ts +144 -0
  133. package/lib/types/events/public-income.js +65 -0
  134. package/lib/types/events/public-liability.d.ts +133 -0
  135. package/lib/types/events/public-liability.js +68 -0
  136. package/lib/types/events/public-required-document.d.ts +99 -0
  137. package/lib/types/events/public-required-document.js +44 -0
  138. package/lib/types/partial-application.d.ts +3 -0
  139. package/lib/types/partial-application.js +2 -0
  140. package/lib/types/recursive-partial.d.ts +3 -0
  141. package/lib/types/recursive-partial.js +2 -0
  142. package/lib/utils/address-tools.d.ts +69 -0
  143. package/lib/utils/address-tools.js +146 -0
  144. package/lib/utils/clean-up.d.ts +7 -0
  145. package/lib/utils/clean-up.js +24 -0
  146. package/lib/utils/generate-address.d.ts +19 -0
  147. package/lib/utils/generate-address.js +102 -0
  148. package/lib/utils/get-financial-institution.d.ts +7 -0
  149. package/lib/utils/get-financial-institution.js +16 -0
  150. package/lib/utils/is-income-type.d.ts +83 -0
  151. package/lib/utils/is-income-type.js +166 -0
  152. package/lib/utils/normalise-date.d.ts +8 -0
  153. package/lib/utils/normalise-date.js +17 -0
  154. package/lib/utils/round-decimal.d.ts +6 -0
  155. package/lib/utils/round-decimal.js +12 -0
  156. package/package.json +10 -7
@@ -0,0 +1,138 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Opportunity",
4
+ "description": "The Opportunity object in Salesforce",
5
+ "type": "object",
6
+ "properties": {
7
+ "version": {
8
+ "type": "string",
9
+ "description": "schema version"
10
+ },
11
+ "type": {
12
+ "type": "string",
13
+ "enum": ["OpportunityCreated", "OpportunityUpdated", "OpportunityMigrated"]
14
+ },
15
+ "payload": {
16
+ "$ref": "#/definitions/opportunity"
17
+ }
18
+ },
19
+ "required": ["version", "type", "payload"],
20
+ "additionalProperties": false,
21
+ "definitions": {
22
+ "opportunity": {
23
+ "type": "object",
24
+ "additionalProperties": true,
25
+ "properties": {
26
+ "areYouAFirstHomeBuyer": {
27
+ "type": ["string", "null"],
28
+ "maxLength": 255
29
+ },
30
+ "brand": {
31
+ "enum": ["domain", "domain variation", "lendi", "lendi variation"],
32
+ "description": "Brand of an Opportunity, taken from Record Type in Salesforce"
33
+ },
34
+ "cashoutAmount": {
35
+ "type": ["number", "null"],
36
+ "description": "From Funnel"
37
+ },
38
+ "customerId": {
39
+ "type": ["string", "null"],
40
+ "maxLength": 255
41
+ },
42
+ "deposit": {
43
+ "type": ["number", "null"],
44
+ "description": "From Funnel"
45
+ },
46
+ "expectedSettlementDate": {
47
+ "type": ["string", "null"],
48
+ "format": "date",
49
+ "description": "From funnel, ISO 8601 string date format"
50
+ },
51
+ "factorsInChoosingALender": {
52
+ "type": ["string", "null"],
53
+ "maxLength": 255,
54
+ "description": "From Funnel"
55
+ },
56
+ "id": {
57
+ "type": ["string"],
58
+ "maxLength": 255,
59
+ "description": "The unique identifier of the Opportunity"
60
+ },
61
+ "isHidden": {
62
+ "type": "boolean",
63
+ "description": "When checked the Application is hidden from view"
64
+ },
65
+ "loanAmount": {
66
+ "type": ["number", "null"]
67
+ },
68
+ "name": {
69
+ "type": ["string", "null"],
70
+ "maxLength": 120
71
+ },
72
+ "preferredRepaymentMethod": {
73
+ "type": ["string", "null"],
74
+ "maxLength": 255
75
+ },
76
+ "stage": {
77
+ "type": "string",
78
+ "maxLength": 255,
79
+ "description": "Opportunity Stage Name",
80
+ "enum": [
81
+ "Application Taken",
82
+ "Appointed",
83
+ "Approval",
84
+ "Approved",
85
+ "At Risk",
86
+ "CL Future Contact Date",
87
+ "Closed Lost",
88
+ "Closed Won - Policy Active",
89
+ "Closed Won - Signed",
90
+ "Closed Won",
91
+ "Confirmed Appointment",
92
+ "In Application",
93
+ "In Assessment",
94
+ "Loan Document",
95
+ "Post-Contact",
96
+ "Post-Settlement",
97
+ "Pre-Contact",
98
+ "Qualification",
99
+ "Quote",
100
+ "Settled",
101
+ "Settlement",
102
+ "Submitted"
103
+ ]
104
+ },
105
+ "status": {
106
+ "type": ["string", "null"],
107
+ "maxLength": 255,
108
+ "description": "Opportunity status. Can be null when this field is empty/not set on new and closed opportunities"
109
+ },
110
+ "transactionType": {
111
+ "type": ["string"],
112
+ "maxLength": 255
113
+ },
114
+ "userId": {
115
+ "type": ["string", "null"],
116
+ "maxLength": 255
117
+ },
118
+ "whyAreYouRefinancing": {
119
+ "type": ["string", "null"],
120
+ "maxLength": 255,
121
+ "description": "From Funnel"
122
+ }
123
+ },
124
+ "required": ["id", "stage", "userId"]
125
+ },
126
+ "opportunityDeleted": {
127
+ "type": "object",
128
+ "additionalProperties": false,
129
+ "properties": {
130
+ "id": {
131
+ "type": ["string"],
132
+ "maxLength": 255,
133
+ "description": "The unique identifier of the Opportunity"
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,8 @@
1
+ import { AssetAndLiabilityRelation } from '../types/events/public-asset-liability-relation';
2
+ /**
3
+ * Generates a partial application from the partial asset and liability event.
4
+ *
5
+ * @param assetLiabilityLink: A partial asset and liability event.
6
+ * @return partialApplication: A partial internal request.
7
+ */
8
+ export declare function generateAssetLiabilityLink({ applicationId, relation }: AssetAndLiabilityRelation): {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.generateAssetLiabilityLink = void 0;
4
+ var lodash_1 = require("lodash");
5
+ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
+ /**
7
+ * Generates a partial application from the partial asset and liability event.
8
+ *
9
+ * @param assetLiabilityLink: A partial asset and liability event.
10
+ * @return partialApplication: A partial internal request.
11
+ */
12
+ function generateAssetLiabilityLink(_a) {
13
+ var applicationId = _a.applicationId, relation = _a.relation;
14
+ var partialApplication = {};
15
+ var assetLiabilityMapping = {
16
+ applicationId: application_paths_1.paths.ApplicationId,
17
+ liabilityId: "".concat(application_paths_1.paths.Liability, ".@UniqueID"),
18
+ assetId: "".concat(application_paths_1.paths.Liability, ".Security[0].@x_Security")
19
+ };
20
+ (0, lodash_1.set)(partialApplication, assetLiabilityMapping.applicationId, applicationId);
21
+ for (var _i = 0, _b = Object.entries(relation); _i < _b.length; _i++) {
22
+ var _c = _b[_i], key = _c[0], value = _c[1];
23
+ if (assetLiabilityMapping[key]) {
24
+ (0, lodash_1.set)(partialApplication, assetLiabilityMapping[key], value);
25
+ }
26
+ }
27
+ return partialApplication;
28
+ }
29
+ exports.generateAssetLiabilityLink = generateAssetLiabilityLink;
@@ -0,0 +1,17 @@
1
+ import { Asset, AssetDefinition as Payload } from '../types/events/public-asset';
2
+ export declare const residentialTypeList: string[];
3
+ export declare const propertyTypeNameList: string[];
4
+ /**
5
+ * Generates a partial internal request from a partial public asset event.
6
+ *
7
+ * @param asset: A partial public asset.
8
+ * @param applicationId: Id of application.
9
+ * @param id: Id of asset entity.
10
+ * @return A partial InternalRequest.
11
+ */
12
+ export declare function generateAsset({ asset, applicationId, id }: Payload): {};
13
+ /**
14
+ * Checks if the asset is of financial type.
15
+ * @param asset asset payload
16
+ */
17
+ export declare function isFinancialAsset(asset: Asset): boolean;
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.isFinancialAsset = exports.generateAsset = exports.propertyTypeNameList = exports.residentialTypeList = void 0;
4
+ var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
+ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
+ var lodash_1 = require("lodash");
7
+ var logger_1 = require("../logger");
8
+ var public_financial_asset_1 = require("../types/enum-mappings/public-financial-asset");
9
+ var public_primary_purpose_1 = require("../types/enum-mappings/public-primary-purpose");
10
+ var public_property_status_1 = require("../types/enum-mappings/public-property-status");
11
+ var public_property_type_1 = require("../types/enum-mappings/public-property-type");
12
+ var public_asset_1 = require("../types/events/public-asset");
13
+ var generate_address_1 = require("../utils/generate-address");
14
+ var get_financial_institution_1 = require("../utils/get-financial-institution");
15
+ var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
16
+ var toBeUsedAsSecurityMapping = {
17
+ "true": lixi_internal_request_1.YesNoList.Yes,
18
+ "false": lixi_internal_request_1.YesNoList.No
19
+ };
20
+ var toBePurchasedMapping = {
21
+ "true": lixi_internal_request_1.AssetTransactionList.Purchasing,
22
+ "false": lixi_internal_request_1.AssetTransactionList.Owns
23
+ };
24
+ var assetMapping = {
25
+ make: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Make"),
26
+ year: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Year"),
27
+ model: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Model"),
28
+ estimatedValue: "".concat(application_paths_1.paths.NonRealEstateAsset, ".EstimatedValue.@Value"),
29
+ zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type"),
30
+ toBeUsedAsSecurity: "".concat(application_paths_1.paths.RealEstateAsset, ".@ToBeUsedAsSecurity"),
31
+ toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
32
+ primaryPurpose: "".concat(application_paths_1.paths.RealEstateAsset, ".@PrimaryPurpose"),
33
+ propertyStatus: "".concat(application_paths_1.paths.RealEstateAsset, ".@Status"),
34
+ financialInstitution: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@FinancialInstitution"),
35
+ propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential.@Type"),
36
+ address: application_paths_1.paths.Address
37
+ };
38
+ exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
39
+ exports.propertyTypeNameList = Object.values(lixi_internal_request_1.Custom3PropertyTypeNameList);
40
+ /**
41
+ * Generates a partial internal request from a partial public asset event.
42
+ *
43
+ * @param asset: A partial public asset.
44
+ * @param applicationId: Id of application.
45
+ * @param id: Id of asset entity.
46
+ * @return A partial InternalRequest.
47
+ */
48
+ function generateAsset(_a) {
49
+ var asset = _a.asset, applicationId = _a.applicationId, id = _a.id;
50
+ var partialApplication = {};
51
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
52
+ var isPropertyAsset = asset.type === public_asset_1.AssetType.Property;
53
+ switch (asset.type) {
54
+ case public_asset_1.AssetType.Vehicle:
55
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
56
+ break;
57
+ case public_asset_1.AssetType.Property:
58
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@MultipleDwellings"), lixi_internal_request_1.YesNoList.No);
59
+ break;
60
+ case public_asset_1.AssetType.HomeContents:
61
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
62
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Type"), lixi_internal_request_1.OtherAssetTypeList.HomeContents);
63
+ break;
64
+ case public_asset_1.AssetType.Gifts:
65
+ case public_asset_1.AssetType.OtherAsset:
66
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
67
+ if (asset.description)
68
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Description"), asset.description);
69
+ break;
70
+ case public_asset_1.AssetType.Shares:
71
+ case public_asset_1.AssetType.Superannuation:
72
+ case public_asset_1.AssetType.TermDeposit:
73
+ case public_asset_1.AssetType.SavingCheckAccount:
74
+ case public_asset_1.AssetType.ManagedFunds:
75
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
76
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.@Type"), public_financial_asset_1.financialAssetMapping[asset.type]);
77
+ break;
78
+ default:
79
+ logger_1.logger.warn({ message: "Unhandled asset type: ".concat(asset.type), applicationId: applicationId });
80
+ return;
81
+ }
82
+ if (isPropertyAsset) {
83
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@UniqueID"), id);
84
+ assetMapping.percentOwned = "".concat(application_paths_1.paths.RealEstateAsset, ".PercentOwned");
85
+ }
86
+ else {
87
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@UniqueID"), id);
88
+ assetMapping.percentOwned = "".concat(application_paths_1.paths.NonRealEstateAsset, ".PercentOwned");
89
+ }
90
+ for (var _i = 0, _b = Object.entries(asset); _i < _b.length; _i++) {
91
+ var _c = _b[_i], key = _c[0], value = _c[1];
92
+ if (assetMapping[key]) {
93
+ switch (key) {
94
+ case 'primaryPurpose':
95
+ (0, lodash_1.set)(partialApplication, assetMapping[key], public_primary_purpose_1.primaryPurposeMapping[value]);
96
+ break;
97
+ case 'toBePurchased':
98
+ (0, lodash_1.set)(partialApplication, assetMapping[key], toBePurchasedMapping[value]);
99
+ break;
100
+ case 'propertyStatus':
101
+ (0, lodash_1.set)(partialApplication, assetMapping[key], public_property_status_1.propertyStatusMapping[value]);
102
+ break;
103
+ case 'toBeUsedAsSecurity':
104
+ if (isPropertyAsset)
105
+ (0, lodash_1.set)(partialApplication, assetMapping[key], toBeUsedAsSecurityMapping[value]);
106
+ break;
107
+ case 'estimatedValue':
108
+ if (isPropertyAsset) {
109
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".EstimatedValue.@Value"), value);
110
+ }
111
+ else {
112
+ (0, lodash_1.set)(partialApplication, assetMapping[key], value);
113
+ }
114
+ break;
115
+ case 'propertyType':
116
+ var mappedValue = public_property_type_1.propertyTypeMapping[value];
117
+ if (exports.residentialTypeList.includes(mappedValue)) {
118
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Residential.@Type"), mappedValue);
119
+ }
120
+ else if (exports.propertyTypeNameList.includes(mappedValue)) {
121
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@PropertyTypeName"), mappedValue);
122
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@CategoryTypeName"), lixi_internal_request_1.Custom2CategoryTypeNameList.Residential);
123
+ }
124
+ else {
125
+ logger_1.logger.warn({ message: "Unknown propertyType ".concat(value, " for asset ").concat(id), applicationId: applicationId });
126
+ }
127
+ break;
128
+ case 'zoneType':
129
+ if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
130
+ (0, lodash_1.set)(partialApplication, "".concat(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
+ }
133
+ else {
134
+ (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Residential);
135
+ }
136
+ break;
137
+ case 'financialInstitution':
138
+ if (isFinancialAsset(asset)) {
139
+ var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
140
+ (0, lodash_1.set)(partialApplication, assetMapping[key], financialInstitution);
141
+ }
142
+ break;
143
+ case 'year':
144
+ (0, lodash_1.set)(partialApplication, assetMapping[key], value.toString());
145
+ break;
146
+ case 'address':
147
+ var addressId = "".concat(id, "-address");
148
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@x_Address"), addressId);
149
+ (0, lodash_1.set)(partialApplication, assetMapping[key], (0, generate_address_1.generateAddress)(value, addressId));
150
+ break;
151
+ case 'percentOwned':
152
+ var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
153
+ if (percentOwned) {
154
+ (0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
155
+ }
156
+ break;
157
+ default:
158
+ (0, lodash_1.set)(partialApplication, assetMapping[key], value);
159
+ }
160
+ }
161
+ }
162
+ return partialApplication;
163
+ }
164
+ exports.generateAsset = generateAsset;
165
+ /**
166
+ * Checks if the asset is of financial type.
167
+ * @param asset asset payload
168
+ */
169
+ function isFinancialAsset(asset) {
170
+ return [
171
+ public_asset_1.AssetType.Shares,
172
+ public_asset_1.AssetType.Superannuation,
173
+ public_asset_1.AssetType.TermDeposit,
174
+ public_asset_1.AssetType.SavingCheckAccount,
175
+ public_asset_1.AssetType.ManagedFunds,
176
+ ].includes(asset.type);
177
+ }
178
+ exports.isFinancialAsset = isFinancialAsset;
@@ -0,0 +1,8 @@
1
+ import { PayloadObject as CreditReportPayload } from '../types/events/credit-report-retrieved';
2
+ /**
3
+ * Generates LIXI compliant `Attachment` and `CreditAssessment` objects which
4
+ * use credit report data fetched from Equifax.
5
+ *
6
+ * @param {CreditReportPayload} creditReport - Credit report rebuilt event.
7
+ */
8
+ export declare function generateCreditReportRebuilt(creditReport: CreditReportPayload): {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.generateCreditReportRebuilt = 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 application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
7
+ /**
8
+ * Generates LIXI compliant `Attachment` and `CreditAssessment` objects which
9
+ * use credit report data fetched from Equifax.
10
+ *
11
+ * @param {CreditReportPayload} creditReport - Credit report rebuilt event.
12
+ */
13
+ function generateCreditReportRebuilt(creditReport) {
14
+ var applicantId = creditReport.applicantId, raw = creditReport.raw, source = creditReport.source;
15
+ var id = "".concat(applicantId, "-creditReport");
16
+ var attachment = {
17
+ '@Filename': 'Credit Report',
18
+ '@UniqueID': id,
19
+ InlineAttachment: {
20
+ $: raw
21
+ }
22
+ };
23
+ var report = {
24
+ '@RequestDateTime': new Date().toISOString(),
25
+ '@Source': source,
26
+ '@x_Party': applicantId,
27
+ Content: [
28
+ {
29
+ '@Type': lixi_internal_request_1.ReportContentTypeList.XML,
30
+ '@x_Attachment': id
31
+ },
32
+ ]
33
+ };
34
+ var partialApplication = {};
35
+ // Set application id, attachment and credit assessment 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
+ return partialApplication;
40
+ }
41
+ exports.generateCreditReportRebuilt = generateCreditReportRebuilt;
@@ -0,0 +1,8 @@
1
+ import { Payload } from '../types/events/public-employment';
2
+ /**
3
+ * Generates a partial application from a employment event.
4
+ *
5
+ * @param employment a employment event payload.
6
+ * @return partialApplication an incomplete application.
7
+ */
8
+ export declare function generateEmployment(employment: Payload): {};
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.generateEmployment = 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 application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
7
+ var logger_1 = require("../logger");
8
+ var public_employment_1 = require("../types/events/public-employment");
9
+ var employment_basis_1 = require("../types/enum-mappings/employment-basis");
10
+ /**
11
+ * Generates a partial application from a employment event.
12
+ *
13
+ * @param employment a employment event payload.
14
+ * @return partialApplication an incomplete application.
15
+ */
16
+ function generateEmployment(employment) {
17
+ var partialApplication = {};
18
+ var employmentPath = application_paths_1.paths.PAYG;
19
+ var isEmployed = false;
20
+ var applicationId = employment.applicationId;
21
+ // Each one Employment object can only contain one of the three types. Set the three object to undefined so that the
22
+ // other two types will be removed from the final result.
23
+ // @pliu 19/11/19
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
+ switch (employment.employmentType) {
28
+ case public_employment_1.EmploymentType.Employee:
29
+ isEmployed = true;
30
+ employmentPath = application_paths_1.paths.PAYG;
31
+ // Setting default for onProbation. If field exists in event value will get overwritten.
32
+ (0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@OnProbation"), lixi_internal_request_1.YesNoList.No);
33
+ break;
34
+ case public_employment_1.EmploymentType.SelfEmployed:
35
+ isEmployed = true;
36
+ employmentPath = application_paths_1.paths.SelfEmployed;
37
+ break;
38
+ case public_employment_1.EmploymentType.NotWorking:
39
+ employmentPath = application_paths_1.paths.NotEmployed;
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
+ break;
43
+ default:
44
+ logger_1.logger.warn({ message: "Unknown EmploymentType ".concat(employment.employmentType), applicationId: applicationId });
45
+ }
46
+ var employmentMapping = {
47
+ applicationId: application_paths_1.paths.ApplicationId,
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
+ };
59
+ for (var _i = 0, _a = Object.entries(employment); _i < _a.length; _i++) {
60
+ var _b = _a[_i], key = _b[0], value = _b[1];
61
+ if (employmentMapping[key]) {
62
+ switch (key) {
63
+ case 'type':
64
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], (0, lodash_1.capitalize)(value));
65
+ break;
66
+ case 'abn':
67
+ case 'businessName':
68
+ // Only transform value in RelatedCompany for employed (self employed or employee) employment, otherwise RelatedCompany would missing UniqueID
69
+ if (isEmployed) {
70
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value.toString());
71
+ }
72
+ break;
73
+ case 'employmentBasis':
74
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], employment_basis_1.paygEmploymentBasisMapping[value]);
75
+ break;
76
+ case 'id':
77
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
78
+ if (isEmployed) {
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
+ }
82
+ break;
83
+ case 'onProbation':
84
+ if (employment.employmentType === public_employment_1.EmploymentType.Employee) {
85
+ var onProbation = value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No;
86
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], onProbation);
87
+ }
88
+ break;
89
+ case 'role':
90
+ var _c = value.anzsco, anzsco = _c === void 0 ? {} : _c;
91
+ if (anzsco.code) {
92
+ (0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@ANZSCOOccupationCode"), anzsco.code.toString());
93
+ }
94
+ if (anzsco.occupation) {
95
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], anzsco.occupation);
96
+ }
97
+ break;
98
+ default:
99
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
100
+ break;
101
+ }
102
+ }
103
+ }
104
+ return partialApplication;
105
+ }
106
+ exports.generateEmployment = generateEmployment;
@@ -0,0 +1,18 @@
1
+ import { Fee } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { FundsRequiredBreakdown } from '../types/events/public-funding-position';
3
+ import { Payload as FundingPositionPayload } from '../types/events/public-funding-position';
4
+ /**
5
+ * GenerateFundingPosition
6
+ *
7
+ * @param fundingPosition a partialFundingPosition.
8
+ * @return partialApplication with fees, grants and borrowers contributions added.
9
+ */
10
+ export declare function generateFundingPosition(fundingPosition: FundingPositionPayload): {};
11
+ /**
12
+ * getFee
13
+ *
14
+ * @param fundsRequiredBreakDown a FundsRequiredBreakdown.
15
+ * @param id
16
+ * @return Array of fees
17
+ */
18
+ export declare function getFees(fundsRequiredBreakDown: FundsRequiredBreakdown, id: string): Fee[];
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.getFees = exports.generateFundingPosition = void 0;
4
+ var lodash_1 = require("lodash");
5
+ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
+ var funding_position_1 = require("../types/enum-mappings/funding-position");
7
+ /**
8
+ * GenerateFundingPosition
9
+ *
10
+ * @param fundingPosition a partialFundingPosition.
11
+ * @return partialApplication with fees, grants and borrowers contributions added.
12
+ */
13
+ function generateFundingPosition(fundingPosition) {
14
+ var partialApplication = {};
15
+ var contributionFunds = [];
16
+ var applicationId = fundingPosition.applicationId, id = fundingPosition.id;
17
+ var fundingPositionMapping = {
18
+ applicationId: application_paths_1.paths.ApplicationId,
19
+ fundsRequested: "".concat(application_paths_1.paths.RolledUpAmounts, ".@TotalNewFunds"),
20
+ lvr: "".concat(application_paths_1.paths.Summary, ".LoanToValuationRatio.@ApplicationLVR"),
21
+ totalGovernmentContributions: application_paths_1.paths.ContributionFunds,
22
+ totalDeposit: application_paths_1.paths.ContributionFunds,
23
+ totalCashOut: "".concat(application_paths_1.paths.EquityRelease, ".Amount.@LumpSum"),
24
+ fundsRequiredBreakdown: application_paths_1.paths.SummaryFee
25
+ };
26
+ for (var _i = 0, _a = Object.entries(fundingPosition); _i < _a.length; _i++) {
27
+ var _b = _a[_i], key = _b[0], value = _b[1];
28
+ if (fundingPositionMapping[key]) {
29
+ switch (key) {
30
+ case 'totalGovernmentContributions':
31
+ case 'totalDeposit':
32
+ contributionFunds.push({
33
+ '@Amount': value,
34
+ '@Type': funding_position_1.contributionMapping[key],
35
+ '@UniqueID': "".concat(id, "-").concat(key)
36
+ });
37
+ break;
38
+ case 'fundsRequiredBreakdown':
39
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.SummaryFee, getFees(value, id));
40
+ break;
41
+ case 'totalCashOut':
42
+ (0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
43
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.LoanDetail, ".@UniqueID"), "".concat(applicationId, "-loanDetails"));
44
+ break;
45
+ case 'fundsRequested':
46
+ (0, lodash_1.set)(partialApplication, fundingPositionMapping[key], Math.round(value));
47
+ break;
48
+ default:
49
+ (0, lodash_1.set)(partialApplication, fundingPositionMapping[key], value);
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ContributionFunds, contributionFunds);
55
+ return partialApplication;
56
+ }
57
+ exports.generateFundingPosition = generateFundingPosition;
58
+ /**
59
+ * getFee
60
+ *
61
+ * @param fundsRequiredBreakDown a FundsRequiredBreakdown.
62
+ * @param id
63
+ * @return Array of fees
64
+ */
65
+ function getFees(fundsRequiredBreakDown, id) {
66
+ // Omitting constructionCosts as they don't belong in fees.
67
+ return Object.entries((0, lodash_1.omit)(fundsRequiredBreakDown, 'constructionCosts')).map(function (_a) {
68
+ var key = _a[0], value = _a[1];
69
+ var descriptionList = ['accruedInterest', 'otherSundries'];
70
+ var fee = {
71
+ '@Amount': value,
72
+ '@Category': funding_position_1.categoryMapping[key],
73
+ '@Type': funding_position_1.typeMapping[key],
74
+ '@UniqueID': "".concat(id, "-").concat(key)
75
+ };
76
+ if (descriptionList.includes(key)) {
77
+ fee['@Description'] = funding_position_1.descriptionMapping[key];
78
+ }
79
+ return fee;
80
+ });
81
+ }
82
+ exports.getFees = getFees;