tyche 0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +23 -0
  3. data/README.markdown +392 -0
  4. data/Rakefile +11 -0
  5. data/app/assets/javascripts/plutus/application.js +16 -0
  6. data/app/assets/javascripts/plutus/reports.js +5 -0
  7. data/app/assets/stylesheets/bootstrap-theme.min.css +5 -0
  8. data/app/assets/stylesheets/bootstrap.min.css +5 -0
  9. data/app/assets/stylesheets/plutus/application.css +19 -0
  10. data/app/controllers/plutus/accounts_controller.rb +30 -0
  11. data/app/controllers/plutus/application_controller.rb +4 -0
  12. data/app/controllers/plutus/entries_controller.rb +34 -0
  13. data/app/controllers/plutus/reports_controller.rb +40 -0
  14. data/app/models/plutus/account.rb +172 -0
  15. data/app/models/plutus/amount.rb +24 -0
  16. data/app/models/plutus/amounts_extension.rb +42 -0
  17. data/app/models/plutus/asset.rb +56 -0
  18. data/app/models/plutus/balance_finders/base_balance_finder.rb +13 -0
  19. data/app/models/plutus/credit_amount.rb +10 -0
  20. data/app/models/plutus/debit_amount.rb +10 -0
  21. data/app/models/plutus/entry.rb +77 -0
  22. data/app/models/plutus/equity.rb +56 -0
  23. data/app/models/plutus/expense.rb +56 -0
  24. data/app/models/plutus/liability.rb +56 -0
  25. data/app/models/plutus/no_tenancy.rb +9 -0
  26. data/app/models/plutus/revenue.rb +56 -0
  27. data/app/models/plutus/tenancy.rb +15 -0
  28. data/app/views/layouts/plutus/_messages.html.erb +9 -0
  29. data/app/views/layouts/plutus/_navigation.html.erb +19 -0
  30. data/app/views/layouts/plutus/_navigation_links.html.erb +5 -0
  31. data/app/views/layouts/plutus/application.html.erb +19 -0
  32. data/app/views/plutus/accounts/index.html.erb +26 -0
  33. data/app/views/plutus/entries/index.html.erb +59 -0
  34. data/app/views/plutus/reports/_account.html.erb +28 -0
  35. data/app/views/plutus/reports/balance_sheet.html.erb +21 -0
  36. data/app/views/plutus/reports/income_statement.html.erb +24 -0
  37. data/config/backtrace_silencers.rb +7 -0
  38. data/config/database.yml +5 -0
  39. data/config/inflections.rb +10 -0
  40. data/config/mime_types.rb +5 -0
  41. data/config/routes.rb +9 -0
  42. data/config/secret_token.rb +7 -0
  43. data/config/session_store.rb +8 -0
  44. data/db/migrate/20160422010135_create_plutus_tables.rb +35 -0
  45. data/lib/generators/plutus/USAGE +22 -0
  46. data/lib/generators/plutus/add_date_upgrade_generator.rb +11 -0
  47. data/lib/generators/plutus/base_generator.rb +19 -0
  48. data/lib/generators/plutus/plutus_generator.rb +12 -0
  49. data/lib/generators/plutus/templates/tenant_migration.rb +6 -0
  50. data/lib/generators/plutus/tenancy_generator.rb +12 -0
  51. data/lib/generators/plutus/upgrade_plutus_generator.rb +12 -0
  52. data/lib/plutus.rb +20 -0
  53. data/lib/plutus/engine.rb +5 -0
  54. data/lib/plutus/version.rb +3 -0
  55. data/spec/controllers/accounts_controller_spec.rb +19 -0
  56. data/spec/controllers/entries_controller_spec.rb +19 -0
  57. data/spec/controllers/reports_controller_spec.rb +24 -0
  58. data/spec/factories/account_factory.rb +35 -0
  59. data/spec/factories/amount_factory.rb +20 -0
  60. data/spec/factories/entry_factory.rb +11 -0
  61. data/spec/lib/plutus_spec.rb +0 -0
  62. data/spec/models/account_spec.rb +133 -0
  63. data/spec/models/amount_spec.rb +13 -0
  64. data/spec/models/asset_spec.rb +7 -0
  65. data/spec/models/credit_amount_spec.rb +7 -0
  66. data/spec/models/debit_amount_spec.rb +7 -0
  67. data/spec/models/entry_spec.rb +182 -0
  68. data/spec/models/equity_spec.rb +7 -0
  69. data/spec/models/expense_spec.rb +7 -0
  70. data/spec/models/liability_spec.rb +7 -0
  71. data/spec/models/revenue_spec.rb +7 -0
  72. data/spec/models/tenancy_spec.rb +45 -0
  73. data/spec/rcov.opts +2 -0
  74. data/spec/routing/accounts_routing_spec.rb +13 -0
  75. data/spec/routing/entries_routing_spec.rb +13 -0
  76. data/spec/spec.opts +4 -0
  77. data/spec/spec_helper.rb +30 -0
  78. data/spec/support/account_shared_examples.rb +62 -0
  79. data/spec/support/active_support_helpers.rb +13 -0
  80. data/spec/support/amount_shared_examples.rb +21 -0
  81. data/spec/support/factory_girl_helpers.rb +8 -0
  82. data/spec/support/shoulda_matchers.rb +8 -0
  83. metadata +240 -0
