has_accounts 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +4 -1
- data/README.md +2 -7
- data/app/models/account.rb +2 -9
- data/app/models/booking.rb +7 -6
- data/app/models/booking_template.rb +1 -1
- data/db/migrate/20111108000000_create_has_accounts_tables.rb +1 -1
- data/lib/has_accounts/version.rb +1 -1
- metadata +13 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28cbabaea7786eb02bdcae1f7f043c148f10be49
|
4
|
+
data.tar.gz: 222d2bf0e7d2d1a754ecda00e135e3393479c5f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b28f0cf26147ace9c7e5dd584ccd825159f08659aa1a90bdbe31cd3a1496debdd9afc6ebd732299a5f349968e37f145fba98478720a441e1eb9471ecfd0f1b96
|
7
|
+
data.tar.gz: 580e84f7697c19d549c863c4996428dcd7e9274de51815bc8015c9cbb8a0c1c8a67bd391dcc9cc4fe414684226ee1e5b70e2b615e130318538c6f4681b83e506
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
Copyright (c) 2008
|
1
|
+
Copyright (c) 2008 Agrabah <http://www.agrabah.ch>
|
2
|
+
Copyright (c) 2008-2014 Simon Hürlimann <simon.huerlimann@cyt.ch>
|
3
|
+
Copyright (c) 2010-2014 CyT <http://www.cyt.ch>
|
4
|
+
Copyright (c) 2008-2010 ZytoLabor <http://www.zyto-labor.com>
|
2
5
|
|
3
6
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
7
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Rails plugin providing financal accounting models and helpers.
|
|
9
9
|
Install
|
10
10
|
=======
|
11
11
|
|
12
|
-
In Rails
|
12
|
+
In Rails simply add
|
13
13
|
|
14
14
|
gem 'has_accounts'
|
15
15
|
|
@@ -38,7 +38,7 @@ Add specific seed depending on the needs of your project, e.g.:
|
|
38
38
|
capital_assets = AccountType.find_by_name('capital_assets')
|
39
39
|
earnings = AccountType.find_by_name('earnings')
|
40
40
|
costs = AccountType.find_by_name('costs')
|
41
|
-
|
41
|
+
|
42
42
|
Account.create!([
|
43
43
|
{:code => "1000", :title => "Kasse", :account_type => current_assets},
|
44
44
|
{:code => "1100", :title => "Debitoren", :account_type => current_assets},
|
@@ -68,9 +68,4 @@ To use it, simply add the following to your Model:
|
|
68
68
|
License
|
69
69
|
=======
|
70
70
|
|
71
|
-
* Copyright (c) 2008 Agrabah <http://www.agrabah.ch>
|
72
|
-
* Copyright (c) 2008-2011 Simon Hürlimann <simon.huerlimann@cyt.ch>
|
73
|
-
* Copyright (c) 2010-2011 CyT <http://www.cyt.ch>
|
74
|
-
* Copyright (c) 2008-2010 ZytoLabor <http://www.zyto-labor.com>
|
75
|
-
|
76
71
|
Released under the MIT license.
|
data/app/models/account.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# Account model
|
1
2
|
class Account < ActiveRecord::Base
|
2
3
|
# Access restrictions
|
3
4
|
attr_accessible :title, :code
|
@@ -30,26 +31,18 @@ class Account < ActiveRecord::Base
|
|
30
31
|
def asset_account?
|
31
32
|
Account.by_type(['current_assets', 'capital_assets', 'costs']).exists?(self)
|
32
33
|
end
|
33
|
-
# Deprecated
|
34
|
-
alias_method :is_asset_account?, :asset_account?
|
35
34
|
|
36
35
|
def liability_account?
|
37
36
|
!asset_account?
|
38
37
|
end
|
39
|
-
# Deprecated
|
40
|
-
alias_method :is_liability_account?, :liability_account?
|
41
38
|
|
42
39
|
def balance_account?
|
43
40
|
Account.by_type(['current_assets', 'capital_assets', 'outside_capital', 'equity_capital']).exists?(self)
|
44
41
|
end
|
45
|
-
# Deprecated
|
46
|
-
alias_method :is_balance_account?, :balance_account?
|
47
42
|
|
48
43
|
def profit_account?
|
49
44
|
!balance_account?
|
50
45
|
end
|
51
|
-
# Deprecated
|
52
|
-
alias_method :is_profit_account?, :profit_account?
|
53
46
|
|
54
47
|
scope :by_type, lambda {|value| includes(:account_type).where('account_types.name' => value)} do
|
55
48
|
include AccountScopeExtension
|
@@ -146,6 +139,6 @@ class Account < ActiveRecord::Base
|
|
146
139
|
|
147
140
|
amount = debit_amount - credit_amount
|
148
141
|
|
149
|
-
return
|
142
|
+
return asset_account? ? amount : -amount
|
150
143
|
end
|
151
144
|
end
|
data/app/models/booking.rb
CHANGED
@@ -52,13 +52,13 @@ class Booking < ActiveRecord::Base
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def balance_account
|
55
|
-
return credit_account if credit_account.
|
56
|
-
return debit_account if debit_account.
|
55
|
+
return credit_account if credit_account.balance_account?
|
56
|
+
return debit_account if debit_account.balance_account?
|
57
57
|
end
|
58
58
|
|
59
59
|
def profit_account
|
60
|
-
return credit_account if credit_account.
|
61
|
-
return debit_account if debit_account.
|
60
|
+
return credit_account if credit_account.profit_account?
|
61
|
+
return debit_account if debit_account.profit_account?
|
62
62
|
end
|
63
63
|
|
64
64
|
# Scoping
|
@@ -147,7 +147,8 @@ class Booking < ActiveRecord::Base
|
|
147
147
|
# @param account_or_id Account id or object
|
148
148
|
def self.unbalanced_by_grouped_reference(account_or_id)
|
149
149
|
# Do a manual sum using select() to be able to give it an alias we can use in having()
|
150
|
-
|
150
|
+
balance_select = "sum(#{SELECT_ACCOUNTED_AMOUNT % {:account_id => get_account_id(account_or_id)}})"
|
151
|
+
summs = group(:reference_type, :reference_id).having("#{balance_select} != 0.0").select("reference_type, reference_id, #{balance_select} AS balance").reorder(nil)
|
151
152
|
|
152
153
|
# Simulate Rails grouped summing result format
|
153
154
|
grouped = Hash[summs.map{ |group| [[group[:reference_type], group[:reference_id]], group[:balance]] }]
|
@@ -222,7 +223,7 @@ class Booking < ActiveRecord::Base
|
|
222
223
|
return BigDecimal.new('0')
|
223
224
|
end
|
224
225
|
|
225
|
-
if account.
|
226
|
+
if account.asset_account?
|
226
227
|
return balance
|
227
228
|
else
|
228
229
|
return -(balance)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class BookingTemplate < ActiveRecord::Base
|
2
2
|
# Access restrictions
|
3
|
-
attr_accessible :title, :code, :amount, :amount_relates_to, :comments
|
3
|
+
attr_accessible :title, :code, :amount, :amount_relates_to, :comments, :charge_rate_code
|
4
4
|
|
5
5
|
# Associations
|
6
6
|
belongs_to :debit_account, :foreign_key => 'debit_account_id', :class_name => "Account"
|
@@ -48,7 +48,7 @@ class CreateHasAccountsTables < ActiveRecord::Migration
|
|
48
48
|
t.integer "credit_account_id"
|
49
49
|
t.integer "debit_account_id"
|
50
50
|
t.date "value_date"
|
51
|
-
t.text "comments", :limit => 1000
|
51
|
+
t.text "comments", :limit => 1000
|
52
52
|
t.string "scan"
|
53
53
|
t.string "debit_currency", :default => "CHF"
|
54
54
|
t.string "credit_currency", :default => "CHF"
|
data/lib/has_accounts/version.rb
CHANGED
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_accounts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Simon Hürlimann (CyT)
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.1'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '3.1'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: validates_timeliness
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: HasAccounts is a full featured Rails 3 gem providing models for financial
|
@@ -53,6 +48,8 @@ extra_rdoc_files:
|
|
53
48
|
- MIT-LICENSE
|
54
49
|
- README.md
|
55
50
|
files:
|
51
|
+
- MIT-LICENSE
|
52
|
+
- README.md
|
56
53
|
- app/models/account.rb
|
57
54
|
- app/models/account_scope_extension.rb
|
58
55
|
- app/models/account_type.rb
|
@@ -72,32 +69,28 @@ files:
|
|
72
69
|
- lib/has_accounts/model.rb
|
73
70
|
- lib/has_accounts/railtie.rb
|
74
71
|
- lib/has_accounts/version.rb
|
75
|
-
- MIT-LICENSE
|
76
|
-
- README.md
|
77
72
|
homepage: https://github.com/huerlisi/has_accounts
|
78
73
|
licenses:
|
79
74
|
- MIT
|
75
|
+
metadata: {}
|
80
76
|
post_install_message:
|
81
77
|
rdoc_options: []
|
82
78
|
require_paths:
|
83
79
|
- lib
|
84
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
81
|
requirements:
|
87
|
-
- -
|
82
|
+
- - ">="
|
88
83
|
- !ruby/object:Gem::Version
|
89
84
|
version: '0'
|
90
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
86
|
requirements:
|
93
|
-
- -
|
87
|
+
- - ">="
|
94
88
|
- !ruby/object:Gem::Version
|
95
89
|
version: '0'
|
96
90
|
requirements: []
|
97
91
|
rubyforge_project:
|
98
|
-
rubygems_version:
|
92
|
+
rubygems_version: 2.2.2
|
99
93
|
signing_key:
|
100
|
-
specification_version:
|
94
|
+
specification_version: 4
|
101
95
|
summary: HasAccounts provides models for financial accounting.
|
102
96
|
test_files: []
|
103
|
-
has_rdoc:
|