/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.arrebol.taxiservicios.model.predio;

import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.GenericEnumType;
import com.arrebol.taxiservicios.model.enums.TipoAbono;
import java.io.Serializable;
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 pc one
 */
@Entity
@Table(name = "abono_proyecto")
public class AbonoProyecto implements Serializable, Comparable<AbonoProyecto>{

    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_proyecto",
            referencedColumnName = "id",
            nullable = false
    )
    private Predio predio;
    
    
    @Enumerated(EnumType.STRING)
    @Column(name = "tipo_abono", nullable = false)
    private TipoAbono tipoAbono;

    @Enumerated(EnumType.STRING)
    @Column(name = "estatus_activo", nullable = false)
    private GenericEnumType estatusActivo;

    @Enumerated(EnumType.STRING)
    @Column(name = "pago_estatus", nullable = false)
    private GenericEnumType pagoEstatus;

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

    @Column(name = "pago", nullable = true)
    private Double pago;

    @Column(name = "saldo_anterior", nullable = true)
    private Double saldoAnterior;

    @Column(name = "saldo_nuevo", nullable = true)
    private Double saldoNuevo;

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

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(
            name = "created_by",
            referencedColumnName = "id",
            nullable = false
    )
    private User createdBy;

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

    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(
            name = "last_updated_by",
            referencedColumnName = "id",
            nullable = true
    )
    private User lastUpdatedBy;

    
    @Column(name = "cantidad_pagada", nullable = true)
    private Double cantidadPagada;
    @Column(name = "total_calculado", nullable = true)
    private Double totalCalculado;
    @Column(name = "porcentaje", nullable = true)
    private Double porcentaje;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "fecha_inicio", length = 19, nullable = true)
    private Date fechaInicio;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "fecha_fin", length = 19, nullable = true)
    private Date fechaFin;
    
    @Column(name = "folios", nullable = true)
    private String folios;
    
    public AbonoProyecto() {
    }

    public AbonoProyecto(String id, Predio predio, TipoAbono tipoAbono, GenericEnumType estatusActivo, GenericEnumType pagoEstatus, Date fechaAPagar, Double pago, Double saldoAnterior, Double saldoNuevo, Date createdOn, User createdBy, Date lastUpdatedOn, User lastUpdatedBy, Double cantidadPagada) {
        this.id = id;
        this.predio = predio;
        this.tipoAbono = tipoAbono;
        this.estatusActivo = estatusActivo;
        this.pagoEstatus = pagoEstatus;
        this.fechaAPagar = fechaAPagar;
        this.pago = pago;
        this.saldoAnterior = saldoAnterior;
        this.saldoNuevo = saldoNuevo;
        this.createdOn = createdOn;
        this.createdBy = createdBy;
        this.lastUpdatedOn = lastUpdatedOn;
        this.lastUpdatedBy = lastUpdatedBy;
        this.cantidadPagada = cantidadPagada;
    }
    
    
    
    public String getId() {
        return id;
    }

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

    public Predio getPredio() {
        return predio;
    }

    public void setPredio(Predio predio) {
        this.predio = predio;
    }

    public TipoAbono getTipoAbono() {
        return tipoAbono;
    }

    public void setTipoAbono(TipoAbono tipoAbono) {
        this.tipoAbono = tipoAbono;
    }

    public GenericEnumType getEstatusActivo() {
        return estatusActivo;
    }

    public void setEstatusActivo(GenericEnumType estatusActivo) {
        this.estatusActivo = estatusActivo;
    }

    public GenericEnumType getPagoEstatus() {
        return pagoEstatus;
    }

    public void setPagoEstatus(GenericEnumType pagoEstatus) {
        this.pagoEstatus = pagoEstatus;
    }

    public Date getFechaAPagar() {
        return fechaAPagar;
    }

    public void setFechaAPagar(Date fechaAPagar) {
        this.fechaAPagar = fechaAPagar;
    }

    public Double getPago() {
        return pago;
    }

    public void setPago(Double pago) {
        this.pago = pago;
    }

    public Double getSaldoAnterior() {
        return saldoAnterior;
    }

    public void setSaldoAnterior(Double saldoAnterior) {
        this.saldoAnterior = saldoAnterior;
    }

    public Double getSaldoNuevo() {
        return saldoNuevo;
    }

    public void setSaldoNuevo(Double saldoNuevo) {
        this.saldoNuevo = saldoNuevo;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

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

    public User getCreatedBy() {
        return createdBy;
    }

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

    public Date getLastUpdatedOn() {
        return lastUpdatedOn;
    }

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

    public User getLastUpdatedBy() {
        return lastUpdatedBy;
    }

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

    public Double getCantidadPagada() {
        return cantidadPagada;
    }

    public void setCantidadPagada(Double cantidadPagada) {
        this.cantidadPagada = cantidadPagada;
    }

    public Date getFechaInicio() {
        return fechaInicio;
    }

    public void setFechaInicio(Date fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    public Date getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Date fechaFin) {
        this.fechaFin = fechaFin;
    }

    public Double getTotalCalculado() {
        return totalCalculado;
    }

    public void setTotalCalculado(Double totalCalculado) {
        this.totalCalculado = totalCalculado;
    }

    public Double getPorcentaje() {
        return porcentaje;
    }

    public void setPorcentaje(Double porcentaje) {
        this.porcentaje = porcentaje;
    }

    public String getFolios() {
        return folios;
    }

    public void setFolios(String folios) {
        this.folios = folios;
    }

    @Override
    public int compareTo(AbonoProyecto o) {
        return getFechaAPagar().compareTo(o.getFechaAPagar()); 
    }

}
