diff --git a/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PagosPolizaController.java b/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PagosPolizaController.java index 04d33c2..8409306 100644 --- a/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PagosPolizaController.java +++ b/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PagosPolizaController.java @@ -81,6 +81,40 @@ public class PagosPolizaController extends ConnectionManager implements Serializ return resultList; } + public List fillPagosPedientesPolizaByPoliza(Poliza poliza) { + logger.info("fillPagosPolizaByPoliza"); + List resultList = null; + Transaction transaction = null; + try { + logger.info("Searching pagos for poliza.."); + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + transaction = session.beginTransaction(); + CriteriaBuilder builder = session.getCriteriaBuilder(); + + CriteriaQuery criteria = builder.createQuery(PagosPoliza.class); + Root root = criteria.from(PagosPoliza.class); + + Predicate criterio1 = builder.equal(root.get("poliza"), poliza); + Predicate criterio2 = builder.equal(root.get("estatusActivo"), GenericEnumType.ENABLED); + Predicate criterio3 = builder.equal(root.get("pagoEstatus"), GenericEnumType.DISABLED); + Predicate criterio4 = builder.equal(root.get("pagoEstatus"), GenericEnumType.INCOMPLETE); + criteria.where(builder.and(criterio1, criterio2), builder.or(criterio3, criterio4)); + criteria.orderBy(builder.asc(root.get("fechaAPagar"))); + + resultList = session.createQuery(criteria).getResultList(); + + logger.info("Total of pagos found: " + (null == resultList ? -1 : resultList.size())); + transaction.commit(); + } catch (HibernateException e) { + logger.error("Pagos cannot be loaded "); + rollback(transaction); + } catch (Exception e) { + logger.error("Method fillPagosPolizaByPoliza ", e); + rollback(transaction); + } + return resultList; + } + public List fillPagosPolizaFechaAPagarByLocationFechaInicioAndFechaFin(Location location, Date startDate, Date endDate) { logger.info("fillPagosPolizaByPoliza"); List resultList = null; @@ -175,6 +209,44 @@ public class PagosPolizaController extends ConnectionManager implements Serializ return success; } + public PagosPoliza getSiguintePagosPolizaARealizarByPoliza(Poliza poliza) { + logger.info("getSiguintePagosPolizaARealizarByPoliza"); + PagosPoliza result = null; + Transaction transaction = null; + try { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + transaction = session.beginTransaction(); + CriteriaBuilder builder = session.getCriteriaBuilder(); + + CriteriaQuery criteria = builder.createQuery(PagosPoliza.class); + Root root = criteria.from(PagosPoliza.class); + + Predicate criterio1 = builder.equal(root.get("poliza"), poliza); + Predicate criterio2 = builder.equal(root.get("estatusActivo"), GenericEnumType.ENABLED); + Predicate criterio3 = builder.equal(root.get("pagoEstatus"), GenericEnumType.DISABLED); + Predicate criterio4 = builder.equal(root.get("pagoEstatus"), GenericEnumType.INCOMPLETE); + + criteria.where(builder.and(criterio1, criterio2), builder.or(criterio3, criterio4)); + criteria.orderBy(builder.desc(root.get("fechaAPagar"))); + + TypedQuery query = session.createQuery(criteria); + query.setMaxResults(1); + result = query.getSingleResult(); + + transaction.commit(); + } catch (NoResultException e) { + logger.info("No se encontró el pago: " + poliza.getFolio()); + rollback(transaction); + } catch (HibernateException e) { + logger.error("Error al obtener el pago " + poliza.getFolio(), e); + rollback(transaction); + } catch (Exception e) { + logger.error("Error en getSiguintePagosPolizaARealizarByPoliza(" + poliza.getFolio() + ")", e); + rollback(transaction); + } + return result; + } + public boolean createDetellePago(DetellePagoPoliza dpago, User user) { logger.info("createDetellePago"); boolean success = false; diff --git a/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PolizaController.java b/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PolizaController.java index 14408c5..9b68351 100644 --- a/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PolizaController.java +++ b/crov-prase-controller/src/main/java/com/crov/prase/controller/prase/PolizaController.java @@ -107,6 +107,38 @@ public class PolizaController extends ConnectionManager implements Serializable return results; } + public List getAllPolizasByLocation(Location location) { + logger.info("findDisable"); + List results = new ArrayList<>(); + + Transaction transaction = null; + + try { + Session session = HibernateUtil.getSessionFactory().getCurrentSession(); + transaction = session.beginTransaction(); + CriteriaBuilder builder = session.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(Poliza.class); + Root root = query.from(Poliza.class); + Predicate locations = builder.equal(root.get("location"), location); + + query.where(builder.and(locations)); + query.orderBy(builder.asc(root.get("createdOn"))); + + results = session.createQuery(query).getResultList(); + + transaction.commit(); + + logger.info("Poliza's list " + results.size()); + } catch (HibernateException e) { + logger.error("Can not load Poliza list ", e); + rollback(transaction); + } catch (Exception e) { + logger.error("Method findDisable() ", e); + rollback(transaction); + } + return results; + } + /** * @param location * @return List of all Poliza. diff --git a/crov-prase-model/src/main/java/com/crov/prase/model/catalog/TipoPoliza.java b/crov-prase-model/src/main/java/com/crov/prase/model/catalog/TipoPoliza.java index adacd8d..7f62c79 100644 --- a/crov-prase-model/src/main/java/com/crov/prase/model/catalog/TipoPoliza.java +++ b/crov-prase-model/src/main/java/com/crov/prase/model/catalog/TipoPoliza.java @@ -5,8 +5,8 @@ package com.crov.prase.model.catalog; import com.arrebol.taxiservicios.model.core.User; -import com.arrebol.taxiservicios.model.enums.PeriodoPago; import com.arrebol.taxiservicios.model.enums.PolizaType; +import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; @@ -28,164 +28,163 @@ import org.hibernate.annotations.GenericGenerator; */ @Entity @Table(name = "tipo_poliza") -public class TipoPoliza { - - private static final long serialVersionUID = -6653037938225719593L; +public class TipoPoliza implements Serializable { - @Id - @GeneratedValue(generator = "uuid") - @GenericGenerator(name = "uuid", strategy = "uuid2") - @Column(name = "id", length = 36) - private String id; - - @Column(name = "name", nullable = true) - private String name; - - @Column(name = "costo", nullable = true) - private Double costo; - - @Column(name = "costo_semestral", nullable = true) - private Double costoSemestral; - - @Column(name = "costo_trimestral", nullable = true) - private Double costoTrimestral; - - @Column(name = "costo_mensual", nullable = true) - private Double costoMensual; - - @Enumerated(EnumType.STRING) - @Column(name = "tipo", nullable = true) - private PolizaType tipo; - - @Column(name = "active", nullable = true) - private boolean active; - - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn( - name = "created_by", - referencedColumnName = "id", - nullable = false - ) - private User createdBy; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_on", length = 19) - private Date createdOn; - - @ManyToOne(fetch = FetchType.LAZY, optional = true) - @JoinColumn( - name = "last_updated_by", - referencedColumnName = "id", - nullable = true - ) - private User lastUpdatedBy; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "last_updated_on", length = 19, nullable = true) - private Date lastUpdatedOn; + private static final long serialVersionUID = -6653037938225719593L; - public String getId() { - return id; - } + @Id + @GeneratedValue(generator = "uuid") + @GenericGenerator(name = "uuid", strategy = "uuid2") + @Column(name = "id", length = 36) + private String id; - public void setId(String id) { - this.id = id; - } + @Column(name = "name", nullable = true) + private String name; - public String getName() { - return name; - } + @Column(name = "costo", nullable = true) + private Double costo; - public void setName(String name) { - this.name = name; - } + @Column(name = "costo_semestral", nullable = true) + private Double costoSemestral; - public boolean isActive() { - return active; - } + @Column(name = "costo_trimestral", nullable = true) + private Double costoTrimestral; - public void setActive(boolean active) { - this.active = active; - } + @Column(name = "costo_mensual", nullable = true) + private Double costoMensual; - public User getCreatedBy() { - return createdBy; - } + @Enumerated(EnumType.STRING) + @Column(name = "tipo", nullable = true) + private PolizaType tipo; - public void setCreatedBy(User createdBy) { - this.createdBy = createdBy; - } + @Column(name = "active", nullable = true) + private boolean active; - public Date getCreatedOn() { - return createdOn; - } + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn( + name = "created_by", + referencedColumnName = "id", + nullable = false + ) + private User createdBy; - public void setCreatedOn(Date createdOn) { - this.createdOn = createdOn; - } + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_on", length = 19) + private Date createdOn; - public User getLastUpdatedBy() { - return lastUpdatedBy; - } + @ManyToOne(fetch = FetchType.LAZY, optional = true) + @JoinColumn( + name = "last_updated_by", + referencedColumnName = "id", + nullable = true + ) + private User lastUpdatedBy; - public void setLastUpdatedBy(User lastUpdatedBy) { - this.lastUpdatedBy = lastUpdatedBy; - } + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "last_updated_on", length = 19, nullable = true) + private Date lastUpdatedOn; - public Date getLastUpdatedOn() { - return lastUpdatedOn; - } + public String getId() { + return id; + } - public void setLastUpdatedOn(Date lastUpdatedOn) { - this.lastUpdatedOn = lastUpdatedOn; - } + public void setId(String id) { + this.id = id; + } - public Double getCosto() { - return costo; - } + public String getName() { + return name; + } - public void setCosto(Double costo) { - this.costo = costo; - } + public void setName(String name) { + this.name = name; + } - public PolizaType getTipo() { - return tipo; - } + public boolean isActive() { + return active; + } - public void setTipo(PolizaType tipo) { - this.tipo = tipo; - } + public void setActive(boolean active) { + this.active = active; + } - public Double getCostoSemestral() { - return costoSemestral; - } + public User getCreatedBy() { + return createdBy; + } - public void setCostoSemestral(Double costoSemestral) { - this.costoSemestral = costoSemestral; - } + public void setCreatedBy(User createdBy) { + this.createdBy = createdBy; + } - public Double getCostoTrimestral() { - return costoTrimestral; - } + public Date getCreatedOn() { + return createdOn; + } - public void setCostoTrimestral(Double costoTrimestral) { - this.costoTrimestral = costoTrimestral; - } + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } - public Double getCostoMensual() { - return costoMensual; - } + public User getLastUpdatedBy() { + return lastUpdatedBy; + } - public void setCostoMensual(Double costoMensual) { - this.costoMensual = costoMensual; - } + public void setLastUpdatedBy(User lastUpdatedBy) { + this.lastUpdatedBy = lastUpdatedBy; + } - public TipoPoliza(String id) { - this.id = id; - } + public Date getLastUpdatedOn() { + return lastUpdatedOn; + } + + public void setLastUpdatedOn(Date lastUpdatedOn) { + this.lastUpdatedOn = lastUpdatedOn; + } + + public Double getCosto() { + return costo; + } + + public void setCosto(Double costo) { + this.costo = costo; + } + + public PolizaType getTipo() { + return tipo; + } + + public void setTipo(PolizaType tipo) { + this.tipo = tipo; + } + + public Double getCostoSemestral() { + return costoSemestral; + } + + public void setCostoSemestral(Double costoSemestral) { + this.costoSemestral = costoSemestral; + } + + public Double getCostoTrimestral() { + return costoTrimestral; + } + + public void setCostoTrimestral(Double costoTrimestral) { + this.costoTrimestral = costoTrimestral; + } + + public Double getCostoMensual() { + return costoMensual; + } + + public void setCostoMensual(Double costoMensual) { + this.costoMensual = costoMensual; + } + + public TipoPoliza(String id) { + this.id = id; + } + + public TipoPoliza() { + } - public TipoPoliza() { - } - - } diff --git a/crov-prase-model/src/main/java/com/crov/prase/model/prase/PagosPoliza.java b/crov-prase-model/src/main/java/com/crov/prase/model/prase/PagosPoliza.java index 88a04ec..18c5bd9 100644 --- a/crov-prase-model/src/main/java/com/crov/prase/model/prase/PagosPoliza.java +++ b/crov-prase-model/src/main/java/com/crov/prase/model/prase/PagosPoliza.java @@ -32,231 +32,243 @@ import org.hibernate.annotations.GenericGenerator; @Table(name = "pagos_poliza") public class PagosPoliza implements Serializable { - private static final long serialVersionUID = -6653037938225719593L; + private static final long serialVersionUID = -6653037938225719593L; - @Id - @GeneratedValue(generator = "uuid") - @GenericGenerator(name = "uuid", strategy = "uuid2") - @Column(name = "id", length = 36) - private String id; + @Id + @GeneratedValue(generator = "uuid") + @GenericGenerator(name = "uuid", strategy = "uuid2") + @Column(name = "id", length = 36) + private String id; - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn( - name = "id_poliza", - referencedColumnName = "id", - nullable = false - ) - private Poliza poliza; + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn( + name = "id_poliza", + referencedColumnName = "id", + nullable = false + ) + private Poliza poliza; - @Enumerated(EnumType.STRING) - @Column(name = "estatus_activo", nullable = false) - private GenericEnumType estatusActivo; + @Enumerated(EnumType.STRING) + @Column(name = "estatus_activo", nullable = false) + private GenericEnumType estatusActivo; - @Enumerated(EnumType.STRING) - @Column(name = "tipo_pago", nullable = false) - private TipoAbono tipoPago; + @Enumerated(EnumType.STRING) + @Column(name = "tipo_pago", nullable = false) + private TipoAbono tipoPago; - @Enumerated(EnumType.STRING) - @Column(name = "pago_estatus", nullable = false) - private GenericEnumType pagoEstatus; + @Enumerated(EnumType.STRING) + @Column(name = "pago_estatus", nullable = false) + private GenericEnumType pagoEstatus; - @Enumerated(EnumType.STRING) - @Column(name = "metodo_pago", nullable = true) - private MetodoPago metodoPago; + @Enumerated(EnumType.STRING) + @Column(name = "metodo_pago", nullable = true) + private MetodoPago metodoPago; - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "fecha_a_pagar") - private Date fechaAPagar; + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "fecha_a_pagar") + private Date fechaAPagar; - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "fecha_pago") - private Date fechaPago; + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "nueva_fecha_a_pagar") + private Date nuevaFechaAPagar; - @Column(name = "pago") - private Double pago; + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "fecha_pago") + private Date fechaPago; - @Column(name = "cantidad_pagada") - private Double cantidadPagada; + @Column(name = "pago") + private Double pago; - @Column(name = "diferencia_pago") - private Double diferenciaPago; + @Column(name = "cantidad_pagada") + private Double cantidadPagada; - @Column(name = "folio") - private String folio; + @Column(name = "diferencia_pago") + private Double diferenciaPago; - @ManyToOne(fetch = FetchType.LAZY, optional = true) - @JoinColumn( - name = "cobro", - referencedColumnName = "id", - nullable = true - ) - private User cobro; + @Column(name = "folio") + private String folio; - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_on") - private Date createdOn; + @ManyToOne(fetch = FetchType.LAZY, optional = true) + @JoinColumn( + name = "cobro", + referencedColumnName = "id", + nullable = true + ) + private User cobro; - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn( - name = "created_by", - referencedColumnName = "id", - nullable = false - ) - private User createdBy; + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_on") + private Date createdOn; - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "last_updated_on") - private Date lastUpdatedOn; + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn( + name = "created_by", + referencedColumnName = "id", + nullable = false + ) + private User createdBy; - @ManyToOne(fetch = FetchType.LAZY, optional = true) - @JoinColumn( - name = "last_updated_by", - referencedColumnName = "id", - nullable = true - ) - private User lastUpdatedBy; + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "last_updated_on") + private Date lastUpdatedOn; - public PagosPoliza() { - } + @ManyToOne(fetch = FetchType.LAZY, optional = true) + @JoinColumn( + name = "last_updated_by", + referencedColumnName = "id", + nullable = true + ) + private User lastUpdatedBy; - public PagosPoliza(String id) { - this.id = id; - } + public PagosPoliza() { + } - public String getId() { - return id; - } + public PagosPoliza(String id) { + this.id = id; + } - public void setId(String id) { - this.id = id; - } + public String getId() { + return id; + } - public Poliza getPoliza() { - return poliza; - } + public void setId(String id) { + this.id = id; + } - public void setPoliza(Poliza poliza) { - this.poliza = poliza; - } + public Poliza getPoliza() { + return poliza; + } - public GenericEnumType getEstatusActivo() { - return estatusActivo; - } + public void setPoliza(Poliza poliza) { + this.poliza = poliza; + } - public void setEstatusActivo(GenericEnumType estatusActivo) { - this.estatusActivo = estatusActivo; - } + public GenericEnumType getEstatusActivo() { + return estatusActivo; + } - public TipoAbono getTipoPago() { - return tipoPago; - } + public void setEstatusActivo(GenericEnumType estatusActivo) { + this.estatusActivo = estatusActivo; + } - public void setTipoPago(TipoAbono tipoPago) { - this.tipoPago = tipoPago; - } + public TipoAbono getTipoPago() { + return tipoPago; + } - public GenericEnumType getPagoEstatus() { - return pagoEstatus; - } + public void setTipoPago(TipoAbono tipoPago) { + this.tipoPago = tipoPago; + } - public void setPagoEstatus(GenericEnumType pagoEstatus) { - this.pagoEstatus = pagoEstatus; - } + public GenericEnumType getPagoEstatus() { + return pagoEstatus; + } - public Date getFechaAPagar() { - return fechaAPagar; - } + public void setPagoEstatus(GenericEnumType pagoEstatus) { + this.pagoEstatus = pagoEstatus; + } - public void setFechaAPagar(Date fechaAPagar) { - this.fechaAPagar = fechaAPagar; - } + public Date getFechaAPagar() { + return fechaAPagar; + } - public Date getFechaPago() { - return fechaPago; - } + public void setFechaAPagar(Date fechaAPagar) { + this.fechaAPagar = fechaAPagar; + } - public void setFechaPago(Date fechaPago) { - this.fechaPago = fechaPago; - } + public Date getFechaPago() { + return fechaPago; + } - public Double getPago() { - return pago; - } + public void setFechaPago(Date fechaPago) { + this.fechaPago = fechaPago; + } - public void setPago(Double pago) { - this.pago = pago; - } + public Double getPago() { + return pago; + } - public Double getCantidadPagada() { - return cantidadPagada; - } + public void setPago(Double pago) { + this.pago = pago; + } - public void setCantidadPagada(Double cantidadPagada) { - this.cantidadPagada = cantidadPagada; - } + public Double getCantidadPagada() { + return cantidadPagada; + } - public Double getDiferenciaPago() { - return diferenciaPago; - } + public void setCantidadPagada(Double cantidadPagada) { + this.cantidadPagada = cantidadPagada; + } - public void setDiferenciaPago(Double diferenciaPago) { - this.diferenciaPago = diferenciaPago; - } + public Double getDiferenciaPago() { + return diferenciaPago; + } - public String getFolio() { - return folio; - } + public void setDiferenciaPago(Double diferenciaPago) { + this.diferenciaPago = diferenciaPago; + } - public void setFolio(String folio) { - this.folio = folio; - } + public String getFolio() { + return folio; + } - public User getCobro() { - return cobro; - } + public void setFolio(String folio) { + this.folio = folio; + } - public void setCobro(User cobro) { - this.cobro = cobro; - } + public User getCobro() { + return cobro; + } - public Date getCreatedOn() { - return createdOn; - } + public void setCobro(User cobro) { + this.cobro = cobro; + } - public void setCreatedOn(Date createdOn) { - this.createdOn = createdOn; - } + public Date getCreatedOn() { + return createdOn; + } - public User getCreatedBy() { - return createdBy; - } + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } - public void setCreatedBy(User createdBy) { - this.createdBy = createdBy; - } + public User getCreatedBy() { + return createdBy; + } - public Date getLastUpdatedOn() { - return lastUpdatedOn; - } + public void setCreatedBy(User createdBy) { + this.createdBy = createdBy; + } - public void setLastUpdatedOn(Date lastUpdatedOn) { - this.lastUpdatedOn = lastUpdatedOn; - } + public Date getLastUpdatedOn() { + return lastUpdatedOn; + } - public User getLastUpdatedBy() { - return lastUpdatedBy; - } + public void setLastUpdatedOn(Date lastUpdatedOn) { + this.lastUpdatedOn = lastUpdatedOn; + } - public void setLastUpdatedBy(User lastUpdatedBy) { - this.lastUpdatedBy = lastUpdatedBy; - } + public User getLastUpdatedBy() { + return lastUpdatedBy; + } - public MetodoPago getMetodoPago() { - return metodoPago; - } + public void setLastUpdatedBy(User lastUpdatedBy) { + this.lastUpdatedBy = lastUpdatedBy; + } - public void setMetodoPago(MetodoPago metodoPago) { - this.metodoPago = metodoPago; - } + public MetodoPago getMetodoPago() { + return metodoPago; + } + + public void setMetodoPago(MetodoPago metodoPago) { + this.metodoPago = metodoPago; + } + + public Date getNuevaFechaAPagar() { + return nuevaFechaAPagar; + } + + public void setNuevaFechaAPagar(Date nuevaFechaAPagar) { + this.nuevaFechaAPagar = nuevaFechaAPagar; + } } diff --git a/crov-prase-web/src/main/java/com/crov/prase/prase/PolizaBean.java b/crov-prase-web/src/main/java/com/crov/prase/prase/PolizaBean.java index ccc11e7..1639ba6 100644 --- a/crov-prase-web/src/main/java/com/crov/prase/prase/PolizaBean.java +++ b/crov-prase-web/src/main/java/com/crov/prase/prase/PolizaBean.java @@ -254,6 +254,28 @@ public class PolizaBean extends TaxiGenericBean implements Serializable, Datatab } } + public void cargarPagos() { + logger.info("cargarPagos()"); + try { + setPagosPolizaList(getPagosPolizaController().fillPagosPedientesPolizaByPoliza(getSelectedPoliza())); + } catch (Exception e) { + logger.error("cargarPagos(): " + e); + } + } + + public void actualizarPagoPoliza() { + logger.info("actualizarPagoPoliza()"); + try { + getPagosPolizaController().updatePago(getSelectedPago(), getLoggedUser()); + getPolizaList(); + cargarPagos(); + showMessage(FacesMessage.SEVERITY_INFO, "Pago actualizado", "Se actualizó la nueva fecha de pago"); + } catch (Exception e) { + showMessage(FacesMessage.SEVERITY_ERROR, "Error", "Ocurrió un error al actualizar el pago"); + logger.error("actualizarPagoPoliza(): " + e); + } + } + public void cargarDevolucion() { setComentario(""); setMontoRenbolso(getSelectedPoliza().getCantidadPagada()); @@ -771,6 +793,14 @@ public class PolizaBean extends TaxiGenericBean implements Serializable, Datatab private GenericPersonController genericPersonController; private List poliza; + private List polizasActivasList; + private List polizasEmitidasList; + private List polizasPedientesDePagoList; + private List polizasVencidasList; + private List polizasFinalizadasList; + private List polizasCaseladasList; + private List pagosPolizaList; + private PagosPoliza selectedPago; private List taxi; private List tipoPoliza; private List asesor; @@ -1238,12 +1268,116 @@ public class PolizaBean extends TaxiGenericBean implements Serializable, Datatab this.montoRenbolso = montoRenbolso; } + public List getPolizasActivasList() { + return polizasActivasList; + } + + public void setPolizasActivasList(List polizasActivasList) { + this.polizasActivasList = polizasActivasList; + } + + public List getPolizasEmitidasList() { + return polizasEmitidasList; + } + + public void setPolizasEmitidasList(List polizasEmitidasList) { + this.polizasEmitidasList = polizasEmitidasList; + } + + public List getPolizasPedientesDePagoList() { + return polizasPedientesDePagoList; + } + + public void setPolizasPedientesDePagoList(List polizasPedientesDePagoList) { + this.polizasPedientesDePagoList = polizasPedientesDePagoList; + } + + public List getPolizasVencidasList() { + return polizasVencidasList; + } + + public void setPolizasVencidasList(List polizasVencidasList) { + this.polizasVencidasList = polizasVencidasList; + } + + public List getPolizasCaseladasList() { + return polizasCaseladasList; + } + + public void setPolizasCaseladasList(List polizasCaseladasList) { + this.polizasCaseladasList = polizasCaseladasList; + } + + public List getPolizasFinalizadasList() { + return polizasFinalizadasList; + } + + public void setPolizasFinalizadasList(List polizasFinalizadasList) { + this.polizasFinalizadasList = polizasFinalizadasList; + } + + public List getPagosPolizaList() { + return pagosPolizaList; + } + + public void setPagosPolizaList(List pagosPolizaList) { + this.pagosPolizaList = pagosPolizaList; + } + + public PagosPoliza getSelectedPago() { + return selectedPago; + } + + public void setSelectedPago(PagosPoliza selectedPago) { + this.selectedPago = selectedPago; + } + public void getPolizaList() { - List PolizaActiva = getController().findActive(getLoggedUser().getLocation()); - List PolizaDeshabilitada = getController().findDisable(getLoggedUser().getLocation()); - setPoliza(new ArrayList<>()); - getPoliza().addAll(PolizaActiva); - getPoliza().addAll(PolizaDeshabilitada); + try { + setPoliza(getController().getAllPolizasByLocation(getLoggedUser().getLocation())); + setPolizasActivasList(new ArrayList<>()); + setPolizasEmitidasList(new ArrayList<>()); + setPolizasPedientesDePagoList(new ArrayList<>()); + setPolizasVencidasList(new ArrayList<>()); + setPolizasFinalizadasList(new ArrayList<>()); + setPolizasCaseladasList(new ArrayList<>()); + Date fechaActual = new Date(); + int NoPolizasConErrorDeCargado = 0; + for (Poliza selecPoliza : getPoliza()) { + switch (selecPoliza.getEstatus()) { + case CANCELADO: + getPolizasCaseladasList().add(selecPoliza); + break; + case LIQUIDADO: + if (selecPoliza.getEndDate().after(fechaActual)) { + getPolizasActivasList().add(selecPoliza); + } else { + getPolizasFinalizadasList().add(selecPoliza); + } + break; + default: + PagosPoliza proximoPago = getPagosPolizaController().getSiguintePagosPolizaARealizarByPoliza(selecPoliza); + if (proximoPago == null) { + NoPolizasConErrorDeCargado++; + continue; + } + if (proximoPago.getNuevaFechaAPagar() != null) { + getPolizasPedientesDePagoList().add(selecPoliza); + } else if (proximoPago.getFechaAPagar().before(fechaActual)) { + getPolizasVencidasList().add(selecPoliza); + } else { + getPolizasEmitidasList().add(selecPoliza); + } + break; + } + } + if (NoPolizasConErrorDeCargado > 0) { + showMessage(FacesMessage.SEVERITY_WARN, "ADVERTENCIA", NoPolizasConErrorDeCargado + " pólizas no se pudieron cargar correctamente "); + } + } catch (Exception e) { + showMessage(FacesMessage.SEVERITY_FATAL, "ERROR", "OCURRIÓ UN ERROR AL TRATA DE CARGAR LAS PÓLIZAS"); + logger.error("getPolizaList(): " + e); + } } public String validarColores(Boolean estatus) { diff --git a/crov-prase-web/src/main/webapp/app/prase/poliza/index.xhtml b/crov-prase-web/src/main/webapp/app/prase/poliza/index.xhtml index a05e451..94e6454 100644 --- a/crov-prase-web/src/main/webapp/app/prase/poliza/index.xhtml +++ b/crov-prase-web/src/main/webapp/app/prase/poliza/index.xhtml @@ -8,6 +8,14 @@ + +