【问题标题】:Adding Inventory Adjustment for QuickBooks using QuickBooks PHP Dev Kit/ QuickBooks Web Connector使用 QuickBooks PHP 开发工具包/QuickBooks Web 连接器为 QuickBooks 添加库存调整
【发布时间】: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 &quot;Inventory Adjustments&quot; 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


【解决方案1】:

查看 QuickBooks UI/帮助或 QuickBooks OSR。

QuantityDifference 字段定义为:

数量差异

正数或负数表示 此库存商品的数量发生变化。

您正在发送:

<QuantityDifference>0.00000</QuantityDifference>

这告诉 QuickBooks 您要更改数量...0。您想将0 添加到数量,并从数量中减去0

您应该能够通过查看 QuickBooks UI 来判断哪些是允许的帐户。

【讨论】:

  • 正如您在我的 OP 中看到的那样,我已经得出了这个结论:Going to assume it's because it's only really passing "QuantityDifference". 我不明白的是为什么您建议我通过仅更新“NewQuantity”(一个甚至不存在的键)。
【解决方案2】:

将此代码用于您的 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>

您的问题与帐户名称有关。正确的帐户名称是“库存资产”。 Qty 应为负数以减少 QB 中的数量。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多