OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 19 → Rev 21

/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ExerciceCommonSQLElement.java
19,6 → 19,7
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.checks.ValidState;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
120,8 → 121,9
return vals;
}
 
public boolean isValidated() {
return (super.isValidated() && (this.dateDeb.getValue()).before(this.dateFin.getValue()));
@Override
public synchronized ValidState getValidState() {
return super.getValidState().and(ValidState.createCached(this.dateDeb.getValue().before(this.dateFin.getValue()), "Date de début après date de fin"));
}
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/SaisieKmSQLElement.java
30,11 → 30,14
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.warning.JLabelWarning;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.checks.ValidState;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.Dimension;
203,121 → 206,18
private boolean isCompteExist = false;
private boolean allLineValid = true;
private SaisieKmItemTable tableKm;
private JLabel labelMotifWarning;
final JLabel labelWarning = new JLabelWarning();
private final JLabel labelMotifWarning = new JLabelWarning();
private SQLElement eltKmItem = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
private SQLRowValues defaultEcritureRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.eltKmItem.getTable()));
 
// depends on inner table, at creation it's empty and thus valid
private ValidState validState = ValidState.getTrueInstance();
 
private TableModelListener tableListener = new TableModelListener() {
 
public void tableChanged(TableModelEvent e) {
 
SaisieKmComponent.this.totalCred = 0;
SaisieKmComponent.this.totalDeb = 0;
long totalCredWithNoValid = 0;
long totalDebWithNoValid = 0;
SaisieKmComponent.this.isCompteExist = true;
SaisieKmComponent.this.allLineValid = true;
for (int i = 0; i < SaisieKmComponent.this.model.getRowCount(); i++) {
long totalLine = 0;
boolean b = SaisieKmComponent.this.model.isRowValid(i);
Long fTc = ((Long) SaisieKmComponent.this.model.getValueAt(i, SaisieKmComponent.this.creditIndex));
Long fTd = ((Long) SaisieKmComponent.this.model.getValueAt(i, SaisieKmComponent.this.debitIndex));
String numCpt = SaisieKmComponent.this.model.getValueAt(i, SaisieKmComponent.this.model.getColumnIndexForElement(SaisieKmComponent.this.tableKm.getNumeroCompteElement()))
.toString();
SaisieKmComponent.this.isCompteExist = SaisieKmComponent.this.isCompteExist && ComptePCESQLElement.isExist(numCpt);
if (fTc != 0 && fTd != 0) {
return;
SaisieKmComponent.this.tableChanged(e);
}
 
if (fTc != null) {
if (b) {
SaisieKmComponent.this.totalCred += fTc.longValue();
}
totalCredWithNoValid += fTc.longValue();
totalLine += fTc.longValue();
}
 
if (fTd != null) {
if (b) {
SaisieKmComponent.this.totalDeb += fTd.longValue();
}
totalDebWithNoValid += fTd.longValue();
totalLine += fTd.longValue();
}
 
final boolean d = totalLine != 0;
SaisieKmComponent.this.tableKm.setRowDeviseValidAt(d, i);
if (!d) {
SaisieKmComponent.this.allLineValid = false;
}
}
SaisieKmComponent.this.tableKm.revalidate();
SaisieKmComponent.this.tableKm.repaint();
// totalCred = (float) new PrixHT(totalCred).getValue();
// totalDeb = (float) new PrixHT(totalDeb).getValue();
 
SaisieKmComponent.this.labelTotalCredit.setText(GestionDevise.currencyToString(SaisieKmComponent.this.totalCred));
SaisieKmComponent.this.labelTotalDebit.setText(GestionDevise.currencyToString(SaisieKmComponent.this.totalDeb));
 
long diff = SaisieKmComponent.this.totalDeb - SaisieKmComponent.this.totalCred;
long diffWithNoValid = totalDebWithNoValid - totalCredWithNoValid;
// System.err.println("Valid ___ " + diff + " NO VALID _____ " +
// diffWithNoValid);
if (diff == 0) {
SaisieKmComponent.this.labelMotifWarning.setVisible(false);
labelWarning.setVisible(false);
} else {
if (diff > 0) {
SaisieKmComponent.this.labelMotifWarning.setText("Le solde des écritures n'est pas nul! Il manque " + GestionDevise.currencyToString(diff) + " en crédit.");
 
} else {
 
SaisieKmComponent.this.labelMotifWarning.setText("Le solde des écritures n'est pas nul! Il manque " + GestionDevise.currencyToString(diff) + " en débit.");
 
}
SaisieKmComponent.this.labelMotifWarning.setVisible(true);
labelWarning.setVisible(true);
}
if (diffWithNoValid != 0) {
if (diffWithNoValid > 0) {
SaisieKmComponent.this.defaultEcritureRowVals.put("DEBIT", Long.valueOf(0));
SaisieKmComponent.this.defaultEcritureRowVals.put("CREDIT", Long.valueOf(diffWithNoValid));
if (SaisieKmComponent.this.model.isLastRowValid()) {
SaisieKmComponent.this.tableKm.getModel().addRow(new SQLRowValues(SaisieKmComponent.this.defaultEcritureRowVals));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (SaisieKmComponent.this.model.getRowCount() > 0) {
SaisieKmComponent.this.tableKm.editCellAt(SaisieKmComponent.this.model.getRowCount() - 1, 0);
}
}
});
}
} else {
SaisieKmComponent.this.defaultEcritureRowVals.put("DEBIT", Long.valueOf(-diffWithNoValid));
SaisieKmComponent.this.defaultEcritureRowVals.put("CREDIT", Long.valueOf(0));
if (SaisieKmComponent.this.model.isLastRowValid()) {
SaisieKmComponent.this.tableKm.getModel().addRow(new SQLRowValues(SaisieKmComponent.this.defaultEcritureRowVals));
 
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (SaisieKmComponent.this.model.getRowCount() > 0) {
SaisieKmComponent.this.tableKm.editCellAt(SaisieKmComponent.this.model.getRowCount() - 1, 0);
}
}
});
 
