deb 0.0.1 → 0.0.2
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/README.markdown +31 -0
- data/app/models/deb/transaction.rb +9 -1
- data/lib/deb/version.rb +1 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
## Double Entry Bookkeeping for Rails
|
2
|
+
|
3
|
+
Inspired by (plutus)[https://github.com/mbulat/plutus].
|
4
|
+
|
5
|
+
Installation
|
6
|
+
|
7
|
+
gem "deb"
|
8
|
+
|
9
|
+
rails g deb
|
10
|
+
rake db:migrate
|
11
|
+
|
12
|
+
|
13
|
+
Example
|
14
|
+
|
15
|
+
@asset = Account.create(kind: "asset")
|
16
|
+
@revenue = Account.create(kind: "revenue")
|
17
|
+
@liability = Account.create(kind: "liability")
|
18
|
+
|
19
|
+
Transaction.start! do
|
20
|
+
debit @asset, 12
|
21
|
+
credit @revenue, 5
|
22
|
+
credit @liability, 7
|
23
|
+
description "foobar"
|
24
|
+
reference @mysome_record
|
25
|
+
end
|
26
|
+
|
27
|
+
TODO: more documentation: balances
|
28
|
+
|
29
|
+
|
30
|
+
Copyright (c) 2013 Boris Nadion
|
31
|
+
|
@@ -8,6 +8,8 @@ module Deb
|
|
8
8
|
has_many :credit_items, class_name: "Deb::Item", conditions: {kind: "credit"}
|
9
9
|
has_many :credit_accounts, through: :credit_items
|
10
10
|
|
11
|
+
validate :debit_items_presence
|
12
|
+
validate :credit_items_presence
|
11
13
|
validate :proper_amounts
|
12
14
|
|
13
15
|
attr_accessible :reference, :description
|
@@ -22,9 +24,15 @@ module Deb
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
def
|
27
|
+
def debit_items_presence
|
26
28
|
errors.add(:base, "no debit items") if debit_items.blank?
|
29
|
+
end
|
30
|
+
|
31
|
+
def credit_items_presence
|
27
32
|
errors.add(:base, "no credit items") if credit_items.blank?
|
33
|
+
end
|
34
|
+
|
35
|
+
def proper_amounts
|
28
36
|
errors.add(:base, "wrong credit total is not equal debit total") unless credit_items.collect(&:amount).reduce(:+) == debit_items.collect(&:amount).reduce(:+)
|
29
37
|
end
|
30
38
|
|
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.2
|
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: -1261436476112288047
|
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: -1261436476112288047
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
157
|
rubygems_version: 1.8.25
|