Rev 538 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 535 | blopes | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | |||
| 6 | import javax.persistence.Column; |
||
| 7 | import javax.persistence.Entity; |
||
| 8 | import javax.persistence.GeneratedValue; |
||
| 9 | import javax.persistence.GenerationType; |
||
| 10 | import javax.persistence.Id; |
||
| 11 | import javax.persistence.JoinColumn; |
||
| 12 | import javax.persistence.ManyToOne; |
||
| 13 | import javax.persistence.SequenceGenerator; |
||
| 14 | import javax.persistence.Table; |
||
| 15 | import javax.persistence.Transient; |
||
| 16 | import javax.validation.constraints.NotNull; |
||
| 17 | import javax.validation.constraints.Size; |
||
| 18 | |||
| 19 | import org.hibernate.annotations.ForeignKey; |
||
| 20 | |||
| 21 | import br.com.ec.core.generic.identidade.Identidade; |
||
| 22 | import br.com.ec.core.interfaces.Alterar; |
||
| 23 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 24 | import br.com.ec.core.util.DataUtils; |
||
| 25 | import br.com.ec.core.util.StringUtil; |
||
| 26 | import br.com.ec.core.util.VerificadorUtil; |
||
| 27 | import br.com.ec.domain.model.tipos.TipoDevolucao; |
||
| 28 | import br.com.ec.domain.model.tipos.TipoEstoqueAuditoria; |
||
| 29 | import br.com.ec.domain.model.tipos.TipoEstoqueAuditoriaVerificacao; |
||
| 30 | import br.com.ec.domain.model.tipos.TipoProduto; |
||
| 31 | |||
| 32 | @Entity |
||
| 33 | @Table(name="sec_estoque_auditoria", schema="sc_sec") |
||
| 34 | public class EstoqueAuditoria implements Serializable, Identidade { |
||
| 35 | |||
| 36 | private static final long serialVersionUID = 1L; |
||
| 37 | |||
| 38 | private Long sequencial; |
||
| 39 | private Usuario usuario; |
||
| 40 | private Produto produto; |
||
| 41 | private Loja loja; |
||
| 623 | blopes | 42 | private Cliente cliente; |
| 535 | blopes | 43 | private Integer quantidadeEstoqueAnterior; |
| 44 | private Integer quantidadeEstoqueNovo; |
||
| 45 | private String observacao; |
||
| 46 | private String auditoria; |
||
| 47 | private Date dataAtualizacao; |
||
| 48 | private String tipoEstoqueAuditoria; |
||
| 49 | private String tipoVerificacao; |
||
| 50 | private Usuario usuarioVerificacao; |
||
| 51 | |||
| 52 | private Long sequencialVenda; |
||
| 53 | private Long sequencialPedido; |
||
| 54 | private Pedido pedidoParaVincular; |
||
| 55 | private Date dataVenda; |
||
| 56 | private Loja lojaVenda; |
||
| 57 | private String tipoDevolucao; |
||
| 58 | private Double valorDevolvido; |
||
| 59 | private String dadosBancarios; |
||
| 60 | private String numeroNotaFiscal; |
||
| 61 | private String numeroLote; |
||
| 62 | private Boolean ehDevolucaoMesmoProduto; |
||
| 63 | |||
| 64 | public EstoqueAuditoria() { |
||
| 65 | setEhDevolucaoMesmoProduto(false); |
||
| 66 | setValorDevolvido(new Double(0.0)); |
||
| 67 | } |
||
| 538 | blopes | 68 | |
| 69 | public EstoqueAuditoria(Long sequencial) { |
||
| 70 | this.sequencial = sequencial; |
||
| 71 | } |
||
| 535 | blopes | 72 | |
| 73 | @Override |
||
| 74 | @Transient |
||
| 75 | public Object getId() { |
||
| 76 | return this.getSequencial(); |
||
| 77 | } |
||
| 78 | @Override |
||
| 79 | public void setId(Object id) { |
||
| 80 | this.sequencial = (Long) id; |
||
| 81 | } |
||
| 82 | |||
| 83 | @Id |
||
| 84 | @SequenceGenerator(name = "sq_estoqueaudit") |
||
| 85 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 86 | @Column(name="seq_estoque_auditoria", nullable=false) |
||
| 87 | public Long getSequencial() { |
||
| 88 | return sequencial; |
||
| 89 | } |
||
| 90 | public void setSequencial(Long sequencial) { |
||
| 91 | this.sequencial = sequencial; |
||
| 92 | } |
||
| 93 | |||
| 94 | @ManyToOne |
||
| 95 | @ForeignKey(name="fk_estoqueaudit_usuario") |
||
| 96 | @JoinColumn(name = "seq_usuario", nullable=true) |
||
| 97 | public Usuario getUsuario() { |
||
| 98 | return usuario; |
||
| 99 | } |
||
| 100 | public void setUsuario(Usuario usuario) { |
||
| 101 | this.usuario = usuario; |
||
| 102 | } |
||
| 103 | |||
| 104 | @ManyToOne |
||
| 105 | @ForeignKey(name="fk_estoqueaudit_usuarioverificacao") |
||
| 106 | @JoinColumn(name = "seq_usuario_verificacao", nullable=true) |
||
| 107 | public Usuario getUsuarioVerificacao() { |
||
| 108 | return usuarioVerificacao; |
||
| 109 | } |
||
| 110 | public void setUsuarioVerificacao(Usuario usuarioVerificacao) { |
||
| 111 | this.usuarioVerificacao = usuarioVerificacao; |
||
| 112 | } |
||
| 113 | |||
| 114 | @ManyToOne |
||
| 115 | @ForeignKey(name="fk_estoqueaudit_produto") |
||
| 116 | @JoinColumn(name = "seq_produto", nullable=true) |
||
| 117 | public Produto getProduto() { |
||
| 118 | return produto; |
||
| 119 | } |
||
| 120 | public void setProduto(Produto produto) { |
||
| 121 | this.produto = produto; |
||
| 122 | } |
||
| 123 | |||
| 124 | @ManyToOne |
||
| 125 | @ForeignKey(name="fk_estoqueaudit_loja") |
||
| 126 | @JoinColumn(name = "seq_loja", nullable=true) |
||
| 127 | public Loja getLoja() { |
||
| 128 | return loja; |
||
| 129 | } |
||
| 130 | public void setLoja(Loja loja) { |
||
| 131 | this.loja = loja; |
||
| 132 | } |
||
| 133 | |||
| 134 | @ManyToOne |
||
| 135 | @ForeignKey(name="fk_estoqueaudit_cliente") |
||
| 136 | @JoinColumn(name = "seq_cliente", nullable=true) |
||
| 137 | public Cliente getCliente() { |
||
| 138 | return cliente; |
||
| 139 | } |
||
| 140 | public void setCliente(Cliente cliente) { |
||
| 141 | this.cliente = cliente; |
||
| 142 | } |
||
| 143 | |||
| 144 | @Column(name="qtd_estoque_anterior") |
||
| 145 | public Integer getQuantidadeEstoqueAnterior() { |
||
| 146 | return quantidadeEstoqueAnterior; |
||
| 147 | } |
||
| 148 | public void setQuantidadeEstoqueAnterior(Integer quantidadeEstoqueAnterior) { |
||
| 149 | this.quantidadeEstoqueAnterior = quantidadeEstoqueAnterior; |
||
| 150 | } |
||
| 151 | |||
| 152 | @Column(name="qtd_estoque_novo") |
||
| 153 | public Integer getQuantidadeEstoqueNovo() { |
||
| 154 | return quantidadeEstoqueNovo; |
||
| 155 | } |
||
| 156 | public void setQuantidadeEstoqueNovo(Integer quantidadeEstoqueNovo) { |
||
| 157 | this.quantidadeEstoqueNovo = quantidadeEstoqueNovo; |
||
| 158 | } |
||
| 159 | |||
| 160 | @Column(name="dsc_observacao") |
||
| 161 | @Size(max = 400, message = "Limite de caracteres ultrapassado: Observação") |
||
| 162 | public String getObservacao() { |
||
| 163 | return observacao; |
||
| 164 | } |
||
| 165 | public void setObservacao(String observacao) { |
||
| 166 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 167 | } |
||
| 168 | |||
| 169 | @Column(name="dsc_auditoria") |
||
| 170 | @Size(max = 400, message = "Limite de caracteres ultrapassado: Descrição da Auditoria") |
||
| 171 | public String getAuditoria() { |
||
| 172 | return auditoria; |
||
| 173 | } |
||
| 174 | public void setAuditoria(String auditoria) { |
||
| 175 | this.auditoria = StringUtil.setarUpperCaseComTrim(auditoria); |
||
| 176 | } |
||
| 177 | |||
| 178 | @NotNull(message="Obrigatório informar a data do ocorrido", groups={Cadastrar.class, Alterar.class}) |
||
| 179 | @Column(name="dth_atualizacao", nullable=false) |
||
| 180 | public Date getDataAtualizacao() { |
||
| 181 | return dataAtualizacao; |
||
| 182 | } |
||
| 183 | public void setDataAtualizacao(Date dataAtualizacao) { |
||
| 184 | this.dataAtualizacao = dataAtualizacao; |
||
| 185 | } |
||
| 186 | |||
| 187 | @Column(name="tip_estoque_auditoria") |
||
| 188 | public String getTipoEstoqueAuditoria() { |
||
| 189 | return tipoEstoqueAuditoria; |
||
| 190 | } |
||
| 191 | public void setTipoEstoqueAuditoria(String tipoEstoqueAuditoria) { |
||
| 192 | this.tipoEstoqueAuditoria = tipoEstoqueAuditoria; |
||
| 193 | } |
||
| 194 | |||
| 195 | @Column(name="tip_verificacao", nullable=false) |
||
| 196 | public String getTipoVerificacao() { |
||
| 197 | return tipoVerificacao; |
||
| 198 | } |
||
| 199 | public void setTipoVerificacao(String tipoVerificacao) { |
||
| 200 | this.tipoVerificacao = tipoVerificacao; |
||
| 201 | } |
||
| 202 | |||
| 203 | @Transient |
||
| 204 | public Long getSequencialVenda() { |
||
| 205 | return sequencialVenda; |
||
| 206 | } |
||
| 207 | public void setSequencialVenda(Long sequencialVenda) { |
||
| 208 | this.sequencialVenda = sequencialVenda; |
||
| 209 | } |
||
| 210 | |||
| 211 | @Transient |
||
| 212 | public Long getSequencialPedido() { |
||
| 213 | return sequencialPedido; |
||
| 214 | } |
||
| 215 | public void setSequencialPedido(Long sequencialPedido) { |
||
| 216 | this.sequencialPedido = sequencialPedido; |
||
| 217 | } |
||
| 218 | |||
| 219 | @Transient |
||
| 220 | public Pedido getPedidoParaVincular() { |
||
| 221 | return pedidoParaVincular; |
||
| 222 | } |
||
| 223 | public void setPedidoParaVincular(Pedido pedidoParaVincular) { |
||
| 224 | this.pedidoParaVincular = pedidoParaVincular; |
||
| 225 | } |
||
| 226 | |||
| 227 | @Transient |
||
| 228 | public Date getDataVenda() { |
||
| 229 | return dataVenda; |
||
| 230 | } |
||
| 231 | public void setDataVenda(Date dataVenda) { |
||
| 232 | this.dataVenda = dataVenda; |
||
| 233 | } |
||
| 234 | |||
| 235 | @Transient |
||
| 236 | public Loja getLojaVenda() { |
||
| 237 | return lojaVenda; |
||
| 238 | } |
||
| 239 | public void setLojaVenda(Loja lojaVenda) { |
||
| 240 | this.lojaVenda = lojaVenda; |
||
| 241 | } |
||
| 242 | |||
| 243 | @Transient |
||
| 244 | public String getTipoDevolucao() { |
||
| 245 | return tipoDevolucao; |
||
| 246 | } |
||
| 247 | public void setTipoDevolucao(String tipoDevolucao) { |
||
| 248 | this.tipoDevolucao = tipoDevolucao; |
||
| 249 | } |
||
| 250 | |||
| 251 | @Transient |
||
| 252 | public Double getValorDevolvido() { |
||
| 253 | return valorDevolvido; |
||
| 254 | } |
||
| 255 | public void setValorDevolvido(Double valorDevolvido) { |
||
| 256 | this.valorDevolvido = valorDevolvido; |
||
| 257 | } |
||
| 258 | |||
| 259 | @Transient |
||
| 260 | public String getDadosBancarios() { |
||
| 261 | return dadosBancarios; |
||
| 262 | } |
||
| 263 | public void setDadosBancarios(String dadosBancarios) { |
||
| 264 | this.dadosBancarios = StringUtil.setarUpperCaseComTrim(dadosBancarios); |
||
| 265 | } |
||
| 266 | |||
| 267 | @Transient |
||
| 268 | public String getNumeroNotaFiscal() { |
||
| 269 | return numeroNotaFiscal; |
||
| 270 | } |
||
| 271 | public void setNumeroNotaFiscal(String numeroNotaFiscal) { |
||
| 272 | this.numeroNotaFiscal = numeroNotaFiscal; |
||
| 273 | } |
||
| 274 | |||
| 275 | @Transient |
||
| 276 | public String getNumeroLote() { |
||
| 277 | return numeroLote; |
||
| 278 | } |
||
| 279 | public void setNumeroLote(String numeroLote) { |
||
| 280 | this.numeroLote = numeroLote; |
||
| 281 | } |
||
| 282 | |||
| 283 | @Transient |
||
| 284 | public Boolean getEhDevolucaoMesmoProduto() { |
||
| 285 | return ehDevolucaoMesmoProduto; |
||
| 286 | } |
||
| 287 | public void setEhDevolucaoMesmoProduto(Boolean ehDevolucaoMesmoProduto) { |
||
| 288 | this.ehDevolucaoMesmoProduto = ehDevolucaoMesmoProduto; |
||
| 289 | } |
||
| 290 | |||
| 291 | @Transient |
||
| 292 | public Boolean aumentouEstoque() { |
||
| 293 | if (VerificadorUtil.naoEstaNulo(getQuantidadeEstoqueAnterior()) && VerificadorUtil.naoEstaNulo(getQuantidadeEstoqueNovo())) { |
||
| 294 | return getQuantidadeEstoqueAnterior() < getQuantidadeEstoqueNovo(); |
||
| 295 | } |
||
| 296 | return null; |
||
| 297 | } |
||
| 298 | |||
| 299 | @Transient |
||
| 300 | public String getTipoEstoqueAuditoriaDescricao() { |
||
| 301 | return VerificadorUtil.naoEstaNulo(getTipoEstoqueAuditoria()) ? TipoEstoqueAuditoria.parse(getTipoEstoqueAuditoria()).getDescricao() : ""; |
||
| 302 | } |
||
| 303 | |||
| 304 | @Transient |
||
| 305 | public Long getSequencialDaLoja() { |
||
| 306 | return VerificadorUtil.naoEstaNulo(getLoja()) ? getLoja().getSequencial() : null; |
||
| 307 | } |
||
| 308 | |||
| 309 | @Transient |
||
| 310 | public Boolean naoVerificado() { |
||
| 311 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoVerificacao()) ? getTipoVerificacao().equals(TipoEstoqueAuditoriaVerificacao.NAO_VERIFICADO.getValor()) : false; |
||
| 312 | } |
||
| 313 | |||
| 314 | @Transient |
||
| 315 | public Boolean verificadoSemPendencia() { |
||
| 316 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoVerificacao()) ? getTipoVerificacao().equals(TipoEstoqueAuditoriaVerificacao.VERIFICADO_SEM_PENDENCIA.getValor()) : false; |
||
| 317 | } |
||
| 318 | |||
| 319 | @Transient |
||
| 320 | public Boolean verificadoComPendencia() { |
||
| 321 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoVerificacao()) ? getTipoVerificacao().equals(TipoEstoqueAuditoriaVerificacao.VERIFICADO_COM_PENDENCIA.getValor()) : false; |
||
| 322 | } |
||
| 323 | |||
| 324 | @Transient |
||
| 325 | public Boolean ehTipoDevolucaoPorTransferencia() { |
||
| 326 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoDevolucao()) ? getTipoDevolucao().equals(TipoDevolucao.TRANSFERENCIA.getValor()) : false; |
||
| 327 | } |
||
| 328 | |||
| 329 | @Transient |
||
| 330 | public String nomeDoUsuario() { |
||
| 331 | return VerificadorUtil.naoEstaNulo(getUsuario())? getUsuario().getNomeDaPessoa() : null; |
||
| 332 | } |
||
| 333 | |||
| 334 | /* |
||
| 335 | @Transient |
||
| 336 | public String nomeDoCliente() { |
||
| 337 | return VerificadorUtil.naoEstaNulo(getCliente())? getCliente().getNome() : null; |
||
| 338 | } |
||
| 339 | |||
| 340 | @Transient |
||
| 341 | public String cpfCnpjDoCliente() { |
||
| 342 | return VerificadorUtil.naoEstaNulo(getCliente())? getCliente().getCpfCnpjFormatado() : null; |
||
| 343 | } |
||
| 344 | */ |
||
| 345 | |||
| 346 | @Transient |
||
| 347 | public Integer getQuantidadeDiasDaAtualizacao() { |
||
| 348 | return DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), getDataAtualizacao()); |
||
| 349 | } |
||
| 350 | |||
| 351 | @Transient |
||
| 352 | public String descricaoCompletaProduto() { |
||
| 353 | StringBuilder descricaoCompleta = new StringBuilder(); |
||
| 354 | if (VerificadorUtil.naoEstaNulo(getProduto())) { |
||
| 355 | descricaoCompleta.append(getProduto().getCodigo()); |
||
| 356 | descricaoCompleta.append(" - "); |
||
| 357 | if (this.getProduto().getTipo().equals(TipoProduto.CAPA.getValor())) { |
||
| 358 | descricaoCompleta.append("CAPA"); |
||
| 359 | } |
||
| 360 | if (!this.getProduto().getTipo().equals(TipoProduto.ACESSORIO.getValor())) { |
||
| 361 | descricaoCompleta.append(" "); |
||
| 362 | descricaoCompleta.append(this.getProduto().getDescricaoDoModelo()); |
||
| 363 | } |
||
| 364 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getProduto().getEstilo())) { |
||
| 365 | descricaoCompleta.append(" "); |
||
| 366 | descricaoCompleta.append(this.getProduto().getDescricaoDoEstilo()); |
||
| 367 | } |
||
| 368 | descricaoCompleta.append(" "); |
||
| 369 | if (this.getProduto().getDescricao().length() > 50) { |
||
| 370 | descricaoCompleta.append(this.getProduto().getDescricao().substring(0, 50)); |
||
| 371 | } else { |
||
| 372 | descricaoCompleta.append(this.getProduto().getDescricao()); |
||
| 373 | } |
||
| 374 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getProduto().getCor())) { |
||
| 375 | descricaoCompleta.append(" ("); |
||
| 376 | descricaoCompleta.append(this.getProduto().getDescricaoDaCor()); |
||
| 377 | descricaoCompleta.append(")"); |
||
| 378 | } |
||
| 379 | } |
||
| 380 | return descricaoCompleta.toString(); |
||
| 381 | } |
||
| 382 | |||
| 383 | @Override |
||
| 384 | public int hashCode() { |
||
| 385 | final int prime = 31; |
||
| 386 | int result = 1; |
||
| 387 | result = prime * result |
||
| 388 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 389 | return result; |
||
| 390 | } |
||
| 391 | |||
| 392 | @Override |
||
| 393 | public boolean equals(Object obj) { |
||
| 394 | if (this == obj) |
||
| 395 | return true; |
||
| 396 | if (obj == null) |
||
| 397 | return false; |
||
| 398 | if (getClass() != obj.getClass()) |
||
| 399 | return false; |
||
| 400 | EstoqueAuditoria other = (EstoqueAuditoria) obj; |
||
| 401 | if (sequencial == null) { |
||
| 402 | if (other.sequencial != null) |
||
| 403 | return false; |
||
| 404 | } else if (!sequencial.equals(other.sequencial)) |
||
| 405 | return false; |
||
| 406 | return true; |
||
| 407 | } |
||
| 408 | |||
| 409 | @Transient |
||
| 410 | public String getDescricaoDaLoja() { |
||
| 411 | return VerificadorUtil.naoEstaNuloOuVazio(getLoja())? getLoja().getDescricao() : ""; |
||
| 412 | } |
||
| 413 | |||
| 414 | } |