我正在使用quickbook v3。我已经从github下载了PHP SAMPLE代码并且运行良好。它可以轻松创建员工,但不会创建采购订单。
这是我到目前为止所做的事情。
$linedet = new IPPPurchaseOrderItemLineDetail();
$linedet->CustomerRef = 86;
$line = new IPPLine();
$line->Id = 0;
$line->Description = 'test purchase order';
$line->Amount = 2.00;
$line->DetailType= 'ItemBasedExpenseLineDetail ';
$line->ItemBasedExpenseLineDetail = $linedet;
$line->BillableStatus = 'Notbillable';
$line->ItemRef = '2';
$line->UnitPrice = '25';
$line->Qty = '1';
$purchaseOrder = new IPPPurchaseOrder();
$purchaseOrder->Line = $line;
$purchaseOrder->VendorRef = 85;
$purchaseOrder->APAccountRef = 1;
$purchaseOrder->TotalAmt = 200.00;
$result = $dataService->Add($purchaseOrder); //add purchase order
运行上面的代码时出现以下错误
Fatal error: Uncaught IdsException: [0]: Argument Null Exception thrown in D:\xamp\htdocs\projectmanager\wp-content\plugins\quickbook-oauth\v3-php-sdk-2.0.5\DataService\DataService.php on line 312
虽然通过api explorer创建采购订单也会导致400错误
我们非常感谢您的帮助。 感谢
答案 0 :(得分:0)
好吧,我给$ line对象提供了错误的项目引用,这就是它抛出错误的原因。现在我可以轻松创建采购订单。 我将itemRef更改为19,它就像魅力一样
from itertools import groupby
def checkRepeat(lst,maxIter=1000):
"""Returns a list that has no repeating elements. Will try for a max of 1000 iterations by default and return False if such a list can't be found"""
def hasRepeat(lst):
"""Returns true if there are any repeats"""
return len([x[0] for x in groupby(lst)]) < len(lst)
offset=numIter=0
while hasRepeat(lst) and numIter<maxIter:
for i,curElt in enumerate(lst):
try:
if lst[i]==lst[i+1]:
lst[i+1],lst[(i+offset) % len(lst)] = lst[(i+offset) % len(lst)],lst[i+1] #swap j+1 with j+offset. wrap around the list
except:
break
offset+=1
numIter+=1
if numIter==maxIter:
return False
else:
return lst