plutus 0.5.2 → 0.7.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.
Files changed (135) hide show
  1. data/README.markdown +116 -69
  2. data/Rakefile +7 -20
  3. data/app/assets/javascripts/plutus/application.js +15 -0
  4. data/app/assets/stylesheets/plutus/application.css +13 -0
  5. data/app/assets/stylesheets/plutus/main.css.scss +86 -0
  6. data/app/controllers/plutus/accounts_controller.rb +45 -0
  7. data/app/controllers/plutus/transactions_controller.rb +44 -0
  8. data/app/models/plutus/account.rb +60 -0
  9. data/app/models/plutus/amount.rb +16 -0
  10. data/app/models/plutus/asset.rb +83 -0
  11. data/app/models/plutus/credit_amount.rb +10 -0
  12. data/app/models/plutus/debit_amount.rb +10 -0
  13. data/app/models/plutus/equity.rb +84 -0
  14. data/app/models/plutus/expense.rb +83 -0
  15. data/app/models/plutus/liability.rb +78 -0
  16. data/app/models/plutus/revenue.rb +83 -0
  17. data/app/models/plutus/transaction.rb +83 -0
  18. data/app/views/{accounts → plutus/accounts}/index.html.erb +4 -2
  19. data/app/views/{accounts → plutus/accounts}/show.html.erb +8 -18
  20. data/app/views/plutus/transactions/index.html.erb +48 -0
  21. data/app/views/plutus/transactions/show.html.erb +46 -0
  22. data/config/database.yml +5 -0
  23. data/config/routes.rb +6 -0
  24. data/lib/generators/plutus/templates/migration.rb +17 -13
  25. data/lib/plutus.rb +3 -2
  26. data/lib/plutus/version.rb +3 -0
  27. data/spec/controllers/accounts_controller_spec.rb +22 -19
  28. data/spec/controllers/transactions_controller_spec.rb +23 -20
  29. data/spec/factories/account_factory.rb +30 -24
  30. data/spec/factories/amount_factory.rb +19 -0
  31. data/spec/factories/transaction_factory.rb +11 -6
  32. data/spec/models/account_spec.rb +61 -40
  33. data/spec/models/amount_spec.rb +12 -0
  34. data/spec/models/asset_spec.rb +46 -39
  35. data/spec/models/credit_amount_spec.rb +22 -0
  36. data/spec/models/debit_amount_spec.rb +22 -0
  37. data/spec/models/equity_spec.rb +51 -43
  38. data/spec/models/expense_spec.rb +49 -41
  39. data/spec/models/liability_spec.rb +48 -40
  40. data/spec/models/revenue_spec.rb +48 -41
  41. data/spec/models/transaction_spec.rb +77 -42
  42. data/spec/routing/accounts_routing_spec.rb +23 -20
  43. data/spec/routing/transactions_routing_spec.rb +23 -20
  44. data/spec/spec_helper.rb +3 -1
  45. metadata +208 -139
  46. data/.yardopts +0 -2
  47. data/VERSION.yml +0 -5
  48. data/app/controllers/accounts_controller.rb +0 -43
  49. data/app/controllers/transactions_controller.rb +0 -42
  50. data/app/models/account.rb +0 -57
  51. data/app/models/asset.rb +0 -81
  52. data/app/models/equity.rb +0 -82
  53. data/app/models/expense.rb +0 -81
  54. data/app/models/liability.rb +0 -76
  55. data/app/models/revenue.rb +0 -81
  56. data/app/models/transaction.rb +0 -27
  57. data/app/views/layouts/accounts.html.erb +0 -68
  58. data/app/views/layouts/transactions.html.erb +0 -68
  59. data/app/views/transactions/index.html.erb +0 -27
  60. data/app/views/transactions/show.html.erb +0 -24
  61. data/doc/Account.html +0 -300
  62. data/doc/AccountsController.html +0 -317
  63. data/doc/Asset.html +0 -610
  64. data/doc/CreatePlutusTables.html +0 -265
  65. data/doc/Equity.html +0 -610
  66. data/doc/Expense.html +0 -610
  67. data/doc/Liability.html +0 -588
  68. data/doc/Plutus.html +0 -91
  69. data/doc/Plutus/Engine.html +0 -100
  70. data/doc/PlutusGenerator.html +0 -312
  71. data/doc/Revenue.html +0 -610
  72. data/doc/Transaction.html +0 -156
  73. data/doc/TransactionsController.html +0 -317
  74. data/doc/_index.html +0 -204
  75. data/doc/class_list.html +0 -36
  76. data/doc/css/common.css +0 -1
  77. data/doc/css/full_list.css +0 -53
  78. data/doc/css/style.css +0 -310
  79. data/doc/file.README.html +0 -250
  80. data/doc/file_list.html +0 -38
  81. data/doc/frames.html +0 -13
  82. data/doc/index.html +0 -250
  83. data/doc/js/app.js +0 -202
  84. data/doc/js/full_list.js +0 -149
  85. data/doc/js/jquery.js +0 -154
  86. data/doc/method_list.html +0 -275
  87. data/doc/top-level-namespace.html +0 -90
  88. data/fixture_rails_root/.gitignore +0 -4
  89. data/fixture_rails_root/Gemfile +0 -38
  90. data/fixture_rails_root/Gemfile.lock +0 -98
  91. data/fixture_rails_root/README +0 -256
  92. data/fixture_rails_root/Rakefile +0 -7
  93. data/fixture_rails_root/app/controllers/application_controller.rb +0 -3
  94. data/fixture_rails_root/app/helpers/application_helper.rb +0 -2
  95. data/fixture_rails_root/app/views/layouts/application.html.erb +0 -14
  96. data/fixture_rails_root/config.ru +0 -4
  97. data/fixture_rails_root/config/application.rb +0 -42
  98. data/fixture_rails_root/config/boot.rb +0 -13
  99. data/fixture_rails_root/config/database.yml +0 -22
  100. data/fixture_rails_root/config/environment.rb +0 -5
  101. data/fixture_rails_root/config/environments/development.rb +0 -26
  102. data/fixture_rails_root/config/environments/production.rb +0 -49
  103. data/fixture_rails_root/config/environments/test.rb +0 -35
  104. data/fixture_rails_root/config/initializers/backtrace_silencers.rb +0 -7
  105. data/fixture_rails_root/config/initializers/inflections.rb +0 -10
  106. data/fixture_rails_root/config/initializers/mime_types.rb +0 -5
  107. data/fixture_rails_root/config/initializers/secret_token.rb +0 -7
  108. data/fixture_rails_root/config/initializers/session_store.rb +0 -8
  109. data/fixture_rails_root/config/locales/en.yml +0 -5
  110. data/fixture_rails_root/config/routes.rb +0 -58
  111. data/fixture_rails_root/db/migrate/20101203193439_create_plutus_tables.rb +0 -33
  112. data/fixture_rails_root/db/schema.rb +0 -40
  113. data/fixture_rails_root/db/seeds.rb +0 -7
  114. data/fixture_rails_root/doc/README_FOR_APP +0 -2
  115. data/fixture_rails_root/lib/tasks/.gitkeep +0 -0
  116. data/fixture_rails_root/public/404.html +0 -26
  117. data/fixture_rails_root/public/422.html +0 -26
  118. data/fixture_rails_root/public/500.html +0 -26
  119. data/fixture_rails_root/public/favicon.ico +0 -0
  120. data/fixture_rails_root/public/images/rails.png +0 -0
  121. data/fixture_rails_root/public/index.html +0 -239
  122. data/fixture_rails_root/public/javascripts/application.js +0 -2
  123. data/fixture_rails_root/public/javascripts/controls.js +0 -965
  124. data/fixture_rails_root/public/javascripts/dragdrop.js +0 -974
  125. data/fixture_rails_root/public/javascripts/effects.js +0 -1123
  126. data/fixture_rails_root/public/javascripts/prototype.js +0 -6001
  127. data/fixture_rails_root/public/javascripts/rails.js +0 -175
  128. data/fixture_rails_root/public/robots.txt +0 -5
  129. data/fixture_rails_root/public/stylesheets/.gitkeep +0 -0
  130. data/fixture_rails_root/script/rails +0 -6
  131. data/fixture_rails_root/test/performance/browsing_test.rb +0 -9
  132. data/fixture_rails_root/test/test_helper.rb +0 -13
  133. data/fixture_rails_root/vendor/plugins/.gitkeep +0 -0
  134. data/plutus.gemspec +0 -176
  135. data/tasks/plutus_tasks.rake +0 -4
