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