has_accounts 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/models/account.rb +3 -18
- data/app/models/account.rb~ +14 -21
- metadata +4 -4
data/app/models/account.rb
CHANGED
@@ -18,29 +18,14 @@ class Account < ActiveRecord::Base
|
|
18
18
|
belongs_to :account_type
|
19
19
|
|
20
20
|
def is_asset_account?
|
21
|
-
[
|
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 :
|
29
|
-
include AccountScopeExtension
|
30
|
-
end
|
31
|
-
scope :capital_assets, where('account_type_id = 2') do
|
32
|
-
include AccountScopeExtension
|
33
|
-
end
|
34
|
-
scope :outside_capital, where('account_type_id = 3') do
|
35
|
-
include AccountScopeExtension
|
36
|
-
end
|
37
|
-
scope :equity_capital, where('account_type_id = 4') do
|
38
|
-
include AccountScopeExtension
|
39
|
-
end
|
40
|
-
scope :expenses, where('account_type_id = 5') do
|
41
|
-
include AccountScopeExtension
|
42
|
-
end
|
43
|
-
scope :earnings, where('account_type_id = 6') do
|
28
|
+
scope :by_type, lambda {|value| includes(:account_type).where('account_types.name' => value)} do
|
44
29
|
include AccountScopeExtension
|
45
30
|
end
|
46
31
|
|
data/app/models/account.rb~
CHANGED
@@ -18,29 +18,14 @@ class Account < ActiveRecord::Base
|
|
18
18
|
belongs_to :account_type
|
19
19
|
|
20
20
|
def is_asset_account?
|
21
|
-
[
|
21
|
+
AccountType.by_type(['current_assets', 'capital_assets', 'costs']).include? account_type
|
22
22
|
end
|
23
23
|
|
24
24
|
def is_liability_account?
|
25
|
-
|
25
|
+
!is_asset_account?
|
26
26
|
end
|
27
27
|
|
28
|
-
scope :
|
29
|
-
include AccountScopeExtension
|
30
|
-
end
|
31
|
-
scope :capital_assets, where('account_type_id = 2') do
|
32
|
-
include AccountScopeExtension
|
33
|
-
end
|
34
|
-
scope :outside_capital, where('account_type_id = 3') do
|
35
|
-
include AccountScopeExtension
|
36
|
-
end
|
37
|
-
scope :equity_capital, where('account_type_id = 4') do
|
38
|
-
include AccountScopeExtension
|
39
|
-
end
|
40
|
-
scope :expenses, where('account_type_id = 5') do
|
41
|
-
include AccountScopeExtension
|
42
|
-
end
|
43
|
-
scope :earnings, where('account_type_id = 6') do
|
28
|
+
scope :by_type, lambda {|value| includes(:account_type).where('account_types.name' => value.underscore)} do
|
44
29
|
include AccountScopeExtension
|
45
30
|
end
|
46
31
|
|
@@ -83,8 +68,16 @@ class Account < ActiveRecord::Base
|
|
83
68
|
}]
|
84
69
|
end
|
85
70
|
elsif
|
86
|
-
|
87
|
-
|
71
|
+
if selector.first == selector.last
|
72
|
+
condition = ["date(value_date) = :value_date", {
|
73
|
+
:value_date => selector.first
|
74
|
+
}]
|
75
|
+
else
|
76
|
+
condition = ["date(value_date) BETWEEN :first_value_date AND :latest_value_date", {
|
77
|
+
:first_value_date => selector.first,
|
78
|
+
:latest_value_date => selector.last
|
79
|
+
}]
|
80
|
+
end
|
88
81
|
end
|
89
82
|
else
|
90
83
|
if selector.is_a? Booking
|
@@ -93,7 +86,7 @@ class Account < ActiveRecord::Base
|
|
93
86
|
condition = ["(value_date < :value_date) OR (date(value_date) = :value_date AND id <#{equality} :id)", {:value_date => selector.value_date, :id => selector.id}]
|
94
87
|
else
|
95
88
|
equality = "=" if inclusive
|
96
|
-
condition = ["value_date <#{equality} ?", selector]
|
89
|
+
condition = ["date(value_date) <#{equality} ?", selector]
|
97
90
|
end
|
98
91
|
end
|
99
92
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 8
|
8
|
+
- 0
|
9
|
+
version: 0.8.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Simon H\xC3\xBCrlimann (CyT)"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-05-02 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|