// System.err.println("RowValid " + e.getType());
} else {
System.err.println(e.getType());
}
}
} else {
SaisieKmComponent.this.defaultEcritureRowVals.put("DEBIT", Long.valueOf(0));
SaisieKmComponent.this.defaultEcritureRowVals.put("CREDIT", Long.valueOf(0));
}
fireValidChange();
}
};
 
public SaisieKmComponent() {
420,18 → 320,12
 
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
labelWarning.setHorizontalAlignment(SwingConstants.RIGHT);
labelWarning.setVisible(false);
this.add(labelWarning, c);
 
this.labelMotifWarning = new JLabel("Le solde des écritures n'est pas nul!");
c.gridwidth = 2;
this.labelMotifWarning.setText("Le solde des écritures n'est pas nul!");
DefaultGridBagConstraints.lockMinimumSize(this.labelMotifWarning);
c.gridx++;
c.gridwidth = 1;
c.weightx = 0;
this.add(this.labelMotifWarning, c);
this.labelMotifWarning.setVisible(false);
c.gridwidth = 1;
 
c.gridy--;
c.gridx = 2;
470,7 → 364,7
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
SaisieKmComponent.this.tableKm.setCreateAutoActive(SaisieKmComponent.this.checkCreateCompte.isSelected());
fireValidChange();
updateValidState();
}
});
 
479,17 → 373,16
DefaultGridBagConstraints.lockMinimumSize(this.comboJrnl);
}
 
public synchronized boolean isValidated() {
 
return ((super.isValidated()) && ((this.totalDeb - this.totalCred) == 0) && (this.checkCreateCompte.isSelected() || (!this.checkCreateCompte.isSelected() && this.isCompteExist)))
&& this.allLineValid;
}
 
