wilian 2017-08-09 17:38:46 +00:00
parent 719e11882f
commit 92df812ce8
3 changed files with 36 additions and 30 deletions

View File

@ -34,37 +34,38 @@ public class NotaCreditoVendaPacoteHibernateDAO extends GenericHibernateDAO<Nota
public List<ReembolsoOcdNotaCreditoVO> busquedaDatosReembolsoOcdNotaCreditoRS(Date fecInicial, Date fecFinal, Date fecPagamentoInicial, Date fecPagamentoFinal, Boolean indPago) { public List<ReembolsoOcdNotaCreditoVO> busquedaDatosReembolsoOcdNotaCreditoRS(Date fecInicial, Date fecFinal, Date fecPagamentoInicial, Date fecPagamentoFinal, Boolean indPago) {
Map<String, Object> params = new HashMap<String,Object>(); Map<String, Object> params = new HashMap<String,Object>();
String queryString = "SELECT n FROM NotaCreditoVendaPacote n " StringBuilder queryString = new StringBuilder("SELECT n FROM NotaCreditoVendaPacote n ");
+ "LEFT JOIN FETCH n.ocdDatosPagamentoList " queryString.append("LEFT JOIN FETCH n.ocdDatosPagamentoList ")
+ "WHERE 1=1 "; .append("LEFT JOIN FETCH n.vendapacotecancelamento vpc ")
.append("WHERE 1=1 ");
if (fecInicial != null) { if (fecInicial != null) {
queryString += "AND n.datanotacredito >= :fecInicial "; queryString.append("AND n.datanotacredito >= :fecInicial ");
params.put("fecInicial", fecInicial); params.put("fecInicial", fecInicial);
} }
if (fecFinal != null) { if (fecFinal != null) {
queryString += "AND n.datanotacredito <= :fecFinal "; queryString.append("AND n.datanotacredito <= :fecFinal ");
params.put("fecFinal", fecFinal); params.put("fecFinal", fecFinal);
} }
if (fecPagamentoInicial != null) { if (fecPagamentoInicial != null) {
queryString += "AND n.datapagamento >= :fecPagamentoInicial "; queryString.append("AND n.datapagamento >= :fecPagamentoInicial ");
params.put("fecPagamentoInicial", fecPagamentoInicial); params.put("fecPagamentoInicial", fecPagamentoInicial);
} }
if (fecPagamentoFinal != null) { if (fecPagamentoFinal != null) {
queryString += "AND n.datapagamento <= :fecPagamentoFinal "; queryString.append("AND n.datapagamento <= :fecPagamentoFinal ");
params.put("fecPagamentoFinal", fecPagamentoFinal); params.put("fecPagamentoFinal", fecPagamentoFinal);
} }
if (indPago != null) { if (indPago != null) {
if (indPago) { if (indPago) {
queryString += "AND n.situacao = :indPago "; queryString.append("AND n.situacao = :indPago ");
} else { } else {
queryString += "AND (n.situacao != :indPago OR n.situacao IS NULL) "; queryString.append("AND (n.situacao != :indPago OR n.situacao IS NULL) ");
} }
params.put("indPago", SituacaoVendaPacote.PAGO.getShortValue()); params.put("indPago", SituacaoVendaPacote.PAGO.getShortValue());
} }
Query query = getSession().createQuery(queryString); Query query = getSession().createQuery(queryString.toString());
for (String p : query.getNamedParameters()) { for (String p : query.getNamedParameters()) {
query.setParameter(p, params.get(p)); query.setParameter(p, params.get(p));
} }

View File

@ -7,6 +7,8 @@ import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
@ -25,11 +27,13 @@ public class NotaCreditoVendaPacote implements java.io.Serializable {
@Column(name = "MOTIVOCANCELVENDAPACOTE_ID", precision = 7, scale = 0) @Column(name = "MOTIVOCANCELVENDAPACOTE_ID", precision = 7, scale = 0)
private Integer motivocancelvendapacoteId; private Integer motivocancelvendapacoteId;
@Column(name = "VENDAPACOTECANCELAMENTO_ID", precision = 7, scale = 0) @ManyToOne
private Integer vendapacotecancelamentoId; @JoinColumn(name = "VENDAPACOTECANCELAMENTO_ID")
private VendaPacote vendapacotecancelamento;
@Column(name = "VENDAPACOTEPAGAMENTO_ID", precision = 7, scale = 0) @ManyToOne
private Integer vendapacotepagamentoId; @JoinColumn(name = "VENDAPACOTEPAGAMENTO_ID")
private VendaPacote vendapacotepagamento;
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "DATAPAGAMENTO", length = 7) @Column(name = "DATAPAGAMENTO", length = 7)
@ -89,22 +93,6 @@ public class NotaCreditoVendaPacote implements java.io.Serializable {
this.motivocancelvendapacoteId = motivocancelvendapacoteId; this.motivocancelvendapacoteId = motivocancelvendapacoteId;
} }
public Integer getVendapacotecancelamentoId() {
return vendapacotecancelamentoId;
}
public void setVendapacotecancelamentoId(Integer vendapacotecancelamentoId) {
this.vendapacotecancelamentoId = vendapacotecancelamentoId;
}
public Integer getVendapacotepagamentoId() {
return vendapacotepagamentoId;
}
public void setVendapacotepagamentoId(Integer vendapacotepagamentoId) {
this.vendapacotepagamentoId = vendapacotepagamentoId;
}
public Date getDatapagamento() { public Date getDatapagamento() {
return datapagamento; return datapagamento;
} }
@ -213,4 +201,20 @@ public class NotaCreditoVendaPacote implements java.io.Serializable {
return situacao; return situacao;
} }
public VendaPacote getVendapacotecancelamento() {
return vendapacotecancelamento;
}
public void setVendapacotecancelamento(VendaPacote vendapacotecancelamento) {
this.vendapacotecancelamento = vendapacotecancelamento;
}
public VendaPacote getVendapacotepagamento() {
return vendapacotepagamento;
}
public void setVendapacotepagamento(VendaPacote vendapacotepagamento) {
this.vendapacotepagamento = vendapacotepagamento;
}
} }

View File

@ -361,6 +361,7 @@ public class ReembolsoOcdNotaCreditoVO {
vo.localizador = String.valueOf(notaCredito.getNotaCreditoVendaPacoteId()); vo.localizador = String.valueOf(notaCredito.getNotaCreditoVendaPacoteId());
vo.data = notaCredito.getDatanotacredito(); vo.data = notaCredito.getDatanotacredito();
vo.dataPagamento = notaCredito.getDatapagamento(); vo.dataPagamento = notaCredito.getDatapagamento();
vo.numoperacion = notaCredito.getVendapacotecancelamento().getNumoperacion();
if(notaCredito.getSituacao().equals(SituacaoNotaCreditoVendaPacote.UTILIZADA.getValue())) { if(notaCredito.getSituacao().equals(SituacaoNotaCreditoVendaPacote.UTILIZADA.getValue())) {
vo.valor = notaCredito.getValor(); vo.valor = notaCredito.getValor();