/*
 * 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.Location;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.BasicType;
import com.arrebol.taxiservicios.model.enums.ExpenseStatusType;
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 Taxes implements Serializable {

    private static final long serialVersionUID = -3411023566907484143L;

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

    private BankCard bankCard;
    private ExpenseStatusType depositStatus;
    public Taxes() {
    }

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

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

    public void setTaxesType(TaxesType taxesType) {
        this.taxesType = taxesType;
    }

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

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