Skip to content
/ tramp Public
forked from renoke/tramp

rails plugin of Martin's Fowler "Accounting Patterns"

License

Notifications You must be signed in to change notification settings

knoguchi/tramp

 
 

Repository files navigation

Tramp
=====

Tramp is a rails plugin of Martin's Fowler "Accounting Patterns". It includes Account, Event, Accounting Entry, Accounting Transaction and Posting Rule.



Example
=======

1. Exemple for monetary events. Monetary is a subclass of Tramp::Model::Event who is a subclass of ActiveRecord :

	class MonetaryEvent < Tramp::Model::Event
  
	  attr_accessor :direct_orders
  
	  rule :monetary_posting_rule

	end
	
	The rule is implemented inside the class method "movement" with the rule method add_collection.
	
	class MonetaryPostingRule < Tramp::Model::Rule

	  movement do |rule|
	    rule.collections<<('direct_orders')
	  end  

	end
	
2. Another exemple :

  class AccountingEvent < ActiveRecord::Base
  
    #attributes are amount, party_account, event_account
  
    include Tramp::Event::InstanceMethods
    extend Tramp::Event::ClassMethods
  
    has_one :service_agreement
    
    rule :accounting_posting_rule

  end

  class AccountingPostingRule < Tramp::Model::Rule

    parameter :amount => "service_agreement.fixed_fee + amount * service_agreement.multiplier"

    movement do |rule|
      rule.entries<<({:account=> :party_account, :debit=> :amount})
      rule.entries<<({:account=> :event_account, :credit=> :amount})
    end 

  end
  
3. You can create also anonymous rule in event :

  class EventWithAnonymousRule < Tramp::Model::Event
    rule 'my_rule' do
      movement do |rule|
        rule.entries<<({:date=>Date.today, :account=>'t1', :debit  =>:amount})
        rule.entries<<({:date=>Date.today, :account=>'t2', :credit =>:amount})
      end 
    end
  end
  



	
	



Copyright (c) 2008 Renaud Kern, released under the MIT license

About

rails plugin of Martin's Fowler "Accounting Patterns"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%