How Product Cost and Tax Calculation Works
Source: product.rb:161-196, product.rb:258-267, product.rb:282-297
- Cost sync has six branches depending on which cost field was changed: if cost > 0 but cost_inc_tax is 0, the system calculates cost_inc_tax; if cost_inc_tax > 0 but cost is 0, it calculates cost; if cost changed but cost_inc_tax did not, it recalculates cost_inc_tax; and vice versa
- For GST-free products, cost and cost_including_tax are synced to be equal -- whichever field has a value is copied to the other; if both have values, the company's price_includes_tax setting determines which is the source of truth
- Tax calculation uses the product's group category-specific purchase/sales tax rate if one exists; otherwise falls back to the company's default tax rate
- The company's price_includes_tax setting controls whether the cost field or cost_including_tax field is the "master" value when both need recalculating
- Product group name is used to look up category-specific tax rates, so changing a product's group can change its tax calculation
- Sell price from cost uses the formula: price = (new_cost * (1 + markup/100)).round(2)
Support scenarios
- "Why did my cost-including-tax change when I only changed the cost?" → The system auto-recalculates the other cost field based on the applicable tax rate
- "Why is the tax on my product different from the company default?" → The product's group has a category with a specific tax rate that overrides the company default
- "Why are my GST-free product's cost and cost-inc-tax the same?" → For GST-free products, the system syncs both fields to be equal
- "Cost changed after I moved the product to a different group" → The new group's category may have a different tax rate, triggering a recalculation