taxedo 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,10 @@ class Taxedo::Builder::Html < Taxedo::Builder::Base
6
6
  else table
7
7
  end
8
8
 
9
- return @content.join("\n")
9
+ @content = @content.join("\n")
10
+ @content = @content.html_safe if @content.respond_to? :html_safe
11
+
12
+ return @content
10
13
  end
11
14
 
12
15
  private
data/lib/taxedo/tax.rb CHANGED
@@ -23,6 +23,6 @@ class Taxedo::Tax
23
23
  private
24
24
 
25
25
  def calculate_amount
26
- ((@source_amount * @rate).round / 10000)
26
+ ((@source_amount * @rate).to_f / 10000).round
27
27
  end
28
28
  end
@@ -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 10,00$" do
8
- let(:receipt) { Taxedo::Region.new('quebec').calculate(1000) }
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 1000 }
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 50 }
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 1149 }
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 10,00$" do
8
- let(:receipt) { Taxedo::Region.new('quebec').calculate(1000) }
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":1000,"taxes":[{"id":"gst","name":"TPS","amount":50},{"id":"qst","name":"TVQ","amount":99}],"total":1149}' }
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 10,00$" do
8
- let(:receipt) { Taxedo::Region.new('quebec').calculate(1000) }
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 .... 10,00$\nTPS ........... 0,50$\nTVQ ........... 0,99$\nTotal ......... 11,49$" }
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
@@ -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 10.00$" do
12
- let(:result) { region.calculate(1000) }
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 1149 }
15
+ the("result.total") { should eql 11498 }
16
16
 
17
17
  context "in July 1994" do
18
- let(:result) { region.calculate(1000, :on => Time.parse('1994-07-01')) }
19
- the("result.total") { should eql 1139 }
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 10.00$" do
28
- let(:result) { region.calculate(1000) }
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 1050 }
31
+ the("result.total") { should eql 10500 }
32
32
  end
33
33
  end
34
34
  end
@@ -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 10$" do
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 = 1000 }
15
+ before { tax.source_amount = 10000 }
16
16
 
17
17
  describe "#source_amount" do
18
- the("tax.amount") { should eql 70 }
19
- the("tax.source_amount") { should eql 1000 }
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 1070 }
23
+ the("tax.subtotal") { should eql 10700 }
24
24
  end
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taxedo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: