@lendi/integrations-transform 1.5.8 → 1.6.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 (108) hide show
  1. package/lib/index.js +1 -1
  2. package/lib/logger.d.ts +1 -2
  3. package/lib/logger.js +3 -3
  4. package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
  5. package/lib/transform-events/generate-asset-liability-link.js +12 -12
  6. package/lib/transform-events/generate-credit-report-rebuilt.js +13 -13
  7. package/lib/transform-events/generate-employment.d.ts +1 -1
  8. package/lib/transform-events/generate-employment.js +33 -34
  9. package/lib/transform-events/generate-required-document.d.ts +1 -7
  10. package/lib/transform-events/generate-required-document.js +37 -54
  11. package/lib/transform-events/transform-applicant.d.ts +2 -1
  12. package/lib/transform-events/transform-applicant.js +57 -63
  13. package/lib/transform-events/transform-application-workflow.d.ts +0 -1
  14. package/lib/transform-events/transform-application-workflow.js +7 -8
  15. package/lib/transform-events/transform-application.d.ts +3 -1
  16. package/lib/transform-events/transform-application.js +23 -24
  17. package/lib/transform-events/transform-asset-address.d.ts +8 -2
  18. package/lib/transform-events/transform-asset-address.js +22 -18
  19. package/lib/transform-events/transform-asset.d.ts +7 -1
  20. package/lib/transform-events/transform-asset.js +112 -122
  21. package/lib/transform-events/transform-expenses.d.ts +4 -0
  22. package/lib/transform-events/transform-expenses.js +31 -29
  23. package/lib/transform-events/transform-funding-position.d.ts +2 -2
  24. package/lib/transform-events/transform-funding-position.js +23 -26
  25. package/lib/transform-events/transform-income.d.ts +8 -1
  26. package/lib/transform-events/transform-income.js +87 -97
  27. package/lib/transform-events/transform-liability.d.ts +4 -1
  28. package/lib/transform-events/transform-liability.js +42 -41
  29. package/lib/transform-events/transform-percent-owned.d.ts +1 -0
  30. package/lib/transform-events/transform-percent-owned.js +8 -11
  31. package/lib/types/enum-mappings/alieo-frequency.js +23 -24
  32. package/lib/types/enum-mappings/asset-type.js +15 -16
  33. package/lib/types/enum-mappings/builder-type.js +7 -8
  34. package/lib/types/enum-mappings/construction-type.js +8 -9
  35. package/lib/types/enum-mappings/country-code.js +244 -245
  36. package/lib/types/enum-mappings/employment-basis.js +10 -11
  37. package/lib/types/enum-mappings/expense-frequency.js +9 -10
  38. package/lib/types/enum-mappings/funding-position.js +6 -6
  39. package/lib/types/enum-mappings/government-benefits.js +8 -9
  40. package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
  41. package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
  42. package/lib/types/enum-mappings/housing-status.js +13 -14
  43. package/lib/types/enum-mappings/income-type.js +14 -15
  44. package/lib/types/enum-mappings/index.js +1 -1
  45. package/lib/types/enum-mappings/liability-payment-type.js +7 -8
  46. package/lib/types/enum-mappings/liability-type.js +19 -20
  47. package/lib/types/enum-mappings/living-expense.js +28 -29
  48. package/lib/types/enum-mappings/marital-status.js +10 -11
  49. package/lib/types/enum-mappings/postcode.js +12 -13
  50. package/lib/types/enum-mappings/preferred-repayment.js +8 -9
  51. package/lib/types/enum-mappings/proof-of-identity.js +8 -9
  52. package/lib/types/enum-mappings/property-expense-category.js +9 -10
  53. package/lib/types/enum-mappings/public-financial-asset.js +10 -11
  54. package/lib/types/enum-mappings/public-primary-purpose.js +7 -8
  55. package/lib/types/enum-mappings/public-property-status.js +9 -10
  56. package/lib/types/enum-mappings/public-property-type.js +21 -22
  57. package/lib/types/enum-mappings/residency-status.js +9 -10
  58. package/lib/types/enum-mappings/title-gender.js +11 -12
  59. package/lib/types/enum-mappings/title.js +11 -12
  60. package/lib/types/enum-mappings/to-be-purchased.js +4 -4
  61. package/lib/types/enum-mappings/to-be-used-as-security.js +4 -4
  62. package/lib/types/enum-mappings/transaction-type.js +7 -8
  63. package/lib/types/enum-mappings/verification.js +11 -12
  64. package/lib/types/events/applicant-delete.js +1 -1
  65. package/lib/types/events/application-workflow.js +1 -1
  66. package/lib/types/events/asset-delete.js +1 -1
  67. package/lib/types/events/asset-liability-relation-delete.js +1 -1
  68. package/lib/types/events/credit-report-retrieved.js +1 -1
  69. package/lib/types/events/employment-delete.js +1 -1
  70. package/lib/types/events/expense-delete.js +1 -1
  71. package/lib/types/events/funding-position.js +1 -1
  72. package/lib/types/events/income-delete.js +1 -1
  73. package/lib/types/events/liability-delete.js +1 -1
  74. package/lib/types/events/opportunity.js +1 -1
  75. package/lib/types/events/public-applicant.js +1 -1
  76. package/lib/types/events/public-application.js +1 -1
  77. package/lib/types/events/public-asset-liability-relation.js +1 -1
  78. package/lib/types/events/public-asset.js +1 -1
  79. package/lib/types/events/public-employment.js +1 -1
  80. package/lib/types/events/public-expense.js +1 -1
  81. package/lib/types/events/public-funding-position.js +1 -1
  82. package/lib/types/events/public-income.js +1 -1
  83. package/lib/types/events/public-liability.js +1 -1
  84. package/lib/types/events/public-required-document.js +1 -1
  85. package/lib/types/partial-application.js +1 -1
  86. package/lib/types/recursive-partial.js +1 -1
  87. package/lib/update-application/merge-application.d.ts +1 -1
  88. package/lib/update-application/merge-application.js +41 -34
  89. package/lib/update-application/update-primary-applicant.d.ts +1 -4
  90. package/lib/update-application/update-primary-applicant.js +12 -31
  91. package/lib/utils/address-tools.d.ts +3 -1
  92. package/lib/utils/address-tools.js +40 -42
  93. package/lib/utils/clean-up.d.ts +1 -1
  94. package/lib/utils/clean-up.js +6 -6
  95. package/lib/utils/formatYesNo.d.ts +0 -1
  96. package/lib/utils/formatYesNo.js +3 -4
  97. package/lib/utils/generate-address.d.ts +3 -2
  98. package/lib/utils/generate-address.js +21 -25
  99. package/lib/utils/get-financial-institution.d.ts +1 -0
  100. package/lib/utils/get-financial-institution.js +6 -5
  101. package/lib/utils/is-asset-type.js +2 -2
  102. package/lib/utils/is-income-type.d.ts +2 -0
  103. package/lib/utils/is-income-type.js +15 -21
  104. package/lib/utils/iso-date.d.ts +0 -1
  105. package/lib/utils/iso-date.js +3 -4
  106. package/lib/utils/normalise-date.js +6 -6
  107. package/lib/utils/round-decimal.js +1 -1
  108. package/package.json +14 -17