@@ -1,25 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe TransactionsController do
3
+ module Plutus
4
+ describe TransactionsController do
5
+ # Run these tests if you enable routing in your rails app. See README
4
6
 
5
- def mock_transaction(stubs={})
6
- @mock_transaction ||= mock_model(Transaction, stubs)
7
- end
8
-
9
- describe "GET index" do
10
- it "assigns all transactions as @transactions" do
11
- Transaction.stub(:find).with(:all).and_return([mock_transaction])
12
- get :index
13
- assigns[:transactions].should == [mock_transaction]
14
- end
15
- end
16
-
17
- describe "GET show" do
18
- it "assigns the requested transaction as @transaction" do
19
- Transaction.stub(:find).with("37").and_return(mock_transaction)
20
- get :show, :id => "37"
21
- assigns[:transaction].should equal(mock_transaction)
22
- end
23
- end
7
+ #def mock_transaction(stubs={})
8
+ #@mock_transaction ||= mock_model(Transaction, stubs)
9
+ #end
10
+
11
+ #describe "GET index" do
12
+ #it "assigns all transactions as @transactions" do
13
+ #Transaction.stub(:find).with(:all).and_return([mock_transaction])
14
+ #get :index
15
+ #assigns[:transactions].should == [mock_transaction]
16
+ #end
17
+ #end
24
18
 
