forked from vinsol-spree-contrib/spree_taxjar
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor preferences dropping unneeded functionality
The core goal was to move the preference off the global config. This is primarily because Solidus has made the global config store by default not database-driven. This means everytime the system is reset any config set is reverted to whatever the intial state is (blank for these new config). I did consider just adding the API key to to code but I think it is more flexible and better to store it with the actual calculator rather than have it be global. In addition to the API key there are two other config options: * Enabled flag * Special logging The enabled flag is not really needed. If you don't want it enabled just don't have the rate! This allows us to reduce the code paths. It is slightly less efficient in the case where there is no configured tax rate. But since that is not really the normal state I didn't really worry about htat. The special logging was actually quite a bit of code and non-normal for a Rails app. The better thing is just to log to the normal Rails logger so tools can consume it. I can understand some argument for a seperate file so you can just get the taxjar info. But if you really need that lets do it the right way. Add tagging to the log messages and then the log system can easily filter on that tag. End result is that we remove a lot of unnecessary code by removing some of the options. We also give ourselve more flexibility by storing the API key with the calculator.
- Loading branch information
Showing
18 changed files
with
113 additions
and
414 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
module Taxable | ||
extend ActiveSupport::Concern | ||
|
||
private | ||
def taxjar_applicable?(order) | ||
Spree::TaxRate.for_address(order.tax_address).any? { |rate| rate.calculator_type == "Spree::Calculator::TaxjarCalculator" } | ||
end | ||
def taxjar_rate order | ||
Spree::TaxRate.for_address(order.tax_address).to_a.find { |rate| rate.calculator_type == "Spree::Calculator::TaxjarCalculator" } | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.