@lendi/integrations-transform 1.1.3 → 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.
@@ -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)
@@ -73,23 +84,22 @@ function getIncomeMapping(incomeType) {
73
84
  basePath = application_paths_1.paths.CompanyApplicant;
74
85
  return {
75
86
  companyId: "".concat(basePath, ".@UniqueID"),
76
- incomes: "".concat(basePath, ".IncomeRecent"),
77
- incomeRecent: "".concat(basePath, ".IncomeRecent"),
78
- incomePrevious: "".concat(basePath, ".IncomePrevious"),
87
+ incomes: "".concat(basePath, ".Income"),
79
88
  gross: "".concat(basePath, ".DeclaredIncome.@IncomeAmount")
80
89
  };
81
90
  }
82
- if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
83
- basePath = application_paths_1.paths.PAYG;
84
- var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
85
- var mapping = {
91
+ if ((0, is_income_type_1.isSelfEmployedIncome)(incomeType)) {
92
+ basePath = application_paths_1.paths.SelfEmployed;
93
+ var amount = exports.EmploymentIncomeTypeMapping[incomeType].amount;
94
+ return {
86
95
  amount: "".concat(basePath, ".").concat(amount),
87
96
  employmentId: "".concat(basePath, ".@UniqueID")
88
97
  };
89
- if (frequency) {
90
- mapping.frequency = "".concat(basePath, ".").concat(frequency);
91
- }
92
- return mapping;
98
+ }
99
+ if ((0, is_income_type_1.isPaygIncome)(incomeType)) {
100
+ basePath = application_paths_1.paths.PAYG;
101
+ var _a = exports.EmploymentIncomeTypeMapping[incomeType], amount = _a.amount, frequency = _a.frequency;
102
+ return __assign({ amount: "".concat(basePath, ".").concat(amount), employmentId: "".concat(basePath, ".@UniqueID") }, (frequency && { frequency: "".concat(basePath, ".").concat(frequency) }));
93
103
  }
94
104
  return {
95
105
  amount: "".concat(basePath, ".@Amount"),
@@ -159,7 +169,7 @@ function generateIncome(payload, applicantId) {
159
169
  var sortedIncomeList = value
160
170
  .sort(is_income_type_1.sortBusinessIncome)
161
171
  .map(generateIncomeBusinessDetails);
162
- (0, lodash_1.set)(partialApplication, 'Package.Content.Application.CompanyApplicant[0].Income', sortedIncomeList);
172
+ (0, lodash_1.set)(partialApplication, incomeMapping[key], sortedIncomeList);
163
173
  break;
164
174
  default:
165
175
  (0, lodash_1.set)(partialApplication, incomeMapping[key], value);
@@ -39,13 +39,14 @@ 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';
42
43
  /**
43
44
  * @description Get the employment ids for an applicant for a specific employment type.
44
45
  * @param {PersonApplicant} applicant An applicant
45
46
  * @param {string} key Employment type key: PAYG or SelfEmployed.
46
47
  * @returns {string[]} An array of employment ids for the applicant of the specified type.
47
48
  */
48
- export declare function getEmploymentIds(applicant: PersonApplicant, key: 'PAYG' | 'SelfEmployed'): string[];
49
+ export declare function getEmploymentIds(applicant: PersonApplicant, key: EmploymentTypes): string[];
49
50
  /**
50
51
  * @description Get applicantId from an array of applicants given an employmentId and employmentType.
51
52
  * @param {PersonApplicant[]} applicants An array of applicants.
@@ -53,7 +54,7 @@ export declare function getEmploymentIds(applicant: PersonApplicant, key: 'PAYG'
53
54
  * @param {string} key Employment type: PAYG or SelfEmployed
54
55
  * @returns {string | undefined} Returns applicantId or undefined.
55
56
  */
56
- export declare function getStoredApplicantId(applicants: PersonApplicant[], employmentId: string, key: 'PAYG' | 'SelfEmployed'): string | undefined;
57
+ export declare function getStoredApplicantId(applicants: PersonApplicant[], employmentId: string, key: EmploymentTypes): string | undefined;
57
58
  /**
58
59
  * @description Get an applicantId from the event or the applicants.
59
60
  * @param {Income} income Income.
@@ -65,6 +66,7 @@ export declare function getApplicantId({ percentOwned, employmentId }: Income, a
65
66
  * @description Sort Business Income By Year.
66
67
  * @param incomeA Income Details for Self Employed Full Doc.
67
68
  * @param incomeB Income Details for Self Employed Full Doc.
68
- * @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.
69
70
  */
70
- export declare function sortBusinessIncome({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails): number;
71
+ export declare const sortBusinessIncome: ({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails) => number;
72
+ export {};
@@ -120,22 +120,19 @@ function getApplicantId(_a, applicants) {
120
120
  if (applicants === void 0) { applicants = []; }
121
121
  return ((0, lodash_1.get)(percentOwned, 'owners[0].applicantId') ||
122
122
  getStoredApplicantId(applicants, employmentId, 'PAYG') ||
123
- getStoredApplicantId(applicants, employmentId, 'SelfEmployed'));
123
+ getStoredApplicantId(applicants, employmentId, 'SelfEmployed') ||
124
+ getStoredApplicantId(applicants, employmentId, 'NotEmployed'));
124
125
  }
125
126
  exports.getApplicantId = getApplicantId;
126
127
  /**
127
128
  * @description Sort Business Income By Year.
128
129
  * @param incomeA Income Details for Self Employed Full Doc.
129
130
  * @param incomeB Income Details for Self Employed Full Doc.
130
- * @returns {0 | - 1 | 1} Returns a number to be used for sorting income.
131
+ * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
131
132
  */
132
- function sortBusinessIncome(_a, _b) {
133
+ var sortBusinessIncome = function (_a, _b) {
133
134
  var _c = _a.year, yearA = _c === void 0 ? 0 : _c;
134
135
  var _d = _b.year, yearB = _d === void 0 ? 0 : _d;
135
- if (yearA > yearB)
136
- return -1;
137
- if (yearB > yearA)
138
- return 1;
139
- return 0;
140
- }
136
+ return yearB - yearA;
137
+ };
141
138
  exports.sortBusinessIncome = sortBusinessIncome;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.1.3",
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",