@lendi/integrations-transform 1.1.6 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/schemas/public-asset-event.json +86 -93
- package/lib/transform-events/generate-asset-liability-link.js +2 -2
- package/lib/transform-events/generate-credit-report-rebuilt.js +1 -1
- package/lib/transform-events/generate-employment.js +17 -17
- package/lib/transform-events/generate-funding-position.js +6 -6
- package/lib/transform-events/generate-liability.js +15 -15
- package/lib/transform-events/generate-opportunity.js +2 -2
- package/lib/transform-events/generate-required-document.js +7 -7
- package/lib/transform-events/transform-applicant.js +26 -29
- package/lib/transform-events/transform-application.js +7 -8
- package/lib/transform-events/transform-asset.d.ts +44 -0
- package/lib/transform-events/transform-asset.js +271 -0
- package/lib/transform-events/transform-expenses.js +6 -7
- package/lib/transform-events/{generate-income.d.ts → transform-income.d.ts} +1 -1
- package/lib/transform-events/{generate-income.js → transform-income.js} +35 -31
- package/lib/transform-events/{generate-lixi-percentowned.d.ts → transform-percent-owned.d.ts} +1 -1
- package/lib/transform-events/{generate-lixi-percentowned.js → transform-percent-owned.js} +3 -3
- package/lib/types/enum-mappings/asset-type.d.ts +3 -0
- package/lib/types/enum-mappings/asset-type.js +18 -0
- package/lib/types/enum-mappings/index.d.ts +26 -0
- package/lib/types/enum-mappings/index.js +38 -0
- package/lib/types/enum-mappings/to-be-purchased.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-purchased.js +8 -0
- package/lib/types/enum-mappings/to-be-used-as-security.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-used-as-security.js +8 -0
- package/lib/types/events/public-asset.d.ts +16 -17
- package/lib/types/events/public-asset.js +3 -0
- package/lib/utils/address-tools.d.ts +14 -1
- package/lib/utils/address-tools.js +35 -3
- package/lib/utils/generate-address.d.ts +3 -4
- package/lib/utils/generate-address.js +8 -9
- package/lib/utils/is-asset-type.d.ts +25 -0
- package/lib/utils/is-asset-type.js +46 -0
- package/lib/utils/normalise-date.js +1 -1
- package/package.json +4 -4
- package/lib/transform-events/generate-asset.d.ts +0 -17
- package/lib/transform-events/generate-asset.js +0 -178
|
@@ -5,10 +5,7 @@ var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/li
|
|
|
5
5
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
6
|
var lodash_1 = require("lodash");
|
|
7
7
|
var address_tools_1 = require("../utils/address-tools");
|
|
8
|
-
var
|
|
9
|
-
var marital_status_1 = require("../types/enum-mappings/marital-status");
|
|
10
|
-
var residency_status_1 = require("../types/enum-mappings/residency-status");
|
|
11
|
-
var title_1 = require("../types/enum-mappings/title");
|
|
8
|
+
var enum_mappings_1 = require("../types/enum-mappings");
|
|
12
9
|
var public_applicant_1 = require("../types/events/public-applicant");
|
|
13
10
|
var normalise_date_1 = require("../utils/normalise-date");
|
|
14
11
|
var booleanMapping = function (input) {
|
|
@@ -18,20 +15,20 @@ var booleanMapping = function (input) {
|
|
|
18
15
|
exports.booleanMapping = booleanMapping;
|
|
19
16
|
var applicantMapping = {
|
|
20
17
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
21
|
-
citizenship:
|
|
22
|
-
contact:
|
|
18
|
+
citizenship: application_paths_1.paths.PersonApplicant + ".@Citizenship",
|
|
19
|
+
contact: application_paths_1.paths.PersonApplicant + ".Contact",
|
|
23
20
|
dependants: 'dependants',
|
|
24
|
-
dateOfBirth:
|
|
25
|
-
firstName:
|
|
26
|
-
id:
|
|
27
|
-
isFirstHomeBuyer:
|
|
28
|
-
isPrimaryApplicant:
|
|
29
|
-
lastName:
|
|
30
|
-
maritalStatus:
|
|
31
|
-
maritalDetails:
|
|
32
|
-
middleName:
|
|
33
|
-
residencyStatus:
|
|
34
|
-
title:
|
|
21
|
+
dateOfBirth: application_paths_1.paths.PersonApplicant + ".@DateOfBirth",
|
|
22
|
+
firstName: application_paths_1.paths.PersonApplicant + ".PersonName.@FirstName",
|
|
23
|
+
id: application_paths_1.paths.PersonApplicant + ".@UniqueID",
|
|
24
|
+
isFirstHomeBuyer: application_paths_1.paths.PersonApplicant + ".@FirstHomeBuyer",
|
|
25
|
+
isPrimaryApplicant: application_paths_1.paths.PersonApplicant + ".@PrimaryApplicant",
|
|
26
|
+
lastName: application_paths_1.paths.PersonApplicant + ".PersonName.@Surname",
|
|
27
|
+
maritalStatus: application_paths_1.paths.PersonApplicant + ".@MaritalStatus",
|
|
28
|
+
maritalDetails: application_paths_1.paths.PersonApplicant + ".MaritalStatusDetails.@x_Spouse",
|
|
29
|
+
middleName: application_paths_1.paths.PersonApplicant + ".PersonName.@MiddleNames",
|
|
30
|
+
residencyStatus: application_paths_1.paths.PersonApplicant + ".@ResidencyStatus",
|
|
31
|
+
title: application_paths_1.paths.PersonName + ".@NameTitle"
|
|
35
32
|
};
|
|
36
33
|
/**
|
|
37
34
|
* Transforms a partial Applicant event to a partial LIXI application.
|
|
@@ -44,7 +41,7 @@ function transformApplicant(applicant) {
|
|
|
44
41
|
var applicantId = applicant.id, applicationId = applicant.applicationId;
|
|
45
42
|
(0, lodash_1.set)(partialApplication, applicantMapping['isFirstHomeBuyer'], (0, exports.booleanMapping)(applicant.isFirstHomeBuyer));
|
|
46
43
|
(0, lodash_1.set)(partialApplication, applicantMapping['isPrimaryApplicant'], (0, exports.booleanMapping)(applicant.isPrimaryApplicant));
|
|
47
|
-
(0, lodash_1.set)(partialApplication, applicantMapping['title'],
|
|
44
|
+
(0, lodash_1.set)(partialApplication, applicantMapping['title'], enum_mappings_1.titleMapping[applicant.title || public_applicant_1.Title.Unknown]);
|
|
48
45
|
var applicantUpdated = (0, lodash_1.omit)(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
|
|
49
46
|
for (var _i = 0, _a = Object.entries(applicantUpdated); _i < _a.length; _i++) {
|
|
50
47
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
@@ -54,13 +51,13 @@ function transformApplicant(applicant) {
|
|
|
54
51
|
(0, lodash_1.set)(partialApplication, applicantMapping[key], (0, normalise_date_1.normaliseDate)(value));
|
|
55
52
|
break;
|
|
56
53
|
case 'maritalStatus':
|
|
57
|
-
(0, lodash_1.set)(partialApplication, applicantMapping[key],
|
|
54
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.maritalStatusMapping[value]);
|
|
58
55
|
break;
|
|
59
56
|
case 'citizenship':
|
|
60
|
-
(0, lodash_1.set)(partialApplication, applicantMapping[key],
|
|
57
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.countryCodeMapping[value]);
|
|
61
58
|
break;
|
|
62
59
|
case 'residencyStatus':
|
|
63
|
-
(0, lodash_1.set)(partialApplication, applicantMapping[key],
|
|
60
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.residencyStatusMapping[value]);
|
|
64
61
|
// Certain bank integrations require the ability to differentiate between permanentResident and Citizen
|
|
65
62
|
// As lixi does not have a citizen enum for residencyStatus citizen is mapped to permanentResident
|
|
66
63
|
// Adding a @Citizenship attribute to person applicant gives us the ability to determine citizenship status
|
|
@@ -84,8 +81,8 @@ function transformApplicant(applicant) {
|
|
|
84
81
|
break;
|
|
85
82
|
case 'dependants':
|
|
86
83
|
var dependants = generateDependants(value, applicantId);
|
|
87
|
-
(0, lodash_1.set)(partialApplication,
|
|
88
|
-
(0, lodash_1.set)(partialApplication,
|
|
84
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
|
|
85
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".Dependant", dependants);
|
|
89
86
|
break;
|
|
90
87
|
default:
|
|
91
88
|
(0, lodash_1.set)(partialApplication, applicantMapping[key], value);
|
|
@@ -120,7 +117,7 @@ function generateContact(contact, id) {
|
|
|
120
117
|
switch (key) {
|
|
121
118
|
case 'currentAddress':
|
|
122
119
|
{
|
|
123
|
-
var addressId =
|
|
120
|
+
var addressId = id + "-current";
|
|
124
121
|
var _c = (0, address_tools_1.rebuildAddress)(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
|
|
125
122
|
lixiAddresses.push(lixiAddress);
|
|
126
123
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
@@ -128,7 +125,7 @@ function generateContact(contact, id) {
|
|
|
128
125
|
break;
|
|
129
126
|
case 'postSettlementAddress':
|
|
130
127
|
{
|
|
131
|
-
var addressId =
|
|
128
|
+
var addressId = id + "-postSettlement";
|
|
132
129
|
var _d = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
|
|
133
130
|
lixiAddresses.push(lixiAddress);
|
|
134
131
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
@@ -136,7 +133,7 @@ function generateContact(contact, id) {
|
|
|
136
133
|
break;
|
|
137
134
|
case 'mailingAddress':
|
|
138
135
|
{
|
|
139
|
-
var addressId =
|
|
136
|
+
var addressId = id + "-mailing";
|
|
140
137
|
var lixiAddress = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId).lixiAddress;
|
|
141
138
|
lixiAddresses.push(lixiAddress);
|
|
142
139
|
(0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
|
|
@@ -144,7 +141,7 @@ function generateContact(contact, id) {
|
|
|
144
141
|
break;
|
|
145
142
|
case 'previousAddresses':
|
|
146
143
|
{
|
|
147
|
-
var addressId =
|
|
144
|
+
var addressId = id + "-previous";
|
|
148
145
|
var previousAddresses = value.sort(function (lhs, rhs) {
|
|
149
146
|
return lhs.endDate.localeCompare(rhs.endDate);
|
|
150
147
|
});
|
|
@@ -154,9 +151,9 @@ function generateContact(contact, id) {
|
|
|
154
151
|
(0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
|
|
155
152
|
// PriorAddresses
|
|
156
153
|
previousAddresses.forEach(function (address, index) {
|
|
157
|
-
var _a = (0, address_tools_1.rebuildAddress)(address,
|
|
154
|
+
var _a = (0, address_tools_1.rebuildAddress)(address, id + "-prior-" + index), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
|
|
158
155
|
lixiAddresses.push(lixiAddress);
|
|
159
|
-
(0, lodash_1.set)(lixiContact,
|
|
156
|
+
(0, lodash_1.set)(lixiContact, contactMapping['priorAddress'] + "." + index, lixiContactAddress);
|
|
160
157
|
});
|
|
161
158
|
}
|
|
162
159
|
break;
|
|
@@ -5,8 +5,7 @@ var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types
|
|
|
5
5
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
6
|
var application_paths_2 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
7
7
|
var lodash_1 = require("lodash");
|
|
8
|
-
var
|
|
9
|
-
var transaction_type_1 = require("../types/enum-mappings/transaction-type");
|
|
8
|
+
var enum_mappings_1 = require("../types/enum-mappings/");
|
|
10
9
|
/**
|
|
11
10
|
* Transforms a partial opportunity event to a partial internal request.
|
|
12
11
|
*
|
|
@@ -18,14 +17,14 @@ function transformApplication(opportunity) {
|
|
|
18
17
|
var opportunityMapping = {
|
|
19
18
|
brand: application_paths_1.paths.BusinessName,
|
|
20
19
|
id: application_paths_1.paths.ApplicationId,
|
|
21
|
-
paymentType:
|
|
20
|
+
paymentType: application_paths_1.paths.LoanTerm + ".@PaymentType",
|
|
22
21
|
preliminary: 'preliminary',
|
|
23
22
|
primaryPurpose: application_paths_1.paths.PurposeOfApplication,
|
|
24
23
|
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
|
|
25
24
|
};
|
|
26
|
-
(0, lodash_1.set)(partialApplication,
|
|
27
|
-
(0, lodash_1.set)(partialApplication,
|
|
28
|
-
(0, lodash_1.set)(partialApplication,
|
|
25
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LoanDetail + ".@UniqueID", opportunity.id + "-loanDetails");
|
|
26
|
+
(0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions + ".@UniqueID", opportunity.id + "-stage");
|
|
27
|
+
(0, lodash_1.set)(partialApplication, application_paths_2.paths.Instructions + ".@Name", lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
|
|
29
28
|
for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
|
|
30
29
|
var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
|
|
31
30
|
if (opportunityMapping[opportunityKey]) {
|
|
@@ -35,10 +34,10 @@ function transformApplication(opportunity) {
|
|
|
35
34
|
if (opportunityMapping[key]) {
|
|
36
35
|
switch (key) {
|
|
37
36
|
case 'paymentType':
|
|
38
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key],
|
|
37
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.preferredRepaymentMapping[value]);
|
|
39
38
|
break;
|
|
40
39
|
case 'primaryPurpose':
|
|
41
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key],
|
|
40
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.transactionTypeMapping[value]);
|
|
42
41
|
break;
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Payload, Address, AddressStandard, PropertyType, Asset } from '../types/events/public-asset';
|
|
2
|
+
import { PartialApplication } from '../types/partial-application';
|
|
3
|
+
import { AddressType, Standard } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
4
|
+
import { Residential, PropertyType as LixiPropertyType } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
5
|
+
export interface PropertyTypeMapping {
|
|
6
|
+
path: string;
|
|
7
|
+
value: Residential | LixiPropertyType;
|
|
8
|
+
}
|
|
9
|
+
export declare const propertyTypeNameList: string[];
|
|
10
|
+
export declare const residentialTypeList: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Generates a partial internal request from a partial public asset event.
|
|
13
|
+
*
|
|
14
|
+
* @param {Payload} asset - A partial public asset.
|
|
15
|
+
* @return {PartialApplication} A partial InternalRequest.
|
|
16
|
+
*/
|
|
17
|
+
export declare function transformAsset({ asset, applicationId, id }: Payload): PartialApplication;
|
|
18
|
+
/**
|
|
19
|
+
* Generates an address for an asset.
|
|
20
|
+
*
|
|
21
|
+
* @param address: An address object.
|
|
22
|
+
* @param id: address event id.
|
|
23
|
+
* @param toBeUsedAsSecurity
|
|
24
|
+
* @return A transformed address object.
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateAddress(address: Address, id: string): Partial<AddressType>;
|
|
27
|
+
/**
|
|
28
|
+
* @description Generates an address standard.
|
|
29
|
+
* @param {AddressStandard} addressStandard An address standard object.
|
|
30
|
+
* @return {Partial<Standard>} A transformed standard object.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateStandard(addressStandard: AddressStandard): Partial<Standard>;
|
|
33
|
+
/**
|
|
34
|
+
* @description Map the propertyType to a RealEstateAsset path and the value.
|
|
35
|
+
* @param {PropertyType} propertyType - A propertyType.
|
|
36
|
+
* @returns {PropertyTypeMapping | null} A path and value to be used for property type mapping.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getPropertyType(propertyType: PropertyType): PropertyTypeMapping | null;
|
|
39
|
+
/**
|
|
40
|
+
* @description Get the asset transform mapping for various asset types.
|
|
41
|
+
* @param {Asset} asset An Asset
|
|
42
|
+
* @returns {Record<string, string>} Asset Transform Mapping.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getAssetMapping(asset: Asset): Record<string, string>;
|
|
@@ -0,0 +1,271 @@
|
|
|
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.getAssetMapping = exports.getPropertyType = exports.generateStandard = exports.generateAddress = exports.transformAsset = exports.residentialTypeList = exports.propertyTypeNameList = void 0;
|
|
15
|
+
var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
16
|
+
var public_asset_1 = require("../types/events/public-asset");
|
|
17
|
+
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
18
|
+
var lodash_1 = require("lodash");
|
|
19
|
+
var get_financial_institution_1 = require("../utils/get-financial-institution");
|
|
20
|
+
var transform_percent_owned_1 = require("./transform-percent-owned");
|
|
21
|
+
var enum_mappings_1 = require("../types/enum-mappings");
|
|
22
|
+
var is_asset_type_1 = require("../utils/is-asset-type");
|
|
23
|
+
var lixi_internal_request_2 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
24
|
+
var logger_1 = require("../logger");
|
|
25
|
+
var address_tools_1 = require("../utils/address-tools");
|
|
26
|
+
exports.propertyTypeNameList = Object.values(lixi_internal_request_2.Custom2PropertyTypeNameList);
|
|
27
|
+
exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
|
|
28
|
+
/**
|
|
29
|
+
* Generates a partial internal request from a partial public asset event.
|
|
30
|
+
*
|
|
31
|
+
* @param {Payload} asset - A partial public asset.
|
|
32
|
+
* @return {PartialApplication} A partial InternalRequest.
|
|
33
|
+
*/
|
|
34
|
+
function transformAsset(_a) {
|
|
35
|
+
var asset = _a.asset, applicationId = _a.applicationId, id = _a.id;
|
|
36
|
+
var isPropertyAsset = (0, is_asset_type_1.isRealEstateAsset)(asset);
|
|
37
|
+
var idPath = isPropertyAsset ? application_paths_1.paths.RealEstateAsset + ".@UniqueID" : application_paths_1.paths.NonRealEstateAsset + ".@UniqueID";
|
|
38
|
+
var addressId = id + "-address";
|
|
39
|
+
var assetMapping = getAssetMapping(asset);
|
|
40
|
+
var partialApplication = {};
|
|
41
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
42
|
+
(0, lodash_1.set)(partialApplication, idPath, id);
|
|
43
|
+
if (isPropertyAsset) {
|
|
44
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@MultipleDwellings", lixi_internal_request_1.YesNoList.No);
|
|
45
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".@x_Address", addressId);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", enum_mappings_1.assetTypeMapping[asset.type]);
|
|
49
|
+
}
|
|
50
|
+
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
51
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
|
|
52
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.@Type", enum_mappings_1.financialAssetMapping[asset.type]);
|
|
53
|
+
}
|
|
54
|
+
if ((0, is_asset_type_1.isOtherAsset)(asset)) {
|
|
55
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
|
|
56
|
+
}
|
|
57
|
+
switch (asset.type) {
|
|
58
|
+
case public_asset_1.AssetType.Vehicle:
|
|
59
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".@Type", lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
|
|
60
|
+
break;
|
|
61
|
+
case public_asset_1.AssetType.HomeContents:
|
|
62
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Type", lixi_internal_request_1.OtherAssetTypeList.HomeContents);
|
|
63
|
+
break;
|
|
64
|
+
case public_asset_1.AssetType.Gifts:
|
|
65
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Description", asset.description || 'Asset Gifts');
|
|
66
|
+
break;
|
|
67
|
+
case public_asset_1.AssetType.OtherAsset:
|
|
68
|
+
if (asset.description) {
|
|
69
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.NonRealEstateAsset + ".OtherAsset.@Description", asset.description);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
for (var _i = 0, _b = Object.entries(asset); _i < _b.length; _i++) {
|
|
74
|
+
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
75
|
+
if (assetMapping[key]) {
|
|
76
|
+
switch (key) {
|
|
77
|
+
case 'contractDetails':
|
|
78
|
+
var contractDate = value.contractDate;
|
|
79
|
+
if (contractDate)
|
|
80
|
+
(0, lodash_1.set)(partialApplication, assetMapping.contractDate, contractDate);
|
|
81
|
+
break;
|
|
82
|
+
case 'primaryPurpose':
|
|
83
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.primaryPurposeMapping[value]);
|
|
84
|
+
break;
|
|
85
|
+
case 'toBePurchased':
|
|
86
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.toBePurchasedMapping[value]);
|
|
87
|
+
break;
|
|
88
|
+
case 'propertyStatus':
|
|
89
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
|
|
90
|
+
break;
|
|
91
|
+
case 'toBeUsedAsSecurity':
|
|
92
|
+
if (isPropertyAsset)
|
|
93
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.toBeUsedAsSecurityMapping[value]);
|
|
94
|
+
break;
|
|
95
|
+
case 'propertyType':
|
|
96
|
+
var propertyTypeMapping_1 = getPropertyType(value);
|
|
97
|
+
if (!propertyTypeMapping_1) {
|
|
98
|
+
logger_1.logger.warn({ message: "Unknown propertyType " + value + " for asset " + id, applicationId: applicationId });
|
|
99
|
+
}
|
|
100
|
+
var path = propertyTypeMapping_1.path, mappedValue = propertyTypeMapping_1.value;
|
|
101
|
+
(0, lodash_1.set)(partialApplication, path, mappedValue);
|
|
102
|
+
break;
|
|
103
|
+
case 'zoneType':
|
|
104
|
+
if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
|
|
105
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.RealEstateAsset + ".Commercial.@Type", lixi_internal_request_1.OtherAssetTypeList.Other);
|
|
106
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom6TypeList.Commercial);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom6TypeList.Residential);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case 'financialInstitution':
|
|
113
|
+
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
114
|
+
var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
|
|
115
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], financialInstitution);
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case 'year':
|
|
119
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], value.toString());
|
|
120
|
+
break;
|
|
121
|
+
case 'address':
|
|
122
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], generateAddress(value, addressId));
|
|
123
|
+
break;
|
|
124
|
+
case 'percentOwned':
|
|
125
|
+
var percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
|
|
126
|
+
if (percentOwned) {
|
|
127
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
(0, lodash_1.set)(partialApplication, assetMapping[key], value);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return partialApplication;
|
|
137
|
+
}
|
|
138
|
+
exports.transformAsset = transformAsset;
|
|
139
|
+
/**
|
|
140
|
+
* Generates an address for an asset.
|
|
141
|
+
*
|
|
142
|
+
* @param address: An address object.
|
|
143
|
+
* @param id: address event id.
|
|
144
|
+
* @param toBeUsedAsSecurity
|
|
145
|
+
* @return A transformed address object.
|
|
146
|
+
*/
|
|
147
|
+
function generateAddress(address, id) {
|
|
148
|
+
var transformedAddress = {
|
|
149
|
+
'@UniqueID': id
|
|
150
|
+
};
|
|
151
|
+
var addressMapping = {
|
|
152
|
+
city: '@Suburb',
|
|
153
|
+
country: '@Country',
|
|
154
|
+
postcode: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasPostCode' : '@AustralianPostCode',
|
|
155
|
+
state: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasState' : '@AustralianState',
|
|
156
|
+
standard: 'Standard',
|
|
157
|
+
formatted: '@Country'
|
|
158
|
+
};
|
|
159
|
+
for (var _i = 0, _a = Object.entries(address); _i < _a.length; _i++) {
|
|
160
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
161
|
+
if (addressMapping[key]) {
|
|
162
|
+
switch (key) {
|
|
163
|
+
case 'standard':
|
|
164
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], generateStandard(value));
|
|
165
|
+
break;
|
|
166
|
+
case 'country':
|
|
167
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], (0, address_tools_1.isOverseasAddress)(address) ? enum_mappings_1.countryCodeMapping[value] : lixi_internal_request_1.CountryCodeList.Au);
|
|
168
|
+
break;
|
|
169
|
+
case 'formatted':
|
|
170
|
+
if (!address.country) {
|
|
171
|
+
var country = (0, address_tools_1.extractCountryFromFormatted)(value);
|
|
172
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], enum_mappings_1.countryCodeMapping[country]);
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return transformedAddress;
|
|
182
|
+
}
|
|
183
|
+
exports.generateAddress = generateAddress;
|
|
184
|
+
/**
|
|
185
|
+
* @description Generates an address standard.
|
|
186
|
+
* @param {AddressStandard} addressStandard An address standard object.
|
|
187
|
+
* @return {Partial<Standard>} A transformed standard object.
|
|
188
|
+
*/
|
|
189
|
+
function generateStandard(addressStandard) {
|
|
190
|
+
var transformedStandard = {};
|
|
191
|
+
var standardMapping = {
|
|
192
|
+
streetName: '@StreetName',
|
|
193
|
+
streetType: '@StreetType',
|
|
194
|
+
streetNumber: '@StreetNumber',
|
|
195
|
+
level: '@Level',
|
|
196
|
+
unit: '@Unit'
|
|
197
|
+
};
|
|
198
|
+
for (var _i = 0, _a = Object.entries(addressStandard); _i < _a.length; _i++) {
|
|
199
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
200
|
+
if (standardMapping[key]) {
|
|
201
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], value);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return transformedStandard;
|
|
205
|
+
}
|
|
206
|
+
exports.generateStandard = generateStandard;
|
|
207
|
+
/**
|
|
208
|
+
* @description Map the propertyType to a RealEstateAsset path and the value.
|
|
209
|
+
* @param {PropertyType} propertyType - A propertyType.
|
|
210
|
+
* @returns {PropertyTypeMapping | null} A path and value to be used for property type mapping.
|
|
211
|
+
*/
|
|
212
|
+
function getPropertyType(propertyType) {
|
|
213
|
+
var value = enum_mappings_1.propertyTypeMapping[propertyType];
|
|
214
|
+
if (exports.residentialTypeList.includes(value)) {
|
|
215
|
+
return {
|
|
216
|
+
path: application_paths_1.paths.RealEstateAsset + ".Residential",
|
|
217
|
+
value: {
|
|
218
|
+
'@Type': value
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (exports.propertyTypeNameList.includes(value)) {
|
|
223
|
+
return {
|
|
224
|
+
path: application_paths_1.paths.RealEstateAsset + ".PropertyType",
|
|
225
|
+
value: {
|
|
226
|
+
'@PropertyTypeName': value,
|
|
227
|
+
'@CategoryTypeName': lixi_internal_request_2.Custom1CategoryTypeNameList.Residential
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
exports.getPropertyType = getPropertyType;
|
|
234
|
+
/**
|
|
235
|
+
* @description Get the asset transform mapping for various asset types.
|
|
236
|
+
* @param {Asset} asset An Asset
|
|
237
|
+
* @returns {Record<string, string>} Asset Transform Mapping.
|
|
238
|
+
*/
|
|
239
|
+
function getAssetMapping(asset) {
|
|
240
|
+
var estimatedValue = application_paths_1.paths.NonRealEstateAsset + ".EstimatedValue.@Value";
|
|
241
|
+
var percentOwned = application_paths_1.paths.NonRealEstateAsset + ".PercentOwned";
|
|
242
|
+
var baseMapping = {
|
|
243
|
+
estimatedValue: estimatedValue,
|
|
244
|
+
percentOwned: percentOwned
|
|
245
|
+
};
|
|
246
|
+
if ((0, is_asset_type_1.isRealEstateAsset)(asset)) {
|
|
247
|
+
estimatedValue = application_paths_1.paths.RealEstateAsset + ".EstimatedValue.@Value";
|
|
248
|
+
percentOwned = application_paths_1.paths.RealEstateAsset + ".PercentOwned";
|
|
249
|
+
return {
|
|
250
|
+
address: application_paths_1.paths.Address,
|
|
251
|
+
contractDetails: 'contractDetails',
|
|
252
|
+
contractDate: application_paths_1.paths.RealEstateAsset + ".ContractDetails.@ContractDate",
|
|
253
|
+
estimatedValue: estimatedValue,
|
|
254
|
+
percentOwned: percentOwned,
|
|
255
|
+
primaryPurpose: application_paths_1.paths.RealEstateAsset + ".@PrimaryPurpose",
|
|
256
|
+
propertyStatus: application_paths_1.paths.RealEstateAsset + ".@Status",
|
|
257
|
+
propertyType: application_paths_1.paths.RealEstateAsset + ".Residential",
|
|
258
|
+
toBePurchased: application_paths_1.paths.RealEstateAsset + ".@Transaction",
|
|
259
|
+
toBeUsedAsSecurity: application_paths_1.paths.RealEstateAsset + ".@ToBeUsedAsSecurity",
|
|
260
|
+
zoneType: application_paths_1.paths.RealEstateAsset + ".Zoning.@Type"
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
if ((0, is_asset_type_1.isMotorVehicle)(asset)) {
|
|
264
|
+
return __assign(__assign({}, baseMapping), { make: application_paths_1.paths.NonRealEstateAsset + ".MotorVehicle.@Make", model: application_paths_1.paths.NonRealEstateAsset + ".MotorVehicle.@Model", year: application_paths_1.paths.NonRealEstateAsset + ".MotorVehicle.@Year" });
|
|
265
|
+
}
|
|
266
|
+
if ((0, is_asset_type_1.isFinancialAsset)(asset)) {
|
|
267
|
+
return __assign(__assign({}, baseMapping), { financialInstitution: application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.AccountNumber.@FinancialInstitution", financialInstitutionAccountNumber: application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.AccountNumber.@AccountNumber", financialInstitutionBsb: application_paths_1.paths.NonRealEstateAsset + ".FinancialAsset.AccountNumber.@BSB" });
|
|
268
|
+
}
|
|
269
|
+
return baseMapping;
|
|
270
|
+
}
|
|
271
|
+
exports.getAssetMapping = getAssetMapping;
|
|
@@ -14,8 +14,7 @@ exports.__esModule = true;
|
|
|
14
14
|
exports.isLivingExpenseEstimate = exports.isOtherCommitment = exports.normaliseExpenseAmount = exports.transformExpense = exports.transformExpenses = exports.otherCommitmentExpenseTypes = void 0;
|
|
15
15
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
16
16
|
var lodash_1 = require("lodash");
|
|
17
|
-
var
|
|
18
|
-
var living_expense_1 = require("../types/enum-mappings/living-expense");
|
|
17
|
+
var enum_mappings_1 = require("../types/enum-mappings/");
|
|
19
18
|
var public_expense_1 = require("../types/events/public-expense");
|
|
20
19
|
exports.otherCommitmentExpenseTypes = [
|
|
21
20
|
public_expense_1.ExpenseType.Board,
|
|
@@ -52,8 +51,8 @@ function transformExpenses(expense) {
|
|
|
52
51
|
}
|
|
53
52
|
var lixiCommitmentExpenses = otherCommitments.map(function (expense, index) { return transformExpense(expense, applicantId, index, id); });
|
|
54
53
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
55
|
-
(0, lodash_1.set)(partialApplication,
|
|
56
|
-
(0, lodash_1.set)(partialApplication,
|
|
54
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Household + ".@UniqueID", applicationId + "-household");
|
|
55
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.PersonApplicant + ".@UniqueID", applicantId);
|
|
57
56
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.OtherCommitments, lixiCommitmentExpenses);
|
|
58
57
|
if (lixiLivingExpenses.length > 0) {
|
|
59
58
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.LivingExpenses, lixiLivingExpenses);
|
|
@@ -72,10 +71,10 @@ exports.transformExpenses = transformExpenses;
|
|
|
72
71
|
function transformExpense(expense, applicantId, index, id) {
|
|
73
72
|
return {
|
|
74
73
|
'@Amount': expense.amount,
|
|
75
|
-
'@Category':
|
|
74
|
+
'@Category': enum_mappings_1.livingExpenseMapping[expense.type],
|
|
76
75
|
'@Description': expense.type,
|
|
77
|
-
'@UniqueID': isOtherCommitment(expense) ?
|
|
78
|
-
'@Frequency':
|
|
76
|
+
'@UniqueID': isOtherCommitment(expense) ? id + "-commitment-" + index : id + "-living-expense-" + index,
|
|
77
|
+
'@Frequency': enum_mappings_1.frequencyMapping[expense.frequency],
|
|
79
78
|
PercentResponsible: {
|
|
80
79
|
Owner: [
|
|
81
80
|
{
|
|
@@ -15,7 +15,7 @@ export declare function getIncomeMapping(incomeType: IncomeType): Record<string,
|
|
|
15
15
|
* @param applicantId PersonApplicant uniqueId on the application.
|
|
16
16
|
* @return partialApplication an incomplete application.
|
|
17
17
|
*/
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function transformIncome(payload: IncomePayload, applicantId?: string): PartialApplication;
|
|
19
19
|
/**
|
|
20
20
|
* Creates Rental Income array.
|
|
21
21
|
* @param amount Amount
|