% 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| %>
<%= month %> |
<% end %>
TOTALE |
<% 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| %>
<%= link_to(cassainfo[:fund_record].descrizione, srg_qec_fund_path(cassainfo[:fund_record].id)) %> |
<% total = 0.0 %>
<% dates.each do |date| %>
<% value = srgqec_rows[date][cassainfo[:fund_key]] %>
<% total += value %>
<%= money_format_zero(value) %> |
<% totals[date] += value %>
<% end %>
<%= money_format_zero(total) %> |
<% end %>
<%= SrgSalvadanaio.label %> |
<% total = 0.0 %>
<% dates.each do |date| %>
<% value = SrgSalvadanaio.get_importo(competenza: cast_daterange(date) ) %>
<% total += value %>
<%= money_format_zero(value) %> |
<% totals[date] += value %>
<% end %>
<%= money_format_zero(total) %> |
<%= PensionFund.label %> |
<% total = 0.0 %>
<% dates.each do |date| %>
<% value = PensionFund.get_importo(date) %>
<% total += value %>
<%= money_format_zero(value) %> |
<% totals[date] += value %>
<% end %>
<%= money_format_zero(total) %> |
<%= Commitment.label %> |
<% regions_ids = Region.all.pluck(:id) %>
<% total = 0.0 %>
<% dates.each do |date| %>
<% value = Region.get_regions_commitments_emessi_on(date) %>
<% total += value %>
<%= money_format_zero(value) %> |
<% totals[date] += value %>
<% end %>
<%= money_format_zero(total) %> |
<% bigtotal = 0.0 %>
totali mese: |
<% dates.each do |date| %>
<%= money_format_zero(totals[date]) %> |
<% bigtotal += totals[date] %>
<% end %>
<%= 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| %>
<%= month %> |
<% end %>
TOTALE |
<% codici.each do |codice_crb| %>
<%= codice_crb.format_for_formselect %> |
<% 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 %>
<%= money_format_zero(value) %> |
<% totals[date] += value %>
<% end %>
<%= money_format_zero(total) %> |
<% end %>
<% bigtotal = 0 %>
totali mese: |
<% dates.each do |date| %>
<%= money_format_zero(totals[date]) %> |
<% bigtotal += totals[date] %>
<% end %>
<%= money_format_zero(bigtotal) %> |