Rev 357 | Rev 450 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 357 | espaco | 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 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 21 | |||
| 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.TipoProduto; |
||
| 28 | |||
| 29 | @Entity |
||
| 30 | @Table(name="sec_produto", schema="sc_sec") |
||
| 31 | public class Produto implements Serializable, Cloneable { |
||
| 32 | |||
| 33 | private static final long serialVersionUID = 1L; |
||
| 34 | |||
| 35 | private Long sequencial; |
||
| 449 | blopes | 36 | private Modelo modelo; |
| 357 | espaco | 37 | private Tributacao tributacao; |
| 38 | private String codigo; |
||
| 39 | private String codigoRapido; |
||
| 40 | private String codigoEAN; |
||
| 41 | private String codigoEANTributado; |
||
| 42 | private String descricao; |
||
| 43 | private String descricaoEtiqueta; |
||
| 44 | private String descricaoParaNotaFiscal; |
||
| 45 | private String tipo; |
||
| 46 | private String genero; |
||
| 47 | private String estilo; |
||
| 48 | private String cor; |
||
| 49 | private String observacao; |
||
| 50 | private Double valorCompra; |
||
| 51 | private Double valorVarejo; |
||
| 52 | private Double valorVarejoPromocional; |
||
| 53 | private Double valorVarejoMaximo; |
||
| 54 | private Double valorVarejoPopular; |
||
| 55 | private Double valorAtacado; |
||
| 56 | private Date dataOnline; |
||
| 57 | private Date dataOnlineShoplog; |
||
| 58 | private Date dataOnlineMercadoLivre; |
||
| 59 | private Boolean indicadorFavorito; |
||
| 60 | private Boolean indicadorComissionado; |
||
| 61 | private Boolean indicadorPersonalizavel; |
||
| 62 | private Boolean indicadorEmissaoNotaFiscal; |
||
| 63 | |||
| 64 | private Double valorVarejoSimulacao; |
||
| 65 | private Boolean sujeitoST; |
||
| 66 | private Double aliquotaIPI; |
||
| 67 | private Double aliquotaIPINotaFiscal; |
||
| 68 | private Double aliquotaIcms; |
||
| 69 | private Double aliquotaIcmsNotaFiscal; |
||
| 70 | private Double aliquotaIcmsST; |
||
| 71 | private Double aliquotaFecoep; |
||
| 72 | private Boolean ativo; |
||
| 73 | |||
| 74 | private String codigoNCM; |
||
| 75 | private String codigoEST; |
||
| 76 | /* |
||
| 77 | private Set<ProdutoPedidoCompra> pedidosCompra; |
||
| 78 | private Set<ProdutoLoja> estoques; |
||
| 79 | private Set<FornecedorProduto> fornecedores; |
||
| 80 | private Set<ProdutoRelacionado> relacionados; |
||
| 81 | private Set<ProdutoRelacionado> relacionadosReverse; |
||
| 82 | |||
| 83 | private List<TransferenciaProduto> transferenciasAbertas = new ArrayList<TransferenciaProduto>(); |
||
| 84 | private List<PedidoProduto> pedidosPendentes = new ArrayList<PedidoProduto>(); |
||
| 85 | */ |
||
| 86 | private Boolean indicadorOnline; |
||
| 87 | private Boolean indicadorOnlineShoplog; |
||
| 88 | private Boolean indicadorOnlineMercadoLivre; |
||
| 89 | private Date dataUltimaVenda; |
||
| 90 | // private Set<ProdutoArquivo> fotos; |
||
| 91 | |||
| 92 | @Id |
||
| 93 | @SequenceGenerator(name = "sq_produto") |
||
| 94 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 95 | @Column(name="seq_produto", nullable=false) |
||
| 96 | public Long getSequencial() { |
||
| 97 | return sequencial; |
||
| 98 | } |
||
| 99 | public void setSequencial(Long sequencial) { |
||
| 100 | this.sequencial = sequencial; |
||
| 101 | } |
||
| 102 | |||
| 103 | @ManyToOne |
||
| 104 | @ForeignKey(name="fk_produto_modelo") |
||
| 105 | @NotNull(message = "Parâmetro obrigatório não preenchido: Modelo do produto", groups = {Cadastrar.class, Alterar.class}) |
||
| 106 | @JoinColumn(name = "seq_modelo", referencedColumnName="seq_modelo", nullable=true) |
||
| 107 | public Modelo getModelo() { |
||
| 108 | return modelo; |
||
| 109 | } |
||
| 110 | public void setModelo(Modelo modelo) { |
||
| 111 | this.modelo = modelo; |
||
| 112 | } |
||
| 113 | |||
| 114 | @ManyToOne |
||
| 115 | @ForeignKey(name="fk_produto_tributacao") |
||
| 116 | @JoinColumn(name = "seq_tributacao", referencedColumnName="seq_tributacao", nullable=true) |
||
| 117 | public Tributacao getTributacao() { |
||
| 118 | return tributacao; |
||
| 119 | } |
||
| 120 | public void setTributacao(Tributacao tributacao) { |
||
| 121 | this.tributacao = tributacao; |
||
| 122 | } |
||
| 123 | |||
| 124 | @Column(name="cod_produto") |
||
| 125 | @Size(max = 20, message = "Limite de caracteres ultrapassado: Código do Produto") |
||
| 126 | @NotNull(message = "Parâmetro obrigatório não preenchido: Código do produto", groups = {Cadastrar.class, Alterar.class}) |
||
| 127 | @NotEmpty(message = "Parâmetro obrigatório não preenchido: Código do produto", groups = {Cadastrar.class, Alterar.class}) |
||
| 128 | public String getCodigo() { |
||
| 129 | return codigo; |
||
| 130 | } |
||
| 131 | public void setCodigo(String codigo) { |
||
| 132 | this.codigo = codigo; |
||
| 133 | } |
||
| 134 | |||
| 135 | @Column(name="cod_rapido_produto") |
||
| 136 | @Size(max = 20, message = "Limite de caracteres ultrapassado: Código Rápido") |
||
| 137 | public String getCodigoRapido() { |
||
| 138 | return codigoRapido; |
||
| 139 | } |
||
| 140 | public void setCodigoRapido(String codigoRapido) { |
||
| 141 | this.codigoRapido = codigoRapido; |
||
| 142 | } |
||
| 143 | |||
| 144 | @Column(name="cod_ean") |
||
| 145 | @Size(max = 20, message = "Limite de caracteres ultrapassado: Código de Barras (EAN)") |
||
| 146 | public String getCodigoEAN() { |
||
| 147 | return codigoEAN; |
||
| 148 | } |
||
| 149 | public void setCodigoEAN(String codigoEAN) { |
||
| 150 | this.codigoEAN = codigoEAN; |
||
| 151 | } |
||
| 152 | |||
| 153 | @Column(name="cod_ean_tributado") |
||
| 154 | @Size(max = 20, message = "Limite de caracteres ultrapassado: Código de Barras Tributado (EAN)") |
||
| 155 | public String getCodigoEANTributado() { |
||
| 156 | return codigoEANTributado; |
||
| 157 | } |
||
| 158 | public void setCodigoEANTributado(String codigoEANTributado) { |
||
| 159 | this.codigoEANTributado = codigoEANTributado; |
||
| 160 | } |
||
| 161 | |||
| 162 | @Column(name="dsc_produto") |
||
| 163 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Descrição do Produto") |
||
| 164 | public String getDescricao() { |
||
| 165 | return descricao; |
||
| 166 | } |
||
| 167 | public void setDescricao(String descricao) { |
||
| 168 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 169 | } |
||
| 170 | |||
| 171 | @Column(name="dsc_etiqueta") |
||
| 172 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição da Etiqueta") |
||
| 173 | public String getDescricaoEtiqueta() { |
||
| 174 | return descricaoEtiqueta; |
||
| 175 | } |
||
| 176 | public void setDescricaoEtiqueta(String descricaoEtiqueta) { |
||
| 177 | this.descricaoEtiqueta = StringUtil.setarUpperCaseComTrim(descricaoEtiqueta); |
||
| 178 | } |
||
| 179 | |||
| 180 | // @Column(name="dsc_notafiscal") |
||
| 181 | // @Size(max = 250, message = "Limite de caracteres ultrapassado: Descrição para Nota Fiscal do Produto") |
||
| 182 | @Transient |
||
| 183 | public String getDescricaoParaNotaFiscal() { |
||
| 184 | return descricaoParaNotaFiscal; |
||
| 185 | } |
||
| 186 | public void setDescricaoParaNotaFiscal(String descricaoParaNotaFiscal) { |
||
| 187 | this.descricaoParaNotaFiscal = descricaoParaNotaFiscal; |
||
| 188 | } |
||
| 189 | |||
| 190 | @Column(name="tip_produto") |
||
| 191 | @NotNull(message = "Parâmetro obrigatório não preenchido: Tipo do produto", groups = {Cadastrar.class, Alterar.class}) |
||
| 192 | public String getTipo() { |
||
| 193 | return tipo; |
||
| 194 | } |
||
| 195 | public void setTipo(String tipo) { |
||
| 196 | this.tipo = tipo; |
||
| 197 | } |
||
| 198 | |||
| 199 | @Column(name="tip_genero") |
||
| 200 | @NotNull(message = "Parâmetro obrigatório não preenchido: Gênero", groups = {Cadastrar.class, Alterar.class}) |
||
| 201 | public String getGenero() { |
||
| 202 | return genero; |
||
| 203 | } |
||
| 204 | public void setGenero(String genero) { |
||
| 205 | this.genero = genero; |
||
| 206 | } |
||
| 207 | |||
| 208 | @Column(name="tip_estilo") |
||
| 209 | public String getEstilo() { |
||
| 210 | return estilo; |
||
| 211 | } |
||
| 212 | public void setEstilo(String estilo) { |
||
| 213 | this.estilo = estilo; |
||
| 214 | } |
||
| 215 | |||
| 216 | @Column(name="tip_cor") |
||
| 217 | public String getCor() { |
||
| 218 | return cor; |
||
| 219 | } |
||
| 220 | public void setCor(String cor) { |
||
| 221 | this.cor = cor; |
||
| 222 | } |
||
| 223 | |||
| 224 | @Column(name="dsc_observacao") |
||
| 225 | @Size(max = 1000, message = "Limite de caracteres ultrapassado: Observação") |
||
| 226 | public String getObservacao() { |
||
| 227 | return observacao; |
||
| 228 | } |
||
| 229 | public void setObservacao(String observacao) { |
||
| 230 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 231 | } |
||
| 232 | |||
| 233 | @Column(name="val_compra") |
||
| 234 | public Double getValorCompra() { |
||
| 235 | return valorCompra; |
||
| 236 | } |
||
| 237 | public void setValorCompra(Double valorCompra) { |
||
| 238 | this.valorCompra = valorCompra; |
||
| 239 | } |
||
| 240 | |||
| 241 | @Transient |
||
| 242 | public String valorCompraFormatado() { |
||
| 243 | if (VerificadorUtil.naoEstaNulo(getValorCompra())) { |
||
| 244 | return StringUtil.formatarValor(getValorCompra()); |
||
| 245 | } |
||
| 246 | return StringUtil.formatarValor(0.0); |
||
| 247 | } |
||
| 248 | |||
| 249 | @Column(name="val_varejo") |
||
| 250 | public Double getValorVarejo() { |
||
| 251 | return valorVarejo; |
||
| 252 | } |
||
| 253 | public void setValorVarejo(Double valorVarejo) { |
||
| 254 | this.valorVarejo = valorVarejo; |
||
| 255 | } |
||
| 256 | |||
| 257 | @Column(name="val_varejo_promocional") |
||
| 258 | public Double getValorVarejoPromocional() { |
||
| 259 | return valorVarejoPromocional; |
||
| 260 | } |
||
| 261 | public void setValorVarejoPromocional(Double valorVarejoPromocional) { |
||
| 262 | this.valorVarejoPromocional = valorVarejoPromocional; |
||
| 263 | } |
||
| 264 | |||
| 265 | @Column(name="val_varejo_maximo") |
||
| 266 | public Double getValorVarejoMaximo() { |
||
| 267 | return valorVarejoMaximo; |
||
| 268 | } |
||
| 269 | public void setValorVarejoMaximo(Double valorVarejoMaximo) { |
||
| 270 | this.valorVarejoMaximo = valorVarejoMaximo; |
||
| 271 | } |
||
| 272 | |||
| 273 | @Column(name="val_varejo_popular") |
||
| 274 | public Double getValorVarejoPopular() { |
||
| 275 | return valorVarejoPopular; |
||
| 276 | } |
||
| 277 | public void setValorAtacado(Double valorAtacado) { |
||
| 278 | this.valorAtacado = valorAtacado; |
||
| 279 | } |
||
| 280 | |||
| 281 | @Column(name="val_atacado") |
||
| 282 | public Double getValorAtacado() { |
||
| 283 | return valorAtacado; |
||
| 284 | } |
||
| 285 | public void setValorVarejoPopular(Double valorVarejoPopular) { |
||
| 286 | this.valorVarejoPopular = valorVarejoPopular; |
||
| 287 | } |
||
| 288 | |||
| 289 | @Column(name="dat_online") |
||
| 290 | public Date getDataOnline() { |
||
| 291 | return dataOnline; |
||
| 292 | } |
||
| 293 | public void setDataOnline(Date dataOnline) { |
||
| 294 | this.dataOnline = dataOnline; |
||
| 295 | } |
||
| 296 | |||
| 297 | @Column(name="dat_online_shoplog") |
||
| 298 | public Date getDataOnlineShoplog() { |
||
| 299 | return dataOnlineShoplog; |
||
| 300 | } |
||
| 301 | public void setDataOnlineShoplog(Date dataOnlineShoplog) { |
||
| 302 | this.dataOnlineShoplog = dataOnlineShoplog; |
||
| 303 | } |
||
| 304 | |||
| 305 | @Column(name="dat_online_mercadolivre") |
||
| 306 | public Date getDataOnlineMercadoLivre() { |
||
| 307 | return dataOnlineMercadoLivre; |
||
| 308 | } |
||
| 309 | public void setDataOnlineMercadoLivre(Date dataOnlineMercadoLivre) { |
||
| 310 | this.dataOnlineMercadoLivre = dataOnlineMercadoLivre; |
||
| 311 | } |
||
| 312 | |||
| 313 | @Column(name="ind_favorito") |
||
| 314 | public Boolean getIndicadorFavorito() { |
||
| 315 | return indicadorFavorito; |
||
| 316 | } |
||
| 317 | public void setIndicadorFavorito(Boolean indicadorFavorito) { |
||
| 318 | this.indicadorFavorito = indicadorFavorito; |
||
| 319 | } |
||
| 320 | |||
| 321 | @Column(name="ind_comissionado") |
||
| 322 | public Boolean getIndicadorComissionado() { |
||
| 323 | return indicadorComissionado; |
||
| 324 | } |
||
| 325 | public void setIndicadorComissionado(Boolean indicadorComissionado) { |
||
| 326 | this.indicadorComissionado = indicadorComissionado; |
||
| 327 | } |
||
| 328 | |||
| 329 | @Column(name="ind_personalizavel") |
||
| 330 | public Boolean getIndicadorPersonalizavel() { |
||
| 331 | return indicadorPersonalizavel; |
||
| 332 | } |
||
| 333 | public void setIndicadorPersonalizavel(Boolean indicadorPersonalizavel) { |
||
| 334 | this.indicadorPersonalizavel = indicadorPersonalizavel; |
||
| 335 | } |
||
| 336 | |||
| 337 | @Column(name="ind_emissao_nf") |
||
| 338 | public Boolean getIndicadorEmissaoNotaFiscal() { |
||
| 339 | if (VerificadorUtil.estaNulo(indicadorEmissaoNotaFiscal)) { |
||
| 340 | return false; |
||
| 341 | } |
||
| 342 | return indicadorEmissaoNotaFiscal; |
||
| 343 | } |
||
| 344 | public void setIndicadorEmissaoNotaFiscal(Boolean indicadorEmissaoNotaFiscal) { |
||
| 345 | this.indicadorEmissaoNotaFiscal = indicadorEmissaoNotaFiscal; |
||
| 346 | } |
||
| 347 | |||
| 348 | @Column(name="ind_sujeito_st", nullable=false) |
||
| 349 | public Boolean getSujeitoST() { |
||
| 350 | if (VerificadorUtil.estaNulo(sujeitoST)) { |
||
| 351 | return false; |
||
| 352 | } |
||
| 353 | return sujeitoST; |
||
| 354 | } |
||
| 355 | public void setSujeitoST(Boolean sujeitoST) { |
||
| 356 | this.sujeitoST = sujeitoST; |
||
| 357 | } |
||
| 358 | |||
| 359 | @Transient |
||
| 360 | public Double getValorVarejoSimulacao() { |
||
| 361 | if (VerificadorUtil.estaNulo(valorVarejoSimulacao)) { |
||
| 362 | return getValorVarejo(); |
||
| 363 | } |
||
| 364 | return valorVarejoSimulacao; |
||
| 365 | } |
||
| 366 | public void setValorVarejoSimulacao(Double valorVarejoSimulacao) { |
||
| 367 | this.valorVarejoSimulacao = valorVarejoSimulacao; |
||
| 368 | } |
||
| 369 | |||
| 370 | @Transient |
||
| 371 | public Double getValorEm18x() { |
||
| 372 | if (VerificadorUtil.naoEstaNulo(getValorVarejo())) { |
||
| 373 | return getValorVarejo() * 1.12; |
||
| 374 | } |
||
| 375 | return 0.0; |
||
| 376 | } |
||
| 377 | |||
| 378 | @Transient |
||
| 379 | public Double getJurosValorEm18x() { |
||
| 380 | if (VerificadorUtil.naoEstaNulo(getValorEm18x()) && |
||
| 381 | VerificadorUtil.naoEstaNulo(getValorVarejo())) { |
||
| 382 | return getValorEm18x() - getValorVarejo(); |
||
| 383 | } |
||
| 384 | return 0.0; |
||
| 385 | } |
||
| 386 | |||
| 387 | @Transient |
||
| 388 | public Double getParcelasValorEm18x() { |
||
| 389 | if (VerificadorUtil.naoEstaNulo(getValorEm18x())) { |
||
| 390 | if (getValorEm18x() > 0.0) { |
||
| 391 | return getValorEm18x()/18; |
||
| 392 | } |
||
| 393 | } |
||
| 394 | return 0.0; |
||
| 395 | } |
||
| 396 | |||
| 397 | @Column(name="val_aliquota_icms") |
||
| 398 | public Double getAliquotaIcms() { |
||
| 399 | return aliquotaIcms; |
||
| 400 | } |
||
| 401 | public void setAliquotaIcms(Double aliquotaIcms) { |
||
| 402 | this.aliquotaIcms = aliquotaIcms; |
||
| 403 | } |
||
| 404 | |||
| 405 | @Transient |
||
| 406 | public Double getAliquotaIcmsNotaFiscal() { |
||
| 407 | return aliquotaIcmsNotaFiscal; |
||
| 408 | } |
||
| 409 | public void setAliquotaIcmsNotaFiscal(Double aliquotaIcmsNotaFiscal) { |
||
| 410 | this.aliquotaIcmsNotaFiscal = aliquotaIcmsNotaFiscal; |
||
| 411 | } |
||
| 412 | |||
| 413 | @Column(name="val_aliquota_icms_st") |
||
| 414 | public Double getAliquotaIcmsST() { |
||
| 415 | return aliquotaIcmsST; |
||
| 416 | } |
||
| 417 | public void setAliquotaIcmsST(Double aliquotaIcmsST) { |
||
| 418 | this.aliquotaIcmsST = aliquotaIcmsST; |
||
| 419 | } |
||
| 420 | |||
| 421 | @Column(name="val_aliquota_fecoep") |
||
| 422 | public Double getAliquotaFecoep() { |
||
| 423 | return aliquotaFecoep; |
||
| 424 | } |
||
| 425 | public void setAliquotaFecoep(Double aliquotaFecoep) { |
||
| 426 | this.aliquotaFecoep = aliquotaFecoep; |
||
| 427 | } |
||
| 428 | |||
| 429 | @Column(name="val_aliquota_ipi") |
||
| 430 | public Double getAliquotaIPI() { |
||
| 431 | return aliquotaIPI; |
||
| 432 | } |
||
| 433 | public void setAliquotaIPI(Double aliquotaIPI) { |
||
| 434 | this.aliquotaIPI = aliquotaIPI; |
||
| 435 | } |
||
| 436 | |||
| 437 | @Transient |
||
| 438 | public Double getAliquotaIPINotaFiscal() { |
||
| 439 | return aliquotaIPINotaFiscal; |
||
| 440 | } |
||
| 441 | public void setAliquotaIPINotaFiscal(Double aliquotaIPINotaFiscal) { |
||
| 442 | this.aliquotaIPINotaFiscal = aliquotaIPINotaFiscal; |
||
| 443 | } |
||
| 444 | |||
| 445 | @Column(name="ind_ativo") |
||
| 446 | public Boolean getAtivo() { |
||
| 447 | return ativo; |
||
| 448 | } |
||
| 449 | public void setAtivo(Boolean ativo) { |
||
| 450 | this.ativo = ativo; |
||
| 451 | } |
||
| 452 | |||
| 453 | /* |
||
| 454 | @OneToMany(mappedBy="produto", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 455 | public Set<ProdutoPedidoCompra> getPedidosCompra() { |
||
| 456 | return pedidosCompra; |
||
| 457 | } |
||
| 458 | public void setPedidosCompra(Set<ProdutoPedidoCompra> pedidosCompra) { |
||
| 459 | this.pedidosCompra = pedidosCompra; |
||
| 460 | } |
||
| 461 | |||
| 462 | @OneToMany(mappedBy="produto", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 463 | public Set<ProdutoLoja> getEstoques() { |
||
| 464 | return estoques; |
||
| 465 | } |
||
| 466 | public void setEstoques(Set<ProdutoLoja> estoques) { |
||
| 467 | this.estoques = estoques; |
||
| 468 | } |
||
| 469 | |||
| 470 | @OneToMany(mappedBy="produto", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 471 | public Set<FornecedorProduto> getFornecedores() { |
||
| 472 | return fornecedores; |
||
| 473 | } |
||
| 474 | public void setFornecedores(Set<FornecedorProduto> fornecedores) { |
||
| 475 | this.fornecedores = fornecedores; |
||
| 476 | } |
||
| 477 | |||
| 478 | @OneToMany(mappedBy="produto", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 479 | public Set<ProdutoRelacionado> getRelacionados() { |
||
| 480 | return relacionados; |
||
| 481 | } |
||
| 482 | public void setRelacionados(Set<ProdutoRelacionado> relacionados) { |
||
| 483 | this.relacionados = relacionados; |
||
| 484 | } |
||
| 485 | |||
| 486 | @OneToMany(mappedBy="produtoRelacionado", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 487 | public Set<ProdutoRelacionado> getRelacionadosReverse() { |
||
| 488 | return relacionadosReverse; |
||
| 489 | } |
||
| 490 | public void setRelacionadosReverse(Set<ProdutoRelacionado> relacionadosReverse) { |
||
| 491 | this.relacionadosReverse = relacionadosReverse; |
||
| 492 | } |
||
| 493 | */ |
||
| 494 | |||
| 495 | @Transient |
||
| 496 | public Boolean getIndicadorOnline() { |
||
| 497 | if (VerificadorUtil.estaNulo(this.getDataOnline()) && VerificadorUtil.estaNulo(this.indicadorOnline)) { |
||
| 498 | setIndicadorOnline(false); |
||
| 499 | } else { |
||
| 500 | setIndicadorOnline(true); |
||
| 501 | } |
||
| 502 | return indicadorOnline; |
||
| 503 | } |
||
| 504 | public void setIndicadorOnline(Boolean indicadorOnline) { |
||
| 505 | this.indicadorOnline = indicadorOnline; |
||
| 506 | } |
||
| 507 | public void atualizarDataOnline() { |
||
| 508 | if (VerificadorUtil.estaNulo(this.getDataOnline())) { |
||
| 509 | this.setDataOnline(DataUtils.getDataAtual()); |
||
| 510 | } else { |
||
| 511 | this.setDataOnline(null); |
||
| 512 | } |
||
| 513 | } |
||
| 514 | |||
| 515 | @Transient |
||
| 516 | public Boolean getIndicadorOnlineShoplog() { |
||
| 517 | if (VerificadorUtil.estaNulo(this.getDataOnlineShoplog()) && VerificadorUtil.estaNulo(this.indicadorOnlineShoplog)) { |
||
| 518 | setIndicadorOnlineShoplog(false); |
||
| 519 | } else { |
||
| 520 | setIndicadorOnlineShoplog(true); |
||
| 521 | } |
||
| 522 | return indicadorOnlineShoplog; |
||
| 523 | } |
||
| 524 | public void setIndicadorOnlineShoplog(Boolean indicadorOnlineShoplog) { |
||
| 525 | this.indicadorOnlineShoplog = indicadorOnlineShoplog; |
||
| 526 | } |
||
| 527 | public void atualizarDataOnlineShoplog() { |
||
| 528 | if (VerificadorUtil.estaNulo(this.getDataOnlineShoplog())) { |
||
| 529 | this.setDataOnlineShoplog(DataUtils.getDataAtual()); |
||
| 530 | } else { |
||
| 531 | this.setDataOnlineShoplog(null); |
||
| 532 | } |
||
| 533 | } |
||
| 534 | |||
| 535 | @Transient |
||
| 536 | public Boolean getIndicadorOnlineMercadoLivre() { |
||
| 537 | if (VerificadorUtil.estaNulo(this.getDataOnlineMercadoLivre()) && VerificadorUtil.estaNulo(this.indicadorOnlineMercadoLivre)) { |
||
| 538 | setIndicadorOnlineMercadoLivre(false); |
||
| 539 | } else { |
||
| 540 | setIndicadorOnlineMercadoLivre(true); |
||
| 541 | } |
||
| 542 | return indicadorOnlineMercadoLivre; |
||
| 543 | } |
||
| 544 | public void setIndicadorOnlineMercadoLivre(Boolean indicadorOnlineMercadoLivre) { |
||
| 545 | this.indicadorOnlineMercadoLivre = indicadorOnlineMercadoLivre; |
||
| 546 | } |
||
| 547 | public void atualizarDataOnlineMercadoLivre() { |
||
| 548 | if (VerificadorUtil.estaNulo(this.getDataOnlineMercadoLivre())) { |
||
| 549 | this.setDataOnlineMercadoLivre(DataUtils.getDataAtual()); |
||
| 550 | } else { |
||
| 551 | this.setDataOnlineMercadoLivre(null); |
||
| 552 | } |
||
| 553 | } |
||
| 554 | |||
| 555 | /* |
||
| 556 | @Transient |
||
| 557 | public List<TransferenciaProduto> getTransferenciasAbertas() { |
||
| 558 | return transferenciasAbertas; |
||
| 559 | } |
||
| 560 | public void setTransferenciasAbertas(List<TransferenciaProduto> transferenciasAbertas) { |
||
| 561 | this.transferenciasAbertas = transferenciasAbertas; |
||
| 562 | } |
||
| 563 | |||
| 564 | @Transient |
||
| 565 | public List<PedidoProduto> getPedidosPendentes() { |
||
| 566 | return pedidosPendentes; |
||
| 567 | } |
||
| 568 | public void setPedidosPendentes(List<PedidoProduto> pedidosPendentes) { |
||
| 569 | this.pedidosPendentes = pedidosPendentes; |
||
| 570 | } |
||
| 571 | */ |
||
| 572 | @Transient |
||
| 573 | public Date getDataUltimaVenda() { |
||
| 574 | return dataUltimaVenda; |
||
| 575 | } |
||
| 576 | public void setDataUltimaVenda(Date dataUltimaVenda) { |
||
| 577 | this.dataUltimaVenda = dataUltimaVenda; |
||
| 578 | } |
||
| 579 | |||
| 580 | @Transient |
||
| 581 | public Integer getQuantidadeDiasUltimaVenda() { |
||
| 582 | if (VerificadorUtil.naoEstaNulo(getDataUltimaVenda())) { |
||
| 583 | return DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), getDataUltimaVenda()); |
||
| 584 | } |
||
| 585 | return null; |
||
| 586 | } |
||
| 587 | /* |
||
| 588 | @Transient |
||
| 589 | public ArrayList<ProdutoRelacionado> getCompativeis() { |
||
| 590 | ArrayList<ProdutoRelacionado> compativeis = new ArrayList<ProdutoRelacionado>(); |
||
| 591 | if (VerificadorUtil.naoEstaNulo(getRelacionados())) { |
||
| 592 | compativeis.addAll(getRelacionados()); |
||
| 593 | } |
||
| 594 | if (VerificadorUtil.naoEstaNulo(getRelacionadosReverse())) { |
||
| 595 | compativeis.addAll(getRelacionadosReverse()); |
||
| 596 | } |
||
| 597 | return compativeis; |
||
| 598 | } |
||
| 599 | */ |
||
| 600 | @Transient |
||
| 601 | public String getCodigoNCM() { |
||
| 602 | return codigoNCM; |
||
| 603 | } |
||
| 604 | public void setCodigoNCM(String codigoNCM) { |
||
| 605 | this.codigoNCM = codigoNCM; |
||
| 606 | } |
||
| 607 | |||
| 608 | @Transient |
||
| 609 | public String getCodigoEST() { |
||
| 610 | return codigoEST; |
||
| 611 | } |
||
| 612 | public void setCodigoEST(String codigoEST) { |
||
| 613 | this.codigoEST = codigoEST; |
||
| 614 | } |
||
| 615 | |||
| 616 | /* |
||
| 617 | @OneToMany(mappedBy="produto", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 618 | public Set<ProdutoArquivo> getFotos() { |
||
| 619 | return fotos; |
||
| 620 | } |
||
| 621 | public void setFotos(Set<ProdutoArquivo> fotos) { |
||
| 622 | this.fotos = fotos; |
||
| 623 | } |
||
| 624 | */ |
||
| 625 | /***************************************************************/ |
||
| 626 | |||
| 627 | @Transient |
||
| 628 | public String getCodigoProdutoPadrao() { |
||
| 629 | try { |
||
| 630 | return VerificadorUtil.naoEstaNulo(codigo) ? String.format("%06d", new Long(codigo.trim())) : ""; |
||
| 631 | } catch (Exception e) { |
||
| 632 | return ""; |
||
| 633 | } |
||
| 634 | } |
||
| 635 | |||
| 636 | public static void main(String[] args) { |
||
| 637 | // System.out.println(String.format("%07d", new Long(12879))); |
||
| 638 | // codigoBarras.gerarCodigoBarra(String.format("%012d", new Long(12879))); |
||
| 639 | // System.out.println(codigoBarras.getCodigoBarra()); |
||
| 640 | //System.out.println(CodigoBarraEAN.gerarCodigoBarras("6659")); |
||
| 641 | // System.out.println(codigoBarras.longToEan13("900000012879")); |
||
| 642 | } |
||
| 643 | |||
| 644 | @Transient |
||
| 645 | public String getCodigoDeBarrasProdutoPadrao() { |
||
| 646 | try { |
||
| 647 | return VerificadorUtil.naoEstaNulo(codigo)? String.format("%07d", new Long(codigo)) : ""; |
||
| 648 | // return VerificadorUtil.naoEstaNulo(codigo) ? StringUtils.rightPad(codigo, 12, "0") : ""; |
||
| 649 | } catch (Exception e) { |
||
| 650 | return ""; |
||
| 651 | } |
||
| 652 | } |
||
| 653 | |||
| 654 | /* |
||
| 655 | @Transient |
||
| 656 | public String getDescricaoDoModelo() { |
||
| 657 | return VerificadorUtil.naoEstaNulo(modelo)? modelo.getDescricao() : ""; |
||
| 658 | } |
||
| 659 | |||
| 660 | @Transient |
||
| 661 | public String getDescricaoTecnicaDoModelo() { |
||
| 662 | return VerificadorUtil.naoEstaNulo(modelo)? VerificadorUtil.naoEstaNulo(modelo.getDescricaoTecnica())? modelo.getDescricaoTecnica() : "" : ""; |
||
| 663 | } |
||
| 664 | |||
| 665 | @Transient |
||
| 666 | public String getDescricaoTecnicaDoModeloComParenteses() { |
||
| 667 | return VerificadorUtil.naoEstaNulo(modelo)? VerificadorUtil.naoEstaNulo(modelo.getDescricaoTecnica())? " (" + modelo.getDescricaoTecnica() + ") " : "" : ""; |
||
| 668 | } |
||
| 669 | |||
| 670 | @Transient |
||
| 671 | public Long getSequencialDoModelo() { |
||
| 672 | return VerificadorUtil.naoEstaNulo(modelo)? modelo.getSequencial() : null; |
||
| 673 | } |
||
| 674 | |||
| 675 | @Transient |
||
| 676 | public Marca getMarcaDoModelo() { |
||
| 677 | if (VerificadorUtil.naoEstaNulo(modelo)) { |
||
| 678 | if (VerificadorUtil.naoEstaNulo(modelo.getMarca())) { |
||
| 679 | return modelo.getMarca(); |
||
| 680 | } |
||
| 681 | } |
||
| 682 | return null; |
||
| 683 | } |
||
| 684 | |||
| 685 | @Transient |
||
| 686 | public String getDescricaoDaMarcaDoModelo() { |
||
| 687 | return VerificadorUtil.naoEstaNulo(getMarcaDoModelo())? getMarcaDoModelo().getDescricao() : ""; |
||
| 688 | } |
||
| 689 | |||
| 690 | @Transient |
||
| 691 | public String getDescricaoComModeloCompletaComCodigo() { |
||
| 692 | StringBuilder descricaoCompleta = new StringBuilder(); |
||
| 693 | descricaoCompleta.append("["); |
||
| 694 | descricaoCompleta.append(getCodigoProdutoPadrao()); |
||
| 695 | descricaoCompleta.append("] "); |
||
| 696 | if (VerificadorUtil.naoEstaNuloOuVazio(getDescricaoDoModelo())) { |
||
| 697 | descricaoCompleta.append(getDescricaoDoModelo()); |
||
| 698 | descricaoCompleta.append(" - "); |
||
| 699 | } |
||
| 700 | descricaoCompleta.append(getDescricaoCompleta()); |
||
| 701 | return descricaoCompleta.toString(); |
||
| 702 | } |
||
| 703 | |||
| 704 | @Transient |
||
| 705 | public String getDescricaoComModeloCompleta() { |
||
| 706 | StringBuilder descricaoCompleta = new StringBuilder(); |
||
| 707 | if (VerificadorUtil.naoEstaNuloOuVazio(getDescricaoDoModelo())) { |
||
| 708 | descricaoCompleta.append(getDescricaoDoModelo()); |
||
| 709 | descricaoCompleta.append(" - "); |
||
| 710 | } |
||
| 711 | descricaoCompleta.append(getDescricaoCompleta()); |
||
| 712 | return descricaoCompleta.toString(); |
||
| 713 | } |
||
| 714 | |||
| 715 | @Transient |
||
| 716 | public String getDescricaoCompleta() { |
||
| 717 | StringBuilder descricaoCompleta = new StringBuilder(); |
||
| 718 | if (VerificadorUtil.naoEstaNuloOuVazio(getEstilo())) { |
||
| 719 | descricaoCompleta.append(getDescricaoDoEstilo()); |
||
| 720 | descricaoCompleta.append(" "); |
||
| 721 | } |
||
| 722 | descricaoCompleta.append(getDescricao()); |
||
| 723 | if (VerificadorUtil.naoEstaNuloOuVazio(getCor())) { |
||
| 724 | descricaoCompleta.append(" ("); |
||
| 725 | descricaoCompleta.append(getDescricaoDaCor()); |
||
| 726 | descricaoCompleta.append(")"); |
||
| 727 | } |
||
| 728 | return descricaoCompleta.toString(); |
||
| 729 | } |
||
| 730 | |||
| 731 | @Transient |
||
| 732 | public String getDescricaoCompletaCapa() { |
||
| 733 | StringBuilder descricaoCompleta = new StringBuilder(); |
||
| 734 | descricaoCompleta.append(getCodigo()); |
||
| 735 | descricaoCompleta.append(" - "); |
||
| 736 | if (this.getTipo().equals(TipoProduto.CAPA.getValor())) { |
||
| 737 | descricaoCompleta.append("CAPA"); |
||
| 738 | } |
||
| 739 | if (!this.getTipo().equals(TipoProduto.ACESSORIO.getValor())) { |
||
| 740 | descricaoCompleta.append(" "); |
||
| 741 | descricaoCompleta.append(getDescricaoDoModelo()); |
||
| 742 | } |
||
| 743 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getEstilo())) { |
||
| 744 | descricaoCompleta.append(" "); |
||
| 745 | descricaoCompleta.append(getDescricaoDoEstilo()); |
||
| 746 | } |
||
| 747 | descricaoCompleta.append(" "); |
||
| 748 | if (this.getDescricao().length() > 50) { |
||
| 749 | descricaoCompleta.append(getDescricao().substring(0, 50)); |
||
| 750 | } else { |
||
| 751 | descricaoCompleta.append(getDescricao()); |
||
| 752 | } |
||
| 753 | if (VerificadorUtil.naoEstaNuloOuVazio(getCor())) { |
||
| 754 | descricaoCompleta.append(" ("); |
||
| 755 | descricaoCompleta.append(getDescricaoDaCor()); |
||
| 756 | descricaoCompleta.append(")"); |
||
| 757 | } |
||
| 758 | return descricaoCompleta.toString(); |
||
| 759 | } |
||
| 760 | */ |
||
| 761 | @Transient |
||
| 762 | public String getDescricaoDoTipo() { |
||
| 763 | return VerificadorUtil.naoEstaNuloOuVazio(getTipo())? TipoProduto.parse(getTipo()).getDescricao() : null; |
||
| 764 | } |
||
| 765 | /* |
||
| 766 | @Transient |
||
| 767 | public String getDescricaoDoGenero() { |
||
| 768 | return VerificadorUtil.naoEstaNuloOuVazio(getGenero())? TipoGenero.parse(getGenero()).getDescricao() : null; |
||
| 769 | } |
||
| 770 | |||
| 771 | @Transient |
||
| 772 | public String getDescricaoDoEstilo() { |
||
| 773 | return VerificadorUtil.naoEstaNuloOuVazio(getEstilo())? TipoEstiloProduto.parse(getEstilo()).getDescricao() : null; |
||
| 774 | } |
||
| 775 | |||
| 776 | @Transient |
||
| 777 | public String getDescricaoDaCor() { |
||
| 778 | return VerificadorUtil.naoEstaNuloOuVazio(getCor())? TipoCorProduto.parse(getCor()).getDescricao() : null; |
||
| 779 | } |
||
| 780 | |||
| 781 | @Transient |
||
| 782 | public String getDescricaoNotaFiscal(String observacaoNotaFiscal) { |
||
| 783 | StringBuilder descricaoCompleta = new StringBuilder(); |
||
| 784 | if (this.getTipo().equals(TipoProduto.CAPA.getValor())) { |
||
| 785 | descricaoCompleta.append("CAPA"); |
||
| 786 | } |
||
| 787 | if (!this.getTipo().equals(TipoProduto.ACESSORIO.getValor()) //!this.getTipo().equals(TipoProduto.RESTAURANTE.getValor()) |
||
| 788 | ) { |
||
| 789 | descricaoCompleta.append(" "); |
||
| 790 | descricaoCompleta.append(this.getDescricaoDoModelo()); |
||
| 791 | } |
||
| 792 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getEstilo())) { |
||
| 793 | descricaoCompleta.append(" "); |
||
| 794 | descricaoCompleta.append(this.getDescricaoDoEstilo()); |
||
| 795 | } |
||
| 796 | descricaoCompleta.append(" "); |
||
| 797 | if (this.getDescricao().length() > 50) { |
||
| 798 | descricaoCompleta.append(this.getDescricao().substring(0, 50)); |
||
| 799 | } else { |
||
| 800 | descricaoCompleta.append(this.getDescricao()); |
||
| 801 | } |
||
| 802 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getCor())) { |
||
| 803 | descricaoCompleta.append(" ("); |
||
| 804 | descricaoCompleta.append(this.getDescricaoDaCor()); |
||
| 805 | descricaoCompleta.append(")"); |
||
| 806 | } |
||
| 807 | if (VerificadorUtil.naoEstaNuloOuVazio(observacaoNotaFiscal)) { |
||
| 808 | descricaoCompleta.append(" "); |
||
| 809 | descricaoCompleta.append(observacaoNotaFiscal); |
||
| 810 | } |
||
| 811 | return descricaoCompleta.toString().trim(); |
||
| 812 | } |
||
| 813 | */ |
||
| 814 | @Transient |
||
| 815 | public Integer getQuantidadeEstoqueTotal() { |
||
| 816 | Integer total = 0; |
||
| 817 | /* |
||
| 818 | for (ProdutoLoja estoque : estoques) { |
||
| 819 | total = total + estoque.getQuantidadeEstoque(); |
||
| 820 | } |
||
| 821 | */ |
||
| 822 | return total; |
||
| 823 | } |
||
| 824 | |||
| 825 | @Transient |
||
| 826 | public Boolean verificarSeQuantidadeEhMenor(Integer primeiro, Integer segundo) { |
||
| 827 | if (VerificadorUtil.naoEstaNulo(primeiro) && VerificadorUtil.naoEstaNulo(segundo)) { |
||
| 828 | return primeiro <= segundo ? true : false; |
||
| 829 | } |
||
| 830 | return false; |
||
| 831 | } |
||
| 832 | |||
| 833 | public void atualizarDados(Produto produto) { |
||
| 834 | this.codigo = produto.getCodigo(); |
||
| 835 | this.descricao = produto.getDescricao(); |
||
| 836 | this.valorCompra = produto.getValorCompra(); |
||
| 837 | this.valorVarejo = produto.getValorVarejo(); |
||
| 838 | if (produto.getQuantidadeEstoqueTotal() > 0) { |
||
| 839 | this.setAtivo(true); |
||
| 840 | } |
||
| 841 | } |
||
| 842 | /* |
||
| 843 | public void atualizarDadosNfe(nfce.java.TNFe.InfNFe.Det produtoNota) { |
||
| 844 | if (VerificadorUtil.estaNuloOuVazio(this.getDescricao())) { |
||
| 845 | this.setDescricao(produtoNota.getProd().getXProd()); |
||
| 846 | } |
||
| 847 | if (VerificadorUtil.estaNuloOuVazio(this.getGenero())) { |
||
| 848 | this.setGenero(TipoGenero.UNISSEX.getValor()); |
||
| 849 | } |
||
| 850 | |||
| 851 | this.setCodigoEAN(StringUtil.retornarApenasNumeros(produtoNota.getProd().getCEAN())); |
||
| 852 | this.setCodigoEANTributado(StringUtil.retornarApenasNumeros(produtoNota.getProd().getCEANTrib())); |
||
| 853 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getNCM())) { |
||
| 854 | this.setCodigoNCM(produtoNota.getProd().getNCM()); |
||
| 855 | } |
||
| 856 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getCEST())) { |
||
| 857 | this.setCodigoEST(produtoNota.getProd().getCEST()); |
||
| 858 | } |
||
| 859 | |||
| 860 | for (JAXBElement<?> elemento : produtoNota.getImposto().getContent()) { |
||
| 861 | if (elemento.getDeclaredType().equals(nfce.java.TNFe.InfNFe.Det.Imposto.ICMS.class)) { |
||
| 862 | nfce.java.TNFe.InfNFe.Det.Imposto.ICMS icms = (nfce.java.TNFe.InfNFe.Det.Imposto.ICMS) elemento.getValue(); |
||
| 863 | if (VerificadorUtil.naoEstaNulo(icms.getICMS00())) { |
||
| 864 | preencherAliquotaIcms(Double.valueOf(icms.getICMS00().getPICMS())); |
||
| 865 | } |
||
| 866 | if (VerificadorUtil.naoEstaNulo(icms.getICMS10())) { |
||
| 867 | preencherAliquotaIcms(Double.valueOf(icms.getICMS10().getPICMS())); |
||
| 868 | } |
||
| 869 | } |
||
| 870 | if (elemento.getDeclaredType().equals(nfce.java.TIpi.class)) { |
||
| 871 | nfce.java.TIpi ipi = (nfce.java.TIpi) elemento.getValue(); |
||
| 872 | if (VerificadorUtil.naoEstaNulo(ipi.getIPITrib())) { |
||
| 873 | Double aliquotaIPITrib = Double.valueOf(ipi.getIPITrib().getPIPI()); |
||
| 874 | if (aliquotaIPITrib > 0.0) { |
||
| 875 | this.setAliquotaIPINotaFiscal(aliquotaIPITrib); |
||
| 876 | } |
||
| 877 | } |
||
| 878 | } |
||
| 879 | } |
||
| 880 | if (VerificadorUtil.estaNulo(getAliquotaIcms())) { |
||
| 881 | this.setAliquotaIcmsNotaFiscal(0.0); |
||
| 882 | this.setAliquotaIcms(ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_INTERNA_ICMS_PADRAO_12); |
||
| 883 | } |
||
| 884 | |||
| 885 | if (VerificadorUtil.estaNulo(this.getValorCompra())) { |
||
| 886 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getVUnCom())) { |
||
| 887 | this.setValorCompra(retornarValorComDesconto(produtoNota.getProd())); |
||
| 888 | } |
||
| 889 | } |
||
| 890 | } |
||
| 891 | |||
| 892 | private void preencherAliquotaIcms(Double aliquotaIcms) { |
||
| 893 | if (aliquotaIcms > 0.0) { |
||
| 894 | this.setAliquotaIcmsNotaFiscal(aliquotaIcms); |
||
| 895 | this.setAliquotaIcms(aliquotaIcms); |
||
| 896 | } else { |
||
| 897 | this.setAliquotaIcmsNotaFiscal(0.0); |
||
| 898 | this.setAliquotaIcms(ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_INTERNA_ICMS_PADRAO_12); |
||
| 899 | } |
||
| 900 | } |
||
| 901 | |||
| 902 | public Double retornarValorComDesconto(nfce.java.TNFe.InfNFe.Det.Prod produto) { |
||
| 903 | Double valor = 0.0; |
||
| 904 | if (VerificadorUtil.naoEstaNuloOuVazio(produto.getVDesc())) { |
||
| 905 | valor = (new Double(produto.getVProd()) - new Double(produto.getVDesc())) / new Double(produto.getQCom()).intValue(); |
||
| 906 | } else { |
||
| 907 | valor = new Double(produto.getVUnCom()); |
||
| 908 | } |
||
| 909 | return valor; |
||
| 910 | } |
||
| 911 | */ |
||
| 912 | public Double retornarLucroBruto() { |
||
| 913 | if (VerificadorUtil.naoEstaNulo(getValorCompra()) && VerificadorUtil.naoEstaNulo(getValorVarejo())) { |
||
| 914 | if (VerificadorUtil.naoEstaNulo(getValorVarejoPromocional())) { |
||
| 915 | return (getValorVarejoPromocional() / getValorCompra()) - 1.0; |
||
| 916 | } else { |
||
| 917 | return (getValorVarejo() / getValorCompra()) - 1.0; |
||
| 918 | } |
||
| 919 | } |
||
| 920 | return 0.0; |
||
| 921 | } |
||
| 922 | |||
| 923 | public Double retornarMargemBruta() { |
||
| 924 | if (VerificadorUtil.naoEstaNulo(getValorCompra()) && VerificadorUtil.naoEstaNulo(getValorVarejo())) { |
||
| 925 | if (VerificadorUtil.naoEstaNulo(getValorVarejoPromocional())) { |
||
| 926 | return (100 - (getValorCompra()*100/getValorVarejoPromocional())) / 100; |
||
| 927 | } else { |
||
| 928 | return (100 - (getValorCompra()*100/getValorVarejo())) / 100; |
||
| 929 | } |
||
| 930 | } |
||
| 931 | return 0.0; |
||
| 932 | } |
||
| 933 | |||
| 934 | public Double retornarValorMargemBruta() { |
||
| 935 | Double margemBruta = retornarMargemBruta(); |
||
| 936 | if (margemBruta > 0.0) { |
||
| 937 | if (VerificadorUtil.naoEstaNulo(getValorVarejoPromocional())) { |
||
| 938 | return margemBruta * getValorVarejoPromocional(); |
||
| 939 | } else { |
||
| 940 | return margemBruta * getValorVarejo(); |
||
| 941 | } |
||
| 942 | } |
||
| 943 | return 0.0; |
||
| 944 | } |
||
| 945 | |||
| 946 | @Transient |
||
| 947 | public String retornarCorMargem() { |
||
| 948 | Double margemBruta = retornarMargemBruta(); |
||
| 949 | if (margemBruta > 0.50) return "green"; |
||
| 950 | if (margemBruta > 0.34) return "orange"; |
||
| 951 | if (margemBruta < 0.35) return "red"; |
||
| 952 | return "black"; |
||
| 953 | } |
||
| 954 | /* |
||
| 955 | @Transient |
||
| 956 | public String retornarCorMargemLucro() { |
||
| 957 | Double margemBruta = calculoMargemAposCustos(); |
||
| 958 | if (margemBruta > 29.99) return "green"; |
||
| 959 | if (margemBruta > 14.99) return "orange"; |
||
| 960 | if (margemBruta < 15.0) return "red"; |
||
| 961 | return "black"; |
||
| 962 | } |
||
| 963 | |||
| 964 | @Transient |
||
| 965 | public String getFornecedorMenorValorComprado(Fornecedor fornecedorComprar) { |
||
| 966 | FornecedorProduto menorValor = null; |
||
| 967 | for (FornecedorProduto fornecedorProduto : this.getFornecedores()) { |
||
| 968 | if (menorValor == null) { |
||
| 969 | menorValor = fornecedorProduto; |
||
| 970 | } else { |
||
| 971 | if (VerificadorUtil.estaNulo(menorValor.getValorCompra()) && |
||
| 972 | VerificadorUtil.naoEstaNulo(fornecedorProduto.getValorCompra())) { |
||
| 973 | menorValor = fornecedorProduto; |
||
| 974 | } |
||
| 975 | if (VerificadorUtil.naoEstaNulo(menorValor.getValorCompra()) && |
||
| 976 | VerificadorUtil.naoEstaNulo(fornecedorProduto.getValorCompra())) { |
||
| 977 | if (menorValor.getValorCompra() > fornecedorProduto.getValorCompra()) { |
||
| 978 | menorValor = fornecedorProduto; |
||
| 979 | } |
||
| 980 | } |
||
| 981 | } |
||
| 982 | } |
||
| 983 | String menorValorComprado = ""; |
||
| 984 | if (VerificadorUtil.naoEstaNulo(menorValor)) { |
||
| 985 | menorValorComprado = "R$ " + formatarValor(menorValor.getValorCompra()); |
||
| 986 | if (VerificadorUtil.naoEstaNulo(menorValor.getFornecedor().getNomeDaPessoa())) { |
||
| 987 | if (!menorValor.getFornecedor().equals(fornecedorComprar)) { |
||
| 988 | menorValorComprado = menorValorComprado + ", " + menorValor.getFornecedor().getNomeDaPessoa(); |
||
| 989 | if (VerificadorUtil.naoEstaNulo(menorValor.getIdentificador())) { |
||
| 990 | menorValorComprado = menorValorComprado + ", ID: " + menorValor.getIdentificador(); |
||
| 991 | } |
||
| 992 | } |
||
| 993 | } |
||
| 994 | } |
||
| 995 | return menorValorComprado; |
||
| 996 | } |
||
| 997 | */ |
||
| 998 | private String formatarValor(Double valor) { |
||
| 999 | return VerificadorUtil.naoEstaNulo(valor)? String.format("%.2f", valor) : "0,00"; |
||
| 1000 | } |
||
| 1001 | |||
| 1002 | @Override |
||
| 1003 | public int hashCode() { |
||
| 1004 | final int prime = 31; |
||
| 1005 | int result = 1; |
||
| 1006 | result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); |
||
| 1007 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 1008 | return result; |
||
| 1009 | } |
||
| 1010 | |||
| 1011 | @Override |
||
| 1012 | public boolean equals(Object obj) { |
||
| 1013 | if (this == obj) |
||
| 1014 | return true; |
||
| 1015 | if (obj == null) |
||
| 1016 | return false; |
||
| 1017 | if (getClass() != obj.getClass()) |
||
| 1018 | return false; |
||
| 1019 | Produto other = (Produto) obj; |
||
| 1020 | if (codigo == null) { |
||
| 1021 | if (other.codigo != null) |
||
| 1022 | return false; |
||
| 1023 | } else if (!codigo.equals(other.codigo)) |
||
| 1024 | return false; |
||
| 1025 | if (sequencial == null) { |
||
| 1026 | if (other.sequencial != null) |
||
| 1027 | return false; |
||
| 1028 | } else if (!sequencial.equals(other.sequencial)) |
||
| 1029 | return false; |
||
| 1030 | return true; |
||
| 1031 | } |
||
| 1032 | |||
| 1033 | @Transient |
||
| 1034 | public void prepararNovoProduto() { |
||
| 1035 | setAtivo(true); |
||
| 1036 | setIndicadorFavorito(false); |
||
| 1037 | setIndicadorComissionado(true); |
||
| 1038 | setIndicadorEmissaoNotaFiscal(false); |
||
| 1039 | setSujeitoST(false); |
||
| 1040 | } |
||
| 1041 | |||
| 1042 | @Transient |
||
| 1043 | public boolean tipoProdutoEhCapa() { |
||
| 1044 | return getTipo().equals(TipoProduto.CAPA.getValor()); |
||
| 1045 | } |
||
| 1046 | |||
| 1047 | @Transient |
||
| 1048 | public boolean tipoProdutoEhPelicula() { |
||
| 1049 | return getTipo().equals(TipoProduto.PELICULA.getValor()); |
||
| 1050 | } |
||
| 1051 | |||
| 1052 | @Transient |
||
| 1053 | public boolean tipoProdutoEhCapaOuAcessorio() { |
||
| 1054 | return tipoProdutoEhCapa() || getTipo().equals(TipoProduto.ACESSORIO.getValor()); |
||
| 1055 | } |
||
| 1056 | |||
| 1057 | @Transient |
||
| 1058 | public boolean tipoProdutoEhCapaOuPelicula() { |
||
| 1059 | return tipoProdutoEhCapa() || tipoProdutoEhPelicula(); |
||
| 1060 | } |
||
| 1061 | |||
| 1062 | @Transient |
||
| 1063 | public boolean tipoProdutoEhServico() { |
||
| 1064 | return getTipo().equals(TipoProduto.SERVICO.getValor()); |
||
| 1065 | } |
||
| 1066 | |||
| 1067 | /*@Transient |
||
| 1068 | public boolean tipoProdutoEhRemedioOuOutros() { |
||
| 1069 | return getTipo().equals(TipoProduto.REMEDIO.getValor()) || |
||
| 1070 | getTipo().equals(TipoProduto.REMEDIO_CARTELA.getValor()) || |
||
| 1071 | getTipo().equals(TipoProduto.OUTROS.getValor()); |
||
| 1072 | }*/ |
||
| 1073 | |||
| 1074 | @Transient |
||
| 1075 | public boolean tipoProdutoTributado() { |
||
| 1076 | return getTipo().equals(TipoProduto.ACESSORIO.getValor()) || |
||
| 1077 | getTipo().equals(TipoProduto.APARELHOS.getValor()) || |
||
| 1078 | getTipo().equals(TipoProduto.CAPA.getValor()) || |
||
| 1079 | getTipo().equals(TipoProduto.PELICULA.getValor()); |
||
| 1080 | } |
||
| 1081 | |||
| 1082 | @Transient |
||
| 1083 | public boolean tipoProdutoNaoTributado() { |
||
| 1084 | return /*getTipo().equals(TipoProduto.REMEDIO.getValor()) || |
||
| 1085 | getTipo().equals(TipoProduto.REMEDIO_CARTELA.getValor()) || |
||
| 1086 | getTipo().equals(TipoProduto.OUTROS.getValor()) ||*/ |
||
| 1087 | getTipo().equals(TipoProduto.SERVICO.getValor()); |
||
| 1088 | } |
||
| 1089 | |||
| 1090 | /* |
||
| 1091 | @Transient |
||
| 1092 | public Boolean verificarSeCodigoEhIgual(String codigoProduto) { |
||
| 1093 | if (codigoProduto.length() > 6 && VerificadorUtil.naoEstaNuloOuVazio(this.getCodigoEAN())) { |
||
| 1094 | if (this.getCodigoEAN().equals(codigoProduto)) { |
||
| 1095 | return true; |
||
| 1096 | } |
||
| 1097 | } |
||
| 1098 | if (CodigoBarraEAN.validarCodigoBarras(codigoProduto)) { |
||
| 1099 | return this.getCodigoProdutoPadrao().equals(CodigoBarraEAN.retornarCodigoDoCodigoBarras(codigoProduto)); |
||
| 1100 | } else { |
||
| 1101 | return this.getCodigoProdutoPadrao().equals(UtilBean.padraoCodigoProduto(codigoProduto)); |
||
| 1102 | } |
||
| 1103 | } |
||
| 1104 | */ |
||
| 1105 | |||
| 1106 | @Transient |
||
| 1107 | public String getCodigoNCMDaTributacao() { |
||
| 1108 | return VerificadorUtil.naoEstaNulo(getTributacao())? getTributacao().getCodigoNCM() : null; |
||
| 1109 | } |
||
| 1110 | |||
| 1111 | @Transient |
||
| 1112 | public String getCodigoESTDaTributacao() { |
||
| 1113 | return VerificadorUtil.naoEstaNulo(getTributacao())? getTributacao().getCodigoEST() : null; |
||
| 1114 | } |
||
| 1115 | |||
| 1116 | @Override |
||
| 1117 | public Produto clone() throws CloneNotSupportedException { |
||
| 1118 | return (Produto) super.clone(); |
||
| 1119 | } |
||
| 1120 | /* |
||
| 1121 | @Transient |
||
| 1122 | public String corDaDescricaoPeloGenero() { |
||
| 1123 | if (VerificadorUtil.naoEstaNulo(getGenero())) { |
||
| 1124 | if (getGenero().equals(TipoGenero.MASCULINO.getValor())) return "#1c82df"; |
||
| 1125 | if (getGenero().equals(TipoGenero.FEMININO.getValor())) return "#f06364"; |
||
| 1126 | } |
||
| 1127 | return "black"; |
||
| 1128 | } |
||
| 1129 | */ |
||
| 1130 | @Transient |
||
| 1131 | public Boolean getProdutoEmPromocao() { |
||
| 1132 | if (VerificadorUtil.naoEstaNulo(getValorVarejoPromocional())) { |
||
| 1133 | return getValorVarejoPromocional() > 0.00; |
||
| 1134 | } |
||
| 1135 | return false; |
||
| 1136 | } |
||
| 1137 | /* |
||
| 1138 | @Transient |
||
| 1139 | public void prepararDadosParaDuplicacao(Produto produto) { |
||
| 1140 | this.modelo = produto.getModelo(); |
||
| 1141 | this.tributacao = produto.getTributacao(); |
||
| 1142 | this.descricao = produto.getDescricao(); |
||
| 1143 | this.tipo = produto.getTipo(); |
||
| 1144 | this.estilo = produto.getEstilo(); |
||
| 1145 | this.genero = produto.getGenero(); |
||
| 1146 | this.cor = produto.getCor(); |
||
| 1147 | this.observacao = produto.getObservacao(); |
||
| 1148 | this.valorCompra = produto.getValorCompra(); |
||
| 1149 | this.valorVarejo = produto.getValorVarejo(); |
||
| 1150 | this.valorVarejoPromocional = produto.getValorVarejoPromocional(); |
||
| 1151 | this.valorVarejoMaximo = produto.getValorVarejoMaximo(); |
||
| 1152 | this.valorVarejoPopular = produto.getValorVarejoPopular(); |
||
| 1153 | this.valorAtacado = produto.getValorAtacado(); |
||
| 1154 | this.indicadorComissionado = produto.getIndicadorComissionado(); |
||
| 1155 | this.indicadorEmissaoNotaFiscal = produto.getIndicadorEmissaoNotaFiscal(); |
||
| 1156 | this.codigoNCM = produto.getCodigoNCM(); |
||
| 1157 | this.codigoEST = produto.getCodigoEST(); |
||
| 1158 | this.setSujeitoST(produto.getSujeitoST()); |
||
| 1159 | this.setAliquotaIcms(produto.getAliquotaIcms()); |
||
| 1160 | this.setAliquotaIcmsST(produto.getAliquotaIcmsST()); |
||
| 1161 | this.setAliquotaFecoep(produto.getAliquotaFecoep()); |
||
| 1162 | this.setAliquotaIPI(produto.getAliquotaIPI()); |
||
| 1163 | this.setAtivo(true); |
||
| 1164 | } |
||
| 1165 | */ |
||
| 1166 | @Transient |
||
| 1167 | public void atualizarAliquotas(Fornecedor fornecedor) { |
||
| 1168 | if (VerificadorUtil.naoEstaNulo(getTributacao())) { |
||
| 1169 | setAliquotaIPI(getTributacao().getAliquotaIPI()); |
||
| 1170 | } |
||
| 1171 | |||
| 1172 | if (VerificadorUtil.naoEstaNulo(getTributacao()) |
||
| 1173 | && VerificadorUtil.naoEstaNulo(getAliquotaIcms()) |
||
| 1174 | && VerificadorUtil.naoEstaNulo(fornecedor)) { |
||
| 1175 | if (getTributacao().getSujeitoST() && fornecedor.getSujeitoST()) { |
||
| 1176 | setAliquotaIcmsST(getTributacao().mvaPorIcms(getAliquotaIcms())); |
||
| 1177 | setAliquotaFecoep(getTributacao().getAliquotaFecoep()); |
||
| 1178 | setSujeitoST(true); |
||
| 1179 | } else { |
||
| 1180 | setAliquotaFecoep(null); |
||
| 1181 | setAliquotaIcmsST(null); |
||
| 1182 | setSujeitoST(false); |
||
| 1183 | } |
||
| 1184 | } else if (VerificadorUtil.naoEstaNulo(getTributacao()) && VerificadorUtil.naoEstaNulo(getAliquotaIcms())) { |
||
| 1185 | if (getTributacao().getSujeitoST()) { |
||
| 1186 | setAliquotaIcmsST(getTributacao().mvaPorIcms(getAliquotaIcms())); |
||
| 1187 | setAliquotaFecoep(getTributacao().getAliquotaFecoep()); |
||
| 1188 | setSujeitoST(true); |
||
| 1189 | } else { |
||
| 1190 | setAliquotaFecoep(null); |
||
| 1191 | setAliquotaIcmsST(null); |
||
| 1192 | setSujeitoST(false); |
||
| 1193 | } |
||
| 1194 | } |
||
| 1195 | } |
||
| 1196 | |||
| 1197 | @Transient |
||
| 1198 | public Double calculoIPI() { |
||
| 1199 | return (VerificadorUtil.naoEstaNulo(getAliquotaIPI()) && |
||
| 1200 | VerificadorUtil.naoEstaNulo(getValorCompra()))? |
||
| 1201 | getAliquotaIPI()/100 * getValorCompra() : 0.0; |
||
| 1202 | } |
||
| 1203 | |||
| 1204 | @Transient |
||
| 1205 | public Double calculoICMS() { |
||
| 1206 | return (VerificadorUtil.naoEstaNulo(getAliquotaIcms()) && |
||
| 1207 | VerificadorUtil.naoEstaNulo(getAliquotaFecoep()) && |
||
| 1208 | VerificadorUtil.naoEstaNulo(getValorCompra()))? |
||
| 1209 | (getAliquotaIcms()/100 + getAliquotaFecoep()/100) * getValorCompra() : 0.0; |
||
| 1210 | } |
||
| 1211 | |||
| 1212 | @Transient |
||
| 1213 | public Double calculoICMSST() { |
||
| 1214 | if (getSujeitoST()) { |
||
| 1215 | return VerificadorUtil.naoEstaNulo(getAliquotaIcmsST()) |
||
| 1216 | && VerificadorUtil.naoEstaNulo(getAliquotaFecoep()) |
||
| 1217 | && VerificadorUtil.naoEstaNulo(getTributacao())? |
||
| 1218 | ((getTributacao().getAliquotaInterna()/100 + getAliquotaFecoep()/100) * baseCalculoICMSST()) - calculoICMS(): 0.0; |
||
| 1219 | } |
||
| 1220 | return 0.0; |
||
| 1221 | } |
||
| 1222 | |||
| 1223 | @Transient |
||
| 1224 | public Double baseCalculoICMSST() { |
||
| 1225 | if (getSujeitoST()) { |
||
| 1226 | if (VerificadorUtil.naoEstaNulo(getTributacao())) { |
||
| 1227 | Double baseCalculoIPI = getValorCompra() + calculoIPI(); |
||
| 1228 | return baseCalculoIPI + (baseCalculoIPI * getTributacao().mvaPorIcms(getAliquotaIcms())/100); |
||
| 1229 | } |
||
| 1230 | } |
||
| 1231 | return 0.0; |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | @Transient |
||
| 1235 | public Double aliquotaMvaProduto() { |
||
| 1236 | return VerificadorUtil.naoEstaNulo(getTributacao())? getTributacao().mvaPorIcms(getAliquotaIcms()) : 0.0; |
||
| 1237 | } |
||
| 1238 | |||
| 1239 | @Transient |
||
| 1240 | public Double calculoTributosCompra() { |
||
| 1241 | return VerificadorUtil.naoEstaNulo(getValorCompra())? getValorCompra() + calculoIPI() + calculoICMSST() : 0.0; |
||
| 1242 | } |
||
| 1243 | /* |
||
| 1244 | @Transient |
||
| 1245 | public Double calculoOperacao() { |
||
| 1246 | Double aliquota = ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_SIMPLES_NACIONAL_11 + |
||
| 1247 | ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_COMISSOES_2 + |
||
| 1248 | ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_CARTAO_2; |
||
| 1249 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? calculoTributosCompra() + (getValorVarejoSimulacao()*aliquota/100) : 0.0; |
||
| 1250 | } |
||
| 1251 | |||
| 1252 | @Transient |
||
| 1253 | public String valorCalculoOperacao() { |
||
| 1254 | return StringUtil.formatarValor(calculoOperacao()); |
||
| 1255 | } |
||
| 1256 | |||
| 1257 | @Transient |
||
| 1258 | public Double calculoValorAposCustos() { |
||
| 1259 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? getValorVarejoSimulacao() - calculoOperacao() : 0.0; |
||
| 1260 | } |
||
| 1261 | |||
| 1262 | @Transient |
||
| 1263 | public Double calculoMargemAposCustos() { |
||
| 1264 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? calculoValorAposCustos() * 100 / calculoOperacao() : 0.0; |
||
| 1265 | } |
||
| 1266 | |||
| 1267 | @Transient |
||
| 1268 | public String retornarLucroBrutoFormatado() { |
||
| 1269 | return StringUtil.formatarPercentual(calculoValorAposCustos()); |
||
| 1270 | } |
||
| 1271 | |||
| 1272 | @Transient |
||
| 1273 | public String retornarMargemBrutaFormatada() { |
||
| 1274 | try { |
||
| 1275 | return StringUtil.formatarValorComDigitos(calculoMargemAposCustos().toString(), 2); |
||
| 1276 | } catch (Exception e) { |
||
| 1277 | e.printStackTrace(); |
||
| 1278 | } |
||
| 1279 | return ""; |
||
| 1280 | } |
||
| 1281 | |||
| 1282 | @Transient |
||
| 1283 | public Double calculoPrecoMinimo() { |
||
| 1284 | Double valorVarejoSimulacao = getValorVarejoSimulacao(); |
||
| 1285 | setValorVarejoSimulacao(this.getValorCompra()); |
||
| 1286 | Double valorMinimo = this.calculoOperacao(); |
||
| 1287 | Double margem = 0.0; |
||
| 1288 | valorMinimo = valorMinimo + (valorMinimo / 100); |
||
| 1289 | if (valorMinimo > 0.0) { |
||
| 1290 | while (margem < 15.0) { |
||
| 1291 | valorMinimo = valorMinimo + (valorMinimo / 100); |
||
| 1292 | setValorVarejoSimulacao(valorMinimo); |
||
| 1293 | margem = calculoMargemAposCustos(); |
||
| 1294 | } |
||
| 1295 | } |
||
| 1296 | setValorVarejoSimulacao(valorVarejoSimulacao); |
||
| 1297 | return valorMinimo; |
||
| 1298 | } |
||
| 1299 | */ |
||
| 1300 | } |