<% reference_year = @filter_params[:filteryear].to_i || Date.today.year %> Bilancio Prima Nota del <%= reference_year %>
Al <%= Date.today.to_dmy %> <% codici = SrgCrb.all.ordered_by_name %> <% dates = (1..12).map{|d| DateTime.new( reference_year, d, 1) } %> <% months = I18n.t("date.month_names").drop(1) %> <% totals = Hash[(1..12).map{ |d| [DateTime.new(reference_year, d, 1), 0] } ] %> <% months.each do |month| %> <% end %> <% codici.each do |codice_crb| %> <% total = 0 %> <% dates.each do |date| %> <% value = SrgPn.where(competenza: date, srg_crb_id: codice_crb.id).sum(:importo) %> <% total += value %> <% totals[date] += value %> <% end %> <% end %> <% bigtotal = 0 %> <% dates.each do |date| %> <% bigtotal += totals[date] %> <% end %>
<%= month %>TOTALE
<%= codice_crb.format_for_formselect %><%= money_format_zero(value) %><%= money_format_zero(total) %>
totali mese:<%= money_format_zero(totals[date]) %><%= money_format_zero(bigtotal) %>