@@ -1,99 +1,86 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.normalizeAmounts = exports.determineOccupancy = exports.generatePropertyExpenses = exports.generateLivingExpenses = exports.getAssetMapping = exports.getPropertyType = exports.transformAsset = exports.residentialTypeList = exports.propertyTypeNameList = void 0;
15
- var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
16
- var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
17
- var lixi_internal_request_2 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
18
- var uuid_1 = require("uuid");
19
- var lodash_1 = require("lodash");
20
- var logger_1 = require("../logger");
21
- var enum_mappings_1 = require("../types/enum-mappings");
22
- var public_asset_1 = require("../types/events/public-asset");
23
- var public_expense_1 = require("../types/events/public-expense");
24
- var get_financial_institution_1 = require("../utils/get-financial-institution");
25
- var is_asset_type_1 = require("../utils/is-asset-type");
26
- var round_decimal_1 = require("../utils/round-decimal");
27
- var transform_asset_address_1 = require("./transform-asset-address");
28
- var transform_percent_owned_1 = require("./transform-percent-owned");
29
- var builder_type_1 = require("../types/enum-mappings/builder-type");
30
- var construction_type_1 = require("../types/enum-mappings/construction-type");
31
- var __1 = require("..");
4
+ const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
5
+ const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
6
+ const lixi_internal_request_2 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
7
+ const uuid_1 = require("uuid");
8
+ const lodash_1 = require("lodash");
9
+ const logger_1 = require("../logger");
10
+ const enum_mappings_1 = require("../types/enum-mappings");
11
+ const public_asset_1 = require("../types/events/public-asset");
12
+ const public_expense_1 = require("../types/events/public-expense");
13
+ const get_financial_institution_1 = require("../utils/get-financial-institution");
14
+ const is_asset_type_1 = require("../utils/is-asset-type");
15
+ const round_decimal_1 = require("../utils/round-decimal");
16
+ const transform_asset_address_1 = require("./transform-asset-address");
17
+ const transform_percent_owned_1 = require("./transform-percent-owned");
18
+ const builder_type_1 = require("../types/enum-mappings/builder-type");
19
+ const construction_type_1 = require("../types/enum-mappings/construction-type");
20
+ const __1 = require("..");
32
21
  exports.propertyTypeNameList = Object.values(lixi_internal_request_2.Custom2PropertyTypeNameList);
33
22
  exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
34
23
  // will add this path to protocol
