@lendi/integrations-transform 1.1.5 → 1.1.6

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.
@@ -36,7 +36,7 @@ var assetMapping = {
36
36
  address: application_paths_1.paths.Address
37
37
  };
38
38
  exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
39
- exports.propertyTypeNameList = Object.values(lixi_internal_request_1.Custom3PropertyTypeNameList);
39
+ exports.propertyTypeNameList = Object.values(lixi_internal_request_1.Custom2PropertyTypeNameList);
40
40
  /**
41
41
  * Generates a partial internal request from a partial public asset event.
42
42
  *
@@ -119,7 +119,7 @@ function generateAsset(_a) {
119
119
  }
120
120
  else if (exports.propertyTypeNameList.includes(mappedValue)) {
121
121
  (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@PropertyTypeName"), mappedValue);
122
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@CategoryTypeName"), lixi_internal_request_1.Custom2CategoryTypeNameList.Residential);
122
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@CategoryTypeName"), lixi_internal_request_1.Custom1CategoryTypeNameList.Residential);
123
123
  }
124
124
  else {
125
125
  logger_1.logger.warn({ message: "Unknown propertyType ".concat(value, " for asset ").concat(id), applicationId: applicationId });
@@ -128,10 +128,10 @@ function generateAsset(_a) {
128
128
  case 'zoneType':
129
129
  if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
130
130
  (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Commercial.@Type"), lixi_internal_request_1.OtherAssetTypeList.Other);
131
- (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Commercial);
131
+ (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom3TypeList.Commercial);
132
132
  }
133
133
  else {
134
- (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom4TypeList.Residential);
134
+ (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom3TypeList.Residential);
135
135
  }
136
136
  break;
137
137
  case 'financialInstitution':
@@ -1,6 +1,6 @@
1
- import { IncomeElement } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
1
+ import { IncomeBusinessActivityStatement, IncomeElement } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
2
2
  import { RentalIncome } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
3
- import { Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
3
+ import { BASDefinition, Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
4
4
  import { PartialApplication } from '../types/partial-application';
5
5
  export interface AmountFrequency {
6
6
  amount: string;
@@ -12,7 +12,7 @@ export declare function getIncomeMapping(incomeType: IncomeType): Record<string,
12
12
  * Generates an partial application from a partial income event.
13
13
  *
14
14
  * @param payload a partial income event.
15
- * @param storedApplication: Current state of the application.
15
+ * @param applicantId PersonApplicant uniqueId on the application.
16
16
  * @return partialApplication an incomplete application.
17
17
  */
18
18
  export declare function generateIncome(payload: IncomePayload, applicantId?: string): PartialApplication;
@@ -35,3 +35,7 @@ export interface SelfEmploymentIncomeMapping {
35
35
  * @returns {IncomeElement} LIXI Income for the Self Employed.
36
36
  */
37
37
  export declare function generateIncomeBusinessDetails(data: IncomeBusinessDetails): IncomeElement;
38
+ /**
39
+ * Generates the BAS array from the bas definition on the event.
40
+ */
41
+ export declare function generateBAS(bas: BASDefinition[]): IncomeBusinessActivityStatement[];
@@ -23,7 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  };
24
24
  var _a;
25
25
  exports.__esModule = true;
26
- exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
26
+ exports.generateBAS = exports.generateIncomeBusinessDetails = exports.createRentalIncome = exports.generateIncome = exports.getIncomeMapping = exports.EmploymentIncomeTypeMapping = void 0;
27
27
  var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
28
28
  var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
29
29
  var lodash_1 = require("lodash");
