我无法获得适当的库存调整。它似乎没有引用/定位QuickBooks中的正确帐户。而且我不清楚它在哪里建立联系以及提供什么。
我还在修补它,但任何建议都会很棒。
更新:将AccountRef FullName更改为“库存资产”可以解除错误,并在同步时更新RefNumber,TxnID等。但是,它仍然没有在QuickBooks中更新数量。假设它是因为它只是真正传递“QuantityDifference”。
QWCLog.txt
$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 插入库存调整并将其排队的代码
Sheets("Reservations").Range("H" & i).Value = _
Format(TimeSerial(ComboBox5.Value, ComboBox6.Value, 0), "hh:mm")
Sheets("Reservations").Range("I" & i).Value = _
Format(TimeSerial(ComboBox7.Value, ComboBox8.Value, 0), "hh:mm")
答案 0 :(得分:0)
查看QuickBooks UI /帮助或QuickBooks OSR。
QuantityDifference
字段定义为:
QuantityDifference
显示的正数或负数 此库存项目的数量更改。
您正在发送:
<QuantityDifference>0.00000</QuantityDifference>
告诉QuickBooks您要通过... 0
更改数量。您想要将0
添加到数量中,并从数量中减去0
。
您应该能够通过查看QuickBooks UI来确定哪些是允许的帐户。
答案 1 :(得分:0)
将此代码用于您的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中的数量。