<% if @fp_fp_nilYear %> <% year = Date.today.year %> <% else %> <% year = @fp_valueYear %> <% end %> PROSPETTO ANNUALE <%= SrgAdac.label.upcase %> per CRB
anno <%= year.to_s %>
Aggiornato al <%= Date.today.to_dmy %>

<% dates = (1..12).map{|d| DateTime.new(year, d, 1) } %> <% totals = Hash[(1..12).map{ |d| [DateTime.new(year, d, 1), 0] } ] %> <% months = I18n.t("date.month_names").drop(1) %> <% crbs = SrgCrb.ordered_by_name %> <% months.each do |month| %> <% end %> <% crbs.each do |crb| %> <% total = 0 %> <% dates.each do |date| %> <% value = SrgAdac.where(srg_crb_id: crb.id, data: date).sum(:importo) %> <% total += value %> <% totals[date] += value %> <% end %> <% end %> <% bigtotal = 0 %> <% dates.each do |date| %> <% bigtotal += totals[date] %> <% end %>
<%= month %>TOTALE
annuale
CRB
<%= crb.cod %><%= money_format_zero(value) %><%= money_format_zero(total) %>
totali mese:<%= money_format_zero(totals[date]) %><%= money_format_zero(bigtotal) %>