/*
 * 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.admin.*;
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 MutualStableSmallBox implements Serializable {

    private String id;
    private BigDecimal totalSmallBox;
    private BigDecimal totalEnvelope;
    private BigDecimal totalBankNote;
    private BigDecimal totalCoin;
    private BigDecimal totalStable;
    private BigDecimal totalTransfer;
    private BasicType activeStatus;
    private String description;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Location location;

    /**
     * Default constructor.
     */
    public MutualStableSmallBox() {
    }

    /**
     *
     * @param id
     * @param totalSmallBox
     * @param totalEnvelope
     * @param totalBankNote
     * @param totalCoin
     * @param totalStable
     * @param activeStatus
     * @param description
     * @param createdBy
     * @param createdOn
     */
    public MutualStableSmallBox(String id, BigDecimal totalSmallBox, BigDecimal totalEnvelope, BigDecimal totalBankNote, BigDecimal totalCoin, BigDecimal totalStable, BasicType activeStatus, String description, User createdBy, Date createdOn) {
        this.id = id;
        this.totalSmallBox = totalSmallBox;
        this.totalEnvelope = totalEnvelope;
        this.totalBankNote = totalBankNote;
        this.totalCoin = totalCoin;
        this.totalStable = totalStable;
        this.activeStatus = activeStatus;
        this.description = description;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }

    /**
     *
     * @param id
     * @param totalSmallBox
     * @param totalEnvelope
     * @param totalBankNote
     * @param totalCoin
     * @param totalStable
     * @param description
     * @param createdOn
     */
    public MutualStableSmallBox(String id, BigDecimal totalSmallBox, BigDecimal totalEnvelope, BigDecimal totalBankNote, BigDecimal totalCoin, BigDecimal totalStable, String description, Date createdOn) {
        this.id = id;
        this.totalSmallBox = totalSmallBox;
        this.totalEnvelope = totalEnvelope;
        this.totalBankNote = totalBankNote;
        this.totalCoin = totalCoin;
        this.totalStable = totalStable;
        this.description = description;
        this.createdOn = createdOn;
    }

    /**
     *
     * @param id
     * @param totalSmallBox
     * @param totalEnvelope
     * @param totalBankNote
     * @param totalCoin
     * @param totalStable
     * @param description
     * @param createdOn
     * @param createdBy
     */
    public MutualStableSmallBox(String id, BigDecimal totalSmallBox, BigDecimal totalEnvelope, BigDecimal totalBankNote, BigDecimal totalCoin, BigDecimal totalStable, String description, Date createdOn, User createdBy) {
        this.id = id;
        this.totalSmallBox = totalSmallBox;
        this.totalEnvelope = totalEnvelope;
        this.totalBankNote = totalBankNote;
        this.totalCoin = totalCoin;
        this.totalStable = totalStable;
        this.description = description;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
    }
    
    public MutualStableSmallBox(String id, BigDecimal totalSmallBox, BigDecimal totalEnvelope, BigDecimal totalBankNote, BigDecimal totalCoin, 
            BigDecimal totalStable, String description, Date createdOn, User createdBy, Location location, BasicType activeStatus) {
        this.id = id;
        this.totalSmallBox = totalSmallBox;
        this.totalEnvelope = totalEnvelope;
        this.totalBankNote = totalBankNote;
        this.totalCoin = totalCoin;
        this.totalStable = totalStable;
        this.description = description;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
        this.location = location;
        this.activeStatus = activeStatus;
    }
    
    public MutualStableSmallBox(String id, BigDecimal totalSmallBox, BigDecimal totalEnvelope, BigDecimal totalBankNote, BigDecimal totalCoin, 
            BigDecimal totalStable, String description, Date createdOn, User createdBy, Location location, BasicType activeStatus, BigDecimal totalTransfer) {
        this.id = id;
        this.totalSmallBox = totalSmallBox;
        this.totalEnvelope = totalEnvelope;
        this.totalBankNote = totalBankNote;
        this.totalCoin = totalCoin;
        this.totalStable = totalStable;
        this.description = description;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
        this.location = location;
        this.activeStatus = activeStatus;
        this.totalTransfer = totalTransfer;
    }

    /**
     *
     * @param id
     * @param totalSmallBox
     * @param totalEnvelope
     * @param totalBankNote
     * @param totalCoin
     * @param createdOn
     */
    public MutualStableSmallBox(String id, BigDecimal totalSmallBox, BigDecimal totalEnvelope, BigDecimal totalBankNote, BigDecimal totalCoin, Date createdOn) {
        this.id = id;
        this.totalSmallBox = totalSmallBox;
        this.totalEnvelope = totalEnvelope;
        this.totalBankNote = totalBankNote;
        this.totalCoin = totalCoin;
        this.createdOn = createdOn;
    }

    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 getTotalSmallBox() {
        return totalSmallBox;
    }

    public void setTotalSmallBox(BigDecimal totalSmallBox) {
        this.totalSmallBox = totalSmallBox;
    }

    public BigDecimal getTotalEnvelope() {
        return totalEnvelope;
    }

    public void setTotalEnvelope(BigDecimal totalEnvelope) {
        this.totalEnvelope = totalEnvelope;
    }

    public BigDecimal getTotalBankNote() {
        return totalBankNote;
    }

    public void setTotalBankNote(BigDecimal totalBankNote) {
        this.totalBankNote = totalBankNote;
    }

    public BigDecimal getTotalCoin() {
        return totalCoin;
    }

    public void setTotalCoin(BigDecimal totalCoin) {
        this.totalCoin = totalCoin;
    }

    public BigDecimal getTotalStable() {
        return totalStable;
    }

    public void setTotalStable(BigDecimal totalStable) {
        this.totalStable = totalStable;
    }

    public BasicType getActiveStatus() {
        return activeStatus;
    }

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

    public String getDescription() {
        return description;
    }

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

    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(){
        if(activeStatus == BasicType.ENEBLED)
            return true;
        else
            return false;
                  
    }

    public BigDecimal getTotalTransfer() {
        return totalTransfer;
    }

    public void setTotalTransfer(BigDecimal totalTransfer) {
        this.totalTransfer = totalTransfer;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 43 * 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 MutualStableSmallBox other = (MutualStableSmallBox) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }
    
    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(MutualStableSmallBox.class.getName()).log(Level.SEVERE, null, ex);
        }
        return action;
    }

    @Override
    public String toString() {
        return "StableSmallBox{" + "activeStatus=" + activeStatus + ", description=" + description + ", createdOn=" + createdOn + '}';
    }

    private static final long serialVersionUID = -7532585852290687551L;

}
