@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.
- package/lib/index.js +10 -22
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +2 -5
- package/lib/schemas/application-workflow-event.json +1 -30
- 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 -183
- 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 -66
- package/lib/transform-events/transform-percent-owned.d.ts +2 -1
- 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 -39
- 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.d.ts +1 -33
- package/lib/types/events/application-workflow.js +10 -46
- 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 +14 -17
|
@@ -1,343 +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
|
-
|
|
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
|
-
|
|
62
|
-
|
|
47
|
+
set(partialApplication, `${paths.RealEstateAsset}.@MultipleDwellings`, YesNoList.No);
|
|
48
|
+
set(partialApplication, `${paths.RealEstateAsset}.@x_Address`, addressId);
|
|
63
49
|
}
|
|
64
50
|
else {
|
|
65
|
-
|
|
51
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.@Type`, assetTypeMapping[asset.type]);
|
|
66
52
|
}
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
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 (
|
|
72
|
-
|
|
57
|
+
if (isOtherAsset(asset)) {
|
|
58
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.@Type`, NonRealEstateAssetTypeList.Other);
|
|
73
59
|
}
|
|
74
60
|
switch (asset.type) {
|
|
75
|
-
case
|
|
76
|
-
|
|
61
|
+
case AssetType.Vehicle:
|
|
62
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.@Type`, NonRealEstateAssetTypeList.MotorVehicleAndTransport);
|
|
77
63
|
break;
|
|
78
|
-
case
|
|
79
|
-
|
|
64
|
+
case AssetType.HomeContents:
|
|
65
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.OtherAsset.@Type`, OtherAssetTypeList.HomeContents);
|
|
80
66
|
break;
|
|
81
|
-
case
|
|
82
|
-
|
|
67
|
+
case AssetType.Gifts:
|
|
68
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description || 'Asset Gifts');
|
|
83
69
|
break;
|
|
84
|
-
case
|
|
70
|
+
case AssetType.OtherAsset:
|
|
85
71
|
if (asset.description) {
|
|
86
|
-
|
|
72
|
+
set(partialApplication, `${paths.NonRealEstateAsset}.OtherAsset.@Description`, asset.description);
|
|
87
73
|
}
|
|
88
74
|
break;
|
|
89
75
|
}
|
|
90
|
-
for (
|
|
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
|
-
|
|
80
|
+
const { contractDate } = value;
|
|
96
81
|
if (contractDate)
|
|
97
|
-
|
|
82
|
+
set(partialApplication, assetMapping.contractDate, contractDate);
|
|
98
83
|
break;
|
|
99
84
|
case 'primaryPurpose':
|
|
100
|
-
|
|
85
|
+
set(partialApplication, assetMapping[key], primaryPurposeMapping[value]);
|
|
101
86
|
break;
|
|
102
87
|
case 'toBePurchased':
|
|
103
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
101
|
+
set(partialApplication, assetMapping[key], propertyStatusMapping[value]);
|
|
117
102
|
break;
|
|
118
103
|
case 'toBeUsedAsSecurity':
|
|
119
104
|
if (isPropertyAsset)
|
|
120
|
-
|
|
105
|
+
set(partialApplication, assetMapping[key], toBeUsedAsSecurityMapping[value]);
|
|
121
106
|
break;
|
|
122
107
|
case 'propertyType':
|
|
123
|
-
|
|
124
|
-
if (!
|
|
125
|
-
|
|
108
|
+
const propertyTypeMapping = getPropertyType(value);
|
|
109
|
+
if (!propertyTypeMapping) {
|
|
110
|
+
logger.warn({ message: `Unknown propertyType ${value} for asset ${id}`, applicationId });
|
|
126
111
|
}
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
const { path, value: mappedValue } = propertyTypeMapping;
|
|
113
|
+
set(partialApplication, path, mappedValue);
|
|
129
114
|
break;
|
|
130
115
|
case 'zoneType':
|
|
131
|
-
if (asset.zoneType ===
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
121
|
+
set(partialApplication, assetMapping[key], Custom6TypeList.Residential);
|
|
137
122
|
}
|
|
138
123
|
break;
|
|
139
124
|
case 'financialInstitution':
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
131
|
+
set(partialApplication, assetMapping[key], value.toString());
|
|
147
132
|
break;
|
|
148
133
|
case 'address':
|
|
149
|
-
|
|
134
|
+
set(partialApplication, assetMapping[key], transformAddress(value, addressId));
|
|
150
135
|
break;
|
|
151
136
|
case 'isConstruction':
|
|
152
|
-
|
|
137
|
+
set(partialApplication, assetMapping[key], booleanMapping(value));
|
|
153
138
|
break;
|
|
154
139
|
case 'percentOwned':
|
|
155
|
-
|
|
140
|
+
const percentOwned = transformPercentOwned(value);
|
|
156
141
|
if (percentOwned) {
|
|
157
|
-
|
|
142
|
+
set(partialApplication, assetMapping[key], percentOwned);
|
|
158
143
|
}
|
|
159
144
|
break;
|
|
160
145
|
case 'constructionDetails':
|
|
161
|
-
for (
|
|
162
|
-
|
|
163
|
-
switch (key_1) {
|
|
146
|
+
for (const [key, constructionDetailsValue] of Object.entries(value)) {
|
|
147
|
+
switch (key) {
|
|
164
148
|
case 'builderType':
|
|
165
|
-
|
|
149
|
+
set(partialApplication, constructionDetailsMapping[key], builderTypeMapping[constructionDetailsValue]);
|
|
166
150
|
break;
|
|
167
151
|
case 'constructionType':
|
|
168
|
-
|
|
152
|
+
set(partialApplication, constructionDetailsMapping[key], constructionTypeMapping[constructionDetailsValue]);
|
|
169
153
|
break;
|
|
170
154
|
case 'isFixedPriceContract':
|
|
171
|
-
|
|
155
|
+
set(partialApplication, constructionDetailsMapping[key], booleanMapping(constructionDetailsValue));
|
|
172
156
|
break;
|
|
173
157
|
default:
|
|
174
|
-
|
|
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
|
-
|
|
165
|
+
set(partialApplication, constructionDetailsMapping[key], value);
|
|
182
166
|
}
|
|
183
|
-
|
|
167
|
+
set(partialApplication, assetMapping[key], value);
|
|
184
168
|
break;
|
|
185
169
|
default:
|
|
186
|
-
|
|
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
|
-
|
|
201
|
-
if (
|
|
182
|
+
export function getPropertyType(propertyType) {
|
|
183
|
+
const value = propertyTypeMapping[propertyType];
|
|
184
|
+
if (residentialTypeList.includes(value)) {
|
|
202
185
|
return {
|
|
203
|
-
path:
|
|
186
|
+
path: `${paths.RealEstateAsset}.Residential`,
|
|
204
187
|
value: {
|
|
205
|
-
'@Type': value
|
|
206
|
-
}
|
|
188
|
+
'@Type': value,
|
|
189
|
+
},
|
|
207
190
|
};
|
|
208
191
|
}
|
|
209
|
-
if (
|
|
192
|
+
if (propertyTypeNameList.includes(value)) {
|
|
210
193
|
return {
|
|
211
|
-
path:
|
|
194
|
+
path: `${paths.RealEstateAsset}.PropertyType`,
|
|
212
195
|
value: {
|
|
213
196
|
'@PropertyTypeName': value,
|
|
214
|
-
'@CategoryTypeName':
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
estimatedValue
|
|
231
|
-
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 (
|
|
234
|
-
estimatedValue =
|
|
235
|
-
percentOwned =
|
|
215
|
+
if (isRealEstateAsset(asset)) {
|
|
216
|
+
estimatedValue = `${paths.RealEstateAsset}.EstimatedValue.@Value`;
|
|
217
|
+
percentOwned = `${paths.RealEstateAsset}.PercentOwned`;
|
|
236
218
|
return {
|
|
237
|
-
address:
|
|
219
|
+
address: paths.Address,
|
|
238
220
|
contractDetails: 'contractDetails',
|
|
239
|
-
contractDate:
|
|
240
|
-
estimatedValue
|
|
241
|
-
percentOwned
|
|
242
|
-
primaryPurpose:
|
|
243
|
-
propertyExpenses:
|
|
244
|
-
propertyStatus:
|
|
245
|
-
propertyType:
|
|
246
|
-
toBePurchased:
|
|
247
|
-
toBeUsedAsSecurity:
|
|
248
|
-
zoneType:
|
|
249
|
-
isConstruction:
|
|
250
|
-
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 (
|
|
254
|
-
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` });
|
|
255
237
|
}
|
|
256
|
-
if (
|
|
257
|
-
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` });
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
percentOwned.owners.forEach(
|
|
273
|
-
|
|
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':
|
|
277
|
-
'@Category':
|
|
278
|
-
'@Frequency':
|
|
279
|
-
'@UniqueID':
|
|
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(
|
|
302
|
-
.map(
|
|
285
|
+
.filter((expense) => expense.amount !== undefined)
|
|
286
|
+
.map((expense) => {
|
|
303
287
|
normalizeAmounts(expense);
|
|
304
288
|
return {
|
|
305
289
|
'@Amount': expense.amount,
|
|
306
|
-
'@Category':
|
|
307
|
-
'@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
|
-
|
|
318
|
-
if (propertyExpenseCategoryList.includes(
|
|
319
|
-
return
|
|
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(
|
|
322
|
-
return
|
|
305
|
+
else if (propertyExpenseCategoryList.includes(PropertyExpenseType.PrimaryResidenceRunningCosts && PropertyExpenseType.SecondaryResidenceRunningCosts)) {
|
|
306
|
+
return OccupancyList.OwnerSecondary;
|
|
323
307
|
}
|
|
324
|
-
else if (propertyExpenseCategoryList.some(
|
|
325
|
-
|
|
326
|
-
|
|
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 ===
|
|
338
|
-
expense.frequency =
|
|
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
|
/**
|