<% months = I18n.t("date.month_names").drop(1) %>
<% functions = EmoFunction.left_joins(:emo_sector).left_joins(:emo_fund).order('emo_funds.codice, emo_sectors.descrizione').pluck(:emo_fund_id, :emo_sector_id).uniq %>
Cassa/Settore |
<%= EmoMonth.human_attribute_name(:ore_effettive) %> |
<%= EmoMonth.human_attribute_name(:ore_bp) %> |
<%= EmoMonth.human_attribute_name(:monthly_hours) %> |
<%= EmoMonth.human_attribute_name(:rimborsi_vari) %> |
<%= EmoMonth.human_attribute_name(:rimborso_bp) %> |
<%= EmoMonth.human_attribute_name(:rimborso_km) %> |
<%= EmoMonth.human_attribute_name(:totalemese_importo) %> |
<%= EmoMonth.human_attribute_name(:busta_paga) %> |
<%= EmoMonth.human_attribute_name(:compenso_importo) %> |
<%= EmoMonth.human_attribute_name(:importo_versato) %> |
<%= EmoMonth.human_attribute_name(:importo_scalato) %> |
<%= EmoMonth.human_attribute_name(:importo_dapagare) %> |
<% totals = Hash[(1..12).map{ |d| [DateTime.new(Date.today.year, d, 1), 0] } ] %>
<% tot_ore_effettive = 0 %>
<% tot_ore_bp = 0 %>
<% tot_monthly_hours = 0 %>
<% tot_rimborsi_vari = 0 %>
<% tot_rimborso_bp = 0 %>
<% tot_rimborso_km = 0 %>
<% tot_busta_paga = 0 %>
<% tot_totalemese_importo = 0 %>
<% tot_compenso_importo = 0 %>
<% tot_versamento_importo = 0 %>
<% tot_scalo_importo = 0 %>
<% functions.each do |function| %>
<% sect_ore_effettive = 0 %>
<% sect_ore_bp = 0 %>
<% sect_monthly_hours = 0 %>
<% sect_rimborsi_vari = 0 %>
<% sect_rimborso_bp = 0 %>
<% sect_rimborso_km = 0 %>
<% sect_busta_paga = 0 %>
<% sect_totalemese = 0 %>
<% sect_compenso_importo = 0 %>
<% sect_versamento_importo = 0 %>
<% sect_scalo_importo = 0 %>
<% fund_id = function[0].to_i %>
<% fund = EmoFund.find(fund_id) %>
<% sector_id = function[1].to_i %>
<% sector = EmoSector.find(sector_id) %>
<% emofunctions = EmoFunction.where(emo_sector_id: sector_id, emo_fund_id: fund_id).order(:descrizione) %>
<% count_rows_not_null = 0 %>
<% emofunctions.each do |emofunction| %>
<% emomonths = EmoMonth.search(@filter_params, true).where(competenza: @filter_params[:filterdate].to_date).where(emo_function_id: emofunction.id) %>
<% emomonths.each do |emomonth| %>
<% if emomonth.any_value_not_null? %>
<% count_rows_not_null += 1 %>
<% if count_rows_not_null == 1 %>
<%= "#{fund.codice}/#{sector.descrizione}" %> |
|
<% end %>
<%= "#{emofunction.descrizione}" %> |
<%= emomonth.ore_effettive %> |
<%= emomonth.ore_bp %> |
<%= emomonth.monthly_hours %> |
<%= money_format(emomonth.rimborsi_vari) %> |
<%= emomonth.rimborso_bp %> |
<%= emomonth.rimborso_km %> |
<%= money_format(emomonth.totalemese_importo) %> |
<%= money_format(emomonth.busta_paga) %> |
<%= money_format(emomonth.compenso_importo) %> |
<%= money_format(emomonth.importo_versato) %> |
<%= money_format(emomonth.importo_scalato) %> |
<%= money_format(emomonth.importo_dapagare) %> |
<% sect_ore_effettive += (emomonth.ore_effettive || 0) %>
<% sect_ore_bp += (emomonth.ore_bp || 0) %>
<% sect_monthly_hours += (emomonth.monthly_hours || 0) %>
<% sect_rimborsi_vari += (emomonth.rimborsi_vari || 0) %>
<% sect_rimborso_bp += (emomonth.rimborso_bp || 0) %>
<% sect_rimborso_km += (emomonth.rimborso_km || 0) %>
<% sect_totalemese += (emomonth.totalemese_importo || 0) %>
<% sect_busta_paga += (emomonth.busta_paga || 0) %>
<% sect_compenso_importo += (emomonth.compenso_importo || 0) %>
<% sect_versamento_importo += (emomonth.importo_versato || 0) %>
<% sect_scalo_importo += (emomonth.importo_scalato || 0) %>
<% end %>
<% end %>
<% end %>
<% if count_rows_not_null > 0 %>
subtotali mese del settore: |
<%= sect_ore_effettive %> |
<%= sect_ore_bp %> |
<%= sect_monthly_hours %> |
<%= money_format(sect_rimborsi_vari) %> |
<%= sect_rimborso_bp %> |
<%= sect_rimborso_km %> |
<%= money_format(sect_totalemese) %> |
<%= money_format(sect_busta_paga) %> |
<%= money_format(sect_compenso_importo) %> |
<%= money_format(sect_versamento_importo) %> |
<%= money_format(sect_scalo_importo) %> |
<%= money_format(sect_compenso_importo - sect_versamento_importo + sect_scalo_importo) %> |
<% tot_ore_effettive += sect_ore_effettive %>
<% tot_ore_bp += sect_ore_bp %>
<% tot_monthly_hours += sect_monthly_hours %>
<% tot_rimborsi_vari += sect_rimborsi_vari %>
<% tot_rimborso_bp += sect_rimborso_bp %>
<% tot_rimborso_km += sect_rimborso_km %>
<% tot_totalemese_importo += sect_totalemese %>
<% tot_busta_paga += sect_busta_paga %>
<% tot_compenso_importo += sect_compenso_importo %>
<% tot_versamento_importo += sect_versamento_importo %>
<% tot_scalo_importo += sect_scalo_importo %>
<% end %>
<% end %>
<% bigtotal = 0 %>
totali mese delle funzioni: |
<%= tot_ore_effettive %> |
<%= tot_ore_bp %> |
<%= tot_monthly_hours %> |
<%= money_format(tot_rimborsi_vari) %> |
<%= tot_rimborso_bp %> |
<%= tot_rimborso_km %> |
<%= money_format(tot_totalemese_importo) %> |
<%= money_format(tot_busta_paga) %> |
<%= money_format(tot_compenso_importo) %> |
<%= money_format(tot_versamento_importo) %> |
<%= money_format(tot_scalo_importo) %> |
<%= money_format(tot_compenso_importo - tot_versamento_importo + tot_scalo_importo) %> |