taxedo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/lib/taxedo/builder/html.rb
CHANGED
data/lib/taxedo/tax.rb
CHANGED
@@ -4,17 +4,17 @@ describe Taxedo::Builder::Hash do
|
|
4
4
|
#*************************************************************************************
|
5
5
|
# PUBLIC INSTANCE METHODS
|
6
6
|
#*************************************************************************************
|
7
|
-
context "with a quebec receipt of
|
8
|
-
let(:receipt) { Taxedo::Region.new('quebec').calculate(
|
7
|
+
context "with a quebec receipt of 100$" do
|
8
|
+
let(:receipt) { Taxedo::Region.new('quebec').calculate(10000) }
|
9
9
|
|
10
10
|
describe "#generate" do
|
11
11
|
let(:hash) { Taxedo::Builder::Hash.new(receipt).generate }
|
12
12
|
|
13
|
-
the("hash[:subtotal]") { should eql
|
13
|
+
the("hash[:subtotal]") { should eql 10000 }
|
14
14
|
the("hash[:taxes][0][:id]") { should eql 'gst' }
|
15
|
-
the("hash[:taxes][0][:amount]") { should eql
|
15
|
+
the("hash[:taxes][0][:amount]") { should eql 500 }
|
16
16
|
the("hash[:taxes][1][:id]") { should eql 'qst' }
|
17
|
-
the("hash[:total]") { should eql
|
17
|
+
the("hash[:total]") { should eql 11498 }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -4,12 +4,12 @@ describe Taxedo::Builder::Json do
|
|
4
4
|
#*************************************************************************************
|
5
5
|
# PUBLIC INSTANCE METHODS
|
6
6
|
#*************************************************************************************
|
7
|
-
context "with a quebec receipt of
|
8
|
-
let(:receipt) { Taxedo::Region.new('quebec').calculate(
|
7
|
+
context "with a quebec receipt of 100$" do
|
8
|
+
let(:receipt) { Taxedo::Region.new('quebec').calculate(10000) }
|
9
9
|
|
10
10
|
describe "#generate" do
|
11
11
|
subject { Taxedo::Builder::Json.new(receipt).generate }
|
12
|
-
it { should eql '{"subtotal":
|
12
|
+
it { should eql '{"subtotal":10000,"taxes":[{"id":"gst","name":"TPS","amount":500},{"id":"qst","name":"TVQ","amount":998}],"total":11498}' }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -4,12 +4,12 @@ describe Taxedo::Builder::Text do
|
|
4
4
|
#*************************************************************************************
|
5
5
|
# PUBLIC INSTANCE METHODS
|
6
6
|
#*************************************************************************************
|
7
|
-
context "with a quebec receipt of
|
8
|
-
let(:receipt) { Taxedo::Region.new('quebec').calculate(
|
7
|
+
context "with a quebec receipt of 100$" do
|
8
|
+
let(:receipt) { Taxedo::Region.new('quebec').calculate(10000) }
|
9
9
|
|
10
10
|
describe "#generate" do
|
11
11
|
subject { Taxedo::Builder::Text.new(receipt).generate }
|
12
|
-
it { should eql "Sous-total ....
|
12
|
+
it { should eql "Sous-total .... 100,00$\nTPS ........... 5,00$\nTVQ ........... 9,98$\nTotal ......... 114,98$" }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/spec/taxedo/region_spec.rb
CHANGED
@@ -8,15 +8,15 @@ describe Taxedo::Region do
|
|
8
8
|
context "with the quebec region" do
|
9
9
|
let(:region) { Taxedo::Region.new('quebec') }
|
10
10
|
|
11
|
-
context "when calculating taxes on
|
12
|
-
let(:result) { region.calculate(
|
11
|
+
context "when calculating taxes on 100$" do
|
12
|
+
let(:result) { region.calculate(10000) }
|
13
13
|
|
14
14
|
the("result.taxes.length") { should eql 2 }
|
15
|
-
the("result.total") { should eql
|
15
|
+
the("result.total") { should eql 11498 }
|
16
16
|
|
17
17
|
context "in July 1994" do
|
18
|
-
let(:result) { region.calculate(
|
19
|
-
the("result.total") { should eql
|
18
|
+
let(:result) { region.calculate(10000, :on => Time.parse('1994-07-01')) }
|
19
|
+
the("result.total") { should eql 11396 }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -24,11 +24,11 @@ describe Taxedo::Region do
|
|
24
24
|
context "with the can region" do
|
25
25
|
let(:region) { Taxedo::Region.new('can') }
|
26
26
|
|
27
|
-
context "when calculating taxes on
|
28
|
-
let(:result) { region.calculate(
|
27
|
+
context "when calculating taxes on 100$" do
|
28
|
+
let(:result) { region.calculate(10000) }
|
29
29
|
|
30
30
|
the("result.taxes.length") { should eql 1 }
|
31
|
-
the("result.total") { should eql
|
31
|
+
the("result.total") { should eql 10500 }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/spec/taxedo/tax_spec.rb
CHANGED
@@ -10,17 +10,17 @@ describe Taxedo::Tax do
|
|
10
10
|
|
11
11
|
let(:tax) { Taxedo::Tax.new('gst') }
|
12
12
|
|
13
|
-
context "having a tax rate of 7% and a source amount of
|
13
|
+
context "having a tax rate of 7% and a source amount of 100$" do
|
14
14
|
before { tax.rate = 700 }
|
15
|
-
before { tax.source_amount =
|
15
|
+
before { tax.source_amount = 10000 }
|
16
16
|
|
17
17
|
describe "#source_amount" do
|
18
|
-
the("tax.amount") { should eql
|
19
|
-
the("tax.source_amount") { should eql
|
18
|
+
the("tax.amount") { should eql 700 }
|
19
|
+
the("tax.source_amount") { should eql 10000 }
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "#subtotal" do
|
23
|
-
the("tax.subtotal") { should eql
|
23
|
+
the("tax.subtotal") { should eql 10700 }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|