c# - 如何使用 Quickbooks SDK (QBFC) 从估算查询中获取“成本”等字段?
问题描述
我正在通过 QBFC 在 Quickbooks 桌面版上运行估算查询,虽然我能够提取在 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
}
}
}
我会得到一个示例输出:
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 的值,但是如果您查看我附上的这张图片,金额实际上是在最右边的列上给了我红色圆圈,而不是绿色圆圈(在“金额”下柱子)。
当我记录小计和总计时,我希望在底部附近同时看到绿色和红色圆圈,但是我得到了两次红色圆圈的值(小计未正确显示)。
最后,我无法获得“成本/单位”列(我相信最初命名为“成本”)。
关于如何访问这些字段的任何想法,或者为什么某些字段似乎提取了错误的值?
提前感谢您的宝贵时间。
解决方案
根据文档:
小计
应用税前所有估计行的总和。(相比之下,小计项目(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 属性似乎代表总金额(费率 * 数量 * 加价)。因此,要找到每条线路的预加价总额,我们可以将线路的费率乘以它的数量。
关于成本/单位,这似乎是每条线的费率。这可以使用以下方法检索:
lineRet.ORRate.Rate.GetValue()
推荐阅读
- css - 如何在 iOS 15 的 Safari 上动态设置高度 100%
- html - 将网页的特定部分读入 R
- c# - 没有 HTTP 动词的 ASP.NET Core 错误处理程序引发 Swashbuckle 异常
- android - getCurrentUser NullPointerException
- python-3.x - 如何在 Google App Engine 中进行 apt-get install
- go - 拒绝服务资源耗尽请求
- azure - 如何将 Azure 存储帐户活动日志发送到 Azure 日志分析工作区
- python - OpenCV沿曲线检测点
- azure - 在 yaml 管道配置中声明时,不会在 Azure Devops 中自动创建环境
- wordpress - Gutenberg 11.7.0 添加了 reset.css - 之后如何应用 CSS?