/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
 */
package com.qsoft.rs.sincoar.constantes;

import com.qsoft.dao.exception.DaoException;
import com.qsoft.rs.sincoar.dao.DaoGenerico;
import com.qsoft.rs.sincoar.model.Tgenecatalog;
import com.qsoft.rs.sincoar.model.Tgenecatalogdetail;
import com.qsoft.rs.sincoar.model.TgenecatalogdetailPK;

/**
 *
 * @author developer2
 */
public enum TgeneCatalogDetailEnum {
    BCE("BCE","BASERATE");

    private Tgenecatalogdetail detalle;

    private String catalog;
    private String catalogCode;
    private TgeneCatalogDetailEnum(String codigo, String catalogCode) {
        this.catalog = codigo;
        this.catalogCode = catalogCode;
        this.detalle = new Tgenecatalogdetail();
    }

    public String getCatalog() {
        return catalog;
    }

    public String getCatalogCode() {
        return catalogCode;
    }
    

    public Tgenecatalogdetail getDetalle(){
        if (this.catalog != null && this.catalogCode != null) {
            DaoGenerico<Tgenecatalogdetail, TgenecatalogdetailPK> dao = new DaoGenerico<>(Tgenecatalogdetail.class);
            Tgenecatalogdetail tgcd = new Tgenecatalogdetail(catalog, catalogCode);
            tgcd.setTgenecatalogdetailPK(new TgenecatalogdetailPK(catalog, catalogCode));
            try {
                this.detalle = dao.buscarUnico(tgcd);
            } catch (DaoException ex) {
                System.out.println("ERROR CARGANDO DETALLE CATALOGO " + ex);
            }
        }
        return detalle;
    }
}
