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