/*
 * 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.mutual;

import com.arrebol.taxiservicios.model.catalog.Location;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.BasicType;
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 Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
public class MutualInicios implements Serializable {

    private static final long serialVersionUID = -3411023566907484143L;

    private String id;
    private BigDecimal amount;
    private String description;
    private User user;
    private BasicType activeStatus;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Location location;

    public MutualInicios() {
    }

    /**
     *
     * @param id
     * @param amount
     * @param description
     * @param createdOn
     */
    public MutualInicios(String id, BigDecimal amount, String description, Date createdOn) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.createdOn = createdOn;
    }

    /**
     *
     * @param id
     * @param amount
     * @param description
     * @param createdOn
     * @param createdBy
     */
    public MutualInicios(String id, BigDecimal amount, String description, Date createdOn, User createdBy) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
    }
    
    public MutualInicios(String id, BigDecimal amount, String description, Date createdOn, User createdBy, Location location, BasicType activeStatus, User user) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
        this.location = location;
        this.activeStatus = activeStatus;
        this.user = user;
    }

    /**
     *
     * @param id
     * @param amount
     * @param description
     * @param expenseCompanyType
     * @param activeStatus
     * @param createdBy
     * @param createdOn
     */
    public MutualInicios(String id, BigDecimal amount, String description, BasicType activeStatus, User createdBy, Date createdOn) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.activeStatus = activeStatus;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }
    
    public MutualInicios(String id, BigDecimal amount, String description, User user, BasicType activeStatus, User createdBy, Date createdOn, Location location) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.user = user;
        this.activeStatus = activeStatus;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.location = location;
    }

    public Location getLocation() {
        return location;
    }

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

    public String getId() {
        return id;
    }

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

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getDescription() {
        return description;
    }

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

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

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

    public BasicType getActiveStatus() {
        return 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;
    }

    @Override
    public String toString() {
        return "ExpenseCompany{" + "amount=" + amount + ", description=" + description + '}';
    }

    @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 MutualInicios other = (MutualInicios) 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(MutualInicios.class.getName()).log(Level.SEVERE, null, ex);
        }
        return action;
    }
}
