使用RefNumberList查询发票QuickBooks QBFC

时间:2014-01-21 19:40:00

标签: c# quickbooks qbfc

我正在开发一个程序,它将使用一组发票号码查询Quickbooks,然后针对每个发票号码查询。将获得发票,发票号码将主要来自文件。并且在快速书中没有匹配记录的问题的数字将保存在另一个文件中。

现在我在RefNumberList中添加了所有发票号码,因为我在以下示例中硬编码了两个号码

IInvoiceQuery Invoices = msgset.AppendInvoiceQueryRq();
Invoices.ORInvoiceQuery.RefNumberList.Add("144");
Invoices.ORInvoiceQuery.RefNumberList.Add("9999");

msgset.Attributes.OnError = ENRqOnError.roeContinue;

if (sessionMgr.doRequests(ref msgset))
{
     MessageBox.Show("An error was detected while processing the request. Please check the log files");
     return;
}

主要问题是,即使任何一张发票编号都没有在快速书中记录,整个查询也会失败。

1 个答案:

答案 0 :(得分:2)

我建议您将每张发票作为单独的请求。这样你仍然会得到其他查询返回一个值。

msgset.Attributes.OnError = ENRqOnError.roeContinue;
string[] InvoiceList = { "144", "9999" };
foreach (string invNum in InvoiceList)
{
    IInvoiceQuery invQuery = msgset.AppendInvoiceQueryRq();
    invQuery.ORInvoiceQuery.RefNumberList.Add(invNum);
}

// Process the requests and get the response IMsgSetResponse MsgResponse = SessionManager.DoRequests(msgset);

// Check each response for (int index = 0; index < MsgResponse.ResponseList.Count; index++) { IResponse response = MsgResponse.ResponseList.GetAt(index); if (response.StatusCode != 0) { // Save the invoice number in the "not found" file // and display the error MessageBox.Show("Error finding invoice " + InvoiceList[index] + ". Error: " + response.StatusMessage); } }