Skip to content

Instantly share code, notes, and snippets.

@valterbarros
Created January 17, 2018 21:02
Show Gist options
  • Save valterbarros/23f3752182352968111926fba42eac06 to your computer and use it in GitHub Desktop.
Save valterbarros/23f3752182352968111926fba42eac06 to your computer and use it in GitHub Desktop.
def calculate_scheduled_for_the_month
sum = 0.0
return sum if @planning.empty?
where_for_planning = clause_where_for_planning
i = 0
@planning.where(where_for_planning).each do |p|
p.preenchimentos.each_with_index do |obj, index|
obj.dth_inicio = Time.now - index.days
obj.dth_fim = Time.now + index.days
obj.save
i += 1
break if i == 2
end
value_to_decrease = percentage_qtd_executed_not_formmatted(p, clause_where_for_fvs)
sum += value_to_decrease
end
final_percentage_formatted sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment