app/models/esa/transaction.rb in event_sourced_accounting-0.1.0 vs app/models/esa/transaction.rb in event_sourced_accounting-0.1.1

- old
+ new

@@ -1,21 +1,24 @@ +require 'esa/associations/amounts_extension' +require 'esa/traits/extendable' + module ESA # Transactions are the recording of debits and credits to various accounts. # This table can be thought of as a traditional accounting Journal. # # Transactions are created from transitions in the corresponding Flag. # # @author Lenno Nagel, Michael Bulat class Transaction < ActiveRecord::Base - include Traits::Extendable + include ESA::Traits::Extendable attr_accessible :description, :accountable, :flag, :time attr_readonly :description, :accountable, :flag, :time belongs_to :accountable, :polymorphic => true belongs_to :flag - has_many :amounts, :extend => Associations::AmountsExtension + has_many :amounts, :extend => ESA::Associations::AmountsExtension has_many :accounts, :through => :amounts, :source => :account, :uniq => true after_initialize :default_values validates_presence_of :time, :description @@ -27,17 +30,17 @@ attr_accessible :credits, :debits def credits=(*attributes) attributes.flatten.each do |attrs| attrs[:transaction] = self - self.amounts << Amounts::Credit.new(attrs) + self.amounts << ESA::Amounts::Credit.new(attrs) end end def debits=(*attributes) attributes.flatten.each do |attrs| attrs[:transaction] = self - self.amounts << Amounts::Debit.new(attrs) + self.amounts << ESA::Amounts::Debit.new(attrs) end end private