Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php TxnLID-9051 -3_Php_Sql_Quickbooks - Fatal编程技术网

Php TxnLID-9051 -3

Php TxnLID-9051 -3,php,sql,quickbooks,Php,Sql,Quickbooks,您的问题是帐户名。正确的账户名称为“库存资产”。数量应为负数,以减少QB中的数量 正如您在我的OP中所看到的,我已经得出了这样的结论:假设这是因为它只传递了“QuantityDifference”。我不明白的是,为什么您建议我只通过更新“NewQuantity”(一个甚至不存在的键)来插入一个InventoryAdjustment.我会跟进的,因为似乎没有人再完全阅读任何东西了。如果你看一看我的(旧的)save.php代码,你会发现我甚至没有传递“QuantityDifference”,所以说我

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

正如您在我的OP中所看到的,我已经得出了这样的结论:
假设这是因为它只传递了“QuantityDifference”。
我不明白的是,为什么您建议我只通过更新“NewQuantity”(一个甚至不存在的键)来插入一个InventoryAdjustment.我会跟进的,因为似乎没有人再完全阅读任何东西了。如果你看一看我的(旧的)save.php代码,你会发现我甚至没有传递“QuantityDifference”,所以说我传递的“QuantityDifference”不正确的所有评论都没有抓住我文章的重点。这个问题肯定是复杂的,我必须承认我没有完全理解(当时)需要什么。更不用说Keith的医生太厉害了。我的问题的真正答案是(某种程度上)基思的回答,这让我推断出哪个字段持有存货调整的适当账户(项目资产账户)。
<?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>
$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);
}
<QuantityDifference>0.00000</QuantityDifference>
 <?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>