package com.arrebol.taxiservicios.model.admin;

import com.arrebol.taxiservicios.model.catalog.BankCard;
import com.arrebol.taxiservicios.model.catalog.Location;
import com.arrebol.taxiservicios.model.core.Person;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.ExpenseStatusType;
import com.arrebol.taxiservicios.model.enums.SanctionType;
import java.io.Serializable;
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 Picasso
 */
public class Sanction implements Serializable {

    private static final long serialVersionUID = 3136636758891142920L;

    private String id;
    private Double payment;
    private Date paymentDate;
    private String description;
    private SanctionType type;
    private Person driver;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Boolean active;
    private Location location;
    private ExpenseStatusType status;
    private BankCard bankCard;
    private ExpenseStatusType depositStatus;

    /**
     *
     * @param id
     * @param payment
     * @param paymentDate
     * @param description
     * @param type
     * @param driver
     */
    public Sanction(String id, Double payment, Date paymentDate, String description, SanctionType type, Person driver) {
        this.id = id;
        this.payment = payment;
        this.paymentDate = paymentDate;
        this.description = description;
        this.type = type;
        this.driver = driver;
    }

    /**
     *
     * @param id
     * @param payment
     * @param paymentDate
     * @param description
     * @param type
     * @param driver
     * @param createdBy
     */
    public Sanction(String id, Double payment, Date paymentDate, String description, SanctionType type, Person driver, User createdBy) {
        this.id = id;
        this.payment = payment;
        this.paymentDate = paymentDate;
        this.description = description;
        this.type = type;
        this.driver = driver;
        this.createdBy = createdBy;
    }

    /**
     *
     * @param id
     * @param payment
     * @param paymentDate
     * @param driver
     * @param description
     * @param type
     * @param createdBy
     * @param createdOn
     */
    public Sanction(String id, Double payment, Date paymentDate, Person driver, String description, SanctionType type, User createdBy, Date createdOn) {
        this.id = id;
        this.payment = payment;
        this.paymentDate = paymentDate;
        this.description = description;
        this.type = type;
        this.driver = driver;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }
    
    public Sanction(String id, Double payment, Date paymentDate, Person driver, String description, SanctionType type, User createdBy, Date createdOn, Location location) {
        this.id = id;
        this.payment = payment;
        this.paymentDate = paymentDate;
        this.description = description;
        this.type = type;
        this.driver = driver;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.location = location;
    }
    
    public Sanction(String id, Double payment, Date paymentDate, Person driver, String description, SanctionType type, User createdBy, Date createdOn, Location location, ExpenseStatusType status) {
        this.id = id;
        this.payment = payment;
        this.paymentDate = paymentDate;
        this.description = description;
        this.type = type;
        this.driver = driver;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.location = location;
        this.status = status;
    }
    
    public Sanction(String id, Double payment, Date paymentDate, Person driver, String description, SanctionType type, User createdBy, Date createdOn, Location location, ExpenseStatusType status, BankCard bankCard) {
        this.id = id;
        this.payment = payment;
        this.paymentDate = paymentDate;
        this.description = description;
        this.type = type;
        this.driver = driver;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.location = location;
        this.status = status;
        this.bankCard = bankCard;
    }

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

    public Sanction(Double payment) {

        this.payment = payment;

    }

    public Sanction() {
    }

    public String getId() {
        return id;
    }

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

    public Double getPayment() {
        return payment;
    }

    public void setPayment(Double payment) {
        this.payment = payment;
    }

    public Date getPaymentDate() {
        return paymentDate;
    }

    public void setPaymentDate(Date paymentDate) {
        this.paymentDate = paymentDate;
    }

    public String getDescription() {
        return description;
    }

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

    public SanctionType getType() {
        return type;
    }

    public void setType(SanctionType type) {
        this.type = type;
    }

    public Person getDriver() {
        return driver;
    }

    public void setDriver(Person driver) {
        this.driver = driver;
    }

    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 Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public Location getLocation() {
        return location;
    }

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

    public ExpenseStatusType getStatus() {
        return status;
    }

    public void setStatus(ExpenseStatusType status) {
        this.status = status;
    }
    
        public BankCard getBankCard() {
        return bankCard;
    }

    public void setBankCard(BankCard bankCard) {
        this.bankCard = bankCard;
    }

    public ExpenseStatusType getDepositStatus() {
        return depositStatus;
    }

    public void setDepositStatus(ExpenseStatusType depositStatus) {
        this.depositStatus = depositStatus;
    }

    
    
    public boolean getAction(Date lastStableSmallBox) {
        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(lastStableSmallBox);

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

}
