Closed usmanmunirr closed 3 years ago
Hi SidneyAllen,
Any update on this one or ETA on getting this bug fixed in the SDK ? Your help will be greatly appreciated.
Hi @usmanmunirr
I've looked at this and found that you need to split this into two API calls.
First create the Employee with the basic information. including the OrdinaryEarningsRateID and PayrollCalendarID
Then you can update the new Employee and with and array of LeaveBalance, array of LeaveLine and payTemplate and the openingBalances
Hi @SidneyAllen,
Thanks for letting me know. I will try splitting the two API calls and will get back to you on this one. I will keep this issue open and will close once its all working.
Hi @SidneyAllen,
This is definitely a bug in SDK. I am not able to update leaveLine() nor leaveBalances() via separate calls. Could you please advise what should be next course of action. I have tried to debug everything. But found no issue at all.
Just FYI - i am using the updated SDK library as well.
This is code i am using:
$xeroEmpID = '5e4a0b15-daff-4275-a126-84f3f0155fc3';
//leave types
$leaveTypes = new XeroAPI\XeroPHP\Models\PayrollAU\LeaveType;
$leaveTypes->setLeaveTypeId('f1cb5696-71ae-4d28-a3c7-e61cb869cb30');
$leaveTypes->setName('Name');
$leaveTypes->setNormalEntitlement(01);
$leaveTypes->setLeaveLoadingRate(01);
$leaveTypes->setTypeOfUnits('03');
$newLeaveTypes = [$leaveTypes];
$employee->setLeaveBalances($newLeaveTypes);
//leave Lines
$leaveLines = new XeroAPI\XeroPHP\Models\PayrollAU\LeaveLine;
$leaveLines->setLeaveTypeId('f1cb5696-71ae-4d28-a3c7-e61cb869cb30');
$leaveLines->setNumberOfUnits(05);
$leaveLines->setCalculationType(\XeroAPI\XeroPHP\Models\PayrollAu\LeaveLineCalculationType::BASEDONORDINARYEARNINGS);
$leaveLines->setAnnualNumberOfUnits(160);
$leaveLines->setFullTimeNumberOfUnitsPerPeriod(3);
$leaveLines->setEmploymentTerminationPaymentType(\XeroAPI\XeroPHP\Models\PayrollAu\EmploymentTerminationPaymentType::R);
$leaveLines->setEntitlementFinalPayPayoutType(\XeroAPI\XeroPHP\Models\PayrollAu\EntitlementFinalPayPayoutType::PAIDOUT);
$leaveLines->setIncludeSuperannuationGuaranteeContribution(true);
$updatedEmployee = [];
array_push($updatedEmployee, $employee);
//request
try {
$result = $this->getApiInstance()->updateEmployee($this->getTenentID(), $xeroEmpID, $updatedEmployee);
var_dump( $result->getEmployees()[0])
} catch (\XeroAPI\XeroPHP\ApiException $e) {
var_dump($e);
}
@usmanmunirr - I just wrote up an example where an employee is created and then updated with the leaveLines. Some UUIDs are hard coded, so you'll need to adjust the code for your use. I tested this on the Demo Company and it works successfully.
$where = "EarningsType==\"ORDINARYTIMEEARNINGS\"";
$payItemsOrdinary = $payrollAuApi->getPayItems($xeroTenantId,null, $where);
$ordinaryEarningsRateID = $payItemsOrdinary->getPayItems()->getEarningsRates()[0]->getEarningsRateID();
$payItems = $payrollAuApi->getPayItems($xeroTenantId);
$leaveTypeID = $payItems->getPayItems()->getLeaveTypes()[0]->getLeaveTypeID();
$employee = new XeroAPI\XeroPHP\Models\PayrollAu\Employee;
$employee->setFirstName("Fred");
$employee->setLastName("Potter");
$employee->setEmail("albus@hogwarts.edu");
$dateOfBirth = DateTime::createFromFormat('m/d/Y', '05/29/2000');
$employee->setDateOfBirthAsDate($dateOfBirth);
$dateStart = DateTime::createFromFormat('m/d/Y', '01/29/2020');
$employee->setStartDateAsDate($dateStart);
$address = new XeroAPI\XeroPHP\Models\PayrollAu\HomeAddress;
$address->setAddressLine1("101 Green St");
$address->setCity("Island Bay");
$address->setRegion(\XeroAPI\XeroPHP\Models\PayrollAu\State::NSW);
$address->setCountry("AUSTRALIA");
$address->setPostalCode("6023");
$employee->setHomeAddress($address);
$employee->setGender(\XeroAPI\XeroPHP\Models\PayrollAu\Employee::GENDER_M);
$employee->setIsAuthorisedToApproveLeave(true);
$employee->setIsAuthorisedToApproveTimesheets(true);
$employee->setClassification("corporate");
$employee->setJobTitle("Regional Manager");
$employee->setMobile("555-1212");
$employee->setPhone("444-2323");
$employee->setStatus(\XeroAPI\XeroPHP\Models\PayrollAu\EmployeeStatus::ACTIVE);
$employee->setOrdinaryEarningsRateID("07fd72fd-353a-4327-9c5a-586404f87bb8");
$employee->setPayrollCalendarID("bd1389de-e9a0-4138-a19e-aa048f262dda");
$newEmployees = [];
array_push($newEmployees, $employee);
$result = $payrollAuApi->createEmployee($xeroTenantId, $newEmployees);
$employeeID = $result->getEmployees()[0]->getEmployeeId();
$upEmployees = new XeroAPI\XeroPHP\Models\PayrollAu\Employees;
$upEmployee = new XeroAPI\XeroPHP\Models\PayrollAu\Employee;
$arrayLeaveBalances = [];
$leaveBalance = new XeroAPI\XeroPHP\Models\PayrollAu\LeaveBalance;
$leaveBalance->setLeaveTypeID($leaveTypeID);
$leaveBalance->setTypeOfUnits("20");
array_push($arrayLeaveBalances, $leaveBalance);
$upEmployee->setLeaveBalances($arrayLeaveBalances);
$arrayLeaveLines = [];
$leaveLine = new XeroAPI\XeroPHP\Models\PayrollAu\LeaveLine;
$leaveLine->setNumberOfUnits(20.0);
$leaveLine->setLeaveTypeID("8b85d26f-1d9f-4011-ba10-81036a2139cb");
$leaveLine->setCalculationType(\XeroAPI\XeroPHP\Models\PayrollAu\LeaveLineCalculationType::BASEDONORDINARYEARNINGS);
$leaveLine->setAnnualNumberOfUnits(20.0);
$leaveLine->setFullTimeNumberOfUnitsPerPeriod(20.0);
array_push($arrayLeaveLines, $leaveLine);
$payTemplate = new XeroAPI\XeroPHP\Models\PayrollAu\PayTemplate;
$arrayEarningsLines = [];
$earningsLine = new XeroAPI\XeroPHP\Models\PayrollAu\EarningsLine;
$earningsLine->setEarningsRateID($ordinaryEarningsRateID);
$earningsLine->setCalculationType(\XeroAPI\XeroPHP\Models\PayrollAu\EarningsRateCalculationType::ANNUALSALARY);
$earningsLine->setAnnualSalary(100000.00);
$earningsLine->setNumberOfUnitsPerWeek(100.00);
array_push($arrayEarningsLines, $earningsLine);
$payTemplate->setEarningsLines($arrayEarningsLines);
$payTemplate->setLeaveLines($arrayLeaveLines);
$upEmployee->setPayTemplate($payTemplate);
$openingBalances = new XeroAPI\XeroPHP\Models\PayrollAu\OpeningBalances;
$openingBalances->setLeaveLines($arrayLeaveLines);
$upEmployee->setOpeningBalances($openingBalances);
$arrayEmployees = [];
array_push($arrayEmployees, $upEmployee);
$employeeUpdated = $payrollAuApi->updateEmployee($xeroTenantId, $employeeID, $arrayEmployees);
`
SDK you're using (please complete the following information):
Describe the bug Leave Types not being added when adding new employee in to PayrollAU
To Reproduce Steps to reproduce the behavior:
setLeaveLines()
orsetLeaveBalances()
Expected behavior Leave types should be added when the new employee is added successfully
Screenshots
Additional context