OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2011-2019 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.
 */
 
 /*
 * Créé le 6 mars 2012
 */
package org.openconcerto.erp.preferences;

import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.ui.preferences.JavaPrefPreferencePanel;
import org.openconcerto.ui.preferences.PrefView;
import org.openconcerto.utils.PrefType;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JCheckBox;

public class GestionCommercialeGlobalPreferencePanel extends JavaPrefPreferencePanel {
    public static String TRANSFERT_REF = "TransfertRef";
    public static String COMMANDE_FOURNISSEUR_EN_COURS = "CommandeFournisseurEncours";
    public static String TRANSFERT_MULTI_REF = "TransfertMultiRef";
    public static String TRANSFERT_NO_REF = "TransfertNoRef";
    public static String ACOMPTE_DEVIS = "AcompteDevis";
    public static String ORDER_PACKAGING_MANAGEMENT = "OrderPackagingManagement";
    public static String ADDRESS_SPEC = "AddressSpec";
    public static String CATEGORIE_COMPTABLE_SPEC = "CategorieComptableSpec";
    public static String GESTION_TIMBRE_FISCAL = "GestionTimbreFiscal";
    public static String TAUX_TIMBRE_FISCAL = "TauxTimbreFiscal";
    public static String BARCODE_INSERTION = "BarcodeInsertion";
    public static String CREATE_ECR_CHQ = "CreateEcritureCheque";
    public static String CHIFFRAGE_COMMANDE_CLIENT = "ChiffrageCmdClient";
    public static String IMPUT_ECART = "ImputEcart";
    public static String FRAIS_DOCUMENT = "GestionFraisDocuments";
    public static String COMPTE_CLIENT_AUTO = "CompteClientAuto";
    public static String FACTURE_PREVISIONNELLE = "FacturePrevisionnelle";
    public static String TRANSFERT_AUTOMATIQUE = "Tr_Automatique";
    public static final String POURCENT_RG = "PourcentRG";
    public static final String DEVIS_VALIDITE_JOURS = "DevisValiditeJours";
    public static final String ECRITURE_FACTURE_REF_LIBELLE = "RefFactureEcritureLibelle";

