0

I am using this wrapper

I can successfully add a blank timesheet for an employee, however when I try to add a timesheet line I am getting a Bad Request response.

Can someone please point me in the right direction???

My PHP code is:

$numberOfUnits = array ("1", "2", "3", "4", "5", "6", "7");

$timesheetLines = new \XeroPHP\Models\PayrollAU\Timesheet\TimesheetLine($xero);

$timesheetLines ->setEarningsRateID ($earningsRateID)
                ->setTrackingItemID (NULL)
                ->addNumberOfUnit ($numberOfUnits);

$timesheet = new \XeroPHP\Models\PayrollAU\Timesheet($xero);

$timesheet  ->setTimesheetID($timesheetID)
            ->setEmployeeID ($employeeID)
            ->setStartDate(new DateTime('2018-10-01'))
            ->setEndDate(new DateTime('2018-10-14'))
            ->setStatus("DRAFT")
            ->addTimesheetLine($timesheetLines);

$timesheet->save();
Vinay
  • 7,442
  • 6
  • 25
  • 48

1 Answers1

0

Your start date and end date shows that you are trying to add data for fortnightly .i.e. 2 weeks. However your numberOfUnits array contains only 7 items.

$numberOfUnits = array ("1", "2", "3", "4", "5", "6", "7");

$timesheetLines = new \XeroPHP\Models\PayrollAU\Timesheet\TimesheetLine($xero);

foreach($numberOfUnits as $unit ){

   $timesheetLines->addNumberOfUnit($unit)

}
rdkrosan
  • 111
  • 1
  • 7