【发布时间】:2019-11-14 23:31:23
【问题描述】:
我正在使用来自/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
}
}
【问题讨论】:
-
如果您使用调试器单步执行此代码,您会在什么时候首先得到意想不到的结果?
-
@Crowcoder 我没有收到任何错误或任何意外结果。它只是通过,没有任何问题。这是有趣的部分。
标签: c# quickbooks nsoftware