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