% currentperiod = ApplicationController.helpers.daterange_current() %>
<% index_now = 0 %>
<% srg_pn_fund_id = srg_pn_fund.present? ? srg_pn_fund.id : nil %>
<% totals = {} %>
<% rowcount = 0 %>
<% dataset = SrgPn.where({srg_pn_fund_id: srg_pn_fund_id, srg_pn_costcenter_id: nil}) %>
<% if dataset.any? %>
<% rowcount += 1 %>
<% totale += importo %>
<% row_total = 0.0 %>
|
(non assegnato) |
<%# sum = dataset.where("competenza < ?", currentperiod.next_month(how_many_months_back)).sum(:importo) %>
<% sum = dataset.where("data < ?", currentperiod.next_month(how_many_months_back)).sum(:importo) %>
<% row_total += sum %>
<% totals[:before] = (totals[:before] || 0.0) + sum %>
<%= money_format(sum) %> |
<% (how_many_months_back..index_now).each do |m| %>
<%# sum = dataset.where(competenza: currentperiod.next_month(m)).sum(:importo) %>
<% sum = dataset.where(data: currentperiod.next_month(m)..(currentperiod.next_month(m).end_of_month)).sum(:importo) %>
<% row_total += sum %>
<% totals[m] = (totals[m] || 0.0) + sum %>
<%= money_format(sum) %> |
<% end %>
<%= money_format(row_total) %> |
<% end %>
<% @centri.each do |centro| %>
<% dataset = SrgPn.where({srg_pn_fund_id: srg_pn_fund_id, srg_pn_costcenter_id: centro.id}) %>
<% if dataset.any? %>
<% rowcount += 1 %>
<% row_total = 0.0 %>
<%= srg_pn_fund.present? ? link_to(srg_pn_fund.cassa, srg_pn_fund_path(srg_pn_fund.id)) : nil %> |
<%= link_to(centro.centro, srg_pn_costcenter_path(centro.id)) %> |
<%# sum = dataset.where("competenza < ?", currentperiod.next_month(how_many_months_back)).sum(:importo) %>
<% sum = dataset.where("data < ?", currentperiod.next_month(how_many_months_back)).sum(:importo) %>
<% row_total += sum %>
<% totals[:before] = (totals[:before] || 0.0) + sum %>
<%= money_format(sum) %> |
<% (how_many_months_back..index_now).each do |m| %>
<%# sum = dataset.where(competenza: currentperiod.next_month(m)).sum(:importo) %>
<% sum = dataset.where(data: currentperiod.next_month(m)..(currentperiod.next_month(m).end_of_month)).sum(:importo) %>
<% row_total += sum %>
<% totals[m] = (totals[m] || 0.0) + sum %>
<%= money_format(sum) %> |
<% end %>
<%= money_format(row_total) %> |
<% end %>
<% end %>
<% if rowcount > 0 %>
<% row_total = 0.0 %>
|
totale |
<%= money_format(totals[:before]) %> |
<% row_total += (totals[:before] || 0.0) %>
<% (how_many_months_back..index_now).each do |m| %>
<%= money_format(totals[m]) %> |
<% row_total += (totals[m] || 0.0) %>
<% end %>
<%= money_format(row_total) %> |
<% end %>