/*
 * 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 java.util.TreeMap;

/**
 *
 * @author developer2
 */
public enum TgeneCatalogEnum {
    BASERATE("BASERATE"),
    CHARGES("CHARGES"),
    ;

    private Tgenecatalog plantilla;
    private final String codigo;
    private TreeMap<String, String> parametros;

    private TgeneCatalogEnum(String codigo) {
        this.codigo = codigo;
        this.plantilla = new Tgenecatalog(codigo);
    }

    public String getCodigo() {
        return codigo;
    }

    /**
     * 
     * @return 
     */
    public Tgenecatalog getTgenecatalog() {
        if (plantilla.getCatalogcode() == null && this.codigo != null) {
            DaoGenerico<Tgenecatalog, String> dao = new DaoGenerico<>(Tgenecatalog.class);
            try {
                this.plantilla = dao.cargar(this.codigo);
            } catch (DaoException ex) {
                System.out.println("ERROR CARGANDO PLANTILLA " + ex);
            }
        }
        return this.plantilla;
    }
}
