OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 149 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
 * 
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing the software, include this License Header Notice in each file.
 */
 
 package org.openconcerto.erp.core.humanresources.payroll.report;

import org.openconcerto.utils.i18n.TranslationManager;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum GroupePayeSimplifiee {

    SANTE("sante", true, Arrays.asList(LignePayeSimplifiee.SANTE_SECURITE, LignePayeSimplifiee.SANTE_COMPLEMENAIRE_DECES, LignePayeSimplifiee.SANTE_COMPLEMENAIRE_SANTE)), ACCIDENT_TRAVAIL("accident",
            false, Arrays.asList(LignePayeSimplifiee.ACCIDENTS_TRAVAIL)), RETRAITE_NON_CADRE("retraite.noncadre", true,
                    Arrays.asList(LignePayeSimplifiee.RETRAITE_SECURITE_PLAF, LignePayeSimplifiee.RETRAITE_SECURITE_NON_PLAF, LignePayeSimplifiee.RETRAITE_COMPLEMENTAIRE_T1,
                            LignePayeSimplifiee.RETRAITE_COMPLEMENTAIRE_T2, LignePayeSimplifiee.RETRAITE_SUPPLEMENTAIRE)), RETRAITE_CADRE(
                                    "retraite.cadre", true,
                                    Arrays.asList(LignePayeSimplifiee.RETRAITE_SECURITE_PLAF, LignePayeSimplifiee.RETRAITE_SECURITE_NON_PLAF, LignePayeSimplifiee.RETRAITE_COMPLEMENTAIRE_T1,
                                            LignePayeSimplifiee.RETRAITE_COMPLEMENTAIRE_T2, LignePayeSimplifiee.RETRAITE_SUPPLEMENTAIRE)), FAMILLE("famille", false,
                                                    Arrays.asList(LignePayeSimplifiee.FAMILLE_ALLOCATIONS)), CHOMAGE_NON_CADRE("chomage.noncadre", false,
                                                            Arrays.asList(LignePayeSimplifiee.ASSURANCE_CHOMAGE_CHOMAGE)), CHOMAGE_CADRE("chomage.cadre", true,
                                                                    Arrays.asList(LignePayeSimplifiee.ASSURANCE_CHOMAGE_CHOMAGE, LignePayeSimplifiee.ASSURANCE_CHOMAGE_APEC)), AUTRES_CONTRIBUTIONS(
                                                                            "autres", false, Arrays.asList(LignePayeSimplifiee.AUTRES_CONTRIBUTIONS)), COTISATIONS_CONVENTION("cotisations.convention",
                                                                                    false, Arrays.asList(LignePayeSimplifiee.COTISATIONS_STATUAIRES)), CSG_NON_IMP("csg.nonimp", false,
                                                                                            Arrays.asList(LignePayeSimplifiee.CSG_NON_IMP)), CSG_IMP("csg.imp", false,
                                                                                                    Arrays.asList(LignePayeSimplifiee.CSG_IMP)), ALLEGEMENT("allegement", false,
                                                                                                            Arrays.asList(LignePayeSimplifiee.ALLEGEMENT_COTISATIONS));

    public final String id;
    public final List<LignePayeSimplifiee> children;
    public final boolean showChildren;

    private GroupePayeSimplifiee(String id, boolean showChildren, List<LignePayeSimplifiee> children) {
        this.children = children;
        this.showChildren = showChildren;
        this.id = id;
    }

    public boolean isShowChildren() {
        return showChildren;
    }

    public List<LignePayeSimplifiee> getChildren() {
        return children;
    }

    public String getId() {
        return id;
    }

    public String getTranslation() {
        final String translationForItem = TranslationManager.getInstance().getTranslationForItem(getId());

        return (translationForItem == null || translationForItem.trim().length() == 0) ? getId() : translationForItem;
    }

    private static final Map<String, GroupePayeSimplifiee> idToEnum = new HashMap<String, GroupePayeSimplifiee>();
    static {
        for (GroupePayeSimplifiee e : values())
            idToEnum.put(e.getId(), e);
    }

    public static GroupePayeSimplifiee fromID(int id) {
        return idToEnum.get(id);
    }

    @Override
    public String toString() {
        return getTranslation();
    }
}