@lendi/integrations-transform 1.1.0 → 1.1.5

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.
Files changed (38) hide show
  1. package/lib/schemas/public-income-event.json +99 -1
  2. package/lib/transform-events/generate-asset-liability-link.js +2 -2
  3. package/lib/transform-events/generate-asset.js +32 -32
  4. package/lib/transform-events/generate-credit-report-rebuilt.js +1 -1
  5. package/lib/transform-events/generate-employment.js +17 -17
  6. package/lib/transform-events/generate-funding-position.js +6 -6
  7. package/lib/transform-events/generate-income.d.ts +20 -32
  8. package/lib/transform-events/generate-income.js +145 -146
  9. package/lib/transform-events/generate-liability.js +13 -13
  10. package/lib/transform-events/generate-lixi-percentowned.d.ts +3 -6
  11. package/lib/transform-events/generate-lixi-percentowned.js +1 -0
  12. package/lib/transform-events/generate-opportunity.js +2 -2
  13. package/lib/transform-events/generate-required-document.js +7 -7
  14. package/lib/transform-events/transform-applicant.js +21 -21
  15. package/lib/transform-events/transform-application.js +4 -4
  16. package/lib/transform-events/transform-expenses.js +3 -3
  17. package/lib/types/enum-mappings/alieo-frequency.d.ts +6 -3
  18. package/lib/types/enum-mappings/alieo-frequency.js +8 -2
  19. package/lib/types/events/applicant-delete.d.ts +42 -0
  20. package/lib/types/events/applicant-delete.js +15 -0
  21. package/lib/types/events/asset-delete.d.ts +33 -0
  22. package/lib/types/events/asset-delete.js +15 -0
  23. package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
  24. package/lib/types/events/asset-liability-relation-delete.js +15 -0
  25. package/lib/types/events/employment-delete.d.ts +19 -0
  26. package/lib/types/events/employment-delete.js +7 -0
  27. package/lib/types/events/expense-delete.d.ts +21 -0
  28. package/lib/types/events/expense-delete.js +7 -0
  29. package/lib/types/events/income-delete.d.ts +33 -0
  30. package/lib/types/events/income-delete.js +15 -0
  31. package/lib/types/events/liability-delete.d.ts +17 -0
  32. package/lib/types/events/liability-delete.js +7 -0
  33. package/lib/types/events/public-income.d.ts +37 -3
  34. package/lib/types/events/public-income.js +2 -0
  35. package/lib/utils/is-income-type.d.ts +72 -0
  36. package/lib/utils/is-income-type.js +138 -0
  37. package/lib/utils/normalise-date.js +1 -1
  38. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- var _a, _b;
2
+ var _a, _b, _c;
3
3
  exports.__esModule = true;
4
- exports.liabilityFrequencyMapping = exports.incomeExpenseFrequencyMapping = void 0;
4
+ exports.rentalIncomeFrequencyMapping = exports.liabilityFrequencyMapping = exports.incomeExpenseFrequencyMapping = void 0;
5
5
  var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
6
6
  var public_liability_1 = require("../events/public-liability");
7
7
  var public_income_1 = require("../events/public-income");
@@ -18,3 +18,9 @@ exports.liabilityFrequencyMapping = (_b = {},
18
18
  _b[public_liability_1.RepaymentFrequency.Fortnightly] = lixi_internal_request_1.List.Fortnightly,
19
19
  _b[public_liability_1.RepaymentFrequency.Weekly] = lixi_internal_request_1.List.Weekly,
20
20
  _b);
