QuickBooks InventoryAdjustMod

QuickBooks InventoryAdjustMod

在 QuickBooks QBFC SDK 中,我需要添加一行库存调整。但出于某种原因,它告诉我需要序列号/批次参考。

这是调整线的 QBFC 参考。它说 ORTypeAdjustmentMod 是必填字段,但我不使用序列号或批号。右侧的 "Y" 表示必填字段。

这是同一请求的 XML 版本。在这一个中,ORTypeAdjustmentMod 是可选的。

我不太确定 <-BEGIN OR-> 注释是什么意思,但这可能与 ORTypeAdjustmentMod 有关。

有人 运行 使用 QuickBooks SDK 进行过类似的操作吗?

编辑

这是与 quickbooks 对话的代码调用。 整个 class 有一个全局会话管理器,然后在 SendMessage 函数中发送消息。当不包括 Lot/Serial 数字时,quickbooks 的错误是“InventoryAdjustmentLineModList: 元素 (0) - ORTypeAdjustmentMod:缺少必填字段 InventoryAdjustmentLineModList 结束 InventoryAdjustmentMod 结束

我注意到的另一个可能与序列号/批号有关的问题是,当您通过将 TxnLineID 设置为“-1”来向现有库存调整添加新行时,它擦除交易中的每一行现有行并添加新行。发生这种情况时,它会给出 "OK" 状态消息。

Function AdjustInventory(itemid As String, adjustment As Single, account As String, _class As String, jobnumber As String, reference As String) As String
    Dim requestMsgSet As IMsgSetRequest
'Checks if previous inventory adjust exists and returns JArray of each line 
'of the transaction. No issue here.
    Dim lines As JArray = GetPreviousQuery(reference)

    requestMsgSet = sessionManager.CreateMsgSetRequest("US", 13, 0)
    requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue
    Dim responseMsgSet As IMsgSetResponse
    Dim exists As Boolean = lines(0)("exists")

'if a previoius adjustment doesnt exist, make a new one.
    If Not exists Then
        Dim InventoryAdjustmentAddRq As IInventoryAdjustmentAdd
        InventoryAdjustmentAddRq = requestMsgSet.AppendInventoryAdjustmentAddRq()
        InventoryAdjustmentAddRq.AccountRef.FullName.SetValue(account)
        InventoryAdjustmentAddRq.ClassRef.FullName.SetValue(_class)
        InventoryAdjustmentAddRq.RefNumber.SetValue(reference)
        If jobnumber IsNot Nothing Then
            InventoryAdjustmentAddRq.CustomerRef.FullName.SetValue(jobnumber)
        End If
        Dim InventoryAdjustmentLineAdd91 As IInventoryAdjustmentLineAdd
            InventoryAdjustmentLineAdd91 = InventoryAdjustmentAddRq.InventoryAdjustmentLineAddList.Append()
            InventoryAdjustmentLineAdd91.ItemRef.ListID.SetValue(itemid)
            InventoryAdjustmentLineAdd91.ORTypeAdjustment.QuantityAdjustment.ORQuantityAdjustment.QuantityDifference.SetValue(adjustment)

            responseMsgSet = Me.SendMessage(requestMsgSet)
        Else
            Dim InventoryAdjustmentModRq As IInventoryAdjustmentMod
        InventoryAdjustmentModRq = requestMsgSet.AppendInventoryAdjustmentModRq()
        'InventoryAdjustmentModRq.RefNumber.SetValue(reference)
        InventoryAdjustmentModRq.TxnID.SetValue(lines(0)("transactionid"))
        InventoryAdjustmentModRq.EditSequence.SetValue(lines(0)("editsequence"))

        Dim isitemnew As Boolean = True

