2014-01-19 55 views
1

我是QuickBook(桌面)集成的全新手。我想使用Quickbook SDK在QuickBook中創建發票。我正在關注C# .NET Application with QuickBooks Desktop Edition以創建我的客戶和發票。如何使用C#和Quickbook SDK在QuickBook中添加發票?

我可以創建客戶但無法發票。

這裏是我的代碼:

ICustomerAdd customerAddRq = requestMsgSet.AppendCustomerAddRq(); 
customerAddRq.Name.SetValue(Customer.Name); 

IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); 
IResponse response = responseMsgSet.ResponseList.GetAt(0); 
ICustomerRet customerRet = (ICustomerRet)response.Detail; 

IInvoiceAdd invoiceAddRq = requestMsgSet.AppendInvoiceAddRq(); 
invoiceAddRq.CustomerRef.ListID.SetValue(customerRet.ListID.GetValue()); 

IMsgSetResponse invoiceResponseMsgSet = sessionManager.DoRequests(requestMsgSet); 
IResponse invoiceResponse = invoiceResponseMsgSet.ResponseList.GetAt(0); 
IInvoiceRet invoiceRet = (IInvoiceRet)invoiceResponse.Detail; 

我得到invoiceRet總是null

另一個問題是哪個屬性是用戶Invoice NumberIInvoiceAdd

回答

2

當您收到回覆時,您需要檢查回覆狀態以查看請求是否有效。例如:

IResponse invoiceResponse = invoiceResponseMsgSet.ResponseList.GetAt(0); 
if(invoiceResponse.StatusCode !=0) 
{ 
    // There was an error with the request. 
    string errorMsg = invoiceResponse.StatusMessage; 
}

在這種情況下,您將收到錯誤消息:「事務處理爲空。」這意味着您需要在發票上添加一些項目以在發票上創建美元金額。即使OSR沒有聲明這些是必需的,但您仍然需要將它們放在那裏,即使它們爲零。這與您試圖在QuickBooks中手動創建發票而不指定任何項目相同。

假設你有一個項目設置所謂的「銷售」,你的要求是這樣的:

ICustomerAdd customerAddRq = requestMsgSet.AppendCustomerAddRq(); 
customerAddRq.Name.SetValue(Customer.Name); 

IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); 
IResponse response = responseMsgSet.ResponseList.GetAt(0); 
ICustomerRet customerRet = (ICustomerRet)response.Detail; 

IInvoiceAdd invoiceAddRq = requestMsgSet.AppendInvoiceAddRq(); 
invoiceAddRq.CustomerRef.ListID.SetValue(customerRet.ListID.GetValue()); 

// Add these lines to your request 
IORInvoiceLineAdd invoiceLineAdd = invoiceAddRq.ORInvoiceLineAddList.Append(); 
invoiceLineAdd.InvoiceLineAdd.ItemRef.FullName.SetValue("Sales"); 

IMsgSetResponse invoiceResponseMsgSet = sessionManager.DoRequests(requestMsgSet); 
IResponse invoiceResponse = invoiceResponseMsgSet.ResponseList.GetAt(0); 
IInvoiceRet invoiceRet = (IInvoiceRet)invoiceResponse.Detail; 

現場發票數量稱爲RefNumber。

相關問題