Rev 182 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | |||
| 6 | import javax.persistence.Column; |
||
| 7 | import javax.persistence.Entity; |
||
| 8 | import javax.persistence.GeneratedValue; |
||
| 9 | import javax.persistence.GenerationType; |
||
| 10 | import javax.persistence.Id; |
||
| 11 | import javax.persistence.JoinColumn; |
||
| 12 | import javax.persistence.ManyToOne; |
||
| 13 | import javax.persistence.Table; |
||
| 14 | import javax.persistence.Transient; |
||
| 15 | import javax.validation.constraints.NotNull; |
||
| 16 | import javax.validation.constraints.Size; |
||
| 17 | |||
| 18 | import org.hibernate.annotations.ForeignKey; |
||
| 19 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 20 | |||
| 21 | import br.com.ec.domain.model.tipos.TipoEmitirNotaFiscal; |
||
| 22 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 23 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 24 | import br.edu.cesmac.core.util.StringUtil; |
||
| 25 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 26 | |||
| 27 | @Entity |
||
| 28 | @Table(name="sec_loja", schema="sc_sec") |
||
| 29 | public class Loja implements Serializable { |
||
| 30 | |||
| 31 | private static final long serialVersionUID = 1L; |
||
| 32 | |||
| 33 | private Long sequencial; |
||
| 34 | private Integer ordenador; |
||
| 35 | private Pessoa pessoaJuridica; |
||
| 36 | private String descricao; |
||
| 37 | private String dvr; |
||
| 38 | private Maquineta maquineta; |
||
| 39 | private String internet; |
||
| 40 | private Date dataAbertura; |
||
| 41 | private Date dataAberturaOficial; |
||
| 42 | private Date dataFechamento; |
||
| 43 | private Date dataFechamentoOficial; |
||
| 44 | private String tipoEmitirNotaFiscal; |
||
| 45 | private Double fundoCaixa; |
||
| 46 | private Boolean receberNotaFiscalRemessa; |
||
| 47 | private String descricaoCertificado; |
||
| 48 | private String senhaCertificado; |
||
| 49 | private String idToken; |
||
| 50 | private String cscToken; |
||
| 51 | private Integer limitadorProdutos; |
||
| 52 | private Boolean ativo; |
||
| 53 | |||
| 54 | private String colorComissao; |
||
| 55 | private Double metaMensal; |
||
| 56 | private Double metaDiariaLiquida; |
||
| 57 | private Double totalVendasNoMes; |
||
| 58 | |||
| 59 | public Loja() {} |
||
| 60 | |||
| 61 | public Loja(Long sequencial) { |
||
| 62 | this.sequencial = sequencial; |
||
| 63 | } |
||
| 64 | |||
| 65 | public Loja(Long sequencial, String descricao) { |
||
| 66 | this.sequencial = sequencial; |
||
| 67 | this.descricao = descricao; |
||
| 68 | } |
||
| 69 | |||
| 70 | @Id |
||
| 71 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 72 | @Column(name="seq_loja", nullable=false) |
||
| 73 | public Long getSequencial() { |
||
| 74 | return sequencial; |
||
| 75 | } |
||
| 76 | public void setSequencial(Long sequencial) { |
||
| 77 | this.sequencial = sequencial; |
||
| 78 | } |
||
| 79 | |||
| 80 | @Column(name="num_ordem") |
||
| 81 | public Integer getOrdenador() { |
||
| 82 | return ordenador; |
||
| 83 | } |
||
| 84 | public void setOrdenador(Integer ordenador) { |
||
| 85 | this.ordenador = ordenador; |
||
| 86 | } |
||
| 87 | |||
| 88 | @ManyToOne |
||
| 89 | @ForeignKey(name = "fk_loja_pessoa") |
||
| 90 | @JoinColumn(name="seq_pessoa", referencedColumnName="seq_pessoa", insertable=true, updatable=true) |
||
| 91 | public Pessoa getPessoaJuridica() { |
||
| 92 | return pessoaJuridica; |
||
| 93 | } |
||
| 94 | public void setPessoaJuridica(Pessoa pessoaJuridica) { |
||
| 95 | this.pessoaJuridica = pessoaJuridica; |
||
| 96 | } |
||
| 97 | |||
| 98 | @Column(name="dsc_loja") |
||
| 99 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição da Loja") |
||
| 100 | @NotNull(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 101 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 102 | public String getDescricao() { |
||
| 103 | return descricao; |
||
| 104 | } |
||
| 105 | public void setDescricao(String descricao) { |
||
| 106 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 107 | } |
||
| 108 | |||
| 109 | @Column(name="dsc_dvr") |
||
| 110 | @Size(max = 30, message = "Limite de caracteres ultrapassado: DVR") |
||
| 111 | public String getDvr() { |
||
| 112 | return dvr; |
||
| 113 | } |
||
| 114 | public void setDvr(String dvr) { |
||
| 115 | this.dvr = dvr; |
||
| 116 | } |
||
| 117 | |||
| 118 | @ManyToOne |
||
| 119 | @ForeignKey(name = "fk_loja_maquineta") |
||
| 120 | @JoinColumn(name="seq_maquineta", referencedColumnName="seq_maquineta", insertable=true, updatable=true) |
||
| 121 | public Maquineta getMaquineta() { |
||
| 122 | return maquineta; |
||
| 123 | } |
||
| 124 | public void setMaquineta(Maquineta maquineta) { |
||
| 125 | this.maquineta = maquineta; |
||
| 126 | } |
||
| 127 | |||
| 128 | @Column(name="dsc_internet") |
||
| 129 | @Size(max = 50, message = "Limite de caracteres ultrapassado: Descrição da Internet") |
||
| 130 | public String getInternet() { |
||
| 131 | return internet; |
||
| 132 | } |
||
| 133 | public void setInternet(String internet) { |
||
| 134 | this.internet = internet; |
||
| 135 | } |
||
| 136 | |||
| 137 | @Column(name="dat_abertura") |
||
| 138 | public Date getDataAbertura() { |
||
| 139 | return dataAbertura; |
||
| 140 | } |
||
| 141 | public void setDataAbertura(Date dataAbertura) { |
||
| 142 | this.dataAbertura = dataAbertura; |
||
| 143 | } |
||
| 144 | |||
| 145 | @Column(name="dat_abertura_oficial") |
||
| 146 | public Date getDataAberturaOficial() { |
||
| 147 | return dataAberturaOficial; |
||
| 148 | } |
||
| 149 | public void setDataAberturaOficial(Date dataAberturaOficial) { |
||
| 150 | this.dataAberturaOficial = dataAberturaOficial; |
||
| 151 | } |
||
| 152 | |||
| 153 | @Column(name="dat_fechamento") |
||
| 154 | public Date getDataFechamento() { |
||
| 155 | return dataFechamento; |
||
| 156 | } |
||
| 157 | public void setDataFechamento(Date dataFechamento) { |
||
| 158 | this.dataFechamento = dataFechamento; |
||
| 159 | } |
||
| 160 | |||
| 161 | @Column(name="dat_fechamento_oficial") |
||
| 162 | public Date getDataFechamentoOficial() { |
||
| 163 | return dataFechamentoOficial; |
||
| 164 | } |
||
| 165 | public void setDataFechamentoOficial(Date dataFechamentoOficial) { |
||
| 166 | this.dataFechamentoOficial = dataFechamentoOficial; |
||
| 167 | } |
||
| 168 | |||
| 169 | @Column(name="tip_emitir_nfe", nullable=false) |
||
| 170 | @NotNull(message="Obrigatório informar o tipo de emissão da nota fiscal", groups={Cadastrar.class, Alterar.class}) |
||
| 171 | public String getTipoEmitirNotaFiscal() { |
||
| 172 | return tipoEmitirNotaFiscal; |
||
| 173 | } |
||
| 174 | public void setTipoEmitirNotaFiscal(String tipoEmitirNotaFiscal) { |
||
| 175 | this.tipoEmitirNotaFiscal = tipoEmitirNotaFiscal; |
||
| 176 | } |
||
| 177 | @Transient |
||
| 178 | public String getDescricaoDoTipoEmitirNotaFiscal() { |
||
| 179 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoEmitirNotaFiscal())? TipoEmitirNotaFiscal.parse(getTipoEmitirNotaFiscal()).getDescricao() : null; |
||
| 180 | } |
||
| 181 | |||
| 182 | @Column(name="val_fundo_caixa") |
||
| 183 | public Double getFundoCaixa() { |
||
| 184 | return fundoCaixa; |
||
| 185 | } |
||
| 186 | public void setFundoCaixa(Double fundoCaixa) { |
||
| 187 | this.fundoCaixa = fundoCaixa; |
||
| 188 | } |
||
| 189 | |||
| 190 | @NotNull(message="Obrigatório informar se receberá NF Remessa", groups={Cadastrar.class, Alterar.class}) |
||
| 191 | @Column(name="ind_receber_nf_remessa", nullable=false) |
||
| 192 | public Boolean getReceberNotaFiscalRemessa() { |
||
| 193 | return receberNotaFiscalRemessa; |
||
| 194 | } |
||
| 195 | public void setReceberNotaFiscalRemessa(Boolean receberNotaFiscalRemessa) { |
||
| 196 | this.receberNotaFiscalRemessa = receberNotaFiscalRemessa; |
||
| 197 | } |
||
| 198 | |||
| 199 | @Column(name="dsc_certificado") |
||
| 200 | @Size(max = 50, message = "Limite de caracteres ultrapassado: Descrição do Certificado") |
||
| 201 | public String getDescricaoCertificado() { |
||
| 202 | return descricaoCertificado; |
||
| 203 | } |
||
| 204 | public void setDescricaoCertificado(String descricaoCertificado) { |
||
| 205 | this.descricaoCertificado = StringUtil.setarUpperCaseComTrim(descricaoCertificado); |
||
| 206 | } |
||
| 207 | |||
| 208 | @Column(name="dsc_senha_certificado") |
||
| 209 | @Size(max = 10, message = "Limite de caracteres ultrapassado: Senha do Certificado") |
||
| 210 | public String getSenhaCertificado() { |
||
| 211 | return senhaCertificado; |
||
| 212 | } |
||
| 213 | public void setSenhaCertificado(String senhaCertificado) { |
||
| 214 | this.senhaCertificado = senhaCertificado; |
||
| 215 | } |
||
| 216 | |||
| 217 | @Column(name="dsc_idtoken") |
||
| 218 | @Size(max = 10, message = "Limite de caracteres ultrapassado: Descrição do Token") |
||
| 219 | public String getIdToken() { |
||
| 220 | return idToken; |
||
| 221 | } |
||
| 222 | public void setIdToken(String idToken) { |
||
| 223 | this.idToken = StringUtil.setarUpperCaseComTrim(idToken); |
||
| 224 | } |
||
| 225 | |||
| 226 | @Column(name="dsc_csctoken") |
||
| 227 | @Size(max = 50, message = "Limite de caracteres ultrapassado: CSC do Token") |
||
| 228 | public String getCscToken() { |
||
| 229 | return cscToken; |
||
| 230 | } |
||
| 231 | public void setCscToken(String cscToken) { |
||
| 232 | this.cscToken = StringUtil.setarUpperCaseComTrim(cscToken); |
||
| 233 | } |
||
| 234 | |||
| 235 | @Column(name="qtd_limitador_produtos") |
||
| 236 | public Integer getLimitadorProdutos() { |
||
| 237 | return limitadorProdutos; |
||
| 238 | } |
||
| 239 | public void setLimitadorProdutos(Integer limitadorProdutos) { |
||
| 240 | this.limitadorProdutos = limitadorProdutos; |
||
| 241 | } |
||
| 242 | |||
| 243 | @Column(name="ind_ativo", nullable=false) |
||
| 244 | public Boolean getAtivo() { |
||
| 245 | return ativo; |
||
| 246 | } |
||
| 247 | public void setAtivo(Boolean ativo) { |
||
| 248 | this.ativo = ativo; |
||
| 249 | } |
||
| 250 | |||
| 251 | @Transient |
||
| 252 | public Double percentualRealizadoMetaMensal(Double valorTotalVendido, Double metaMensal) { |
||
| 253 | if (VerificadorUtil.naoEstaNulo(valorTotalVendido) && VerificadorUtil.naoEstaNulo(metaMensal)) { |
||
| 254 | if (metaMensal > new Double(0.0)) { |
||
| 255 | return valorTotalVendido / metaMensal; |
||
| 256 | } |
||
| 257 | } |
||
| 258 | return new Double (0.0); |
||
| 259 | } |
||
| 260 | |||
| 261 | @Transient |
||
| 262 | public String getColorComissao() { |
||
| 263 | return colorComissao; |
||
| 264 | } |
||
| 265 | public void setColorComissao(String colorComissao) { |
||
| 266 | this.colorComissao = colorComissao; |
||
| 267 | } |
||
| 268 | |||
| 269 | @Transient |
||
| 270 | public Double getMetaMensal() { |
||
| 271 | return metaMensal; |
||
| 272 | } |
||
| 273 | public void setMetaMensal(Double metaMensal) { |
||
| 274 | this.metaMensal = metaMensal; |
||
| 275 | } |
||
| 276 | |||
| 277 | @Transient |
||
| 278 | public Double getMetaDiariaLiquida() { |
||
| 279 | return metaDiariaLiquida; |
||
| 280 | } |
||
| 281 | public void setMetaDiariaLiquida(Double metaDiariaLiquida) { |
||
| 282 | this.metaDiariaLiquida = metaDiariaLiquida; |
||
| 283 | } |
||
| 284 | |||
| 285 | @Transient |
||
| 286 | public Double getTotalVendasNoMes() { |
||
| 287 | return totalVendasNoMes; |
||
| 288 | } |
||
| 289 | public void setTotalVendasNoMes(Double totalVendasNoMes) { |
||
| 290 | this.totalVendasNoMes = totalVendasNoMes; |
||
| 291 | } |
||
| 292 | |||
| 293 | @Override |
||
| 294 | public int hashCode() { |
||
| 295 | final int prime = 31; |
||
| 296 | int result = 1; |
||
| 297 | result = prime * result |
||
| 298 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 299 | return result; |
||
| 300 | } |
||
| 301 | |||
| 302 | @Override |
||
| 303 | public boolean equals(Object obj) { |
||
| 304 | if (this == obj) |
||
| 305 | return true; |
||
| 306 | if (obj == null) |
||
| 307 | return false; |
||
| 308 | if (getClass() != obj.getClass()) |
||
| 309 | return false; |
||
| 310 | Loja other = (Loja) obj; |
||
| 311 | if (sequencial == null) { |
||
| 312 | if (other.sequencial != null) |
||
| 313 | return false; |
||
| 314 | } else if (!sequencial.equals(other.sequencial)) |
||
| 315 | return false; |
||
| 316 | return true; |
||
| 317 | } |
||
| 318 | |||
| 319 | /* |
||
| 320 | @Transient |
||
| 321 | public Boolean emissaoNotaFiscalPermitida() { |
||
| 322 | if (this.getSequencial().equals(ConstantesSEC.SEQUENCIAL_LOJA_VIVO_4) || |
||
| 323 | this.getSequencial().equals(ConstantesSEC.SEQUENCIAL_LOJA_FARMACIA_7) || |
||
| 324 | this.getSequencial().equals(ConstantesSEC.SEQUENCIAL_ESTOQUE_9)) { |
||
| 325 | return false; |
||
| 326 | } |
||
| 327 | return true; |
||
| 328 | } |
||
| 329 | */ |
||
| 330 | |||
| 331 | @Transient |
||
| 332 | public Boolean emissaoNotaFiscalPermitida() { |
||
| 333 | return !TipoEmitirNotaFiscal.NAO_PERMITIR_EMISSAO.getValor().equals(getTipoEmitirNotaFiscal()); |
||
| 334 | } |
||
| 335 | |||
| 336 | @Transient |
||
| 337 | public Boolean emissaoNotaFiscalEletronica() { |
||
| 338 | return TipoEmitirNotaFiscal.EMITIR_NOTA_ELETRONICA.getValor().equals(getTipoEmitirNotaFiscal()); |
||
| 339 | } |
||
| 340 | |||
| 341 | @Transient |
||
| 342 | public String getDescricaoMaquineta() { |
||
| 343 | return VerificadorUtil.naoEstaNulo(getMaquineta()) ? getMaquineta().descricaoCompleta() : null; |
||
| 344 | } |
||
| 345 | |||
| 346 | } |