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