plutus 0.5.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +116 -69
- data/Rakefile +7 -20
- data/app/assets/javascripts/plutus/application.js +15 -0
- data/app/assets/stylesheets/plutus/application.css +13 -0
- data/app/assets/stylesheets/plutus/main.css.scss +86 -0
- data/app/controllers/plutus/accounts_controller.rb +45 -0
- data/app/controllers/plutus/transactions_controller.rb +44 -0
- data/app/models/plutus/account.rb +60 -0
- data/app/models/plutus/amount.rb +16 -0
- data/app/models/plutus/asset.rb +83 -0
- data/app/models/plutus/credit_amount.rb +10 -0
- data/app/models/plutus/debit_amount.rb +10 -0
- data/app/models/plutus/equity.rb +84 -0
- data/app/models/plutus/expense.rb +83 -0
- data/app/models/plutus/liability.rb +78 -0
- data/app/models/plutus/revenue.rb +83 -0
- data/app/models/plutus/transaction.rb +83 -0
- data/app/views/{accounts → plutus/accounts}/index.html.erb +4 -2
- data/app/views/{accounts → plutus/accounts}/show.html.erb +8 -18
- data/app/views/plutus/transactions/index.html.erb +48 -0
- data/app/views/plutus/transactions/show.html.erb +46 -0
- data/config/database.yml +5 -0
- data/config/routes.rb +6 -0
- data/lib/generators/plutus/templates/migration.rb +17 -13
- data/lib/plutus.rb +3 -2
- data/lib/plutus/version.rb +3 -0
- data/spec/controllers/accounts_controller_spec.rb +22 -19
- data/spec/controllers/transactions_controller_spec.rb +23 -20
- data/spec/factories/account_factory.rb +30 -24
- data/spec/factories/amount_factory.rb +19 -0
- data/spec/factories/transaction_factory.rb +11 -6
- data/spec/models/account_spec.rb +61 -40
- data/spec/models/amount_spec.rb +12 -0
- data/spec/models/asset_spec.rb +46 -39
- data/spec/models/credit_amount_spec.rb +22 -0
- data/spec/models/debit_amount_spec.rb +22 -0
- data/spec/models/equity_spec.rb +51 -43
- data/spec/models/expense_spec.rb +49 -41
- data/spec/models/liability_spec.rb +48 -40
- data/spec/models/revenue_spec.rb +48 -41
- data/spec/models/transaction_spec.rb +77 -42
- data/spec/routing/accounts_routing_spec.rb +23 -20
- data/spec/routing/transactions_routing_spec.rb +23 -20
- data/spec/spec_helper.rb +3 -1
- metadata +208 -139
- data/.yardopts +0 -2
- data/VERSION.yml +0 -5
- data/app/controllers/accounts_controller.rb +0 -43
- data/app/controllers/transactions_controller.rb +0 -42
- data/app/models/account.rb +0 -57
- data/app/models/asset.rb +0 -81
- data/app/models/equity.rb +0 -82
- data/app/models/expense.rb +0 -81
- data/app/models/liability.rb +0 -76
- data/app/models/revenue.rb +0 -81
- data/app/models/transaction.rb +0 -27
- data/app/views/layouts/accounts.html.erb +0 -68
- data/app/views/layouts/transactions.html.erb +0 -68
- data/app/views/transactions/index.html.erb +0 -27
- data/app/views/transactions/show.html.erb +0 -24
- data/doc/Account.html +0 -300
- data/doc/AccountsController.html +0 -317
- data/doc/Asset.html +0 -610
- data/doc/CreatePlutusTables.html +0 -265
- data/doc/Equity.html +0 -610
- data/doc/Expense.html +0 -610
- data/doc/Liability.html +0 -588
- data/doc/Plutus.html +0 -91
- data/doc/Plutus/Engine.html +0 -100
- data/doc/PlutusGenerator.html +0 -312
- data/doc/Revenue.html +0 -610
- data/doc/Transaction.html +0 -156
- data/doc/TransactionsController.html +0 -317
- data/doc/_index.html +0 -204
- data/doc/class_list.html +0 -36
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -53
- data/doc/css/style.css +0 -310
- data/doc/file.README.html +0 -250
- data/doc/file_list.html +0 -38
- data/doc/frames.html +0 -13
- data/doc/index.html +0 -250
- data/doc/js/app.js +0 -202
- data/doc/js/full_list.js +0 -149
- data/doc/js/jquery.js +0 -154
- data/doc/method_list.html +0 -275
- data/doc/top-level-namespace.html +0 -90
- data/fixture_rails_root/.gitignore +0 -4
- data/fixture_rails_root/Gemfile +0 -38
- data/fixture_rails_root/Gemfile.lock +0 -98
- data/fixture_rails_root/README +0 -256
- data/fixture_rails_root/Rakefile +0 -7
- data/fixture_rails_root/app/controllers/application_controller.rb +0 -3
- data/fixture_rails_root/app/helpers/application_helper.rb +0 -2
- data/fixture_rails_root/app/views/layouts/application.html.erb +0 -14
- data/fixture_rails_root/config.ru +0 -4
- data/fixture_rails_root/config/application.rb +0 -42
- data/fixture_rails_root/config/boot.rb +0 -13
- data/fixture_rails_root/config/database.yml +0 -22
- data/fixture_rails_root/config/environment.rb +0 -5
- data/fixture_rails_root/config/environments/development.rb +0 -26
- data/fixture_rails_root/config/environments/production.rb +0 -49
- data/fixture_rails_root/config/environments/test.rb +0 -35
- data/fixture_rails_root/config/initializers/backtrace_silencers.rb +0 -7
- data/fixture_rails_root/config/initializers/inflections.rb +0 -10
- data/fixture_rails_root/config/initializers/mime_types.rb +0 -5
- data/fixture_rails_root/config/initializers/secret_token.rb +0 -7
- data/fixture_rails_root/config/initializers/session_store.rb +0 -8
- data/fixture_rails_root/config/locales/en.yml +0 -5
- data/fixture_rails_root/config/routes.rb +0 -58
- data/fixture_rails_root/db/migrate/20101203193439_create_plutus_tables.rb +0 -33
- data/fixture_rails_root/db/schema.rb +0 -40
- data/fixture_rails_root/db/seeds.rb +0 -7
- data/fixture_rails_root/doc/README_FOR_APP +0 -2
- data/fixture_rails_root/lib/tasks/.gitkeep +0 -0
- data/fixture_rails_root/public/404.html +0 -26
- data/fixture_rails_root/public/422.html +0 -26
- data/fixture_rails_root/public/500.html +0 -26
- data/fixture_rails_root/public/favicon.ico +0 -0
- data/fixture_rails_root/public/images/rails.png +0 -0
- data/fixture_rails_root/public/index.html +0 -239
- data/fixture_rails_root/public/javascripts/application.js +0 -2
- data/fixture_rails_root/public/javascripts/controls.js +0 -965
- data/fixture_rails_root/public/javascripts/dragdrop.js +0 -974
- data/fixture_rails_root/public/javascripts/effects.js +0 -1123
- data/fixture_rails_root/public/javascripts/prototype.js +0 -6001
- data/fixture_rails_root/public/javascripts/rails.js +0 -175
- data/fixture_rails_root/public/robots.txt +0 -5
- data/fixture_rails_root/public/stylesheets/.gitkeep +0 -0
- data/fixture_rails_root/script/rails +0 -6
- data/fixture_rails_root/test/performance/browsing_test.rb +0 -9
- data/fixture_rails_root/test/test_helper.rb +0 -13
- data/fixture_rails_root/vendor/plugins/.gitkeep +0 -0
- data/plutus.gemspec +0 -176
- data/tasks/plutus_tasks.rake +0 -4
@@ -1,25 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
module Plutus
|
4
|
+
describe TransactionsController do
|
5
|
+
# Run these tests if you enable routing in your rails app. See README
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
2
|
-
account
|
3
|
-
|
4
|
-
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :account, :class => Plutus::Account do |account|
|
3
|
+
account.name
|
4
|
+
account.contra false
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
factory :asset, :class => Plutus::Asset do |account|
|
8
|
+
account.name
|
9
|
+
account.contra false
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
12
|
+
factory :equity, :class => Plutus::Equity do |account|
|
13
|
+
account.name
|
14
|
+
account.contra false
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
17
|
+
factory :expense, :class => Plutus::Expense do |account|
|
18
|
+
account.name
|
19
|
+
account.contra false
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
2
|
-
transaction
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
data/spec/models/account_spec.rb
CHANGED
@@ -1,43 +1,64 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
account
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
data/spec/models/asset_spec.rb
CHANGED
@@ -1,46 +1,53 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
6
|
+
it "should allow creating an asset account" do
|
7
|
+
asset = FactoryGirl.create(:asset)
|
8
|
+
end
|
22
9
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
data/spec/models/equity_spec.rb
CHANGED
@@ -1,46 +1,54 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
equity
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
equity
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|