XeroAPI / xero-php-oauth2

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

getInvoiceByInvoiceNumber is needed in AccountingApi #239

Closed Amberon closed 3 years ago

Amberon commented 3 years ago

Version 2.6.0

getInvoiceByInvoiceNumber is missing in AccountingApi. There is getContactByContactNumber but no such method for Invoice

willhemming commented 3 years ago

You can do this via getInvoices

https://xeroapi.github.io/xero-php-oauth2/docs/v2/accounting/index.html#api-Accounting-getInvoices

Put the invoice number you want in the array $invoiceNumbers, you can set most of the other values to null and it will return matching records

SerKnight commented 3 years ago

@willhemming got it!

Code example for ya:

$if_modified_since = new \DateTime("2019-01-02T19:20:30+01:00"); // \DateTime | Only records created or modified since this timestamp will be returned
$if_modified_since = null;
$where = 'Type=="ACCREC"'; // string
$where = null;
$order = null; // string
$ids = null; // string[] | Filter by a comma-separated list of Invoice Ids.
$invoice_numbers = "INV-0039"; // string[] |  Filter by a comma-separated list of Invoice Numbers.
$contact_ids = null; // string[] | Filter by a comma-separated list of ContactIDs.
$statuses = array("DRAFT", "SUBMITTED");;
$page = 1; // int | e.g. page=1 – Up to 100 invoices will be returned in a single API call with line items
$include_archived = null; // bool | e.g. includeArchived=true - Contacts with a status of ARCHIVED will be included
$created_by_my_app = null; // bool | When set to true you'll only retrieve Invoices created by your app
$unitdp = null; // int | e.g. unitdp=4 – You can opt in to use four decimal places for unit amounts

$apiResponse = $apiInstance->getInvoices($xeroTenantId, $if_modified_since, $where, $order, $ids, $invoice_numbers, $contact_ids, $statuses, $page, $include_archived, $created_by_my_app, $unitdp);