Rev 296 | Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 259 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | |||
| 5 | import javax.persistence.Column; |
||
| 6 | import javax.persistence.Entity; |
||
| 7 | import javax.persistence.Id; |
||
| 8 | import javax.persistence.Table; |
||
| 9 | import javax.persistence.Transient; |
||
| 10 | import javax.validation.constraints.Size; |
||
| 11 | |||
| 12 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 13 | |||
| 14 | import br.com.ec.core.interfaces.Alterar; |
||
| 15 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 16 | import br.com.ec.core.util.StringUtil; |
||
| 17 | import br.com.ec.core.util.VerificadorUtil; |
||
| 18 | import br.com.ec.domain.shared.ConstantesSEC; |
||
| 19 | |||
| 20 | @Entity |
||
| 21 | @Table(name="sec_dre", schema="sc_sec") |
||
| 22 | public class IndicadorDRE implements Serializable, Cloneable { |
||
| 23 | |||
| 24 | private static final long serialVersionUID = 1L; |
||
| 25 | |||
| 26 | private Long codigo; |
||
| 27 | private String descricao; |
||
| 28 | private Integer numeroOrdem; |
||
| 29 | private Boolean ativo; |
||
| 30 | |||
| 31 | private Double valorTotal; |
||
| 32 | private Double margem; |
||
| 33 | private String observacao; |
||
| 34 | |||
| 35 | @Id |
||
| 36 | @Column(name="cod_dre", nullable=false) |
||
| 37 | public Long getCodigo() { |
||
| 38 | return codigo; |
||
| 39 | } |
||
| 40 | public void setCodigo(Long codigo) { |
||
| 41 | this.codigo = codigo; |
||
| 42 | } |
||
| 43 | |||
| 44 | @Column(name="dsc_dre") |
||
| 45 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 46 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 47 | public String getDescricao() { |
||
| 48 | return descricao; |
||
| 49 | } |
||
| 50 | public void setDescricao(String descricao) { |
||
| 51 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 52 | } |
||
| 53 | |||
| 54 | @Column(name="num_ordem") |
||
| 55 | public Integer getNumeroOrdem() { |
||
| 56 | return numeroOrdem; |
||
| 57 | } |
||
| 58 | public void setNumeroOrdem(Integer numeroOrdem) { |
||
| 59 | this.numeroOrdem = numeroOrdem; |
||
| 60 | } |
||
| 61 | |||
| 62 | @Column(name="ind_ativo", nullable=false) |
||
| 63 | public Boolean getAtivo() { |
||
| 64 | return ativo; |
||
| 65 | } |
||
| 66 | public void setAtivo(Boolean ativo) { |
||
| 67 | this.ativo = ativo; |
||
| 68 | } |
||
| 69 | |||
| 70 | @Transient |
||
| 71 | public Double getValorTotal() { |
||
| 72 | return valorTotal; |
||
| 73 | } |
||
| 74 | public void setValorTotal(Double valorTotal) { |
||
| 75 | this.valorTotal = valorTotal; |
||
| 76 | } |
||
| 77 | |||
| 78 | @Transient |
||
| 79 | public Double getMargem() { |
||
| 80 | return margem; |
||
| 81 | } |
||
| 82 | public void setMargem(Double margem) { |
||
| 83 | this.margem = margem; |
||
| 84 | } |
||
| 85 | |||
| 86 | @Transient |
||
| 87 | public String getObservacao() { |
||
| 88 | return observacao; |
||
| 89 | } |
||
| 90 | public void setObservacao(String observacao) { |
||
| 91 | this.observacao = observacao; |
||
| 92 | } |
||
| 93 | |||
| 94 | @Override |
||
| 95 | public int hashCode() { |
||
| 96 | final int prime = 31; |
||
| 97 | int result = 1; |
||
| 98 | result = prime * result |
||
| 99 | + ((codigo == null) ? 0 : codigo.hashCode()); |
||
| 100 | return result; |
||
| 101 | } |
||
| 102 | |||
| 103 | @Override |
||
| 104 | public boolean equals(Object obj) { |
||
| 105 | if (this == obj) |
||
| 106 | return true; |
||
| 107 | if (obj == null) |
||
| 108 | return false; |
||
| 109 | if (getClass() != obj.getClass()) |
||
| 110 | return false; |
||
| 111 | IndicadorDRE other = (IndicadorDRE) obj; |
||
| 112 | if (codigo == null) { |
||
| 113 | if (other.codigo != null) |
||
| 114 | return false; |
||
| 115 | } else if (!codigo.equals(other.codigo)) |
||
| 116 | return false; |
||
| 117 | return true; |
||
| 118 | } |
||
| 119 | |||
| 120 | @Override |
||
| 121 | public IndicadorDRE clone() throws CloneNotSupportedException { |
||
| 122 | return (IndicadorDRE) super.clone(); |
||
| 123 | } |
||
| 124 | |||
| 125 | @Transient |
||
| 126 | public String corIndicador() { |
||
| 127 | if (VerificadorUtil.naoEstaNulo(getCodigo())) { |
||
| 128 | if (getCodigo().equals(ConstantesSEC.DRE.RECEITA_OPERACIONAL_BRUTA_1)) { |
||
| 129 | return "green"; |
||
| 130 | } else { |
||
| 131 | if (getValorTotal() >= 0.0) { |
||
| 132 | return "red"; |
||
| 133 | } else { |
||
| 134 | return "green"; |
||
| 135 | } |
||
| 136 | } |
||
| 137 | } else { |
||
| 138 | if (getValorTotal() >= 0.0) { |
||
| 139 | return "green"; |
||
| 140 | } else { |
||
| 141 | return "red"; |
||
| 142 | } |
||
| 143 | } |
||
| 144 | } |
||
| 145 | |||
| 146 | } |