19
+ #describe "GET show" do
20
+ #it "assigns the requested transaction as @transaction" do
21
+ #Transaction.stub(:find).with("37").and_return(mock_transaction)
22
+ #get :show, :id => "37"
23
+ #assigns[:transaction].should equal(mock_transaction)
24
+ #end
25
+ #end
26
+
27
+ end
25
28
  end
@@ -1,29 +1,35 @@
1
- Factory.define :account do |account|
2
- account.name 'factory name'
3
- account.contra false
4
- end
1
+ FactoryGirl.define do
2
+ factory :account, :class => Plutus::Account do |account|
3
+ account.name
4
+ account.contra false
5
+ end
5
6
 
6
- Factory.define :asset do |account|
7
- account.name 'factory name'
8
- account.contra false
9
- end
7
+ factory :asset, :class => Plutus::Asset do |account|
8
+ account.name
9
+ account.contra false
10
+ end
10
11
 
11
- Factory.define :equity do |account|
12
- account.name 'factory name'
13
- account.contra false
14
- end
12
+ factory :equity, :class => Plutus::Equity do |account|
13
+ account.name
14
+ account.contra false
15
+ end
15
16
 
16
- Factory.define :expense do |account|
17
- account.name 'factory name'
18
- account.contra false
19
- end
17
+ factory :expense, :class => Plutus::Expense do |account|
18
+ account.name
19
+ account.contra false
20
+ end
20
21
 
21
- Factory.define :liability do |account|
22
- account.name 'factory name'
23
- account.contra false
24
- end
22
+ factory :liability, :class => Plutus::Liability do |account|
23
+ account.name
24
+ account.contra false
25
+ end
26
+
27
+ factory :revenue, :class => Plutus::Revenue do |account|
28
+ account.name
29
+ account.contra false
30
+ end
25
31
 