21
+ exports.rentalIncomeFrequencyMapping = (_c = {},
22
+ _c[public_income_1.Frequency.Fortnightly] = lixi_internal_request_1.List.Fortnightly,
23
+ _c[public_income_1.Frequency.Monthly] = lixi_internal_request_1.List.Monthly,
24
+ _c[public_income_1.Frequency.Weekly] = lixi_internal_request_1.List.Weekly,
25
+ _c[public_income_1.Frequency.Yearly] = lixi_internal_request_1.List.Yearly,
26
+ _c);
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Delete.
3
+ */
4
+ export interface ApplicantDelete {
5
+ payload: Payload;
6
+ type: Type;
7
+ /**
8
+ * schema version
9
+ */
10
+ version: string;
11
+ }
12
+ export interface Payload {
13
+ /**
14
+ * uuid of application
15
+ */
16
+ applicationId: string;
17
+ id: string;
18
+ meta?: ApplicantMeta;
19
+ }
20
+ /**
21
+ * The metadata of the applicant
22
+ */
23
+ export interface ApplicantMeta {
24
+ /**
25
+ * uuid of user who made the action (delete)
26
+ */
27
+ actionedBy: string;
28
+ /**
29
+ * role of the user that made the action
30
+ */
31
+ actionedByRole: ActionedByRole;
32
+ }
33
+ /**
34
+ * role of the user that made the action
35
+ */
36
+ export declare enum ActionedByRole {
37
+ Customer = "customer",
38
+ Team = "team"
39
+ }
40
+ export declare enum Type {
41
+ DeleteApplicant = "DeleteApplicant"
42
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Type = exports.ActionedByRole = void 0;
4
+ /**
5
+ * role of the user that made the action
6
+ */
7
+ var ActionedByRole;
8
+ (function (ActionedByRole) {
9
+ ActionedByRole["Customer"] = "customer";
10
+ ActionedByRole["Team"] = "team";
11
+ })(ActionedByRole = exports.ActionedByRole || (exports.ActionedByRole = {}));
12
+ var Type;
13
+ (function (Type) {
14
+ Type["DeleteApplicant"] = "DeleteApplicant";
15
+ })(Type = exports.Type || (exports.Type = {}));
@@ -0,0 +1,33 @@
1
+ export interface AssetDelete {
2
+ payload: DeletePayloadDefinition;
3
+ type: Type;
4
+ version: string;
5
+ }
6
+ export interface DeletePayloadDefinition {
7
+ applicationId: string;
8
+ id: string;
9
+ meta?: Meta;
10
+ }
11
+ /**
12
+ * The metadata of the alieo
13
+ */
14
+ export interface Meta {
15
+ /**
16
+ * uuid of user who made the action (create/update/delete)
17
+ */
18
+ actionedBy: string;
19
+ /**
20
+ * role of the user that made the action
21
+ */
22
+ actionedByRole: ActionedByRole;
23
+ }
24
+ /**
25
+ * role of the user that made the action
26
+ */
27
+ export declare enum ActionedByRole {
28
+ Customer = "customer",
29
+ Team = "team"
30
+ }
31
+ export declare enum Type {
32
+ AssetDeleted = "AssetDeleted"
33
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Type = exports.ActionedByRole = void 0;
4
+ /**
5
+ * role of the user that made the action
6
+ */
7
+ var ActionedByRole;
8
+ (function (ActionedByRole) {
9
+ ActionedByRole["Customer"] = "customer";
10
+ ActionedByRole["Team"] = "team";
11
+ })(ActionedByRole = exports.ActionedByRole || (exports.ActionedByRole = {}));
12
+ var Type;
13
+ (function (Type) {
14
+ Type["AssetDeleted"] = "AssetDeleted";
15
+ })(Type = exports.Type || (exports.Type = {}));
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The AssetAndLiabilityRelationDeleted event schema
3
+ */
4
+ export interface AssetLiabilityRelationDelete {
5
+ payload: DeleteAssetAndLiabilityRelationDefinition;
6
+ type: Type;
7
+ /**
8
+ * schema version
9
+ */
10
+ version: string;
11
+ }
12
+ /**
13
+ * delete Asset And Liability Relation payload
14
+ */
15
+ export interface DeleteAssetAndLiabilityRelationDefinition {
16
+ applicationId: string;
17
+ meta?: Meta;
18
+ relation: Relation;
19
+ }
20
+ /**
21
+ * The metadata of the alieo
22
+ */
23
+ export interface Meta {
24
+ /**
25
+ * uuid of user who made the action (create/update/delete)
26
+ */
27
+ actionedBy: string;
28
+ /**
29
+ * role of the user that made the action
30
+ */
31
+ actionedByRole: ActionedByRole;
32
+ }
33
+ /**
34
+ * role of the user that made the action
35
+ */
36
+ export declare enum ActionedByRole {
37
+ Customer = "customer",
38
+ Team = "team"
39
+ }
40
+ export interface Relation {
41
+ /**
42
+ * uuid of asset
43
+ */
44
+ assetId: string;
45
+ /**
46
+ * uuid of liability
47
+ */
48
+ liabilityId: string;
49
+ }
50
+ export declare enum Type {
51
+ AssetAndLiabilityRelationDeleted = "AssetAndLiabilityRelationDeleted"
52
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Type = exports.ActionedByRole = void 0;
4
+ /**
5
+ * role of the user that made the action
6
+ */
7
+ var ActionedByRole;
8
+ (function (ActionedByRole) {
9
+ ActionedByRole["Customer"] = "customer";
10
+ ActionedByRole["Team"] = "team";
11
+ })(ActionedByRole = exports.ActionedByRole || (exports.ActionedByRole = {}));
12
+ var Type;
13
+ (function (Type) {
14
+ Type["AssetAndLiabilityRelationDeleted"] = "AssetAndLiabilityRelationDeleted";
15
+ })(Type = exports.Type || (exports.Type = {}));
@@ -0,0 +1,19 @@
1
+ export interface EmploymentDelete {
2
+ payload: Payload;
3
+ type: Type;
4
+ version: string;
5
+ }
6
+ export interface Payload {
7
+ /**
8
+ * uuid of applicant
9
+ */
10
+ applicantId?: string;
11
+ /**
12
+ * uuid of application
13
+ */
14
+ applicationId: string;
15
+ id: string;
16
+ }
17
+ export declare enum Type {
18
+ EmploymentDeleted = "EmploymentDeleted"
19
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Type = void 0;
4
+ var Type;
5
+ (function (Type) {
6
+ Type["EmploymentDeleted"] = "EmploymentDeleted";
7
+ })(Type = exports.Type || (exports.Type = {}));
@@ -0,0 +1,21 @@
1
+ export interface ExpenseDelete {
2
+ payload: Payload;
3
+ type: Type;
4
+ version: string;
5
+ }
6
+ export interface Payload {
7
+ /**
8
+ * uuid of applicant
9
+ */
10
+ applicantId: string;
11
+ applicationId: string;
12
+ id: string;
13
+ meta?: Meta;
14
+ }
15
+ export interface Meta {
16
+ actionedBy: string;
17
+ actionedByRole: string;
18
+ }
19
+ export declare enum Type {
20
+ ExpenseDeleted = "ExpenseDeleted"
21
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Type = void 0;
4
+ var Type;
5
+ (function (Type) {
6
+ Type["ExpenseDeleted"] = "ExpenseDeleted";
7
+ })(Type = exports.Type || (exports.Type = {}));
@@ -0,0 +1,33 @@
1
+ export interface IncomeDelete {
2
+ payload: DeleteEntityDefinition;
3
+ type: Type;
4
+ version: string;
5
+ }
6
+ export interface DeleteEntityDefinition {
7
+ applicationId: string;
8
+ id: string;
9
+ meta?: Meta;
10
+ }
11
+ /**
12
+ * The metadata of the alieo
13
+ */
14
+ export interface Meta {
15
+ /**
16
+ * uuid of user who made the action (create/update/delete)
17
+ */
18
+ actionedBy: string;
19
+ /**
20
+ * role of the user that made the action
21
+ */
22
+ actionedByRole: ActionedByRole;
23
+ }
24
+ /**
25
+ * role of the user that made the action
26
+ */
27
+ export declare enum ActionedByRole {
28
+ Customer = "customer",
29
+ Team = "team"
30
+ }
31
+ export declare enum Type {
32
+ IncomeDeleted = "IncomeDeleted"
33
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Type = exports.ActionedByRole = void 0;
4
+ /**
5
+ * role of the user that made the action
6
+ */
7
+ var ActionedByRole;
8
+ (function (ActionedByRole) {
9
+ ActionedByRole["Customer"] = "customer";
10
+ ActionedByRole["Team"] = "team";
11
+ })(ActionedByRole = exports.ActionedByRole || (exports.ActionedByRole = {}));
12
+ var Type;
13
+ (function (Type) {
14
+ Type["IncomeDeleted"] = "IncomeDeleted";
15
+ })(Type = exports.Type || (exports.Type = {}));
@@ -0,0 +1,17 @@
1
+ export interface LiabilityDelete {
2
+ payload: Payload;
3
+ type: Type;
4
+ version: string;
5
+ }
6
+ export interface Payload {
7
+ applicationId: string;
8
+ id: string;
9
+ meta?: Meta;
10
+ }
11
+ export interface Meta {
12
+ actionedBy: string;
13
+ actionedByRole: string;
14
+ }
15
+ export declare enum Type {
16
+ LiabilityDeleted = "LiabilityDeleted"
17
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Type = void 0;
4
+ var Type;
5
+ (function (Type) {
6
+ Type["LiabilityDeleted"] = "LiabilityDeleted";
7
+ })(Type = exports.Type || (exports.Type = {}));
@@ -13,19 +13,30 @@ export interface IncomeDefinition {
13
13
  meta?: Meta;
14
14
  }
15
15
  export interface Income {
16
- amount: number;
16
+ amount?: number;
17
17
  assetId?: string;
18
+ bas?: BASDefinition[];
18
19
  benefitType?: BenefitType;
19
20
  comments?: string;
21
+ companyId?: string;
20
22
  description?: string;
21
23
  /**
22
24
  * Company Applicant
23
25
  */
24
26
  employmentId?: string;
25
- frequency: Frequency;
26
- percentOwned: OwnershipProportion;
27
+ frequency?: Frequency;
28
+ gross?: number;
29
+ incomes?: IncomeBusinessDetails[];
30
+ percentOwned?: OwnershipProportion;
27
31
  type: IncomeType;
28
32
  }
33
+ /**
34
+ * Business activity statement details
35
+ */
36
+ export interface BASDefinition {
37
+ quarter: number;
38
+ salesAmount?: number;
39
+ }
29
40
  export declare enum BenefitType {
30
41
  AgePension = "AGE_PENSION",
31
42
  DisabilitySupportPension = "DISABILITY_SUPPORT_PENSION",
@@ -39,6 +50,27 @@ export declare enum Frequency {
39
50
  Weekly = "WEEKLY",
40
51
  Yearly = "YEARLY"
41
52
  }
53
+ /**
54
+ * Earnings for a company over a specified financial year
55
+ */
56
+ export interface IncomeBusinessDetails {
57
+ addback?: AddBackDefinition;
58
+ companyProfitBeforeTax?: number;
59
+ nonRecurringIncome?: number;
60
+ year?: number;
61
+ }
62
+ /**
63
+ * add-back is an expense that is added back to the profits of the business
64
+ */
65
+ export interface AddBackDefinition {
66
+ depreciation?: number;
67
+ interest?: number;
68
+ lease?: number;
69
+ nonRecurringExpenses?: number;
70
+ other?: number;
71
+ salary?: number;
72
+ superannuationExcess?: number;
73
+ }
42
74
  export interface OwnershipProportion {
43
75
  owners: Ownership[];
44
76
  /**
@@ -81,6 +113,8 @@ export declare enum IncomeType {
81
113
  PaygSalarySacrifice = "PAYG_SALARY_SACRIFICE",
82
114
  RentalIncome = "RENTAL_INCOME",
83
115
  SelfEmployedBusinessIncome = "SELF_EMPLOYED_BUSINESS_INCOME",
116
+ SelfEmployedBusinessIncomeFullDoc = "SELF_EMPLOYED_BUSINESS_INCOME_FULL_DOC",
117
+ SelfEmployedBusinessIncomeLowDoc = "SELF_EMPLOYED_BUSINESS_INCOME_LOW_DOC",
84
118
  SuperAnnuityPension = "SUPER_ANNUITY_PENSION",
85
119
  WorkersCompensation = "WORKERS_COMPENSATION"
86
120
  }
@@ -45,6 +45,8 @@ var IncomeType;
45
45
  IncomeType["PaygSalarySacrifice"] = "PAYG_SALARY_SACRIFICE";
46
46
  IncomeType["RentalIncome"] = "RENTAL_INCOME";
47
47
  IncomeType["SelfEmployedBusinessIncome"] = "SELF_EMPLOYED_BUSINESS_INCOME";
48
+ IncomeType["SelfEmployedBusinessIncomeFullDoc"] = "SELF_EMPLOYED_BUSINESS_INCOME_FULL_DOC";
49
+ IncomeType["SelfEmployedBusinessIncomeLowDoc"] = "SELF_EMPLOYED_BUSINESS_INCOME_LOW_DOC";
48
50
  IncomeType["SuperAnnuityPension"] = "SUPER_ANNUITY_PENSION";
49
51
  IncomeType["WorkersCompensation"] = "WORKERS_COMPENSATION";
50
52
  })(IncomeType = exports.IncomeType || (exports.IncomeType = {}));
@@ -0,0 +1,72 @@
1
+ import { PersonApplicant } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { IncomeType, Income, IncomeBusinessDetails } from '../types/events/public-income';
3
+ export declare const descriptionOtherIncomeTypes: string[];
4
+ export declare const PAYGList: string[];
5
+ export declare const otherIncomeList: IncomeType[];
6
+ /**
7
+ * @description Is income type one of the PAYG income.
8
+ * @param {string} incomeType Income type.
9
+ * @returns {boolean} Returns true if Income type is a PAYG Income.
10
+ */
11
+ export declare function isPaygIncome(incomeType: string): boolean;
12
+ /**
13
+ * @description Is income type SelfEmployedBusinessIncome.
14
+ * @param {string} incomeType Income type.
15
+ * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
16
+ */
17
+ export declare function isSelfEmployedIncome(incomeType: string): boolean;
18
+ /**
19
+ * @description Is income type Rental Income.
20
+ * @param {IncomeType} incomeType Income type.
21
+ * @returns {boolean} true if Income type is Rental Income.
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;
30
+ /**
31
+ * @description Is Income type one of OtherIncome types.
32
+ * @param {IncomeType} incomeType Income Type.
33
+ * @returns {boolean} returns true for other income.
34
+ */
35
+ export declare function isOtherIncomeWithDesc(incomeType: string): boolean;
36
+ /**
37
+ * @description Is Self Employed Full Doc or Low Doc Income
38
+ * @param incomeType Income Type from Event
39
+ * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
40
+ */
41
+ export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
42
+ declare type EmploymentTypes = 'PAYG' | 'SelfEmployed' | 'NotEmployed';
43
+ /**
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.
48
+ */
49
+ export declare function getEmploymentIds(applicant: PersonApplicant, key: EmploymentTypes): string[];
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.
56
+ */
57
+ export declare function getStoredApplicantId(applicants: PersonApplicant[], employmentId: string, key: EmploymentTypes): string | undefined;
58
+ /**
59
+ * @description Get an applicantId from the event or the applicants.
60
+ * @param {Income} income Income.
61
+ * @param {PersonApplicant[]} applicants An array of LIXI applicants.
62
+ * @returns {string | undefined} An applicantId or undefined.
63
+ */
64
+ export declare function getApplicantId({ percentOwned, employmentId }: Income, applicants?: PersonApplicant[]): string | undefined;
65
+ /**
66
+ * @description Sort Business Income By Year.
67
+ * @param incomeA Income Details for Self Employed Full Doc.
68
+ * @param incomeB Income Details for Self Employed Full Doc.
69
+ * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
70
+ */
71
+ export declare const sortBusinessIncome: ({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails) => number;
72
+ export {};
@@ -0,0 +1,138 @@
1
+ "use strict";
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;
4
+ var lodash_1 = require("lodash");
5
+ var public_income_1 = require("../types/events/public-income");
6
+ exports.descriptionOtherIncomeTypes = [
7
+ public_income_1.IncomeType.InvestmentIncome,
8
+ public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
9
+ ];
10
+ exports.PAYGList = [
11
+ public_income_1.IncomeType.PaygAllowancesNotTaxed,
12
+ public_income_1.IncomeType.PaygAllowancesTaxed,
13
+ public_income_1.IncomeType.PaygBaseSalary,
14
+ public_income_1.IncomeType.PaygBonusIncome,
15
+ public_income_1.IncomeType.PaygCarAllowance,
16
+ public_income_1.IncomeType.PaygCommissionIncome,
17
+ public_income_1.IncomeType.PaygCompanyCar,
18
+ public_income_1.IncomeType.PaygOvertimeIncome,
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
+ ];
31
+ /**
32
+ * @description Is income type one of the PAYG income.
33
+ * @param {string} incomeType Income type.
34
+ * @returns {boolean} Returns true if Income type is a PAYG Income.
35
+ */
36
+ function isPaygIncome(incomeType) {
37
+ return exports.PAYGList.includes(incomeType);
38
+ }
39
+ exports.isPaygIncome = isPaygIncome;
40
+ /**
41
+ * @description Is income type SelfEmployedBusinessIncome.
42
+ * @param {string} incomeType Income type.
43
+ * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
44
+ */
45
+ function isSelfEmployedIncome(incomeType) {
46
+ return incomeType === public_income_1.IncomeType.SelfEmployedBusinessIncome;
47
+ }
48
+ exports.isSelfEmployedIncome = isSelfEmployedIncome;
49
+ /**
50
+ * @description Is income type Rental Income.
51
+ * @param {IncomeType} incomeType Income type.
52
+ * @returns {boolean} true if Income type is Rental Income.
53
+ */
54
+ function isRentalIncome(incomeType) {
55
+ return incomeType === public_income_1.IncomeType.RentalIncome;
56
+ }
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;
67
+ /**
68
+ * @description Is Income type one of OtherIncome types.
69
+ * @param {IncomeType} incomeType Income Type.
70
+ * @returns {boolean} returns true for other income.
71
+ */
72
+ function isOtherIncomeWithDesc(incomeType) {
73
+ return exports.descriptionOtherIncomeTypes.includes(incomeType);
74
+ }
75
+ exports.isOtherIncomeWithDesc = isOtherIncomeWithDesc;
76
+ /**
77
+ * @description Is Self Employed Full Doc or Low Doc Income
78
+ * @param incomeType Income Type from Event
79
+ * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
80
+ */
81
+ function isFullDocOrLowDocIncome(incomeType) {
82
+ return [public_income_1.IncomeType.SelfEmployedBusinessIncomeFullDoc, public_income_1.IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
83
+ }
84
+ exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
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.
90
+ */
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;
95
+ /**
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.
101
+ */
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
+ }
109
+ return undefined;
110
+ }
111
+ exports.getStoredApplicantId = getStoredApplicantId;
112
+ /**
113
+ * @description Get an applicantId from the event or the applicants.
114
+ * @param {Income} income Income.
115
+ * @param {PersonApplicant[]} applicants An array of LIXI applicants.
116
+ * @returns {string | undefined} An applicantId or undefined.
117
+ */
118
+ function getApplicantId(_a, applicants) {
119
+ var percentOwned = _a.percentOwned, employmentId = _a.employmentId;
120
+ 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'));
125
+ }
126
+ exports.getApplicantId = getApplicantId;
127
+ /**
128
+ * @description Sort Business Income By Year.
129
+ * @param incomeA Income Details for Self Employed Full Doc.
130
+ * @param incomeB Income Details for Self Employed Full Doc.
131
+ * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
132
+ */
133
+ var sortBusinessIncome = function (_a, _b) {
134
+ var _c = _a.year, yearA = _c === void 0 ? 0 : _c;
135
+ var _d = _b.year, yearB = _d === void 0 ? 0 : _d;
136
+ return yearB - yearA;
137
+ };
138
+ exports.sortBusinessIncome = sortBusinessIncome;
@@ -12,6 +12,6 @@ function normaliseDate(dateOfBirth) {
12
12
  var year = date.getFullYear();
13
13
  var month = ('0' + (date.getMonth() + 1)).slice(-2);
14
14
  var day = ('0' + date.getDate()).slice(-2);
15
- return year + "-" + month + "-" + day;
15
+ return "".concat(year, "-").concat(month, "-").concat(day);
16
16
  }
17
17
  exports.normaliseDate = normaliseDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.1.0",
3
+ "version": "1.1.5",
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,7 +21,7 @@
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",
24
+ "@lendi/integrations-credit-protocol": "1.14.4",
25
25
  "@lendi/integrations-protocol": "2.3.0",
26
26
  "clean-deep": "^3.4.0",
27
27
  "date-fns": "2.19.0",