Class: Gestorh::FolhaAgrupada

Inherits:
GestorhRecord show all
Defined in:
app/models/gestorh/folha_agrupada.rb

Instance Method Summary collapse

Instance Method Details

#diariasObject

diarias



69
70
71
72
# File 'app/models/gestorh/folha_agrupada.rb', line 69

def diarias
  self.daily_rates.where(date: [Date.new(self.ano, self.mes)..Date.new(self.ano, self.mes).at_end_of_month])
    .sum(:pago)
end

#diarias_negativasObject



79
80
81
82
# File 'app/models/gestorh/folha_agrupada.rb', line 79

def diarias_negativas
  self.daily_rates.where(pago: [-Float::INFINITY..0], date: [Date.new(self.ano, self.mes)..Date.new(self.ano, self.mes).at_end_of_month])
      .sum(:pago)
end

#diarias_positivasObject



74
75
76
77
# File 'app/models/gestorh/folha_agrupada.rb', line 74

def diarias_positivas
  self.daily_rates.where(pago: [0..Float::INFINITY], date: [Date.new(self.ano, self.mes)..Date.new(self.ano, self.mes).at_end_of_month])
      .sum(:pago)
end

#eventos_e_valoresObject



16
17
18
19
20
21
22
23
24
# File 'app/models/gestorh/folha_agrupada.rb', line 16

def eventos_e_valores
  Gestorh::MovimentoAcumulado.where(mv_regfolha: self.folhas, mv_matricula: self.matricula)
    .joins(:evento_folha_pagamento)
    .where.not('evento_folha_pagamentos.tipo': 'DESCONTO_PREVIDENCIA_PUBLICA_IAPEP')
    .select('mv_regfolha as folha_id', 'mv_verba as codigo_evento',
      'evento_folha_pagamentos.descricao as nome_evento',
      'mv_dc as status', 'mv_total as valor', 'evento_folha_pagamentos.tipo')
    .to_a
end

#gratificacoesObject



54
55
56
# File 'app/models/gestorh/folha_agrupada.rb', line 54

def gratificacoes
  self.eventos_e_valores.select{|x| x.tipo == 'RENDIMENTO_GRATIFICACOES' && x.status == 'C'}
end

#indenizacoesObject



46
47
48
# File 'app/models/gestorh/folha_agrupada.rb', line 46

def indenizacoes
  self.eventos_e_valores.select{|x| x.tipo == 'RENDIMENTO_INDENIZACOES' && x.status == 'C' }
end

#liquido_totalObject



12
13
14
# File 'app/models/gestorh/folha_agrupada.rb', line 12

def liquido_total
  self.rendimento_total - self.desconto_total
end

#remuneracao_paradigmaObject



26
27
28
29
30
31
32
# File 'app/models/gestorh/folha_agrupada.rb', line 26

def remuneracao_paradigma
  if Date.new(ano, mes, 1) < Date.new(2013,7,1)
    self.eventos_e_valores.select{|x| x.tipo == 'RENDIMENTO_REMUNERACAO' && x.status == 'C'}
  else
    []
  end
end

#subsidio_vantagens_pessoaisObject

sobrou da show



59
60
61
# File 'app/models/gestorh/folha_agrupada.rb', line 59

def subsidio_vantagens_pessoais
  self.eventos_e_valores.select{|x| x.tipo == 'RENDIMENTO_VANTAGENS_EVENTUAIS' || x.tipo == 'RENDIMENTO_VANTAGENS_PESSOAIS'}
end

#subsidio_vantagens_pessoais_eventuaisObject



63
64
65
66
# File 'app/models/gestorh/folha_agrupada.rb', line 63

def subsidio_vantagens_pessoais_eventuais
  self.eventos_e_valores.select{|x| x.tipo == 'RENDIMENTO_SUBSIDIO_DIFERENCA_FUNCAO' ||
    x.tipo == 'RENDIMENTO_VANTAGENS_PESSOAIS' || (x.tipo == 'RENDIMENTO_VANTAGENS_EVENTUAIS' && x.status == 'C')}
end

#subsidiosObject



38
39
40
41
42
43
44
# File 'app/models/gestorh/folha_agrupada.rb', line 38

def subsidios
  if Date.new(ano, mes, 1) < Date.new(2013,7,1)
    []
  else
    self.eventos_e_valores.select{|x| (x.tipo == 'RENDIMENTO_SUBSIDIO_DIFERENCA_FUNCAO' ||  x.tipo == 'RENDIMENTO_REMUNERACAO') && x.status == 'C'}
  end
end

#vantagens_eventuaisObject



50
51
52
# File 'app/models/gestorh/folha_agrupada.rb', line 50

def vantagens_eventuais
  self.eventos_e_valores.select{|x| x.tipo == 'RENDIMENTO_VANTAGENS_EVENTUAIS' && x.status == 'C'}
end

#vantagens_pessoaisObject



34
35
36
# File 'app/models/gestorh/folha_agrupada.rb', line 34

def vantagens_pessoais
  self.eventos_e_valores.select{|x| x.tipo == 'RENDIMENTO_VANTAGENS_PESSOAIS' && x.status == 'C'}
end