@@ -83,6 +83,7 @@ function getIncomeMapping(incomeType) {
83
83
  if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
84
84
  basePath = application_paths_1.paths.CompanyApplicant;
85
85
  return {
86
+ bas: "".concat(basePath, ".Income[0].BusinessActivityStatement"),
86
87
  companyId: "".concat(basePath, ".@UniqueID"),
87
88
  incomes: "".concat(basePath, ".Income"),
88
89
  gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
@@ -114,7 +115,7 @@ exports.getIncomeMapping = getIncomeMapping;
114
115
  * Generates an partial application from a partial income event.
115
116
  *
116
117
  * @param payload a partial income event.
117
- * @param storedApplication: Current state of the application.
118
+ * @param applicantId PersonApplicant uniqueId on the application.
118
119
  * @return partialApplication an incomplete application.
119
120
  */
120
121
  function generateIncome(payload, applicantId) {
@@ -137,6 +138,11 @@ function generateIncome(payload, applicantId) {
137
138
  var amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
138
139
  (0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
139
140
  break;
141
+ case 'bas':
142
+ var basWithAmount = value.filter(function (bas) { return bas.salesAmount !== undefined || false; });
143
+ if (!(0, lodash_1.isEmpty)(basWithAmount))
144
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], generateBAS(basWithAmount));
145
+ break;
140
146
  case 'frequency':
141
147
  (0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
142
148
  break;
@@ -229,13 +235,16 @@ function generateIncomeBusinessDetails(data) {
229
235
  var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
230
236
  for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
231
237
  var _b = _a[_i], key = _b[0], value = _b[1];
232
- if (selfEmploymentIncomeMapping[key] != null) {
238
+ if (selfEmploymentIncomeMapping[key] !== null) {
233
239
  if (key === 'addback') {
234
240
  for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
235
241
  var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
236
242
  (0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
237
243
  }
238
244
  }
245
+ else if (key === 'year') {
246
+ (0, lodash_1.set)(income, dateAndIncomeMapping[key], value.toString());
247
+ }
239
248
  else {
240
249
  (0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
241
250
  }
@@ -244,3 +253,13 @@ function generateIncomeBusinessDetails(data) {
244
253
  return income;
245
254
  }
246
255
  exports.generateIncomeBusinessDetails = generateIncomeBusinessDetails;
256
+ /**
257
+ * Generates the BAS array from the bas definition on the event.
258
+ */
259
+ function generateBAS(bas) {
260
+ return bas.map(function (bas) { return ({
261
+ '@Quarter': bas.quarter,
262
+ '@SalesAmount': bas.salesAmount
263
+ }); });
264
+ }
265
+ exports.generateBAS = generateBAS;
@@ -1,4 +1,4 @@
1
- import { FeeCategoryList, FeeTypeList, Custom5DescriptionList as DescriptionList, ContributionFundsTypeList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
1
+ import { FeeCategoryList, FeeTypeList, Custom4DescriptionList as DescriptionList, ContributionFundsTypeList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
2
  declare type CategoryMapping = {
3
3
  [key: string]: FeeCategoryList;
4
4
  };
@@ -25,8 +25,8 @@ exports.typeMapping = {
25
25
  foreignBuyerSurcharge: lixi_internal_request_1.FeeTypeList.Other
26
26
  };
27
27
  exports.descriptionMapping = {
28
- accruedInterest: lixi_internal_request_1.Custom5DescriptionList.PotentialAccruedInterest,
29
- otherSundries: lixi_internal_request_1.Custom5DescriptionList.OtherSundries
28
+ accruedInterest: lixi_internal_request_1.Custom4DescriptionList.PotentialAccruedInterest,
29
+ otherSundries: lixi_internal_request_1.Custom4DescriptionList.OtherSundries
30
30
  };
31
31
  exports.contributionMapping = {
32
32
  totalGovernmentContributions: lixi_internal_request_1.ContributionFundsTypeList.FirstHomeOwnerGrant,
@@ -1,7 +1,7 @@
1
- import { OtherIncomeTypeList, Custom1DescriptionList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
1
+ import { OtherIncomeTypeList, Custom0DescriptionList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
2
  import { IncomeType } from '../events/public-income';
3
3
  declare type OtherIncomeMapping = {
4
- [key in IncomeType]: OtherIncomeTypeList | Custom1DescriptionList;
4
+ [key in IncomeType]: OtherIncomeTypeList | Custom0DescriptionList;
5
5
  };
6
6
  export declare const otherIncomeMapping: Partial<OtherIncomeMapping>;
7
7
  export {};
@@ -8,9 +8,9 @@ exports.otherIncomeMapping = (_a = {},
8
8
  _a[public_income_1.IncomeType.ChildMaintenance] = lixi_internal_request_1.OtherIncomeTypeList.ChildMaintenance,
9
9
  _a[public_income_1.IncomeType.ForeignIncome] = lixi_internal_request_1.OtherIncomeTypeList.ForeignSourced,
10
10
  _a[public_income_1.IncomeType.GovtBenefit] = lixi_internal_request_1.OtherIncomeTypeList.GovernmentBenefits,
11
- _a[public_income_1.IncomeType.InvestmentIncome] = lixi_internal_request_1.Custom1DescriptionList.InvestmentIncome,
11
+ _a[public_income_1.IncomeType.InvestmentIncome] = lixi_internal_request_1.Custom0DescriptionList.InvestmentIncome,
12
12
  _a[public_income_1.IncomeType.OtherIncome] = lixi_internal_request_1.OtherIncomeTypeList.OtherIncome,
13
- _a[public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax] = lixi_internal_request_1.Custom1DescriptionList.PAYGNonVoluntaryDeductionsPreTax,
13
+ _a[public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax] = lixi_internal_request_1.Custom0DescriptionList.PAYGNonVoluntaryDeductionsPreTax,
14
14
  _a[public_income_1.IncomeType.PaygSalarySacrifice] = lixi_internal_request_1.OtherIncomeTypeList.SalarySacrificeContribution,
15
15
  _a[public_income_1.IncomeType.SuperAnnuityPension] = lixi_internal_request_1.OtherIncomeTypeList.Superannuation,
16
16
  _a[public_income_1.IncomeType.WorkersCompensation] = lixi_internal_request_1.OtherIncomeTypeList.WorkersCompensation,
@@ -1,7 +1,7 @@
1
1
  import { PropertyType } from '../events/public-asset';
2
- import { ResidentialTypeList, Custom3PropertyTypeNameList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { ResidentialTypeList, Custom2PropertyTypeNameList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
3
3
  declare type PropertyTypeMapping = {
4
- [key in PropertyType]: ResidentialTypeList | Custom3PropertyTypeNameList;
4
+ [key in PropertyType]: ResidentialTypeList | Custom2PropertyTypeNameList;
5
5
  };
6
6
  export declare const propertyTypeMapping: PropertyTypeMapping;
7
7
  export {};
@@ -19,6 +19,6 @@ exports.propertyTypeMapping = (_a = {},
19
19
  _a[public_asset_1.PropertyType.Townhouse] = lixi_internal_request_1.ResidentialTypeList.Townhouse,
20
20
  _a[public_asset_1.PropertyType.Villa] = lixi_internal_request_1.ResidentialTypeList.Villa,
21
21
  _a[public_asset_1.PropertyType.WarehouseApartment] = lixi_internal_request_1.ResidentialTypeList.StudioWarehouseApartment,
22
- _a[public_asset_1.PropertyType.PropertyOver10_Ha] = lixi_internal_request_1.Custom3PropertyTypeNameList.PropertyOver10HA,
23
- _a[public_asset_1.PropertyType.MultiDwellingSingleTitle] = lixi_internal_request_1.Custom3PropertyTypeNameList.MultiDwellingSingleTitle,
22
+ _a[public_asset_1.PropertyType.PropertyOver10_Ha] = lixi_internal_request_1.Custom2PropertyTypeNameList.PropertyOver10HA,
23
+ _a[public_asset_1.PropertyType.MultiDwellingSingleTitle] = lixi_internal_request_1.Custom2PropertyTypeNameList.MultiDwellingSingleTitle,
24
24
  _a);
@@ -39,22 +39,22 @@ export declare function isOtherIncomeWithDesc(incomeType: string): boolean;
39
39
  * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
40
40
  */
41
41
  export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
42
- declare type EmploymentTypes = 'PAYG' | 'SelfEmployed' | 'NotEmployed';
43
42
  /**
44
- * @description Get the employment ids for an applicant for a specific employment type.
45
- * @param {PersonApplicant} applicant An applicant
46
- * @param {string} key Employment type key: PAYG or SelfEmployed.
47
- * @returns {string[]} An array of employment ids for the applicant of the specified type.
43
+ * Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
44
+ *
45
+ * @param {PersonApplicant} applicant - An applicant
46
+ * @param {string} employmentId - Employment id being searched for
47
+ * @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
48
48
  */
49
- export declare function getEmploymentIds(applicant: PersonApplicant, key: EmploymentTypes): string[];
49
+ export declare const hasMatchingEmploymentId: (applicant: PersonApplicant, employmentId: string) => boolean;
50
50
  /**
51
- * @description Get applicantId from an array of applicants given an employmentId and employmentType.
52
- * @param {PersonApplicant[]} applicants An array of applicants.
53
- * @param {string} employmentId EmploymentId
54
- * @param {string} key Employment type: PAYG or SelfEmployed
55
- * @returns {string | undefined} Returns applicantId or undefined.
51
+ * Gets the applicant id using the employment id
52
+ *
53
+ * @param {PersonApplicant[]} applicants - An array of applicants.
54
+ * @param {string} employmentId - Employment ID
55
+ * @returns {string | undefined} - Applicant id or undefined
56
56
  */
57
- export declare function getStoredApplicantId(applicants: PersonApplicant[], employmentId: string, key: EmploymentTypes): string | undefined;
57
+ export declare function getApplicantIdFromEmploymentId(applicants: PersonApplicant[], employmentId: string): string | undefined;
58
58
  /**
59
59
  * @description Get an applicantId from the event or the applicants.
60
60
  * @param {Income} income Income.
@@ -69,4 +69,3 @@ export declare function getApplicantId({ percentOwned, employmentId }: Income, a
69
69
  * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
70
70
  */
71
71
  export declare const sortBusinessIncome: ({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails) => number;
72
- export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.sortBusinessIncome = exports.getApplicantId = exports.getStoredApplicantId = exports.getEmploymentIds = exports.isFullDocOrLowDocIncome = exports.isOtherIncomeWithDesc = exports.isOtherIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.otherIncomeList = exports.PAYGList = exports.descriptionOtherIncomeTypes = void 0;
3
+ exports.sortBusinessIncome = exports.getApplicantId = exports.getApplicantIdFromEmploymentId = exports.hasMatchingEmploymentId = exports.isFullDocOrLowDocIncome = exports.isOtherIncomeWithDesc = exports.isOtherIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.otherIncomeList = exports.PAYGList = exports.descriptionOtherIncomeTypes = void 0;
4
4
  var lodash_1 = require("lodash");
5
5
  var public_income_1 = require("../types/events/public-income");
6
6
  exports.descriptionOtherIncomeTypes = [
@@ -83,32 +83,37 @@ function isFullDocOrLowDocIncome(incomeType) {
83
83
  }
84
84
  exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
85
85
  /**
86
- * @description Get the employment ids for an applicant for a specific employment type.
87
- * @param {PersonApplicant} applicant An applicant
88
- * @param {string} key Employment type key: PAYG or SelfEmployed.
89
- * @returns {string[]} An array of employment ids for the applicant of the specified type.
86
+ * Checks if there is some employment for the applicant that has the same employment id as the employment id in the income event
87
+ *
88
+ * @param {PersonApplicant} applicant - An applicant
89
+ * @param {string} employmentId - Employment id being searched for
90
+ * @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
90
91
  */
91
- function getEmploymentIds(applicant, key) {
92
- return (0, lodash_1.compact)(applicant.Employment.flatMap(function (employment) { return (0, lodash_1.get)(employment, "".concat(key, ".@UniqueID")); }));
93
- }
94
- exports.getEmploymentIds = getEmploymentIds;
92
+ var hasMatchingEmploymentId = function (applicant, employmentId) {
93
+ return (applicant.Employment || []).some(function (employment) {
94
+ var id = (0, lodash_1.get)(employment, 'PAYG.@UniqueID') ||
95
+ (0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') ||
96
+ (0, lodash_1.get)(employment, 'NotEmployed.@UniqueID');
97
+ return id === employmentId;
98
+ });
99
+ };
100
+ exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
95
101
  /**
96
- * @description Get applicantId from an array of applicants given an employmentId and employmentType.
97
- * @param {PersonApplicant[]} applicants An array of applicants.
98
- * @param {string} employmentId EmploymentId
99
- * @param {string} key Employment type: PAYG or SelfEmployed
100
- * @returns {string | undefined} Returns applicantId or undefined.
102
+ * Gets the applicant id using the employment id
103
+ *
104
+ * @param {PersonApplicant[]} applicants - An array of applicants.
105
+ * @param {string} employmentId - Employment ID
106
+ * @returns {string | undefined} - Applicant id or undefined
101
107
  */
102
- function getStoredApplicantId(applicants, employmentId, key) {
103
- for (var _i = 0, applicants_1 = applicants; _i < applicants_1.length; _i++) {
104
- var applicant = applicants_1[_i];
105
- var employmentIds = getEmploymentIds(applicant, key);
106
- if (employmentIds.includes(employmentId))
107
- return applicant['@UniqueID'];
108
+ function getApplicantIdFromEmploymentId(applicants, employmentId) {
109
+ var applicantId;
110
+ if (applicants && employmentId) {
111
+ var applicant = applicants.find(function (applicant) { return (0, exports.hasMatchingEmploymentId)(applicant, employmentId); });
112
+ applicantId = applicant === null || applicant === void 0 ? void 0 : applicant['@UniqueID'];
108
113
  }
109
- return undefined;
114
+ return applicantId;
110
115
  }
111
- exports.getStoredApplicantId = getStoredApplicantId;
116
+ exports.getApplicantIdFromEmploymentId = getApplicantIdFromEmploymentId;
112
117
  /**
113
118
  * @description Get an applicantId from the event or the applicants.
114
119
  * @param {Income} income Income.
@@ -118,10 +123,7 @@ exports.getStoredApplicantId = getStoredApplicantId;
118
123
  function getApplicantId(_a, applicants) {
119
124
  var percentOwned = _a.percentOwned, employmentId = _a.employmentId;
120
125
  if (applicants === void 0) { applicants = []; }
121
- return ((0, lodash_1.get)(percentOwned, 'owners[0].applicantId') ||
122
- getStoredApplicantId(applicants, employmentId, 'PAYG') ||
123
- getStoredApplicantId(applicants, employmentId, 'SelfEmployed') ||
124
- getStoredApplicantId(applicants, employmentId, 'NotEmployed'));
126
+ return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
125
127
  }
126
128
  exports.getApplicantId = getApplicantId;
127
129
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Library for kafka event data transforming",
5
5
  "author": "Integrations <integrations@lendi.com.au>",
6
6
  "homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
@@ -21,8 +21,8 @@
21
21
  "url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
22
22
  },
23
23
  "dependencies": {
24
- "@lendi/integrations-credit-protocol": "1.14.4",
25
- "@lendi/integrations-protocol": "2.3.0",
24
+ "@lendi/integrations-credit-protocol": "1.14.7",
25
+ "@lendi/integrations-protocol": "2.4.9",
26
26
  "clean-deep": "^3.4.0",
27
27
  "date-fns": "2.19.0",
28
28
  "dd-trace": "^0.28.1",