@lendi/integrations-transform 1.1.1 → 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,21 +1,21 @@
1
+ import { IncomeBusinessActivityStatement, IncomeElement } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
1
2
  import { RentalIncome } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
3
+ import { BASDefinition, Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
2
4
  import { PartialApplication } from '../types/partial-application';
3
- import { Frequency, IncomeBusinessDetails, IncomeDefinition as IncomePayload, IncomeType, Ownership } from '../types/events/public-income';
4
- import { IncomeRecent } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
5
5
  export interface AmountFrequency {
6
6
  amount: string;
7
7
  frequency?: string;
8
8
  }
9
9
  export declare const EmploymentIncomeTypeMapping: Record<string, AmountFrequency>;
10
- export declare function getIncomeMapping(incomeType: IncomeType, basePath?: string): Record<string, string>;
10
+ export declare function getIncomeMapping(incomeType: IncomeType): Record<string, string>;
11
11
  /**
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
- export declare function generateIncome(payload: IncomePayload, storedApplication: PartialApplication): PartialApplication;
18
+ export declare function generateIncome(payload: IncomePayload, applicantId?: string): PartialApplication;
19
19
  /**
20
20
  * Creates Rental Income array.
21
21
  * @param amount Amount
@@ -32,6 +32,10 @@ export interface SelfEmploymentIncomeMapping {
32
32
  /**
33
33
  * @description Transform a Self Employed Income Details to LIXI
34
34
  * @param data Financial Year Income Details for Self Employed Income.
35
- * @returns {IncomeRecent} LIXI Income for the Self Employed.
35
+ * @returns {IncomeElement} LIXI Income for the Self Employed.
36
36
  */
37
- export declare function generateIncomeBusinessDetails(data: IncomeBusinessDetails): IncomeRecent;
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[];
@@ -1,4 +1,15 @@
1
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
+ };
2
13
  var __rest = (this && this.__rest) || function (s, e) {
3
14
  var t = {};
4
15
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -12,17 +23,17 @@ var __rest = (this && this.__rest) || function (s, e) {
12
23
  };
13
24
  var _a;
14
25
  exports.__esModule = true;
15
- 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;
16
27
  var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
17
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
28
+ var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
18
29
  var lodash_1 = require("lodash");
19
30
  var alieo_frequency_1 = require("../types/enum-mappings/alieo-frequency");
20
31
  var government_benefits_1 = require("../types/enum-mappings/government-benefits");
21
32
  var income_type_1 = require("../types/enum-mappings/income-type");
22
33
  var public_income_1 = require("../types/events/public-income");
34
+ var is_income_type_1 = require("../utils/is-income-type");
23
35
  var round_decimal_1 = require("../utils/round-decimal");
24
36
  var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
25
- var is_income_type_1 = require("../utils/is-income-type");
26
37
  var netWorkAllowanceAmount = 'Income.@NetWorkAllowanceAmount';
27
38
  var netWorkAllowanceFrequency = 'Income.@NetWorkAllowanceFrequency';
28
39
  // Income types mapping from internal to LIXI types /paths.
@@ -59,37 +70,37 @@ exports.EmploymentIncomeTypeMapping = (_a = {},
59
70
  amount: 'Income.@GrossRegularOvertimeAmount',
60
71
  frequency: 'Income.@GrossRegularOvertimeFrequency'
61
72
  },
62
- _a[public_income_1.IncomeType.SelfEmployedBusinessIncome] = {
63
- amount: 'BusinessIncomeRecent.@ProfitBeforeTax'
64
- },
65
73
  _a);
