我无法进行正确的库存调整要经过。看来,这不是引用/内的QuickBooks瞄准正确的帐户。而且我不是在那里的使它的连接和如何处理提供清楚。
我仍然与它修修补补,但任何建议将是真棒。
更新:更改AccountRef全名,以“库存资产”摆脱了错误,并会在同步时也将更新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);
}
看在QuickBooks的UI /帮助或QuickBooks的OSR。
所述QuantityDifference
字段被定义为:
数量差异
无论是正数或负数,显示了该项目的库存数量的变化。
您发送:
<QuantityDifference>0.00000</QuantityDifference>
它告诉你想...... 0
更改数量的QuickBooks。你想0
增加数量,并从数量减去0
。
你应该能够判断哪些是允许的账户通过查看QuickBooks的UI。
使用此代码为您的XML请求:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InventoryAdjustmentAddRq requestID="13">
<InventoryAdjustmentAdd>
<AccountRef>
<FullName>Inventory Asset</FullName>
</AccountRef>
<TxnDate>2016-12-28</TxnDate>
<!--<RefNumber>9051</RefNumber>-->
<Memo></Memo>
<InventoryAdjustmentLineAdd>
<ItemRef>
<ListID>TxnLID-9051</ListID>
</ItemRef>
<QuantityAdjustment>
<QuantityDifference>-3</QuantityDifference>
</QuantityAdjustment>
</InventoryAdjustmentLineAdd>
</InventoryAdjustmentAdd>
</InventoryAdjustmentAddRq>
</QBXMLMsgsRq>
</QBXML>
你的问题是与帐户名称。正确的帐户名是“库存资产”。数量应该在负降低QB的数量。