Class: Deb::Account

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

Constant Summary collapse

ACCOUNTS_POSITIONS =
{
  "debit" => ["asset", "expense"],
  "credit" => ["liability", "equity", "revenue"]
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](some_shot_name) ⇒ Object



11
12
13
# File 'app/models/deb/account.rb', line 11

def self.[](some_shot_name)
  where(short_name: some_shot_name).first
end

.swap_position(value) ⇒ Object



24
25
26
# File 'app/models/deb/account.rb', line 24

def self.swap_position(value)
  "debit" == value ? "credit" : "debit"
end

Instance Method Details

#can_be_in?(position) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/deb/account.rb', line 20

def can_be_in?(position)
  ACCOUNTS_POSITIONS[contra? ? self.class.swap_position(position) : position].member?(kind)
end