public int insert(SQLRow order) {
int id = super.insert(order);
final int id = super.insert(order);
 
this.tableKm.updateField("ID_SAISIE_KM", id);
 
try {
SQLUtils.executeAtomic(Configuration.getInstance().getSystemRoot().getDataSource(), new SQLUtils.SQLFactory<Object>() {
@Override
public Object create() throws SQLException {
 
GenerationMvtSaisieKm gen = new GenerationMvtSaisieKm(id);
int idMvt = gen.genereMouvement();
 
496,19 → 389,26
// maj de l'id du mouvement correspondant
SQLRowValues valEcriture = new SQLRowValues(SaisieKmSQLElement.this.getTable());
valEcriture.put("ID_MOUVEMENT", new Integer(idMvt));
try {
if (valEcriture.getInvalid() == null) {
 
valEcriture.update(id);
}
} catch (SQLException e) {
System.err.println("Erreur à l'insertion dans la table " + valEcriture.getTable().getName() + " : " + e);
e.printStackTrace();
}
 
SQLElement eltMvt = Configuration.getInstance().getDirectory().getElement("MOUVEMENT");
SQLRow rowMvt = eltMvt.getTable().getRow(idMvt);
JOptionPane.showMessageDialog(this, "Numéro de mouvement associé : " + rowMvt.getObject("NUMERO"));
final SQLRow rowMvt = eltMvt.getTable().getRow(idMvt);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(SaisieKmComponent.this, "Numéro de mouvement associé : " + rowMvt.getObject("NUMERO"));
}
});
return null;
}
});
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
ExceptionHandler.handle("Erreur lors de la création des écritures associées à la saisie au kilometre.", exn);
}
return id;
}
 
558,10 → 458,12
}
 
