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