@lendi/integrations-transform 1.5.6 → 1.5.9

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