taxedo 0.0.5 → 0.0.6
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.
- data/lib/taxedo/region.rb +10 -6
- metadata +2 -2
data/lib/taxedo/region.rb
CHANGED
@@ -8,11 +8,11 @@ class Taxedo::Region
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def calculate(amount, options={})
|
11
|
-
options = { :on => Time.now, :rule => 'standard', :
|
11
|
+
options = { :on => Time.now, :rule => 'standard', :equation_type => 'compiled'}.merge(options)
|
12
12
|
|
13
13
|
receipt = Taxedo::Receipt.new(@id, amount)
|
14
14
|
receipt.currency = @data['currency']
|
15
|
-
receipt.equation_type = equation_type_from_date(options[:on]).nil? ? options[:
|
15
|
+
receipt.equation_type = equation_type_from_date(options[:on]).nil? ? options[:equation_type] : equation_type_from_date(options[:on])
|
16
16
|
|
17
17
|
taxes(options[:rule], options[:on]).each do |tax|
|
18
18
|
receipt.add_tax tax[0], tax[1]
|
@@ -25,11 +25,15 @@ class Taxedo::Region
|
|
25
25
|
|
26
26
|
def equation_type_from_date(start_at)
|
27
27
|
selection = Time.at(0)
|
28
|
-
@data['equation_types'].
|
29
|
-
|
30
|
-
|
28
|
+
if @data['equation_types'].nil?
|
29
|
+
return nil
|
30
|
+
else
|
31
|
+
@data['equation_types'].each do |equation_start_at, equation|
|
32
|
+
equation_start_at = Time.parse(equation_start_at.to_s)
|
33
|
+
selection = equation_start_at if equation_start_at <= start_at and equation_start_at > selection
|
34
|
+
end
|
35
|
+
return @data['equation_types'][selection.strftime('%Y%m%d').to_i]
|
31
36
|
end
|
32
|
-
@data['equation_types'][selection.strftime('%Y%m%d').to_i]
|
33
37
|
end
|
34
38
|
|
35
39
|
def tax_from_start_date(tax_id, start_at)
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: taxedo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sebastien Rosa
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|