Subversion Repositories Integrator Subversion

Rev

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