<% reference_year = @filter_params[:filteryear].to_i || Date.today.year %> Bilancio Emissioni del <%= reference_year %> per cassa
Al <%= Date.today.to_dmy %> <% codici = SrgCrb.all.ordered_by_name %> <% dates = (1..12).map{|m| DateTime.new( reference_year, m, 1) } %> <% months = I18n.t("date.month_names").drop(1) %> <% totals = Hash[(1..12).map{ |m| [DateTime.new(reference_year, m, 1), 0] } ] %> <% casseinfo = SrgQec.get_virtual_funds(reference_year) %> <% cassekeys = casseinfo.collect {|info| info[:fund_key] } %> <% months.each do |month| %> <% end %> <% srgqec_rows = {} %> <% dates.each do |date| %> <% srgqec_rows[date] = SrgQec.aggrega_debito_credito((SrgQec.get_query_competenza_sum(date)).take.to_row, date) %> <% end %> <% casseinfo.each do |cassainfo| %> <% total = 0.0 %> <% dates.each do |date| %> <% value = srgqec_rows[date][cassainfo[:fund_key]] %> <% total += value %> <% totals[date] += value %> <% end %> <% end %> <% total = 0.0 %> <% dates.each do |date| %> <% value = SrgSalvadanaio.get_importo(competenza: cast_daterange(date) ) %> <% total += value %> <% totals[date] += value %> <% end %> <% total = 0.0 %> <% dates.each do |date| %> <% value = PensionFund.get_importo(date) %> <% total += value %> <% totals[date] += value %> <% end %> <% regions_ids = Region.all.pluck(:id) %> <% total = 0.0 %> <% dates.each do |date| %> <% value = Region.get_regions_commitments_emessi_on(date) %> <% total += value %> <% totals[date] += value %> <% end %> <% bigtotal = 0.0 %> <% dates.each do |date| %> <% bigtotal += totals[date] %> <% end %>
<%= month %>TOTALE
<%= link_to(cassainfo[:fund_record].descrizione, srg_qec_fund_path(cassainfo[:fund_record].id)) %><%= money_format_zero(value) %><%= money_format_zero(total) %>
<%= SrgSalvadanaio.label %><%= money_format_zero(value) %><%= money_format_zero(total) %>
<%= PensionFund.label %><%= money_format_zero(value) %><%= money_format_zero(total) %>
<%= Commitment.label %><%= money_format_zero(value) %><%= money_format_zero(total) %>
totali mese:<%= money_format_zero(totals[date]) %><%= money_format_zero(bigtotal) %>


Bilancio Emissioni del <%= reference_year %> per CRB
Al <%= Date.today.to_dmy %>
Attenzione: raggruppamento per CRB ancora INCOMPLETO!
<% totals = Hash[(1..12).map{ |m| [DateTime.new(reference_year, m, 1), 0] } ] %> <% months.each do |month| %> <% end %> <% codici.each do |codice_crb| %> <% total = 0 %> <% dates.each do |date| %> <% value1 = SrgAdac.where(data: date, srg_crb_id: codice_crb.id).sum(:importo) %> <% value2 = SrgFsn.where(data: date, srg_crb_id: codice_crb.id).sum(:importo) %> <% case codice_crb.cod %> <% when SrgSalvadanaio.get_SrgCrb_id then %> <% value3 = SrgSalvadanaio.get_importo(competenza: date) %> <% when SrgCrbsHelper::SrgCrbUTEATE_code then %> <% value3 = SrgQec.where(competenza: date).sum(:atenari) %> <% when SrgCrbsHelper::SrgCrbUTEMIL_code then %> <% value3 = SrgQec.where(competenza: date).sum(:milri) %> <% when SrgCrbsHelper::SrgCrbQUOASS_code then %> <% value3 = SrgQec.where(competenza: date).sum('milq + atenaq + csd - csc') %> <% else %> <% value3 = 0 %> <% end %> <% value = value1 + value2 + value3 %> <% 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) %>