This commit is contained in:
Nicolas Bally 2021-05-20 21:45:08 +02:00
parent 067b625fa9
commit d5dbc20627
2 changed files with 17 additions and 17 deletions

View File

@ -139,22 +139,22 @@ class Admin::SheetsController < ApplicationController
@gift_years = { @gift_years = {
:nbr_foyers => SheetYear.count(:conditions => ['year = ? AND gift_year = ? ',@year, true]), :nbr_foyers => SheetYear.where('year = ? AND gift_year = ? ',@year, true).count(),
:nbr_familles => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND join_type = ?',@year, true,2]), :nbr_familles => SheetYear.where('year = ? AND gift_year = ? AND join_type = ?',@year, true,2).count(),
:nbr_associations => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND join_type = ?',@year, true,3]), :nbr_associations => SheetYear.where('year = ? AND gift_year = ? AND join_type = ?',@year, true,3).count(),
:nbr_individuel => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND join_type = ?',@year, true,1]), :nbr_individuel => SheetYear.where('year = ? AND gift_year = ? AND join_type = ?',@year, true,1).count(),
:nbr_benefactors => SheetYear.count(:conditions => ['year = ? AND gift_year = ? AND benefactor = ?',@year, true,true]) :nbr_benefactors => SheetYear.where('year = ? AND gift_year = ? AND benefactor = ?',@year, true,true).count()
} }
@gift_years[:pouvoirs] = (@gift_years[:nbr_familles] + @gift_years[:nbr_associations])*2 + @gift_years[:nbr_individuel] @gift_years[:pouvoirs] = (@gift_years[:nbr_familles] + @gift_years[:nbr_associations])*2 + @gift_years[:nbr_individuel]
@renewed_prev_year = { @renewed_prev_year = {
:nbr_foyers => SheetYear.count(:conditions => ['year = ? AND paid_at < ? ',@year, @start_date]), :nbr_foyers => SheetYear.where('year = ? AND paid_at < ? ',@year, @start_date).count(),
:nbr_familles => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,2]), :nbr_familles => SheetYear.where('year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,2).count(),
:nbr_associations => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,3]), :nbr_associations => SheetYear.where('year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,3).count(),
:nbr_individuel => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,1]), :nbr_individuel => SheetYear.where('year = ? AND paid_at < ? AND join_type = ?',@year, @start_date,1).count(),
:nbr_benefactors => SheetYear.count(:conditions => ['year = ? AND paid_at < ? AND benefactor = ?',@year, @start_date,true]) :nbr_benefactors => SheetYear.where('year = ? AND paid_at < ? AND benefactor = ?',@year, @start_date,true).count()
} }
@renewed_prev_year[:pouvoirs] = (@renewed_prev_year[:nbr_familles] + @renewed_prev_year[:nbr_associations])*2 + @renewed_prev_year[:nbr_individuel] @renewed_prev_year[:pouvoirs] = (@renewed_prev_year[:nbr_familles] + @renewed_prev_year[:nbr_associations])*2 + @renewed_prev_year[:nbr_individuel]
@ -179,11 +179,11 @@ class Admin::SheetsController < ApplicationController
while month <= @end_date while month <= @end_date
@months[month.month.to_s] = { @months[month.month.to_s] = {
:month => month.month, :month => month.month,
:nbr_foyers => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? ',@year, month, month.end_of_month]), :nbr_foyers => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? ',@year, month, month.end_of_month).count(),
:nbr_familles => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,2]), :nbr_familles => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,2).count(),
:nbr_associations => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,3]), :nbr_associations => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,3).count(),
:nbr_individuel => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,1]), :nbr_individuel => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND join_type = ?',@year, month, month.end_of_month,1).count(),
:nbr_benefactors => SheetYear.count(:conditions => ['year = ? AND paid_at >= ? and paid_at <= ? AND benefactor = ?',@year, month, month.end_of_month,true]) :nbr_benefactors => SheetYear.where('year = ? AND paid_at >= ? and paid_at <= ? AND benefactor = ?',@year, month, month.end_of_month,true).count()
} }

View File

@ -1,5 +1,5 @@
-last_year= SheetYear.find(:first, :order => "year DESC").year -last_year= SheetYear.order("year DESC").first.year
-first_year= SheetYear.find(:first, :order => "year ASC").year -first_year= SheetYear.order("year ASC").first.year
-y = last_year -y = last_year
#stat_years #stat_years