26
- Factory.define :revenue do |account|
27
- account.name 'factory name'
28
- account.contra false
29
- end
32
+ sequence :name do |n|
33
+ "Factory Name #{n}"
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ FactoryGirl.define do
2
+ factory :amount, :class => Plutus::Amount do |amount|
3
+ amount.amount BigDecimal.new('473')
4
+ amount.association :transaction, :factory => :transaction_with_credit_and_debit
5
+ amount.association :account, :factory => :asset
6
+ end
7
+
8
+ factory :credit_amount, :class => Plutus::CreditAmount do |credit_amount|
9
+ credit_amount.amount BigDecimal.new('473')
10
+ credit_amount.association :transaction, :factory => :transaction_with_credit_and_debit
11
+ credit_amount.association :account, :factory => :revenue
12
+ end
13
+
14
+ factory :debit_amount, :class => Plutus::DebitAmount do |debit_amount|
15
+ debit_amount.amount BigDecimal.new('473')
16
+ debit_amount.association :transaction, :factory => :transaction_with_credit_and_debit
17
+ debit_amount.association :account, :factory => :asset
18
+ end
19
+ end
@@ -1,6 +1,11 @@
1
- Factory.define :transaction do |transaction|
2
- transaction.description 'factory description'
3
- transaction.credit_account {|credit_account| credit_account.association(:asset)}
4
- transaction.debit_account {|debit_account| debit_account.association(:revenue)}
5
- transaction.amount BigDecimal.new('100')
6
- end
1
+ FactoryGirl.define do
2
+ factory :transaction, :class => Plutus::Transaction do |transaction|
3
+ transaction.description 'factory description'
4
+ factory :transaction_with_credit_and_debit, :class => Plutus::Transaction do |transaction_cd|
5
+ transaction_cd.after_build do |t|
6
+ t.credit_amounts << FactoryGirl.build(:credit_amount, :transaction => t)
7
+ t.debit_amounts << FactoryGirl.build(:debit_amount, :transaction => t)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,43 +1,64 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Account do
4
-
5
- it "should not allow creating an account without a subtype" do
6
- account = Factory.build(:account)
7
- account.should_not be_valid
8
- end
9
-
10
- it "should not have a balance method" do
11
- lambda{Account.balance}.should raise_error(NoMethodError)
12
- end
13
-
14
- it "should have a trial balance" do
15
- Account.should respond_to(:trial_balance)
16
- Account.trial_balance.should be_kind_of(BigDecimal)
17
- end
18
-
19
- it "should report a trial balance of 0 with correct transactions" do
20
- # credit accounts
21
- liability = Factory(:liability)
22
- equity = Factory(:equity)
23
- revenue = Factory(:revenue)
24
- contra_asset = Factory(:asset, :contra => true)
25
- contra_expense = Factory(:expense, :contra => true)
26
-
27
- # debit accounts
28
- asset = Factory(:asset)
29
- expense = Factory(:expense)
30
- contra_liability = Factory(:liability, :contra => true)
31
- contra_equity = Factory(:equity, :contra => true)
32
- contra_revenue = Factory(:revenue, :contra => true)
33
-
34
- Factory(:transaction, :credit_account => liability, :debit_account => asset, :amount => 100000)
35
- Factory(:transaction, :credit_account => equity, :debit_account => expense, :amount => 1000)
36
- Factory(:transaction, :credit_account => revenue, :debit_account => contra_liability, :amount => 40404)
37
- Factory(:transaction, :credit_account => contra_asset, :debit_account => contra_equity, :amount => 2)
38
- Factory(:transaction, :credit_account => contra_expense, :debit_account => contra_revenue, :amount => 333)
39
-
40
- Account.trial_balance.should == 0
41
- end
3
+ module Plutus
4
+ describe Account do
5
+
6
+ it "should not allow creating an account without a subtype" do
7
+ account = FactoryGirl.build(:account)
8
+ account.should_not be_valid
9
+ end
10
+
11
+ it "should be unique per name" do
12
+ FactoryGirl.create(:account, :name => "Test1", :type => "Plutus::Asset")
13
+ account = FactoryGirl.build(:account, :name => "Test1", :type => "Plutus::Asset")
14
+ account.should_not be_valid
15
+ account.errors[:name].should == ["has already been taken"]
16
+ end
17
+
18
+ it "should not have a balance method" do
19
+ lambda{Account.balance}.should raise_error(NoMethodError)
20
+ end
42
21
 
