Class: ExpenseGun::Expense

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AASM
Defined in:
app/models/expense_gun/expense.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Expense

Returns a new instance of Expense.



10
11
12
13
# File 'app/models/expense_gun/expense.rb', line 10

def initialize(*args)
  super
  self.date = Date.today if self.date.nil?
end

Instance Method Details

#current_stateObject



30
31
32
# File 'app/models/expense_gun/expense.rb', line 30

def current_state
  aasm.current_state
end

#may_edit?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/models/expense_gun/expense.rb', line 58

def may_edit?
  current_state == :new
end

#total_all_taxesObject

Sum of line amounts



16
17
18
# File 'app/models/expense_gun/expense.rb', line 16

def total_all_taxes
  expense_lines.map(&:total_all_taxes).sum
end

#total_employee_paybackObject

Sum of line emplee payback



21
22
23
# File 'app/models/expense_gun/expense.rb', line 21

def total_employee_payback
  expense_lines.map(&:employee_payback).sum
end

#total_vat_deductibleObject

Sum of deductible deductible vat



26
27
28
# File 'app/models/expense_gun/expense.rb', line 26

def total_vat_deductible
  expense_lines.map(&:total_vat_deductible).sum
end