/*
 * 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.BankCard;
import com.arrebol.taxiservicios.model.catalog.ExpenseIncomeCatalog;
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.ExpenseCompanyType;
import com.arrebol.taxiservicios.model.enums.ExpenseStatusType;
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 ExpenseCompany implements Serializable {

    private static final long serialVersionUID = -3411023566907484143L;

    private String id;
    private BigDecimal amount;
    private String description;
    private ExpenseCompanyType expenseCompanyType;
    private BasicType activeStatus;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Location location;
    private Boolean print;
    private BankCard bankCard;
    private ExpenseStatusType depositStatus;
    private ExpenseIncomeCatalog idExpenseType;
    private StableGeneralBox stableGeneralBox;

    public ExpenseCompany() {
    }

    /**
     *
     * @param id
     * @param amount
     * @param description
     * @param createdOn
     */
    public ExpenseCompany(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 ExpenseCompany(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 ExpenseCompany(String id, BigDecimal amount, String description, Date createdOn, User createdBy, Location location, BasicType activeStatus) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
        this.location = location;
        this.activeStatus = activeStatus;
    }

    public ExpenseCompany(String id, BigDecimal amount, String description, BasicType activeStatus, User createdBy, Date createdOn, Location location, Boolean print) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.activeStatus = activeStatus;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.location = location;
        this.print = print;
    }

    public ExpenseCompany(String id, BigDecimal amount, String description, Date createdOn, User createdBy, Location location, BasicType activeStatus, ExpenseIncomeCatalog idExpenseType) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
        this.location = location;
        this.activeStatus = activeStatus;
        this.idExpenseType = idExpenseType;
    }

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

    public ExpenseCompany(String id, BigDecimal amount, String description, ExpenseCompanyType expenseCompanyType, BasicType activeStatus, User createdBy, Date createdOn, Location location) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.expenseCompanyType = expenseCompanyType;
        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 ExpenseCompanyType getExpenseCompanyType() {
        return expenseCompanyType;
    }

    public void setExpenseCompanyType(ExpenseCompanyType expenseCompanyType) {
        this.expenseCompanyType = expenseCompanyType;
    }

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

    public ExpenseIncomeCatalog getIdExpenseType() {
        return idExpenseType;
    }

    public void setIdExpenseType(ExpenseIncomeCatalog idExpenseType) {
        this.idExpenseType = idExpenseType;
    }

    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 StableGeneralBox getStableGeneralBox() {
        return stableGeneralBox;
    }

    public void setStableGeneralBox(StableGeneralBox stableGeneralBox) {
        this.stableGeneralBox = stableGeneralBox;
    }

    public Boolean getPrint() {
        return print;
    }

    public void setPrint(Boolean print) {
        this.print = print;
    }

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