/*
 * 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.qsoft.rs.sincoar.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TCUSTBALANCE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tcustbalance.findAll", query = "SELECT t FROM Tcustbalance t"),
    @NamedQuery(name = "Tcustbalance.findByPersoncode", query = "SELECT t FROM Tcustbalance t WHERE t.tcustbalancePK.personcode = :personcode"),
    @NamedQuery(name = "Tcustbalance.findByBalancedate", query = "SELECT t FROM Tcustbalance t WHERE t.tcustbalancePK.balancedate = :balancedate")})
public class Tcustbalance implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TcustbalancePK tcustbalancePK;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tcustbalance")
    private Collection<Tcustbalancefinancial> tcustbalancefinancialCollection;
    @JoinColumn(name = "PERSONCODE", referencedColumnName = "PERSONCODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tcustperson tcustperson;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tcustbalance")
    private Collection<Tcustpersonbalance> tcustpersonbalanceCollection;

    public Tcustbalance() {
    }

    public Tcustbalance(TcustbalancePK tcustbalancePK) {
        this.tcustbalancePK = tcustbalancePK;
    }

    public Tcustbalance(long personcode, Date balancedate) {
        this.tcustbalancePK = new TcustbalancePK(personcode, balancedate);
    }

    public TcustbalancePK getTcustbalancePK() {
        return tcustbalancePK;
    }

    public void setTcustbalancePK(TcustbalancePK tcustbalancePK) {
        this.tcustbalancePK = tcustbalancePK;
    }

    @XmlTransient
    public Collection<Tcustbalancefinancial> getTcustbalancefinancialCollection() {
        return tcustbalancefinancialCollection;
    }

    public void setTcustbalancefinancialCollection(Collection<Tcustbalancefinancial> tcustbalancefinancialCollection) {
        this.tcustbalancefinancialCollection = tcustbalancefinancialCollection;
    }

    public Tcustperson getTcustperson() {
        return tcustperson;
    }

    public void setTcustperson(Tcustperson tcustperson) {
        this.tcustperson = tcustperson;
    }

    @XmlTransient
    public Collection<Tcustpersonbalance> getTcustpersonbalanceCollection() {
        return tcustpersonbalanceCollection;
    }

    public void setTcustpersonbalanceCollection(Collection<Tcustpersonbalance> tcustpersonbalanceCollection) {
        this.tcustpersonbalanceCollection = tcustpersonbalanceCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tcustbalancePK != null ? tcustbalancePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tcustbalance)) {
            return false;
        }
        Tcustbalance other = (Tcustbalance) object;
        if ((this.tcustbalancePK == null && other.tcustbalancePK != null) || (this.tcustbalancePK != null && !this.tcustbalancePK.equals(other.tcustbalancePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsoft.rs.sincoar.model.Tcustbalance[ tcustbalancePK=" + tcustbalancePK + " ]";
    }
    
}
