Class: Taxedo::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/taxedo/region.rb

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Region

Returns a new instance of Region.



4
5
6
7
# File 'lib/taxedo/region.rb', line 4

def initialize(id)
  @id = id
  @data = YAML.load_file(Taxedo.base_data_path + "regions.yml")['taxedo']['regions'][@id]
end

Instance Method Details

#calculate(amount, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/taxedo/region.rb', line 9

def calculate(amount, options={})
  options = { :on => Time.now, :rule => 'standard' }.merge(options)

  receipt = Taxedo::Receipt.new(@id, amount)
  receipt.currency = @data['currency']

  taxes(options[:rule], options[:on]).each do |tax|
    receipt.add_tax tax[0], tax[1]
  end

  return receipt
end