/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.taxiservicios.model.admin;

import com.arrebol.taxiservicios.model.catalog.Location;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.BasicType;
import com.arrebol.taxiservicios.model.enums.TaxesType;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Oscar Vargas
 */
public class TiempoAire implements Serializable {

    private static final long serialVersionUID = -3411023566907484143L;

    private String id;
    private BigDecimal amountMayoreo;
    private BigDecimal amountMenudeo;
    private String description;
    private Taxi taxi;
    private Date vigencia;
    private BasicType activeStatus;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Location location;

    public TiempoAire() {
    }

    public TiempoAire(String id, BigDecimal amountMayoreo, BigDecimal amountMenudeo, String description, Taxi taxi, Date vigencia, BasicType activeStatus, User createdBy, Date createdOn) {
        this.id = id;
        this.amountMayoreo = amountMayoreo;
        this.amountMenudeo = amountMenudeo;
        this.description = description;
        this.taxi = taxi;
        this.vigencia = vigencia;
        this.activeStatus = activeStatus;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }

    public TiempoAire(String id, BigDecimal amountMayoreo, BigDecimal amountMenudeo, String description, Taxi taxi, Date vigencia, BasicType activeStatus, User createdBy, Date createdOn, Location location) {
        this.id = id;
        this.amountMayoreo = amountMayoreo;
        this.amountMenudeo = amountMenudeo;
        this.description = description;
        this.taxi = taxi;
        this.vigencia = vigencia;
        this.activeStatus = activeStatus;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.location = location;
    }
    
    

    public String getId() {
        return id;
    }

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

    public BigDecimal getAmountMayoreo() {
        return amountMayoreo;
    }

    public void setAmountMayoreo(BigDecimal amountMayoreo) {
        this.amountMayoreo = amountMayoreo;
    }

    public BigDecimal getAmountMenudeo() {
        return amountMenudeo;
    }

    public void setAmountMenudeo(BigDecimal amountMenudeo) {
        this.amountMenudeo = amountMenudeo;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Taxi getTaxi() {
        return taxi;
    }

    public void setTaxi(Taxi taxi) {
        this.taxi = taxi;
    }

    public Date getVigencia() {
        return vigencia;
    }

    public void setVigencia(Date vigencia) {
        this.vigencia = vigencia;
    }

    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;
    }

    
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 23 * 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 TiempoAire other = (TiempoAire) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    public boolean getActive(){
        if(activeStatus == BasicType.ENEBLED)
            return true;
        else
            return false;
                  
    }
    
    public boolean getAction(Date lastStableGeneralBox) {
        Date date = createdOn;
        boolean action = true;
        try {
            SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");

            String dateStr = dt1.format(date);
            date = dt1.parse(dateStr);

            action = date.after(lastStableGeneralBox);

        } catch (ParseException ex) {
            Logger.getLogger(TiempoAire.class.getName()).log(Level.SEVERE, null, ex);
        }
        return action;
    }
}
