第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Xero API php 包裝器的 createTimesheet 出現(xiàn) 500 錯(cuò)誤

Xero API php 包裝器的 createTimesheet 出現(xiàn) 500 錯(cuò)誤

PHP
UYOU 2023-09-22 17:09:23
我正在使用 Xero API php 包裝器來(lái)發(fā)布時(shí)間表,除了“發(fā)生錯(cuò)誤”和狀態(tài) 500 之外,沒(méi)有返回任何詳細(xì)信息。我正在驗(yàn)證,它包含在范圍內(nèi),據(jù)我所知,它是所請(qǐng)求格式的有效 json...[{"EmployeeID":"a valid employee id","StartDate":"2020-08-03","EndDate":"2020-08-09","Status":"Draft","TimesheetLines":{"TimesheetLine":[{"EarningsRateID":"a valid pay item id","NumberOfUnits":{"NumberOfUnit":["0.00","0.00","8","0.00","0.00","0.00","0.00"]}},{"EarningsRateID":"a valid pay item id","NumberOfUnits":{"NumberOfUnit":["0.00","0.00","0.00","8.5","0.00","0.00","0.00"]}},{"EarningsRateID":"a valid pay item id","NumberOfUnits":{"NumberOfUnit":["0.00","0.00","0.00","0.00","8","0.00","0.00"]}},{"EarningsRateID":"a valid pay item id","NumberOfUnits":{"NumberOfUnit":["0.00","0.00","0.00","0.00","0.00","8","0.00"]}},{"EarningsRateID":"a valid pay item id","NumberOfUnits":{"NumberOfUnit":["0.00","0.00","0.00","0.00","0.00","0.00","8.5"]}}]}}]這是通過(guò)...發(fā)送的try {      $result = $payrollAuApi->createTimesheet($xeroTenantId, $timesheet);      print_r($result);  } catch (Exception $e) {      echo 'Exception when calling PayrollAuApi->createTimesheet: ', $e->getMessage(), PHP_EOL;  }并且tenantID沒(méi)問(wèn)題。我很感激任何關(guān)于我出錯(cuò)的地方的指導(dǎo)。
查看完整描述

2 回答

?
明月笑刀無(wú)情

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個(gè)贊

看起來(lái)您的 TimesheetLines 是一個(gè)包含名為 TimesheetLine 的屬性的對(duì)象,它是一個(gè)集合 - 但根據(jù)文檔, TimesheetLines 本身應(yīng)該是時(shí)間表行的集合。

即你應(yīng)該有類似的東西:

[{ EmployeeID : 4fd71c0f-8612-4fd8-99d0-b3a2e8272b02 , StartDate : 2020-08-03 , EndDate : 2020-08-09 , Status : Draft , TimesheetLines :[{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 8 , 0.00 , 0.00 , 0.00 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 8.5 , 0.00 , 0.00 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 0.00 , 8 , 0.00 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 0.00 , 0.00 , 8 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 0.00 , 0.00 , 0.00 , 8.5 ]}}]}]

...代替...

[{ EmployeeID : 4fd71c0f-8612-4fd8-99d0-b3a2e8272b02 , StartDate : 2020-08-03 , EndDate : 2020-08-09 , Status : Draft , TimesheetLines :{ TimesheetLine :[{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 8 , 0.00 , 0.00 , 0.00 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 8.5 , 0.00 , 0.00 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 0.00 , 8 , 0.00 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 0.00 , 0.00 , 8 , 0.00 ]}},{ EarningsRateID : 0e30f933-04ed-4b96-9357-9747209c306f , NumberOfUnits :{ NumberOfUnit :[ 0.00 , 0.00 , 0.00 , 0.00 , 0.00 , 0.00 , 8.5 ]}}]}}]

改變這個(gè)有幫助嗎?


查看完整回答
反對(duì) 回復(fù) 2023-09-22
?
萬(wàn)千封印

TA貢獻(xiàn)1891條經(jīng)驗(yàn) 獲得超3個(gè)贊

對(duì)于遇到此問(wèn)題的任何人來(lái)說(shuō),問(wèn)題在于,與我在私人應(yīng)用程序中使用的舊包裝器不同,我在私人應(yīng)用程序中構(gòu)建了完整的 XML 時(shí)間表并發(fā)送它,Xero 的 oauth2 包裝器并不需要完整的時(shí)間表。相反,您創(chuàng)建時(shí)間表的實(shí)例并為其設(shè)置屬性。

代碼積分從存儲(chǔ)庫(kù)轉(zhuǎn)到@wobinb

$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()-?

>setAccessToken( (string)$storage->getAccessToken() );

$payrollApi = new XeroAPI\XeroPHP\Api\PayrollAuApi(

? new GuzzleHttp\Client(),

? $config

);


//first retrieve a list of active employees

$apiResponse = $payrollApi->getEmployees($tenantId, null, "Status==\"ACTIVE\"");

$employees = $apiResponse->getEmployees();

foreach ($employees AS $employee) {

? print $employee->getFirstName()." ".$employee->getLastName()." - ".$employee->getPayrollCalendarID();

? ?if ($employee->getPayrollCalendarID() != null) {

? ? ?$employeeID = $employee->getEmployeeID();

? ? ?$payrollCalendarID = $employee->getPayrollCalendarID();

? ? ?$ordinaryEarningsRateID = $employee->getOrdinaryEarningsRateID();

? ?}

? ?print "<br />";

}

print "<br />";

//and now the payroll calendar

$apiResponse = $payrollApi->getPayrollCalendar($tenantId,$payrollCalendarID);

$calendar = $apiResponse->getPayrollCalendars()[0];

print $calendar->getName()." - ".$calendar->getCalendarType();

print "<br />";


//finally create the timesheet

$timesheet = new XeroAPI\XeroPHP\Models\PayrollAu\Timesheet();

$timesheet->setEmployeeID($employeeID);

$timesheet->setStartDateAsDate($calendar->getStartDateAsDate());

//need to calculate how many days the timesheet will cover

switch ($calendar->getCalendarType()) {

? case "WEEKLY":

? ? $lengthofCalendar = 7;

? ? break;

? case "FORTNIGHTLY":

? ? $lengthofCalendar = 14;

? ? break;

? case "FOURWEEKLY":

? ? $lengthofCalendar = 28;

? ? break;

//monthly pay runs will be more complicated to calculate??

}

$endDate = $calendar->getStartDateAsDate();

//end date will be start date plus the length and minus one day

$period = "P". ($lengthofCalendar - 1) . "D";

$endDate->add(new DateInterval($period));

$timesheet->setEndDateAsDate($endDate);

$timesheet->setStatus("DRAFT");

$timesheetLine = new XeroAPI\XeroPHP\Models\PayrollAu\TimesheetLine();

$timesheetLine->setEarningsRateId($ordinaryEarningsRateID);

for ($day = 1; $day <= $lengthofCalendar; $day++) {?

? $numberOfUnits[] = $day;

}

$timesheetLine->setNumberOfUnits($numberOfUnits);

$timesheetLines[] = $timesheetLine;

$timesheet->setTimeSheetLines($timesheetLines);

$timesheets[] = $timesheet;

$apiResponse = $payrollApi->createTimesheet($tenantId,$timesheets);


查看完整回答
反對(duì) 回復(fù) 2023-09-22
  • 2 回答
  • 0 關(guān)注
  • 138 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)