0

我有一个收银系统,其中有价格和税金字段。输入的价格不含税(按照美国的惯例)。

对于欧洲的一些人来说,他们喜欢在价格中包含税费。例子:

含税 30.00 税率 10%

为了存储不含税的价格,价格将为:27.2727273

问题是,在我的系统中,我只允许 2 个小数点的价格。

最好的方法是增加价格字段允许的小数位数并为英国客户计算不含税的价格并存储它?

我需要多少小数点?

4

2 回答 2

1

If we are talking about currency you need more the two decimal point accuracy. I would say you need at least 4 decimal point accuracy for the simple fact. 1/100 of a cent and 1/1000 of a cent given enough transactions CAN be a good sum of money

Is the best way to do this to increase the number of decimal points allowed for the price field and calculate the price without tax for UK customers and store it?

The solution to your problem is to store 3 numbers.

  • Price of the item without Tax.
  • Amount of Tax
  • Total Price with Tax

This would allow you to store the same information for any item, for any customer, all that matters is how they input and/or display the price.

Sadly, this was a little long for a comment, and since there is no code I can't supply any.

于 2012-07-20T11:45:39.263 回答
0

我认为你最好的选择是根本不存储税额。

存储适用的起始/截止日期的税率,并在需要时通过将该税率应用于价格来得出税额。当税率发生变化时,这也将使您的喜欢变得更容易(因为不久前英国的增值税税率没有变化)。

对于实际价格,您应该能够获得小数点后 2 位,因为四舍五入将应用于每笔交易,因为它们发生在“现实世界”中 - 即没有人支付 6.66 英镑和三分之二,将四舍五入为 6.67 英镑。

如果您交易的不是离散的实物(石油、外币、股票),那么是的,您需要能够记录最低货币面额的分数。

于 2012-07-20T11:08:54.757 回答