@lendi/integrations-transform 1.5.7 → 1.5.10

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