我試圖從QuickBooks的特定日期已經支付的所有發票列表中。如何獲取從QuickBooks到.NET應用程序的特定日期已支付的發票?
我在博客中找到了從QuickBooks獲取所有發票的方式。
bool sessionBegun = false;
bool connectionOpen = false;
QBSessionManager sessionManager = null;
try
{
//Create the session Manager object
sessionManager = new QBSessionManager();
//Create the message set request object to hold our request
IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0);
requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
//Connect to QuickBooks and begin a session
sessionManager.OpenConnection("", "IDN InvoiceAdd C# sample");
connectionOpen = true;
sessionManager.BeginSession(@"C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\MyCia.qbw", ENOpenMode.omDontCare);
sessionBegun = true;
IInvoiceQuery invoiceQueryRq = requestMsgSet.AppendInvoiceQueryRq();
invoiceQueryRq.IncludeLineItems.SetValue(true);
//Send the request and get the response from QuickBooks
IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
IResponse response = responseMsgSet.ResponseList.GetAt(0);
IInvoiceRetList invoiceRetList = (IInvoiceRetList)response.Detail;
var invoices = new List<Invoice>();
if (invoiceRetList != null)
{
for (int i = 0; i < invoiceRetList.Count; i++)
{
IInvoiceRet invoiceRet = invoiceRetList.GetAt(i);
var invoice = new Invoice
{
QuickBooksID = invoiceRet.TxnID.GetValue(),
EditSequence = invoiceRet.EditSequence.GetValue()
};
}
}
}
然後我可以檢查「IsPaid」參數。
但我在想,當我有一個非常大量的發票時,這將不再是一個有效的解決方案。
那麼,如何過濾我的查詢以獲取已在特定日期支付的發票?
注意: 我正在使用C#與QBFC13Lib庫。
雖然這應該讓你大部分的交易,有一些情況下,這可能會得到你不正確的信息。例如:1月1日輸入的發票,1月2日支付,然後發票在1月3日進行編輯。這將顯示在您的第三名單中,但它應該是第二個,因爲它是在付款時。 – Hpjchobbes