我正在关注这个包装器
我有这样的错误:开捕致命错误:传递给XeroPHP \型号\会计\发票:: setDueDate(参数1)必须实现接口DateTimeInterface,字符串中给定
这是我的代码:
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("johngwapo@hot.com")
->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();
}
Run Code Online (Sandbox Code Playgroud)
当我尝试这样做时:
->setDueDate(\DateTimeInterface::format("Y-m-d"))
Run Code Online (Sandbox Code Playgroud)
我得到了这个错误:致命错误:非静态方法DateTimeInterface :: format()无法静态调用,假设$ this来自不兼容的上下文
这是我调用的setDueDate的功能:
/**
* @param \DateTimeInterface $value
* @return Invoice
*/
public function setDueDate(\DateTimeInterface $value)
{
$this->propertyUpdated('DueDate', $value);
$this->_data['DueDate'] = $value; …
Run Code Online (Sandbox Code Playgroud) 我很困惑,因为如果我删除te .toFixed(2)然后条件将返回false,因此是正确的,但如果有.toFixed(2)它返回true,这是错误的.
此外,当我使用console.log显示包含值的两个变量时,它们都返回此值
5.00 and 20.00
Run Code Online (Sandbox Code Playgroud)
这是代码:
//this two values are actually populated from .val of an input field
var coupon_limit2 = 0;
var coupon_limit = $("#product_coupon_limit").val();
var sale_price = $("#product_product_list_price").val();
if(disc_type == "Percentage"){
if(coupon_type == "amount"){
coupon_limit2 = (coupon_limit/sale_price)*100;
}else{
coupon_limit2 = coupon_limit;
}
}else{
if(coupon_type == "percent"){
coupon_limit2 = (coupon_limit/100)*sale_price;
}else{
coupon_limit2 = coupon_limit;
}
}
var x = parseFloat($("#product_product_discount").val()).toFixed(2);
var y = coupon_limit2;
//returns correctly
if(x > parseFloat(y)){
alert("hi");
}
//returns wrong
if(x > parseFloat(y).toFixed(2)){
alert("hi");
} …
Run Code Online (Sandbox Code Playgroud)