Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 582 | blopes | 1 | package br.com.ec.domain.dto; |
| 2 | |||
| 3 | import br.com.ec.core.util.VerificadorUtil; |
||
| 4 | import br.com.ec.domain.model.Loja; |
||
| 5 | import br.com.ec.domain.model.Produto; |
||
| 6 | |||
| 7 | public class RankingProdutoPorLojaDTO implements Comparable<RankingProdutoPorLojaDTO> { |
||
| 8 | |||
| 9 | private Produto produto; |
||
| 10 | private Loja loja; |
||
| 11 | private Long quantidadeVendas; |
||
| 12 | private Long quantidadeEstoque; |
||
| 13 | |||
| 14 | private Integer quantidadeMinimaTransferir = 1; |
||
| 15 | private Long quantidadeSugeridaParaTransferir; |
||
| 16 | |||
| 17 | public RankingProdutoPorLojaDTO() {} |
||
| 18 | |||
| 19 | public RankingProdutoPorLojaDTO(Loja loja, Long quantidadeVendas, Long quantidadeEstoque) { |
||
| 20 | this.loja = loja; |
||
| 21 | this.quantidadeVendas = quantidadeVendas; |
||
| 22 | this.quantidadeEstoque = quantidadeEstoque; |
||
| 23 | } |
||
| 24 | |||
| 25 | public Produto getProduto() { |
||
| 26 | return produto; |
||
| 27 | } |
||
| 28 | public void setProduto(Produto produto) { |
||
| 29 | this.produto = produto; |
||
| 30 | } |
||
| 31 | |||
| 32 | public Loja getLoja() { |
||
| 33 | return loja; |
||
| 34 | } |
||
| 35 | public void setLoja(Loja loja) { |
||
| 36 | this.loja = loja; |
||
| 37 | } |
||
| 38 | |||
| 39 | public Long getQuantidadeVendas() { |
||
| 40 | return quantidadeVendas; |
||
| 41 | } |
||
| 42 | public void setQuantidadeVendas(Long quantidadeVendas) { |
||
| 43 | this.quantidadeVendas = quantidadeVendas; |
||
| 44 | } |
||
| 45 | |||
| 46 | public Long getQuantidadeEstoque() { |
||
| 47 | return quantidadeEstoque; |
||
| 48 | } |
||
| 49 | public void setQuantidadeEstoque(Long quantidadeEstoque) { |
||
| 50 | this.quantidadeEstoque = quantidadeEstoque; |
||
| 51 | } |
||
| 52 | |||
| 53 | public Integer getQuantidadeMinimaTransferir() { |
||
| 54 | return quantidadeMinimaTransferir; |
||
| 55 | } |
||
| 56 | public void setQuantidadeMinimaTransferir(Integer quantidadeMinimaTransferir) { |
||
| 57 | this.quantidadeMinimaTransferir = quantidadeMinimaTransferir; |
||
| 58 | } |
||
| 59 | |||
| 60 | public Long getQuantidadeSugeridaParaTransferir() { |
||
| 61 | return quantidadeSugeridaParaTransferir; |
||
| 62 | } |
||
| 63 | public void setQuantidadeSugeridaParaTransferir(Long quantidadeSugeridaParaTransferir) { |
||
| 64 | this.quantidadeSugeridaParaTransferir = quantidadeSugeridaParaTransferir; |
||
| 65 | } |
||
| 66 | |||
| 67 | public Integer quantidadeParaComprar(Integer quantidadeVendas, Integer quantidadeEstoque) { |
||
| 68 | return (getQuantidadeMinimaTransferir() * quantidadeVendas) - quantidadeEstoque; |
||
| 69 | } |
||
| 70 | |||
| 71 | public Integer quantidadeParaComprar(Integer quantidadeParaComprar, Integer quantidadeVendas, Integer quantidadeEstoque) { |
||
| 72 | return VerificadorUtil.naoEstaNulo(quantidadeParaComprar)? |
||
| 73 | (quantidadeParaComprar * quantidadeVendas) - quantidadeEstoque : quantidadeParaComprar(quantidadeVendas, quantidadeEstoque); |
||
| 74 | } |
||
| 75 | |||
| 76 | public Long quantidadeParaTransferir() { |
||
| 77 | if (VerificadorUtil.estaNulo(quantidadeVendas)) { |
||
| 78 | quantidadeVendas = new Long(0); |
||
| 79 | } |
||
| 80 | if (VerificadorUtil.estaNulo(quantidadeEstoque)) { |
||
| 81 | quantidadeEstoque = new Long(0); |
||
| 82 | } |
||
| 83 | return (quantidadeEstoque - quantidadeVendas) * getQuantidadeMinimaTransferir() * -1; |
||
| 84 | } |
||
| 85 | |||
| 86 | @Override |
||
| 87 | public int compareTo(RankingProdutoPorLojaDTO rankingProdutoDTO) { |
||
| 88 | return this.getLoja().getDescricao().compareTo(rankingProdutoDTO.getLoja().getDescricao()); |
||
| 89 | } |
||
| 90 | |||
| 91 | } |