Hi all, I have a billing application in which I want to create a matrix-type view of period billings by accounting number and by period. It''s almost working, but not quite, and I''m not Rails-savvy enough to take it further. Can anyone point me in the right direction? Thanks in advance! -Katie The app is on github so you can see the models, joins, etc: https://github.com/sdstoic/billing/tree/master/app CONTROLLER (period_billings): def period_billings @sla = Sla.find(params[:sla_id]) @current_period = PeriodCounter.first.period.pe_number @period_billings = @sla.period_billings.sort_by { |pb| [pb.period.pe_number, pb.general_ledger.general_ledger_number] } @billings = Array.new(@period_billings.collect { |pb| pb.general_ledger.general_ledger_number }).uniq.sort_by { |gl| gl } @periods = Period.where("fiscal_year = ?", @sla.fiscal_year) @general_ledgers = GeneralLedger.sla_related @total_period_billings @sla.period_billings.group_by(&:general_ledger_id) #@sum_current_amt @sla.period_billings.sum(current_amt).group_by(&:general_ledger_id) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @period_billings } end end VIEW (_period_billings.html.erb): <% @cumulative_total = 0 %> <div id="gl_crosstab"> <table> <tr> <th>Period</th> <% @general_ledgers.each do |g| %> <th><%= g.general_ledger_number %></th> <% end %> <th>Total</th> <th>% Expended</th> </tr> <% @period_billings.group_by(&:general_ledger_id).each do |pb| %> <tr> <td><%= pb[1].first.period.pe_number %></td> <% pb[1].each do |p| %> <td> <% @sum_current_amt = pb[1].inject(0){|sum,p| sum + p.current_amt.to_i} %> <%= number_to_currency(@sum_current_amt) %> </td> <% end %> <td> <% @cumulative_total = @cumulative_total + pb[1].inject(0){| sum,billing| sum+billing.current_amt.to_i} %> <%= number_to_currency( @cumulative_total ) %> </td> <td><%= number_to_currency((@cumulative_total/ @sla.project_total)*100) %> % </td> </tr> <% end %> </table> </div> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.