Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retrieve LEAVES for employee? #896

Open
pdolinaj opened this issue Jul 10, 2023 · 3 comments
Open

How to retrieve LEAVES for employee? #896

pdolinaj opened this issue Jul 10, 2023 · 3 comments

Comments

@pdolinaj
Copy link

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.

@calcinai
Copy link
Owner

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.

@pdolinaj
Copy link
Author

pdolinaj commented Jul 11, 2023

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();
  1. 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.

  1. There's no way to set the EmployeeId when creating the leave.

Any ideas please?

@Healyhatman
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants