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