@lendi/integrations-transform 1.0.8 → 1.1.2

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 +141 -140
  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 +7 -4
  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 +83 -0
  36. package/lib/utils/is-income-type.js +166 -0
  37. package/lib/utils/normalise-date.js +1 -1
  38. package/package.json +3 -6
@@ -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,83 @@
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
+ /**
6
+ * @description Is income type one of the PAYG income.
7
+ * @param {string} incomeType Income type.
8
+ * @returns {boolean} Returns true if Income type is a PAYG Income.
9
+ */
10
+ export declare function isPaygIncome(incomeType: string): boolean;
11
+ /**
12
+ * @description Is income type SelfEmployedBusinessIncome.
13
+ * @param {string} incomeType Income type.
14
+ * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
15
+ */
16
+ export declare function isSelfEmployedIncome(incomeType: string): boolean;
17
+ /**
18
+ * @description Is income type Rental Income.
19
+ * @param {IncomeType} incomeType Income type.
20
+ * @returns {boolean} true if Income type is Rental Income.
21
+ */
22
+ export declare function isRentalIncome(incomeType: string): boolean;
23
+ /**
24
+ * @description Is Income type one of OtherIncome types.
25
+ * @param {IncomeType} incomeType Income Type.
26
+ * @returns {boolean} returns true for other income.
27
+ */
28
+ export declare function isOtherIncome(incomeType: string): boolean;
29
+ /**
30
+ * @description Is Self Employed Full Doc or Low Doc Income
31
+ * @param incomeType Income Type from Event
32
+ * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
33
+ */
34
+ export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
35
+ /**
36
+ * @description Checks if an Income event is a valid rental income event.
37
+ * @param {Income} income Income.
38
+ * @returns {boolean} true if income type is RENTAL_INCOME and an assetId exists.
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.
60
+ */
61
+ export declare function getEmploymentIds(applicant: PersonApplicant, key: 'PAYG' | 'SelfEmployed'): string[];
62
+ /**
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.
68
+ */
69
+ export declare function getStoredApplicantId(applicants: PersonApplicant[], employmentId: string, key: 'PAYG' | 'SelfEmployed'): string | undefined;
70
+ /**
71
+ * @description Get an applicantId from the event or the applicants.
72
+ * @param {Income} income Income.
73
+ * @param {PersonApplicant[]} applicants An array of LIXI applicants.
74
+ * @returns {string | undefined} An applicantId or undefined.
75
+ */
76
+ export declare function getApplicantId({ percentOwned, employmentId }: Income, applicants?: PersonApplicant[]): string | undefined;
77
+ /**
78
+ * @description Sort Business Income By Year.
79
+ * @param incomeA Income Details for Self Employed Full Doc.
80
+ * @param incomeB Income Details for Self Employed Full Doc.
81
+ * @returns {0 | - 1 | 1} Returns a number to be used for sorting income.
82
+ */
83
+ export declare function sortBusinessIncome({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails): number;
@@ -0,0 +1,166 @@
1
+ "use strict";
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;
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
+ public_income_1.IncomeType.RentalIncome,
10
+ ];
11
+ exports.PAYGList = [
12
+ public_income_1.IncomeType.PaygAllowancesNotTaxed,
13
+ public_income_1.IncomeType.PaygAllowancesTaxed,
14
+ public_income_1.IncomeType.PaygBaseSalary,
15
+ public_income_1.IncomeType.PaygBonusIncome,
16
+ public_income_1.IncomeType.PaygCarAllowance,
17
+ public_income_1.IncomeType.PaygCommissionIncome,
18
+ public_income_1.IncomeType.PaygCompanyCar,
19
+ public_income_1.IncomeType.PaygOvertimeIncome,
20
+ ];
21
+ /**
22
+ * @description Is income type one of the PAYG income.
23
+ * @param {string} incomeType Income type.
24
+ * @returns {boolean} Returns true if Income type is a PAYG Income.
25
+ */
26
+ function isPaygIncome(incomeType) {
27
+ return exports.PAYGList.includes(incomeType);
28
+ }
29
+ exports.isPaygIncome = isPaygIncome;
30
+ /**
31
+ * @description Is income type SelfEmployedBusinessIncome.
32
+ * @param {string} incomeType Income type.
33
+ * @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
34
+ */
35
+ function isSelfEmployedIncome(incomeType) {
36
+ return incomeType === public_income_1.IncomeType.SelfEmployedBusinessIncome;
37
+ }
38
+ exports.isSelfEmployedIncome = isSelfEmployedIncome;
39
+ /**
40
+ * @description Is income type Rental Income.
41
+ * @param {IncomeType} incomeType Income type.
42
+ * @returns {boolean} true if Income type is Rental Income.
43
+ */
44
+ function isRentalIncome(incomeType) {
45
+ return incomeType === public_income_1.IncomeType.RentalIncome;
46
+ }
47
+ exports.isRentalIncome = isRentalIncome;
48
+ /**
49
+ * @description Is Income type one of OtherIncome types.
50
+ * @param {IncomeType} incomeType Income Type.
51
+ * @returns {boolean} returns true for other income.
52
+ */
53
+ function isOtherIncome(incomeType) {
54
+ return exports.descriptionOtherIncomeTypes.includes(incomeType);
55
+ }
56
+ exports.isOtherIncome = isOtherIncome;
57
+ /**
58
+ * @description Is Self Employed Full Doc or Low Doc Income
59
+ * @param incomeType Income Type from Event
60
+ * @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
61
+ */
62
+ function isFullDocOrLowDocIncome(incomeType) {
63
+ return [public_income_1.IncomeType.SelfEmployedBusinessIncomeFullDoc, public_income_1.IncomeType.SelfEmployedBusinessIncomeLowDoc].includes(incomeType);
64
+ }
65
+ exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
66
+ /**
67
+ * @description Checks if an Income event is a valid rental income event.
68
+ * @param {Income} income Income.
69
+ * @returns {boolean} true if income type is RENTAL_INCOME and an assetId exists.
70
+ */
71
+ function isValidRentalIncomeEvent(_a) {
72
+ var assetId = _a.assetId, incomeType = _a.type;
73
+ return isRentalIncome(incomeType) && !!assetId;
74
+ }
75
+ exports.isValidRentalIncomeEvent = isValidRentalIncomeEvent;
76
+ /**
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.
81
+ */
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 (!isFullDocOrLowDocIncome(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'];
133
+ }
134
+ return undefined;
135
+ }
136
+ exports.getStoredApplicantId = getStoredApplicantId;
137
+ /**
138
+ * @description Get an applicantId from the event or the applicants.
139
+ * @param {Income} income Income.
140
+ * @param {PersonApplicant[]} applicants An array of LIXI applicants.
141
+ * @returns {string | undefined} An applicantId or undefined.
142
+ */
143
+ function getApplicantId(_a, applicants) {
144
+ var percentOwned = _a.percentOwned, employmentId = _a.employmentId;
145
+ 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'));
149
+ }
150
+ exports.getApplicantId = getApplicantId;
151
+ /**
152
+ * @description Sort Business Income By Year.
153
+ * @param incomeA Income Details for Self Employed Full Doc.
154
+ * @param incomeB Income Details for Self Employed Full Doc.
155
+ * @returns {0 | - 1 | 1} Returns a number to be used for sorting income.
156
+ */
157
+ function sortBusinessIncome(_a, _b) {
158
+ var _c = _a.year, yearA = _c === void 0 ? 0 : _c;
159
+ 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
+ }
166
+ 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;