使用 Quickbooks API 创建支票
问题描述:
请帮助我使用 QuickBooks online (Qbo) API 写支票.我尝试这样做,但我总是收到一条错误消息验证详细信息行时出错:至少需要一个详细信息行".示例代码在下面.. 我应该如何添加检查行.
Please help me on writing a check using the QuickBooks online(Qbo) API. I tried to do that but i'm always getting an error saying "Error validating Detail Lines:At least one detail line is required." Sample Code is in Below.. How should I add Lines for Checks.
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)
答
如果您已经有账单,那么您可以简单地使用 billpayment API 来创建支票.网址:https://quickbooks.api.intuit.com/v3/company/111111111111/billpayment?minorversion=4
If you have bill already then you can simply use billpayment API to create checks. URL : https://quickbooks.api.intuit.com/v3/company/111111111111/billpayment?minorversion=4
请求 JSON 数据:
request JSON data:
{
"VendorRef": {
"value": "1",
"name": "vendor_name"
},
"PayType": "Check",
"CheckPayment": {
"BankAccountRef": {
"value": "1",
"name": "Test Account"
}
},
"TotalAmt": 100.00,
"PrivateNote": "Acct. 1JK90",
"Line": [
{
"Amount": 100.00,
"LinkedTxn": [
{
"TxnId": "1",
"TxnType": "Bill"
}
]
}
]
}