[英]How to add Invoice in QuickBook using C# and Quickbook SDK?
我是QuickBook(Desktop)集成的新手。 我想使用Quickbook SDK在QuickBook中创建发票。 我正在使用带有QuickBooks Desktop Edition的C#.NET应用程序来创建客户和发票。
我可以创建客户,但无法开具发票。
这是我的代码:
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
。
另一个问题是IInvoiceAdd
Invoice Number
用户是哪个属性?
收到响应后,您将需要检查响应状态以查看请求是否有效。 例如:
IResponse invoiceResponse = invoiceResponseMsgSet.ResponseList.GetAt(0);
if(invoiceResponse.StatusCode !=0)
{
// There was an error with the request.
string errorMsg = invoiceResponse.StatusMessage;
}
在这种情况下,您将收到错误消息:“事务为空。” 这意味着您需要在发票中添加一些项目以在发票上创建美元金额。 即使OSR并未指出这些是必需的,即使它们的数量为零,您仍然需要将它们放在那儿。 就像您尝试在QuickBooks中手动创建发票而不指定任何项目一样。
假设您有一个名为“ Sales”的商品设置,那么您的请求将如下所示:
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。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.