【发布时间】:2016-12-28 19:22:42
【问题描述】:
我无法进行适当的库存调整。似乎它没有在 QuickBooks 中引用/定位正确的帐户。而且我不清楚它在哪里建立联系以及提供什么。
我仍在修改它,但任何建议都会很棒。
更新:将 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);
}
【问题讨论】:
-
我会跟进,因为似乎没有人完全阅读任何内容了。如果您查看我的(旧)save.php 代码,您会注意到我什至没有传递“QuantityDifference”,所以所有说我传递了不正确的“QuantityDifference”的 cmets 都错过了我的帖子的重点。这个问题肯定是复杂的,我必须承认我没有完全掌握(当时)需要什么。更不用说基思的文档很糟糕。我的问题的真正答案是(某种程度上)由 Keith 回答,这让我推断出哪个字段持有适当的库存调整账户(项目资产账户)。
标签: php sql quickbooks