myoutdesk/prismapi

1.1.1 2021-02-16 17:20 UTC

This package is auto-updated.

Last update: 2024-09-17 01:21:44 UTC


README

PrismHR API 的临时仓库。以下是一份指南。

初始需求

以下信息

  1. PEO ID 从系统参数页面获取(后台办公室 -> 系统 -> 更改 -> 系统参数
  2. Web Service 用户 系统 -> 更改 -> 系统参数 -> 操作菜单 -> "Web 服务用户"。这些凭据将在调用 API 时使用。
  3. ClientID (公司 ID) 这需要在前端获取。可以在“我的公司”仪表板上找到。所有员工都必须在这家公司之下。

认证

$api = new \Myoutdesk\PrismApi\PrismApi();
// Throws Authentication Exception if failure occurs
$api->authenticate('WEB_USER_USERNAME','WEB_USER_PASSWORD','PEO_ID');
$api->getSession();

获取所有员工

$api = new \Myoutdesk\PrismApi\PrismApi();
// Authenticate here...
$employees = $api->getAllEmployees('1111');

获取一个或多个员工

$api = new \Myoutdesk\PrismApi\PrismApi();
// Authenticate here...
$employee = $api->getEmployee('F72609', '1111');
// Or get multiple
$arrayOfEmployee = $api->getEmployees(['F72609','D68213'], '1111');

创建工资批次

需要工资批次来上传考勤表。使用 findOrCreatePayrollBatch 来完成此操作。必须设置员工列表。

$api = new \Myoutdesk\PrismApi\PrismApi();
// Create a payroll batch for a list of employees
$api->findOrCreatePayrollBatch(new \DateTime('now', new \DateTimeZone('UTC')), 'COMPANY_ID', ['EMPLOYEE_ID']);

创建 MyTimeIn 工资导入定义

为了上传考勤表,必须通过后端菜单 系统 - 更改 - 工资导入定义 指定工资导入定义。以下必须设置

定义 ID: MyTimeIn

描述: MyTimeIn 导入

文件格式: 分隔符

分隔符: 逗号

导入字段定义 配置导入字段定义如下

MyTimeIn 将使用 REG 或 OT 在 CODE 列中与 Prism 进行通信。

用于配置 MyTimeIn 的公司必须能够访问此工资导入定义

上传考勤表

上传考勤表有一定的流程,以便正常工作。以下必须按顺序完成

构建 CSV 数据

构建数据以发送到 Prism,包括:EMPID、DATE(MM/DD/YYYY)、HRS、CSV 格式中的 "REG" 或 "OT"。捆绑了一个 CSV 辅助工具来协助此过程

$api = new \Myoutdesk\PrismApi\PrismApi();
$csv = $api->getCsvService();
// Example Data
$dataToWrite =[
  ['X1', "12/07/2020", 8, "REG"],
  ['X2', "12/06/2020", 8, "REG"],
  ['X3', "12/05/2020", 8, "REG"],
  ['X4', "12/08/2020", 8, "REG"]
];
// Make a string version
$timesheetData = $csv->createFromData($dataToWrite);

创建工资批次

$api = new \Myoutdesk\PrismApi\PrismApi();
// authenticate here
$now = new DateTime('now', new DateTimeZone('UTC'));
$payrollBatchId = $api->findOrCreatePayrollBatch($now, 'COMPANY_ID', ['X1', 'X2', 'X3', 'X4']);

将考勤表上传到批次

$api = new \Myoutdesk\PrismApi\PrismApi();
// auth, etc...
// Process the upload
$timesheetUpload = $api->uploadTimesheets('BATCHID', 'COMPANY_ID', 'USERNAME', 'CSV_STRING_OF_DATA_HERE');
// Make sure to store the key aka the uploadId
$uploadId = $timesheetUpload->getUploadKey();
// If you don't, fetch it from here as it is in progress and will be in the array of batches
$pendingBatches = $api->getTimesheetParamData('COMPANY_ID');
// If there are any errors, handle them here and keep retrying this step of uploading timesheets
if($timesheetUpload->hasErrors()) {
    return json_encode($timesheetUpload->getErrors());
}

批准上传

一旦考勤表响应无错误,则可以批准上传。

$api = new \Myoutdesk\PrismApi\PrismApi();
// auth, etc...
$api->approveTimesheetUpload('TIMESHEETUPLOAD_KEY', '1111', 'username', 'TIMESHEET_UPLOAD_KEY');

批准后

一旦批准了批次的上传,条目将出现在 PrismHR 的 工资-操作-考勤表条目 下,由最终用户进行批准。