delphi - 如何在我的应用程序中为新估算的项目设置值(value)率

标签 delphi quickbooks qbfc

我使用 QBFC v13 和 Delphi XE6。
目标是从我的应用程序创建 Estimate 并将其参数设置到 QuickBooks 中。
我从 QBFC13 导入类型库并将其添加到我的项目中。
我的项目编译没有错误。
我从我的应用程序(片段 1,行:04)创建了 Estimate,然后我尝试为其项目设置费率。
当我调用函数 Rate.SetValue (fragment 1, line: 06) 时,我没有收到错误消息。
然后我调用 DoRequest (fragment 1, line: 07) 就可以了。
当我检查 StatusCode(片段 1,第 09 行)时,它必须为 0。但它是 3045,StatusMessage(片段 1,第 10 行):
“在'项目成本'字段中转换价格'23.00'时出错。QuickBooks错误消息:此字段包含无效字符”。

问题一:为什么会这样? (变量 'rate' 是 double 并且原型(prototype) SetValue(val: Double) 具有 double 类型)。

片段 1:

01: var
02: rate: double;
    i: integer;
03:     rate := 23.00;
....
04:     estimateAdd := requestMsgSet.AppendEstimateAddRq();
....
05:     estimateLineAdd := estimateAdd.OREstimateLineAddList.Append.EstimateLineAdd;
....
06:     estimateLineAdd.ORRate.Rate.SetValue(rate);
....
07:     QueryResponse := SessionManager.DoRequests(requestMsgSet);
08:     i := response.StatusCode;
09:     if (i <> 0) then
10:         MessageDlg(response.StatusMessage, mtError, [mbOk], 0);

我发现部分解决了我的问题。我可以设置值 Rate 调用电话 Rate.SetAsString(const val: WideString) (fragment 2, line: 01)
但出现其他问题。当可变利率小数部分为零时,Estimate 被添加到 QuickBooks 中。
如果小数部分不为零(例如:rate := 23.10),当调用 SetAsString 过程时,我的应用程序中会出现异常。
和错误消息:“无效的价格值”。

问题 #2:为什么我不能用小数部分评分?

片段 2:
01:    estimateLineAdd.ORRate.Rate.SetAsString(FloatToStr(rate));

如果我尝试将过程参数更改为字符串值:
estimateLineAdd.ORRate.Rate.SetAsString('23.21') 我有第一个问题的错误。
如果我尝试将过程参数更改为:
estimateLineAdd.ORRate.Rate.SetAsString('23,21')
我收到相同的异常和错误消息:“无效的价格值”。
可以理解,分隔符是'.'反而 ','。

最佳答案

delimeter is '.' instead ','.



我有同样的问题,因为 QB 在 , 的机器上运行被用作分隔符,不支持:https://community.intuit.com/questions/1012431-how-to-change-number-formatting-decimal-and-grouping-separators

我在 Windows 中的区域设置设置为 ru-RU 区域设置,因此 QB 将价格显示为“60,12”。

似乎 QBFC 除外 . :
queryRq.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.SetAsString("60,12"); // this immediatly throws
queryRq.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.SetAsString("60.12"); // this is OK

当我执行“获取所有项目”请求时,QB 以 , 返回价格,(根据地区设置):
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<ItemServiceQueryRs requestID="0" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<ItemServiceRet>
...
<SalesOrPurchase>
<Price>60,07</Price>

但是 obj.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.GetValue();返回 60无一异常(exception)。

真正奇怪的是(在我手动修复从 sendRequestXML 返回的 xml 字符串之后)也不是 ,都不是.接受了我的 QuickBooks Pro 2017!在 receiveResponseXML 我得到:
<ItemServiceAddRs requestID=\"0\" statusCode=\"3045\" statusSeverity=\"Error\" statusMessage=\"There was an error when converting the price &quot;60.12&quot; 
and
<ItemServiceAddRs requestID=\"0\" statusCode=\"3045\" statusSeverity=\"Error\" statusMessage=\"There was an error when converting the price &quot;60,12&quot;

在我将设置更改为 en-US(对于 QB Pro US)后,所有设置都适用于“60.12”。

关于delphi - 如何在我的应用程序中为新估算的项目设置值(value)率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27211458/

相关文章:

php - 在美国版 QuickBooks Online 中成功添加客户,但在加拿大版 QBO 中通过 PHP 中的 Intuit API 出现验证错误

vb.net - QBSDK发票查询

c# - 如何将 QBFC13_0.msm 添加到 Clickonce

quickbooks - 由于出现以下错误 : 80040154,检索 CLSID 为 {6C9E80E3-B780-4361-A693-5E5C6BDC83A9} 的组件的 COM 类工厂失败

delphi - URL编码单引号字符?

Delphi 字典和排序数据

delphi - Delphi-如何枚举要键入的字符串

delphi - 自定义仪表在运行时无法绘制

QuickBooks AccountQuery - 全名不包括 parent 姓名

quickbooks - 如何使用 QuickBooks QBFC 从发票中获取自定义模板字段