gpt4 book ai didi

c# - 如何使用 C# 和 Quickbook SDK 在 QuickBook 中添加发票?

转载 作者:行者123 更新时间:2023-11-30 22:09:55 24 4
gpt4 key购买 nike

我对 QuickBook(桌面)集成完全陌生。我想使用 QuickBook SDK 在 QuickBook 中创建发票。我正在关注 C# .NET Application with QuickBooks Desktop Edition将我的客户和发票打包。

我可以创建客户但无法开具发票。

这是我的代码:

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

另一个问题是 IInvoiceAddInvoice Number 的用户是哪个属性?

最佳答案

收到响应后,您需要检查响应状态以查看请求是否有效。例如:

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。

关于c# - 如何使用 C# 和 Quickbook SDK 在 QuickBook 中添加发票?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21216924/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com