@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.
- package/lib/index.js +10 -26
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +2 -5
- package/lib/schemas/application-workflow-event.json +1 -1
- package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
- package/lib/transform-events/generate-asset-liability-link.js +14 -18
- package/lib/transform-events/generate-credit-report-rebuilt.js +17 -21
- package/lib/transform-events/generate-employment.d.ts +1 -1
- package/lib/transform-events/generate-employment.js +51 -56
- package/lib/transform-events/generate-required-document.d.ts +1 -7
- package/lib/transform-events/generate-required-document.js +43 -69
- package/lib/transform-events/transform-applicant.d.ts +2 -1
- package/lib/transform-events/transform-applicant.js +78 -91
- package/lib/transform-events/transform-application-workflow.d.ts +0 -1
- package/lib/transform-events/transform-application-workflow.js +9 -14
- package/lib/transform-events/transform-application.d.ts +3 -1
- package/lib/transform-events/transform-application.js +28 -33
- package/lib/transform-events/transform-asset-address.d.ts +8 -2
- package/lib/transform-events/transform-asset-address.js +35 -37
- package/lib/transform-events/transform-asset.d.ts +7 -1
- package/lib/transform-events/transform-asset.js +164 -184
- package/lib/transform-events/transform-expenses.d.ts +4 -0
- package/lib/transform-events/transform-expenses.js +52 -58
- package/lib/transform-events/transform-funding-position.d.ts +2 -2
- package/lib/transform-events/transform-funding-position.js +38 -46
- package/lib/transform-events/transform-income.d.ts +8 -1
- package/lib/transform-events/transform-income.js +121 -139
- package/lib/transform-events/transform-liability.d.ts +4 -1
- package/lib/transform-events/transform-liability.js +62 -65
- package/lib/transform-events/transform-percent-owned.d.ts +1 -0
- package/lib/transform-events/transform-percent-owned.js +7 -14
- package/lib/types/enum-mappings/alieo-frequency.js +22 -26
- package/lib/types/enum-mappings/asset-type.js +14 -18
- package/lib/types/enum-mappings/builder-type.js +6 -10
- package/lib/types/enum-mappings/construction-type.js +7 -11
- package/lib/types/enum-mappings/country-code.js +243 -247
- package/lib/types/enum-mappings/employment-basis.js +9 -13
- package/lib/types/enum-mappings/expense-frequency.js +8 -12
- package/lib/types/enum-mappings/funding-position.js +29 -32
- package/lib/types/enum-mappings/government-benefits.js +7 -11
- package/lib/types/enum-mappings/housing-status.js +12 -16
- package/lib/types/enum-mappings/income-type.js +13 -17
- package/lib/types/enum-mappings/index.js +27 -43
- package/lib/types/enum-mappings/liability-payment-type.js +6 -10
- package/lib/types/enum-mappings/liability-type.js +18 -22
- package/lib/types/enum-mappings/living-expense.js +27 -31
- package/lib/types/enum-mappings/marital-status.js +9 -13
- package/lib/types/enum-mappings/postcode.js +11 -15
- package/lib/types/enum-mappings/preferred-repayment.js +7 -11
- package/lib/types/enum-mappings/proof-of-identity.js +7 -11
- package/lib/types/enum-mappings/property-expense-category.js +8 -12
- package/lib/types/enum-mappings/public-financial-asset.js +9 -13
- package/lib/types/enum-mappings/public-primary-purpose.js +6 -10
- package/lib/types/enum-mappings/public-property-status.js +8 -12
- package/lib/types/enum-mappings/public-property-type.js +20 -24
- package/lib/types/enum-mappings/residency-status.js +8 -12
- package/lib/types/enum-mappings/title-gender.js +10 -14
- package/lib/types/enum-mappings/title.js +10 -14
- package/lib/types/enum-mappings/to-be-purchased.js +4 -7
- package/lib/types/enum-mappings/to-be-used-as-security.js +4 -7
- package/lib/types/enum-mappings/transaction-type.js +6 -10
- package/lib/types/enum-mappings/verification.js +10 -14
- package/lib/types/events/applicant-delete.js +4 -7
- package/lib/types/events/application-workflow.js +10 -13
- package/lib/types/events/asset-delete.js +4 -7
- package/lib/types/events/asset-liability-relation-delete.js +4 -7
- package/lib/types/events/credit-report-retrieved.js +4 -7
- package/lib/types/events/employment-delete.js +2 -5
- package/lib/types/events/expense-delete.js +2 -5
- package/lib/types/events/funding-position.js +6 -9
- package/lib/types/events/income-delete.js +4 -7
- package/lib/types/events/liability-delete.js +2 -5
- package/lib/types/events/opportunity.js +6 -9
- package/lib/types/events/public-applicant.js +28 -31
- package/lib/types/events/public-application.js +26 -29
- package/lib/types/events/public-asset-liability-relation.js +4 -7
- package/lib/types/events/public-asset.js +26 -29
- package/lib/types/events/public-employment.js +18 -21
- package/lib/types/events/public-expense.js +8 -11
- package/lib/types/events/public-funding-position.js +2 -5
- package/lib/types/events/public-income.js +12 -15
- package/lib/types/events/public-liability.js +16 -19
- package/lib/types/events/public-required-document.js +14 -17
- package/lib/types/partial-application.js +1 -2
- package/lib/types/recursive-partial.js +1 -2
- package/lib/update-application/merge-application.d.ts +1 -1
- package/lib/update-application/merge-application.js +41 -38
- package/lib/update-application/update-primary-applicant.d.ts +1 -4
- package/lib/update-application/update-primary-applicant.js +14 -38
- package/lib/utils/address-tools.d.ts +3 -1
- package/lib/utils/address-tools.js +56 -68
- package/lib/utils/clean-up.d.ts +1 -1
- package/lib/utils/clean-up.js +6 -10
- package/lib/utils/formatYesNo.d.ts +0 -1
- package/lib/utils/formatYesNo.js +2 -7
- package/lib/utils/generate-address.d.ts +3 -2
- package/lib/utils/generate-address.js +33 -42
- package/lib/utils/get-financial-institution.d.ts +1 -0
- package/lib/utils/get-financial-institution.js +7 -10
- package/lib/utils/is-asset-type.js +13 -20
- package/lib/utils/is-income-type.d.ts +2 -0
- package/lib/utils/is-income-type.js +50 -69
- package/lib/utils/iso-date.d.ts +0 -1
- package/lib/utils/iso-date.js +2 -7
- package/lib/utils/normalise-date.js +6 -10
- package/lib/utils/round-decimal.js +1 -5
- package/package.json +15 -18
|
@@ -1,344 +1,324 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
builderType:
|
|
38
|
-
buildPriceAmount:
|
|
39
|
-
constructionType:
|
|
40
|
-
estimatedValue:
|
|
41
|
-
isFixedPriceContract:
|
|
42
|
-
landEstimatedValue:
|
|
43
|
-
otherConstructionCosts:
|
|
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
|
-
* @
|
|
35
|
+
* @returns {PartialApplication} A partial InternalRequest.
|
|
50
36
|
*/
|
|
51
|
-
function transformAsset(
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
63
|
-
|
|
47
|
+
set(partialApplication, `${paths.RealEstateAsset}.@MultipleDwellings`, YesNoList.No);
|
|
48
|
+
set(partialApplication, `${paths.RealEstateAsset}.@x_Address`, addressId);
|
|
64
49
|
}
|
|
65
50
|
else {
|
|
66
|
-
|
|
51
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.@Type`, assetTypeMapping[asset.type]);
|
|
67
52
|
}
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
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 (
|
|
73
|
-
|
|
57
|
+
if (isOtherAsset(asset)) {
|
|
58
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.@Type`, NonRealEstateAssetTypeList.Other);
|
|
74
59
|
}
|
|
75
60
|
switch (asset.type) {
|
|
76
|
-
case
|
|
77
|
-
|
|
61
|
+
case AssetType.Vehicle:
|
|
62
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.@Type`, NonRealEstateAssetTypeList.MotorVehicleAndTransport);
|
|
78
63
|
break;
|
|
79
|
-
case
|
|
80
|
-
|
|
64
|
+
case AssetType.HomeContents:
|
|
65
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.OtherAsset.@Type`, OtherAssetTypeList.HomeContents);
|
|
81
66
|
break;
|
|
82
|
-
case
|
|
83
|
-
|
|
67
|
+
case AssetType.Gifts:
|
|
68
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description || 'Asset Gifts');
|
|
84
69
|
break;
|
|
85
|
-
case
|
|
70
|
+
case AssetType.OtherAsset:
|
|
86
71
|
if (asset.description) {
|
|
87
|
-
|
|
72
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description);
|
|
88
73
|
}
|
|
89
74
|
break;
|
|
90
75
|
}
|
|
91
|
-
for (
|
|
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
|
-
|
|
80
|
+
const { contractDate } = value;
|
|
97
81
|
if (contractDate)
|
|
98
|
-
|
|
82
|
+
set(partialApplication, assetMapping.contractDate, contractDate);
|
|
99
83
|
break;
|
|
100
84
|
case 'primaryPurpose':
|
|
101
|
-
|
|
85
|
+
set(partialApplication, assetMapping[key], primaryPurposeMapping[value]);
|
|
102
86
|
break;
|
|
103
87
|
case 'toBePurchased':
|
|
104
|
-
|
|
88
|
+
set(partialApplication, assetMapping[key], toBePurchasedMapping[value]);
|
|
105
89
|
break;
|
|
106
90
|
case 'propertyExpenses':
|
|
107
|
-
if (!asset.percentOwned ||
|
|
91
|
+
if (!asset.percentOwned || isEmpty((_a = asset.percentOwned) === null || _a === void 0 ? void 0 : _a.owners)) {
|
|
108
92
|
break;
|
|
109
93
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
101
|
+
set(partialApplication, assetMapping[key], propertyStatusMapping[value]);
|
|
118
102
|
break;
|
|
119
103
|
case 'toBeUsedAsSecurity':
|
|
120
104
|
if (isPropertyAsset)
|
|
121
|
-
|
|
105
|
+
set(partialApplication, assetMapping[key], toBeUsedAsSecurityMapping[value]);
|
|
122
106
|
break;
|
|
123
107
|
case 'propertyType':
|
|
124
|
-
|
|
125
|
-
if (!
|
|
126
|
-
|
|
108
|
+
const propertyTypeMapping = getPropertyType(value);
|
|
109
|
+
if (!propertyTypeMapping) {
|
|
110
|
+
logger.warn({ message: `Unknown propertyType ${value} for asset ${id}`, applicationId });
|
|
127
111
|
}
|
|
128
|
-
|
|
129
|
-
|
|
112
|
+
const { path, value: mappedValue } = propertyTypeMapping;
|
|
113
|
+
set(partialApplication, path, mappedValue);
|
|
130
114
|
break;
|
|
131
115
|
case 'zoneType':
|
|
132
|
-
if (asset.zoneType ===
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
121
|
+
set(partialApplication, assetMapping[key], Custom6TypeList.Residential);
|
|
138
122
|
}
|
|
139
123
|
break;
|
|
140
124
|
case 'financialInstitution':
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
131
|
+
set(partialApplication, assetMapping[key], value.toString());
|
|
148
132
|
break;
|
|
149
133
|
case 'address':
|
|
150
|
-
|
|
134
|
+
set(partialApplication, assetMapping[key], transformAddress(value, addressId));
|
|
151
135
|
break;
|
|
152
136
|
case 'isConstruction':
|
|
153
|
-
|
|
137
|
+
set(partialApplication, assetMapping[key], booleanMapping(value));
|
|
154
138
|
break;
|
|
155
139
|
case 'percentOwned':
|
|
156
|
-
|
|
140
|
+
const percentOwned = transformPercentOwned(value);
|
|
157
141
|
if (percentOwned) {
|
|
158
|
-
|
|
142
|
+
set(partialApplication, assetMapping[key], percentOwned);
|
|
159
143
|
}
|
|
160
144
|
break;
|
|
161
145
|
case 'constructionDetails':
|
|
162
|
-
for (
|
|
163
|
-
|
|
164
|
-
switch (key_1) {
|
|
146
|
+
for (const [key, constructionDetailsValue] of Object.entries(value)) {
|
|
147
|
+
switch (key) {
|
|
165
148
|
case 'builderType':
|
|
166
|
-
|
|
149
|
+
set(partialApplication, constructionDetailsMapping[key], builderTypeMapping[constructionDetailsValue]);
|
|
167
150
|
break;
|
|
168
151
|
case 'constructionType':
|
|
169
|
-
|
|
152
|
+
set(partialApplication, constructionDetailsMapping[key], constructionTypeMapping[constructionDetailsValue]);
|
|
170
153
|
break;
|
|
171
154
|
case 'isFixedPriceContract':
|
|
172
|
-
|
|
155
|
+
set(partialApplication, constructionDetailsMapping[key], booleanMapping(constructionDetailsValue));
|
|
173
156
|
break;
|
|
174
157
|
default:
|
|
175
|
-
|
|
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
|
-
|
|
165
|
+
set(partialApplication, constructionDetailsMapping[key], value);
|
|
183
166
|
}
|
|
184
|
-
|
|
167
|
+
set(partialApplication, assetMapping[key], value);
|
|
185
168
|
break;
|
|
186
169
|
default:
|
|
187
|
-
|
|
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
|
-
|
|
202
|
-
if (
|
|
182
|
+
export function getPropertyType(propertyType) {
|
|
183
|
+
const value = propertyTypeMapping[propertyType];
|
|
184
|
+
if (residentialTypeList.includes(value)) {
|
|
203
185
|
return {
|
|
204
|
-
path:
|
|
186
|
+
path: `${paths.RealEstateAsset}.Residential`,
|
|
205
187
|
value: {
|
|
206
|
-
'@Type': value
|
|
207
|
-
}
|
|
188
|
+
'@Type': value,
|
|
189
|
+
},
|
|
208
190
|
};
|
|
209
191
|
}
|
|
210
|
-
if (
|
|
192
|
+
if (propertyTypeNameList.includes(value)) {
|
|
211
193
|
return {
|
|
212
|
-
path:
|
|
194
|
+
path: `${paths.RealEstateAsset}.PropertyType`,
|
|
213
195
|
value: {
|
|
214
196
|
'@PropertyTypeName': value,
|
|
215
|
-
'@CategoryTypeName':
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
estimatedValue
|
|
232
|
-
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 (
|
|
235
|
-
estimatedValue =
|
|
236
|
-
percentOwned =
|
|
215
|
+
if (isRealEstateAsset(asset)) {
|
|
216
|
+
estimatedValue = `${paths.RealEstateAsset}.EstimatedValue.@Value`;
|
|
217
|
+
percentOwned = `${paths.RealEstateAsset}.PercentOwned`;
|
|
237
218
|
return {
|
|
238
|
-
address:
|
|
219
|
+
address: paths.Address,
|
|
239
220
|
contractDetails: 'contractDetails',
|
|
240
|
-
contractDate:
|
|
241
|
-
estimatedValue
|
|
242
|
-
percentOwned
|
|
243
|
-
primaryPurpose:
|
|
244
|
-
propertyExpenses:
|
|
245
|
-
propertyStatus:
|
|
246
|
-
propertyType:
|
|
247
|
-
toBePurchased:
|
|
248
|
-
toBeUsedAsSecurity:
|
|
249
|
-
zoneType:
|
|
250
|
-
isConstruction:
|
|
251
|
-
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 (
|
|
255
|
-
return
|
|
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 (
|
|
258
|
-
return
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
percentOwned.owners.forEach(
|
|
274
|
-
|
|
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':
|
|
278
|
-
'@Category':
|
|
279
|
-
'@Frequency':
|
|
280
|
-
'@UniqueID':
|
|
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(
|
|
303
|
-
.map(
|
|
285
|
+
.filter((expense) => expense.amount !== undefined)
|
|
286
|
+
.map((expense) => {
|
|
304
287
|
normalizeAmounts(expense);
|
|
305
288
|
return {
|
|
306
289
|
'@Amount': expense.amount,
|
|
307
|
-
'@Category':
|
|
308
|
-
'@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
|
-
|
|
319
|
-
if (propertyExpenseCategoryList.includes(
|
|
320
|
-
return
|
|
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(
|
|
323
|
-
return
|
|
305
|
+
else if (propertyExpenseCategoryList.includes(PropertyExpenseType.PrimaryResidenceRunningCosts && PropertyExpenseType.SecondaryResidenceRunningCosts)) {
|
|
306
|
+
return OccupancyList.OwnerSecondary;
|
|
324
307
|
}
|
|
325
|
-
else if (propertyExpenseCategoryList.some(
|
|
326
|
-
|
|
327
|
-
|
|
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 ===
|
|
339
|
-
expense.frequency =
|
|
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
|
/**
|