@lendi/integrations-transform 1.7.0 → 1.7.1

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.
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './transform-events/transform-applicant';
2
2
  export * from './transform-events/transform-application';
3
3
  export * from './transform-events/transform-application-workflow';
4
+ export * from './transform-events/transform-employment';
4
5
  export * from './transform-events/transform-income';
5
6
  export * from './transform-events/transform-asset';
6
7
  export * from './transform-events/transform-expenses';
package/lib/index.js CHANGED
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  __exportStar(require("./transform-events/transform-applicant"), exports);
19
19
  __exportStar(require("./transform-events/transform-application"), exports);
20
20
  __exportStar(require("./transform-events/transform-application-workflow"), exports);
21
+ __exportStar(require("./transform-events/transform-employment"), exports);
21
22
  __exportStar(require("./transform-events/transform-income"), exports);
22
23
  __exportStar(require("./transform-events/transform-asset"), exports);
23
24
  __exportStar(require("./transform-events/transform-expenses"), exports);
@@ -15,7 +15,7 @@
15
15
  "meta": {
16
16
  "type": "object",
17
17
  "additionalProperties": false,
18
- "description": "The metadata of the alieo",
18
+ "description": "The metadata of the employment",
19
19
  "properties": {
20
20
  "actionedBy": {
21
21
  "description": "uuid of user who made the action (create/update/delete)",
@@ -57,6 +57,10 @@
57
57
  "type": "string",
58
58
  "enum": ["QLD", "NSW", "VIC", "WA", "SA", "TAS", "ACT", "NT"]
59
59
  },
60
+ "otherState": {
61
+ "type": "string",
62
+ "example": "Ohio"
63
+ },
60
64
  "employerAddress": {
61
65
  "type": "object",
62
66
  "additionalProperties": false,
@@ -65,6 +69,7 @@
65
69
  "type": "string"
66
70
  },
67
71
  "state": {
72
+ "example": "NSW",
68
73
  "$ref": "#/definitions/australianStates"
69
74
  },
70
75
  "city": {
@@ -152,10 +157,6 @@
152
157
  }
153
158
  }
154
159
  },
155
- "foreignEmployed": {
156
- "type": "boolean",
157
- "example": false
158
- },
159
160
  "maternityLeaveReturnBasis": {
160
161
  "type": "string",
161
162
  "description": "Employment basis after returning from maternity leave.",
@@ -171,7 +172,6 @@
171
172
  },
172
173
  "addressStandard": {
173
174
  "type": "object",
174
- "description": "The address standard",
175
175
  "properties": {
176
176
  "buildingName": {
177
177
  "description": "The building name",
@@ -215,9 +215,9 @@
215
215
  "$ref": "#/definitions/id",
216
216
  "description": "uuid of applicant"
217
217
  },
218
- "clientId": {
218
+ "companyId": {
219
219
  "$ref": "#/definitions/id",
220
- "description": "uuid of client"
220
+ "description": "uuid of the related company"
221
221
  },
222
222
  "applicationId": {
223
223
  "$ref": "#/definitions/id",
@@ -235,30 +235,9 @@
235
235
  "employmentBasis": {
236
236
  "$ref": "#/definitions/employmentBasis"
237
237
  },
238
- "businessName": {
239
- "$ref": "#/definitions/businessName"
240
- },
241
- "abn": {
242
- "$ref": "#/definitions/abn"
243
- },
244
- "abnVerified": {
245
- "$ref": "#/definitions/abnVerified"
246
- },
247
- "companyType": {
248
- "$ref": "#/definitions/companyType"
249
- },
250
- "employerAddress": {
251
- "$ref": "#/definitions/employerAddress"
252
- },
253
- "businessStructure": {
254
- "$ref": "#/definitions/businessStructure"
255
- },
256
238
  "onProbation": {
257
239
  "$ref": "#/definitions/onProbation"
258
240
  },
259
- "foreignEmployed": {
260
- "$ref": "#/definitions/foreignEmployed"
261
- },
262
241
  "startDate": {
263
242
  "$ref": "#/definitions/startDate"
264
243
  },
@@ -273,13 +252,10 @@
273
252
  },
274
253
  "maternityLeaveReturnBasis": {
275
254
  "$ref": "#/definitions/maternityLeaveReturnBasis"
276
- },
277
- "privateOrPublic": {
278
- "$ref": "#/definitions/PrivateOrPublic"
279
255
  }
280
256
  },
281
257
  "required": ["id", "applicantId", "applicationId", "type"],
282
- "description": "create employment payload"
258
+ "description": "create or update employment payload"
283
259
  }
284
260
  },
285
261
  "type": "object",
@@ -295,7 +271,7 @@
295
271
  },
