<% if @fp_fp_nilYear %> <% year = Date.today.year %> <% else %> <% year = @fp_valueYear %> <% end %> PROSPETTO ANNUALE <%= SrgSalvadanaio.label.upcase %>
anno <%= year.to_s %>
secondo il filtro applicato:
<%= SrgSalvadanaio.humanize_filter(@filter_params) %>

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) %> <% services = SrgService.ordered_by_name %> <% months.each do |month| %> <% end %> <% count_row_not_null = 0 %> <% services.each do |service| %> <% month_values = Hash[(1..12).map{ |d| [DateTime.new(year, d, 1), 0] } ] %> <% count_not_null = 0 %> <% total = 0 %> <% dates.each do |date| %> <% value = SrgSalvadanaio.search(@filter_params) .unscope(where: :srg_service_id) .unscope(where: :competenza) .where(srg_service_id: service.id, competenza: date).sum(:importo) %> <% total += value %> <% month_values[date] = value %> <% count_not_null += 1 if value.is_not_zero? %> <% totals[date] += value %> <% end %> <% if count_not_null > 0 %> <% count_row_not_null += 1 %> <% dates.each do |date| %> <% end %> <% end %> <% end %> <% if count_row_not_null > 1 %> <% bigtotal = 0 %> <% dates.each do |date| %> <% bigtotal += totals[date] %> <% end %> <% end %>
<%= month %>TOTALE
annuale
servizio
<%= service.cassa %> <%= money_format_zero(month_values[date]) %> <%= money_format_zero(total) %>
totali mese:<%= money_format_zero(totals[date]) %><%= money_format_zero(bigtotal) %>