Rev 375 | Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 296 | 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 | |||
| 18 | import org.hibernate.annotations.ForeignKey; |
||
| 19 | |||
| 20 | import br.com.ec.core.interfaces.Alterar; |
||
| 21 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 22 | import br.com.ec.domain.model.tipos.TipoExtratoBanco; |
||
| 23 | |||
| 24 | @Entity |
||
| 25 | @Table(name="sec_extrato_banco", schema="sc_sec") |
||
| 26 | public class ExtratoBanco implements Serializable { |
||
| 27 | |||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | private static final long CONTA_CAIXA = 1L; |
||
| 30 | |||
| 31 | private Long sequencial; |
||
| 32 | private ContaBancaria contaBancaria; |
||
| 33 | private String tipoExtratoBanco; // D - Débitos e C - Créditos |
||
| 34 | private Date dataLancamento; |
||
| 35 | private Double valorTotal; |
||
| 36 | private String observacao; |
||
| 37 | |||
| 38 | public ExtratoBanco() {} |
||
| 39 | |||
| 40 | public ExtratoBanco(Long sequencial) { |
||
| 41 | this.sequencial = sequencial; |
||
| 42 | } |
||
| 43 | |||
| 44 | @Id |
||
| 45 | @SequenceGenerator(name = "sq_extratobanco") |
||
| 46 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 47 | @Column(name="seq_extrato_banco", nullable=false) |
||
| 48 | public Long getSequencial() { |
||
| 49 | return sequencial; |
||
| 50 | } |
||
| 51 | public void setSequencial(Long sequencial) { |
||
| 52 | this.sequencial = sequencial; |
||
| 53 | } |
||
| 54 | |||
| 55 | @ManyToOne |
||
| 56 | @ForeignKey(name="fk_extratobanco_contabancaria") |
||
| 57 | @JoinColumn(name = "seq_conta_bancaria", nullable=false) |
||
| 58 | @NotNull(message="Obrigatório informar a conta bancária", groups={Cadastrar.class, Alterar.class}) |
||
| 59 | public ContaBancaria getContaBancaria() { |
||
| 60 | return contaBancaria; |
||
| 61 | } |
||
| 62 | public void setContaBancaria(ContaBancaria contaBancaria) { |
||
| 63 | this.contaBancaria = contaBancaria; |
||
| 64 | } |
||
| 65 | |||
| 66 | @Column(name="tip_extrato_banco", nullable=false) |
||
| 67 | @NotNull(message="Obrigatório informar o tipo do extrato", groups={Cadastrar.class, Alterar.class}) |
||
| 68 | public String getTipoExtratoBanco() { |
||
| 69 | return tipoExtratoBanco; |
||
| 70 | } |
||
| 71 | public void setTipoExtratoBanco(String tipoExtratoBanco) { |
||
| 72 | this.tipoExtratoBanco = tipoExtratoBanco; |
||
| 73 | } |
||
| 74 | |||
| 75 | @Column(name="dat_lancamento", nullable=false) |
||
| 76 | @NotNull(message="Obrigatório informar a data do lançamento", groups={Cadastrar.class, Alterar.class}) |
||
| 77 | public Date getDataLancamento() { |
||
| 78 | return dataLancamento; |
||
| 79 | } |
||
| 80 | public void setDataLancamento(Date dataLancamento) { |
||
| 81 | this.dataLancamento = dataLancamento; |
||
| 82 | } |
||
| 83 | |||
| 84 | @Column(name="dsc_observacao") |
||
| 85 | public String getObservacao() { |
||
| 86 | return observacao; |
||
| 87 | } |
||
| 88 | public void setObservacao(String observacao) { |
||
| 89 | this.observacao = observacao; |
||
| 90 | } |
||
| 91 | |||
| 92 | @Transient |
||
| 93 | public String getTipoExtratoBancoDescricao() { |
||
| 94 | return TipoExtratoBanco.parse(getTipoExtratoBanco()).getDescricao(); |
||
| 95 | } |
||
| 96 | |||
| 97 | @Column(name="val_total", nullable=false) |
||
| 98 | @NotNull(message="Obrigatório informar o valor total do extrato", groups={Cadastrar.class, Alterar.class}) |
||
| 99 | public Double getValorTotal() { |
||
| 100 | return valorTotal; |
||
| 101 | } |
||
| 102 | public void setValorTotal(Double valorTotal) { |
||
| 103 | this.valorTotal = valorTotal; |
||
| 104 | } |
||
| 105 | |||
| 106 | @Transient |
||
| 107 | public static long getContaCaixa() { |
||
| 108 | return CONTA_CAIXA; |
||
| 109 | } |
||
| 110 | |||
| 111 | @Override |
||
| 112 | public int hashCode() { |
||
| 113 | final int prime = 31; |
||
| 114 | int result = 1; |
||
| 115 | result = prime * result |
||
| 116 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 117 | return result; |
||
| 118 | } |
||
| 119 | |||
| 120 | @Override |
||
| 121 | public boolean equals(Object obj) { |
||
| 122 | if (this == obj) |
||
| 123 | return true; |
||
| 124 | if (obj == null) |
||
| 125 | return false; |
||
| 126 | if (getClass() != obj.getClass()) |
||
| 127 | return false; |
||
| 128 | ExtratoBanco other = (ExtratoBanco) obj; |
||
| 129 | if (sequencial == null) { |
||
| 130 | if (other.sequencial != null) |
||
| 131 | return false; |
||
| 132 | } else if (!sequencial.equals(other.sequencial)) |
||
| 133 | return false; |
||
| 134 | return true; |
||
| 135 | } |
||
| 136 | |||
| 137 | } |