Ejemplo n.º 1
0
  private static void updateMultiBase() {
    // Calcul automatique du ht des saisies de vente avec facture

    System.err.println("Start");
    // on recupere les differentes bases
    ComptaPropsConfiguration instance = ComptaPropsConfiguration.create();
    Configuration.setInstance(instance);
    SQLBase base = Configuration.getInstance().getBase();
    SQLTable tableBase = base.getTable("SOCIETE_COMMON");

    SQLSelect sel = new SQLSelect(base, false);
    sel.addSelect(tableBase.getField("DATABASE_NAME"));

    List listBasesNX =
        (List)
            Configuration.getInstance()
                .getBase()
                .getDataSource()
                .execute(sel.asString(), new ArrayListHandler());

    // for (int i = 0; i < listBasesNX.size(); i++) {
    // Object[] tmp = (Object[]) listBasesNX.get(i);
    //
    // setOrdreComptePCE(tmp[0].toString());
    // }

    reOrderCompteID("Default");
    System.err.println("End");
  }
Ejemplo n.º 2
0
  public static void addUndefined(SQLBase base) {
    Set<String> tableNames = base.getTableNames();
    for (String tableName : tableNames) {
      SQLTable table = base.getTable(tableName);
      SQLField fieldPrimaryKey = table.getKey();

      if (fieldPrimaryKey != null
          && fieldPrimaryKey.getType().getJavaType().getSuperclass() != null
          && fieldPrimaryKey.getType().getJavaType().getSuperclass() == Number.class) {

        String patch =
            "INSERT INTO \"" + tableName + "\"(\"" + fieldPrimaryKey.getName() + "\") VALUES (1)";
        base.execute(patch);
      }
    }
  }
