package com.arrebol.taxiservicios.model.admin;

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.EmployeeSanctionType;
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 EmployeeSanction implements Serializable {

    private static final long serialVersionUID = 3136636758891142920L;

    private String id;
    private Double payment;
    private String description;
    private EmployeeSanctionType type;
    private Person employee;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Boolean active;
    private Double amountToPay;
    private Double paymentWeek;
    private Location location;

    /**
     *
     * @param id
     * @param payment
     * @param paymentDate
     * @param description
     * @param type
     * @param employee
     */
    public EmployeeSanction(String id, Double payment, String description, EmployeeSanctionType type, Person employee) {
        this.id = id;
        this.payment = payment;
        this.description = description;
        this.type = type;
        this.employee = employee;
    }

    /**
     *
     * @param id
     * @param payment
     * @param paymentDate
     * @param description
     * @param type
     * @param employee
     * @param createdBy
     */
    public EmployeeSanction(String id, Double payment,String description, EmployeeSanctionType type, Person employee, User createdBy) {
        this.id = id;
        this.payment = payment;
        this.description = description;
        this.type = type;
        this.employee = employee;
        this.createdBy = createdBy;
    }
    
    public EmployeeSanction(String id, Double payment,String description, EmployeeSanctionType type, Person employee, User createdBy, Date createdOn) {
        this.id = id;
        this.payment = payment;
        this.description = description;
        this.type = type;
        this.employee = employee;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }
    
    public EmployeeSanction(String id, Double payment,String description, EmployeeSanctionType type, Person employee, User createdBy, Date createdOn, 
            double paymentWeek, double amountToPay) {
        this.id = id;
        this.payment = payment;
        this.description = description;
        this.type = type;
        this.employee = employee;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.paymentWeek = paymentWeek;
        this.amountToPay = amountToPay;
    }

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

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

    public EmployeeSanction(Double payment) {

        this.payment = payment;

    }

    public EmployeeSanction() {
    }

    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 String getDescription() {
        return description;
    }

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

    public EmployeeSanctionType getType() {
        return type;
    }

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

    public Person getEmployee() {
        return employee;
    }

    public void setEmployee(Person employee) {
        this.employee = employee;
    }

    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 Double getAmountToPay() {
        return amountToPay;
    }

    public void setAmountToPay(Double amountToPay) {
        this.amountToPay = amountToPay;
    }

    public Double getPaymentWeek() {
        return paymentWeek;
    }

    public void setPaymentWeek(Double paymentWeek) {
        this.paymentWeek = paymentWeek;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }
    
    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;
    }

}
