summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/super_good/solidus_taxjar.rb1
-rw-r--r--lib/super_good/solidus_taxjar/tax_calculator.rb29
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb21
3 files changed, 51 insertions, 0 deletions
diff --git a/lib/super_good/solidus_taxjar.rb b/lib/super_good/solidus_taxjar.rb
index 5ed9bd4..6553213 100644
--- a/lib/super_good/solidus_taxjar.rb
+++ b/lib/super_good/solidus_taxjar.rb
@@ -8,3 +8,4 @@ module SuperGood
end
require "super_good/solidus_taxjar/version"
+require "super_good/solidus_taxjar/tax_calculator"
diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb
new file mode 100644
index 0000000..e2a398e
--- /dev/null
+++ b/lib/super_good/solidus_taxjar/tax_calculator.rb
@@ -0,0 +1,29 @@
+module SuperGood
+ module SolidusTaxJar
+ class TaxCalculator
+ def initialize(order)
+ @order = order
+ end
+
+ def calculate
+ Spree::Tax::OrderTax.new(
+ order_id: order.id,
+ line_item_taxes: line_item_rates,
+ shipment_taxes: shipment_rates
+ )
+ end
+
+ private
+
+ attr_reader :order
+
+ def line_item_rates
+ []
+ end
+
+ def shipment_rates
+ []
+ end
+ end
+ end
+end
diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
new file mode 100644
index 0000000..eaf810c
--- /dev/null
+++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+RSpec.describe SuperGood::SolidusTaxJar::TaxCalculator do
+ describe "#calculate" do
+ subject { calculator.calculate }
+
+ let(:calculator) { described_class.new(order) }
+
+ let(:order) do
+ Spree::Order.new(
+ id: 10
+ )
+ end
+
+ it "returns the taxes" do
+ expect(subject.order_id).to eq order.id
+ expect(subject.line_item_taxes).to be_empty
+ expect(subject.shipment_taxes).to be_empty
+ end
+ end
+end