c# - 无法在 Quickbooks 桌面更新 SalesReceipt
问题描述
我正在使用/nSoftware的 QuickBooks Integrator 与 QuickBooks Desktop 集成
我正在尝试更新发票,但没有收到任何错误,但是当我签入 QuickBooks 时,我发现没有任何变化,实际上也没有更新。
首先,我尝试根据 RefNumber 查找发票,如果找到发票,那么我尝试替换行项目,然后我像这样调用更新方法existingInvoice.Update();
这是我的代码示例:
public static List<Invoice> FindInvoice(string refNumber)
{
var invoicesSearch = new Objsearch
{
QueryType = ObjsearchQueryTypes.qtInvoiceSearch,
RuntimeLicense = "MYLICENSEKEY",
QBConnectionString = "MYCONNECTIONSTRINGTOREMOTECONNECTOR",
SearchCriteria = new SearchCriteria
{
RefNumberContains = refNumber
},
};
invoicesSearch.Search();
var qbInvoiceList = invoicesSearch.Results.ToList();
var invoiceObjList = new List<Invoice>();
foreach (var inv in qbInvoiceList)
{
var newInv = new Invoice();
newInv.QBResponseAggregate = inv.Aggregate;
invoiceObjList.Add(newInv);
}
return invoiceObjList.FirstOrDefault();
}
public static void PutInvoice(Invoice invoice)
{
var existingInvoice = FindInvoice(invoice.RefNumber);
if (existingInvoice != null)
{
existingInvoice.LineItems.Clear();
existingInvoice.LineItems.AddRange(invoice.LineItems);
existingInvoice.QBConnectionString = "MYCONNECTIONSTRINGTOREMOTECONNECTOR";
existingInvoice.RuntimeLicense = RuntimeLicense;
existingInvoice.QBXMLVersion = "12.0";
existingInvoice.Update(); //this line
}
}
解决方案
好的,所以问题是我QBXMLVersion
在更新之前设置了最后一件事。
为了Update()
成功处理,QBXMLVersion
首先需要设置。
这是一个更新的工作示例:
public static void PutInvoice(Invoice invoice)
{
var existingInvoice = FindInvoice(invoice.RefNumber);
if (existingInvoice != null)
{
existingInvoice.QBXMLVersion = "12.0";
existingInvoice.RuntimeLicense = "MyRuntimeLicenseKey";
existingInvoice.QBConnectionString = "MYCONNECTIONSTRINGTOREMOTECONNECTOR";
existingInvoice.LineItems.Clear();
existingInvoice.LineItems.AddRange(invoice.LineItems);
existingInvoice.Update();
}
}
推荐阅读
- django - 在 Django 模板中迭代列表
- javascript - 使用提交按钮减去两个日期
- variables - 如何将张量流变量设置为第一个输入数据?
- android - 从微调器填充编辑文本
- perl - 将内置 perl 文档复制到 txt 文件中
- javascript - WordPress 上的响应式菜单不流畅
- javascript - 从 Web api 获取数据的问题
- javascript - 将 WebSocket 与两个 Web 浏览器实例区分开来
- c# - 将字符串值存储在数组中,然后显示数组值
- android - 是否可以在不安装 Google Play 游戏应用程序的情况下使用 Android 排行榜?