/*
 * 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.enums.LoanRenovationStatus;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

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

    private static final long serialVersionUID = 6330391021926685986L;

    @EmbeddedId
    LoanByRenovationId id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(
            name = "id_loan_old",
            referencedColumnName = "id",
            insertable = false,
            updatable = false
    )
    private Loan loanOld;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(
            name = "id_loan_new",
            referencedColumnName = "id",
            insertable = false,
            updatable = false
    )
    private Loan loanNew;

    @Enumerated(EnumType.STRING)
    @Column(name = "loan_by_renovation_status", nullable = false)
    private LoanRenovationStatus loanRenovationStatus;

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

    @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 LoanByRenovation() {
    }

    public LoanByRenovation(LoanByRenovationId id) {
        this.id = id;
    }

    public LoanByRenovation(LoanByRenovationId id, LoanRenovationStatus loanRenovationStatus, String createdBy, Date createdOn) {
        this.id = id;
        this.loanRenovationStatus = loanRenovationStatus;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }

    public LoanByRenovationId getId() {
        return id;
    }

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

    public Loan getLoanOld() {
        return loanOld;
    }

    public void setLoanOld(Loan loanOld) {
        this.loanOld = loanOld;
    }

    public Loan getLoanNew() {
        return loanNew;
    }

    public void setLoanNew(Loan loanNew) {
        this.loanNew = loanNew;
    }

    public LoanRenovationStatus getLoanRenovationStatus() {
        return loanRenovationStatus;
    }

    public void setLoanRenovationStatus(LoanRenovationStatus loanRenovationStatus) {
        this.loanRenovationStatus = loanRenovationStatus;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

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

    @Override
    public String toString() {
        return "LoanByRenovation{" + "loanOld=" + loanOld + ", loanNew=" + loanNew + ", loanRenovationStatus=" + loanRenovationStatus + ", comments=" + comments + ", createdOn=" + createdOn + '}';
    }

}
