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

import com.arrebol.apc.model.core.Office;
import com.arrebol.apc.model.enums.ActiveStatus;
import com.arrebol.apc.model.enums.DaysInWeekend;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
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.OneToMany;
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_LOAN_TYPE")
public class LoanType implements Serializable {

    private static final long serialVersionUID = 1286109384972738375L;

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

    @Column(name = "loan_type_name", length = 50, nullable = false)
    private String loanTypeName;

    @Column(name = "total_days", nullable = false)
    private Integer totalDays;

    @Column(name = "loan_fee", nullable = false)
    private BigDecimal fee;

    @Column(name = "opening_fee", nullable = false)
    private Integer openingFee;

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

    @Column(name = "payment_daily", nullable = false)
    private BigDecimal paymentDaily;

    @Column(name = "payment_total", nullable = false)
    private BigDecimal paymentTotal;

    @Enumerated(EnumType.STRING)
    @Column(name = "payment_monday")
    private DaysInWeekend monday;

    @Enumerated(EnumType.STRING)
    @Column(name = "payment_tuesday")
    private DaysInWeekend tuesday;

    @Enumerated(EnumType.STRING)
    @Column(name = "payment_wednesday")
    private DaysInWeekend wednesday;

    @Enumerated(EnumType.STRING)
    @Column(name = "payment_thursday")
    private DaysInWeekend thursday;

    @Enumerated(EnumType.STRING)
    @Column(name = "payment_friday")
    private DaysInWeekend friday;

    @Enumerated(EnumType.STRING)
    @Column(name = "payment_saturday")
    private DaysInWeekend saturday;

    @Enumerated(EnumType.STRING)
    @Column(name = "payment_sunday")
    private DaysInWeekend sunday;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "convenio", nullable = false)
    private ActiveStatus convenio;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(
            name = "id_office",
            referencedColumnName = "id",
            nullable = false
    )
    private Office office;

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

    @OneToMany(
            mappedBy = "loanType",
            cascade = CascadeType.ALL,
            fetch = FetchType.LAZY,
            orphanRemoval = true
    )
    private List<Loan> loans;

    public LoanType() {
    }

    /**
     *
     * @param id
     */
    public LoanType(String id) {
        this.id = id;
    }

    /**
     * Complete constructor.
     *
     * @param id
     * @param loanTypeName
     * @param totalDays
     * @param fee
     * @param paymentDaily
     * @param paymentTotal
     * @param monday
     * @param tuesday
     * @param wednesday
     * @param thursday
     * @param friday
     * @param saturday
     * @param sunday
     * @param office
     * @param createdBy
     * @param createdOn
     * @param lastUpdatedBy
     * @param lastUpdatedOn
     * @param loans
     */
    public LoanType(String id, String loanTypeName, Integer totalDays, BigDecimal fee, BigDecimal paymentDaily, BigDecimal paymentTotal, DaysInWeekend monday, DaysInWeekend tuesday, DaysInWeekend wednesday, DaysInWeekend thursday, DaysInWeekend friday, DaysInWeekend saturday, DaysInWeekend sunday, Office office, String createdBy, Date createdOn, String lastUpdatedBy, Date lastUpdatedOn, List<Loan> loans) {
        this.id = id;
        this.loanTypeName = loanTypeName;
        this.totalDays = totalDays;
        this.fee = fee;
        this.paymentDaily = paymentDaily;
        this.paymentTotal = paymentTotal;
        this.monday = monday;
        this.tuesday = tuesday;
        this.wednesday = wednesday;
        this.thursday = thursday;
        this.friday = friday;
        this.saturday = saturday;
        this.sunday = sunday;
        this.office = office;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.lastUpdatedBy = lastUpdatedBy;
        this.lastUpdatedOn = lastUpdatedOn;
        this.loans = loans;
    }

    /**
     *
     * @param id
     * @param payment
     */
    public LoanType(String id, BigDecimal payment) {
        this.id = id;
        this.payment = payment;
    }
    
    /**
     * 
     * @param id
     * @param payment
     * @param loanTypeName 
     */
    public LoanType(String id, BigDecimal payment, String loanTypeName) {
        this.id = id;
        this.payment = payment;
        this.loanTypeName = loanTypeName;
    }

    public String getId() {
        return id;
    }

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

    public String getLoanTypeName() {
        return loanTypeName;
    }

    public void setLoanTypeName(String loanTypeName) {
        this.loanTypeName = loanTypeName;
    }

    public Integer getTotalDays() {
        return totalDays;
    }

    public void setTotalDays(Integer totalDays) {
        this.totalDays = totalDays;
    }

    public BigDecimal getFee() {
        return fee;
    }

    public void setFee(BigDecimal fee) {
        this.fee = fee;
    }

    public Integer getOpeningFee() {
        return openingFee;
    }

    public void setOpeningFee(Integer openingFee) {
        this.openingFee = openingFee;
    }

    public BigDecimal getPayment() {
        return payment;
    }

    public void setPayment(BigDecimal payment) {
        this.payment = payment;
    }

    public BigDecimal getPaymentDaily() {
        return paymentDaily;
    }

    public void setPaymentDaily(BigDecimal paymentDaily) {
        this.paymentDaily = paymentDaily;
    }

    public BigDecimal getPaymentTotal() {
        return paymentTotal;
    }

    public void setPaymentTotal(BigDecimal paymentTotal) {
        this.paymentTotal = paymentTotal;
    }

    public DaysInWeekend getMonday() {
        return monday;
    }

    public void setMonday(DaysInWeekend monday) {
        this.monday = monday;
    }

    public DaysInWeekend getTuesday() {
        return tuesday;
    }

    public void setTuesday(DaysInWeekend tuesday) {
        this.tuesday = tuesday;
    }

    public DaysInWeekend getWednesday() {
        return wednesday;
    }

    public void setWednesday(DaysInWeekend wednesday) {
        this.wednesday = wednesday;
    }

    public DaysInWeekend getThursday() {
        return thursday;
    }

    public void setThursday(DaysInWeekend thursday) {
        this.thursday = thursday;
    }

    public DaysInWeekend getFriday() {
        return friday;
    }

    public void setFriday(DaysInWeekend friday) {
        this.friday = friday;
    }

    public DaysInWeekend getSaturday() {
        return saturday;
    }

    public void setSaturday(DaysInWeekend saturday) {
        this.saturday = saturday;
    }

    public DaysInWeekend getSunday() {
        return sunday;
    }

    public void setSunday(DaysInWeekend sunday) {
        this.sunday = sunday;
    }

    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 List<Loan> getLoans() {
        return loans;
    }

    public void setLoans(List<Loan> loans) {
        this.loans = loans;
    }

    public ActiveStatus getConvenio() {
        return convenio;
    }

    public void setConvenio(ActiveStatus convenio) {
        this.convenio = convenio;
    }

    @Override
    public String toString() {
        return "LoanType{" + "loanTypeName=" + loanTypeName + '}';
    }

}