public void updateEcriture() {
try {
SQLUtils.executeAtomic(Configuration.getInstance().getSystemRoot().getDataSource(), new SQLUtils.SQLFactory<Object>() {
@Override
public Object create() throws SQLException {
 
SQLTable ecritureTable = getTable().getBase().getTable("ECRITURE");
SQLElement assocElt = Configuration.getInstance().getDirectory().getElement("ASSOCIATION_ANALYTIQUE");
 
final SQLRow rowSaisieKm = getElement().getTable().getRow(getSelectedID());
List<SQLRow> myListDevisItem = rowSaisieKm.getReferentRows(getTable().getBase().getTable("SAISIE_KM_ELEMENT"));
 
628,29 → 530,6
}
}
 
final List<SQLRow> referentRowsAssocEcr = rowElement.getForeign("ID_ECRITURE").getReferentRows(assocElt.getTable());
for (SQLRow sqlRow : referentRowsAssocEcr) {
try {
assocElt.archive(sqlRow.getID());
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
 
for (SQLRow sqlRow : rowElement.getReferentRows(assocElt.getTable())) {
SQLRowValues rowVals = sqlRow.asRowValues();
rowVals.putEmptyLink("ID_SAISIE_KM_ELEMENT");
rowVals.put("ID_ECRITURE", rowElement.getInt("ID_ECRITURE"));
rowVals.setID(SQLRow.NONEXISTANT_ID);
try {
rowVals.commit();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
 
List<SQLRow> l = new ArrayList<SQLRow>(listEcr);
for (SQLRow sqlRow : l) {
if (sqlRow.getID() == rowElement.getInt("ID_ECRITURE")) {
673,6 → 552,138
}
}
}
return null;
}
});
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
ExceptionHandler.handle("Erreur lors de la mise à jour des écritures associées à la saisie au kilometre.", exn);
}
}
 
@Override
public synchronized ValidState getValidState() {
return super.getValidState().and(this.validState);
}
 
private void updateValidState() {
ValidState state = ValidState.create(!this.labelMotifWarning.isVisible(), this.labelMotifWarning.getText());
if (!this.isCompteExist && !this.checkCreateCompte.isSelected())
state = state.and(ValidState.createCached(false, "Certains comptes n'existent pas"));
if (!this.allLineValid)
state = state.and(ValidState.createCached(false, "Certaines lignes n'ont pas de crédit ni de débit"));
this.setValidState(state);
}
 
private void setValidState(final ValidState state) {
if (!state.equals(this.validState)) {
this.validState = state;
fireValidChange();
}
}
 
private void setTotals(final long totalCred, final long totalDeb) {
this.totalCred = totalCred;
this.totalDeb = totalDeb;
this.labelTotalCredit.setText(GestionDevise.currencyToString(this.totalCred));
this.labelTotalDebit.setText(GestionDevise.currencyToString(this.totalDeb));
 
final long diff = this.totalDeb - this.totalCred;
final String reason;
if (diff == 0) {
reason = null;
} else if (diff > 0) {
reason = "Le solde des écritures n'est pas nul! Il manque " + GestionDevise.currencyToString(diff) + " en crédit.";
} else {
reason = "Le solde des écritures n'est pas nul! Il manque " + GestionDevise.currencyToString(diff) + " en débit.";
}
this.labelMotifWarning.setVisible(reason != null);
if (reason != null)
this.labelMotifWarning.setText(reason);
}
 
private void tableChanged(TableModelEvent e) {
long totalCred = 0;
long totalDeb = 0;
long totalCredWithNoValid = 0;
long totalDebWithNoValid = 0;
boolean isCompteExist = true;
boolean allLineValid = true;
for (int i = 0; i < this.model.getRowCount(); i++) {
final boolean rowValid = this.model.isRowValid(i);
final long fTc = ((Number) this.model.getValueAt(i, this.creditIndex)).longValue();
final long fTd = ((Number) this.model.getValueAt(i, this.debitIndex)).longValue();
String numCpt = this.model.getValueAt(i, this.model.getColumnIndexForElement(this.tableKm.getNumeroCompteElement())).toString();
isCompteExist &= ComptePCESQLElement.isExist(numCpt);
// see SaisieKmItemTable RowValuesTableModel, one of the values will be zeroed
if (fTc != 0 && fTd != 0)
return;
 
if (rowValid)
totalCred += fTc;
totalCredWithNoValid += fTc;
 
if (rowValid)
totalDeb += fTd;
totalDebWithNoValid += fTd;
 
final boolean emptyAmount = fTc == 0 && fTd == 0;
this.tableKm.setRowDeviseValidAt(!emptyAmount, i);
allLineValid &= !emptyAmount;
}
this.tableKm.revalidate();
this.tableKm.repaint();
// totalCred = (float) new PrixHT(totalCred).getValue();
// totalDeb = (float) new PrixHT(totalDeb).getValue();
 
this.isCompteExist = isCompteExist;
this.allLineValid = allLineValid;
this.setTotals(totalCred, totalDeb);
 
updateValidState();
 
// add a row to balance totals
final long diffWithNoValid = totalDebWithNoValid - totalCredWithNoValid;
// System.err.println("Valid ___ " + diff + " NO VALID _____ " +
// diffWithNoValid);
if (diffWithNoValid != 0) {
if (diffWithNoValid > 0) {
this.defaultEcritureRowVals.put("DEBIT", Long.valueOf(0));
this.defaultEcritureRowVals.put("CREDIT", Long.valueOf(diffWithNoValid));
if (this.model.isLastRowValid()) {
this.tableKm.getModel().addRow(new SQLRowValues(this.defaultEcritureRowVals));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (SaisieKmComponent.this.model.getRowCount() > 0) {
SaisieKmComponent.this.tableKm.editCellAt(SaisieKmComponent.this.model.getRowCount() - 1, 0);
}
}
});
}
} else {
this.defaultEcritureRowVals.put("DEBIT", Long.valueOf(-diffWithNoValid));
this.defaultEcritureRowVals.put("CREDIT", Long.valueOf(0));
if (this.model.isLastRowValid()) {
this.tableKm.getModel().addRow(new SQLRowValues(this.defaultEcritureRowVals));
 
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (SaisieKmComponent.this.model.getRowCount() > 0) {
SaisieKmComponent.this.tableKm.editCellAt(SaisieKmComponent.this.model.getRowCount() - 1, 0);
}
}
});
 
// System.err.println("RowValid " + e.getType());
} else {
System.err.println(e.getType());
}
}
} else {
this.defaultEcritureRowVals.put("DEBIT", Long.valueOf(0));
this.defaultEcritureRowVals.put("CREDIT", Long.valueOf(0));
}
}
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ComptePCESQLElement.java
18,6 → 18,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
29,6 → 30,7
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.checks.ValidState;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.GridBagConstraints;
71,6 → 73,21
private boolean isCompteValid = false;
private JUniqueTextField textNumero = new JUniqueTextField(7);
 
@Override
public void update() {
// TODO Raccord de méthode auto-généré
int id = getSelectedID();
super.update();
SQLElement eltEcr = Configuration.getInstance().getDirectory().getElement("ECRITURE");
Configuration
.getInstance()
.getBase()
.getDataSource()
.execute(
"UPDATE " + eltEcr.getTable().getSQLName().quote() + " SET \"COMPTE_NUMERO\"=c.\"NUMERO\",\"COMPTE_NOM\"=c.\"NOM\" FROM " + getTable().getSQLName().quote()
+ " c WHERE c.\"ID\"=\"ID_COMPTE_PCE\" AND c.\"ID\"=" + id);
}
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
181,8 → 198,8
}
 
