自动关闭 Quickbooks 中新销售订单记录的未结余额

Automatically closing an open balance on a new SalesOrder record in Quickbooks

我正在尝试使用 nsoftware SDK 在 quickbooks 中创建销售记录。以下代码根据需要在 Quickbooks 中创建销售项目,除了它显示 "Open Balance" 和状态 "Open"。

    var total = "999";

    var connectionString = config.ToString(); 

    var report = new nsoftware.InQB.Salesorder
    {
        QBConnectionString = config.ToString(),
        CustomerName = "Internal Application Test", 
    }; 

    var salesOrderItem = new SalesOrderItem(); 
    salesOrderItem.ItemName = "Daily Cash Sales Test";
    salesOrderItem.Amount = total;

    //salesOrderItem.ManuallyClosed = ManuallyCloseds.mcManuallyClosed;

    report.LineItems.Add(salesOrderItem);

    await report.OpenQBConnectionAsync().ConfigureAwait(false);

    bool isSuccess = true;

    try
    {
        await report.AddAsync().ConfigureAwait(false);   
    }
    catch (Exception x)
    {
        System.Diagnostics.Debug.WriteLine(x);
        isSuccess = false;
    }
    finally
    {
        await report.CloseQBConnectionAsync().ConfigureAwait(false);
    }

我试图通过调用手动关闭来结束销售:

salesOrderItem.ManuallyClosed = ManuallyCloseds.mcManuallyClosed;

这似乎没有任何影响。

我的问题

有没有办法以编程方式将未结余额清零并结束销售?

据我所知,您不能简单地将余额归零并关闭销售订单。你必须跳过几个箍。

为了将销售订单标记为零余额的已付款,您需要为销售订单的客户创建发票。然后,您需要对发票应用付款 (ReceivePayment)。这将导致您的销售订单被标记为已付款且余额为零。

您可以使用此官方 Intuit 资源来构建必要的查询:

https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html

Consolibyte 网站也包含了一堆有用的例子:

http://www.consolibyte.com/docs/index.php/Example_qbXML_Requests

当然,如果有人有更好的解决方案,欢迎post提出来,我会重新考虑选择的答案。