taxedo 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,6 +27,7 @@ taxedo:
27
27
 
28
28
  rules:
29
29
  standard: ['gst', 'qst']
30
+ non_taxable: ['gst_zero', 'qst_zero']
30
31
  books: ['gst']
31
32
 
32
33
  taxes:
@@ -34,8 +35,12 @@ taxedo:
34
35
  19910101: 700
35
36
  20060701: 600
36
37
  20080101: 500
38
+ gst_zero:
39
+ 19910101: 0
37
40
  qst:
38
41
  19940513: 650
39
42
  19980101: 750
40
43
  20110101: 850
41
44
  20120101: 950
45
+ qst_zero:
46
+ 19910101: 0
@@ -14,5 +14,9 @@ taxedo:
14
14
  taxes:
15
15
  gst:
16
16
  short: TPS
17
+ gst_zero:
18
+ short: TPS
17
19
  qst:
18
20
  short: TVQ
21
+ qst_zero:
22
+ short: TVQ
@@ -18,6 +18,10 @@ class Taxedo::Receipt
18
18
  @taxes << tax
19
19
  end
20
20
 
21
+ def language
22
+ defined?(I18n) ? I18n.locale.to_s : 'fr'
23
+ end
24
+
21
25
  def subtotal
22
26
  @amount
23
27
  end
@@ -25,7 +29,10 @@ class Taxedo::Receipt
25
29
  def t(path)
26
30
  text = @translations
27
31
 
28
- path.split('.').each { |p| text = text[p] }
32
+ path.split('.').each do |p|
33
+ raise "TAXEDO: No #{language} translation for #{path}." if not text
34
+ text = text[p]
35
+ end
29
36
 
30
37
  return text.to_s
31
38
  end
@@ -62,8 +69,6 @@ class Taxedo::Receipt
62
69
  private
63
70
 
64
71
  def load_translations
65
- language = defined?(I18n) ? I18n.locale.to_s : 'fr'
66
-
67
72
  @translations = YAML.load_file(Taxedo.base_languages_path + "#{language}.yml")['taxedo'][language]
68
73
  end
69
74
 
@@ -33,6 +33,8 @@ class Taxedo::Region
33
33
  end
34
34
 
35
35
  def taxes(rule, start_at)
36
+ raise 'TAXEDO: This tax rule doesn\'t exists!' if not @data['rules'][rule]
37
+
36
38
  @data['rules'][rule].map do |tax_id|
37
39
  tax_key = tax_from_start_date(tax_id, start_at)
38
40
 
@@ -19,6 +19,10 @@ describe Taxedo::Region do
19
19
  the("result.total") { should eql 11396 }
20
20
  end
21
21
  end
22
+
23
+ context "when calculating taxes on 100$ with a rule that doesn't exists" do
24
+ it { expect { region.calculate(10000, :rule => 'unknown') }.to raise_error("TAXEDO: This tax rule doesn't exists!") }
25
+ end
22
26
  end
23
27
 
24
28
  context "with the can region" do
@@ -6,6 +6,17 @@ describe Taxedo do
6
6
  end
7
7
 
8
8
  describe "::tax_for" do
9
- pending "TOTEST"
9
+ context "when getting the quebec tax for 10$ in text format" do
10
+ subject { Taxedo.tax_for 'quebec', 1000, format: :text }
11
+
12
+ it { should eql "Sous-total .... 10,00$\nTPS ........... 0,50$\nTVQ ........... 1,00$\nTotal ......... 11,50$" }
13
+
14
+ context "with a non_taxable rule" do
15
+ subject { Taxedo.tax_for 'quebec', 1000, format: :text, :rule => 'non_taxable' }
16
+
17
+ it { should eql "Sous-total .... 10,00$\nTPS ........... 0,00$\nTVQ ........... 0,00$\nTotal ......... 10,00$" }
18
+ end
19
+ end
20
+
10
21
  end
11
22
  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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-23 00:00:00.000000000 Z
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &2151812360 !ruby/object:Gem::Requirement
16
+ requirement: &2153049320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.7
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2151812360
24
+ version_requirements: *2153049320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2151810620 !ruby/object:Gem::Requirement
27
+ requirement: &2153048540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2151810620
35
+ version_requirements: *2153048540
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec-aspic
38
- requirement: &2151809700 !ruby/object:Gem::Requirement
38
+ requirement: &2153047200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.0.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2151809700
46
+ version_requirements: *2153047200
47
47
  description: ''
48
48
  email:
49
49
  - sebastien@demarque.com