Class: ChargeLine

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/charge_line.rb

Overview

create_table :charge_lines do |t|

t.string      :sti_type
t.references  :money
t.string      :description     #could be expanded to include type information, etc.
t.string      :external_identifier
t.string      :external_id_source

#polymorphic
t.references :charged_item, :polymorphic => true

t.timestamps

end

add_index :charge_lines, [:charged_item_id, :charged_item_type], :name => ‘charged_item_idx’

Instance Method Summary collapse

Instance Method Details

#calculate_tax(ctx = {}) ⇒ Object

calculates tax and save to sales_tax



32
33
34
35
36
37
38
39
# File 'app/models/charge_line.rb', line 32

def calculate_tax(ctx={})
  taxation = ErpOrders::Taxation.new

  self.sales_tax = taxation.calculate_tax(self,
                                          ctx.merge({
                                                        amount: money.amount
                                                    }))
end

#taxed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/charge_line.rb', line 27

def taxed?
  self.charge_type.try(:taxable)
end