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_venda_formapagament", schema="sc_sec") |
||
| 22 | public class VendaFormaPagamento implements Serializable { |
||
| 23 | |||
| 24 | private static final long serialVersionUID = 1L; |
||
| 25 | |||
| 26 | private Long sequencial; |
||
| 27 | |||
| 28 | private Venda venda; |
||
| 29 | private FormaPagamento formaPagamento; |
||
| 30 | private BandeiraCartao bandeiraCartao; |
||
| 31 | private Cupom cupom; |
||
| 32 | private Double valorPagamento; |
||
| 33 | |||
| 34 | public VendaFormaPagamento() {} |
||
| 35 | |||
| 36 | public VendaFormaPagamento(FormaPagamento formaPagamento) { |
||
| 37 | this.formaPagamento = formaPagamento; |
||
| 38 | } |
||
| 39 | |||
| 40 | public VendaFormaPagamento(Venda venda, FormaPagamento formaPagamento) { |
||
| 41 | this.venda = venda; |
||
| 42 | this.formaPagamento = formaPagamento; |
||
| 43 | } |
||
| 44 | |||
| 45 | public VendaFormaPagamento(Venda venda, FormaPagamento formaPagamento, BandeiraCartao bandeiraCartao) { |
||
| 46 | this.venda = venda; |
||
| 47 | this.formaPagamento = formaPagamento; |
||
| 48 | this.bandeiraCartao = bandeiraCartao; |
||
| 49 | } |
||
| 50 | |||
| 51 | @Id |
||
| 52 | @SequenceGenerator(name = "sq_vendaformapagament") |
||
| 53 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 54 | @Column(name="seq_vendaformapagament", nullable=false) |
||
| 55 | public Long getSequencial() { |
||
| 56 | return sequencial; |
||
| 57 | } |
||
| 58 | public void setSequencial(Long sequencial) { |
||
| 59 | this.sequencial = sequencial; |
||
| 60 | } |
||
| 61 | |||
| 62 | @ManyToOne |
||
| 63 | @ForeignKey(name="fk_vendaformapag_venda") |
||
| 64 | @JoinColumn(name = "seq_venda", nullable=false) |
||
| 65 | public Venda getVenda() { |
||
| 66 | return venda; |
||
| 67 | } |
||
| 68 | public void setVenda(Venda venda) { |
||
| 69 | this.venda = venda; |
||
| 70 | } |
||
| 71 | |||
| 72 | @ManyToOne |
||
| 73 | @ForeignKey(name="fk_vendaformapag_formapagament") |
||
| 74 | @JoinColumn(name = "cod_formapagament", nullable=false) |
||
| 75 | public FormaPagamento getFormaPagamento() { |
||
| 76 | return formaPagamento; |
||
| 77 | } |
||
| 78 | public void setFormaPagamento(FormaPagamento formaPagamento) { |
||
| 79 | this.formaPagamento = formaPagamento; |
||
| 80 | } |
||
| 81 | |||
| 82 | @ManyToOne |
||
| 83 | @ForeignKey(name="fk_vendaformapag_bandeiracartao") |
||
| 84 | @JoinColumn(name = "cod_bandeira_cartao", nullable=false) |
||
| 85 | public BandeiraCartao getBandeiraCartao() { |
||
| 86 | return bandeiraCartao; |
||
| 87 | } |
||
| 88 | public void setBandeiraCartao(BandeiraCartao bandeiraCartao) { |
||
| 89 | this.bandeiraCartao = bandeiraCartao; |
||
| 90 | } |
||
| 91 | |||
| 92 | @ManyToOne |
||
| 93 | @ForeignKey(name="fk_vendaformapag_cupom") |
||
| 94 | @JoinColumn(name = "seq_cupom", nullable=false) |
||
| 95 | public Cupom getCupom() { |
||
| 96 | return cupom; |
||
| 97 | } |
||
| 98 | public void setCupom(Cupom cupom) { |
||
| 99 | this.cupom = cupom; |
||
| 100 | } |
||
| 101 | |||
| 102 | @Column(name="val_pagamento", nullable=false) |
||
| 103 | public Double getValorPagamento() { |
||
| 104 | return valorPagamento; |
||
| 105 | } |
||
| 106 | public void setValorPagamento(Double valorPagamento) { |
||
| 107 | this.valorPagamento = valorPagamento; |
||
| 108 | } |
||
| 109 | |||
| 110 | @Transient |
||
| 111 | public Long getSequencialDaVenda() { |
||
| 112 | return VerificadorUtil.naoEstaNulo(getVenda())? getVenda().getSequencial() : null; |
||
| 113 | } |
||
| 114 | |||
| 115 | @Transient |
||
| 116 | public Long getCodigoDaFormaPagamento() { |
||
| 117 | return VerificadorUtil.naoEstaNulo(getFormaPagamento())? getFormaPagamento().getCodigo() : null; |
||
| 118 | } |
||
| 119 | |||
| 120 | @Transient |
||
| 121 | public Long getCodigoDaBandeiraCartao() { |
||
| 122 | return VerificadorUtil.naoEstaNulo(getBandeiraCartao())? getBandeiraCartao().getCodigo() : null; |
||
| 123 | } |
||
| 124 | |||
| 125 | @Transient |
||
| 126 | public String getDescricaoDaBandeiraCartao() { |
||
| 127 | return VerificadorUtil.naoEstaNulo(getBandeiraCartao())? getBandeiraCartao().getDescricao() : null; |
||
| 128 | } |
||
| 129 | |||
| 130 | @Transient |
||
| 131 | public EmpresaAdquirente getEmpresaAdquirenteDaMaquinetaDaVenda() { |
||
| 132 | return VerificadorUtil.naoEstaNulo(getVenda().getMaquineta()) ? getVenda().getMaquineta().getEmpresaAdquirente() : null; |
||
| 133 | } |
||
| 134 | |||
| 135 | @Override |
||
| 136 | public int hashCode() { |
||
| 137 | final int prime = 31; |
||
| 138 | int result = 1; |
||
| 139 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 140 | return result; |
||
| 141 | } |
||
| 142 | |||
| 143 | @Override |
||
| 144 | public boolean equals(Object obj) { |
||
| 145 | if (this == obj) |
||
| 146 | return true; |
||
| 147 | if (obj == null) |
||
| 148 | return false; |
||
| 149 | if (getClass() != obj.getClass()) |
||
| 150 | return false; |
||
| 151 | VendaFormaPagamento other = (VendaFormaPagamento) obj; |
||
| 152 | if (sequencial == null) { |
||
| 153 | if (other.sequencial != null) |
||
| 154 | return false; |
||
| 155 | } else if (!sequencial.equals(other.sequencial)) |
||
| 156 | return false; |
||
| 157 | return true; |
||
| 158 | } |
||
| 159 | |||
| 160 | } |