66
- function getIncomeMapping(incomeType, basePath) {
67
- if (basePath === void 0) { basePath = application_paths_1.paths.PAYG; }
74
+ function getIncomeMapping(incomeType) {
75
+ var basePath = application_paths_1.paths.OtherIncome;
68
76
  if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
77
+ basePath = application_paths_1.paths.RealEstateAsset;
69
78
  return {
70
79
  assetId: "".concat(basePath, ".@UniqueID"),
71
80
  percentOwned: "".concat(basePath, ".RentalIncome")
72
81
  };
73
82
  }
74
83
  if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
84
+ basePath = application_paths_1.paths.CompanyApplicant;
75
85
  return {
76
- incomes: "".concat(basePath, ".IncomeRecent"),
86
+ bas: "".concat(basePath, ".Income[0].BusinessActivityStatement"),
77
87
  companyId: "".concat(basePath, ".@UniqueID"),
78
- incomeRecent: "".concat(basePath, ".IncomeRecent"),
79
- incomePrevious: "".concat(basePath, ".IncomePrevious"),
88
+ incomes: "".concat(basePath, ".Income"),
80
89
  gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
81
90
  };
82
91
  }
83
- if ((0, is_income_type_1.isPaygIncome)(incomeType) || (0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
84
- var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
85
- var mapping = {
92
+ if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
93
+ basePath = application_paths_1.paths.SelfEmployed;
94
+ var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
95
+ return {
86
96
  amount: "".concat(basePath, ".").concat(amount),
87
97
  employmentId: "".concat(basePath, ".@UniqueID")
88
98
  };
89
- if (frequency) {
90
- mapping.frequency = "".concat(basePath, ".").concat(frequency);
91
- }
92
- return mapping;
99
+ }
100
+ if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
101
+ basePath = application_paths_1.paths.PAYG;
102
+ var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
103
+ return __assign({ amount: "".concat(basePath, ".").concat(amount), employmentId: "".concat(basePath, ".@UniqueID") }, (frequency && { frequency: "".concat(basePath, ".").concat(frequency) }));
93
104
  }
94
105
  return {
95
106
  amount: "".concat(basePath, ".@Amount"),
@@ -104,39 +115,21 @@ exports.getIncomeMapping = getIncomeMapping;
104
115
  * Generates an partial application from a partial income event.
105
116
  *
106
117
  * @param payload a partial income event.
107
- * @param storedApplication: Current state of the application.
118
+ * @param applicantId PersonApplicant uniqueId on the application.
108
119
  * @return partialApplication an incomplete application.
109
120
  */
110
- function generateIncome(payload, storedApplication) {
121
+ function generateIncome(payload, applicantId) {
111
122
  var applicationId = payload.applicationId, id = payload.id, income = payload.income;
112
123
  var incomeAmount = income.amount, incomeType = income.type, incomeFrequency = income.frequency;
113
124
  var partialApplication = {};
114
125
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
115
- if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
116
- var applicants = (0, lodash_1.get)(storedApplication, application_paths_1.paths.PersonApplicants);
117
- var applicantId = (0, is_income_type_1.getApplicantId)(income, applicants);
118
- if (applicantId) {
119
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
120
- }
121
- }
122
- var incomeMapping;
123
- if ((0, is_income_type_1.isRentalIncome)(incomeType)) {
124
- incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.RealEstateAsset);
125
- }
126
- else if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
127
- incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.PAYG);
128
- }
129
- else if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
130
- incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.SelfEmployed);
131
- }
132
- else if ((0, is_income_type_1.isFullDocOrLowDocIncome)(incomeType)) {
133
- var basePath = 'Package.Content.Application.CompanyApplicant[0]';
134
- incomeMapping = getIncomeMapping(incomeType, basePath);
126
+ if (!(0, is_income_type_1.isRentalIncome)(incomeType) && applicantId) {
127
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
135
128
  }
136
- else {
129
+ if ((0, is_income_type_1.isOtherIncome)(incomeType)) {
137
130
  (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@UniqueID"), id);
138
- incomeMapping = getIncomeMapping(incomeType, application_paths_1.paths.OtherIncome);
139
131
  }
132
+ var incomeMapping = getIncomeMapping(incomeType);
140
133
  for (var _i = 0, _a = Object.entries(income); _i < _a.length; _i++) {
141
134
  var _b = _a[_i], key = _b[0], value = _b[1];
142
135
  if (incomeMapping[key]) {
@@ -145,6 +138,11 @@ function generateIncome(payload, storedApplication) {
145
138
  var amount = incomeFrequency === public_income_1.Frequency.Quarterly ? value * 4 : value;
146
139
  (0, lodash_1.set)(partialApplication, incomeMapping[key], (0, round_decimal_1.roundDecimal)(amount));
147
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;
148
146
  case 'frequency':
149
147
  (0, lodash_1.set)(partialApplication, incomeMapping[key], alieo_frequency_1.incomeExpenseFrequencyMapping[value]);
150
148
  break;
@@ -161,7 +159,7 @@ function generateIncome(payload, storedApplication) {
161
159
  case 'type':
162
160
  if (!(0, is_income_type_1.isRentalIncome)(incomeType)) {
163
161
  var mappedType = income_type_1.otherIncomeMapping[value];
164
- if ((0, is_income_type_1.isOtherIncome)(value)) {
162
+ if ((0, is_income_type_1.isOtherIncomeWithDesc)(value)) {
165
163
  (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.OtherIncome, ".@Description"), mappedType);
166
164
  (0, lodash_1.set)(partialApplication, incomeMapping[key], lixi_internal_request_1.OtherIncomeTypeList.OtherIncome);
167
165
  }
@@ -177,7 +175,7 @@ function generateIncome(payload, storedApplication) {
177
175
  var sortedIncomeList = value
178
176
  .sort(is_income_type_1.sortBusinessIncome)
179
177
  .map(generateIncomeBusinessDetails);
180
- (0, lodash_1.set)(partialApplication, 'Package.Content.Application.CompanyApplicant[0].Income', sortedIncomeList);
178
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], sortedIncomeList);
181
179
  break;
182
180
  default:
183
181
  (0, lodash_1.set)(partialApplication, incomeMapping[key], value);
@@ -230,20 +228,23 @@ var selfEmploymentIncomeMapping = {
230
228
  /**
231
229
  * @description Transform a Self Employed Income Details to LIXI
232
230
  * @param data Financial Year Income Details for Self Employed Income.
233
- * @returns {IncomeRecent} LIXI Income for the Self Employed.
231
+ * @returns {IncomeElement} LIXI Income for the Self Employed.
234
232
  */
235
233
  function generateIncomeBusinessDetails(data) {
236
234
  var income = {};
237
235
  var addbackMapping = selfEmploymentIncomeMapping.addback, dateAndIncomeMapping = __rest(selfEmploymentIncomeMapping, ["addback"]);
238
236
  for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
239
237
  var _b = _a[_i], key = _b[0], value = _b[1];
240
- if (selfEmploymentIncomeMapping[key] != null) {
238
+ if (selfEmploymentIncomeMapping[key] !== null) {
241
239
  if (key === 'addback') {
242
240
  for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
243
241
  var _e = _d[_c], addbackKey = _e[0], addbackValue = _e[1];
244
242
  (0, lodash_1.set)(income, addbackMapping[addbackKey], addbackValue);
245
243
  }
246
244
  }
245
+ else if (key === 'year') {
246
+ (0, lodash_1.set)(income, dateAndIncomeMapping[key], value.toString());
247
+ }
247
248
  else {
248
249
  (0, lodash_1.set)(income, dateAndIncomeMapping[key], value);
249
250
  }
@@ -252,3 +253,13 @@ function generateIncomeBusinessDetails(data) {
252
253
  return income;
253
254
  }
254
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);
@@ -2,6 +2,7 @@ import { PersonApplicant } from '@lendi/integrations-protocol/lib/types/lixi-int
2
2
  import { IncomeType, Income, IncomeBusinessDetails } from '../types/events/public-income';
3
3
  export declare const descriptionOtherIncomeTypes: string[];
4
4
  export declare const PAYGList: string[];
5
+ export declare const otherIncomeList: IncomeType[];
5
6
  /**
6
7
  * @description Is income type one of the PAYG income.
7
8
  * @param {string} incomeType Income type.
@@ -20,12 +21,18 @@ export declare function isSelfEmployedIncome(incomeType: string): boolean;
20
21
  * @returns {boolean} true if Income type is Rental Income.
21
22
  */
22
23
  export declare function isRentalIncome(incomeType: string): boolean;
24
+ /**
25
+ * @description Is income type grouped as OtherIncome.
26
+ * @param {IncomeType} incomeType Income type.
27
+ * @returns {boolean} true if income is of type other income.
28
+ */
29
+ export declare function isOtherIncome(incomeType: IncomeType): boolean;
23
30
  /**
24
31
  * @description Is Income type one of OtherIncome types.
25
32
  * @param {IncomeType} incomeType Income Type.
26
33
  * @returns {boolean} returns true for other income.
27
34
  */
28
- export declare function isOtherIncome(incomeType: string): boolean;
35
+ export declare function isOtherIncomeWithDesc(incomeType: string): boolean;
29
36
  /**
30
37
  * @description Is Self Employed Full Doc or Low Doc Income
31
38
  * @param incomeType Income Type from Event
@@ -33,40 +40,21 @@ export declare function isOtherIncome(incomeType: string): boolean;
33
40
  */
34
41
  export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
35
42
  /**
36
- * @description Checks if an Income event is a valid rental income event.
37
- * @param {Income} income Income.
38
- * @returns {boolean} true if event is a valid Rental Income.
39
- */
40
- export declare function isValidRentalIncomeEvent({ assetId, type: incomeType }: Income): boolean;
41
- /**
42
- * @description Is event valid PAYG income event.
43
- * @param {Income} income Income.
44
- * @param {PersonApplicant[]} applicants An array of applicants.
45
- * @returns {boolean} true if Income type is a PAYG value and event is valid PAYG event.
46
- */
47
- export declare function isValidPaygIncomeEvent({ percentOwned, employmentId, type: incomeType }: Income, applicants?: PersonApplicant[]): boolean;
48
- /**
49
- * @description Checks if an Income event is a valid self-employment income event.
50
- * @param {Income} income Income.
51
- * @param {PersonApplicant[]} applicants An array of applicants.
52
- * @returns {boolean} Returns true if event is a valid self employment income event.
53
- */
54
- export declare function isValidSelfEmployedIncomeEvent({ percentOwned, employmentId, type: incomeType }: Income, applicants?: PersonApplicant[]): boolean;
55
- /**
56
- * @description Get the employment ids for an applicant for a specific employment type.
57
- * @param {PersonApplicant} applicant An applicant
58
- * @param {string} key Employment type key: PAYG or SelfEmployed.
59
- * @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
60
48
  */
61
- export declare function getEmploymentIds(applicant: PersonApplicant, key: 'PAYG' | 'SelfEmployed'): string[];
49
+ export declare const hasMatchingEmploymentId: (applicant: PersonApplicant, employmentId: string) => boolean;
62
50
  /**
63
- * @description Get applicantId from an array of applicants given an employmentId and employmentType.
64
- * @param {PersonApplicant[]} applicants An array of applicants.
65
- * @param {string} employmentId EmploymentId
66
- * @param {string} key Employment type: PAYG or SelfEmployed
67
- * @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
68
56
  */
69
- export declare function getStoredApplicantId(applicants: PersonApplicant[], employmentId: string, key: 'PAYG' | 'SelfEmployed'): string | undefined;
57
+ export declare function getApplicantIdFromEmploymentId(applicants: PersonApplicant[], employmentId: string): string | undefined;
70
58
  /**
71
59
  * @description Get an applicantId from the event or the applicants.
72
60
  * @param {Income} income Income.
@@ -78,6 +66,6 @@ export declare function getApplicantId({ percentOwned, employmentId }: Income, a
78
66
  * @description Sort Business Income By Year.
79
67
  * @param incomeA Income Details for Self Employed Full Doc.
80
68
  * @param incomeB Income Details for Self Employed Full Doc.
81
- * @returns {0 | - 1 | 1} Returns a number to be used for sorting income.
69
+ * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
82
70
  */
83
- export declare function sortBusinessIncome({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails): number;
71
+ export declare const sortBusinessIncome: ({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails) => number;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.sortBusinessIncome = exports.getApplicantId = exports.getStoredApplicantId = exports.getEmploymentIds = exports.isValidSelfEmployedIncomeEvent = exports.isValidPaygIncomeEvent = exports.isValidRentalIncomeEvent = exports.isFullDocOrLowDocIncome = exports.isOtherIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = 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 = [
7
7
  public_income_1.IncomeType.InvestmentIncome,
8
8
  public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
9
- public_income_1.IncomeType.RentalIncome,
10
9
  ];
11
10
  exports.PAYGList = [
12
11
  public_income_1.IncomeType.PaygAllowancesNotTaxed,
@@ -18,6 +17,17 @@ exports.PAYGList = [
18
17
  public_income_1.IncomeType.PaygCompanyCar,
19
18
  public_income_1.IncomeType.PaygOvertimeIncome,
20
19
  ];
20
+ exports.otherIncomeList = [
21
+ public_income_1.IncomeType.ChildMaintenance,
22
+ public_income_1.IncomeType.ForeignIncome,
23
+ public_income_1.IncomeType.GovtBenefit,
24
+ public_income_1.IncomeType.InvestmentIncome,
25
+ public_income_1.IncomeType.OtherIncome,
26
+ public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
27
+ public_income_1.IncomeType.PaygSalarySacrifice,
28
+ public_income_1.IncomeType.SuperAnnuityPension,
29
+ public_income_1.IncomeType.WorkersCompensation,
30
+ ];
21
31
  /**
22
32
  * @description Is income type one of the PAYG income.
23
33
  * @param {string} incomeType Income type.
@@ -45,15 +55,24 @@ function isRentalIncome(incomeType) {
45
55
  return incomeType === public_income_1.IncomeType.RentalIncome;
46
56
  }
47
57
  exports.isRentalIncome = isRentalIncome;
58
+ /**
59
+ * @description Is income type grouped as OtherIncome.
60
+ * @param {IncomeType} incomeType Income type.
61
+ * @returns {boolean} true if income is of type other income.
62
+ */
63
+ function isOtherIncome(incomeType) {
64
+ return exports.otherIncomeList.includes(incomeType);
65
+ }
66
+ exports.isOtherIncome = isOtherIncome;
48
67
  /**
49
68
  * @description Is Income type one of OtherIncome types.
50
69
  * @param {IncomeType} incomeType Income Type.
51
70
  * @returns {boolean} returns true for other income.
52
71
  */
53
- function isOtherIncome(incomeType) {
72
+ function isOtherIncomeWithDesc(incomeType) {
54
73
  return exports.descriptionOtherIncomeTypes.includes(incomeType);
55
74
  }
56
- exports.isOtherIncome = isOtherIncome;
75
+ exports.isOtherIncomeWithDesc = isOtherIncomeWithDesc;
57
76
  /**
58
77
  * @description Is Self Employed Full Doc or Low Doc Income
59
78
  * @param incomeType Income Type from Event
@@ -64,76 +83,37 @@ function isFullDocOrLowDocIncome(incomeType) {
64
83
  }
65
84
  exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
66
85
  /**
67
- * @description Checks if an Income event is a valid rental income event.
68
- * @param {Income} income Income.
69
- * @returns {boolean} true if event is a valid Rental Income.
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
70
91
  */
71
- function isValidRentalIncomeEvent(_a) {
72
- var assetId = _a.assetId, incomeType = _a.type;
73
- return isRentalIncome(incomeType) && !assetId;
74
- }
75
- exports.isValidRentalIncomeEvent = isValidRentalIncomeEvent;
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;
76
101
  /**
77
- * @description Is event valid PAYG income event.
78
- * @param {Income} income Income.
79
- * @param {PersonApplicant[]} applicants An array of applicants.
80
- * @returns {boolean} true if Income type is a PAYG value and event is valid PAYG event.
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
81
107
  */
82
- function isValidPaygIncomeEvent(_a, applicants) {
83
- var percentOwned = _a.percentOwned, employmentId = _a.employmentId, incomeType = _a.type;
84
- if (applicants === void 0) { applicants = []; }
85
- if (!isPaygIncome(incomeType))
86
- return false;
87
- var applicantId = (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getStoredApplicantId(applicants, employmentId, 'PAYG');
88
- if (!applicantId)
89
- return false;
90
- return true;
91
- }
92
- exports.isValidPaygIncomeEvent = isValidPaygIncomeEvent;
93
- /**
94
- * @description Checks if an Income event is a valid self-employment income event.
95
- * @param {Income} income Income.
96
- * @param {PersonApplicant[]} applicants An array of applicants.
97
- * @returns {boolean} Returns true if event is a valid self employment income event.
98
- */
99
- function isValidSelfEmployedIncomeEvent(_a, applicants) {
100
- var percentOwned = _a.percentOwned, employmentId = _a.employmentId, incomeType = _a.type;
101
- if (applicants === void 0) { applicants = []; }
102
- if (!isSelfEmployedIncome(incomeType))
103
- return false;
104
- var applicantId = (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getStoredApplicantId(applicants, employmentId, 'PAYG');
105
- if (!applicantId)
106
- return false;
107
- return true;
108
- }
109
- exports.isValidSelfEmployedIncomeEvent = isValidSelfEmployedIncomeEvent;
110
- /**
111
- * @description Get the employment ids for an applicant for a specific employment type.
112
- * @param {PersonApplicant} applicant An applicant
113
- * @param {string} key Employment type key: PAYG or SelfEmployed.
114
- * @returns {string[]} An array of employment ids for the applicant of the specified type.
115
- */
116
- function getEmploymentIds(applicant, key) {
117
- return (0, lodash_1.compact)(applicant.Employment.flatMap(function (employment) { return (0, lodash_1.get)(employment, "".concat(key, ".@UniqueID")); }));
118
- }
119
- exports.getEmploymentIds = getEmploymentIds;
120
- /**
121
- * @description Get applicantId from an array of applicants given an employmentId and employmentType.
122
- * @param {PersonApplicant[]} applicants An array of applicants.
123
- * @param {string} employmentId EmploymentId
124
- * @param {string} key Employment type: PAYG or SelfEmployed
125
- * @returns {string | undefined} Returns applicantId or undefined.
126
- */
127
- function getStoredApplicantId(applicants, employmentId, key) {
128
- for (var _i = 0, applicants_1 = applicants; _i < applicants_1.length; _i++) {
129
- var applicant = applicants_1[_i];
130
- var employmentIds = getEmploymentIds(applicant, key);
131
- if (employmentIds.includes(employmentId))
132
- 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'];
133
113
  }
134
- return undefined;
114
+ return applicantId;
135
115
  }
136
- exports.getStoredApplicantId = getStoredApplicantId;
116
+ exports.getApplicantIdFromEmploymentId = getApplicantIdFromEmploymentId;
137
117
  /**
138
118
  * @description Get an applicantId from the event or the applicants.
139
119
  * @param {Income} income Income.
@@ -143,24 +123,18 @@ exports.getStoredApplicantId = getStoredApplicantId;
143
123
  function getApplicantId(_a, applicants) {
144
124
  var percentOwned = _a.percentOwned, employmentId = _a.employmentId;
145
125
  if (applicants === void 0) { applicants = []; }
146
- return ((0, lodash_1.get)(percentOwned, 'owners[0].applicantId') ||
147
- getStoredApplicantId(applicants, employmentId, 'PAYG') ||
148
- getStoredApplicantId(applicants, employmentId, 'SelfEmployed'));
126
+ return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
149
127
  }
150
128
  exports.getApplicantId = getApplicantId;
151
129
  /**
152
130
  * @description Sort Business Income By Year.
153
131
  * @param incomeA Income Details for Self Employed Full Doc.
154
132
  * @param incomeB Income Details for Self Employed Full Doc.
155
- * @returns {0 | - 1 | 1} Returns a number to be used for sorting income.
133
+ * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
156
134
  */
157
- function sortBusinessIncome(_a, _b) {
135
+ var sortBusinessIncome = function (_a, _b) {
158
136
  var _c = _a.year, yearA = _c === void 0 ? 0 : _c;
159
137
  var _d = _b.year, yearB = _d === void 0 ? 0 : _d;
160
- if (yearA > yearB)
161
- return -1;
162
- if (yearB > yearA)
163
- return 1;
164
- return 0;
165
- }
138
+ return yearB - yearA;
139
+ };
166
140
  exports.sortBusinessIncome = sortBusinessIncome;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.1.1",
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.13.9",
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",