XeroAPI / xero-php-oauth2

Xero PHP SDK for oAuth 2 generated from Xero API OpenAPI Spec 3.0
MIT License
93 stars 66 forks source link

Error on setStatus when pushing new Invoice to Bills #146

Closed Sam-Othman closed 4 years ago

Sam-Othman commented 4 years ago

SDK you're using (please complete the following information):

Describe the bug When I try to use setStatus it will let me create an invoice with any status except for 'AUTHORISED'. I am unsure if I am doing something wrong. Please see code below:

$invoice ->setStatus('AUTHORISED') ->setType('ACCPAY') ->setContact($contact['contacts'][0]) ->setInvoiceNumber($invoice_number) ->setDate($invoice_date) ->setDueDate($due_date) ->setLineAmountTypes($tax_type) ->setLineItems($arr_lineitems);

When I use AUTHORISED it will give me the below:

PHP Fatal error: Uncaught XeroAPI\XeroPHP\ApiException: [400] Client error: PUT https://api.xero.com/api.xro/2.0/Invoices?summarizeErrors=true resulted in a 400 Bad Request response: { "ErrorNumber": 10, "Type": "ValidationException", "Message": "A validation exception occurred", "Elements" (truncated...) in D:\inetpub\wwroot\ithub-staging\resources\vendor\xeroapi\xero-php-oauth2\lib\Api\AccountingApi.php:8579 Stack trace:

0 D:\inetpub\wwroot\ithub-staging\resources\vendor\xeroapi\xero-php-oauth2\lib\Api\AccountingApi.php(8552): XeroAPI\XeroPHP\Api\AccountingApi->createInvoicesWithHttpInfo('1e7b23e5-abaf-4...', Object(XeroAPI\XeroPHP\Models\Accounting\Invoice), true, NULL)

1 D:\inetpub\wwroot\ithub-staging\resources\vendor\xeroapi\xero-php-oauth2\xero-push-invoice.php(103): XeroAPI\XeroPHP\Api\AccountingApi->createInvoices('1e7b23e5-abaf-4...', Object(XeroAPI\XeroPHP\Models\Accounting\Invoice), true)

2 {main}

thrown in D:\inetpub\wwroot\ithub-staging\resources\vendor\xeroapi\xero-php-oauth2\lib\Api\AccountingApi.php on line 8579

To Reproduce Steps to reproduce the behavior: Try to push an invoice into Xero and use AUTHORISED as the status. All other statuses seem to work

Expected behavior I thought it should put the bill into the "Awaiting Payment" section of "Bills"

Sam-Othman commented 4 years ago

Sorry guys, I just found the API key history in the dev portal and that gave me some info regarding the error which was related to the date range being locked.