XeroAPI/xero-php-oauth2

how to set / Edit newly created invoice branding theme

redlaw03 opened this issue · 2 comments

Hi
I am able to create an invoice using the xero sdk(https://github.com/XeroAPI/xero-php-oauth2) with php no problem.
Question: how do I set the newly created invoice 'Terms & Payment Advice (Invoice and Statement)' which usually falls under https://go.xero.com/InvoiceSettings/InvoiceSettings.aspx in the xero console but in php using the api?
image

Question 2: how do I set the newly created invoice line item in php using the api?

Hi @redlaw03

  1. Currently you are not able to set this up via the API.
    Usually this is setup one time by the user who is creating the Xero system.

  2. Line items can be added as an array to the full body of the invoice in a POST request. For example using PHP SDK see below.
    Also take a look at the PHP Full Sample App.

$lineitems = [];

$lineitem = new XeroAPI\XeroPHP\Models\Accounting\LineItem;
$lineitem->setDescription('Sample Item')
->setQuantity(1)
->setUnitAmount(20)
->setAccountCode("200");

array_push($lineitems,$lineitem);

$invoice->setReference('Ref-123')
->setDueDate(new DateTime('2023-02-24'))
->setContact($contact)
->setLineItems($lineitems)
->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_DRAFT)
->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCREC)
->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE); `

Hi @redlaw03 I'm going to close this one now, if you need further assistance with LineItem arrays, do feel free to contact our friendly API support team on api@support.xero.com.