/*
 * 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.apc.model.admin;

import com.arrebol.apc.model.core.Office;
import com.arrebol.apc.model.core.User;
import com.arrebol.apc.model.enums.ActiveStatus;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
@Entity
@Table(name = "APC_STABLE_GENERAL_BOX")
public class StableGeneralBox implements Serializable {

    private static final long serialVersionUID = -3501956555560463690L;

    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid2")
    @Column(name = "id", length = 36)
    private String id;

    @Column(name = "total_general_box", nullable = false)
    private BigDecimal totalGeneralBox;

    @Column(name = "total_envelope", nullable = false)
    private BigDecimal totalEnvelope;

    @Column(name = "total_bank_note", nullable = false)
    private BigDecimal totalBankNote;

    @Column(name = "total_coin", nullable = false)
    private BigDecimal totalCoin;

    @Column(name = "total_stable", nullable = false)
    private BigDecimal totalStable;

    @Column(name = "description", length = 200)
    private String description;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(
            name = "id_office",
            referencedColumnName = "id",
            nullable = false
    )
    private Office office;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(
            name = "created_by",
            referencedColumnName = "id",
            insertable = false,
            updatable = false,
            nullable = false
    )
    private User user;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "active_status", nullable = false)
    private ActiveStatus activeStatus;

    @Column(name = "created_by", nullable = false, length = 36)
    private String createdBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_on", length = 19)
    private Date createdOn;

    @Column(name = "last_updated_by", length = 36)
    private String lastUpdatedBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_updated_on", length = 19)
    private Date lastUpdatedOn;

    public StableGeneralBox() {
    }

    public String getId() {
        return id;
    }

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

    public BigDecimal getTotalGeneralBox() {
        return totalGeneralBox;
    }

    public void setTotalGeneralBox(BigDecimal totalGeneralBox) {
        this.totalGeneralBox = totalGeneralBox;
    }

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

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

    public Office getOffice() {
        return office;
    }

    public void setOffice(Office office) {
        this.office = office;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Date getLastUpdatedOn() {
        return lastUpdatedOn;
    }

    public void setLastUpdatedOn(Date lastUpdatedOn) {
        this.lastUpdatedOn = lastUpdatedOn;
    }

    public ActiveStatus getActiveStatus() {
        return activeStatus;
    }

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

    public User getUser() {
        return user;
    }

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

    public String getUserName() {
        String lNombre = user.getHumanResource().getFirstName() + " " + user.getHumanResource().getSecondName() + " " + user.getHumanResource().getLastName();
        return lNombre;
    }
    
    public String conditionEnabled()   {
        if(getActiveStatus() == ActiveStatus.DISABLED)
            return "grayRow";
        else
            return null;
    }

    public boolean getActive() {
        if (activeStatus == ActiveStatus.ENEBLED) {
            return true;
        } else {
            return false;
        }

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

}
