pull:初次提交

This commit is contained in:
Yep_Q
2025-09-08 04:48:28 +08:00
parent 5c0619656d
commit f64f498365
11751 changed files with 1953723 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
import { updateEmployeeSharedDescription } from './sharedDescription';
import type { EmployeeProperties } from '../../Interfaces';
export const employeeUpdateDescription: EmployeeProperties = [
{
displayName: 'Employee ID',
name: 'employeeId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: ['update'],
resource: ['employee'],
},
},
default: '',
},
{
displayName: 'Synced with Trax Payroll',
name: 'synced',
type: 'boolean',
required: true,
displayOptions: {
show: {
operation: ['update'],
resource: ['employee'],
},
},
default: false,
description:
'Whether the employee to create was added to a pay schedule synced with Trax Payroll',
},
...(updateEmployeeSharedDescription(true) as EmployeeProperties),
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
operation: ['update'],
resource: ['employee'],
},
},
options: [
...updateEmployeeSharedDescription(false),
{
displayName: 'Work Email',
name: 'workEmail',
type: 'string',
default: '',
},
{
displayName: 'Work Phone',
name: 'workPhone',
type: 'string',
default: '',
},
],
},
];

View File

@@ -0,0 +1,103 @@
import { capitalCase } from 'change-case';
import moment from 'moment-timezone';
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';
import { apiRequest } from '../../../transport';
export async function update(
this: IExecuteFunctions,
index: number,
): Promise<INodeExecutionData[]> {
let body: IDataObject = {};
const requestMethod = 'POST';
//meta data
const id = this.getNodeParameter('employeeId', index) as string;
//endpoint
const endpoint = `employees/${id}`;
//body parameters
body = this.getNodeParameter('updateFields', index);
const updateFields = this.getNodeParameter('updateFields', index);
const synced = this.getNodeParameter('synced', index) as boolean;
if (synced) {
Object.assign(body, {
address: this.getNodeParameter('address.value', index, {}) as IDataObject,
});
Object.assign(body, {
payRate: this.getNodeParameter('payRate.value', index, {}) as IDataObject,
});
body.firstName = this.getNodeParameter('firstName', index) as string;
body.lastName = this.getNodeParameter('lastName', index) as string;
body.department = this.getNodeParameter('department', index) as string;
body.dateOfBirth = this.getNodeParameter('dateOfBirth', index) as string;
body.division = this.getNodeParameter('division', index) as string;
body.employeeNumber = this.getNodeParameter('employeeNumber', index) as string;
body.exempt = this.getNodeParameter('exempt', index) as string;
body.gender = this.getNodeParameter('gender', index) as string;
body.hireDate = this.getNodeParameter('hireDate', index) as string;
body.location = this.getNodeParameter('location', index) as string;
body.maritalStatus = this.getNodeParameter('maritalStatus', index) as string;
body.mobilePhone = this.getNodeParameter('mobilePhone', index) as string;
body.paidPer = this.getNodeParameter('paidPer', index) as string;
body.payType = this.getNodeParameter('payType', index) as string;
body.preferredName = this.getNodeParameter('preferredName', index) as string;
body.ssn = this.getNodeParameter('ssn', index) as string;
} else {
if (!Object.keys(updateFields).length) {
throw new NodeOperationError(this.getNode(), 'At least one fields must be updated');
}
Object.assign(body, {
address: this.getNodeParameter('updateFields.address.value', index, {}) as IDataObject,
});
Object.assign(body, {
payRate: this.getNodeParameter('updateFields.payRate.value', index, {}) as IDataObject,
});
delete updateFields.address;
delete updateFields.payRate;
}
Object.assign(body, updateFields);
if (body.gender) {
body.gender = capitalCase(body.gender as string);
}
if (body.dateOfBirth) {
body.dateOfBirth = moment(body.dateOfBirth as string).format('YYYY-MM-DD');
}
if (body.exempt) {
body.exempt = capitalCase(body.exempt as string);
}
if (body.hireDate) {
body.hireDate = moment(body.hireDate as string).format('YYYY-MM-DD');
}
if (body.maritalStatus) {
body.maritalStatus = capitalCase(body.maritalStatus as string);
}
if (body.payType) {
body.payType = capitalCase(body.payType as string);
}
if (body.paidPer) {
body.paidPer = capitalCase(body.paidPer as string);
}
if (!Object.keys(body.payRate as IDataObject).length) {
delete body.payRate;
}
await apiRequest.call(this, requestMethod, endpoint, body);
//return
return this.helpers.returnJsonArray({ success: true });
}

View File

@@ -0,0 +1,4 @@
import { employeeUpdateDescription as description } from './description';
import { update as execute } from './execute';
export { description, execute };

View File