35
- var constructionDetailsPath = "".concat(application_paths_1.paths.RealEstateAsset, ".ConstructionDetails");
36
- var constructionDetailsMapping = {
37
- builderType: "".concat(constructionDetailsPath, ".@BuilderType"),
38
- buildPriceAmount: "".concat(constructionDetailsPath, ".@BuildPriceAmount"),
39
- constructionType: "".concat(constructionDetailsPath, ".@Type"),
40
- estimatedValue: "".concat(constructionDetailsPath, ".@TotalAmount"),
41
- isFixedPriceContract: "".concat(constructionDetailsPath, ".@FixedPriceContract"),
42
- landEstimatedValue: "".concat(constructionDetailsPath, ".@LandValue"),
43
- otherConstructionCosts: "".concat(constructionDetailsPath, ".@OutOfContractItemsCost")
24
+ const constructionDetailsPath = `${application_paths_1.paths.RealEstateAsset}.ConstructionDetails`;
25
+ const constructionDetailsMapping = {
26
+ builderType: `${constructionDetailsPath}.@BuilderType`,
27
+ buildPriceAmount: `${constructionDetailsPath}.@BuildPriceAmount`,
28
+ constructionType: `${constructionDetailsPath}.@Type`,
29
+ estimatedValue: `${constructionDetailsPath}.@TotalAmount`,
30
+ isFixedPriceContract: `${constructionDetailsPath}.@FixedPriceContract`,
31
+ landEstimatedValue: `${constructionDetailsPath}.@LandValue`,
32
+ otherConstructionCosts: `${constructionDetailsPath}.@OutOfContractItemsCost`,
44
33
  };
45
34
  /**
46
35
  * Generates a partial internal request from a partial public asset event.
47
36
  *
48
37
  * @param {Payload} asset - A partial public asset.
49
- * @return {PartialApplication} A partial InternalRequest.
38
+ * @returns {PartialApplication} A partial InternalRequest.
50
39
  */
51
- function transformAsset(_a) {
52
- var _b;
53
- var asset = _a.asset, applicationId = _a.applicationId, id = _a.id;
54
- var isPropertyAsset = (0, is_asset_type_1.isRealEstateAsset)(asset);
55
- var idPath = isPropertyAsset ? "".concat(application_paths_1.paths.RealEstateAsset, ".@UniqueID") : "".concat(application_paths_1.paths.NonRealEstateAsset, ".@UniqueID");
56
- var addressId = "".concat(id, "-address");
57
- var assetMapping = getAssetMapping(asset);
58
- var partialApplication = {};
40
+ function transformAsset({ asset, applicationId, id }) {
41
+ var _a;
42
+ const isPropertyAsset = (0, is_asset_type_1.isRealEstateAsset)(asset);
43
+ const idPath = isPropertyAsset ? `${application_paths_1.paths.RealEstateAsset}.@UniqueID` : `${application_paths_1.paths.NonRealEstateAsset}.@UniqueID`;
44
+ const addressId = `${id}-address`;
45
+ const assetMapping = getAssetMapping(asset);
46
+ const partialApplication = {};
59
47
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
60
48
  (0, lodash_1.set)(partialApplication, idPath, id);
61
49
  if (isPropertyAsset) {
62
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@MultipleDwellings"), lixi_internal_request_1.YesNoList.No);
63
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@x_Address"), addressId);
50
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.@MultipleDwellings`, lixi_internal_request_1.YesNoList.No);
51
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.@x_Address`, addressId);
64
52
  }
65
53
  else {
66
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), enum_mappings_1.assetTypeMapping[asset.type]);
54
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, enum_mappings_1.assetTypeMapping[asset.type]);
67
55
  }
68
56
  if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
69
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
70
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.@Type"), enum_mappings_1.financialAssetMapping[asset.type]);
57
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
58
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.@Type`, enum_mappings_1.financialAssetMapping[asset.type]);
71
59
  }
72
60
  if ((0, is_asset_type_1.isOtherAsset)(asset)) {
73
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
61
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
74
62
  }
75
63
  switch (asset.type) {
76
64
  case public_asset_1.AssetType.Vehicle:
77
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
65
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.@Type`, lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
78
66
  break;
79
67
  case public_asset_1.AssetType.HomeContents:
80
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Type"), lixi_internal_request_1.OtherAssetTypeList.HomeContents);
68
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.OtherAsset.@Type`, lixi_internal_request_1.OtherAssetTypeList.HomeContents);
81
69
  break;
82
70
  case public_asset_1.AssetType.Gifts:
83
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Description"), asset.description || 'Asset Gifts');
71
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description || 'Asset Gifts');
84
72
  break;
85
73
  case public_asset_1.AssetType.OtherAsset:
86
74
  if (asset.description) {
87
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Description"), asset.description);
75
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description);
88
76
  }
89
77
  break;
90
78
  }
91
- for (var _i = 0, _c = Object.entries(asset); _i < _c.length; _i++) {
92
- var _d = _c[_i], key = _d[0], value = _d[1];
79
+ for (const [key, value] of Object.entries(asset)) {
93
80
  if (assetMapping[key]) {
94
81
  switch (key) {
95
82
  case 'contractDetails':
96
- var contractDate = value.contractDate;
83
+ const { contractDate } = value;
97
84
  if (contractDate)
98
85
  (0, lodash_1.set)(partialApplication, assetMapping.contractDate, contractDate);
99
86
  break;
@@ -104,14 +91,14 @@ function transformAsset(_a) {
104
91
  (0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.toBePurchasedMapping[value]);
105
92
  break;
106
93
  case 'propertyExpenses':
107
- if (!asset.percentOwned || (0, lodash_1.isEmpty)((_b = asset.percentOwned) === null || _b === void 0 ? void 0 : _b.owners)) {
94
+ if (!asset.percentOwned || (0, lodash_1.isEmpty)((_a = asset.percentOwned) === null || _a === void 0 ? void 0 : _a.owners)) {
108
95
  break;
109
96
  }
110
- var propertyExpenses = generatePropertyExpenses(value);
111
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyExpense"), propertyExpenses);
112
- var livingExpenses = generateLivingExpenses(asset.percentOwned, id, value);
97
+ const propertyExpenses = generatePropertyExpenses(value);
98
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.PropertyExpense`, propertyExpenses);
99
+ const livingExpenses = generateLivingExpenses(asset.percentOwned, id, value);
113
100
  (0, lodash_1.set)(partialApplication, assetMapping[key], livingExpenses);
114
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@Occupancy"), determineOccupancy(value));
101
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.@Occupancy`, determineOccupancy(value));
115
102
  break;
116
103
  case 'propertyStatus':
117
104
  (0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
@@ -121,16 +108,16 @@ function transformAsset(_a) {
121
108
  (0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.toBeUsedAsSecurityMapping[value]);
122
109
  break;
123
110
  case 'propertyType':
124
- var propertyTypeMapping_1 = getPropertyType(value);
125
- if (!propertyTypeMapping_1) {
126
- logger_1.logger.warn({ message: "Unknown propertyType ".concat(value, " for asset ").concat(id), applicationId: applicationId });
111
+ const propertyTypeMapping = getPropertyType(value);
112
+ if (!propertyTypeMapping) {
113
+ logger_1.logger.warn({ message: `Unknown propertyType ${value} for asset ${id}`, applicationId });
127
114
  }
128
- var path = propertyTypeMapping_1.path, mappedValue = propertyTypeMapping_1.value;
115
+ const { path, value: mappedValue } = propertyTypeMapping;
129
116
  (0, lodash_1.set)(partialApplication, path, mappedValue);
130
117
  break;
131
118
  case 'zoneType':
132
119
  if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
133
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Commercial.@Type"), lixi_internal_request_1.OtherAssetTypeList.Other);
120
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RealEstateAsset}.Commercial.@Type`, lixi_internal_request_1.OtherAssetTypeList.Other);
134
121
  (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom6TypeList.Commercial);
135
122
  }
136
123
  else {
@@ -139,7 +126,7 @@ function transformAsset(_a) {
139
126
  break;
140
127
  case 'financialInstitution':
141
128
  if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
142
- var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
129
+ const financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
143
130
  (0, lodash_1.set)(partialApplication, assetMapping[key], financialInstitution);
144
131
  }
145
132
  break;
@@ -153,26 +140,25 @@ function transformAsset(_a) {
153
140
  (0, lodash_1.set)(partialApplication, assetMapping[key], (0, __1.booleanMapping)(value));
154
141
  break;
155
142
  case 'percentOwned':
156
- var percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
143
+ const percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
157
144
  if (percentOwned) {
158
145
  (0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
159
146
  }
160
147
  break;
161
148
  case 'constructionDetails':
162
- for (var _e = 0, _f = Object.entries(value); _e < _f.length; _e++) {
163
- var _g = _f[_e], key_1 = _g[0], constructionDetailsValue = _g[1];
164
- switch (key_1) {
149
+ for (const [key, constructionDetailsValue] of Object.entries(value)) {
150
+ switch (key) {
165
151
  case 'builderType':
166
- (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], builder_type_1.builderTypeMapping[constructionDetailsValue]);
152
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], builder_type_1.builderTypeMapping[constructionDetailsValue]);
167
153
  break;
168
154
  case 'constructionType':
169
- (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], construction_type_1.constructionTypeMapping[constructionDetailsValue]);
155
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], construction_type_1.constructionTypeMapping[constructionDetailsValue]);
170
156
  break;
171
157
  case 'isFixedPriceContract':
172
- (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], (0, __1.booleanMapping)(constructionDetailsValue));
158
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], (0, __1.booleanMapping)(constructionDetailsValue));
173
159
  break;
