Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

A validation exception occurred (Account code '200' is not a valid code for this document).

Started by Chris Trembath -   in API Endpoints

Hello,

While creating an invoice using Xero-PHP, I keep getting "A validation exception occurred (Account code '200' is not a valid code for this document) Validation errors: Account code '200' is not a valid code for this document."

Any idea?

I am using following code to create invoice:

$invoice = new Invoice($xero);
$invoice->setType(Invoice::INVOICE_TYPE_ACCREC)
->setStatus(Invoice::INVOICE_STATUS_AUTHORISED)
->setContact($contact)
->setDate('')
->setDueDate('')
->setLineAmountType(Invoice::LINEAMOUNT_TYPE_EXCLUSIVE)
->setCurrencyCode('AUD')
->setInvoiceNumber('INV-TEST01');
$lineitem = new Invoice\LineItem($xero);
$lineitem->setAccountCode('200')
->setQuantity('01')
->setDescription('xxxxxxx')
->setTaxType('OUTPUT')
->setTaxAmount(('xxx')
->setUnitAmount('xxx');
$invoice->addLineItem($lineitem);
$invoice->save();
$invoice->sendEmail();


Regards,