@Override
public synchronized boolean isValidated() {
return super.isValidated() && this.isCompteValid;
public synchronized ValidState getValidState() {
return super.getValidState().and(ValidState.createCached(this.isCompteValid, "Le numéro de compte ne commence pas par un chiffre entre 1 et 8"));
}
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java
75,6 → 75,7
final List<String> l = new ArrayList<String>();
 
l.add("ID");
l.add("VALIDE");
l.add("ID_MOUVEMENT");
// l.add("ID_COMPTE_PCE");
l.add("COMPTE_NUMERO");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceAgeeListeSheetXML.java
45,12 → 45,16
this.printer = PrinterNXProps.getInstance().getStringProperty("BonPrinter");
this.deb = deb;
this.fin = fin;
this.modele = "BalanceAgee";
 
this.locationOO = SheetXml.getLocationForTuple(tupleDefault, false);
this.locationPDF = SheetXml.getLocationForTuple(tupleDefault, true);
}
 
@Override
public String getDefaultModele() {
return "BalanceAgee";
}
 
public String getFileName() {
return getValidFileName("BalanceAgee" + new Date().getTime());
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map3310.java
38,7 → 38,6
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
 
 
public class Map3310 extends Thread {
 
private Map<String, Object> m;
146,13 → 145,13
this.m = new HashMap<String, Object>();
 
long v010 = -this.sommeCompte.soldeCompte(70, 70, true, this.dateDebut, this.dateFin);
this.m.put("A01", GestionDevise.currencyToString(v010, false));
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.currencyToString(achatsIntra, false));
this.m.put("A03", GestionDevise.round(achatsIntra));
this.m.put("A04", "");
this.m.put("A05", "");
this.m.put("A06", "");
159,8 → 158,8
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.currencyToString(tvaCol, false));
this.m.put("B08HT", GestionDevise.currencyToString(Math.round(tvaCol / 0.196), false));
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", "");
178,26 → 177,28
this.m.put("B14HT", "");
 
this.m.put("B15", "");
this.m.put("B16", GestionDevise.currencyToString(tvaCol, false));
this.m.put("B17", GestionDevise.currencyToString(tvaIntra, false));
this.m.put("B16", GestionDevise.round(tvaCol));
this.m.put("B17", GestionDevise.round(tvaIntra));
this.m.put("B18", "");
this.m.put("B19", "");
long tvaImmo = this.sommeCompte.sommeCompteFils(rowCompteTVAImmo.getString("NUMERO"), new Date(100, 0, 1), this.dateFin);
this.m.put("B19", GestionDevise.round(tvaImmo));
 
long tvaDed = this.sommeCompte.sommeCompteFils(rowCompteTVADed.getString("NUMERO"), new Date(100, 0, 1), this.dateFin);
this.m.put("B20", GestionDevise.currencyToString(tvaDed, false));
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", "");
this.m.put("B24", GestionDevise.currencyToString(tvaDed, false));
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.currencyToString(tvaCol - tvaDed, false));
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.currencyToString(tvaCol - tvaDed, false));
this.m.put("C32", GestionDevise.round(tvaCol - tvaDed));
 