174
160
  default:
175
- (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key_1], constructionDetailsValue);
161
+ (0, lodash_1.set)(partialApplication, constructionDetailsMapping[key], constructionDetailsValue);
176
162
  break;
177
163
  }
178
164
  }
@@ -198,22 +184,22 @@ exports.transformAsset = transformAsset;
198
184
  * @returns {PropertyTypeMapping | null} A path and value to be used for property type mapping.
199
185
  */
200
186
  function getPropertyType(propertyType) {
201
- var value = enum_mappings_1.propertyTypeMapping[propertyType];
187
+ const value = enum_mappings_1.propertyTypeMapping[propertyType];
202
188
  if (exports.residentialTypeList.includes(value)) {
203
189
  return {
204
- path: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
190
+ path: `${application_paths_1.paths.RealEstateAsset}.Residential`,
205
191
  value: {
206
- '@Type': value
207
- }
192
+ '@Type': value,
193
+ },
208
194
  };
209
195
  }
210
196
  if (exports.propertyTypeNameList.includes(value)) {
211
197
  return {
212
- path: "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType"),
198
+ path: `${application_paths_1.paths.RealEstateAsset}.PropertyType`,
213
199
  value: {
214
200
  '@PropertyTypeName': value,
215
- '@CategoryTypeName': lixi_internal_request_2.Custom1CategoryTypeNameList.Residential
216
- }
201
+ '@CategoryTypeName': lixi_internal_request_2.Custom1CategoryTypeNameList.Residential,
202
+ },
217
203
  };
218
204
  }
219
205
  return null;
@@ -225,37 +211,37 @@ exports.getPropertyType = getPropertyType;
225
211
  * @returns {Record<string, string>} Asset Transform Mapping.
226
212
  */
