Skip to content

Commit 4ca63c2

Browse files
committed
new components
1 parent 82acf19 commit 4ca63c2

File tree

13 files changed

+476
-705
lines changed

13 files changed

+476
-705
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import kenjo from "../../kenjo.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "kenjo-create-attendance-entry",
6+
name: "Create Attendance Entry",
7+
description: "Creates a new attendance entry for an employee in Kenjo. [See the documentation](https://kenjo.readme.io/reference/post_attendances)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
kenjo,
12+
employeeId: {
13+
propDefinition: [
14+
kenjo,
15+
"employeeId",
16+
],
17+
},
18+
date: {
19+
type: "string",
20+
label: "Date",
21+
description: "The date of the entry. Format: `YYYY-MM-DD`",
22+
},
23+
startTime: {
24+
type: "string",
25+
label: "Start Time",
26+
description: "The start time of the entry. Format: `hh:mm:ss`",
27+
},
28+
endTime: {
29+
type: "string",
30+
label: "End Time",
31+
description: "The end time of the entry. Format: `hh:mm:ss`",
32+
optional: true,
33+
},
34+
breakStartTime: {
35+
type: "string",
36+
label: "Break Start Time",
37+
description: "The start time of the break. Format: `hh:mm:ss`",
38+
optional: true,
39+
},
40+
breakEndTime: {
41+
type: "string",
42+
label: "Break End Time",
43+
description: "The end time of the break. Format: `hh:mm:ss`",
44+
optional: true,
45+
},
46+
comment: {
47+
type: "string",
48+
label: "Comment",
49+
description: "Comment to describe the attendance record",
50+
optional: true,
51+
},
52+
},
53+
async run({ $ }) {
54+
if (this.breakEndTime && !this.breakStartTime) {
55+
throw new ConfigurationError("Break Start Time is required if including a break");
56+
}
57+
58+
const response = await this.kenjo.createAttendanceEntry({
59+
$,
60+
data: {
61+
userId: this.employeeId,
62+
date: this.date,
63+
startTime: this.startTime,
64+
endTime: this.endTime,
65+
breaks: this.breakStartTime && [
66+
{
67+
start: this.breakStartTime,
68+
end: this.breakEndTime,
69+
},
70+
],
71+
comment: this.comment,
72+
},
73+
});
74+
$.export("$summary", `Successfully created attendance entry with ID: ${response._id}`);
75+
return response;
76+
},
77+
};
Lines changed: 149 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,178 @@
11
import kenjo from "../../kenjo.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "kenjo-create-employee",
65
name: "Create Employee",
7-
description: "Creates a new employee in Kenjo. [See the documentation]()",
8-
version: "0.0.{{ts}}",
6+
description: "Creates a new employee in Kenjo. [See the documentation](https://kenjo.readme.io/reference/post_employees)",
7+
version: "0.0.1",
98
type: "action",
109
props: {
1110
kenjo,
12-
createEmployeeName: {
11+
email: {
12+
type: "string",
13+
label: "Email",
14+
description: "The email address of the employee",
15+
},
16+
firstName: {
17+
type: "string",
18+
label: "First Name",
19+
description: "The first name of the employee",
20+
},
21+
lastName: {
22+
type: "string",
23+
label: "Last Name",
24+
description: "The last name of the employee",
25+
},
26+
companyId: {
1327
propDefinition: [
1428
kenjo,
15-
"createEmployeeName",
29+
"companyId",
1630
],
1731
},
18-
createEmployeeEmail: {
32+
weeklyHours: {
33+
type: "integer",
34+
label: "Weekly Hours",
35+
description: "The number of weekly hours that an employee works",
36+
},
37+
officeId: {
1938
propDefinition: [
2039
kenjo,
21-
"createEmployeeEmail",
40+
"officeId",
41+
(c) => ({
42+
companyId: c.companyId,
43+
}),
2244
],
2345
},
24-
createEmployeeDepartment: {
46+
departmentId: {
2547
propDefinition: [
2648
kenjo,
27-
"createEmployeeDepartment",
49+
"departmentId",
2850
],
2951
},
30-
createEmployeeRole: {
31-
propDefinition: [
32-
kenjo,
33-
"createEmployeeRole",
52+
language: {
53+
type: "string",
54+
label: "Language",
55+
description: "The employee's language",
56+
options: [
57+
"en",
58+
"es",
59+
"de",
60+
],
61+
optional: true,
62+
},
63+
birthdate: {
64+
type: "string",
65+
label: "Birthdate",
66+
description: "The birthdate of the employee. Format `YYYY-MM-DDThh:mm:ss.000Z`",
67+
optional: true,
68+
},
69+
jobTitle: {
70+
type: "string",
71+
label: "Job Title",
72+
description: "The job title of the employee",
73+
optional: true,
74+
},
75+
workPhone: {
76+
type: "string",
77+
label: "Work Phone",
78+
description: "The work phone number of the employee",
79+
optional: true,
80+
},
81+
personalPhone: {
82+
type: "string",
83+
label: "Personal Phone",
84+
description: "The personal phone number of the employee",
85+
optional: true,
86+
},
87+
workDays: {
88+
type: "string[]",
89+
label: "Work Days",
90+
description: "The days of the week that the employee works",
91+
options: [
92+
"monday",
93+
"tuesday",
94+
"wednesday",
95+
"thursday",
96+
"friday",
97+
"saturday",
98+
"sunday",
3499
],
100+
optional: true,
101+
},
102+
trackAttendance: {
103+
type: "boolean",
104+
label: "Track Attendance",
105+
description: "Set to `true` to activate attendance tracking for the employee",
106+
optional: true,
107+
},
108+
street: {
109+
type: "string",
110+
label: "Street",
111+
description: "The street address of the employee",
112+
optional: true,
113+
},
114+
postalCode: {
115+
type: "string",
116+
label: "Postal Code",
117+
description: "The postal code of the employee",
118+
optional: true,
119+
},
120+
city: {
121+
type: "string",
122+
label: "City",
123+
description: "The city of the employee",
124+
optional: true,
125+
},
126+
country: {
127+
type: "string",
128+
label: "Country",
129+
description: "The country code in ISO 3166-1 alpha-2. Example: `ES`",
130+
optional: true,
35131
},
36132
},
37133
async run({ $ }) {
134+
const workSchedule = {
135+
trackAttendance: this.trackAttendance,
136+
};
137+
if (this.workDays?.length) {
138+
for (const day of this.workDays) {
139+
workSchedule[`${day}WorkingDay`] = true;
140+
}
141+
}
142+
38143
const response = await this.kenjo.createEmployee({
39-
name: this.createEmployeeName,
40-
email: this.createEmployeeEmail,
41-
department_id: this.createEmployeeDepartment,
42-
role_id: this.createEmployeeRole,
144+
$,
145+
data: {
146+
account: {
147+
email: this.email,
148+
language: this.language,
149+
},
150+
personal: {
151+
firstName: this.firstName,
152+
lastName: this.lastName,
153+
birthdate: this.birthdate,
154+
},
155+
work: {
156+
companyId: this.companyId,
157+
officeId: this.officeId,
158+
departmentId: this.departmentId,
159+
weeklyHours: this.weeklyHours,
160+
jobTitle: this.jobTitle,
161+
workPhone: this.workPhone,
162+
},
163+
workSchedule,
164+
address: (this.street || this.postalCode || this.city || this.country) && {
165+
street: this.street,
166+
postalCode: this.postalCode,
167+
city: this.city,
168+
country: this.country,
169+
},
170+
home: this.personalPhone && {
171+
personalPhone: this.personalPhone,
172+
},
173+
},
43174
});
44-
$.export("$summary", `Created employee ${response.name}`);
175+
$.export("$summary", `Created employee with ID: ${response.account._id}`);
45176
return response;
46177
},
47178
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import kenjo from "../../kenjo.app.mjs";
2+
3+
export default {
4+
key: "kenjo-create-leave-request",
5+
name: "Create Leave Request",
6+
description: "Creates a new leave request in Kenjo. [See the documentation](https://kenjo.readme.io/reference/post_time-off-requests).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
kenjo,
11+
employeeId: {
12+
propDefinition: [
13+
kenjo,
14+
"employeeId",
15+
],
16+
},
17+
timeOffTypeId: {
18+
propDefinition: [
19+
kenjo,
20+
"timeOffTypeId",
21+
],
22+
},
23+
from: {
24+
type: "string",
25+
label: "From",
26+
description: "The starting date of the time-off request in format `YYYY-MM-DD`",
27+
},
28+
to: {
29+
type: "string",
30+
label: "To",
31+
description: "The ending date of the time-off request in format `YYYY-MM-DD`",
32+
},
33+
partOfDayFrom: {
34+
type: "string",
35+
label: "Part of Day From",
36+
description: "The duration of the from date. 'StartOfDay' means that the from date is the entire day. 'HalfOfDay' means that the request starts to apply in the middle of the from day. If not specified, the default value will be 'StartOfDay'.",
37+
options: [
38+
"StartOfDay",
39+
"HalfOfDay",
40+
],
41+
optional: true,
42+
},
43+
partOfDayTo: {
44+
type: "string",
45+
label: "Part of Day To",
46+
description: "The duration of the to date. 'EndOfDay' means that the to date is the entire day. 'HalfOfDay' means the request starts to apply in the middle of the to day. If not specified, the default value will be 'EndOfDay'.",
47+
options: [
48+
"HalfOfDay",
49+
"EndOfDay",
50+
],
51+
optional: true,
52+
},
53+
description: {
54+
type: "string",
55+
label: "Description",
56+
description: "The description of the time-off request",
57+
optional: true,
58+
},
59+
},
60+
async run({ $ }) {
61+
const response = await this.kenjo.createLeaveRequest({
62+
$,
63+
data: {
64+
_userId: this.employeeId,
65+
_timeOffTypeId: this.timeOffTypeId,
66+
from: this.from,
67+
to: this.to,
68+
partOfDayFrom: this.partOfDayFrom,
69+
partOfDayTo: this.partOfDayTo,
70+
description: this.description,
71+
},
72+
});
73+
$.export("$summary", `Successfully created leave request with ID: ${response._id}`);
74+
return response;
75+
},
76+
};

components/kenjo/actions/generate-payslip/generate-payslip.mjs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)