Skip to content

Commit

Permalink
Closes #231
Browse files Browse the repository at this point in the history
  • Loading branch information
vtamara committed Oct 2, 2023
1 parent a48c594 commit 5b17268
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/msip/personas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def atributos_show
:actividad_ids,
:caso_ids,
:familiarvictima_ids,
:proximo_aporte,
:aportes,
:fecha_desafiliacion_aportante,
:etiqueta_ids,
]
end
Expand All @@ -44,6 +46,7 @@ def atributos_form
:actividad_ids,
:caso_ids,
:familiarvictima_ids,
:proximo_aporte
]
a[a.index(:familiares)] = :persona_trelacion1
return a
Expand All @@ -69,6 +72,7 @@ def atributos_index
:actividad_ids,
:caso_ids,
:familiarvictima_ids,
:proximo_aporte,
:aportes,
]
end
Expand Down
28 changes: 28 additions & 0 deletions app/models/msip/persona.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ def sindoc_estandar
end
end

validate :sin_aportes_tras_desafiliacion
def sin_aportes_tras_desafiliacion
if !self.fecha_desafiliacion_aportante
return
end
aporte.each do |a|
if (a.anio && a.mes &&
a.anio > self.fecha_desafiliacion_aportante.year ||
(a.anio == self.fecha_desafiliacion_aportante.year &&
a.mes > self.fecha_desafiliacion_aportante.month))
errors.add(:fecha_desafiliacion_aportante,
"No puede haber aportes posteriores a la "\
"fecha de deshabilitación como #{a.mes}/#{a.anio}")
end
end
end

# Registros msip_persona_trelacion en los que
# esta persona aparece como persona2 y la
Expand All @@ -73,5 +89,17 @@ def como_familiar_de_victima
)
end

def proximo_aporte
if self.fecha_desafiliacion_aportante
return "Desafiliado"
end
if aporte.where("valor > 0").count == 0
return "No aportante"
end
ultimo = aporte.where("valor > 0").
order(["anio desc", "mes desc"]).first
return ultimo.valor.a_decimal_localizado
end

end
end

0 comments on commit 5b17268

Please sign in to comment.