227
213
  function getAssetMapping(asset) {
228
- var estimatedValue = "".concat(application_paths_1.paths.NonRealEstateAsset, ".EstimatedValue.@Value");
229
- var percentOwned = "".concat(application_paths_1.paths.NonRealEstateAsset, ".PercentOwned");
230
- var baseMapping = {
231
- estimatedValue: estimatedValue,
232
- percentOwned: percentOwned
214
+ let estimatedValue = `${application_paths_1.paths.NonRealEstateAsset}.EstimatedValue.@Value`;
215
+ let percentOwned = `${application_paths_1.paths.NonRealEstateAsset}.PercentOwned`;
216
+ const baseMapping = {
217
+ estimatedValue,
218
+ percentOwned,
233
219
  };
234
220
  if ((0, is_asset_type_1.isRealEstateAsset)(asset)) {
235
- estimatedValue = "".concat(application_paths_1.paths.RealEstateAsset, ".EstimatedValue.@Value");
236
- percentOwned = "".concat(application_paths_1.paths.RealEstateAsset, ".PercentOwned");
221
+ estimatedValue = `${application_paths_1.paths.RealEstateAsset}.EstimatedValue.@Value`;
222
+ percentOwned = `${application_paths_1.paths.RealEstateAsset}.PercentOwned`;
237
223
  return {
238
224
  address: application_paths_1.paths.Address,
239
225
  contractDetails: 'contractDetails',
240
- contractDate: "".concat(application_paths_1.paths.RealEstateAsset, ".ContractDetails.@ContractDate"),
241
- estimatedValue: estimatedValue,
242
- percentOwned: percentOwned,
243
- primaryPurpose: "".concat(application_paths_1.paths.RealEstateAsset, ".@PrimaryPurpose"),
226
+ contractDate: `${application_paths_1.paths.RealEstateAsset}.ContractDetails.@ContractDate`,
227
+ estimatedValue,
228
+ percentOwned,
229
+ primaryPurpose: `${application_paths_1.paths.RealEstateAsset}.@PrimaryPurpose`,
244
230
  propertyExpenses: application_paths_1.paths.LivingExpenses,
245
- propertyStatus: "".concat(application_paths_1.paths.RealEstateAsset, ".@Status"),
246
- propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential"),
247
- toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
248
- toBeUsedAsSecurity: "".concat(application_paths_1.paths.RealEstateAsset, ".@ToBeUsedAsSecurity"),
249
- zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type"),
250
- isConstruction: "".concat(application_paths_1.paths.RealEstateAsset, ".@Construction"),
251
- constructionDetails: "".concat(application_paths_1.paths.RealEstateAsset, ".ConstructionDetails")
231
+ propertyStatus: `${application_paths_1.paths.RealEstateAsset}.@Status`,
232
+ propertyType: `${application_paths_1.paths.RealEstateAsset}.Residential`,
233
+ toBePurchased: `${application_paths_1.paths.RealEstateAsset}.@Transaction`,
234
+ toBeUsedAsSecurity: `${application_paths_1.paths.RealEstateAsset}.@ToBeUsedAsSecurity`,
235
+ zoneType: `${application_paths_1.paths.RealEstateAsset}.Zoning.@Type`,
236
+ isConstruction: `${application_paths_1.paths.RealEstateAsset}.@Construction`,
237
+ constructionDetails: `${application_paths_1.paths.RealEstateAsset}.ConstructionDetails`,
252
238
  };
253
239
  }
254
240
  if ((0, is_asset_type_1.isMotorVehicle)(asset)) {
255
- return __assign(__assign({}, baseMapping), { make: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Make"), model: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Model"), year: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Year") });
241
+ return Object.assign(Object.assign({}, baseMapping), { make: `${application_paths_1.paths.NonRealEstateAsset}.MotorVehicle.@Make`, model: `${application_paths_1.paths.NonRealEstateAsset}.MotorVehicle.@Model`, year: `${application_paths_1.paths.NonRealEstateAsset}.MotorVehicle.@Year` });
256
242
  }
257
243
  if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
258
- return __assign(__assign({}, baseMapping), { financialInstitution: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@FinancialInstitution"), financialInstitutionAccountNumber: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@AccountNumber"), financialInstitutionBsb: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@BSB") });
244
+ return Object.assign(Object.assign({}, baseMapping), { financialInstitution: `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.AccountNumber.@FinancialInstitution`, financialInstitutionAccountNumber: `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.AccountNumber.@AccountNumber`, financialInstitutionBsb: `${application_paths_1.paths.NonRealEstateAsset}.FinancialAsset.AccountNumber.@BSB` });
259
245
  }
260
246
  return baseMapping;
261
247
  }
@@ -266,26 +252,29 @@ exports.getAssetMapping = getAssetMapping;
266
252
  * @param percentOwned: owners of the property
267
253
  * @param assetId: Asset id
268
254
  * @param propertyExpenses: propertyExpenses items
255
+ * @param percentOwned
256
+ * @param assetId
257
+ * @param propertyExpenses
269
258
  */
270
259
  function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
271
- var livingExpenses = [];
272
- var filteredPropertyExpenses = propertyExpenses.filter(function (expense) { return expense.amount !== undefined; });
273
- percentOwned.owners.forEach(function (owner) {
274
- var expenses = filteredPropertyExpenses.map(function (expense) {
260
+ let livingExpenses = [];
261
+ const filteredPropertyExpenses = propertyExpenses.filter((expense) => expense.amount !== undefined);
262
+ percentOwned.owners.forEach((owner) => {
263
+ const expenses = filteredPropertyExpenses.map((expense) => {
275
264
  normalizeAmounts(expense);
276
265
  return {
277
266
  '@Amount': (0, round_decimal_1.roundDecimal)(expense.amount * owner.percent),
278
267
  '@Category': enum_mappings_1.livingExpenseMapping[expense.type],
279
268
  '@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency],
280
- '@UniqueID': "".concat((0, uuid_1.v4)(), "--").concat(assetId),
269
+ '@UniqueID': `${(0, uuid_1.v4)()}--${assetId}`,
281
270
  PercentResponsible: {
282
271
  Owner: [
283
272
  {
284
273
  '@Percent': 100,
285
- '@x_Party': owner.applicantId
274
+ '@x_Party': owner.applicantId,
286
275
  },
287
- ]
288
- }
276
+ ],
277
+ },
289
278
  };
290
279
  });
291
280
  livingExpenses = livingExpenses.concat(expenses);
@@ -295,43 +284,44 @@ function generateLivingExpenses(percentOwned, assetId, propertyExpenses) {
295
284
  exports.generateLivingExpenses = generateLivingExpenses;
296
285
  /**
297
286
  * Creates PropertyExpense array on RealEstateAsset from the same array on the event.
287
+ *
298
288
  * @param propertyExpenses
299
289
  */
300
290
  function generatePropertyExpenses(propertyExpenses) {
301
291
  return propertyExpenses
302
- .filter(function (expense) { return expense.amount !== undefined; })
303
- .map(function (expense) {
292
+ .filter((expense) => expense.amount !== undefined)
293
+ .map((expense) => {
304
294
  normalizeAmounts(expense);
305
295
  return {
306
296
  '@Amount': expense.amount,
307
297
  '@Category': enum_mappings_1.propertyExpenseCategoryMapping[expense.type],
308
- '@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency]
298
+ '@Frequency': enum_mappings_1.incomeExpenseFrequencyMapping[expense.frequency],
309
299
  };
310
300
  });
311
301
  }
312
302
  exports.generatePropertyExpenses = generatePropertyExpenses;
313
303
  /**
314
304
  * Determines the occupancy based on the list of property expense types available.
305
+ *
315
306
  * @param propertyExpenses
316
307
  */
317
308
  function determineOccupancy(propertyExpenses) {
318
- var propertyExpenseCategoryList = propertyExpenses.map(function (expense) { return expense.type; });
309
+ const propertyExpenseCategoryList = propertyExpenses.map((expense) => expense.type);
319
310
  if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.InvestmentPropertyRunningCosts)) {
320
311
  return lixi_internal_request_1.OccupancyList.NonOwner;
321
312
  }
322
313
  else if (propertyExpenseCategoryList.includes(public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts && public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts)) {
323
314
  return lixi_internal_request_1.OccupancyList.OwnerSecondary;
324
315
  }
325
- else if (propertyExpenseCategoryList.some(function (item) {
326
- return item !== public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts &&
327
- item === public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts;
328
- })) {
316
+ else if (propertyExpenseCategoryList.some((item) => item !== public_asset_1.PropertyExpenseType.SecondaryResidenceRunningCosts &&
317
+ item === public_asset_1.PropertyExpenseType.PrimaryResidenceRunningCosts)) {
329
318
  return lixi_internal_request_1.OccupancyList.OwnerPrimary;
330
319
  }
331
320
  }
332
321
  exports.determineOccupancy = determineOccupancy;
333
322
  /**
334
323
  * Calculates the correct amount and frequency.
324
+ *
335
325
  * @param expense
336
326
  */
337
327
  function normalizeAmounts(expense) {
@@ -15,6 +15,10 @@ export declare function transformExpenses(expense: ExpensePayload): PartialAppli
15
15
  * @param applicantId: Event applicantId.
16
16
  * @param index: Index of the map.
17
17
  * @param id: Id of the event.
18
+ * @param expense
19
+ * @param applicantId
20
+ * @param index
21
+ * @param id
18
22
  */
19
23
  export declare function transformExpense(expense: Expense, applicantId: string, index: number, id: string): LivingExpense | OtherCommitment;
20
24
  /**
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isLivingExpenseEstimate = exports.isOtherCommitment = exports.normaliseExpenseAmount = exports.transformExpense = exports.transformExpenses = exports.otherCommitmentExpenseTypes = void 0;
4
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
- var lodash_1 = require("lodash");
6
- var enum_mappings_1 = require("../types/enum-mappings/");
7
- var public_expense_1 = require("../types/events/public-expense");
4
+ const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
+ const lodash_1 = require("lodash");
6
+ const enum_mappings_1 = require("../types/enum-mappings/");
7
+ const public_expense_1 = require("../types/events/public-expense");
8
8
  exports.otherCommitmentExpenseTypes = [
9
9
  public_expense_1.ExpenseType.Board,
10
10
  public_expense_1.ExpenseType.ChildAndSpousalMaintenance,
11
11
  public_expense_1.ExpenseType.Rent,
12
12
  ];
13
- var propertyExpenseCategories = [
13
+ const propertyExpenseCategories = [
14
14
  public_expense_1.ExpenseType.InvestmentPropertyRunningCosts,
15
15
  public_expense_1.ExpenseType.BodyCorporateFeesStrataFeesAndLandTax,
16
16
  public_expense_1.ExpenseType.SecondaryResidenceRunningCosts,
@@ -22,33 +22,31 @@ var propertyExpenseCategories = [
22
22
  * @param expense
23
23
  */
24
24
  function transformExpenses(expense) {
25
- var partialApplication = {};
26
- var applicantId = expense.applicantId, applicationId = expense.applicationId, _a = expense.expenses, expenses = _a === void 0 ? [] : _a, id = expense.id;
27
- if (expenses.every(function (expense) { return expense.amount === undefined || expense.amount === null; })) {
25
+ const partialApplication = {};
26
+ const { applicantId, applicationId, expenses = [], id } = expense;
27
+ if (expenses.every((expense) => expense.amount === undefined || expense.amount === null)) {
28
28
  return partialApplication;
29
29
  }
30
- var normalisedExpenses = expenses.map(normaliseExpenseAmount);
31
- var filteredLivingExpensesWithAmount = normalisedExpenses.filter(function (expense) { return expense.amount || !propertyExpenseCategories.includes(expense.type); });
32
- var livingExpenseEstimate = filteredLivingExpensesWithAmount.find(isLivingExpenseEstimate);
33
- var otherCommitments = filteredLivingExpensesWithAmount.filter(isOtherCommitment);
34
- var expenseBreakdown = filteredLivingExpensesWithAmount.filter(function (item) { return !(isOtherCommitment(item) || isLivingExpenseEstimate(item)); });
35
- var livingExpenseEstimateExists = (0, lodash_1.get)(livingExpenseEstimate || {}, 'amount', 0) > 0;
36
- var expenseBreakdownAmountSum = (0, lodash_1.sumBy)(expenseBreakdown, 'amount');
37
- var lixiLivingExpenses;
30
+ const normalisedExpenses = expenses.map(normaliseExpenseAmount);
31
+ const filteredLivingExpensesWithAmount = normalisedExpenses.filter((expense) => expense.amount || !propertyExpenseCategories.includes(expense.type));
32
+ const livingExpenseEstimate = filteredLivingExpensesWithAmount.find(isLivingExpenseEstimate);
33
+ const otherCommitments = filteredLivingExpensesWithAmount.filter(isOtherCommitment);
34
+ const expenseBreakdown = filteredLivingExpensesWithAmount.filter((item) => !(isOtherCommitment(item) || isLivingExpenseEstimate(item)));
35
+ const livingExpenseEstimateExists = (0, lodash_1.get)(livingExpenseEstimate || {}, 'amount', 0) > 0;
36
+ const expenseBreakdownAmountSum = (0, lodash_1.sumBy)(expenseBreakdown, 'amount');
37
+ let lixiLivingExpenses;
38
38
  // unless all individual expenses have a value of 0 and a living estimate exists, transform them without question.
39
39
  if (expenseBreakdownAmountSum === 0 && livingExpenseEstimateExists) {
40
- var estimate = transformExpense(livingExpenseEstimate, applicantId, 0, id);
40
+ const estimate = transformExpense(livingExpenseEstimate, applicantId, 0, id);
41
41
  lixiLivingExpenses = [estimate];
42
42
  }
43
43
  else {
44
- lixiLivingExpenses = expenseBreakdown.map(function (expense, index) {
45
- return transformExpense(expense, applicantId, index, id);
46
- });
44
+ lixiLivingExpenses = expenseBreakdown.map((expense, index) => transformExpense(expense, applicantId, index, id));
47
45
  }
48
- var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
46
+ const lixiCommitmentExpenses = otherCommitments.map((expense, index) => transformExpense(expense, applicantId, index, id));
49
47
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
50
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
51
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
48
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Household}.@UniqueID`, `${applicationId}-household`);
49
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
52
50
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
53
51
  if (lixiLivingExpenses.length > 0) {
54
52
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
@@ -63,22 +61,26 @@ exports.transformExpenses = transformExpenses;
63
61
  * @param applicantId: Event applicantId.
64
62
  * @param index: Index of the map.
65
63
  * @param id: Id of the event.
64
+ * @param expense
65
+ * @param applicantId
66
+ * @param index
67
+ * @param id
66
68
  */
67
69
  function transformExpense(expense, applicantId, index, id) {
68
70
  return {
69
71
  '@Amount': expense.amount,
70
72
  '@Category': enum_mappings_1.livingExpenseMapping[expense.type],
71
73
  '@Description': expense.type,
72
- '@UniqueID': isOtherCommitment(expense) ? "".concat(id, "-commitment-").concat(index) : "".concat(id, "-living-expense-").concat(index),
74
+ '@UniqueID': isOtherCommitment(expense) ? `${id}-commitment-${index}` : `${id}-living-expense-${index}`,
73
75
  '@Frequency': enum_mappings_1.frequencyMapping[expense.frequency],
74
76
  PercentResponsible: {
75
77
  Owner: [
76
78
  {
77
79
  '@Percent': 100,
78
- '@x_Party': applicantId
80
+ '@x_Party': applicantId,
79
81
  },
80
- ]
81
- }
82
+ ],
83
+ },
82
84
  };
83
85
  }
84
86
  exports.transformExpense = transformExpense;
@@ -88,7 +90,7 @@ exports.transformExpense = transformExpense;
88
90
  * @returns {Expense} An normalised expense.
89
91
  */
90
92
  function normaliseExpenseAmount(expense) {
91
- var amount = expense.amount, _a = expense.frequency, frequency = _a === void 0 ? public_expense_1.Frequency.Yearly : _a, expenseType = expense.type;
93
+ const { amount, frequency = public_expense_1.Frequency.Yearly, type: expenseType } = expense;
92
94
  if (frequency === public_expense_1.Frequency.Quarterly) {
93
95
  expense.frequency = public_expense_1.Frequency.Yearly;
94
96
  expense.amount *= 4;
@@ -6,7 +6,7 @@ import { PartialApplication } from '../types/partial-application';
6
6
  *
7
7
  * @param fundingPosition a partialFundingPosition.
8
8
  * @param uniqueIdSuffix
9
- * @return partialApplication with fees, grants and borrowers contributions added.
9
+ * @returns partialApplication with fees, grants and borrowers contributions added.
10
10
  */
11
11
  export declare function transformFundingPosition(fundingPosition: FundingPositionPayload, uniqueIdSuffix?: string): PartialApplication;
12
12
  /**
@@ -16,6 +16,6 @@ export declare function transformFundingPosition(fundingPosition: FundingPositio
16
16
  * @param lmi
17
17
  * @param lmiIncluded
18
18
  * @param id
19
- * @return Array of fees
19
+ * @returns Array of fees
20
20
  */
21
21
  export declare function getFees(fundsRequiredBreakDown: FundsRequiredBreakdown, lmi: number, lmiIncluded: boolean, id: string): Fee[];