43
- end
22
+ it "should have a trial balance" do
23
+ Account.should respond_to(:trial_balance)
24
+ Account.trial_balance.should be_kind_of(BigDecimal)
25
+ end
26
+
27
+ it "should report a trial balance of 0 with correct transactions" do
28
+ # credit accounts
29
+ liability = FactoryGirl.create(:liability)
30
+ equity = FactoryGirl.create(:equity)
31
+ revenue = FactoryGirl.create(:revenue)
32
+ contra_asset = FactoryGirl.create(:asset, :contra => true)
33
+ contra_expense = FactoryGirl.create(:expense, :contra => true)
34
+ # credit amounts
35
+ ca1 = FactoryGirl.build(:credit_amount, :account => liability, :amount => 100000)
36
+ ca2 = FactoryGirl.build(:credit_amount, :account => equity, :amount => 1000)
37
+ ca3 = FactoryGirl.build(:credit_amount, :account => revenue, :amount => 40404)
38
+ ca4 = FactoryGirl.build(:credit_amount, :account => contra_asset, :amount => 2)
39
+ ca5 = FactoryGirl.build(:credit_amount, :account => contra_expense, :amount => 333)
40
+
41
+ # debit accounts
42
+ asset = FactoryGirl.create(:asset)
43
+ expense = FactoryGirl.create(:expense)
44
+ contra_liability = FactoryGirl.create(:liability, :contra => true)
45
+ contra_equity = FactoryGirl.create(:equity, :contra => true)
46
+ contra_revenue = FactoryGirl.create(:revenue, :contra => true)
47
+ # debit amounts
48
+ da1 = FactoryGirl.build(:debit_amount, :account => asset, :amount => 100000)
49
+ da2 = FactoryGirl.build(:debit_amount, :account => expense, :amount => 1000)
50
+ da3 = FactoryGirl.build(:debit_amount, :account => contra_liability, :amount => 40404)
51
+ da4 = FactoryGirl.build(:debit_amount, :account => contra_equity, :amount => 2)
52
+ da5 = FactoryGirl.build(:debit_amount, :account => contra_revenue, :amount => 333)
53
+
54
+ FactoryGirl.create(:transaction, :credit_amounts => [ca1], :debit_amounts => [da1])
55
+ FactoryGirl.create(:transaction, :credit_amounts => [ca2], :debit_amounts => [da2])
56
+ FactoryGirl.create(:transaction, :credit_amounts => [ca3], :debit_amounts => [da3])
57
+ FactoryGirl.create(:transaction, :credit_amounts => [ca4], :debit_amounts => [da4])
58
+ FactoryGirl.create(:transaction, :credit_amounts => [ca5], :debit_amounts => [da5])
59
+
60
+ Account.trial_balance.should == 0
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ module Plutus
4
+ describe Amount do
5
+
6
+ it "should not allow creating an amount without a subtype" do
7
+ amount = FactoryGirl.build(:amount)
8
+ amount.should_not be_valid
9
+ end
10
+
11
+ end
12
+ end
@@ -1,46 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Asset do
4
-
5
- it "should allow creating an asset account" do
6
- asset = Factory(:asset)
7
- end
8
-
9
- it "should report a balance for the asset account" do
10
- asset = Factory(:asset)
11
- asset.balance.should be_kind_of(BigDecimal)
12
- end
13
-
14
- it "should report a balance for the class of accounts" do
15
- Asset.should respond_to(:balance)
16
- Asset.balance.should be_kind_of(BigDecimal)
17
- end
3
+ module Plutus
4
+ describe Asset do
18
5
 
