我正在使用/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
}
}