I am following this wrapper
I have this error: Catchable fatal error: Argument 1 passed to XeroPHP\Models\Accounting\Invoice::setDueDate() must implement interface DateTimeInterface, string given
This is my code:
try{
$lineitem = new LineItem($this->_xi);
$lineitem->setAccountCode('200')
->setQuantity('5.400')
->setDescription('this is awesome test')
->setUnitAmount('9900.00');
$contact = new Contact($this->_xi);
$contact->setName("John Doe")
->setFirstName("John")
->setLastName("Doe")
->setEmailAddress("[email protected]")
->setContactStatus(Contact::CONTACT_STATUS_ACTIVE);
$invoice = new Invoice($this->_xi);
$invoice->setType(Invoice::INVOICE_TYPE_ACCREC)
->setStatus(Invoice::INVOICE_STATUS_AUTHORISED)
->setContact($contact)
//->setDate(\DateTimeInterface::format("Y-m-d"))
->setDueDate("2018-09-09")
->setLineAmountType(Invoice::LINEAMOUNT_TYPE_EXCLUSIVE)
->addLineItem($lineitem)
->setInvoiceNumber('10')
->save();
}catch ( Exception $e ){
$GLOBALS['log']->fatal('[Xero-createContact]-' . $e->getMessage());
echo $e->getMessage();
}
When I tried doing it like this:
->setDueDate(\DateTimeInterface::format("Y-m-d"))
I got this error instead: Fatal error: Non-static method DateTimeInterface::format() cannot be called statically, assuming $this from incompatible context
This is the function of setDueDate that I am calling:
/**
* @param \DateTimeInterface $value
* @return Invoice
*/
public function setDueDate(\DateTimeInterface $value)
{
$this->propertyUpdated('DueDate', $value);
$this->_data['DueDate'] = $value;
return $this;
}
I'm really lost here as to how do I use this DateTimeInterface and how can I even set a future date using it, and how do I solve all this errors.