首页 > 解决方案 > 无法在 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 
        }
    }

标签: c#quickbooksnsoftware

解决方案


好的,所以问题是我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(); 
    }
}

推荐阅读