0
我無法通過適當的庫存調整來完成。看起來它沒有在QuickBooks中引用/定位適當的帳戶。而且我不清楚它在哪裏建立連接以及如何提供它。使用QuickBooks爲QuickBooks添加庫存調整PHP開發工具包/ QuickBooks Web連接器
我仍然在修補它,但任何建議都會很棒。
更新:將AccountRef FullName更改爲「Inventory Asset」可以消除錯誤,並在同步時更新RefNumber,TxnID等。但是,它仍然沒有在QuickBooks中更新數量。假設這是因爲它只是真正傳遞「QuantityDifference」。
QWCLog.txt
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InventoryAdjustmentAddRq requestID="13">
<InventoryAdjustmentAdd>
<AccountRef>
<FullName>Inventory Adjustments</FullName>
</AccountRef>
<TxnDate>2016-12-28</TxnDate>
<!--<RefNumber>9051</RefNumber>-->
<Memo></Memo>
<InventoryAdjustmentLineAdd>
<ItemRef>
<ListID>TxnLID-9051</ListID>
</ItemRef>
<QuantityAdjustment>
<QuantityDifference>0.00000</QuantityDifference>
</QuantityAdjustment>
</InventoryAdjustmentLineAdd>
</InventoryAdjustmentAdd>
</InventoryAdjustmentAddRq>
</QBXMLMsgsRq>
</QBXML>
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : Request xml received.
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Processing request #2
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : REQUEST: received from application: size (bytes) = 1191
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Sending request to QuickBooks.
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Response received from QuickBooks: size (bytes) = 379
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Sending response back to application.
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : *** Calling receiveResponseXML() with following parameters:
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : wcTicket="3388bbdc-18d0-a594-7dfd-70f68aac289e"
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : response =
20161228.19:16:51 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<InventoryAdjustmentAddRs requestID="13" statusCode="3140" statusSeverity="Error" statusMessage="There is an invalid reference to QuickBooks Account "Inventory Adjustments" in the InventoryAdjustment. QuickBooks error message: Invalid argument. The specified record does not exist in the list." />
</QBXMLMsgsRs>
</QBXML>
save.php是插入和隊列的庫存調整
$Queue = new QuickBooks_WebConnector_Queue($dsn);
// IMPORTANT: ONLY UPDATE CHANGED ROWS. WE DONT WANT INVENTORY ADJUSTMENTS FOR UNCHANGED ITEMS!
foreach ($updates as $update) {
// Update QuantityOnHand still so our web interface can easily see the new quantity before QB sync
$sql = "UPDATE qb_item SET QuantityOnHand='" . $update[1] . "' WHERE ListID='" . $update[0] . "'";
if (!$qb_result = $qb->query($sql)) {
dErr("Error: Our query failed to execute and here is why: <br />Query: " . $sql . "<br />Errno: " . $qb->errno . "<br />Error: " . $qb->error);
}
$sql = "SELECT * FROM qb_item WHERE ListID='" . $update[0] . "'";
if (!$qb_result = $qb->query($sql)) {
dErr("Error: Our query failed to execute and here is why: <br />Query: " . $sql . "<br />Errno: " . $qb->errno . "<br />Error: " . $qb->error);
}
$row = $qb_result->fetch_assoc();
// Generate unique TxnID
// Apparently QuickBooks will overwrite it with the permanent TxnID when it syncs
$tID = rand(1000, 9999);
// Insert new Item Adjustment
$sql = "INSERT INTO `qb_inventoryadjustment` (`TxnID`, `TimeCreated`, `TimeModified`, `Account_FullName`, `TxnDate`, `RefNumber`, `Memo`, `qbsql_discov_datetime`, `qbsql_resync_datetime`, `qbsql_modify_timestamp`) VALUES ('TxnID-" . $tID . "', now(), now(), 'Inventory Adjustments', CURDATE(), '" . $tID . "', NULL, NULL, NULL, now())";
if (!$qb_result = $qb->query($sql)) {
dErr("Error: Our query failed to execute and here is why: <br />Query: " . $sql . "<br />Errno: " . $qb->errno . "<br />Error: " . $qb->error);
}
// Get the primary key of the new record
$id = $qb->insert_id;
// Queue up the inventory adjustment
$Queue->enqueue(QUICKBOOKS_ADD_INVENTORYADJUSTMENT, $id);
// Insert new Item Adjustment Line
$sql = "INSERT INTO `qb_inventoryadjustment_inventoryadjustmentline` (`InventoryAdjustment_TxnID`, `SortOrder`, `TxnLineID`, `Item_ListID`, `Item_FullName`, `QuantityAdjustment_NewQuantity`) VALUES ('TxnID-" . $tID . "', '0', 'TxnLID-" . $tID . "', '" . $update[0] . "', '" . $row['FullName'] . "', " . $update[1] . ")";
if (!$qb_result = $qb->query($sql)) {
dErr("Error: Our query failed to execute and here is why: <br />Query: " . $sql . "<br />Errno: " . $qb->errno . "<br />Error: " . $qb->error);
}
// Get the primary key of the new record
$id = $qb->insert_id;
// Queue up the inventory adjusment
$Queue->enqueue(QUICKBOOKS_ADD_INVENTORYADJUSTMENT, $id);
}
正如你可以在我的OP中看到的,我已經得出這樣的結論:'假設這是因爲它只是真的傳遞「QuantityDifference」。'我不明白爲什麼你建議我插入InventoryAdjustment通過僅更新「NewQuantity」(甚至不存在的密鑰)。 – logicPwn