QuickBooks InventroyAdjustMod

问题描述 投票:0回答:1

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

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

enter image description here

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

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

enter image description here

有没有人用QuickBooks SDK遇到类似的东西?

编辑

这是与quickbooks交谈的代码调用。整个类都有一个全局会话管理器,然后在SendMessage函数中发送消息。不包括批次/序列号时来自quickbooks的错误是“InventoryAdjustmentLineModList:element(0) - ORTypeAdjustmentMod:required field is missing End of InventoryAdjustmentLineModList End of 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
.net xml vb.net quickbooks
1个回答
1
投票

您确定QuickBooks文件没有打开序列号/批号吗?我在示例QuickBooks文件中进行了测试,并且能够创建库存数量调整而无需指定序列号/批号。我的代码是C#(和我的硬编码值):`QBSessionManager SessionManager = new QBSessionManager(); SessionManager.OpenConnection2(“StackOverflow”,“StackOverflow”,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程序员指南,即使您没有进行更改,也需要包含行。但是,您不需要为未更改的行指定所有字段。只需包含一个仅包含该行的TxnLineID的LineMod,它将被保留。您可以在第127-131页的QBSDK程序员指南中获取更多详细信息和代码示例。

© www.soinside.com 2019 - 2024. All rights reserved.