平方舍入误差(银行舍入)

时间:2020-06-14 21:25:05

标签: square-connect square

我从方说到错误

{"errors": [{"code": "BAD_REQUEST","detail": "The total of the requested payments does not match the total of the sale order.","category": "INVALID_REQUEST_ERROR"}]}

该项目为3.00,税为9.5%,我们的应用费为3%。

我会发送过来

3.00
+ 0.29 (0.095 * 3.00 = 28.5 rounded up)
+ 0.09
______
  3.38

我可以清楚地看到这是我在请求中发送的金额,并且如果该商品的价格为2.99或3.01,则可以使用。当Square响应创建订单时,它返回的税额为$ 0.28,这不是Banker的舍入。在这种情况下,我最好假设Square无法解决此错误,我应该四舍五入征税吗?

订单端点的响应:

{"order": {"id": "gMTUBc5FrYvLzkoNv6xOYfkLtkUZY","location_id": "RE7KBN4EGW4KT","line_items": [{"uid": "Z3mT3QHmkk4SPCkbrSW5MB","catalog_object_id": "NN5CHF66YK6MUGXG3BNWF6X5","quantity": "1","name": "Steamer","variation_name": "Regular","base_price_money": {"amount": 300,"currency": "USD"},"taxes": [{"uid": "rQurMfiksaO3xTaMqWdb1C","catalog_object_id": "YSI7WUNXGGSJRQEQ4QEQYK5G","name": "Sales Tax","percentage": "9.5","type": "ADDITIVE","applied_money": {"amount": 28,"currency": "USD"},"scope": "LINE_ITEM"}],"gross_sales_money": {"amount": 300,"currency": "USD"},"total_tax_money": {"amount": 28,"currency": "USD"},"total_discount_money": {"amount": 0,"currency": "USD"},"total_money": {"amount": 328,"currency": "USD"},"variation_total_price_money": {"amount": 300,"currency": "USD"},"applied_taxes": [{"uid": "rQurMfiksaO3xTaMqWdb1C","tax_uid": "rQurMfiksaO3xTaMqWdb1C","applied_money": {"amount": 28,"currency": "USD"}}]}],"taxes": [{"uid": "rQurMfiksaO3xTaMqWdb1C","catalog_object_id": "YSI7WUNXGGSJRQEQ4QEQYK5G","name": "Sales Tax","percentage": "9.5","type": "ADDITIVE","applied_money": {"amount": 28,"currency": "USD"},"scope": "LINE_ITEM"}],"fulfillments": [{"uid": "jJtsXtwaWfjJBIpbe7wkk","type": "PICKUP","state": "PROPOSED","pickup_details": {"pickup_at": "2020-06-14T20:58:09.257Z","recipient": {"display_name": "Table: #1"}}}],"created_at": "2020-06-14T20:43:09.731Z","updated_at": "2020-06-14T20:43:09.731Z","state": "OPEN","version": 1,"total_tax_money": {"amount": 28,"currency": "USD"},"total_discount_money": {"amount": 0,"currency": "USD"},"total_tip_money": {"amount": 0,"currency": "USD"},"total_money": {"amount": 337,"currency": "USD"},"service_charges": [{"uid": "2lD47tU2idwjyOpydkfrtB","name": "Service Fee","amount_money": {"amount": 9,"currency": "USD"},"applied_money": {"amount": 9,"currency": "USD"},"calculation_phase": "SUBTOTAL_PHASE","taxable": false,"total_money": {"amount": 9,"currency": "USD"},"total_tax_money": {"amount": 0,"currency": "USD"}}],"total_service_charge_money": {"amount": 9,"currency": "USD"},"net_amounts": {"total_money": {"amount": 337,"currency": "USD"},"tax_money": {"amount": 28,"currency": "USD"},"discount_money": {"amount": 0,"currency": "USD"},"tip_money": {"amount": 0,"currency": "USD"},"service_charge_money": {"amount": 9,"currency": "USD"}},"source": {"name": "Table: #1"}}}

1 个答案:

答案 0 :(得分:1)

只有当结束号码在两个号码之间是等距的时候,银行家的四舍五入才适用(在这种情况下为.05)。

在您的示例中:

3.00
+ 0.28 (0.095 * 3.00 = 0.285 which according to Banker's rounding, rounds to the closest even number, so this would be 0.28)
+ 0.09
_______
  3.37

在另一个示例(3.01)中:

3.01
+ 0.29 (0.095 * 3.01 = 0.28595 which would round to 0.286 and then use normal rounding, since it doesn't end in 5, to be 0.29)
+ 0.09
______
  3.39