spree/spree — Issue #1216: compound tax support
Author: nathany
Created: 2012-03-02 10:07:42+00:00
State: open

According to your Taxation Guide, compound taxes aren't yet supported.

Just recently, I wrote a taxation engine for an international client in an existing Rails 2 app. I thought I'd share my approach, which may be somewhat novel:

```ruby
# Takes an effective rate (for math) and an optional nominal rate (for display).
#
# TaxRate.new(:gst, 0.05)
# TaxRate.new(:qst, 0.08925, 0.085)
```

This kept the math simple, while displaying the "right" thing to the end user.

The actual code for Quebec provincial sales tax takes a block:

```ruby
# Canadian Provincial Taxes (effective rates will be impacted by changes to GST)
'CAQCQST' => TaxRate.new(:qst) do # effective, nominal
if Time.now >= Time.utc(2012,1,1,5,0) # Eastern Time (US & Canada), -05:00
[0.09975, 0.095]
else
[0.08925, 0.085]
end
end
```

This is just how i approached it, I'm not saying this is how it should work in Spree. I have yet to dig into the Spree source code, having just discovered that it's open source!

I didn't see an existing ticket, so i thought I'd "start the conversation."

Hopefully at some point Spree could replace a tonne of custom code in the app where I work, and be better for it.

Nathan.