Ejemplo n.º 3
0
  public void loadAsynchronous() {

    // On recupere les differents journaux
    SQLTable journalTable = base.getTable("JOURNAL");
    // SQLSelect selJournal = new SQLSelect(base);
    //
    // selJournal.addSelect(journalTable.getField("ID"));
    // selJournal.addSelect(journalTable.getField("NOM"));
    // selJournal.addSelect(journalTable.getField("CODE"));
    //
    // selJournal.addRawOrder("\"JOURNAL\".\"NOM\"");
    //
    // String reqJournal = selJournal.asString();
    // Object obJournal = base.getDataSource().execute(reqJournal, new ArrayListHandler());
    //
    // List myListJournal = (List) obJournal;
    //
    // if (myListJournal.size() != 0) {

    List<SQLRow> liste =
        SQLBackgroundTableCache.getInstance().getCacheForTable(journalTable).getRows();
    for (int k = 0; k < liste.size(); k++) {
      SQLRow row = liste.get(k);
      fireIsLoading(true);
      final Journal jrnlTmp = new Journal(row.getID(), row.getString("NOM"), row.getString("CODE"));
      new SwingWorker<JPanel, Object>() {
        @Override
        protected JPanel doInBackground() throws Exception {

          final JPanel initJournalPanel = initJournalPanel(jrnlTmp);
          return initJournalPanel;
        }

        @Override
        protected void done() {
          JPanel initJournalPanel;
          try {
            initJournalPanel = get();

            initJournalPanel.setOpaque(false);
            JScrollPane scroll = new JScrollPane(initJournalPanel);
            scroll.setBorder(null);
            scroll.setOpaque(false);
            scroll.getViewport().setOpaque(false);
            EtatJournauxPanel.this.tabbedJournaux.addTab(jrnlTmp.getNom(), scroll);
          } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (ExecutionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          fireIsLoading(false);
          super.done();
        }
      }.execute();
    }
  }
Ejemplo n.º 4
0
  @SuppressWarnings("unchecked")
  public static final Map<String, Map<Integer, String>> getMapAllStyle() {
    Map<String, Map<Integer, String>> m = new HashMap<String, Map<Integer, String>>();
    SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLSelect sel = new SQLSelect(base);
    sel.addSelect(base.getField("STYLE.NOM"));
    String req = sel.asString();
    List<Map<String, Object>> l = base.getDataSource().execute(req);

    for (Map<String, Object> map : l) {

      Object o = map.get("NOM");
      String s = (o == null) ? null : o.toString();
      m.put(s, null);
    }
    m.put("BlankStyle", null);
    return m;
  }
Ejemplo n.º 5
0
  /**
   * Check si la table posséde au moins une ligne avec un ordre different null le cas cas échéant le
   * crée
   *
   * @param base
   */
  public static void correct(SQLBase base) {
    Set<String> tableNames = base.getTableNames();
    for (String tableName : tableNames) {

      if (base.getTable(tableName).contains("ORDRE")) {
        SQLSelect select = new SQLSelect(base);
        select.addSelect("ORDRE");
        List l = base.getDataSource().execute(select.asString());
        if (l == null || l.size() == 0) {
          SQLRowValues rowVals = new SQLRowValues(base.getTable(tableName));
          rowVals.put("ORDRE", 0);
          try {
            rowVals.commit();
          } catch (SQLException e) {

            e.printStackTrace();
          }
        }
      }
    }
    // TODO Checker que toutes les tables sont dans FWK_UNDEFINED_ID
  }
Ejemplo n.º 6
0
  public static void setOrder(SQLBase base) {
    Set<String> tableNames = base.getTableNames();
    for (String tableName : tableNames) {
      SQLTable table = base.getTable(tableName);
      // SQLField fieldPrimaryKey = table.getKey();
      SQLField field = table.getOrderField();

      if (field != null) {
        base.execute(
            "ALTER TABLE \""
                + tableName
                + "\" ALTER COLUMN \""
                + field.getName()
                + "\" SET DEFAULT 0;");
        base.execute(
            "ALTER TABLE \""
                + tableName
                + "\" ALTER COLUMN \""
                + field.getName()
                + "\" SET NOT NULL;");
      }
    }
  }
  private int[] getMouvement(int idPiece) {

    int[] idS = null;

    SQLBase b = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLTable tableMvt = b.getTable("MOUVEMENT");

    SQLSelect sel = new SQLSelect(b);
    sel.addSelect(tableMvt.getField("NUMERO"));
    sel.setWhere(tableMvt.getField("ID_PIECE"), "=", idPiece);

    List l = (List) b.getDataSource().execute(sel.asString(), new ArrayListHandler());

    if (l.size() > 0) {
      idS = new int[l.size()];
    }

    for (int i = 0; i < l.size(); i++) {
      Object[] tmp = (Object[]) l.get(i);
      idS[i] = Integer.parseInt(tmp[0].toString());
    }

    return idS;
  }
  public SuppressionEcrituresPanel(final int idMvt) {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.weightx = 1;
    SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLTable tableMouvement = base.getTable("MOUVEMENT");
    SQLRow rowMvt = tableMouvement.getRow(idMvt);
    JLabel label = new JLabel("Vous allez supprimer la piéce n°" + rowMvt.getInt("ID_PIECE"));
    JLabelWarning warning = new JLabelWarning();
    JPanel panelLabel = new JPanel();
    panelLabel.add(warning);
    panelLabel.add(label);

    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(panelLabel, c);

    // TODO afficher les numeros de mouvement implique
    int[] idS = getMouvement(rowMvt.getInt("ID_PIECE"));
    if (idS == null) {
      ExceptionHandler.handle(
          "Aucun mouvement associé à la piéce n°"
              + ((rowMvt != null) ? rowMvt.getInt("ID_PIECE") : "mouvement nul"));
    } else {
      StringBuffer s = new StringBuffer();
      s.append("Elle est composée par les mouvements : (");
      JLabel labelMouv = new JLabel();
      // c.gridwidth = 1;
      c.gridy++;
      c.gridx = 0;
      this.add(labelMouv, c);
      s.append(idS[0]);
      for (int i = 1; i < idS.length; i++) {

        s.append(", ");
        s.append(idS[i]);
      }
      s.append(')');
      labelMouv.setText(s.toString());
    }

    JButton buttonOK = new JButton("OK");
    JButton buttonCancel = new JButton("Annuler");

    c.gridwidth = 1;
    c.gridy++;
    c.gridx = 0;
    this.add(buttonOK, c);
    c.gridx++;
    this.add(buttonCancel, c);

    buttonOK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            EcritureSQLElement elt =
                (EcritureSQLElement)
                    Configuration.getInstance().getDirectory().getElement("ECRITURE");
            elt.archiveMouvement(idMvt);
            ((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose();
          }
        });
    buttonCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose();
          }
        });
  }
Ejemplo n.º 9
0
public class Map3310 extends Thread {

  private Map<String, Object> m;
  private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
  private JProgressBar bar;
  private Date dateDebut, dateFin;

