Hi Prashanta,
This is a feature that is on the list of things to add to Plutus. At the moment, it needs to be done manually by querying the records. Here's an example of a method to obtain a balance of a certain revenue account for a specific time period. It makes use of the ActiveRecord Query Interface which you can read more about here:
http://guides.rubyonrails.org/active_record_querying.html You should be able to do all your reporting with similar types of queries.
First what account are we balancing
revenue_account = Plutus::Revenue.find_by_name("Widget Sales")
Next we need to get all the transactions for the period we are reporting. We only need the IDs, so i'm specifying :id in the select (assumes a start_date and end_date)
period_transactions = Plutus::Transaction.where('created_at >= ?', start_date).where('created_at < ?', end_date).select(:id)
Next we'll find all of the amounts for that account and period (this performs a basic SQL "IN" query with the array of transaction ids)
# map the ids to a string for the next sql query
transaction_id_string = period_transactions.map {|t| t.id}.join(', ')
period_amounts = Plutus::Amount.where(:account_id => revenue_account.id).where("transaction_id IN (#{transaction_id_string})")
You can then loop through all the amount records to add up the balance for that account, something like this:
balance = BigDecimal.new('0')
period_amounts.each do |amount_record|
if amount_record.type == "Plutus::DebitAmount"
balance -= amount_record.amount
else
balance += amount_record.amount
end
end
You'll need to switch the +/- depending on the account type standard balance.
-- Mike