Skip to content

Commit

Permalink
Merge 09ea069 into 00a98af
Browse files Browse the repository at this point in the history
  • Loading branch information
vstabile committed May 29, 2018
2 parents 00a98af + 09ea069 commit ce5ef88
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/models/plutus/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module Plutus
class Account < ActiveRecord::Base
class_attribute :normal_credit_balance

has_many :amounts
has_many :amounts, :dependent => :destroy
has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount'
has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount'
has_many :entries, through: :amounts, source: :entry
Expand Down
2 changes: 1 addition & 1 deletion app/models/plutus/amount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Plutus
#
# @author Michael Bulat
class Amount < ActiveRecord::Base
belongs_to :entry, :class_name => 'Plutus::Entry'
belongs_to :entry, :class_name => 'Plutus::Entry', :dependent => :destroy
belongs_to :account, :class_name => 'Plutus::Account'

validates_presence_of :type, :amount, :entry, :account
Expand Down
13 changes: 9 additions & 4 deletions app/models/plutus/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ class Entry < ActiveRecord::Base
belongs_to :commercial_document, :polymorphic => true
end

has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount', :inverse_of => :entry
has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount', :inverse_of => :entry
has_many :credit_accounts, :through => :credit_amounts, :source => :account, :class_name => 'Plutus::Account'
has_many :debit_accounts, :through => :debit_amounts, :source => :account, :class_name => 'Plutus::Account'
has_many :amounts, :class_name => 'Plutus::Amount', :dependent => :destroy
has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount',
:inverse_of => :entry
has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount',
:inverse_of => :entry
has_many :credit_accounts, :through => :credit_amounts, :source => :account,
:class_name => 'Plutus::Account'
has_many :debit_accounts, :through => :debit_amounts, :source => :account,
:class_name => 'Plutus::Account'

validates_presence_of :description
validate :has_credit_amounts?
Expand Down
3 changes: 3 additions & 0 deletions lib/plutus.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Plutus
require "rails"
require "jquery-rails"
require "jquery-ui-rails"
require "kaminari"

module Plutus
class Engine < Rails::Engine
Expand Down
7 changes: 3 additions & 4 deletions plutus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Gem::Specification.new do |s|
"README.markdown"
]
s.add_dependency("rails", "> 4.0")
s.add_dependency("jquery-rails", ">= 3.0")
s.add_dependency("jquery-ui-rails", ">= 4.2.2")
s.add_dependency("kaminari", "~> 1.0")
s.add_dependency("jquery-rails", "~> 4.0")
s.add_dependency("jquery-ui-rails", "~> 5.0")
s.add_dependency("kaminari", "~> 1.1")
s.add_development_dependency("yard")
s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE", "Rakefile", "README.markdown"]
s.homepage = %q{http://github.com/mbulat/plutus}
Expand All @@ -40,4 +40,3 @@ Gem::Specification.new do |s|
else
end
end

0 comments on commit ce5ef88

Please sign in to comment.