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

import com.arrebol.apc.model.enums.CustomerClassification;
import com.arrebol.apc.model.enums.PeopleType;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Immutable;

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

    @Id
    @Column(name = "id", length = 36)
    private String id;

    @Column(name = "full_name", length = 103)
    private String fullName;

    @Column(name = "company_name", length = 150)
    private String companyName;

    @Column(name = "address_home", length = 150)
    private String addressHome;

    @Column(name = "address_business", length = 150)
    private String addressBusiness;

    @Column(name = "route_name", length = 25)
    private String routeName;

    @Enumerated(EnumType.STRING)
    @Column(name = "people_type", nullable = false)
    private PeopleType peopleType;

    @Column(name = "str_people_type", length = 14)
    private String strPeopleType;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "classification", nullable = false)
    private CustomerClassification classification;

    @Column(name = "office_name", length = 100)
    private String officeName;

    @Column(name = "total_of_loan")
    private Integer totalOfLoan;

    public CustomerView() {
    }

    public String getId() {
        return id;
    }

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

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getAddressHome() {
        return addressHome;
    }

    public void setAddressHome(String addressHome) {
        this.addressHome = addressHome;
    }

    public String getAddressBusiness() {
        return addressBusiness;
    }

    public void setAddressBusiness(String addressBusiness) {
        this.addressBusiness = addressBusiness;
    }

    public String getRouteName() {
        return routeName;
    }

    public void setRouteName(String routeName) {
        this.routeName = routeName;
    }

    public PeopleType getPeopleType() {
        return peopleType;
    }

    public void setPeopleType(PeopleType peopleType) {
        this.peopleType = peopleType;
    }

    public String getStrPeopleType() {
        return strPeopleType;
    }

    public void setStrPeopleType(String strPeopleType) {
        this.strPeopleType = strPeopleType;
    }

    public String getOfficeName() {
        return officeName;
    }

    public void setOfficeName(String officeName) {
        this.officeName = officeName;
    }

    public Integer getTotalOfLoan() {
        return totalOfLoan;
    }

    public void setTotalOfLoan(Integer totalOfLoan) {
        this.totalOfLoan = totalOfLoan;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * 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 CustomerView other = (CustomerView) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    public CustomerClassification getClassification() {
        return classification;
    }

    public void setClassification(CustomerClassification classification) {
        this.classification = classification;
    }
    
    public String conditionStyle()
    {
        if(getClassification().equals(classification.RED))
            return "redRow";
        else if(getClassification().equals(classification.YELLOW))
            return "yellowRow";
        return null;
    }
    
    @Override
    public String toString() {
        return "CustomerView{" + "fullName=" + fullName + ", routeName=" + routeName + ", officeName=" + officeName + '}';
    }

}
