Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获取字段,例如;“成本”;从使用Quickbooks SDK(QBFC)的估算查询中?_C#_.net_Quickbooks_Qbfc - Fatal编程技术网

C# 如何获取字段,例如;“成本”;从使用Quickbooks SDK(QBFC)的估算查询中?

C# 如何获取字段,例如;“成本”;从使用Quickbooks SDK(QBFC)的估算查询中?,c#,.net,quickbooks,qbfc,C#,.net,Quickbooks,Qbfc,我正在Quickbooks桌面版上通过QBFC运行估算查询,虽然我能够提取Quickbooks估算屏幕上显示的一些字段,但还有一些字段我无法提取/查找。此外,我正在提取的某些属性与我期望的值不匹配 我的代码在这里: ... IEstimateQuery estimateQuery = msgSetReq.AppendEstimateQueryRq(); estimateQuery.OwnerIDList.Add("0"); estimateQuery.ORTxnQuery.TxnFilter.E

我正在Quickbooks桌面版上通过QBFC运行估算查询,虽然我能够提取Quickbooks估算屏幕上显示的一些字段,但还有一些字段我无法提取/查找。此外,我正在提取的某些属性与我期望的值不匹配

我的代码在这里:

...
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
        }
    }
}
你会注意到上面我记录了lineRet.Amount的值,但是如果你看我附上的这张图片,Amount实际上给了我最右栏的红色圆圈,而不是绿色圆圈(在“Amount”栏下)

当我记录subtotal和total时,我希望看到底部附近的绿色和红色圆圈,但相反,我得到了红色圆圈的值两次(subtotal的结果不正确)

最后,我无法获取“成本/单位”列(我相信它最初的名称是“成本”)

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

提前感谢您抽出时间

根据:

小计

应用税前所有估算行的总和。 (相比之下,小计项目(ItemSubtotal对象)只提供 显示在其上方的行中的金额总和。)

因此,看起来SDK中的“小计”与UI中的“小计”具有不同的含义。在SDK中,小计指税前总额。在UI中,它表示标记前的总计

我认为使用SDK获得预标记总计的唯一方法是迭代每一行并自己合计

// Somewhere outside your loop
double premarkupSubtotal = 0;

// ...
// Within your loop
premarkupSubtotal += (lineRet.ORRate.Rate.GetValue() * lineRet.Quantity.GetValue());
请注意,行的Amount属性似乎表示总金额(rate*quantity*markup)。因此,为了找到每一行的预标记总数,我们可以将该行的速率乘以其数量

关于成本/单位,这似乎是每条线的费率。可以使用以下方法检索此信息:

lineRet.ORRate.Rate.GetValue()

谢谢你的帮助,凯!关于使用ItemQuery。。我觉得在“估价”屏幕中,物品的价格要么是手动输入的,要么是当时从数据库中提取的。。在后一种情况下,如果我做一个ItemQuery,并且项目的价格已经改变了,那么这个值会不会与估算中显示的值不同呢?或者,我想我可以访问加价率,这样也许我可以从中反向工作。@SuperXero,啊,是的,对不起,你是对的。执行ItemQuery可能不需要返回估算中使用的相同比率。我进行了更多的测试,看起来您的“成本/单位”表示单位费率,“金额”指的是每行的预加成小计。因此,在这种情况下,两者都可以从lineRet派生。(成本/单位为lineRet.ORRate.Rate和Amount=lineRet.ORRate.Rate.GetValue()*lineRet.Quantity.GetValue())我将更新我的答案以反映这一点。进行了一些进一步的测试。我假设您的“成本/单位”是“成本”列,该列已通过估算模板定制,以显示“成本/单位”作为标题。QuickBooks会在“成本”列中自动填充项目的成本(如果可用)。如果不可用,则使用销售率。然后,根据销售价格和采购价格之间的差额减去任何价格水平调整,自动填充加价%。因此,“成本”列应该与SDK中的ORRate.Rate相对应。谢谢Kei-你说得对,lineRet.ORRate.Rate绝对是我想要的成本。此外,除了对项目进行迭代(这没有问题),小计不可访问,看起来您是正确的。再次感谢!
lineRet.ORRate.Rate.GetValue()