calcinai / xero-php

A php library for the Xero API, with a cleaner OAuth interface and ORM-like abstraction.
MIT License
359 stars 256 forks source link

Receipt Option? #532

Open kunallibra opened 5 years ago

kunallibra commented 5 years ago

I am trying to send a receipt (bill/ expense) as a draft to the Xero, but what ever I try and do, I am getting an error. Basically, I want to upload the receipt( the invoice sent by the supplier), enter the Name of the supplier, Amount to pay, Invoice Number from the supplier and our reference code merged (eg: Inv Num / Ref as 987/ 123), due date, and a small description like 1 dozen blue ball pens. Can you please guide me how to solve this issue please.

$invoice= new \XeroPHP\Models\Accounting\Receipt();
$xcontact= new \XeroPHP\Models\Accounting\Contact();

$xcontact->setName('Test Contact');
$xcontact->setFirstName('Test');
$xcontact->setLastName('Contact');
$xcontact->setEmailAddress('amo.chohan@gmail.com');
$xcontact->setDefaultCurrency('AUD');
$invoice->setContact($xcontact);

// till the above code, things are working fine but having issues here)

 $invoice->setTotal('300.00');
 $dateInstance = new DateTime();
 $invoice->setDate($dateInstance);
 $invoice->setReceiptNumber('987/');
 $invoice->setReference('123');

i was trying to send the info but giving me an error as:

Call to undefined method XeroPHP\Models\Accounting\Receipt::setReceiptNumber()

and if comment the setReceiptNumber(); I get the following error as:

XeroPHP\Models\Accounting\Receipt::$LineItems is mandatory and is either missing or empty.

Not too sure how can I send the Bills to the Xero.

Thanks for your time.

calcinai commented 5 years ago

@kunallibra I think the issue is that you're using a Receipt, as opposed to an Invoice