我正在尝试确定存储产品税费的最合适方式。
TABLE products (
id
name
description
)
TABLE tax_zones (
id
code
)
TABLE tax_rates (
id
zone_id
rate
)
TABLE tax (
id
rate_id
)
TABLE product_tax (
id
product_id
tax_id
)
我承认,即使我对这种结构有点困惑,所以我需要一些帮助来简化或澄清或两者兼而有之。
我的商店是国际性的,所以只针对加拿大和美国...产品可以在世界各地购买。
最佳答案
表 product_tax
的用途是什么?存储每种产品的税务信息不是您应该采取的方式。
美国(可能还有加拿大)的税收因州而异,通常低至邮政编码级别(有时甚至是子邮政编码!)。处理税收的正确方法是将其应用于整个购物车(即按百分比计算),而不是针对单个产品。
至于如何处理税收……欢迎来到在线购物的有趣世界。有一些服务提供网络服务(因为税收变化非常频繁)。此类产品之一是 AvaTax .
我会重申我在评论中所说的话。我已经 build 了许多购物车(并且在这个过程中被烧毁了!)我在该领域拥有丰富的经验。
"Local" is irrelevant when it comes to tax. Tax should be applied according to the country, state, region, county, town, etc. that the item is being 'shipped' to. In other words, it's the recipient's tax rules that are applicable. If a product is a gift to someone in a region other than that of the purchaser, it is their tax rules that apply. In other words, the buyer pays the tax that applies to the person receiving the gift!
此外,我将在下面进一步阐明我的评论......
税收与相关产品完全分开。税款应适用于全部成本金额,而不是单个项目。唯一的异常(exception)是产品被视为“免税”。这主要适用于某些被视为“必需品”的食品。显然,其他一切都被视为奢侈!
因此,如果购物车中有 3 件 1 美元的商品,则将应用 8.00% 的税率,使总额达到 3.24 美元。任何运费都将在税费征收后添加。运费不属于产品价格的一部分,因此无需纳税(联邦 express 、UPS 等已对运费进行预税)。
由于税率因地理位置而异,因此尝试将“税”值附加到数据库中的产品是没有意义的。该数据应单独应用于每笔交易。从网络服务获取正确的税额可以减少出错的可能性。值得注意的是,税收经常变化。如果您经过审计并被证明收取了错误的税款,您可能需要自行支付差额。税法很少关心谁纳税,只关心纳税。
好吧,关于表结构的一些想法......
product table {
id
sku [manufacturer or made up]
related_items
brand
description
features
specifications
keywords
price
weight
width
height
length
packaging_type
shipping_info
flatrate_shipping
taxable
discountable
insured
featured
status [enum('outofstock','instock','specialorder','calltoorder','comingsoon','onorder','sold','onhold','hide')]
stock
}
category table {
id
category_id
category_name
category_description
}
product_category table {
id
category_id
product_id
}
最后一个表提供了一种将许多产品归入一个类别,或将一个产品归入多个类别的方法。
关于php - 税收数据库架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16801286/