    public GestionCommercialeGlobalPreferencePanel() {
        super("Gestion des pièces commerciales", null);
        setPrefs(new SQLPreferences(((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete()));
    }

    @Override
    protected void addViews() {
        PrefView<Boolean> viewCompteClientAuto = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Créer les comptes clients en automatique à la création", COMPTE_CLIENT_AUTO);
        viewCompteClientAuto.setDefaultValue(Boolean.FALSE);
        this.addView(viewCompteClientAuto);

        PrefView<Boolean> viewTransfert = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Transférer les numéros des pièces commeriales en tant que référence", TRANSFERT_REF);
        viewTransfert.setDefaultValue(Boolean.TRUE);
        this.addView(viewTransfert);

        PrefView<Boolean> viewMultiTransfert = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Transférer les numéros des pièces commerciales dans le corps", TRANSFERT_MULTI_REF);
        viewMultiTransfert.setDefaultValue(Boolean.FALSE);
        this.addView(viewMultiTransfert);

        PrefView<Boolean> viewNo = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Ne pas transférer les numéros des pièces commerciales", TRANSFERT_NO_REF);
        viewNo.setDefaultValue(Boolean.FALSE);
        this.addView(viewNo);

        PrefView<Boolean> orderPackaging = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Gérer la préparation des commandes clients", ORDER_PACKAGING_MANAGEMENT);
        orderPackaging.setDefaultValue(Boolean.TRUE);
        this.addView(orderPackaging);

        PrefView<Boolean> orderPackagingTrAuto = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Activer les options de transferts automatique", TRANSFERT_AUTOMATIQUE);
        orderPackagingTrAuto.setDefaultValue(Boolean.FALSE);
        this.addView(orderPackagingTrAuto);

        PrefView<Boolean> orderQuoting = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Gérer le chiffrage détaillés des commandes clients", CHIFFRAGE_COMMANDE_CLIENT);
        orderQuoting.setDefaultValue(Boolean.FALSE);
        this.addView(orderQuoting);

        PrefView<Boolean> cmdEnCours = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Activer la gestion des commandes fournisseurs en cours", COMMANDE_FOURNISSEUR_EN_COURS);
        cmdEnCours.setDefaultValue(Boolean.FALSE);
        this.addView(cmdEnCours);

        PrefView<Boolean> viewAcompteDevis = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Gérer les acomptes sur devis", ACOMPTE_DEVIS);
        viewAcompteDevis.setDefaultValue(Boolean.FALSE);
        this.addView(viewAcompteDevis);

        PrefView<Boolean> viewPrev = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Activer la gestion des factures prévisionnelles", FACTURE_PREVISIONNELLE);
        viewPrev.setDefaultValue(Boolean.FALSE);
        this.addView(viewPrev);

        PrefView<Boolean> addressSpec = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Afficher les sélecteurs d'adresse spécifique", ADDRESS_SPEC);
        addressSpec.setDefaultValue(Boolean.TRUE);
        this.addView(addressSpec);

        PrefView<Boolean> catComptableSpec = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Afficher les sélecteurs de catégorie comptable spécifique", CATEGORIE_COMPTABLE_SPEC);
        catComptableSpec.setDefaultValue(Boolean.FALSE);
        this.addView(catComptableSpec);

        PrefView<Boolean> gestTimbreFisc = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Activer la gestion du timbre fiscal", GESTION_TIMBRE_FISCAL);
        gestTimbreFisc.setDefaultValue(Boolean.FALSE);
        this.addView(gestTimbreFisc);

        PrefView<Double> tauxTimbreFisc = new PrefView<Double>(PrefType.DOUBLE_TYPE, "Taux du timbre fiscal", TAUX_TIMBRE_FISCAL);
        tauxTimbreFisc.setDefaultValue(Double.valueOf(1));
        this.addView(tauxTimbreFisc);

        PrefView<Boolean> ecoColumns = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Afficher les colonnes éco-contributions", AbstractArticleItemTable.SHOW_ECO_CONTRIBUTION_COLUMNS);
        ecoColumns.setDefaultValue(Boolean.FALSE);
        this.addView(ecoColumns);

        PrefView<Boolean> fraisDoc = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Gérer des frais sur la création des documents clients", FRAIS_DOCUMENT);
        fraisDoc.setDefaultValue(Boolean.FALSE);
        this.addView(fraisDoc);

        PrefView<Boolean> ecoTotal = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Afficher le total de l'éco-contribution", AbstractArticleItemTable.SHOW_TOTAL_ECO_CONTRIBUTION);
        ecoTotal.setDefaultValue(Boolean.FALSE);
        this.addView(ecoTotal);

        PrefView<Boolean> barcodeInsert = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Insérer des lignes dans le corps avec la douchette", BARCODE_INSERTION);
        barcodeInsert.setDefaultValue(Boolean.FALSE);
        this.addView(barcodeInsert);

        PrefView<Boolean> createEcrChq = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Créer les écritures comptables à la réception des chèques clients", CREATE_ECR_CHQ);
        createEcrChq.setDefaultValue(Boolean.TRUE);
        this.addView(createEcrChq);

        PrefView<Boolean> createEcrImput = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Imputer les écarts de calcul dans le compte 758", IMPUT_ECART);
        createEcrImput.setDefaultValue(Boolean.TRUE);
        this.addView(createEcrImput);

        final PrefView<Boolean> rg = new PrefView<>(PrefType.BOOLEAN_TYPE, "Activer la gestion des pourcentages de retenue de garantie", POURCENT_RG);
        rg.setDefaultValue(Boolean.FALSE);
        this.addView(rg);

        final PrefView<Integer> devisJours = new PrefView<>(PrefType.INT_TYPE, "Nombre de jours de validité des devis", DEVIS_VALIDITE_JOURS);
        devisJours.setDefaultValue(30);
        this.addView(devisJours);
        final PrefView<Boolean> refEcriture = new PrefView<>(PrefType.BOOLEAN_TYPE, "Inclure la référence des factures clients dans le libellé des écritures.", ECRITURE_FACTURE_REF_LIBELLE);
        refEcriture.setDefaultValue(Boolean.FALSE);
        this.addView(refEcriture);

        final JCheckBox boxMulti = (JCheckBox) viewMultiTransfert.getVW().getComp();
        final JCheckBox boxTR = (JCheckBox) viewTransfert.getVW().getComp();
        final JCheckBox boxNoTR = (JCheckBox) viewNo.getVW().getComp();
        boxNoTR.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (boxNoTR.isSelected()) {
                    boxMulti.setSelected(false);
                    boxTR.setSelected(false);
                }

            }
        });

        boxMulti.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (boxMulti.isSelected()) {
                    boxNoTR.setSelected(false);
                }

            }
        });
        boxTR.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (boxTR.isSelected()) {
                    boxNoTR.setSelected(false);
                }

            }
        });
    }
}