@@ -0,0 +1,2 @@
1
+ --exclude "spec/*,gems/*"
2
+ --rails
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ module Plutus
4
+ describe AccountsController do
5
+ routes { Plutus::Engine.routes }
6
+
7
+ describe "routing" do
8
+ it "recognizes and generates #index" do
9
+ expect(:get => "/accounts").to route_to(:controller => "plutus/accounts", :action => "index")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ module Plutus
4
+ describe EntriesController do
5
+ routes { Plutus::Engine.routes }
6
+
7
+ describe "routing" do
8
+ it "recognizes and generates #index" do
9
+ expect(:get => "/entries").to route_to(:controller => "plutus/entries", :action => "index")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,30 @@
1
+ # require 'coveralls'
2
+ # Coveralls.wear!
3
+
4
+ ENV["RAILS_ENV"] ||= 'test'
5
+ require File.expand_path(File.dirname(__FILE__) + "/../fixture_rails_root/config/environment")
6
+
7
+ require Rails.root.join('db/schema').to_s
8
+ require 'rspec/rails'
9
+
10
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib/')
11
+ require 'plutus'
12
+ require 'kaminari'
13
+
14
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
15
+
16
+ require 'factory_bot'
17
+ plutus_definitions = File.expand_path(File.join(File.dirname(__FILE__), 'factories'))
18
+ FactoryBot.definition_file_paths << plutus_definitions
19
+
20
+
21
+ RSpec.configure do |config|
22
+ config.use_transactional_fixtures = true
23
+ config.infer_spec_type_from_file_location!
24
+ config.include(Shoulda::Matchers::ActiveRecord, type: :model)
25
+ config.include FactoryBot::Syntax::Methods
26
+
27
+ end
28
+
29
+
30
+ FactoryBotHelpers.reload()
@@ -0,0 +1,62 @@
1
+ require 'bigdecimal'
2
+
3
+ shared_examples_for 'a Plutus::Account subtype' do |elements|
4
+ let(:contra) { false }
5
+ let(:account) { FactoryBot.create(elements[:kind], contra: contra)}
6
+ subject { account }
7
+
8
+ describe "class methods" do
9
+ subject { account.class }
10
+ its(:balance) { is_expected.to be_kind_of(BigDecimal) }
11
+ describe "trial_balance" do
12
+ it "should raise NoMethodError" do
13
+ expect { subject.trial_balance }.to raise_error NoMethodError
14
+ end
15
+ end
16
+ end
17
+
18
+ describe "instance methods" do
19
+ its(:balance) { is_expected.to be_kind_of(BigDecimal) }
20
+
21
+ it "reports a balance with date range" do
22
+ expect(account.balance(:from_date => "2014-01-01", :to_date => Date.today)).to be_kind_of(BigDecimal)
23
+ end
24
+
25
+ it { is_expected.to respond_to(:credit_entries) }
26
+ it { is_expected.to respond_to(:debit_entries) }
27
+ end
28
+
29
+ it "requires a name" do
30
+ account.name = nil
31
+ expect(account).not_to be_valid
32
+ end
33
+
34
+ # Figure out which way credits and debits should apply
35
+ if elements[:normal_balance] == :debit
36
+ debit_condition = :>
37
+ credit_condition = :<
38
+ else
39
+ credit_condition = :>
40
+ debit_condition = :<
41
+ end
42
+
43
+ describe "when given a debit" do
44
+ before { FactoryBot.create(:debit_amount, account: account) }
45
+ its(:balance) { is_expected.to be.send(debit_condition, 0) }
46
+
47
+ describe "on a contra account" do
48
+ let(:contra) { true }
49
+ its(:balance) { is_expected.to be.send(credit_condition, 0) }
50
+ end
51
+ end
52
+
53
+ describe "when given a credit" do
54
+ before { FactoryBot.create(:credit_amount, account: account) }
55
+ its(:balance) { is_expected.to be.send(credit_condition, 0) }
56
+
57
+ describe "on a contra account" do
58
+ let(:contra) { true }
59
+ its(:balance) { is_expected.to be.send(debit_condition, 0) }
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,13 @@
1
+ module ActiveSupportHelpers
2
+ # Helps in removing model, and force-reloading it next time This helper does 2
3
+ # things:
4
+ # * remove from $LOADED_FEATURES so that ruby 'require' reloads file again
5
+ # * remove the constant from active support dependencies
6
+ def self.clear_model(model_name)
7
+ ActiveSupport::Dependencies.remove_constant('Plutus::' + model_name)
8
+
9
+ models_dir = File.dirname(__FILE__) + '/../../app/models/plutus/'
10
+ path = File.expand_path(models_dir + model_name.downcase + '.rb')
11
+ $LOADED_FEATURES.delete(path)
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ shared_examples_for 'a Plutus::Amount subtype' do |elements|
2
+ let(:amount) { FactoryBot.build(elements[:kind]) }
3
+ subject { amount }
4
+
5
+ it { is_expected.to be_valid }
6
+
7
+ it "should require an amount" do
8
+ amount.amount = nil
9
+ expect(amount).not_to be_valid
10
+ end
11
+
12
+ it "should require a entry" do
13
+ amount.entry = nil
14
+ expect(amount).not_to be_valid
15
+ end
16
+
17
+ it "should require an account" do
18
+ amount.account = nil
19
+ expect(amount).not_to be_valid
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module FactoryBotHelpers
2
+ def self.reload
3
+ FactoryBot.factories.clear()
4
+ FactoryBot.sequences.clear()
5
+ FactoryBot.traits.clear()
6
+ FactoryBot.find_definitions()
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'shoulda-matchers'
2
+
3
+ Shoulda::Matchers.configure do |config|
4
+ config.integrate do |with|
5
+ with.test_framework :rspec
6
+ with.library :active_record
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,240 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tyche
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.14'
5
+ platform: ruby
6
+ authors:
7
+ - Michael Bulat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jquery-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jquery-ui-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 4.2.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 4.2.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: kaminari
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: shoulda-matchers
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: The plutus plugin provides a complete double entry accounting system
98
+ for use in any Ruby on Rails application. The plugin follows general Double Entry
99
+ Bookkeeping practices. All calculations are done using BigDecimal in order to prevent
100
+ floating point rounding errors. The plugin requires a decimal type on your database
101
+ as well.
102
+ email: mbulat@crazydogsoftware.com
103
+ executables: []
104
+ extensions: []
105
+ extra_rdoc_files:
106
+ - LICENSE
107
+ - README.markdown
108
+ files:
109
+ - LICENSE
110
+ - README.markdown
111
+ - Rakefile
112
+ - app/assets/javascripts/plutus/application.js
113
+ - app/assets/javascripts/plutus/reports.js
114
+ - app/assets/stylesheets/bootstrap-theme.min.css
115
+ - app/assets/stylesheets/bootstrap.min.css
116
+ - app/assets/stylesheets/plutus/application.css
117
+ - app/controllers/plutus/accounts_controller.rb
118
+ - app/controllers/plutus/application_controller.rb
119
+ - app/controllers/plutus/entries_controller.rb
120
+ - app/controllers/plutus/reports_controller.rb
121
+ - app/models/plutus/account.rb
122
+ - app/models/plutus/amount.rb
123
+ - app/models/plutus/amounts_extension.rb
124
+ - app/models/plutus/asset.rb
125
+ - app/models/plutus/balance_finders/base_balance_finder.rb
126
+ - app/models/plutus/credit_amount.rb
127
+ - app/models/plutus/debit_amount.rb
128
+ - app/models/plutus/entry.rb
129
+ - app/models/plutus/equity.rb
130
+ - app/models/plutus/expense.rb
131
+ - app/models/plutus/liability.rb
132
+ - app/models/plutus/no_tenancy.rb
133
+ - app/models/plutus/revenue.rb
134
+ - app/models/plutus/tenancy.rb
135
+ - app/views/layouts/plutus/_messages.html.erb
136
+ - app/views/layouts/plutus/_navigation.html.erb
137
+ - app/views/layouts/plutus/_navigation_links.html.erb
138
+ - app/views/layouts/plutus/application.html.erb
139
+ - app/views/plutus/accounts/index.html.erb
140
+ - app/views/plutus/entries/index.html.erb
141
+ - app/views/plutus/reports/_account.html.erb
142
+ - app/views/plutus/reports/balance_sheet.html.erb
143
+ - app/views/plutus/reports/income_statement.html.erb
144
+ - config/backtrace_silencers.rb
145
+ - config/database.yml
146
+ - config/inflections.rb
147
+ - config/mime_types.rb
148
+ - config/routes.rb
149
+ - config/secret_token.rb
150
+ - config/session_store.rb
151
+ - db/migrate/20160422010135_create_plutus_tables.rb
152
+ - lib/generators/plutus/USAGE
153
+ - lib/generators/plutus/add_date_upgrade_generator.rb
154
+ - lib/generators/plutus/base_generator.rb
155
+ - lib/generators/plutus/plutus_generator.rb
156
+ - lib/generators/plutus/templates/tenant_migration.rb
157
+ - lib/generators/plutus/tenancy_generator.rb
158
+ - lib/generators/plutus/upgrade_plutus_generator.rb
159
+ - lib/plutus.rb
160
+ - lib/plutus/engine.rb
161
+ - lib/plutus/version.rb
162
+ - spec/controllers/accounts_controller_spec.rb
163
+ - spec/controllers/entries_controller_spec.rb
164
+ - spec/controllers/reports_controller_spec.rb
165
+ - spec/factories/account_factory.rb
166
+ - spec/factories/amount_factory.rb
167
+ - spec/factories/entry_factory.rb
168
+ - spec/lib/plutus_spec.rb
169
+ - spec/models/account_spec.rb
170
+ - spec/models/amount_spec.rb
171
+ - spec/models/asset_spec.rb
172
+ - spec/models/credit_amount_spec.rb
173
+ - spec/models/debit_amount_spec.rb
174
+ - spec/models/entry_spec.rb
175
+ - spec/models/equity_spec.rb
176
+ - spec/models/expense_spec.rb
177
+ - spec/models/liability_spec.rb
178
+ - spec/models/revenue_spec.rb
179
+ - spec/models/tenancy_spec.rb
180
+ - spec/rcov.opts
181
+ - spec/routing/accounts_routing_spec.rb
182
+ - spec/routing/entries_routing_spec.rb
183
+ - spec/spec.opts
184
+ - spec/spec_helper.rb
185
+ - spec/support/account_shared_examples.rb
186
+ - spec/support/active_support_helpers.rb
187
+ - spec/support/amount_shared_examples.rb
188
+ - spec/support/factory_girl_helpers.rb
189
+ - spec/support/shoulda_matchers.rb
190
+ homepage: http://github.com/mbulat/plutus
191
+ licenses: []
192
+ metadata: {}
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: 1.3.6
207
+ requirements: []
208
+ rubygems_version: 3.0.2
209
+ signing_key:
210
+ specification_version: 3
211
+ summary: A Plugin providing a Double Entry Accounting Engine for Rails
212
+ test_files:
213
+ - spec/spec_helper.rb
214
+ - spec/spec.opts
215
+ - spec/models/revenue_spec.rb
216
+ - spec/models/expense_spec.rb
217
+ - spec/models/account_spec.rb
218
+ - spec/models/tenancy_spec.rb
219
+ - spec/models/debit_amount_spec.rb
220
+ - spec/models/amount_spec.rb
221
+ - spec/models/liability_spec.rb
222
+ - spec/models/entry_spec.rb
223
+ - spec/models/credit_amount_spec.rb
224
+ - spec/models/asset_spec.rb
225
+ - spec/models/equity_spec.rb
226
+ - spec/rcov.opts
227
+ - spec/support/active_support_helpers.rb
228
+ - spec/support/shoulda_matchers.rb
229
+ - spec/support/account_shared_examples.rb
230
+ - spec/support/amount_shared_examples.rb
231
+ - spec/support/factory_girl_helpers.rb
232
+ - spec/factories/entry_factory.rb
233
+ - spec/factories/amount_factory.rb
234
+ - spec/factories/account_factory.rb
235
+ - spec/lib/plutus_spec.rb
236
+ - spec/routing/entries_routing_spec.rb
237
+ - spec/routing/accounts_routing_spec.rb
238
+ - spec/controllers/reports_controller_spec.rb
239
+ - spec/controllers/accounts_controller_spec.rb
240
+ - spec/controllers/entries_controller_spec.rb