deb 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/deb/account.rb +0 -13
- data/app/models/deb/item.rb +0 -5
- data/lib/deb/version.rb +1 -1
- metadata +3 -3
data/app/models/deb/account.rb
CHANGED
@@ -11,18 +11,5 @@ module Deb
|
|
11
11
|
def self.[](some_shot_name)
|
12
12
|
where(short_name: some_shot_name).first
|
13
13
|
end
|
14
|
-
|
15
|
-
ACCOUNTS_POSITIONS = {
|
16
|
-
"debit" => ["asset", "expense"],
|
17
|
-
"credit" => ["liability", "equity", "revenue"]
|
18
|
-
}
|
19
|
-
|
20
|
-
def can_be_in?(position)
|
21
|
-
ACCOUNTS_POSITIONS[contra? ? self.class.swap_position(position) : position].member?(kind)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.swap_position(value)
|
25
|
-
"debit" == value ? "credit" : "debit"
|
26
|
-
end
|
27
14
|
end
|
28
15
|
end
|
data/app/models/deb/item.rb
CHANGED
@@ -4,17 +4,12 @@ module Deb
|
|
4
4
|
belongs_to :transaction
|
5
5
|
validates :kind, inclusion: {in: %w(debit credit)}
|
6
6
|
validates :account_id, presence: true
|
7
|
-
validate :account_kind
|
8
7
|
validate :positive_amount
|
9
8
|
|
10
9
|
after_create :update_balances
|
11
10
|
|
12
11
|
attr_accessible :account, :amount
|
13
12
|
|
14
|
-
def account_kind
|
15
|
-
errors.add(:account_id, "account cannot be in #{kind}") if !account || !account.can_be_in?(kind)
|
16
|
-
end
|
17
|
-
|
18
13
|
def positive_amount
|
19
14
|
errors.add(:amount, "should be positive") unless amount > 0
|
20
15
|
end
|
data/lib/deb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
segments:
|
144
144
|
- 0
|
145
|
-
hash:
|
145
|
+
hash: -1736791583155961067
|
146
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
147
|
none: false
|
148
148
|
requirements:
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
segments:
|
153
153
|
- 0
|
154
|
-
hash:
|
154
|
+
hash: -1736791583155961067
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
157
|
rubygems_version: 1.8.25
|