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