19
- it "should not report a trial balance" do
20
- lambda{Asset.trial_balance}.should raise_error(NoMethodError)
21
- end
6
+ it "should allow creating an asset account" do
7
+ asset = FactoryGirl.create(:asset)
8
+ end
22
9
 
23
- it "should not be valid without a name" do
24
- asset = Factory.build(:asset, :name => nil)
25
- asset.should_not be_valid
26
- end
27
-
28
- it "should have many credit transactions" do
29
- asset = Factory(:asset)
30
- asset.should respond_to(:credit_transactions)
31
- end
10
+ it "should report a balance for the asset account" do
11
+ asset = FactoryGirl.create(:asset)
12
+ FactoryGirl.create(:debit_amount, :account => asset)
13
+ asset.balance.should > 0
14
+ asset.balance.should be_kind_of(BigDecimal)
15
+ end
32
16
 
33
- it "should have many debit transactions" do
34
- asset = Factory(:asset)
35
- asset.should respond_to(:debit_transactions)
36
- end
17
+ it "should report a balance for the class of accounts" do
18
+ asset = FactoryGirl.create(:asset)
19
+ FactoryGirl.create(:debit_amount, :account => asset)
20
+ Asset.should respond_to(:balance)
21
+ Asset.balance.should > 0
22
+ Asset.balance.should be_kind_of(BigDecimal)
23
+ end
24
+
25
+ it "should not report a trial balance" do
26
+ lambda{Asset.trial_balance}.should raise_error(NoMethodError)
27
+ end
28
+
29
+ it "should not be valid without a name" do
30
+ asset = FactoryGirl.build(:asset, :name => nil)
31
+ asset.should_not be_valid
32
+ end
33
+
34
+ it "should have many credit transactions" do
35
+ asset = Factory(:asset)
36
+ asset.should respond_to(:credit_transactions)
37
+ end
38
+
39
+ it "should have many debit transactions" do
40
+ asset = Factory(:asset)
41
+ asset.should respond_to(:debit_transactions)
42
+ end
43
+
44
+ it "a contra account should reverse the normal balance" do
45
+ contra_asset = Factory(:asset, :contra => true)
46
+ # the odd amount below is because factories create an asset debit_amount
47
+ FactoryGirl.create(:credit_amount, :account => contra_asset, :amount => 473)
48
+ contra_asset.balance.should > 0
49
+ Asset.balance.should == 0
50
+ end
37
51
 
38
- it "a contra account should reverse the normal balance" do
39
- asset = Factory(:asset)
40
- contra_asset = Factory(:asset, :contra => true)
41
- transaction = Factory(:transaction, :credit_account => contra_asset, :debit_account => asset, :amount => 1000)
42
- contra_asset.balance.should > 0
43
- Asset.balance.should == 0
44
52
  end