296
272
  "type": {
297
273
  "type": "string",
298
- "enum": ["EmploymentCreated", "EmploymentUpdated"]
274
+ "enum": ["EmploymentV2Created", "EmploymentV2Updated"]
299
275
  }
300
276
  },
301
277
  "required": ["version", "payload", "type"]
@@ -5,4 +5,4 @@ import { Payload } from '../types/events/public-employment';
5
5
  * @param employment a employment event payload.
6
6
  * @returns partialApplication an incomplete application.
7
7
  */
8
- export declare function generateEmployment(employment: Payload): {};
8
+ export declare function transformEmployment(employment: Payload, isSelfEmployed: boolean): {};
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateEmployment = void 0;
3
+ exports.transformEmployment = void 0;
4
4
  const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
5
  const lodash_1 = require("lodash");
6
- const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
+ const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
7
7
  const logger_1 = require("../logger");
8
8
  const public_employment_1 = require("../types/events/public-employment");
9
9
  const enum_mappings_1 = require("../types/enum-mappings");
@@ -13,10 +13,10 @@ const enum_mappings_1 = require("../types/enum-mappings");
13
13
  * @param employment a employment event payload.
14
14
  * @returns partialApplication an incomplete application.
15
15
  */
16
- function generateEmployment(employment) {
16
+ function transformEmployment(employment, isSelfEmployed) {
17
17
  const partialApplication = {};
18
18
  let employmentPath = application_paths_1.paths.PAYG;
19
- let isEmployed = false;
19
+ const companyId = employment.companyId;
20
20
  const { applicationId } = employment;
21
21
  // Each one Employment object can only contain one of the three types. Set the three object to undefined so that the
22
22
  // other two types will be removed from the final result.
@@ -26,14 +26,17 @@ function generateEmployment(employment) {
26
26
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.NotEmployed, undefined);
27
27
  switch (employment.employmentType) {
28
28
  case public_employment_1.EmploymentType.Employee:
29
- isEmployed = true;
30
29
  employmentPath = application_paths_1.paths.PAYG;
31
30
  // Setting default for onProbation. If field exists in event value will get overwritten.
32
31
  (0, lodash_1.set)(partialApplication, `${employmentPath}.@OnProbation`, lixi_internal_request_1.YesNoList.No);
33
32
  break;
34
33
  case public_employment_1.EmploymentType.SelfEmployed:
35
- isEmployed = true;
36
34
  employmentPath = application_paths_1.paths.SelfEmployed;
35
+ if (companyId && isSelfEmployed) {
36
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.CompanyApplicant}.@UniqueID`, companyId);
37
+ (0, lodash_1.set)(partialApplication, `${employmentPath}.@x_Employer`, companyId);
38
+ break;
39
+ }
37
40
  break;
38
41
  case public_employment_1.EmploymentType.NotWorking:
39
42
  employmentPath = application_paths_1.paths.NotEmployed;
@@ -46,9 +49,8 @@ function generateEmployment(employment) {
46
49
  const employmentMapping = {
47
50
  applicationId: application_paths_1.paths.ApplicationId,
48
51
  applicantId: `${application_paths_1.paths.PersonApplicant}.@UniqueID`,
52
+ companyId: `${application_paths_1.paths.RelatedCompany}.@UniqueID`,
49
53
  id: `${employmentPath}.@UniqueID`,
50
- abn: `${application_paths_1.paths.RelatedCompany}.@ABN`,
51
- businessName: `${application_paths_1.paths.RelatedCompany}.@BusinessName`,
52
54
  type: `${employmentPath}.@Status`,
53
55
  employmentBasis: `${employmentPath}.@Basis`,
54
56
  startDate: `${employmentPath}.@StartDate`,
@@ -62,21 +64,13 @@ function generateEmployment(employment) {
62
64
  case 'type':
63
65
  (0, lodash_1.set)(partialApplication, employmentMapping[key], (0, lodash_1.capitalize)(value));
64
66
  break;
65
- case 'abn':
66
- case 'businessName':
67
- // Only transform value in RelatedCompany for employed (self employed or employee) employment, otherwise RelatedCompany would missing UniqueID
68
- if (isEmployed) {
69
- (0, lodash_1.set)(partialApplication, employmentMapping[key], value.toString());
70
- }
71
- break;
72
67
  case 'employmentBasis':
73
68
  (0, lodash_1.set)(partialApplication, employmentMapping[key], enum_mappings_1.paygEmploymentBasisMapping[value]);
74
69
  break;
75
- case 'id':
76
- (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
77
- if (isEmployed) {
78
- (0, lodash_1.set)(partialApplication, `${employmentPath}.@x_Employer`, `${value}-businessName`);
79
- (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RelatedCompany}.@UniqueID`, `${value}-businessName`);
70
+ case 'companyId':
71
+ if (employment.employmentType === public_employment_1.EmploymentType.Employee) {
72
+ (0, lodash_1.set)(partialApplication, `${employmentPath}.@x_Employer`, value);
73
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
80
74
  }
81
75
  break;
82
76
  case 'onProbation':
@@ -86,10 +80,13 @@ function generateEmployment(employment) {
86
80
  }
87
81
  break;
88
82
  case 'role':
89
- const { anzsco = {} } = value;
83
+ const { anzsco = {}, asco = {} } = value;
90
84
  if (anzsco.code) {
91
85
  (0, lodash_1.set)(partialApplication, `${employmentPath}.@ANZSCOOccupationCode`, anzsco.code.toString());
92
86
  }
87
+ if (asco.code) {
88
+ (0, lodash_1.set)(partialApplication, `${employmentPath}.@OccupationCode`, asco.code);
89
+ }
93
90
  if (anzsco.occupation) {
94
91
  (0, lodash_1.set)(partialApplication, employmentMapping[key], anzsco.occupation);
95
92
  }
@@ -102,4 +99,4 @@ function generateEmployment(employment) {
102
99
  }
103
100
  return partialApplication;
104
101
  }
105
- exports.generateEmployment = generateEmployment;
102
+ exports.transformEmployment = transformEmployment;
@@ -1,6 +1,6 @@
1
- import { AustralianStates } from '../events/public-employment';
1
+ import { AustralianState } from '../events/public-required-document';
2
2
  declare type PostCodeMapping = {
3
- [key in AustralianStates]: string;
3
+ [key in AustralianState]: string;
4
4
  };
5
5
  export declare const postcodeMapping: PostCodeMapping;
6
6
  export {};
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.postcodeMapping = void 0;
4
4
  // Mapping the postcode based on the state if not specified.
5
- const public_employment_1 = require("../events/public-employment");
5
+ const public_required_document_1 = require("../events/public-required-document");
6
6
  exports.postcodeMapping = {
7
- [public_employment_1.AustralianStates.Act]: '2600',
8
- [public_employment_1.AustralianStates.Nsw]: '2000',
9
- [public_employment_1.AustralianStates.NT]: '0800',
10
- [public_employment_1.AustralianStates.Qld]: '4000',
11
- [public_employment_1.AustralianStates.Sa]: '5000',
12
- [public_employment_1.AustralianStates.Tas]: '7000',
13
- [public_employment_1.AustralianStates.Vic]: '3000',
14
- [public_employment_1.AustralianStates.Wa]: '6000',
7
+ [public_required_document_1.AustralianState.Act]: '2600',
8
+ [public_required_document_1.AustralianState.Nsw]: '2000',
9
+ [public_required_document_1.AustralianState.NT]: '0800',
10
+ [public_required_document_1.AustralianState.Qld]: '4000',
11
+ [public_required_document_1.AustralianState.Sa]: '5000',
12
+ [public_required_document_1.AustralianState.Tas]: '7000',
13
+ [public_required_document_1.AustralianState.Vic]: '3000',
14
+ [public_required_document_1.AustralianState.Wa]: '6000',
15
15
  };
@@ -10,11 +10,9 @@ export interface PublicEmployment {
10
10
  version: string;
11
11
  }
12
12
  /**
13
- * create employment payload
13
+ * create or update employment payload
14
14
  */
15
15
  export interface Payload {
16
- abn?: number;
17
- abnVerified?: boolean;
18
16
  /**
19
17
  * uuid of applicant
20
18
  */
@@ -23,18 +21,13 @@ export interface Payload {
23
21
  * uuid of application
24
22
  */
25
23
  applicationId: string;
26
- businessName?: string;
27
- businessStructure?: BusinessStructure;
28
24
  /**
29
- * uuid of client
25
+ * uuid of the related company
30
26
  */
31
- clientId?: string;
32
- companyType?: CompanyType;
33
- employerAddress?: EmployerAddress;
27
+ companyId?: string;
34
28
  employmentBasis?: EmploymentBasis;
35
29
  employmentType?: EmploymentType;
36
30
  endDate?: null | string;
37
- foreignEmployed?: boolean;
38
31
  /**
39
32
  * uuid of employment
40
33
  */
@@ -43,72 +36,10 @@ export interface Payload {
43
36
  maternityLeaveReturnDate?: string;
44
37
  meta?: Meta;
45
38
  onProbation?: boolean;
46
- privateOrPublic?: CompanyType;
47
39
  role?: Role;
48
40
  startDate?: string;
49
41
  type: PayloadType;
50
42
  }
51
- export declare enum BusinessStructure {
52
- Company = "COMPANY",
53
- Partnership = "PARTNERSHIP",
54
- SoleTrader = "SOLE_TRADER",
55
- Trust = "TRUST"
56
- }
57
- export declare enum CompanyType {
58
- Private = "PRIVATE",
59
- Public = "PUBLIC"
60
- }
61
- export interface EmployerAddress {
62
- city?: string;
63
- country?: string;
64
- formatted?: string;
65
- postcode?: string;
66
- standard?: AddressStandard;
67
- state?: AustralianStates;
68
- }
69
- /**
70
- * The address standard
71
- */
72
- export interface AddressStandard {
73
- /**
74
- * The building name
75
- */
76
- buildingName?: string;
77
- /**
78
- * The level of the unit/apartment
79
- */
80
- level?: string;
81
- /**
82
- * The lot number
83
- */
84
- lotSection?: string;
85
- /**
86
- * The street name
87
- */
88
- streetName?: string;
89
- /**
90
- * The street number
91
- */
92
- streetNumber?: string;
93
- /**
94
- * The type of the street i.e. road
95
- */
96
- streetType?: string;
97
- /**
98
- * The unit number
99
- */
100
- unit?: string;
101
- }
102
- export declare enum AustralianStates {
103
- Act = "ACT",
104
- NT = "NT",
105
- Nsw = "NSW",
106
- Qld = "QLD",
107
- Sa = "SA",
108
- Tas = "TAS",
109
- Vic = "VIC",
110
- Wa = "WA"
111
- }
112
43
  export declare enum EmploymentBasis {
113
44
  Casual = "CASUAL",
114
45
  Contractor = "CONTRACTOR",
@@ -131,7 +62,7 @@ export declare enum MaternityLeaveReturnBasis {
131
62
  PartTime = "PART_TIME"
132
63
  }
133
64
  /**
134
- * The metadata of the alieo
65
+ * The metadata of the employment
135
66
  */
136
67
  export interface Meta {
137
68
  /**
@@ -185,6 +116,6 @@ export declare enum PayloadType {
185
116
  Secondary = "SECONDARY"
186
117
  }
187
118
  export declare enum PublicEmploymentType {
188
- EmploymentCreated = "EmploymentCreated",
189
- EmploymentUpdated = "EmploymentUpdated"
119
+ EmploymentV2Created = "EmploymentV2Created",
120
+ EmploymentV2Updated = "EmploymentV2Updated"
190
121
  }
@@ -1,29 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PublicEmploymentType = exports.PayloadType = exports.ActionedByRole = exports.MaternityLeaveReturnBasis = exports.EmploymentType = exports.EmploymentBasis = exports.AustralianStates = exports.CompanyType = exports.BusinessStructure = void 0;
4
- var BusinessStructure;
5
- (function (BusinessStructure) {
6
- BusinessStructure["Company"] = "COMPANY";
7
- BusinessStructure["Partnership"] = "PARTNERSHIP";
8
- BusinessStructure["SoleTrader"] = "SOLE_TRADER";
9
- BusinessStructure["Trust"] = "TRUST";
10
- })(BusinessStructure = exports.BusinessStructure || (exports.BusinessStructure = {}));
11
- var CompanyType;
12
- (function (CompanyType) {
13
- CompanyType["Private"] = "PRIVATE";
14
- CompanyType["Public"] = "PUBLIC";
15
- })(CompanyType = exports.CompanyType || (exports.CompanyType = {}));
16
- var AustralianStates;
17
- (function (AustralianStates) {
18
- AustralianStates["Act"] = "ACT";
19
- AustralianStates["NT"] = "NT";
20
- AustralianStates["Nsw"] = "NSW";
21
- AustralianStates["Qld"] = "QLD";
22
- AustralianStates["Sa"] = "SA";
23
- AustralianStates["Tas"] = "TAS";
24
- AustralianStates["Vic"] = "VIC";
25
- AustralianStates["Wa"] = "WA";
26
- })(AustralianStates = exports.AustralianStates || (exports.AustralianStates = {}));
3
+ exports.PublicEmploymentType = exports.PayloadType = exports.ActionedByRole = exports.MaternityLeaveReturnBasis = exports.EmploymentType = exports.EmploymentBasis = void 0;
27
4
  var EmploymentBasis;
28
5
  (function (EmploymentBasis) {
29
6
  EmploymentBasis["Casual"] = "CASUAL";
@@ -64,6 +41,6 @@ var PayloadType;
64
41
  })(PayloadType = exports.PayloadType || (exports.PayloadType = {}));
65
42
  var PublicEmploymentType;
66
43
  (function (PublicEmploymentType) {
67
- PublicEmploymentType["EmploymentCreated"] = "EmploymentCreated";
68
- PublicEmploymentType["EmploymentUpdated"] = "EmploymentUpdated";
44
+ PublicEmploymentType["EmploymentV2Created"] = "EmploymentV2Created";
45
+ PublicEmploymentType["EmploymentV2Updated"] = "EmploymentV2Updated";
69
46
  })(PublicEmploymentType = exports.PublicEmploymentType || (exports.PublicEmploymentType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
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",