Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
rails plugin of Martin's Fowler "Accounting Patterns"
Ruby
branch: master

This branch is 2 commits ahead of renoke:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
generators/tramp
lib
tasks
test
.gitignore
MIT-LICENSE
README
Rakefile
init.rb
install.rb
tramp_plugin.tmproj
uninstall.rb

README

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
Something went wrong with that request. Please try again.