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