'loops through all items in adjustment to see if the current item matches.
        For Each line As JObject In lines
            If line("listid") = itemid Then
                Dim prevquan As Single
                prevquan = line("quantitydifference")
                Dim newval As Single = prevquan + adjustment

                Dim InventoryAdjustmentLineMod116 As IInventoryAdjustmentLineMod
                InventoryAdjustmentLineMod116 = InventoryAdjustmentModRq.InventoryAdjustmentLineModList.Append()
                InventoryAdjustmentLineMod116.ItemRef.ListID.SetValue(itemid)

                InventoryAdjustmentLineMod116.QuantityDifference.SetValue(newval)
                InventoryAdjustmentLineMod116.TxnLineID.SetValue(lines(0)("linetxnid"))
                InventoryAdjustmentLineMod116.ORTypeAdjustmentMod.LotAdjustment.CountAdjustment.SetValue(newval)
                isitemnew = False
            End If

        Next

'If item is new, append it to the inventory adjustment.
        If isitemnew Then
            Dim invadjustlineadd As IInventoryAdjustmentLineMod
            invadjustlineadd = InventoryAdjustmentModRq.InventoryAdjustmentLineModList.Append()
'Heres where the erasing issue arises'
'the transaction doesnt get replaced when the TxnLineID is actually matches 
'an existing TxnLineID, it only happens when trying to add a new one.
            invadjustlineadd.TxnLineID.SetValue("-1")
            invadjustlineadd.ItemRef.ListID.SetValue(itemid)

            invadjustlineadd.QuantityDifference.SetValue(adjustment)

            invadjustlineadd.ORTypeAdjustmentMod.LotAdjustment.CountAdjustment.SetValue(adjustment)
            Debug.WriteLine(invadjustlineadd.TxnLineID.GetValue.ToString)
        End If
        responseMsgSet = Me.SendMessage(requestMsgSet)
    End If








    Dim res As Object = responseMsgSet.ResponseList.GetAt(0)
    Dim code As String = res.StatusCode
    Dim mes As String = res.StatusMessage
    Dim sev As String = res.StatusSeverity
    Dim jres As Object
    jres = New With {Key .status = sev, Key .code = code, Key .detail = mes}
    Dim output As String = JsonConvert.SerializeObject(jres)
    Return output



End Function

Function SendMessage(requestMsgSet As IMsgSetRequest) As IMsgSetResponse

    Dim responseMsgSet As IMsgSetResponse

    'Send the request and get the response from QuickBooks

    responseMsgSet = sessionManager.DoRequests(requestMsgSet)

    'End the session and close the connection to QuickBooks

    Return responseMsgSet
End Function

您确定 QuickBooks 文件没有打开 Serial/Lot 号码吗?我在示例 QuickBooks 文件中进行了测试,并且能够在不指定 serial/lot 数字的情况下创建库存数量调整。我的代码是 C#(我硬编码值):`QBSessionManager SessionManager = new QBSessionManager(); SessionManager.OpenConnection2("Whosebug", "Whosebug", ENConnectionType.ctLocalQBD); SessionManager.BeginSession("", ENOpenMode.omDontCare);

        IMsgSetRequest MsgRequest = SessionManager.CreateMsgSetRequest("US", 13, 0);
        IInventoryAdjustmentAdd iAdd = MsgRequest.AppendInventoryAdjustmentAddRq();
        iAdd.AccountRef.FullName.SetValue("Advertising Expense");
        iAdd.RefNumber.SetValue("12345");
        iAdd.TxnDate.SetValue(DateTime.Today);

        IInventoryAdjustmentLineAdd iLine = iAdd.InventoryAdjustmentLineAddList.Append();
        iLine.ItemRef.FullName.SetValue("Indoor Electrical Wire");
        iLine.ORTypeAdjustment.QuantityAdjustment.ORQuantityAdjustment.QuantityDifference.SetValue(10);

        IResponse Response = SessionManager.DoRequests(MsgRequest).ResponseList.GetAt(0); `

根据 QBSDK 程序员指南,对于修改事务时丢失的行,即使您没有进行更改,也需要包含这些行。但是,您不需要为不更改的行指定所有字段。只需包含一个 LineMod 和该线路的 TxnLineID,它就会被保留。您可以在第 127-131 页的 QBSDK 程序员指南中获得更多详细信息和代码示例。