45
-
46
- end
53
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Plutus
4
+ describe CreditAmount do
5
+
6
+ it "should be invalid without an amount" do
7
+ credit_amount = FactoryGirl.build(:credit_amount, :amount => nil)
8
+ credit_amount.should_not be_valid
9
+ end
10
+
11
+ it "should not be valid without a transaction" do
12
+ credit_amount = FactoryGirl.build(:credit_amount, :transaction => nil)
13
+ credit_amount.should_not be_valid
14
+ end
15
+
16
+ it "should not be valid without an account" do
17
+ credit_amount = FactoryGirl.build(:credit_amount, :account => nil)
18
+ credit_amount.should_not be_valid
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Plutus
4
+ describe DebitAmount do
5
+
6
+ it "should be invalid without an amount" do
7
+ debit_amount = FactoryGirl.build(:debit_amount, :amount => nil)
8
+ debit_amount.should_not be_valid
9
+ end
10
+
11
+ it "should not be valid without a transaction" do
12
+ debit_amount = FactoryGirl.build(:debit_amount, :transaction => nil)
13
+ debit_amount.should_not be_valid
14
+ end
15
+
16
+ it "should not be valid without an account" do
17
+ debit_amount = FactoryGirl.build(:debit_amount, :account => nil)
18
+ debit_amount.should_not be_valid
19
+ end
20
+
21
+ end
22
+ end
@@ -1,46 +1,54 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Equity do
4
-
5
- it "should allow creating a equity account" do
6
- equity = Factory(:equity)
7
- end
8
-
9
- it "should report a balance for the equity account" do
10
- equity = Factory(:equity)
11
- equity.balance.should be_kind_of(BigDecimal)
12
- end
13
-
14
- it "should report a balance for the class of accounts" do
15
- Equity.should respond_to(:balance)
16
- Equity.balance.should be_kind_of(BigDecimal)
17
- end
18
-
19
- it "should not report a trial balance" do
20
- lambda{Equity.trial_balance}.should raise_error(NoMethodError)
21
- end
22
-
23
- it "should not be valid without a name" do
24
- equity = Factory.build(:equity, :name => nil)
25
- equity.should_not be_valid
26
- end
27
-
28
- it "should have many credit transactions" do
29
- equity = Factory(:equity)
30
- equity.should respond_to(:credit_transactions)
31
- end
3
+ module Plutus
4
+ describe Equity do
5
+
6
+ it "should allow creating an equity account" do
7
+ equity = FactoryGirl.create(:equity)
8
+ end
9
+
10
+ it "should report a balance for the equity account" do
11
+ equity = FactoryGirl.create(:equity)
12
+ FactoryGirl.create(:credit_amount, :account => equity)
13
+ equity.balance.should > 0
14
+ equity.balance.should be_kind_of(BigDecimal)
15
+ end
32
16
 
33
- it "should have many debit transactions" do
34
- equity = Factory(:equity)
35
- equity.should respond_to(:debit_transactions)
36
- end
37
-
38
- it "a contra account should reverse the normal balance" do
39
- equity = Factory(:equity)
40
- contra_equity = Factory(:equity, :contra => true)
41
- transaction = Factory(:transaction, :credit_account => equity, :debit_account => contra_equity, :amount => 1000)
42
- contra_equity.balance.should > 0
43
- Equity.balance.should == 0
44
- end
45
-
46
- end
17
+ it "should report a balance for the class of accounts" do
18
+ equity = FactoryGirl.create(:equity)
19
+ FactoryGirl.create(:credit_amount, :account => equity)
20
+ Equity.should respond_to(:balance)
21
+ Equity.balance.should > 0
22
+ Equity.balance.should be_kind_of(BigDecimal)
23
+ end
24
+
25
+ it "should not report a trial balance" do
26
+ lambda{Equity.trial_balance}.should raise_error(NoMethodError)
27
+ end
28
+
29
+ it "should not be valid without a name" do
30
+ equity = FactoryGirl.build(:equity, :name => nil)
31
+ equity.should_not be_valid
32
+ end
33
+
34
+ it "should have many credit transactions" do
35
+ equity = Factory(:equity)
36
+ equity.should respond_to(:credit_transactions)
37
+ end
38
+
39
+ it "should have many debit transactions" do
40
+ equity = Factory(:equity)
41
+ equity.should respond_to(:debit_transactions)
42
+ end
43
+
44
+ it "a contra account should reverse the normal balance" do
45
+ equity = FactoryGirl.create(:equity)
46
+ contra_equity = Factory(:equity, :contra => true)
47
+ FactoryGirl.create(:credit_amount, :account => equity)
48
+ FactoryGirl.create(:debit_amount, :account => contra_equity)
49
+ contra_equity.balance.should > 0
50
+ Equity.balance.should == 0
51
+ end
52
+
53
+ end
54
+ end