如何使用 Quickbooks SDK (QBFC) 从估算查询中获取 "cost" 等字段?

How do I get fields such as "cost" from an estimate query using Quickbooks SDK (QBFC)?

我是 运行 通过 QBFC 在 Quickbooks 桌面版上进行的估算查询,虽然我能够提取在 Quickbooks 的“估算”屏幕上看到的一些字段,但我还有其他字段无法 pull/find。此外,我提取的某些属性与我期望的值不匹配。

我的代码在这里:

...
IEstimateQuery estimateQuery = msgSetReq.AppendEstimateQueryRq();
estimateQuery.OwnerIDList.Add("0");
estimateQuery.ORTxnQuery.TxnFilter.EntityFilter.OREntityFilter.FullNameList.Add("testcustomer");
estimateQuery.IncludeLineItems.SetValue(true);

IMsgSetResponse msgSetResp = sessionManager.DoRequests(msgSetReq);

IResponse resp = msgSetResp.ResponseList.GetAt(0); //a list of responses for each request - we only sent one request so get the first response

IEstimateRetList estimateList = (IEstimateRetList)resp.Detail;
for(int i=0; i < estimateList.Count; i++) {
    IEstimateRet estimate = estimateList.GetAt(i);
    Debug.WriteLine("est name: " + estimate.CustomerRef.FullName.GetValue());
    Debug.WriteLine("est subtotal: " + estimate.Subtotal.GetValue());
    Debug.WriteLine("est total: " + estimate.TotalAmount.GetValue());

    if(estimate.DataExtRetList != null) {
        for(int j=0; j<estimate.DataExtRetList.Count; j++) {
            string fieldName = estimate.DataExtRetList.GetAt(j).DataExtName.GetValue();
            string fieldValue = estimate.DataExtRetList.GetAt(j).DataExtValue.GetValue();
            Debug.WriteLine("--- " + fieldName + " : " + fieldValue);
        }
    }

    if(estimate.OREstimateLineRetList != null) {
        for (int j = 0; j < estimate.OREstimateLineRetList.Count; j++) {
            IEstimateLineRet lineRet = estimate.OREstimateLineRetList.GetAt(j).EstimateLineRet;

            if(lineRet.Amount != null) {
                Debug.WriteLine("total [" + j + "] " + lineRet.Amount.GetValue()); //for some reason amount is estimated par total
                if (lineRet.Desc != null) {
                    Debug.WriteLine("description row [" + j + "] " + lineRet.Desc.GetValue());
                }
            }

            //lineRet.DataExtRetList is null, I've checked
        }
    }
}

我会得到一个示例输出:

est name: testcustomer
est subtotal: 6996.07
est total: 6996.07
--- Net Income : 6530.24
--- Other : 8036
total [0] 4451.1
description row [0] Test item1
total [1] 1952.5
description row [1] Test item2
...

你会注意到我在上面记录了 lineRet.Amount 的值,但是如果你看一下我附上的这张图片,金额实际上是在最右边的栏中给我一个红色圆圈,而不是绿色圆圈(在 'Amount' 列下)。

当我记录小计和总计时,我希望在底部附近看到绿色和红色圆圈,但我得到了两次红色圆圈的值(小计未正确显示)。

最后,我无法获得 "Cost / Unit" 列(我相信它最初被命名为 'Cost')。

关于如何访问这些字段的任何想法,或者为什么某些字段似乎提取了错误的值?

预先感谢您的宝贵时间。

根据 documentation:

Subtotal

The total of all the estimate lines before taxes are applied. (By contrast, a subtotal item (an ItemSubtotal object) gives only the total of the amounts in the lines that appear above it.)

因此,看起来SDK中的"Subtotal"与UI中的"Subtotal"具有不同的含义。在SDK中,小计是指税前合计。 UI中表示加价前合计

我认为使用 SDK 获取加价前总计的唯一方法是遍历每一行并自己计算总计。

// Somewhere outside your loop
double premarkupSubtotal = 0;

// ...
// Within your loop
premarkupSubtotal += (lineRet.ORRate.Rate.GetValue() * lineRet.Quantity.GetValue());

请注意,该行的金额 属性 似乎代表总金额(费率 * 数量 * 加价)。因此,要找到每行的加价前总计,我们只需将行的费率乘以其数量即可。

关于 Cost / Unit,这似乎是每行的费率。这可以使用以下方式检索:

lineRet.ORRate.Rate.GetValue()