Subversion Repositories SmartDukaan

Rev

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

package com.spice.profitmandi.dao.enumuration.dtr;

/**
 * Agenda types tracked as lifecycle instances (user.agenda_instance.agenda_type).
 * Mirrors {@link VisitAgenda} 1:1 (same names, same labels). Types with an AUTO
 * rule are populated by the nightly cron ONLY — planners cannot assign them
 * manually; only the non-auto types are manual-assignable on Assign Visit.
 */
public enum AgendaType {
    LOW_INVESTMENT("Low investment", true),
    LOW_SALES("Low sales", true),
    LOW_PURCHASE("Low purchase", true),
    BRAND_ADDITION("Brand addition", false),
    CREDIT_DUES("Credit dues", true),
    SYSTEM_TRAINING("System training", false),
    REVIVAL("Revival", true),
    NEW_STOCK_PAYMENT("New Stock Payment", false);

    private final String label;
    private final boolean hasAutoRule;

    AgendaType(String label, boolean hasAutoRule) {
        this.label = label;
        this.hasAutoRule = hasAutoRule;
    }

    public String getLabel() {
        return label;
    }

    public boolean hasAutoRule() {
        return hasAutoRule;
    }

    public boolean isManualAssignable() {
        return !hasAutoRule;
    }

    public static java.util.List<String> manualAssignableLabels() {
        java.util.List<String> out = new java.util.ArrayList<>();
        for (AgendaType t : values()) {
            if (t.isManualAssignable()) out.add(t.label);
        }
        return out;
    }

    public static AgendaType fromLabel(String label) {
        if (label == null) return null;
        for (AgendaType t : values()) {
            if (t.label.equalsIgnoreCase(label.trim())) return t;
        }
        return null;
    }
}