Subversion Repositories Integrator Subversion

Rev

Rev 106 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

package br.com.ec.domain.dto;

import java.util.Date;

import javax.persistence.Transient;

import br.com.ec.core.util.VerificadorUtil;
import br.com.ec.domain.model.BandeiraCartao;
import br.com.ec.domain.model.FormaPagamento;

public class CartaoBandeiraDTO implements Cloneable, Comparable<CartaoBandeiraDTO> {

        private Date data;
        private BandeiraCartao bandeira;
        private Double bruto;
        private Double brutoImportado;
        private Integer quantidade;
        private Integer quantidadeImportado;
        private FormaPagamento formaPagamento;
       
        public CartaoBandeiraDTO() {
                this.bruto = new Double(0.0);
                this.brutoImportado = new Double(0.0);
                this.quantidade = 0;
                this.quantidadeImportado = 0;
        }
       
        public Date getData() {
                return data;
        }
        public void setData(Date data) {
                this.data = data;
        }
       
        public BandeiraCartao getBandeira() {
                return bandeira;
        }
        public void setBandeira(BandeiraCartao bandeira) {
                this.bandeira = bandeira;
        }
       
        public Double getBruto() {
                return bruto;
        }
        public void setBruto(Double bruto) {
                this.bruto = bruto;
        }
       
        public Double getBrutoImportado() {
                return brutoImportado;
        }
        public void setBrutoImportado(Double brutoImportado) {
                this.brutoImportado = brutoImportado;
        }
       
        public Integer getQuantidade() {
                return quantidade;
        }
        public void setQuantidade(Integer quantidade) {
                this.quantidade = quantidade;
        }
       
        public Integer getQuantidadeImportado() {
                return quantidadeImportado;
        }
        public void setQuantidadeImportado(Integer quantidadeImportado) {
                this.quantidadeImportado = quantidadeImportado;
        }
       
        public FormaPagamento getFormaPagamento() {
                return formaPagamento;
        }
        public void setFormaPagamento(FormaPagamento formaPagamento) {
                this.formaPagamento = formaPagamento;
        }
       
        public Long getCodigoDaBandeira() {
                return VerificadorUtil.naoEstaNulo(bandeira)? bandeira.getCodigo() : null;
        }
       
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + ((data == null) ? 0 : data.hashCode());
                result = prime * result + ((bandeira == null) ? 0 : bandeira.hashCode());
                result = prime * result + ((formaPagamento == null) ? 0 : formaPagamento.hashCode());
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                CartaoBandeiraDTO other = (CartaoBandeiraDTO) obj;
                if (data == null) {
                        if (other.data != null)
                                return false;
                } else if (!data.equals(other.data))
                        return false;
                if (bandeira == null) {
                        if (other.bandeira != null)
                                return false;
                } else if (!bandeira.equals(other.bandeira))
                        return false;
                if (formaPagamento == null) {
                        if (other.formaPagamento != null)
                                return false;
                } else if (!formaPagamento.equals(other.formaPagamento))
                        return false;
                return true;
        }

        @Override
        public CartaoBandeiraDTO clone() {
                try {
                        return (CartaoBandeiraDTO) super.clone();
                } catch (CloneNotSupportedException e) {
                        e.printStackTrace();
                }
                return null;
        }
       
        @Override
        public int compareTo(CartaoBandeiraDTO cartaoBandeira) {
                return this.formaPagamento.getNumeroOrdem().compareTo(cartaoBandeira.getFormaPagamento().getNumeroOrdem());
        }
       
        @Transient
        public String getCorValoresConciliados() {
                return /*getQuantidade().equals(getQuantidadeImportado()) &&*/ getBruto().equals(getBrutoImportado())? "green" : "red";
        }
       
}