  private static final SQLBase base =
      ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
  private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
  private static final SQLTable tableCompte =
      Configuration.getInstance().getRoot().findTable("COMPTE_PCE");
  private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte);
  SommeCompte sommeCompte;

  private static String getVille(final String name) {

    Ville ville = Ville.getVilleFromVilleEtCode(name);
    if (ville == null) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              JOptionPane.showMessageDialog(
                  null,
                  "La ville "
                      + "\""
                      + name
                      + "\""
                      + " est introuvable! Veuillez corriger l'erreur!");
            }
          });
      return null;
    }
    return ville.getName();
  }

  private static String getVilleCP(String name) {
    Ville ville = Ville.getVilleFromVilleEtCode(name);
    if (ville == null) {

      return null;
    }
    return ville.getCodepostal();
  }

  // TODO if value = 0.0 ne pas mettre -0.0

  public void run() {

    SQLRow rowPrefCompte = tablePrefCompte.getRow(2);
    this.rowPrefCompteVals.loadAbsolutelyAll(rowPrefCompte);
    // TVA Coll
    int idCompteTVACol = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_VENTE");
    if (idCompteTVACol <= 1) {
      String compte;
      try {
        compte = ComptePCESQLElement.getComptePceDefault("TVACollectee");
        idCompteTVACol = ComptePCESQLElement.getId(compte);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    SQLRow rowCompteTVACol = tableCompte.getRow(idCompteTVACol);

    // TVA Ded
    int idCompteTVADed = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_ACHAT");
    if (idCompteTVADed <= 1) {
      try {
        String compte = ComptePCESQLElement.getComptePceDefault("TVADeductible");
        idCompteTVADed = ComptePCESQLElement.getId(compte);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    SQLRow rowCompteTVADed = tableCompte.getRow(idCompteTVADed);

    // TVA intracomm
    int idCompteTVAIntra = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_INTRA");
    if (idCompteTVAIntra <= 1) {
      try {
        String compte = ComptePCESQLElement.getComptePceDefault("TVAIntraComm");
        idCompteTVAIntra = ComptePCESQLElement.getId(compte);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    SQLRow rowCompteTVAIntra = tableCompte.getRow(idCompteTVAIntra);

    // Achats intracomm
    int idCompteAchatsIntra = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_ACHAT_INTRA");
    if (idCompteAchatsIntra <= 1) {
      try {
        String compte = ComptePCESQLElement.getComptePceDefault("AchatsIntra");
        idCompteAchatsIntra = ComptePCESQLElement.getId(compte);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    SQLRow rowCompteAchatIntra = tableCompte.getRow(idCompteAchatsIntra);

    // TVA immo
    int idCompteTVAImmo = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_IMMO");
    if (idCompteTVAImmo <= 1) {
      try {
        String compte = ComptePCESQLElement.getComptePceDefault("TVAImmo");
        idCompteTVAImmo = ComptePCESQLElement.getId(compte);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    SQLRow rowCompteTVAImmo = tableCompte.getRow(idCompteTVAImmo);

    PdfGenerator_3310 p = new PdfGenerator_3310();
    this.m = new HashMap<String, Object>();

    long v010 = -this.sommeCompte.soldeCompte(70, 70, true, this.dateDebut, this.dateFin);
    this.m.put("A01", GestionDevise.round(v010));

    // long vA02 = this.sommeCompte.soldeCompte(70, 70, true, this.dateDebut, this.dateFin);
    this.m.put("A02", "");
    long tvaIntra =
        -this.sommeCompte.sommeCompteFils(
            rowCompteTVAIntra.getString("NUMERO"), new Date(100, 0, 1), this.dateFin);
    long achatsIntra =
        this.sommeCompte.sommeCompteFils(
            rowCompteAchatIntra.getString("NUMERO"), this.dateDebut, this.dateFin);
    this.m.put("A03", GestionDevise.round(achatsIntra));
    this.m.put("A04", "");
    this.m.put("A05", "");
    this.m.put("A06", "");
    this.m.put("A07", "");

    long tvaCol =
        -this.sommeCompte.sommeCompteFils(
                rowCompteTVACol.getString("NUMERO"), new Date(100, 0, 1), this.dateFin)
            + tvaIntra;
    this.m.put("B08", GestionDevise.round(tvaCol));
    this.m.put("B08HT", GestionDevise.round(Math.round(tvaCol / 0.196)));
    this.m.put("B09", "");
    this.m.put("B09HT", "");
    this.m.put("B09B", "");
    this.m.put("B09BHT", "");

    this.m.put("B10", "");
    this.m.put("B10HT", "");
    this.m.put("B11", "");
    this.m.put("B11HT", "");
    this.m.put("B12", "");
    this.m.put("B12HT", "");
    this.m.put("B13", "");
    this.m.put("B13HT", "");
    this.m.put("B14", "");
    this.m.put("B14HT", "");

    this.m.put("B15", "");
    this.m.put("B16", GestionDevise.round(tvaCol));
    this.m.put("B17", GestionDevise.round(tvaIntra));
    this.m.put("B18", "");
    long tvaImmo =
        this.sommeCompte.sommeCompteFils(
            rowCompteTVAImmo.getString("NUMERO"), new Date(100, 0, 1), this.dateFin);
    this.m.put("B19", GestionDevise.round(tvaImmo));

    long tvaAutre =
        this.sommeCompte.sommeCompteFils(
            rowCompteTVADed.getString("NUMERO"), new Date(100, 0, 1), this.dateFin);
    this.m.put("B20", GestionDevise.round(tvaAutre));
    this.m.put("B21", "");
    this.m.put("B22", "");
    this.m.put("B23", "");
    long tvaDed = tvaAutre + tvaImmo;
    this.m.put("B24", GestionDevise.round(tvaDed));

    this.m.put("C25", "");
    this.m.put("C26", "");
    this.m.put("C27", "");
    this.m.put("C28", GestionDevise.round(tvaCol - tvaDed));
    this.m.put("C29", "");
    this.m.put("C30", "");
    this.m.put("C31", "");
    this.m.put("C32", GestionDevise.round(tvaCol - tvaDed));

    p.generateFrom(this.m);

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            Map3310.this.bar.setValue(95);
          }
        });

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            String file =
                TemplateNXProps.getInstance().getStringProperty("Location3310PDF")
                    + File.separator
                    + String.valueOf(Calendar.getInstance().get(Calendar.YEAR))
                    + File.separator
                    + "result_3310_2.pdf";
            System.err.println(file);
            File f = new File(file);
            Gestion.openPDF(f);
            Map3310.this.bar.setValue(100);
          }
        });
  }

  public Map3310(JProgressBar bar, Date dateDeb, Date dateFin) {

    this.bar = bar;

    if (dateDeb == null && dateFin == null) {
      SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
      SQLRow rowExercice =
          Configuration.getInstance()
              .getBase()
              .getTable("EXERCICE_COMMON")
              .getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
      dateFin = (Date) rowExercice.getObject("DATE_FIN");
      dateDeb = (Date) rowExercice.getObject("DATE_DEB");
    }

    this.dateDebut = dateDeb;
    this.dateFin = dateFin;
    this.sommeCompte = new SommeCompte();
  }

  public Map3310(JProgressBar bar) {

    this(bar, null, null);
  }

  public void generateMap2033A() {
    this.start();
  }
}
Ejemplo n.º 10
0
public class PointageModel extends AbstractTableModel {

  private String[] titresCol;
  private String[] titresRow;

  private long debitPointe,
      creditPointe,
      debitNonPointe,
      creditNonPointe,
      creditSelection,
      debitSelection;

  private static final SQLBase base =
      ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
  private static final SQLTable tableEcr = base.getTable("ECRITURE");
  int idCpt;

  public PointageModel(int idCpt) {

    this.creditNonPointe = 0;
    this.creditPointe = 0;
    this.creditSelection = 0;

    this.debitNonPointe = 0;
    this.debitPointe = 0;
    this.debitSelection = 0;

    this.idCpt = idCpt;
    this.titresCol = new String[6];
    this.titresCol[0] = "Totaux";
    this.titresCol[1] = "Pointé";
    this.titresCol[2] = "Non Pointé";
    this.titresCol[3] = "Total";

    this.titresCol[4] = "Sélection";
    this.titresCol[5] = "Pointéé + sélection";

    this.titresRow = new String[3];
    this.titresRow[0] = "Débit";
    this.titresRow[1] = "Crédit";
    this.titresRow[2] = "Solde";

    updateTotauxCompte();
  }

  public void setIdCompte(int id) {
    this.idCpt = id;
    updateTotauxCompte();
    updateSelection(null);
  }

  public void updateSelection(int[] rowIndex) {
    System.err.println("Update Selection");
    this.creditSelection = 0;
    this.debitSelection = 0;

    if (rowIndex != null) {
      for (int i = 0; i < rowIndex.length; i++) {

        SQLRow row = tableEcr.getRow(rowIndex[i]);

        if (row != null) {

          // if (row.getString("POINTEE").trim().length() == 0) {
          this.debitSelection += ((Long) row.getObject("DEBIT")).longValue();
          this.creditSelection += ((Long) row.getObject("CREDIT")).longValue();
          // }
          /*
           * else {
           *
           * this.debitSelection -= row.getFloat("DEBIT"); this.creditSelection -=
           * row.getFloat("CREDIT"); }
           */
        }
      }
    }
    this.fireTableDataChanged();
  }

  public void updateTotauxCompte() {

    new SwingWorker<String, Object>() {

      @Override
      protected String doInBackground() throws Exception {

        SQLSelect sel = new SQLSelect(base);
        sel.addSelect(tableEcr.getField("CREDIT"), "SUM");
        sel.addSelect(tableEcr.getField("DEBIT"), "SUM");

        Where w = new Where(tableEcr.getField("ID_COMPTE_PCE"), "=", PointageModel.this.idCpt);
        sel.setWhere(w.and(new Where(tableEcr.getField("POINTEE"), "!=", "")));

        String reqPointee = sel.toString();

        Object obPointee = base.getDataSource().execute(reqPointee, new ArrayListHandler());

        List myListPointee = (List) obPointee;

        PointageModel.this.creditPointe = 0;
        PointageModel.this.debitPointe = 0;
        if (myListPointee.size() != 0) {

          for (int i = 0; i < myListPointee.size(); i++) {
            Object[] objTmp = (Object[]) myListPointee.get(i);

            if (objTmp[0] != null) {
              PointageModel.this.creditPointe += ((Number) objTmp[0]).longValue();
            }
            if (objTmp[1] != null) {
              PointageModel.this.debitPointe += ((Number) objTmp[1]).longValue();
            }
          }
        }

        sel.setWhere(w.and(new Where(tableEcr.getField("POINTEE"), "=", "")));
        String reqNotPointee = sel.toString();

        Object obNotPointee = base.getDataSource().execute(reqNotPointee, new ArrayListHandler());

        List myListNotPointee = (List) obNotPointee;

        PointageModel.this.creditNonPointe = 0;
        PointageModel.this.debitNonPointe = 0;
        if (myListNotPointee.size() != 0) {

          for (int i = 0; i < myListNotPointee.size(); i++) {
            Object[] objTmp = (Object[]) myListNotPointee.get(i);

            if (objTmp[0] != null) {
              PointageModel.this.creditNonPointe += ((Number) objTmp[0]).longValue();
            }

            if (objTmp[1] != null) {
              PointageModel.this.debitNonPointe += ((Number) objTmp[1]).longValue();
            }
          }
        }

        return null;
      }

      @Override
      protected void done() {

        PointageModel.this.fireTableDataChanged();
      }
    }.execute();
  }

  public String getColumnName(int column) {

    return this.titresCol[column];
  }

  public int getColumnCount() {

    return this.titresCol.length;
  }

  public int getRowCount() {

    return this.titresRow.length;
  }

  @Override
  public Class<?> getColumnClass(int columnIndex) {
    if (columnIndex == 0) {
      return String.class;
    } else {
      return Long.class;
    }
  }

  public Object getValueAt(int rowIndex, int columnIndex) {

    if (columnIndex == 0) {
      return this.titresRow[rowIndex];
    }

    if (columnIndex == 1) {
      if (rowIndex == 0) {
        return new Long(this.debitPointe);
      }
      if (rowIndex == 1) {
        return new Long(this.creditPointe);
      }
      if (rowIndex == 2) {
        return new Long(this.debitPointe - this.creditPointe);
      }
    }

    if (columnIndex == 2) {
      if (rowIndex == 0) {
        return new Long(this.debitNonPointe);
      }
      if (rowIndex == 1) {
        return new Long(this.creditNonPointe);
      }
      if (rowIndex == 2) {
        return new Long(this.debitNonPointe - this.creditNonPointe);
      }
    }

    if (columnIndex == 3) {
      if (rowIndex == 0) {
        return new Long(this.debitNonPointe + this.debitPointe);
      }
      if (rowIndex == 1) {
        return new Long(this.creditNonPointe + this.creditPointe);
      }
      if (rowIndex == 2) {
        return new Long(
            (this.debitNonPointe - this.creditNonPointe) + (this.debitPointe - this.creditPointe));
      }
    }

    if (columnIndex == 4) {
      if (rowIndex == 0) {
        return new Long(this.debitSelection);
      }
      if (rowIndex == 1) {
        return new Long(this.creditSelection);
      }
      if (rowIndex == 2) {
        return new Long(this.debitSelection - this.creditSelection);
      }
    }

    if (columnIndex == 5) {
      if (rowIndex == 0) {
        return new Long(this.debitSelection + this.debitPointe);
      }
      if (rowIndex == 1) {
        return new Long(this.creditSelection + this.creditPointe);
      }
      if (rowIndex == 2) {
        return new Long(
            this.debitSelection - this.creditSelection + this.debitPointe - this.creditPointe);
      }
    }

    return null;
  }
}
Ejemplo n.º 11
0
  /*
   * Crée un panel destiné à l'onglet de jrnl
   */
  private JPanel initJournalPanel(final Journal jrnl) {

    final JPanel panelTmp = new JPanel();
    long totalDebitJournal = 0;
    long totalCreditJournal = 0;

    panelTmp.setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    // Récupération des ecritures du journal avec le total par mois
    // SQLTable ecritureTable = base.getTable("ECRITURE");
    // SQLSelect sel = new SQLSelect(base);
    //
    // sel.addSelect(ecritureTable.getField("DATE"), "YEAR");
    // sel.addSelect(ecritureTable.getField("DATE"), "MONTH");
    // sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
    // sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
    //
    // Where w = new Where(ecritureTable.getField("ID_JOURNAL"), "=", jrnl.getId());
    //
    // sel.setWhere(w);
    //
    // sel.setDistinct(true);
    //
    // String req = sel.asString() + " GROUP BY YEAR(ECRITURE.DATE), MONTH(ECRITURE.DATE) ORDER
    // BY ECRITURE.DATE";

    String req =
        "SELECT DISTINCT EXTRACT(YEAR FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"),"
            + " SUM(\""
            + baseName
            + "\".\"ECRITURE\".\"DEBIT\"), "
            + "SUM(\""
            + baseName
            + "\".\"ECRITURE\".\"CREDIT\")"
            + " FROM \""
            + baseName
            + "\".\"ECRITURE\" "
            + "WHERE (\""
            + baseName
            + "\".\"ECRITURE\".\"ID\" != 1) "
            + "AND ((\""
            + baseName
            + "\".\"ECRITURE\".\"ARCHIVE\" = 0) "
            + "AND (\""
            + baseName
            + "\".\"ECRITURE\".\"ID_JOURNAL\" = "
            + jrnl.getId()
            + ")) "
            + "GROUP BY EXTRACT(YEAR FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\") "
            + "ORDER BY EXTRACT(YEAR FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \""
            + baseName
            + "\".\"ECRITURE\".\"DATE\")";
    System.out.println(req);

    Object ob = base.getDataSource().execute(req, new ArrayListHandler());

    List myList = (List) ob;

    // System.err.println("TEST DATE " + t);

    if (myList.size() != 0) {

      for (int i = 0; i < myList.size(); i++) {

        Object[] objTmp = (Object[]) myList.get(i);

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DATE, 1);
        int month = (new Double(objTmp[1].toString()).intValue() - 1);
        System.err.println(jrnl.getNom() + " SET MONTH " + month);
        cal.set(Calendar.MONTH, month);
        System.err.println(month + " = " + cal.getTime());

        cal.set(Calendar.YEAR, new Double(objTmp[0].toString()).intValue());

        long debitMois = ((Number) objTmp[2]).longValue();
        long creditMois = ((Number) objTmp[3]).longValue();

        c.gridwidth = GridBagConstraints.REMAINDER;
        final JPanel creerJournalMoisPanel =
            creerJournalMoisPanel(cal.getTime(), debitMois, creditMois, jrnl);
        creerJournalMoisPanel.setOpaque(false);
        panelTmp.add(creerJournalMoisPanel, c);

        c.gridy++;

        totalDebitJournal += debitMois;
        totalCreditJournal += creditMois;
      }
    }
    c.gridx = 0;
    c.weighty = 1;
    c.gridwidth = 1;
    final JLabel label = new JLabel("Journal " + jrnl.getNom());
    label.setOpaque(false);
    panelTmp.add(label, c);
    c.gridx = GridBagConstraints.RELATIVE;
    panelTmp.add(
        new JLabel(" Total débit : " + GestionDevise.currencyToString(totalDebitJournal)), c);
    panelTmp.add(
        new JLabel(" Total crédit : " + GestionDevise.currencyToString(totalCreditJournal)), c);

    return panelTmp;
  }