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.GeneratedValue; |
||
| 8 | import javax.persistence.GenerationType; |
||
| 9 | import javax.persistence.Id; |
||
| 10 | import javax.persistence.SequenceGenerator; |
||
| 11 | import javax.persistence.Table; |
||
| 12 | import javax.persistence.Transient; |
||
| 13 | import javax.validation.constraints.Size; |
||
| 14 | |||
| 15 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 16 | |||
| 17 | import br.com.ec.core.interfaces.Alterar; |
||
| 18 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 19 | import br.com.ec.core.util.StringUtil; |
||
| 20 | import br.com.ec.core.util.VerificadorUtil; |
||
| 21 | |||
| 22 | @Entity |
||
| 23 | @Table(name="sec_tributacao", schema="sc_sec") |
||
| 24 | public class Tributacao implements Serializable { |
||
| 25 | |||
| 26 | private static final long serialVersionUID = 1L; |
||
| 27 | |||
| 28 | private Long sequencial; |
||
| 29 | private String descricao; |
||
| 30 | private String codigoNCM; |
||
| 31 | private String codigoEST; |
||
| 32 | private Boolean ativo; |
||
| 33 | |||
| 34 | private Boolean sujeitoST; |
||
| 35 | |||
| 36 | private Double mvaOriginal; |
||
| 37 | private Double mvaAjustada_4; |
||
| 38 | private Double mvaAjustada_7; |
||
| 39 | private Double mvaAjustada_12; |
||
| 40 | private Double aliquotaInterna; |
||
| 41 | private Double aliquotaFecoep; |
||
| 42 | private Double aliquotaIPI; |
||
| 43 | |||
| 44 | @Id |
||
| 45 | @SequenceGenerator(name = "sq_tributacao") |
||
| 46 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 47 | @Column(name="seq_tributacao", nullable=false) |
||
| 48 | public Long getSequencial() { |
||
| 49 | return sequencial; |
||
| 50 | } |
||
| 51 | public void setSequencial(Long sequencial) { |
||
| 52 | this.sequencial = sequencial; |
||
| 53 | } |
||
| 54 | |||
| 55 | @Column(name="dsc_tributacao") |
||
| 56 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 57 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 58 | public String getDescricao() { |
||
| 59 | return descricao; |
||
| 60 | } |
||
| 61 | public void setDescricao(String descricao) { |
||
| 62 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 63 | } |
||
| 64 | |||
| 65 | @Column(name="cod_ncm") |
||
| 66 | @Size(max = 8, message = "Limite de caracteres ultrapassado: Código NCM") |
||
| 67 | @NotEmpty(message="Obrigatório informar o NCM", groups={Cadastrar.class, Alterar.class}) |
||
| 68 | public String getCodigoNCM() { |
||
| 69 | return codigoNCM; |
||
| 70 | } |
||
| 71 | public void setCodigoNCM(String codigoNCM) { |
||
| 72 | this.codigoNCM = codigoNCM; |
||
| 73 | } |
||
| 74 | |||
| 75 | @Column(name="cod_est") |
||
| 76 | @Size(max = 8, message = "Limite de caracteres ultrapassado: Código EST") |
||
| 77 | public String getCodigoEST() { |
||
| 78 | return codigoEST; |
||
| 79 | } |
||
| 80 | public void setCodigoEST(String codigoEST) { |
||
| 81 | this.codigoEST = codigoEST; |
||
| 82 | } |
||
| 83 | |||
| 84 | @Column(name="ind_sujeito_st") |
||
| 85 | public Boolean getSujeitoST() { |
||
| 86 | return sujeitoST; |
||
| 87 | } |
||
| 88 | public void setSujeitoST(Boolean sujeitoST) { |
||
| 89 | this.sujeitoST = sujeitoST; |
||
| 90 | } |
||
| 91 | |||
| 92 | @Column(name="val_mvaoriginal") |
||
| 93 | public Double getMvaOriginal() { |
||
| 94 | return mvaOriginal; |
||
| 95 | } |
||
| 96 | public void setMvaOriginal(Double mvaOriginal) { |
||
| 97 | this.mvaOriginal = mvaOriginal; |
||
| 98 | } |
||
| 99 | |||
| 100 | @Column(name="val_mvaajustada_4") |
||
| 101 | public Double getMvaAjustada_4() { |
||
| 102 | return mvaAjustada_4; |
||
| 103 | } |
||
| 104 | public void setMvaAjustada_4(Double mvaAjustada_4) { |
||
| 105 | this.mvaAjustada_4 = mvaAjustada_4; |
||
| 106 | } |
||
| 107 | |||
| 108 | @Column(name="val_mvaajustada_7") |
||
| 109 | public Double getMvaAjustada_7() { |
||
| 110 | return mvaAjustada_7; |
||
| 111 | } |
||
| 112 | public void setMvaAjustada_7(Double mvaAjustada_7) { |
||
| 113 | this.mvaAjustada_7 = mvaAjustada_7; |
||
| 114 | } |
||
| 115 | |||
| 116 | @Column(name="val_mvaajustada_12") |
||
| 117 | public Double getMvaAjustada_12() { |
||
| 118 | return mvaAjustada_12; |
||
| 119 | } |
||
| 120 | public void setMvaAjustada_12(Double mvaAjustada_12) { |
||
| 121 | this.mvaAjustada_12 = mvaAjustada_12; |
||
| 122 | } |
||
| 123 | |||
| 124 | @Column(name="val_aliquota_interna") |
||
| 125 | public Double getAliquotaInterna() { |
||
| 126 | return aliquotaInterna; |
||
| 127 | } |
||
| 128 | public void setAliquotaInterna(Double aliquotaInterna) { |
||
| 129 | this.aliquotaInterna = aliquotaInterna; |
||
| 130 | } |
||
| 131 | |||
| 132 | @Column(name="val_aliquota_fecoep") |
||
| 133 | public Double getAliquotaFecoep() { |
||
| 134 | return aliquotaFecoep; |
||
| 135 | } |
||
| 136 | public void setAliquotaFecoep(Double aliquotaFecoep) { |
||
| 137 | this.aliquotaFecoep = aliquotaFecoep; |
||
| 138 | } |
||
| 139 | |||
| 140 | @Column(name="val_aliquota_ipi") |
||
| 141 | public Double getAliquotaIPI() { |
||
| 142 | return aliquotaIPI; |
||
| 143 | } |
||
| 144 | public void setAliquotaIPI(Double aliquotaIPI) { |
||
| 145 | this.aliquotaIPI = aliquotaIPI; |
||
| 146 | } |
||
| 147 | |||
| 148 | @Column(name="ind_ativo") |
||
| 149 | public Boolean getAtivo() { |
||
| 150 | return ativo; |
||
| 151 | } |
||
| 152 | public void setAtivo(Boolean ativo) { |
||
| 153 | this.ativo = ativo; |
||
| 154 | } |
||
| 155 | |||
| 156 | @Transient |
||
| 157 | public Double mvaPorIcms(String icms) { |
||
| 158 | if (icms.equals("4")) { |
||
| 159 | return getMvaAjustada_4(); |
||
| 160 | } |
||
| 161 | if (icms.equals("7")) { |
||
| 162 | return getMvaAjustada_7(); |
||
| 163 | } |
||
| 164 | if (icms.equals("12")) { |
||
| 165 | return getMvaAjustada_12(); |
||
| 166 | } |
||
| 167 | return 0.0; |
||
| 168 | } |
||
| 169 | |||
| 170 | @Transient |
||
| 171 | public Double mvaPorIcms(Double icms) { |
||
| 172 | if (VerificadorUtil.naoEstaNulo(icms)) { |
||
| 173 | if (icms.equals(4.0)) { |
||
| 174 | return retornarValorMva(getMvaAjustada_4()); |
||
| 175 | } |
||
| 176 | if (icms.equals(7.0)) { |
||
| 177 | return retornarValorMva(getMvaAjustada_7()); |
||
| 178 | } |
||
| 179 | if (icms.equals(12.0)) { |
||
| 180 | return retornarValorMva(getMvaAjustada_12()); |
||
| 181 | } |
||
| 182 | } |
||
| 183 | return 0.0; |
||
| 184 | } |
||
| 185 | |||
| 186 | @Transient |
||
| 187 | public Double retornarValorMva(Double mva) { |
||
| 188 | return VerificadorUtil.naoEstaNulo(mva)? mva : 0.0; |
||
| 189 | } |
||
| 190 | |||
| 191 | @Override |
||
| 192 | public int hashCode() { |
||
| 193 | final int prime = 31; |
||
| 194 | int result = 1; |
||
| 195 | result = prime * result |
||
| 196 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 197 | return result; |
||
| 198 | } |
||
| 199 | |||
| 200 | @Override |
||
| 201 | public boolean equals(Object obj) { |
||
| 202 | if (this == obj) |
||
| 203 | return true; |
||
| 204 | if (obj == null) |
||
| 205 | return false; |
||
| 206 | if (getClass() != obj.getClass()) |
||
| 207 | return false; |
||
| 208 | Tributacao other = (Tributacao) obj; |
||
| 209 | if (sequencial == null) { |
||
| 210 | if (other.sequencial != null) |
||
| 211 | return false; |
||
| 212 | } else if (!sequencial.equals(other.sequencial)) |
||
| 213 | return false; |
||
| 214 | return true; |
||
| 215 | } |
||
| 216 | |||
| 217 | } |