xero-php
xero-php copied to clipboard
How to retrieve LEAVES for employee?
I am retrieving list of all employees:
$data = $xero->load(\XeroPHP\Models\Accounting\Employee::class)->execute();
How can I retrieve all leaves for this employee?
vendor/calcinai/xero-php/src/XeroPHP/Models/PayrollUK/Employee/Leave.php
Is there a way to retrieve more data about employee, e.g. email address? I can only access the user ID + First Name + Last Name.
Hi @pdolinaj, it looks like this might need to be added to the model. Have a look at the Employee/Employment model as a guide (it uses the same api structure) and feel free to make a PR.
Sing out if you have any issues.
Thanks, I'll have a look at it.
On another note, I was trying to create a Leave for employee but I'm facing 2 issues:
$xero = new \XeroPHP\Application($access_token, $tenant_id);
$employee_id = 'e752b13c-a157-4bc1-92aa-493c588a5365';
$leave = new \XeroPHP\Models\PayrollUK\Employee\Leave($xero);
$leave->setStartDate(new \DateTime('2023-07-01'));
$leave->setEndDate(new \DateTime('2023-07-07'));
$leave->setDescription('Holiday Test');
$leave->save();
- It complains that it's missing the LeaveTypeId
XeroPHP\Remote\Exception XeroPHP\Models\PayrollUK\Employee\Leave::$LeaveTypeID is mandatory and is either missing or empty.
- There's no way to set the EmployeeId when creating the leave.
Any ideas please?
This one would need an update to make it work I reckon since you actually need to send to a different URL, and I'm not sure how the codebase handles this.
POST https://api.xero.com/payroll.xro/2.0/employees/35cdd697-c9fc-4931-b579-a18cb8b6fe14/leave
So it might need a change to getAPIStem() to add the employee ID to the URL if one exists?