Class: Taxedo::Region
- Inherits:
-
Object
- Object
- Taxedo::Region
- Defined in:
- lib/taxedo/region.rb
Instance Method Summary collapse
- #calculate(amount, options = {}) ⇒ Object
-
#initialize(id) ⇒ Region
constructor
A new instance of Region.
Constructor Details
#initialize(id) ⇒ Region
Returns a new instance of Region.
5 6 7 8 |
# File 'lib/taxedo/region.rb', line 5 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
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/taxedo/region.rb', line 10 def calculate(amount, ={}) = { :on => Time.now, :rule => 'standard', :equation_type => 'compiled'}.merge() receipt = Taxedo::Receipt.new(@id, amount) receipt.currency = @data['currency'] receipt.equation_type = equation_type_from_date([:on]).nil? ? [:equation_type] : equation_type_from_date([:on]) taxes([:rule], [:on]).each do |tax| receipt.add_tax tax[0], tax[1] end return receipt end |