@@ -0,0 +1,344 @@
import type { INodeProperties } from 'n8n-workflow';
export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] => {
let elements: INodeProperties[] = [
{
displayName: 'Address',
name: 'addasasress',
placeholder: 'Address',
type: 'fixedCollection',
typeOptions: {
multipleValues: false,
},
default: {},
options: [
{
name: 'value',
displayName: 'Address',
values: [
{
displayName: 'Line 1',
name: 'address1',
type: 'string',
default: '',
},
{
displayName: 'Line 2',
name: 'address2',
type: 'string',
default: '',
},
{
displayName: 'City',
name: 'city',
type: 'string',
default: '',
},
{
displayName: 'State',
name: 'state',
type: 'string',
default: '',
placeholder: 'Florida',
description: 'The full name of the state/province',
},
{
displayName: 'Country',
name: 'country',
type: 'string',
default: '',
placeholder: 'United States',
description: 'The name of the country. Must exist in the BambooHr country list.',
},
],
},
],
},
{
displayName: 'Date of Birth',
name: 'dateOfBirth',
type: 'dateTime',
default: '',
},
{
displayName: 'Department Name or ID',
name: 'department',
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getDepartments',
},
default: '',
},
{
displayName: 'Division Name or ID',
name: 'division',
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getDivisions',
},
default: '',
},
{
displayName: 'Employee Number',
name: 'employeeNumber',
type: 'string',
default: '',
},
{
displayName: 'First Name',
name: 'firstName',
type: 'string',
displayOptions: {
show: {
synced: [false],
},
},
default: '',
},
{
displayName: 'Last Name',
name: 'lastName',
type: 'string',
displayOptions: {
show: {
synced: [false],
},
},
default: '',
},
{
displayName: 'FLSA Overtime Status',
name: 'exempt',
type: 'options',
options: [
{
name: 'Exempt',
value: 'exempt',
},
{
name: 'Non-Exempt',
value: 'non-exempt',
},
],
default: '',
},
{
displayName: 'Gender',
name: 'gender',
type: 'options',
options: [
{
name: 'Female',
value: 'female',
},
{
name: 'Male',
value: 'male',
},
],
default: '',
},
{
displayName: 'Hire Date',
name: 'hireDate',
type: 'dateTime',
default: '',
},
{
displayName: 'Location Name or ID',
name: 'location',
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getEmployeeLocations',
},
default: '',
},
{
displayName: 'Marital Status',
name: 'maritalStatus',
type: 'options',
options: [
{
name: 'Single',
value: 'single',
},
{
name: 'Married',
value: 'married',
},
{
name: 'Domestic Partnership',
value: 'domesticPartnership',
},
],
default: '',
},
{
displayName: 'Mobile Phone',
name: 'mobilePhone',
type: 'string',
default: '',
},
{
displayName: 'Pay Per',
name: 'paidPer',
type: 'options',
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
options: [
{
name: 'Hour',
value: 'hour',
},
{
name: 'Day',
value: 'day',
},
{
name: 'Week',
value: 'week',
},
{
name: 'Month',
value: 'month',
},
{
name: 'Quater',
value: 'quater',
},
{
name: 'Year',
value: 'year',
},
],
default: '',
},
{
displayName: 'Pay Rate',
name: 'payRate',
placeholder: 'Add Pay Rate',
type: 'fixedCollection',
typeOptions: {
multipleValues: false,
},
default: {},
options: [
{
name: 'value',
displayName: 'Pay Rate',
values: [
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
placeholder: '20.00',
},
{
displayName: 'Currency',
name: 'currency',
type: 'string',
default: '',
placeholder: 'USD',
},
],
},
],
},
{
displayName: 'Pay Type',
name: 'payType',
type: 'options',
options: [
{
name: 'Commission',
value: 'commission',
},
{
name: 'Contract',
value: 'contract',
},
{
name: 'Daily',
value: 'daily',
},
{
name: 'Exception Hourly',
value: 'exceptionHourly',
},
{
name: 'Hourly',
value: 'hourly',
},
{
name: 'Monthly',
value: 'monthly',
},
{
name: 'Piece Rate',
value: 'pieceRate',
},
{
name: 'Pro Rata',
value: 'proRata',
},
{
name: 'Salary',
value: 'salary',
},
{
name: 'Weekly',
value: 'weekly',
},
],
default: '',
},
{
displayName: 'Preferred Name',
name: 'preferredName',
type: 'string',
default: '',
},
{
displayName: 'Social Security Number',
name: 'ssn',
type: 'string',
default: '',
placeholder: '123-45-6789',
description: 'A standard United States Social Security number, with dashes',
},
];
if (sync) {
elements = elements.map((element) => {
return Object.assign(element, {
displayOptions: {
show: {
resource: ['employee'],
operation: ['update'],
synced: [true],
},
},
required: true,
});
});
return elements;
} else {
elements = elements.map((element) => {
return Object.assign(element, {
displayOptions: {
show: {
'/synced': [false],
},
},
});
});
}
return elements;
};