使用Quickbooks API创建检查

时间:2013-06-27 11:32:57

标签: quickbooks quickbooks-online

请使用QuickBooks在线(Qbo)API帮我编写支票。我试图这样做,但我总是收到错误说“错误验证细节线:至少需要一个细节线。”示例代码在下面..我应该如何添加支票行。

                    Dim existingChk = New Qbo.Check()
                    Dim existingChks = commonService.FindAll(existingChk, 1, 10).ToList()

                    Dim payment = New Qbo.Payment()
                    Dim payments = commonService.FindAll(payment, 1, 10).ToList()

                    Dim qboCheck = New Intuit.Ipp.Data.Qbo.CheckHeader()
                    Dim bank = New Intuit.Ipp.Data.Qbo.Account()
                    bank.Type = Intuit.Ipp.Data.Qbo.AccountTypeEnum.Asset
                    Dim Banks = commonService.FindAll(bank, 1, 100).ToList()
                    Dim accountId As New Qbo.IdType
                    For Each bnk As Intuit.Ipp.Data.Qbo.Account In Banks
                        If bnk.Name = "Test Bank" Then
                            accountId = bnk.Id
                        End If
                    Next
                    qboCheck.BankAccountId = accountId
                    qboCheck.BankAccountName = "Test Bank"
                    qboCheck.TotalAmt = 20.0
                    qboCheck.Currency = Intuit.Ipp.Data.Qbo.currencyCode.USD
                    qboCheck.TxnId = payments(0).Id
                    Dim qboCustomer = New Intuit.Ipp.Data.Qbo.Customer()
                    Dim qboCustomers = commonService.FindAll(qboCustomer, 1, 10).ToList()
                    For Each cus As Intuit.Ipp.Data.Qbo.Customer In qboCustomers
                        If cus.Name.Contains("Customer1") Then
                            qboCheck.EntityId = cus.Id
                        End If
                    Next
                    qboCheck.EntityType = Qbo.EntityTypeEnum.Customer

                    Dim check = New Intuit.Ipp.Data.Qbo.Check()
                    check.Header = qboCheck
                    check.Id = New Qbo.IdType
                    check.Id.idDomain = existingChks(0).Id.idDomain
                    check.Id.Value = CInt(existingChks(0).Id.Value) + 1

                    Dim resultCheck As Qbo.Check = TryCast(commonService.Add(check), Qbo.Check)

3 个答案:

答案 0 :(得分:0)

看起来它是.net devkit中的一个错误(我不是100%肯定)。 JavaDocs说accountId和itemId都是从LinePurchase(PFB快照)继承的。但是在.net devkit中,我没有在LinePurchase和LineBase中看到这些字段。

JavaDoc参考 - http://developer-static.intuit.com/SDKDocs/QBV2Doc/ipp-java-devkit-2.0.10-SNAPSHOT-javadoc/

enter image description here

API端点工作正常。

https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/check#Sample_Create_Request_XML

<?xml version="1.0" encoding="utf-8" ?>
<Check xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2">
    <Header>
        <TxnDate>2013-08-09</TxnDate>
        <BankAccountId>44</BankAccountId>
        <EntityId>2</EntityId>
    </Header>
    <Line>
        <Desc>Hard Disks</Desc>
        <Amount>500</Amount>
        <BillableStatus>NotBillable</BillableStatus>
        <ItemId>4</ItemId>
        <Qty>10</Qty>
        <UnitPrice>50</UnitPrice>
    </Line>
</Check>

PN -

<BankAccountId>:此帐户应为“检查”类型。

<ItemId>:商品应该有'ExpenseAccountRef'标签。

您可以使用ApiExplorer工具测试此用例。

链接 - https://developer.intuit.com/apiexplorer?apiname=V2QBO

如果可能的话,我会在星期一使用.net devkit尝试这个,并确认它是否是.net devkit中的错误。

由于

答案 1 :(得分:0)

为BillpaymentHeader添加c#的伪代码。

同样,您可以将它用于CheckLine:

   billheader.ItemsElementName = new ItemsChoiceType[1];
   billheader.ItemsElementName[0] = ItemsChoiceType.BankAccountId;
   billheader.Items = new object[1];
   billheader.Items[0] = new Intuit.Ipp.Data.Qbo.IdType() { idDomain = Intuit.Ipp.Data.Qbo.idDomainEnum.QBO, Value = "1" };

参考 - How to add AccountID or ItemID when creating Checks in QuickBooks

答案 2 :(得分:0)

如果您已经有账单,那么您只需使用billpayment API来创建支票。 网址:https://quickbooks.api.intuit.com/v3/company/111111111111/billpayment?minorversion=4

请求JSON数据:

"exception": "org.springframework.http.converter.HttpMessageNotReadableException",
"message": "JSON parse error: Unresolved forward references for: ; nested exception is com.fasterxml.jackson.databind.deser.UnresolvedForwardReference: Unresolved forward references for: \n at [Source: java.io.PushbackInputStream@25614608; line: 5, column: 1]Object id [2] (for myapp.ws.people.entity.Person) at [Source: java.io.PushbackInputStream@25614608; line: 2, column: 13].",