Subversion Repositories Integrator Subversion

Rev

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
 
5
import javax.persistence.Column;
6
import javax.persistence.Entity;
7
import javax.persistence.GeneratedValue;
8
import javax.persistence.GenerationType;
9
import javax.persistence.Id;
10
import javax.persistence.JoinColumn;
11
import javax.persistence.ManyToOne;
12
import javax.persistence.SequenceGenerator;
13
import javax.persistence.Table;
14
import javax.persistence.Transient;
15
 
16
import org.hibernate.annotations.ForeignKey;
17
 
18
import br.com.ec.core.util.VerificadorUtil;
19
 
20
@Entity
21
@Table(name="sec_conta_forma_pagamento", schema="sc_sec")
22
public class ContaFormaPagamento implements Serializable {
23
 
24
        private static final long serialVersionUID = 1L;
25
 
26
        private Long sequencial;
27
 
28
        private FormaPagamento formaPagamento;
29
        private BandeiraCartao bandeiraCartao;
30
        private Double valorPagamento;
31
 
32
        public ContaFormaPagamento() {}
33
 
34
        public ContaFormaPagamento(FormaPagamento formaPagamento, BandeiraCartao bandeiraCartao) {  
35
        this.formaPagamento = formaPagamento;
36
        this.bandeiraCartao = bandeiraCartao;
37
    }
38
 
39
        public ContaFormaPagamento(VendaFormaPagamento vendaFormaPagamento) {  
40
        this.formaPagamento = vendaFormaPagamento.getFormaPagamento();
41
        this.bandeiraCartao = vendaFormaPagamento.getBandeiraCartao();
42
        this.valorPagamento = vendaFormaPagamento.getValorPagamento();
43
    }
44
 
45
        @Id
46
        @SequenceGenerator(name = "sq_contaformapag")
47
        @GeneratedValue(strategy = GenerationType.IDENTITY)
48
        @Column(name="seq_conta_forma_pagamento", nullable=false)
49
        public Long getSequencial() {
50
                return sequencial;
51
        }
52
        public void setSequencial(Long sequencial) {
53
                this.sequencial = sequencial;
54
        }
55
 
56
        @ManyToOne
57
        @ForeignKey(name = "fk_contaformapag_formapagament")
58
        @JoinColumn(name="cod_formapagament", referencedColumnName="cod_formapagament", insertable=true, updatable=false)
59
        public FormaPagamento getFormaPagamento() {
60
                return formaPagamento;
61
        }
62
        public void setFormaPagamento(FormaPagamento formaPagamento) {
63
                this.formaPagamento = formaPagamento;
64
        }
65
 
66
        @ManyToOne
67
        @ForeignKey(name="fk_contaformapag_banderiacartao")
68
        @JoinColumn(name = "cod_bandeira_cartao", nullable=false)
69
        public BandeiraCartao getBandeiraCartao() {
70
                return bandeiraCartao;
71
        }
72
        public void setBandeiraCartao(BandeiraCartao bandeiraCartao) {
73
                this.bandeiraCartao = bandeiraCartao;
74
        }
75
 
76
        @Column(name="val_pagamento", nullable=false)
77
        public Double getValorPagamento() {
78
                return valorPagamento;
79
        }
80
        public void setValorPagamento(Double valorPagamento) {
81
                this.valorPagamento = valorPagamento;
82
        }
83
 
84
        @Override
85
        public int hashCode() {
86
                final int prime = 31;
87
                int result = 1;
88
                result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode());
89
                return result;
90
        }
91
 
92
        @Override
93
        public boolean equals(Object obj) {
94
                if (this == obj)
95
                        return true;
96
                if (obj == null)
97
                        return false;
98
                if (getClass() != obj.getClass())
99
                        return false;
100
                ContaFormaPagamento other = (ContaFormaPagamento) obj;
101
                if (sequencial == null) {
102
                        if (other.sequencial != null)
103
                                return false;
104
                } else if (!sequencial.equals(other.sequencial))
105
                        return false;
106
                return true;
107
        }
108
 
109
        @Transient
110
        public Long getCodigoDaFormaPagamento() {
111
                return VerificadorUtil.naoEstaNulo(getFormaPagamento())? getFormaPagamento().getCodigo() : null;
112
        }
113
 
114
        @Transient
115
        public Long getCodigoDaBandeiraCartao() {
116
                return VerificadorUtil.naoEstaNulo(getBandeiraCartao())? getBandeiraCartao().getCodigo() : null;
117
        }
118
 
119
        @Transient
120
        public Boolean formaDePagamentoEhDebito() {
121
                return VerificadorUtil.naoEstaNulo(getFormaPagamento())? getFormaPagamento().formaPagamentoEhDebito() : false;
122
        }
123
 
124
        @Transient
125
        public Boolean formaDePagamentoEhCredito() {
126
                return VerificadorUtil.naoEstaNulo(getFormaPagamento())? getFormaPagamento().formaPagamentoEhCredito() : false;
127
        }
128
 
129
}