p.generateFrom(this.m);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ExportRelationExpertAction.java
New file
0,0 → 1,35
/*
* 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.finance.accounting.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.panel.compta.ExportRelationExpertPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
 
public class ExportRelationExpertAction extends CreateFrameAbstractAction {
public ExportRelationExpertAction() {
super();
this.putValue(Action.NAME, "Export relation expert");
}
 
public JFrame createFrame() {
 
return new PanelFrame(new ExportRelationExpertPanel(), "Export relation expert");
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ReglementCompteVentePreferencePanel.java
13,7 → 13,6
package org.openconcerto.erp.core.finance.accounting.ui;
 
 
public class ReglementCompteVentePreferencePanel extends AbstractReglementComptePreferencePanel {
 
@Override
38,7 → 37,6
 
@Override
public String getComptePCEEspeces() {
// FIXME: URGENT: verifier cette valeur (avec s ou pas?)
return "VenteEspece";
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/RepartitionAxeAnalytiquePanel.java
19,8 → 19,8
import org.openconcerto.erp.element.objet.RepartitionElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.table.CloseTableHeaderRenderer;
import org.openconcerto.ui.table.PopUpTableManager;
import org.openconcerto.ui.table.TablePopupMenuProvider;
import org.openconcerto.ui.table.TablePopupMouseListener;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
33,7 → 33,8
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.awt.event.MouseEvent;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
 
42,6 → 43,7
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
50,7 → 52,7
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
 
public class RepartitionAxeAnalytiquePanel extends JPanel implements TablePopupMenuProvider {
public class RepartitionAxeAnalytiquePanel extends JPanel {
 
private int idAxe;
private AnalytiqueModel model;
176,7 → 178,17
}
};
 
new PopUpTableManager(this.listeRepartitions, this);
TablePopupMouseListener.add(this.listeRepartitions, new ITransformer<MouseEvent, JPopupMenu>() {
@Override
public JPopupMenu transformChecked(MouseEvent input) {
final JPopupMenu res = new JPopupMenu();
final JTable table = (JTable) input.getSource();
for (final Action a : getActions(table, table.getSelectedRow())) {
res.add(a);
}
return res;
}
});
 
JScrollPane scrollPane = new JScrollPane(this.listeRepartitions);
 
212,7 → 224,7
/***********************************************************************************************
* Action click droit sur les éléments de la liste
**********************************************************************************************/
public List getActions(final JTable table, final int row) {
public List<Action> getActions(final JTable table, final int row) {
Action a = new AbstractAction("Supprimer ligne " + row) {
 
public void actionPerformed(ActionEvent e) {
231,10 → 243,7
}
};
 
List v = new ArrayList<Action>();
v.add(a);
v.add(a2);
return v;
return Arrays.asList(a, a2);
}
 
/***********************************************************************************************
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/SommeCompte.java
47,6 → 47,7
if (this.rowAnalytique != null) {
SQLTable tableAssoc = ecritureTable.getTable("ASSOCIATION_ANALYTIQUE");
Where join = new Where(tableAssoc.getField("ID_ECRITURE"), "=", ecritureTable.getKey());
join = join.and(new Where(tableAssoc.getField("ID_POSTE_ANALYTIQUE"), "=", this.rowAnalytique.getID()));
sel.addJoin("RIGHT", ecritureTable.getTable("ASSOCIATION_ANALYTIQUE"), join);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ReglerMontantSQLElement.java
34,6 → 34,7
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.warning.JLabelWarning;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.checks.ValidState;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
202,7 → 203,8
SQLRowValues rowVals = new SQLRowValues(tableModeRegl);
rowVals.put("ID_TYPE_REGLEMENT", idTypeRegl);
rowVals.put("COMPTANT", Boolean.TRUE);
 
rowVals.put("AJOURS", 0);
rowVals.put("LENJOUR", 0);
eltModeRegl.setValue(rowVals);
}
}
256,8 → 258,9
return id;
}
 
public boolean isValidated() {
return (super.isValidated() && montantIsValidated());
@Override
public synchronized ValidState getValidState() {
return super.getValidState().and(ValidState.createCached(montantIsValidated(), "Le montant est négatif ou supérieur à l'échéance"));
}
 
@Override
282,33 → 285,19
 
// test si le montant est correct par rapport à l'echeance selectionnée
public boolean montantIsValidated() {
 
long montantValue = 0;
 
if (this.comboEcheance.isEmpty()) {
this.labelWarning.setVisible(false);
this.labelWarningText.setVisible(false);
return true;
final SQLRow echRow = this.comboEcheance.getSelectedRow();
final boolean res;
if (echRow == null) {
res = true;
} else {
final long montantValue = GestionDevise.parseLongCurrency(this.montant.getText().trim());
res = (montantValue > 0) && (montantValue <= echRow.getLong("MONTANT"));
}
 
montantValue = GestionDevise.parseLongCurrency(this.montant.getText().trim());
 
int idEch = this.comboEcheance.getSelectedId();
 
if (idEch >= 1) {
SQLRow echRow = getTable().getBase().getTable("ECHEANCE_FOURNISSEUR").getRow(idEch);
 
if ((montantValue > 0) && (montantValue <= ((Long) echRow.getObject("MONTANT")).longValue())) {
this.labelWarning.setVisible(false);
this.labelWarningText.setVisible(false);
return true;
this.labelWarning.setVisible(!res);
this.labelWarningText.setVisible(!res);
return res;
}
}
 
this.labelWarning.setVisible(true);
this.labelWarningText.setVisible(true);
return false;
}
};
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/EncaisserMontantSQLComponent.java
30,7 → 30,6
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.RowValuesTableModel;
60,15 → 59,12
 
public class EncaisserMontantSQLComponent extends BaseSQLComponent {
 
private SQLElement eltEch = Configuration.getInstance().getDirectory().getElement("ECHEANCE_CLIENT");
private EncaisseMontantTable table = new EncaisseMontantTable();
final Where wRegle = new Where(eltEch.getTable().getField("REGLE"), "=", Boolean.FALSE);
 
private JTextField nom = new JTextField();
private DeviseField montant = new DeviseField(6);
private JLabel labelWarning = new JLabelWarning();
private JLabel labelWarning = new JLabelWarning("Le montant est trop élevé!");
 
private JLabel labelWarningText = new JLabel("Le montant est trop élevé!");
private JDate date;
 
public EncaisserMontantSQLComponent(SQLElement elt) {
150,11 → 146,9
 
// Warning
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
this.labelWarning.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(this.labelWarning, c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(this.labelWarningText, c);
 
/***********************************************************************************
* * MODE DE REGLEMENT
235,7 → 229,10
}
 
}
if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == model.getColumnIndexForElement(table.getMontantAReglerElement())) {
updateWarning();
}
}
};
 
this.montant.getDocument().addDocumentListener(new SimpleDocumentListener() {
245,7 → 242,7
table.getRowValuesTable().getRowValuesTableModel().removeTableModelListener(tableListener);
updateMontant(montant.getText());
table.getRowValuesTable().getRowValuesTableModel().addTableModelListener(tableListener);
fireValidChange();
updateWarning();
 
}
});
373,20 → 370,14
return vals;
}
 
@Override
public synchronized boolean isValidated() {
return (super.isValidated() && montantIsValidated());
}
 
// test si le montant est correct par rapport à l'echeance selectionnée
public boolean montantIsValidated() {
private final void updateWarning() {
 
long montantValue = 0;
 
if (this.table.getRowValuesTable().getRowCount() == 0) {
this.labelWarning.setVisible(false);
this.labelWarningText.setVisible(false);
return true;
return;
}
 
try {
407,17 → 398,9
total += nHT.longValue();
}
 
if ((montantValue > 0) && (montantValue <= total)) {
this.labelWarning.setVisible(false);
this.labelWarningText.setVisible(false);
return true;
this.labelWarning.setVisible(montantValue <= 0 || montantValue > total);
}
 
this.labelWarning.setVisible(true);
this.labelWarningText.setVisible(true);
return true;
}
 
public void loadEcheancesFromRows(List<SQLRow> rows) {
 
Collections.sort(rows, new Comparator<SQLRow>() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/ModeDeReglementSQLComponent.java
28,6 → 28,7
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
60,7 → 61,7
private final SQLRequestComboBox comboTypeReglement = new SQLRequestComboBox();
private ITextCombo comboA;
private ITextCombo comboLe = new SQLTextCombo();
private ITextCombo comboBanque = new SQLTextCombo();
private SQLSearchableTextCombo comboBanque = new SQLSearchableTextCombo();
private JRadioButton buttonFinMois = new JRadioButton("fin de mois");
private JRadioButton buttonDateFacture = new JRadioButton("date de facturation");
private JRadioButton buttonLe = new JRadioButton("le");
106,7 → 107,7
this.checkboxComptant.setSelected(true);
}
 
setEcheanceEnabled(!boolean2);
setEcheanceEnabled(!this.checkboxComptant.isSelected());
 
// Si cheque et comptant
boolean chequeComptant = (rowTypeRegl.getID() == TypeReglementSQLElement.CHEQUE && this.checkboxComptant.isSelected());