/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.arrebol.taxiservicios.model.predio;



import com.arrebol.taxiservicios.model.core.Person;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.CompromisoPago;
import com.arrebol.taxiservicios.model.enums.EstatusLote;
import com.arrebol.taxiservicios.model.enums.GenericEnumType;
import com.arrebol.taxiservicios.model.enums.PeriodoPago;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
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 javax.persistence.Transient;
import org.hibernate.annotations.GenericGenerator;

/**
 *
 * @author Picasso
 */
@Entity
@Table(name = "lote")
public class Lote implements Serializable {

    private static final long serialVersionUID = -6653037938225719593L;

    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid2")
    @Column(name = "id", length = 36)
    private String id;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(
            name = "id_manzana",
            referencedColumnName = "id",
            nullable = false
    )
    private Manzana manzana;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(
            name = "id_cliente",
            referencedColumnName = "id",
            nullable = true
    )
    private Person cliente;
    
    @Column(name = "medida", nullable = true)
    private Double medida;
    
    @Column(name = "metro_cuadrado", nullable = true)
    private String metroCuadrado;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "estatus", nullable = false)
    private EstatusLote estatusLote;
    
    @Column(name = "anticipo", nullable = true)
    private Double anticipo;
 
    @Enumerated(EnumType.STRING)
    @Column(name = "periodo_pago", nullable = true)
    private PeriodoPago periodoPago;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "estatus_activo", nullable = true)
    private GenericEnumType estatusActivo;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "dia_a_pagar", length = 19, nullable = true)
    private Date diaAPagar;
    
    @Column(name = "costo", nullable = true)
    private Double costo;
    
    @Column(name = "total_a_pagar", nullable = true)
    private Double totalAPagar;
    
    @Column(name = "mensualidad", nullable = true)
    private Double mensualidad;
    
    @Column(name ="folio", nullable = true)
    private String folio;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(
            name = "created_by",
            referencedColumnName = "id",
            nullable = false
    )
    private User createdBy;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_on", length = 19)
    private Date createdOn;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(
            name = "last_updated_by",
            referencedColumnName = "id",
            nullable = true
    )
    private User lastUpdatedBy;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_updated_on", length = 19, nullable = true)
    private Date lastUpdatedOn;
    
    @Column(name = "plazo_meses", nullable = true)
    private String plazoMeses;
    
    @Column(name = "total_pago", nullable = true)
    private Double totalPago;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "fin_reserva", length = 19, nullable = true)
    private Date finReserva;
    
    
    @Column(name = "monto_pagado", nullable = true)
    private Double montoPagado;
    
    @Transient
    private Boolean cargarUrbanizacion;
    
    /**
     *
     * @param id
     * @param manzana
     * @param medida
     * @param metroCuadrado
     * @param estatusLote
     */
    public Lote(String id, Manzana manzana, Double medida, String metroCuadrado, EstatusLote estatusLote) {
        this.id = id;
        this.manzana = manzana;
        this.medida = medida;
        this.metroCuadrado = metroCuadrado;
        this.estatusLote = estatusLote;
    }
        
    public Lote() {
    }

    public Lote(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }   
 
    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 Manzana getManzana() {
        return manzana;
    }

    public void setManzana(Manzana manzana) {
        this.manzana = manzana;
    }

    public Person getCliente() {
        return cliente;
    }

    public void setCliente(Person cliente) {
        this.cliente = cliente;
    }

    public Double getMedida() {
        return medida;
    }

    public void setMedida(Double medida) {
        this.medida = medida;
    }

    public String getMetroCuadrado() {
        return metroCuadrado;
    }

    public void setMetroCuadrado(String metroCuadrado) {
        this.metroCuadrado = metroCuadrado;
    }

    public EstatusLote getEstatusLote() {
        return estatusLote;
    }

    public void setEstatusLote(EstatusLote estatusLote) {
        this.estatusLote = estatusLote;
    }

    public Double getAnticipo() {
        return anticipo;
    }

    public void setAnticipo(Double anticipo) {
        this.anticipo = anticipo;
    }

    public PeriodoPago getPeriodoPago() {
        return periodoPago;
    }

    public void setPeriodoPago(PeriodoPago periodoPago) {
        this.periodoPago = periodoPago;
    }

    public Date getDiaAPagar() {
        return diaAPagar;
    }

    public void setDiaAPagar(Date diaAPagar) {
        this.diaAPagar = diaAPagar;
    }

    public Double getCosto() {
        return costo;
    }

    public void setCosto(Double costo) {
        this.costo = costo;
    }

    public Double getTotalAPagar() {
        return totalAPagar;
    }

    public void setTotalAPagar(Double totalAPagar) {
        this.totalAPagar = totalAPagar;
    }

    public Double getMensualidad() {
        return mensualidad;
    }

    public void setMensualidad(Double mensualidad) {
        this.mensualidad = mensualidad;
    }

    public String getPlazoMeses() {
        return plazoMeses;
    }

    public void setPlazoMeses(String plazoMeses) {
        this.plazoMeses = plazoMeses;
    }

    public Double getTotalPago() {
        return totalPago;
    }

    public void setTotalPago(Double totalPago) {
        this.totalPago = totalPago;
    }
    public String getFolio() {
        return folio;
    }

    public void setFolio(String folio) {
        this.folio = folio;
    }

    public Date getFinReserva() {
        return finReserva;
    }

    public void setFinReserva(Date finReserva) {
        this.finReserva = finReserva;
    } 

    public GenericEnumType getEstatusActivo() {
        return estatusActivo;
    }

    public void setEstatusActivo(GenericEnumType estatusActivo) {
        this.estatusActivo = estatusActivo;
    }
    
    
    
    @Override
    public String toString() {
        return medida + "";
    }

    public Boolean getCargarUrbanizacion() {
        return cargarUrbanizacion;
    }

    public void setCargarUrbanizacion(Boolean cargarUrbanizacion) {
        this.cargarUrbanizacion = cargarUrbanizacion;
    }

    public Double getMontoPagado() {
        return montoPagado;
    }

    public void setMontoPagado(Double montoPagado) {
        this.montoPagado = montoPagado;
    }
    
    
    

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Lote other = (Lote) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }
    

}
