/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.arrebol.taxiservicios.model.catalog;

import com.arrebol.taxiservicios.model.admin.Sale;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.BasicType;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 *
 * @author Picasso
 */
public class BankCard implements Serializable {

    private static final long serialVersionUID = -6653037938225719593L;

    private String id;
    private String bank;
    private String titular;
    private String numero;
    private BasicType activeStatus;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Location location;
    private Double balance;
    private Set<Sale> sales = new HashSet(0);

    public BankCard() {
    }

    /**
     *
     * @param id
     */
    public BankCard(String id) {
        this.id = id;
    }

    /**
     *
     * @param id
     * @param bank
     * @param titular
     * @param numero
     */
    public BankCard(String id, String bank, String titular, String numero) {
        this.id = id;
        this.bank = bank;
        this.titular = titular;
        this.numero = numero;
    }
    
    public BankCard(String id, String bank, String titular, String numero,Double balance) {
        this.id = id;
        this.bank = bank;
        this.titular = titular;
        this.numero = numero;
        this.balance = balance;
    }

    /**
     *
     * @param id
     * @param numero
     */
    public BankCard(String id, String numero) {
        this.id = id;
        this.numero = numero;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getBank() {
        return bank;
    }

    public void setBank(String bank) {
        this.bank = bank;
    }

    public String getTitular() {
        return titular;
    }

    public void setTitular(String titular) {
        this.titular = titular;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public BasicType getActiveStatus() {
        return activeStatus;
    }

    public void setActiveStatus(BasicType activeStatus) {
        this.activeStatus = activeStatus;
    }

    public User getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(User createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public User getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(User lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Date getLastUpdatedOn() {
        return lastUpdatedOn;
    }

    public void setLastUpdatedOn(Date lastUpdatedOn) {
        this.lastUpdatedOn = lastUpdatedOn;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public Set<Sale> getSales() {
        return sales;
    }

    public void setSales(Set<Sale> sales) {
        this.sales = sales;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }
    
    

    public String getMaskNumber() {
        try {
            return "****-****-****-" + numero.substring(numero.length() - 4, numero.length());
        } catch (NullPointerException e) {
            return "****-****-****-****";
        }
    }

    @Override
    public String toString() {
        return "BankCard{" + "id=" + id + ", activeStatus=" + activeStatus + '}';
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 53 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final BankCard other = (BankCard) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

}
