has_accounts 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,7 @@ class Account < ActiveRecord::Base
16
16
  # Account Type
17
17
  # ============
18
18
  belongs_to :account_type
19
+ validates_presence_of :account_type
19
20
 
20
21
  def is_asset_account?
21
22
  Account.by_type(['current_assets', 'capital_assets', 'costs']).exists?(self)
@@ -18,14 +18,14 @@ class Account < ActiveRecord::Base
18
18
  belongs_to :account_type
19
19
 
20
20
  def is_asset_account?
21
- AccountType.by_type(['current_assets', 'capital_assets', 'costs']).include? account_type
21
+ Account.by_type(['current_assets', 'capital_assets', 'costs']).exists?(self)
22
22
  end
23
23
 
24
24
  def is_liability_account?
25
25
  !is_asset_account?
26
26
  end
27
27
 
28
- scope :by_type, lambda {|value| includes(:account_type).where('account_types.name' => value.underscore)} do
28
+ scope :by_type, lambda {|value| includes(:account_type).where('account_types.name' => value)} do
29
29
  include AccountScopeExtension
30
30
  end
31
31
 
@@ -1,4 +1,7 @@
1
1
  class AccountType < ActiveRecord::Base
2
+ # Validation
3
+ validates_presence_of :name, :title
4
+
2
5
  # Helpers
3
6
  def to_s
4
7
  title
@@ -0,0 +1,6 @@
1
+ class AccountType < ActiveRecord::Base
2
+ # Helpers
3
+ def to_s
4
+ title
5
+ end
6
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 0
9
- version: 0.8.0
8
+ - 1
9
+ version: 0.8.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Simon H\xC3\xBCrlimann (CyT)"
@@ -33,6 +33,7 @@ files:
33
33
  - app/models/bank.rb
34
34
  - app/models/account.rb
35
35
  - app/models/booking.rb
36
+ - app/models/account_type.rb~
36
37
  - app/models/account_type.rb
37
38
  - app/models/bank_account.rb
38
39
  - app/models/booking.rb~