OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Ignore whitespace Rev 155 → Rev 156

/trunk/OpenConcerto/src/META-INF/services/java.nio.file.spi.FileTypeDetector
New file
0,0 → 1,0
ilm.utils.mime.FreeDesktopMimeDetector
/trunk/OpenConcerto/src/org/jopenchart/DataModel1D.java
4,7 → 4,7
import java.util.List;
 
public class DataModel1D extends DataModel {
private final List<Number> l = new ArrayList<Number>();
private final List<Number> l = new ArrayList<>();
 
public DataModel1D() {
 
12,8 → 12,7
 
public DataModel1D(Number[] data) {
for (int i = 0; i < data.length; i++) {
Number number = data[i];
l.add(number);
l.add(data[i]);
}
}
 
21,15 → 20,15
this.addAll(list);
}
 
public void addAll(List<Number> data) {
public synchronized void addAll(List<Number> data) {
l.addAll(data);
}
 
public int getSize() {
public synchronized int getSize() {
return l.size();
}
 
public void setValueAt(int index, Number value) {
public synchronized void setValueAt(int index, Number value) {
ensureCapacity(index);
l.set(index, value);
}
40,37 → 39,34
}
}
 
public Number getValueAt(int index) {
public synchronized Number getValueAt(int index) {
ensureCapacity(index);
return l.get(index);
}
 
public Number getMaxValue() {
public synchronized Number getMaxValue() {
Number max = 0;
for (Number b : this.l) {
if (max == null) {
if (b != null && b.doubleValue() > max.doubleValue()) {
max = b;
} else if (b != null && b.doubleValue() > max.doubleValue()) {
max = b;
}
}
return max;
}
 
public Number getMinValue() {
public synchronized Number getMinValue() {
Number min = 0;
for (Number b : this.l) {
if (min == null) {
if (b != null && b.doubleValue() < min.doubleValue()) {
min = b;
} else if (b != null && b.doubleValue() < min.doubleValue()) {
min = b;
}
}
return min;
}
 
public void clear() {
for (int i = 0; i < this.getSize(); i++) {
public synchronized void clear() {
final int size = l.size();
for (int i = 0; i < size; i++) {
this.setValueAt(i, null);
}
}
/trunk/OpenConcerto/src/org/jopenchart/DataModel2D.java
7,10 → 7,10
public class DataModel2D extends DataModel {
 
private String[][] data;
private int rowCount;
private int colCount;
private List<String> rowLabels = new ArrayList<String>();
private List<String> colLabels = new ArrayList<String>();
private final int rowCount;
private final int colCount;
private List<String> rowLabels = new ArrayList<>();
private List<String> colLabels = new ArrayList<>();
 
public DataModel2D(int row, int col) {
this.rowCount = row;
27,24 → 27,24
this.rowLabels.add(String.valueOf((char) ('A' + i)));
}
for (int i = 0; i < col; i++) {
this.colLabels.add(String.valueOf(((1 + i))));
this.colLabels.add(String.valueOf(1 + i));
}
 
}
 
public String getValue(int row, int col) {
public synchronized String getValue(int row, int col) {
return data[row][col];
}
 
public void setValue(String value, int row, int col) {
public synchronized void setValue(String value, int row, int col) {
data[row][col] = value;
}
 
public String getColumnLabel(int col) {
public synchronized String getColumnLabel(int col) {
return this.colLabels.get(col);
}
 
public String getRowLabel(int row) {
public synchronized String getRowLabel(int row) {
return this.rowLabels.get(row);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/action/AboutAction.java
14,15 → 14,23
package org.openconcerto.erp.action;
 
import org.openconcerto.erp.config.Benchmark;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.sql.ui.InfoPanel;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.ReloadPanel;
 
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
 
import javax.swing.AbstractAction;
import javax.swing.Action;
54,6 → 62,7
p.setLayout(new BorderLayout());
 
final JScrollPane contentPane = new JScrollPane(new InfoPanel());
p.add(createComptaInfoPanel(), BorderLayout.NORTH);
p.add(contentPane, BorderLayout.CENTER);
p.add(createBenchMarkPanel(), BorderLayout.SOUTH);
frame.setContentPane(p);
79,6 → 88,53
frame.setVisible(true);
}
 
private Component createComptaInfoPanel() {
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
final File confFile = ComptaPropsConfiguration.getConfFile(ComptaPropsConfiguration.productInfo);
String path = "";
if (confFile != null) {
path = confFile.getAbsolutePath();
}
c.fill = GridBagConstraints.NONE;
c.weightx = 0;
c.anchor = GridBagConstraints.EAST;
p.add(new JLabelBold("Fichier de configuration : "), c);
c.gridx++;
c.weightx = 1;
c.anchor = GridBagConstraints.WEST;
p.add(new JLabel(path), c);
c.gridy++;
c.gridx = 0;
final String serverIp = ComptaPropsConfiguration.getInstanceCompta().getServerIp();
if (serverIp.startsWith("file:")) {
final String dbPath = ComptaPropsConfiguration.getInstanceCompta().getServerIp().substring(5);
c.weightx = 0;
c.anchor = GridBagConstraints.EAST;
p.add(new JLabelBold("Fichier de base de données : "), c);
c.gridx++;
c.weightx = 1;
c.anchor = GridBagConstraints.WEST;
p.add(new JLabel(dbPath), c);
}
c.gridy++;
try {
c.gridx = 0;
c.weightx = 0;
c.anchor = GridBagConstraints.EAST;
p.add(new JLabelBold("Dossier des modules : "), c);
c.gridx++;
c.weightx = 1;
c.anchor = GridBagConstraints.WEST;
p.add(new JLabel(Gestion.MODULES_DIR.getCanonicalPath()), c);
} catch (IOException e) {
e.printStackTrace();
}
 
return p;
}
 
private JPanel createBenchMarkPanel() {
final JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.LEFT));
/trunk/OpenConcerto/src/org/openconcerto/erp/action/NouvelleConnexionAction.java
35,7 → 35,6
import org.openconcerto.erp.rights.MenuComboRightEditor;
import org.openconcerto.erp.utils.NXDatabaseAccessor;
import org.openconcerto.map.model.Ville;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLBase;
61,6 → 60,7
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.component.MutableListComboPopupListener;
import org.openconcerto.ui.preferences.EmailProps;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.JImage;
import org.openconcerto.utils.cc.IClosure;
71,6 → 71,7
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
90,10 → 91,12
import javax.swing.UIManager;
 
public class NouvelleConnexionAction extends CreateFrameAbstractAction {
private final ComptaPropsConfiguration conf;
private ConnexionPanel connexionPanel;
 
public NouvelleConnexionAction() {
public NouvelleConnexionAction(ComptaPropsConfiguration conf) {
super();
this.conf = conf;
this.putValue(Action.NAME, "Changer d'utilisateur");
}
 
101,7 → 104,7
// needed as done() must come after us
assert SwingUtilities.isEventDispatchThread();
 
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
final ComptaPropsConfiguration comptaPropsConfiguration = this.conf;
 
Runnable r = new Runnable() {
 
135,20 → 138,22
}
comptaPropsConfiguration.setUpSocieteDataBaseConnexion(selectedSociete);
comptaPropsConfiguration.setupBarCodeIfNeeded();
 
File fMail2 = new File(comptaPropsConfiguration.getConfDir(), "Email" + selectedSociete + ".properties");
EmailProps.getInstance().setPropsFileName(fMail2.toString());
// needed by openEmergencyModuleManager()
UserRightsManager.getInstance().addRightForAdmins(new RightTuple(ModuleManager.MODULE_DB_RIGHT, true));
UserRightsManager.getInstance().addRightForAdmins(new RightTuple(BackupPanel.RIGHT_CODE, true));
// finish filling the configuration before going any further, otherwise the
// SQLElementDirectory is not coherent
ModuleManager.getInstance().setup(comptaPropsConfiguration.getRootSociete(), comptaPropsConfiguration);
final ModuleManager moduleMngr = comptaPropsConfiguration.getModuleManager();
try {
ModuleManager.getInstance().init();
moduleMngr.init();
} catch (Throwable e) {
// not OK to continue without required elements
openEmergencyModuleManager("Impossible de configurer les modules requis", e);
openEmergencyModuleManager(moduleMngr, "Impossible de configurer les modules requis", e);
return;
}
 
MenuManager.setInstance(
(Gestion.isMinimalMode() ? new MinimalMenuConfiguration(comptaPropsConfiguration) : new DefaultMenuConfiguration(comptaPropsConfiguration)).createMenuAndActions());
 
197,7 → 202,7
MutableListComboPopupListener.setLockOverridable(rights.isSuperUser());
 
StatusPanel.getInstance().fireStatusChanged();
final MainFrame f = new MainFrame();
final MainFrame f = new MainFrame(comptaPropsConfiguration);
String version = comptaPropsConfiguration.getVersion();
final String socTitle = comptaPropsConfiguration.getRowSociete() == null ? "" : ", [Société " + comptaPropsConfiguration.getRowSociete().getString("NOM") + "]";
f.setTitle(comptaPropsConfiguration.getAppName() + " " + version + socTitle);
209,7 → 214,7
public void run() {
// make sure the application is started with all required and mandatory
// modules
if (ModuleManager.getInstance().isInited()) {
if (moduleMngr.isInited()) {
final MainFrame mainFrame = MainFrame.getInstance();
mainFrame.initMenuBar();
FrameUtil.show(mainFrame);
216,7 → 221,7
}
}
}, null);
ModuleManager.getInstance().invoke(new IClosure<ModuleManager>() {
moduleMngr.invoke(new IClosure<ModuleManager>() {
@Override
public void executeChecked(ModuleManager input) {
// start modules before displaying the frame (e.g. avoid modifying a
230,7 → 235,7
// but don't continue right away otherwise connexion panel will
// be closed and the popup with it
try {
ExceptionHandler.handle(NouvelleConnexionAction.this.connexionPanel, "Impossible de démarrer les modules", exn).getDialogFuture().get();
ExceptionHandler.handle(NouvelleConnexionAction.this.connexionPanel, "Impossible de démarrer les modules", exn).get();
} catch (Exception e) {
e.printStackTrace();
}
237,7 → 242,7
}
SwingUtilities.invokeLater(showMainFrame);
} catch (Exception exn) {
openEmergencyModuleManager("Impossible de démarrer les modules requis", exn);
openEmergencyModuleManager(input, "Impossible de démarrer les modules requis", exn);
}
}
});
246,7 → 251,8
showMainFrame.get();
} catch (Throwable e) {
if (e.getMessage() != null && ((e.getMessage().contains("table") && e.getMessage().contains("not found")) || e.getMessage().contains("unknown field")
|| e.getMessage().contains("Couldn't add showAs"))) {
|| e.getMessage().contains("Couldn't add showAs") || e.getMessage().contains("Base de données non à jour"))) {
e.printStackTrace();
JOptionPane.showMessageDialog(new JFrame(),
"Votre base de données n'est pas à jour.\nUtilisez l'outil de configuration et pensez à l'achat du manuel !\n(" + e.getMessage() + ")");
return;
276,7 → 282,7
if (this.connexionPanel == null)
return null;
this.connexionPanel.initLocalization(getClass().getName(), Arrays.asList(Locale.FRANCE, Locale.CANADA_FRENCH, new Locale("fr", "CH"), new Locale("fr", "BE"), Locale.UK, Locale.CANADA,
Locale.US, Locale.GERMANY, new Locale("de", "CH"), new Locale("pl", "PL")));
Locale.US, Locale.GERMANY, new Locale("de", "CH"), new Locale("es", "ES"), new Locale("pl", "PL")));
 
p.add(this.connexionPanel, c);
final PanelFrame panelFrame = new PanelFrame(p, "Connexion");
313,6 → 319,9
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("COMMERCIAL"), 600);
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("PERIODE_VALIDITE"), 1000);
 
if (comptaConf.getRootSociete().contains("DEPOT_STOCK")) {
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("DEPOT_STOCK"), 600);
}
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("TYPE_REGLEMENT"), 1000);
SQLBackgroundTableCache.getInstance().startCacheWatcher();
 
351,7 → 360,7
}
}
 
private void openEmergencyModuleManager(final String str, final Throwable e) {
private void openEmergencyModuleManager(ModuleManager mngr, final String str, final Throwable e) {
Log.get().log(Level.SEVERE, "Normal startup impossible, opening the module manager in order to resolve the issue.", e);
SwingUtilities.invokeLater(new Runnable() {
@Override
359,7 → 368,7
ExceptionHandler.handle(str, e);
// can't start since there's no main frame (and obviously no modules can be stopped
// since none are running)
final ModuleFrame fMod = ModuleFrame.createInstallOnlyInstance();
final ModuleFrame fMod = new ModuleFrame(mngr, true);
fMod.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fMod.setTitle(str);
FrameUtil.show(fMod);
/trunk/OpenConcerto/src/org/openconcerto/erp/action/NouvelleConnexionAction_es.properties
New file
0,0 → 1,6
adminLogin = Administrateur
loginLabel=Login
passwordLabel=Contraseña
companyLabel=Sociedad
saveCheckBox=Recordar contraseña
buttonConnect=Conexión
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateListFrameAbstractAction.java
13,6 → 13,8
package org.openconcerto.erp.action;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.element.SQLElement;
35,6 → 37,10
import org.openconcerto.ui.light.ListToolbarLine;
import org.openconcerto.ui.light.RowSelectionSpec;
import org.openconcerto.ui.light.TableSpec;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.i18n.MessageArgs;
import org.openconcerto.utils.i18n.NounClass;
import org.openconcerto.utils.i18n.TM.MissingMode;
import org.openconcerto.utils.i18n.TranslationManager;
 
import java.util.ArrayList;
42,16 → 48,41
import java.util.Iterator;
import java.util.List;
 
import javax.swing.JFrame;
 
import org.jdom2.Document;
import org.jdom2.input.DOMBuilder;
 
public abstract class CreateListFrameAbstractAction extends CreateFrameAbstractAction implements LightUIFrameProvider {
abstract public String getTableName();
public abstract class CreateListFrameAbstractAction<E extends SQLElement, F extends JFrame> extends GenericElementFrameAction<E, F> implements LightUIFrameProvider {
 
private static final String TRANSLATION_KEY = "listMenuItem.name";
private static final String[] TRANSLATION_KEY_ARRAY = new String[] { TRANSLATION_KEY };
 
private final ComptaPropsConfiguration conf;
 
protected CreateListFrameAbstractAction(final ComptaPropsConfiguration conf, final Class<? extends E> clazz) {
super(conf.getDirectory().getElement(clazz));
this.conf = conf;
// TODO use conf to find TM
final NounClass nounClass = this.getElem().getName().getNounClass();
final String[] translationKeys = nounClass == null ? TRANSLATION_KEY_ARRAY : new String[] { TRANSLATION_KEY + '.' + nounClass.getName(), TRANSLATION_KEY };
this.putValue(NAME, StringUtils.firstUp(TM.getTM().translateFirst(MissingMode.NULL, MessageArgs.create("elem", this.getElem().getName()), translationKeys)));
}
 
public final ComptaPropsConfiguration getConf() {
return this.conf;
}
 
@Override
protected void initFrame(F frame) {
super.initFrame(frame);
CreateFrameAbstractAction.initFrame(frame, this, getConf(), true);
}
 
@Override
public LightUIFrame getUIFrame(PropsConfiguration configuration) {
// Get SQLElement
SQLElement element = configuration.getDirectory().getElement(getTableName());
SQLElement element = getElem();
final String elementCode = element.getCode();
 
// Title of frame should be the element code with .title
/trunk/OpenConcerto/src/org/openconcerto/erp/action/PreferencesAction.java
15,6 → 15,7
 
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.finance.accounting.ui.ComptaPrefTreeNode;
import org.openconcerto.erp.modules.ModuleManager;
import org.openconcerto.sql.Configuration;
import org.openconcerto.ui.preferences.PreferenceFrame;
import org.openconcerto.ui.state.WindowStateManager;
29,14 → 30,17
 
public class PreferencesAction extends AbstractAction {
 
public PreferencesAction() {
private final ModuleManager moduleManager;
 
public PreferencesAction(final ModuleManager mngr) {
super();
this.putValue(Action.NAME, "Préférences");
this.moduleManager = mngr;
}
 
@Override
public void actionPerformed(final ActionEvent e) {
final JFrame frame = new PreferenceFrame(new ComptaPrefTreeNode());
final JFrame frame = new PreferenceFrame(new ComptaPrefTreeNode(this.moduleManager));
frame.setIconImages(Gestion.getFrameIcon());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
/trunk/OpenConcerto/src/org/openconcerto/erp/action/GenericElementFrameAction.java
New file
0,0 → 1,39
/*
* 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.action;
 
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.SQLMenuItemHelper.AbstractSQLMenuItemAction;
 
import javax.swing.JFrame;
 
public abstract class GenericElementFrameAction<E extends SQLElement, F extends JFrame> extends AbstractSQLMenuItemAction<E> {
 
public GenericElementFrameAction(E elem) {
super(elem, null);
this.setCacheFrame(false);
}
 
protected abstract F instantiateFrame();
 
protected void initFrame(F f) {
}
 
@Override
protected final F createFrame() {
final F res = instantiateFrame();
this.initFrame(res);
return res;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateFrameAbstractAction.java
40,15 → 40,20
 
public void actionPerformed(ActionEvent e) {
final JFrame frame = createFrame();
initFrame(frame, this, Configuration.getInstance(), this.mustLoadState);
FrameUtil.show(frame);
}
 
protected static void initFrame(final JFrame frame, final Action action, final Configuration conf, final boolean mustLoadState) {
frame.setIconImages(Gestion.getFrameIcon());
 
final Object name = this.getValue(Action.NAME);
final Object name = action.getValue(Action.NAME);
WindowStateManager stateManager = null;
if (name != null) {
stateManager = new WindowStateManager(frame, new File(Configuration.getInstance().getConfDir(), "Configuration" + File.separator + "Frame" + File.separator + name.toString() + ".xml"),
stateManager = new WindowStateManager(frame, new File(conf.getConfDir(), "Configuration" + File.separator + "Frame" + File.separator + name.toString() + ".xml"),
true);
} else {
System.err.println("Warning: no action name for action " + this + ", unable to use a window state manager.");
System.err.println("Warning: no action name for action " + action + ", unable to use a window state manager.");
}
 
frame.pack();
63,8 → 68,6
}
 
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
FrameUtil.show(frame);
 
}
 
abstract public JFrame createFrame();
/trunk/OpenConcerto/src/org/openconcerto/erp/action/NouvelleSocieteAction.java
13,21 → 13,13
package org.openconcerto.erp.action;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.core.common.element.SocieteCommonSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouvelleSocieteAction extends CreateEditFrameAbstractAction<SocieteCommonSQLElement> {
 
public class NouvelleSocieteAction extends CreateFrameAbstractAction {
 
public NouvelleSocieteAction() {
super();
this.putValue(Action.NAME, "Nouvelle société");
public NouvelleSocieteAction(final PropsConfiguration conf) {
super(conf, SocieteCommonSQLElement.class);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("SOCIETE_COMMON"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateIListFrameAbstractAction.java
New file
0,0 → 1,56
/*
* 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.action;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSource;
 
public abstract class CreateIListFrameAbstractAction<E extends SQLElement> extends CreateListFrameAbstractAction<E, IListFrame> {
 
protected CreateIListFrameAbstractAction(final ComptaPropsConfiguration conf, final Class<? extends E> clazz) {
super(conf, clazz);
}
 
protected SQLTableModelSource createTableSource() {
return this.getElem().createTableSource();
}
 
protected String getPanelVariant() {
return null;
}
 
protected IListPanel instantiateListPanel(final SQLTableModelSource tableSource, String panelVariant) {
return new ListeAddPanel(tableSource.getElem(), new IListe(tableSource), panelVariant);
}
 
protected final IListPanel createListPanel() {
final SQLTableModelSource tableSource = this.createTableSource();
if (tableSource.getElem() != this.getElem())
throw new IllegalStateException("Element mismatch");
final IListPanel res = this.instantiateListPanel(tableSource, this.getPanelVariant());
if (res.getListe().getSource() != tableSource)
throw new IllegalStateException("Source mismatch");
return res;
}
 
@Override
protected final IListFrame instantiateFrame() {
return new IListFrame(createListPanel());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateEditFrameAbstractAction.java
New file
0,0 → 1,47
/*
* 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.action;
 
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.i18n.MessageArgs;
import org.openconcerto.utils.i18n.NounClass;
import org.openconcerto.utils.i18n.TM.MissingMode;
 
public class CreateEditFrameAbstractAction<E extends SQLElement> extends GenericElementFrameAction<E, EditFrame> {
 
private static final String TRANSLATION_KEY = "createMenuItem.name";
private static final String[] TRANSLATION_KEY_ARRAY = new String[] { TRANSLATION_KEY };
 
protected CreateEditFrameAbstractAction(final PropsConfiguration conf, final Class<? extends E> clazz) {
super(conf.getDirectory().getElement(clazz));
// TODO use conf to find TM
final NounClass nounClass = this.getElem().getName().getNounClass();
final String[] translationKeys = nounClass == null ? TRANSLATION_KEY_ARRAY : new String[] { TRANSLATION_KEY + '.' + nounClass.getName(), TRANSLATION_KEY };
this.putValue(NAME, StringUtils.firstUp(TM.getTM().translateFirst(MissingMode.NULL, MessageArgs.create("elem", this.getElem().getName()), translationKeys)));
}
 
@Override
protected final EditFrame instantiateFrame() {
return new EditFrame(getElem().createComponent(getComponentID()), EditPanel.CREATION);
}
 
protected String getComponentID() {
return SQLElement.DEFAULT_COMP_ID;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/DevisCommandeSQLInjector.java
34,6 → 34,13
if (tableDevis.contains("PORT_HT") && tableCommande.contains("PORT_HT")) {
map(tableDevis.getField("PORT_HT"), tableCommande.getField("PORT_HT"));
}
 
if (getSource().contains("FRAIS_DOCUMENT_HT") && getDestination().contains("FRAIS_DOCUMENT_HT")) {
map(getSource().getField("FRAIS_DOCUMENT_HT"), getDestination().getField("FRAIS_DOCUMENT_HT"));
}
if (getSource().contains("ID_TAXE_FRAIS_DOCUMENT") && getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
map(getSource().getField("ID_TAXE_FRAIS_DOCUMENT"), getDestination().getField("ID_TAXE_FRAIS_DOCUMENT"));
}
mapDefaultValues(tableCommande.getField("SOURCE"), tableDevis.getName());
map(tableDevis.getField("ID_DEVIS"), tableCommande.getField("IDSOURCE"));
map(tableDevis.getField("ID_DEVIS"), tableCommande.getField("ID_DEVIS"));
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/DevisFactureSQLInjector.java
34,6 → 34,12
map(tableDevis.getField("T_ACOMPTE"), tableFacture.getField("T_ACOMPTE"));
}
map(tableDevis.getField("PORT_HT"), tableFacture.getField("PORT_HT"));
if (getSource().contains("FRAIS_DOCUMENT_HT") && getDestination().contains("FRAIS_DOCUMENT_HT")) {
map(getSource().getField("FRAIS_DOCUMENT_HT"), getDestination().getField("FRAIS_DOCUMENT_HT"));
}
if (getSource().contains("ID_TAXE_FRAIS_DOCUMENT") && getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
map(getSource().getField("ID_TAXE_FRAIS_DOCUMENT"), getDestination().getField("ID_TAXE_FRAIS_DOCUMENT"));
}
map(tableDevis.getField("REMISE_HT"), tableFacture.getField("REMISE_HT"));
map(tableDevis.getField("ID_CLIENT"), tableFacture.getField("ID_CLIENT"));
map(tableDevis.getField("ID_COMMERCIAL"), tableFacture.getField("ID_COMMERCIAL"));
76,6 → 82,14
transfertReference(srcRow, rowVals, "INFOS", "INFOS");
transfertNumberReference(srcRow, rowVals, tableElementDestination, "ID_SAISIE_VENTE_FACTURE");
 
if (getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
final SQLRowAccessor rowClient = srcRow.getForeign("ID_CLIENT");
SQLRowAccessor rowFrais = rowClient.getForeign("ID_FRAIS_DOCUMENT");
if (rowFrais != null && !rowFrais.isUndefined()) {
rowVals.put("FRAIS_DOCUMENT_HT", rowFrais.getLong("MONTANT_HT"));
rowVals.put("ID_TAXE_FRAIS_DOCUMENT", rowFrais.getForeignID("ID_TAXE"));
}
}
if (myListItem.size() != 0) {
final SQLInjector injector = SQLInjector.getInjector(tableElementSource, tableElementDestination);
for (SQLRowAccessor rowElt : myListItem) {
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/DevisBlSQLInjector.java
33,7 → 33,7
}
mapDefaultValues(tableBon.getField("SOURCE"), tableBon.getName());
map(tableDevis.getField("ID_DEVIS"), tableBon.getField("IDSOURCE"));
if (tableDevis.getTable().contains("ID_POLE_PRODUIT")) {
if (tableDevis.getTable().contains("ID_POLE_PRODUIT") && tableBon.getTable().contains("ID_POLE_PRODUIT")) {
map(tableDevis.getField("ID_POLE_PRODUIT"), tableBon.getField("ID_POLE_PRODUIT"));
}
if (getSource().getTable().contains("ID_CLIENT_DEPARTEMENT")) {
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/BonFactureSQLInjector.java
52,6 → 52,12
if (tableBon.contains("PORT_HT")) {
map(tableBon.getField("PORT_HT"), tableFacture.getField("PORT_HT"));
}
if (getSource().contains("FRAIS_DOCUMENT_HT") && getDestination().contains("FRAIS_DOCUMENT_HT")) {
map(getSource().getField("FRAIS_DOCUMENT_HT"), getDestination().getField("FRAIS_DOCUMENT_HT"));
}
if (getSource().contains("ID_TAXE_FRAIS_DOCUMENT") && getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
map(getSource().getField("ID_TAXE_FRAIS_DOCUMENT"), getDestination().getField("ID_TAXE_FRAIS_DOCUMENT"));
}
if (tableBon.contains("REMISE_HT")) {
map(tableBon.getField("REMISE_HT"), tableFacture.getField("REMISE_HT"));
}
74,7 → 80,14
transfertReference(srcRow, rowVals, "NOM", "NOM");
transfertReference(srcRow, rowVals, "INFOS", "INFOS");
transfertNumberReference(srcRow, rowVals, tableElementDestination, "ID_SAISIE_VENTE_FACTURE");
 
if (getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
final SQLRowAccessor rowClient = srcRow.getForeign("ID_CLIENT");
SQLRowAccessor rowFrais = rowClient.getForeign("ID_FRAIS_DOCUMENT");
if (rowFrais != null && !rowFrais.isUndefined()) {
rowVals.put("FRAIS_DOCUMENT_HT", rowFrais.getLong("MONTANT_HT"));
rowVals.put("ID_TAXE_FRAIS_DOCUMENT", rowFrais.getForeignID("ID_TAXE"));
}
}
if (myListItem.size() != 0) {
final SQLInjector injector = SQLInjector.getInjector(tableElementSource, tableElementDestination);
for (SQLRowAccessor rowElt : myListItem) {
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeFactureClientSQLInjector.java
35,6 → 35,12
if (tableCommande.contains("PORT_HT")) {
map(tableCommande.getField("PORT_HT"), tableFacture.getField("PORT_HT"));
}
if (getSource().contains("FRAIS_DOCUMENT_HT") && getDestination().contains("FRAIS_DOCUMENT_HT")) {
map(getSource().getField("FRAIS_DOCUMENT_HT"), getDestination().getField("FRAIS_DOCUMENT_HT"));
}
if (getSource().contains("ID_TAXE_FRAIS_DOCUMENT") && getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
map(getSource().getField("ID_TAXE_FRAIS_DOCUMENT"), getDestination().getField("ID_TAXE_FRAIS_DOCUMENT"));
}
if (tableCommande.contains("ACOMPTE_COMMANDE")) {
map(tableCommande.getField("ACOMPTE_COMMANDE"), tableFacture.getField("ACOMPTE_COMMANDE"));
}
80,6 → 86,14
transfertReference(srcRow, rowVals, "NOM", "NOM");
transfertReference(srcRow, rowVals, "INFOS", "INFOS");
transfertNumberReference(srcRow, rowVals, tableElementDestination, "ID_SAISIE_VENTE_FACTURE");
if (getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
final SQLRowAccessor rowClient = srcRow.getForeign("ID_CLIENT");
SQLRowAccessor rowFrais = rowClient.getForeign("ID_FRAIS_DOCUMENT");
if (rowFrais != null && !rowFrais.isUndefined()) {
rowVals.put("FRAIS_DOCUMENT_HT", rowFrais.getLong("MONTANT_HT"));
rowVals.put("ID_TAXE_FRAIS_DOCUMENT", rowFrais.getForeignID("ID_TAXE"));
}
}
if (myListItem.size() != 0) {
final SQLInjector injector = SQLInjector.getInjector(tableElementSource, tableElementDestination);
for (SQLRowAccessor rowElt : myListItem) {
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/DevisBlEltSQLInjector.java
New file
0,0 → 1,28
/*
* 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.injector;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInjector;
 
public class DevisBlEltSQLInjector extends SQLInjector {
public DevisBlEltSQLInjector(final DBRoot root) {
super(root, "DEVIS_ELEMENT", "BON_DE_LIVRAISON_ELEMENT", false);
createDefaultMap();
mapDefaultValues(getDestination().getField("QTE_LIVREE"), Integer.valueOf(0));
if (getDestination().contains("ID_DEVIS_ELEMENT")) {
map(getSource().getKey(), getDestination().getField("ID_DEVIS_ELEMENT"));
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeBlSQLInjector.java
54,6 → 54,12
if (tableBl.contains("PORT_HT")) {
map(tableCmd.getField("PORT_HT"), tableBl.getField("PORT_HT"));
}
if (getSource().contains("FRAIS_DOCUMENT_HT") && getDestination().contains("FRAIS_DOCUMENT_HT")) {
map(getSource().getField("FRAIS_DOCUMENT_HT"), getDestination().getField("FRAIS_DOCUMENT_HT"));
}
if (getSource().contains("ID_TAXE_FRAIS_DOCUMENT") && getDestination().contains("ID_TAXE_FRAIS_DOCUMENT")) {
map(getSource().getField("ID_TAXE_FRAIS_DOCUMENT"), getDestination().getField("ID_TAXE_FRAIS_DOCUMENT"));
}
if (tableBl.contains("REMISE_HT")) {
map(tableCmd.getField("REMISE_HT"), tableBl.getField("REMISE_HT"));
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/AbstractJOOReportsSheet.java
231,7 → 231,7
}
}
 
private File getDocumentFile() {
public File getDocumentFile() {
File outputDir = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(getDefaultTemplateID());
return new File(outputDir, getFileName() + ".odt");
}
302,12 → 302,15
return init;
}
 
public File getPDFDocumentFile() {
final File outputPDFDirectory = DocumentLocalStorageManager.getInstance().getPDFOutputDirectory(this.templateId);
return new File(outputPDFDirectory, getFileName() + ".pdf");
}
 
public void exportToPdf() {
// Export vers PDF
final String fileName = getFileName();
final File fileOutOO = getDocumentFile();
final File outputPDFDirectory = DocumentLocalStorageManager.getInstance().getPDFOutputDirectory(this.templateId);
final File fileOutPDF = new File(outputPDFDirectory, fileName + ".pdf");
final File fileOutPDF = getPDFDocumentFile();
 
if (!fileOutOO.exists()) {
generate(false, false, "");
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/AbstractLocalTemplateProvider.java
47,7 → 47,7
throw new NullPointerException("null templateId");
}
File templateFile1 = getTemplateFromLocalFile(templateId, language, type);
if (templateFile1 != null && templateFile1.exists()) {
if (templateFile1 != null && templateFile1.exists() && !templateFile1.isDirectory()) {
return templateFile1;
}
File templateFile2 = getTemplateFromLocalFile(templateId + ".ods", language, type);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationListeColumnXML.java
24,12 → 24,16
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.StreamUtils;
import org.openconcerto.utils.io.BOMSkipper;
 
import java.awt.Point;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
46,7 → 50,7
public class OOgenerationListeColumnXML {
 
// Cache pour la recherche des styles
private static Map<Sheet, Map<String, Map<Integer, String>>> cacheStyle = new HashMap<Sheet, Map<String, Map<Integer, String>>>();
private static Map<Sheet, Map<String, Map<Integer, String>>> cacheStyle = new HashMap<>();
 
public static File genere(String modele, File pathDest, String fileDest, Map<Integer, List<Map<String, Object>>> liste, Map<Integer, Map<String, Object>> values) {
return genere(modele, pathDest, fileDest, liste, values, new HashMap<Integer, Map<Integer, String>>(), null, null);
61,7 → 65,11
if (xmlConfiguration == null) {
throw new IllegalStateException("Template configuration " + templateId + " not found (" + TemplateManager.getInstance().getClass().getName() + ")");
}
Document doc = builder.build(xmlConfiguration);
final BufferedReader xmlConfigurationReader = new BufferedReader(new InputStreamReader(xmlConfiguration, Charset.forName("UTF8")));
BOMSkipper.skip(xmlConfigurationReader);
final Document doc = builder.build(xmlConfigurationReader);
xmlConfigurationReader.close();
xmlConfiguration.close();
 
// On initialise un nouvel élément racine avec l'élément racine du
// document.
84,7 → 92,7
for (Integer i : liste.keySet()) {
final Sheet sheet = spreadSheet.getSheet(i);
List children = racine.getChildren("element" + i);
if (children.size() == 0) {
if (children.isEmpty()) {
children = racine.getChildren("element");
}
parseElementsXML(children, sheet, values.get(i));
138,7 → 146,7
}
Object oLastColTmp = tableau.getAttributeValue("lastColumn");
int lastColumn = -1;
int endPageLine = Integer.valueOf(tableau.getAttributeValue("endPageLine"));
int endPageLine = Integer.parseInt(tableau.getAttributeValue("endPageLine"));
if (oLastColTmp != null) {
lastColumn = sheet.resolveHint(oLastColTmp.toString() + 1).x + 1;
}
202,11 → 210,7
*/
private static int fillTable(Element tableau, List<Map<String, Object>> liste, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test, Map<Integer, String> style) {
 
// int nbPage = 1;
// int currentLineTmp = Integer.valueOf(tableau.getAttributeValue("firstLine"));
// int currentLine = Integer.valueOf(tableau.getAttributeValue("firstLine"));
// int endPageLine = Integer.valueOf(tableau.getAttributeValue("endPageLine"));
int endLine = Integer.valueOf(tableau.getAttributeValue("endLine"));
int endLine = Integer.parseInt(tableau.getAttributeValue("endLine"));
 
List listElts = tableau.getChildren("element");
 
222,7 → 226,6
int currentCol = firstCol;
for (int i = 0; i < liste.size(); i++) {
Map<String, Object> mValues = liste.get(i);
// System.err.println(mValues);
if (currentCol != firstCol) {
for (int k = 0; k < endLine; k++) {
MutableCell<SpreadSheet> c1 = sheet.getCellAt(firstCol, k);
464,9 → 467,8
}
 
// Copie de l'odsp
try {
File odspOut = new File(pathDest, fileName + ".odsp");
InputStream odspIn = TemplateManager.getInstance().getTemplatePrintConfiguration(templateId, rowLanguage != null ? rowLanguage.getString("CHEMIN") : null, null);
File odspOut = new File(pathDest, fileName + ".odsp");
try (final InputStream odspIn = TemplateManager.getInstance().getTemplatePrintConfiguration(templateId, rowLanguage != null ? rowLanguage.getString("CHEMIN") : null, null);) {
if (odspIn != null) {
StreamUtils.copy(odspIn, odspOut);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/DepotChequeXmlSheet.java
New file
0,0 → 1,44
/*
* 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.generationDoc.gestcomm;
 
import org.openconcerto.erp.generationDoc.AbstractSheetXMLWithDate;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
 
public class DepotChequeXmlSheet extends AbstractSheetXMLWithDate {
 
public static final String TEMPLATE_ID = "DepotCheque";
public static final String TEMPLATE_PROPERTY_NAME = "LocationDepotCheque";
 
@Override
public String getName() {
 
return "DepotCheque" + this.row.getID();
}
 
public DepotChequeXmlSheet(SQLRow row) {
super(row);
this.printer = PrinterNXProps.getInstance().getStringProperty("FacturePrinter");
this.elt = Configuration.getInstance().getDirectory().getElement("DEPOT_CHEQUE");
getDefaultTemplateId();
}
 
@Override
public String getDefaultTemplateId() {
return TEMPLATE_ID;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/ReportingTaxeComplementaireSheetXML.java
83,15 → 83,25
private static SQLTable tableVF = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE").getTable();
 
class TaxeComplRecap {
private final String code, nom;
private final String code, nom, numeroCptProduit, numeroCpt;
private BigDecimal percentTaxe, totalBase, qte;
 
public TaxeComplRecap(String code, String nom, BigDecimal percentTaxe) {
this.code = code;
this.nom = nom;
public TaxeComplRecap(SQLRowAccessor foreignTaxeCompl) {
this.code = foreignTaxeCompl.getString("CODE");
this.nom = foreignTaxeCompl.getString("NOM");
this.qte = BigDecimal.ZERO;
this.percentTaxe = percentTaxe;
this.percentTaxe = foreignTaxeCompl.getBigDecimal("POURCENT");
this.totalBase = BigDecimal.ZERO;
if (foreignTaxeCompl.getObject("ID_COMPTE_PCE") != null && !foreignTaxeCompl.isForeignEmpty("ID_COMPTE_PCE")) {
this.numeroCpt = foreignTaxeCompl.getForeign("ID_COMPTE_PCE").getString("NUMERO");
} else {
this.numeroCpt = "";
}
if (foreignTaxeCompl.getObject("ID_COMPTE_PCE_PRODUITS") != null && !foreignTaxeCompl.isForeignEmpty("ID_COMPTE_PCE_PRODUITS")) {
this.numeroCptProduit = foreignTaxeCompl.getForeign("ID_COMPTE_PCE_PRODUITS").getString("NUMERO");
} else {
this.numeroCptProduit = "";
}
}
 
public void cumul(BigDecimal qte, BigDecimal total) {
107,6 → 117,14
return nom;
}
 
public String getNumeroCpt() {
return numeroCpt;
}
 
public String getNumeroCptProduit() {
return numeroCptProduit;
}
 
public BigDecimal getQte() {
return qte;
}
142,8 → 160,10
rowvalsVFElt.put("T_PV_HT", null);
rowvalsVFElt.put("QTE", null);
rowvalsVFElt.put("QTE_UNITAIRE", null);
rowvalsVFElt.putRowValues("ID_ARTICLE").putRowValues("ID_TAXE_COMPLEMENTAIRE").putNulls("CODE", "NOM", "POURCENT");
 
final SQLRowValues rowValsTaxeCompl = rowvalsVFElt.putRowValues("ID_ARTICLE").putRowValues("ID_TAXE_COMPLEMENTAIRE");
rowValsTaxeCompl.putNulls("CODE", "NOM", "POURCENT");
rowValsTaxeCompl.putRowValues("ID_COMPTE_PCE_PRODUITS").putNulls("NUMERO", "NOM");
rowValsTaxeCompl.putRowValues("ID_COMPTE_PCE").putNulls("NUMERO", "NOM");
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowvalsVFElt);
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
166,7 → 186,7
if (recap.containsKey(foreignTaxeCompl.getID())) {
r = recap.get(foreignTaxeCompl.getID());
} else {
r = new TaxeComplRecap(foreignTaxeCompl.getString("CODE"), foreignTaxeCompl.getString("NOM"), foreignTaxeCompl.getBigDecimal("POURCENT"));
r = new TaxeComplRecap(foreignTaxeCompl);
recap.put(foreignTaxeCompl.getID(), r);
}
r.cumul(sqlRowValues.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowValues.getInt("QTE"))), sqlRowValues.getBigDecimal("T_PV_HT"));
186,6 → 206,9
for (TaxeComplRecap item : recap.values()) {
Map<String, Object> vals = new HashMap<String, Object>();
 
vals.put("COMPTE_NUMERO", item.getNumeroCpt());
vals.put("COMPTE_PRODUIT_NUMERO", item.getNumeroCptProduit());
 
vals.put("CODE", item.getCode());
vals.put("NOM", item.getNom());
vals.put("QTE", item.getQte());
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/InvalidTemplateException.java
New file
0,0 → 1,26
/*
* 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.generationDoc;
 
public class InvalidTemplateException extends RuntimeException {
 
public InvalidTemplateException(String cause) {
super(cause);
}
 
public InvalidTemplateException(String cause, Exception e) {
super(cause, e);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/A4.java
28,6 → 28,6
final double width = (210 * DPI) / INCH_TO_MM;
final double height = (297 * DPI) / INCH_TO_MM;
setSize(width, height);
setImageableArea(hMargin, vMargin, width + 2 * hMargin, height - 2 * vMargin);
setImageableArea(hMargin, vMargin, width - 2 * hMargin, height - 2 * vMargin);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/DefaultLocalTemplateProvider.java
109,8 → 109,14
final File from = getFile(templateId + ext, language, type);
final File to = getLocalFile(templateId + ext, language, type);
try {
if (from.exists() && !to.exists()) {
FileUtils.copyFile(from, to);
if (from != null && to != null && from.exists() && !to.exists()) {
final File parentDir = to.getParentFile();
if (parentDir != null) {
if (!parentDir.exists()) {
parentDir.mkdirs();
}
FileUtils.copyFile(from, to);
}
}
} catch (IOException e) {
throw new IllegalStateException("Copie impossible", e);
140,7 → 146,7
for (int i = 0; i < EXTS.length; i++) {
final String ext = EXTS[i];
final File local = getLocalFile(templateId + ext, language, type);
if (local.exists()) {
if (local != null && local.exists()) {
local.delete();
ensureDelete(local);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/element/ModeleSQLElement.java
33,15 → 33,17
super("MODELE", "un modele ", "modeles");
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
final List<String> l = new ArrayList<>(2);
l.add("NOM");
l.add("ID_TYPE_MODELE");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
final List<String> l = new ArrayList<>(2);
l.add("NOM");
l.add("ID_TYPE_MODELE");
return l;
52,7 → 54,7
 
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<String>();
final Set<String> s = new HashSet<>();
// s.add("NOM");
// s.add("ID_TYPE_MODELE");
return s;
65,8 → 67,13
};
}
 
@Override
public String getDescription(SQLRow fromRow) {
return fromRow.getString("NOM");
}
 
@Override
protected String createCode() {
return "document.template";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/element/TypeModeleSQLElement.java
16,8 → 16,7
*/
package org.openconcerto.erp.generationDoc.element;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.DBRoot;
33,16 → 32,12
import java.util.Map;
import java.util.Set;
 
public class TypeModeleSQLElement extends ConfSQLElement {
public class TypeModeleSQLElement extends ComptaSQLConfElement {
 
public TypeModeleSQLElement(DBRoot root) {
super(root.getTable("TYPE_MODELE"), "un type_modele ", "type_modeles");
super(root.getTable("TYPE_MODELE"), "un type de modèle", "types de modèles");
}
 
public TypeModeleSQLElement() {
this(Configuration.getInstance().getRoot());
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
91,17 → 86,20
 
if (this.template == null) {
this.template = new HashMap<String, String>();
SQLSelect sel = new SQLSelect(getTable().getBase());
SQLSelect sel = new SQLSelect();
sel.addSelectStar(getTable());
List<SQLRow> rows = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
for (SQLRow sqlRow : rows) {
template.put(sqlRow.getString("TABLE"), sqlRow.getString("DEFAULT_MODELE"));
for (SQLRow sqlRow : SQLRowListRSH.execute(sel)) {
this.template.put(sqlRow.getString("TABLE"), sqlRow.getString("DEFAULT_MODELE"));
}
 
}
 
return template;
return this.template;
 
}
 
@Override
protected String createCode() {
return "document.template-type";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationXML.java
37,15 → 37,19
import org.openconcerto.utils.StreamUtils;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.ITransformer;
import org.openconcerto.utils.io.BOMSkipper;
 
import java.awt.Point;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
77,12 → 81,12
private DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
 
// Cache pour la recherche des styles
private Map<Sheet, Map<String, Map<Integer, String>>> cacheStyle = new HashMap<Sheet, Map<String, Map<Integer, String>>>();
private Map<SQLRowAccessor, Map<String, Object>> taxe = new HashMap<SQLRowAccessor, Map<String, Object>>();
private Map<String, Map<Integer, SQLRowAccessor>> cacheForeign = new HashMap<String, Map<Integer, SQLRowAccessor>>();
private Map<Sheet, Map<String, Map<Integer, String>>> cacheStyle = new HashMap<>();
private Map<SQLRowAccessor, Map<String, Object>> taxe = new HashMap<>();
private Map<String, Map<Integer, SQLRowAccessor>> cacheForeign = new HashMap<>();
 
// Cache pour les SQLRow du tableau
private Map<String, List<? extends SQLRowAccessor>> rowsEltCache = new HashMap<String, List<? extends SQLRowAccessor>>();
private Map<String, List<? extends SQLRowAccessor>> rowsEltCache = new HashMap<>();
private final OOXMLCache rowRefCache = new OOXMLCache();
private final SQLRow row;
 
155,7 → 159,11
+ ((typeTemplate == null) ? "" : typeTemplate));
return null;
}
Document doc = builder.build(xmlConfiguration);
 
final BufferedReader xmlConfigurationReader = new BufferedReader(new InputStreamReader(xmlConfiguration, Charset.forName("UTF8")));
BOMSkipper.skip(xmlConfigurationReader);
final Document doc = builder.build(xmlConfigurationReader);
xmlConfigurationReader.close();
xmlConfiguration.close();
 
// On initialise un nouvel élément racine avec l'élément racine du document.
239,7 → 247,7
// et d'optimiser la recherche
Object oLastColTmp = tableau.getAttributeValue("lastColumn");
int lastColumn = -1;
int endPageLine = Integer.valueOf(tableau.getAttributeValue("endPageLine"));
int endPageLine = Integer.parseInt(tableau.getAttributeValue("endPageLine"));
if (oLastColTmp != null) {
lastColumn = sheet.resolveHint(oLastColTmp.toString() + 1).x + 1;
}
251,8 → 259,8
return;
}
int nbPage = fillTable(tableau, row, sheet, mapStyle, true, rowLanguage);
int firstLine = Integer.valueOf(tableau.getAttributeValue("firstLine"));
int endLine = Integer.valueOf(tableau.getAttributeValue("endLine"));
int firstLine = Integer.parseInt(tableau.getAttributeValue("firstLine"));
int endLine = Integer.parseInt(tableau.getAttributeValue("endLine"));
Object printRangeObj = sheet.getPrintRanges();
 
System.err.println("Nombre de page == " + nbPage);
286,7 → 294,7
int lineToAdd = endPageLine - endLine;
String repeatedCount = tableau.getAttributeValue("repeatedCount");
if (repeatedCount != null && repeatedCount.trim().length() > 0) {
int count = Integer.valueOf(repeatedCount);
int count = Integer.parseInt(repeatedCount);
sheet.duplicateRows(firstLine, lineToAdd / count, count);
final int rest = lineToAdd % count;
// Si le nombre de ligne ne termine pas à la fin de la page
324,7 → 332,7
cell2.setValue("Page " + (i + start) + "/" + nbPageRef);
}
if (pageAdd != null && pageAdd.trim().length() > 0) {
int pAdd = Integer.valueOf(pageAdd);
int pAdd = Integer.parseInt(pageAdd);
for (int i = 0; i < pAdd; i++) {
Sheet s = sheet.getSpreadSheet().getSheet(idSheet + i + 1);
MutableCell<SpreadSheet> cell2 = s.getCellAt(pageRef);
362,7 → 370,7
SQLRowAccessor foreign = row.getForeign(field.getName());
 
if (c == null) {
Map<Integer, SQLRowAccessor> map = new HashMap<Integer, SQLRowAccessor>();
Map<Integer, SQLRowAccessor> map = new HashMap<>();
map.put(i, foreign);
cacheForeign.put(field.getName(), map);
} else {
371,7 → 379,6
 
return foreign;
}
// return row.getForeignRow(field.getName());
 
}
 
384,7 → 391,7
SQLBackgroundTableCacheItem prefsCpt = SQLBackgroundTableCache.getInstance().getCacheForTable(tableElt.getTable("PREFS_COMPTE"));
if (tableElt.contains("ID_TAXE") && tableElt.contains("T_PA_HT")) {
boolean achat = tableElt.contains("T_PA_TTC");
TotalCalculator calc = new TotalCalculator("T_PA_HT", achat ? "T_PA_HT" : "T_PV_HT", null, achat, null);
TotalCalculator calc = new TotalCalculator("T_PA_HT", achat ? "T_PA_HT" : "T_PV_HT", null, achat, null, null);
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean bServiceActive = Boolean.valueOf(val);
 
487,7 → 494,7
Map<SQLRowAccessor, Tuple2<BigDecimal, BigDecimal>> taxeCalc = calc.getMapHtTVARowTaux();
for (SQLRowAccessor sqlRow : taxeCalc.keySet()) {
Tuple2<BigDecimal, BigDecimal> v = taxeCalc.get(sqlRow);
Map<String, Object> m = new HashMap<String, Object>();
Map<String, Object> m = new HashMap<>();
m.put("MONTANT_HT", v.get0());
m.put("MONTANT_TVA", v.get1());
taxe.put(sqlRow, m);
510,12 → 517,9
 
StyleSQLElement styleElt = Configuration.getInstance().getDirectory().getElement(StyleSQLElement.class);
 
boolean cache = false;
String ref = tableau.getAttributeValue("table") + "_" + row.getTable().getName() + row.getID();
if (rowsEltCache.get(ref) == null) {
rowsEltCache.put(ref, tableElement.getRows());
} else {
cache = true;
}
List<Element> listElts = tableau.getChildren("element");
 
553,10 → 557,10
}
 
// Cache des valeurs
Map<Element, Object> mapValues = new HashMap<Element, Object>();
Map<Element, Object> mapValues = new HashMap<>();
 
// Test si l'ensemble des donnees tient sur la page courante
Map<String, Integer> tmpMapNbCel = new HashMap<String, Integer>();
Map<String, Integer> tmpMapNbCel = new HashMap<>();
int tmpNbCellule = fillTableLine(sheet, mapStyle, true, rowLanguage, tableElement, currentLine, listElts, numeroRef, rowElt, tmpMapNbCel, styleName, mapValues);
for (String s : tmpMapNbCel.keySet()) {
tmpNbCellule = Math.max(tmpNbCellule, tmpMapNbCel.get(s));
569,7 → 573,7
}
 
// Remplissage reel des cellules
Map<String, Integer> mapNbCel = new HashMap<String, Integer>();
Map<String, Integer> mapNbCel = new HashMap<>();
int nbCellule = fillTableLine(sheet, mapStyle, test, rowLanguage, tableElement, currentLine, listElts, numeroRef, rowElt, mapNbCel, styleName, mapValues);
 
for (String s : mapNbCel.keySet()) {
707,7 → 711,7
 
private void fillTaxeDocumentMap(Element tableau, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test) {
 
int line = Integer.valueOf(tableau.getAttributeValue("firstLine"));
int line = Integer.parseInt(tableau.getAttributeValue("firstLine"));
List<Element> listElts = tableau.getChildren("element");
 
for (SQLRowAccessor rowTaxe : taxe.keySet()) {
953,12 → 957,10
}
 
// Copie de l'odsp
try {
File odspOut = new File(pathDest, fileName + ".odsp");
final InputStream odspIn = TemplateManager.getInstance().getTemplatePrintConfiguration(templateId, langage, null);
File odspOut = new File(pathDest, fileName + ".odsp");
try (final InputStream odspIn = TemplateManager.getInstance().getTemplatePrintConfiguration(templateId, langage, null);) {
if (odspIn != null) {
StreamUtils.copy(odspIn, odspOut);
odspIn.close();
}
} catch (FileNotFoundException e) {
System.err.println("OOgenerationXML.saveSpreadSheet() : Le fichier odsp n'existe pas.");
985,7 → 987,7
System.err.println("End row search : " + rowCount);
for (int i = 0; i < rowCount; i++) {
int x = 0;
Map<Integer, String> mapCellStyle = new HashMap<Integer, String>();
Map<Integer, String> mapCellStyle = new HashMap<>();
String style = "";
 
for (int j = 0; j < columnCount; j++) {
1045,7 → 1047,7
List<Element> listTable = racine.getChildren("table");
 
Element tableau;
if (listTable.size() == 0) {
if (listTable.isEmpty()) {
return false;
} else {
if (listTable.get(0).getAttributeValue("table").equalsIgnoreCase("TVA")) {
1058,7 → 1060,7
 
Object oLastColTmp = tableau.getAttributeValue("lastColumn");
int lastColumn = -1;
int endPageLine = Integer.valueOf(tableau.getAttributeValue("endPageLine"));
int endPageLine = Integer.parseInt(tableau.getAttributeValue("endPageLine"));
if (oLastColTmp != null) {
lastColumn = sheet.resolveHint(oLastColTmp.toString() + 1).x + 1;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationListeXML.java
24,12 → 24,16
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.StreamUtils;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.io.BOMSkipper;
 
import java.awt.Point;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
62,7 → 66,11
if (xmlConfiguration == null) {
throw new IllegalStateException("Template configuration " + templateId + " not found (" + TemplateManager.getInstance().getClass().getName() + ")");
}
Document doc = builder.build(xmlConfiguration);
final BufferedReader xmlConfigurationReader = new BufferedReader(new InputStreamReader(xmlConfiguration, Charset.forName("UTF8")));
BOMSkipper.skip(xmlConfigurationReader);
final Document doc = builder.build(xmlConfigurationReader);
xmlConfigurationReader.close();
xmlConfiguration.close();
 
// On initialise un nouvel élément racine avec l'élément racine du
// document.
74,6 → 82,7
throw new IllegalStateException("Template " + templateId + " not found (" + TemplateManager.getInstance().getClass().getName() + ")");
}
final SpreadSheet spreadSheet = new ODPackage(template).getSpreadSheet();
 
Sheet sheet0 = spreadSheet.getSheet(0);
if (sheetName != null && sheetName.size() > 0) {
for (int i = 1; i < sheetName.size(); i++) {
83,7 → 92,12
}
 
for (Integer i : liste.keySet()) {
final Sheet sheet = spreadSheet.getSheet(i);
final Sheet sheet;
try {
sheet = spreadSheet.getSheet(i);
} catch (Exception e) {
throw new InvalidTemplateException("La feuille numéro " + i + " n'est pas dans le modèle", e);
}
List children = racine.getChildren("element" + i);
if (children.size() == 0) {
children = racine.getChildren("element");
96,6 → 110,7
parseListeXML(child, liste.get(i), sheet, mapStyle.get(i));
}
cacheStyle.clear();
 
// Sauvegarde du fichier
return saveSpreadSheet(spreadSheet, pathDest, fileDest, templateId, rowLanguage);
 
555,9 → 570,8
}
 
// Copie de l'odsp
try {
File odspOut = new File(pathDest, fileName + ".odsp");
InputStream odspIn = TemplateManager.getInstance().getTemplatePrintConfiguration(templateId, rowLanguage != null ? rowLanguage.getString("CHEMIN") : null, null);
File odspOut = new File(pathDest, fileName + ".odsp");
try (final InputStream odspIn = TemplateManager.getInstance().getTemplatePrintConfiguration(templateId, rowLanguage != null ? rowLanguage.getString("CHEMIN") : null, null);) {
if (odspIn != null) {
StreamUtils.copy(odspIn, odspOut);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLCache.java
24,6 → 24,7
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLSelectJoin;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.CompareUtils;
301,8 → 302,11
if (orderBy != null && orderBy.contains(".")) {
String fieldRefTable = orderBy.substring(0, orderBy.indexOf('.'));
String field = orderBy.substring(orderBy.indexOf('.') + 1, orderBy.length());
sel.addJoin("LEFT", sel.getAlias(tableForeign).getField(fieldRefTable));
sel.addFieldOrder(sel.getAlias(tableForeign.getForeignTable(fieldRefTable)).getField(field));
if (sel.getJoin(tableForeign.getField(fieldRefTable)) == null) {
sel.addJoin("LEFT", sel.getAlias(tableForeign).getField(fieldRefTable));
}
SQLSelectJoin join = sel.getJoin(tableForeign.getField(fieldRefTable));
sel.addFieldOrder(join.getJoinedTable().getField(field));
} else {
sel.addFieldOrder(tableForeign.getOrderField());
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SheetXml.java
15,7 → 15,10
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.PreviewFrame;
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
import org.openconcerto.erp.core.sales.quote.report.PaypalStamper;
import org.openconcerto.erp.generationDoc.element.TypeModeleSQLElement;
import org.openconcerto.erp.preferences.PayPalPreferencePanel;
import org.openconcerto.erp.storage.CloudStorageEngine;
import org.openconcerto.erp.storage.StorageEngine;
import org.openconcerto.erp.storage.StorageEngines;
26,19 → 29,31
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.GraphicsEnvironment;
import java.awt.print.PrinterJob;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.Thread.UncaughtExceptionHandler;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
213,8 → 228,7
}
 
} catch (Exception e) {
e.printStackTrace();
ExceptionHandler.handle("Impossible de charger le document OpenOffice", e);
ExceptionHandler.handle("Impossible de charger le document OpenOffice " + pdfFile.getAbsolutePath() + "(viewer : " + useODSViewer + ")", e);
}
}
 
239,12 → 253,87
return this.meta;
}
 
public static void createPDF(final File generatedFile, final File pdfFile, final OpenDocument doc, String storagePath) {
public void createPDF(final File generatedFile, final File pdfFile, final OpenDocument doc, String storagePath) {
if (pdfFile == null) {
throw new IllegalArgumentException("null PDF file");
}
try {
SheetUtils.convert2PDF(doc, pdfFile);
if (VenteFactureXmlSheet.TEMPLATE_ID.equals(getDefaultTemplateId())) {
final SQLPreferences prefs = SQLPreferences.getMemCached(getElement().getTable().getDBRoot());
if (prefs.getBoolean(PayPalPreferencePanel.PAYPAL_INVOICE, false)) {
try {
final File inFile = File.createTempFile("oc_", pdfFile.getName());
SheetUtils.convert2PDF(doc, inFile);
PaypalStamper s = new PaypalStamper();
int x = prefs.getInt(PayPalPreferencePanel.PAYPAL_INVOICE_X, 0);
int y = prefs.getInt(PayPalPreferencePanel.PAYPAL_INVOICE_Y, 0);
 
// Reference
String ref = getSQLRow().getString("NUMERO");
// Montant : ex : 10.55
long cents = getSQLRow().getLong("NET_A_PAYER");
String amount = cents / 100 + "." + cents % 100;
// Devise
// TODO : autres devises
String currency = "EUR";
// POST
final URL url = new URL("https://cloud.openconcerto.org/payment");
final URLConnection con = url.openConnection();
final HttpURLConnection http = (HttpURLConnection) con;
http.setRequestMethod("POST");
http.setDoOutput(true);
http.setDefaultUseCaches(false);
 
String hyperlink = null;
// x-www-form-urlencoded
final Map<String, String> arguments = new HashMap<>();
arguments.put("pI", prefs.get(PayPalPreferencePanel.PAYPAL_CLIENTID, ""));
arguments.put("pS", prefs.get(PayPalPreferencePanel.PAYPAL_SECRET, ""));
arguments.put("ref", ref);
arguments.put("amount", amount);
arguments.put("currency", currency);
arguments.put("type", "paypal");
final StringJoiner sj = new StringJoiner("&");
for (Map.Entry<String, String> entry : arguments.entrySet()) {
sj.add(URLEncoder.encode(entry.getKey(), "UTF-8") + "=" + URLEncoder.encode(entry.getValue(), "UTF-8"));
}
final String postData = sj.toString();
System.err.println("SheetXml.createPDF() " + postData);
byte[] out = postData.getBytes(StandardCharsets.UTF_8);
int length = out.length;
http.setFixedLengthStreamingMode(length);
http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
http.connect();
try (OutputStream os = http.getOutputStream()) {
os.write(out);
}
if (http.getResponseCode() != 401) {
 
InputStream is = http.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
 
int numCharsRead;
char[] charArray = new char[1024];
StringBuilder sb = new StringBuilder();
while ((numCharsRead = isr.read(charArray)) > 0) {
sb.append(charArray, 0, numCharsRead);
}
//
hyperlink = sb.toString();
}
s.addLink(inFile, pdfFile, x, y, hyperlink);
} catch (Exception e) {
e.printStackTrace();
SheetUtils.convert2PDF(doc, pdfFile);
}
 
} else {
SheetUtils.convert2PDF(doc, pdfFile);
}
} else {
SheetUtils.convert2PDF(doc, pdfFile);
}
 
} catch (Throwable e) {
ExceptionHandler.handle("Impossible de créer le PDF " + pdfFile.getAbsolutePath(), e);
}
421,8 → 510,23
File f;
try {
f = getOrCreateDocumentFile();
// ComptaPropsConfiguration.getOOConnexion().loadDocument(f, false);
OOUtils.open(f);
if (f != null && f.exists()) {
OOUtils.open(f);
} else {
if (!GraphicsEnvironment.isHeadless()) {
if (f != null) {
JOptionPane.showMessageDialog(null, "Le fichier " + f.getAbsolutePath() + " est manquant");
} else {
JOptionPane.showMessageDialog(null, "Fichier manquant");
}
} else {
if (f != null) {
throw new FileNotFoundException(f.getAbsolutePath() + " missing");
} else {
throw new NullPointerException("null document");
}
}
}
} catch (Exception e) {
ExceptionHandler.handle("Impossible d'ouvrir le document.", e);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLField.java
84,6 → 84,9
// {
String field = this.elt.getAttributeValue("name");
 
if (field != null && field.trim().length() > 0 && !this.row.getTable().contains(field)) {
throw new InvalidTemplateException("Le champ " + field + " n'existe pas dans la table " + this.row.getTable().getName());
}
final SQLField sqlField = (field == null || field.trim().length() == 0) ? null : this.row.getTable().getField(field);
boolean isForeignField = (sqlField == null) ? false : this.row.getTable().getForeignKeys().contains(sqlField);
 
137,10 → 140,16
String typeComp = this.elt.getAttributeValue("type");
if (this.op != null && this.op.trim().length() > 0 && !(typeComp != null && typeComp.trim().length() > 0 && typeComp.toLowerCase().startsWith("deviselettre"))) {
String field2 = this.elt.getAttributeValue("name2");
if (!this.row.getTable().contains(field)) {
throw new InvalidTemplateException("Le champ " + field + " n'existe pas dans la table " + this.row.getTable().getName());
}
Number o = (Number) this.row.getObject(field);
 
Number o2;
if (field2 != null && field2.trim().length() > 0) {
if (!this.row.getTable().contains(field2)) {
throw new InvalidTemplateException("Le champ " + field2 + " n'existe pas dans la table " + this.row.getTable().getName());
}
o2 = (Number) this.row.getObject(field2);
} else {
o2 = Double.parseDouble(this.elt.getAttributeValue("number"));
223,6 → 232,9
}
stringValue = o.toString();
} else {
if (!this.row.getTable().contains(field)) {
throw new InvalidTemplateException("Le champ " + field + " n'existe pas dans la table " + this.row.getTable().getName());
}
Object o2 = this.row.getObject(field);
 
if (o2 != null && scale != null && scale.trim().length() > 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SpreadSheetGenerator.java
14,6 → 14,7
package org.openconcerto.erp.generationDoc;
 
import static org.openconcerto.task.config.ComptaBasePropsConfiguration.getStreamStatic;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.PreviewFrame;
import org.openconcerto.erp.preferences.TemplateNXProps;
216,13 → 217,12
fTmp.renameTo(fDest);
 
fDest = new File(this.destDirOO, this.destFileName + ".ods");
final InputStream stream = getStreamStatic(fODSP);
if (stream != null) {
// Copie de l'odsp
File odspOut = new File(this.destDirOO, this.destFileName + ".odsp");
StreamUtils.copy(stream, odspOut);
stream.close();
 
try (final InputStream stream = getStreamStatic(fODSP)) {
if (stream != null) {
// Copie de l'odsp
File odspOut = new File(this.destDirOO, this.destFileName + ".odsp");
StreamUtils.copy(stream, odspOut);
}
}
try {
ssheet.saveAs(fDest);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieVenteFacture.java
139,12 → 139,14
 
SQLTable tableEchantillon = null;
BigDecimal portHT = BigDecimal.valueOf(saisieRow.getLong("PORT_HT")).movePointLeft(2);
BigDecimal fraisDocHT = BigDecimal.valueOf(saisieRow.getLong("FRAIS_DOCUMENT_HT")).movePointLeft(2);
TotalCalculator calc;
if (clientRow.getTable().contains("ID_COMPTE_PCE_PRODUIT") && !clientRow.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
calc = getValuesFromElement(false, false, "T_PV_HT", saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), tableEchantillon,
clientRow.getForeign("ID_COMPTE_PCE_PRODUIT"));
calc = getValuesFromElement(false, false, "T_PV_HT", saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), fraisDocHT,
saisieRow.getForeign("ID_TAXE_FRAIS_DOCUMENT"), tableEchantillon, clientRow.getForeign("ID_COMPTE_PCE_PRODUIT"));
} else {
calc = getValuesFromElement(saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), tableEchantillon);
calc = getValuesFromElement(saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), fraisDocHT,
saisieRow.getForeign("ID_TAXE_FRAIS_DOCUMENT"), tableEchantillon);
}
 
// On génére les ecritures si la facture n'est pas un acompte
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementAchat.java
72,6 → 72,9
}
 
SQLRow rowMvtSource = tableMouvement.getRow(mvtSource);
if (rowMvtSource == null) {
throw new IllegalStateException("Aucun mouvement source associé aux échéances.\n(Mouvement source : " + mvtSource + ", REGLER_MONTANT " + regMontantRow.getID() + ")");
}
 
// si paiement comptant
if ((modeRegRow.getInt("AJOURS") == 0) && (modeRegRow.getInt("LENJOUR") == 0)) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtFactureFournisseur.java
96,7 → 96,7
}
BigDecimal portHT = BigDecimal.valueOf(saisieRow.getLong("PORT_HT")).movePointLeft(2);
TotalCalculator calc = getValuesFromElement(rowFournisseur.getBoolean("UE"), true, "T_PA_HT", saisieRow, saisieRow.getTable().getTable("FACTURE_FOURNISSEUR_ELEMENT"), portHT,
saisieRow.getForeign("ID_TAXE_PORT"), null, rowCompteAchat);
saisieRow.getForeign("ID_TAXE_PORT"), BigDecimal.ZERO, null, null, rowCompteAchat);
 
long ttcLongValue = calc.getTotalTTC().movePointRight(2).longValue();
long htLongValue = calc.getTotalHT().movePointRight(2).longValue();
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtReglementFactureFournisseur.java
70,7 → 70,7
// long l = ((Number) avoirRow.getObject("MONTANT_TTC")).longValue();
// prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue() - l);
// } else {
prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue());
prixTTC = new PrixTTC(((Long) saisieRow.getObject("NET_A_PAYER")).longValue());
// }
 
this.date = (Date) saisieRow.getObject("DATE");
192,7 → 192,7
// long l = ((Number) avoirRow.getObject("MONTANT_TTC")).longValue();
// prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue() - l);
// } else {
prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue());
prixTTC = new PrixTTC(((Long) saisieRow.getObject("NET_A_PAYER")).longValue());
// }
 
// Ajout dans cheque fournisseur
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtDepotChequeClient.java
New file
0,0 → 1,174
/*
* 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.
*/
/*
* 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.generationEcritures;
 
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesCluster.StoreMode;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.StringUtils;
 
import java.util.ArrayList;
import java.util.List;
 
public class GenerationMvtDepotChequeClient extends GenerationEcritures {
 
private long montant;
 
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
private final SQLRow depot;
private SQLRowAccessor banque;
 
public GenerationMvtDepotChequeClient(SQLRow depot) {
this.montant = depot.getLong("MONTANT");
this.date = depot.getDate("DATE").getTime();
this.banque = depot.getForeign("ID_" + BanqueSQLElement.TABLENAME);
this.depot = depot;
// SQLRow chequeRow = base.getTable("CHEQUE_A_ENCAISSER").getRow(this.idCheque);
// String num = "";
// if (chequeRow != null && !chequeRow.isUndefined() &&
// chequeRow.getString("NUMERO").trim().length() > 0) {
// num = " N° " + chequeRow.getString("NUMERO");
// }
//
// if (s != null && s.trim().length() > 0) {
// this.nom = s + (num.trim().length() > 0 ? " - Cheque" + num : "");
// } else {
// this.nom = "Reglement cheque client" + num;
// }
}
 
public void genere() throws Exception {
System.err.println("génération des ecritures de règlement d'un cheque client du mouvement " + this.idMvt);
this.nom = this.depot.getString("NOM");
if (this.depot.getObject("ID_MOUVEMENT") == null || this.depot.isForeignEmpty("ID_MOUVEMENT")) {
this.idMvt = getNewMouvement(depot.getTable().getName(), depot.getID(), 1, this.nom);
} else {
this.idMvt = this.depot.getForeignID("ID_MOUVEMENT");
SQLRowValues rowValspiece = this.depot.getForeign("ID_MOUVEMENT").getForeign("ID_PIECE").createEmptyUpdateRow();
rowValspiece.put("NOM", this.nom);
rowValspiece.update();
}
 
// initialisation des valeurs de la map
this.putValue("ID_MOUVEMENT", new Integer(this.idMvt));
this.putValue("DATE", new java.sql.Date(this.date.getTime()));
this.putValue("NOM", this.nom);
if (this.banque == null || this.banque.isUndefined() || this.banque.isForeignEmpty("ID_JOURNAL")) {
fillJournalBanqueFromRow(depot);
} else {
int idJrnl = this.banque.getForeignID("ID_JOURNAL");
this.putValue("ID_JOURNAL", idJrnl);
}
 
List<Integer> pieceIDs = new ArrayList<Integer>();
SQLRowValues rowValsDepotElt = new SQLRowValues(depot.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
rowValsDepotElt.putNulls("MONTANT", "TIERS");
rowValsDepotElt.putRowValues("ID_CLIENT").putNulls("NOM", "ID_COMPTE_PCE");
final SQLRowValues rowValuesChq = rowValsDepotElt.putRowValues("ID_CHEQUE_A_ENCAISSER");
rowValuesChq.putNulls("SANS_VALEUR_ENCAISSEMENT").putRowValues("ID_MOUVEMENT").putNulls("ID_PIECE");
rowValuesChq.putNulls("ID_COMPTE_PCE_TIERS").putNulls("NUMERO");
List<SQLRowValues> cheques = SQLRowValuesListFetcher.create(rowValsDepotElt).fetch(new Where(rowValsDepotElt.getTable().getField("ID_DEPOT_CHEQUE"), "=", depot.getID()));
for (SQLRowValues sqlRowAccessor : cheques) {
final SQLRowAccessor clientRow = sqlRowAccessor.getForeign("ID_CLIENT");
// this.nom = this.nom + " " + StringUtils.limitLength(clientRow.getString("NOM"), 20);
this.putValue("NOM", this.nom + " " + StringUtils.limitLength(clientRow.getString("NOM"), 20));
SQLRowAccessor chequeRow = sqlRowAccessor.getForeign("ID_CHEQUE_A_ENCAISSER");
pieceIDs.add(chequeRow.getForeign("ID_MOUVEMENT").getForeignID("ID_PIECE"));
// compte Clients
SQLRowAccessor rowCptTiers = chequeRow.getForeign("ID_COMPTE_PCE_TIERS");
int idCompteClient = rowCptTiers != null && !rowCptTiers.isUndefined() ? rowCptTiers.getID() : -1;
 
if (chequeRow.getBoolean("SANS_VALEUR_ENCAISSEMENT")) {
if (idCompteClient == -1) {
if (clientRow != null) {
idCompteClient = clientRow.getInt("ID_COMPTE_PCE");
}
if (idCompteClient <= 1) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
}
} else {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("ValeurEncaissement");
}
}
 
this.putValue("ID_COMPTE_PCE", new Integer(idCompteClient));
this.putValue("DEBIT", new Long(0));
this.putValue("CREDIT", new Long(sqlRowAccessor.getLong("MONTANT")));
SQLRow insertedRow = ajoutEcriture();
 
sqlRowAccessor.createEmptyUpdateRow().put("ID_ECRITURE", insertedRow.getID()).getGraph().store(StoreMode.COMMIT, false);
sqlRowAccessor.getForeign("ID_CHEQUE_A_ENCAISSER").createEmptyUpdateRow().put("ENCAISSE", Boolean.TRUE).getGraph().store(StoreMode.COMMIT, false);
}
// compte de reglement cheque, ...
fillCompteBanqueFromRow(depot, "VenteCheque", false);
this.putValue("NOM", this.nom);
this.putValue("DEBIT", new Long(this.montant));
this.putValue("CREDIT", new Long(0));
SQLRow insertedRow = ajoutEcriture();
 
depot.createEmptyUpdateRow().put("ID_MOUVEMENT", idMvt).put("ID_ECRITURE", insertedRow.getID()).getGraph().store(StoreMode.COMMIT, false);
 
pieceIDs.add(mouvementTable.getRow(idMvt).getForeignID("ID_PIECE"));
lettrageAuto(pieceIDs, this.date);
 
System.err.println("Ecritures générées pour le mouvement " + this.idMvt);
 
}
 
// private void setDateReglement(int idCheque, Date d) throws SQLException {
// if (idCheque > 1) {
// SQLRow chequeRow =
// Configuration.getInstance().getBase().getTable("CHEQUE_A_ENCAISSER").getRow(idCheque);
// final int sourceId = MouvementSQLElement.getSourceId(chequeRow.getInt("ID_MOUVEMENT"));
// SQLRow rowMvt = Configuration.getInstance().getBase().getTable("MOUVEMENT").getRow(sourceId);
//
// if (rowMvt.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
// SQLElement eltFacture =
// Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
// SQLRow saisieRow = eltFacture.getTable().getRow(rowMvt.getInt("IDSOURCE"));
// // On fixe la date du paiement
// SQLRowValues rowValsUpdateVF = saisieRow.createEmptyUpdateRow();
// rowValsUpdateVF.put("DATE_REGLEMENT", new Timestamp(d.getTime()));
// rowValsUpdateVF.update();
// }
// }
// }
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtTicketCaisse.java
79,7 → 79,7
GenerationMvtTicketCaisse.this.putValue("ID_MOUVEMENT", Integer.valueOf(GenerationMvtTicketCaisse.this.idMvt));
}
 
TotalCalculator calc = getValuesFromElement(rowTicket, rowTicket.getTable().getTable("SAISIE_VENTE_FACTURE_ELEMENT"), BigDecimal.ZERO, null, null);
TotalCalculator calc = getValuesFromElement(rowTicket, rowTicket.getTable().getTable("SAISIE_VENTE_FACTURE_ELEMENT"), BigDecimal.ZERO, null, BigDecimal.ZERO, null, null);
long ttcLongValue = calc.getTotalTTC().movePointRight(2).longValue();
 
// compte Vente Produits
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationEcritures.java
19,6 → 19,7
import org.openconcerto.erp.core.common.ui.TotalCalculator;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
import org.openconcerto.erp.generationDoc.OOXMLCache;
import org.openconcerto.erp.generationEcritures.provider.AnalytiqueProvider;
import org.openconcerto.erp.generationEcritures.provider.AnalytiqueProviderManager;
import org.openconcerto.erp.preferences.DefaultNXProps;
26,11 → 27,13
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLBackgroundTableCacheItem;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesCluster.StoreMode;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
40,6 → 43,7
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
92,6 → 96,9
return this.rowAnalytiqueSource;
}
 
private Date dDebEx = null;
private Date dCloture = null;
 
/**
* Ajout d'une écriture et maj des totaux du compte associé
*
106,7 → 113,8
// Report des valeurs pour accelerer les IListes
Number n = (Number) this.mEcritures.get("ID_JOURNAL");
if (n != null) {
SQLRow rowJrnl = journalTable.getRow(n.intValue());
final SQLBackgroundTableCacheItem cacheForTableJrnl = SQLBackgroundTableCache.getInstance().getCacheForTable(journalTable);
SQLRow rowJrnl = cacheForTableJrnl.getRowFromId(n.intValue());
if (rowJrnl == null) {
throw new IllegalArgumentException("Le journal qui a pour ID " + n + " a été archivé.");
}
116,7 → 124,11
 
Number n2 = (Number) this.mEcritures.get("ID_COMPTE_PCE");
if (n2 != null) {
SQLRow rowCpt = compteTable.getRow(n2.intValue());
final SQLBackgroundTableCacheItem cacheForTableCpt = SQLBackgroundTableCache.getInstance().getCacheForTable(compteTable);
SQLRow rowCpt = cacheForTableCpt.getRowFromId(n2.intValue());
if (rowCpt == null) {
rowCpt = compteTable.getRow(n2.intValue());
}
this.mEcritures.put("COMPTE_NUMERO", rowCpt.getString("NUMERO"));
this.mEcritures.put("COMPTE_NOM", rowCpt.getString("NOM"));
}
143,17 → 155,18
// TODO checker que les ecritures sont entrees à une date correcte
Date d = (Date) this.mEcritures.get("DATE");
 
SQLTable tableExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON");
SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
SQLRow rowExercice = tableExercice.getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
Date dDebEx = (Date) rowExercice.getObject("DATE_DEB");
if (this.dDebEx == null) {
SQLTable tableExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON");
SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
SQLRow rowExercice = tableExercice.getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
this.dDebEx = (Date) rowExercice.getObject("DATE_DEB");
this.dCloture = (Date) rowExercice.getObject("DATE_CLOTURE");
}
 
Date dCloture = (Date) rowExercice.getObject("DATE_CLOTURE");
 
if (dCloture != null) {
if (dCloture.after(d)) {
final String error = "Impossible de générer l'écriture pour la date " + SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL).format(d)
+ ". Cette date est postérieure à la date de clôture (" + SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL).format(dCloture) + ")";
+ ". Cette date est antérieure à la date de clôture (" + SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL).format(dCloture) + ")";
throw new IllegalArgumentException(error);
}
} else {
168,17 → 181,14
valEcriture.put("IDUSER_CREATE", UserManager.getInstance().getCurrentUser().getId());
 
try {
if (valEcriture.getInvalid() == null) {
// ajout de l'ecriture
SQLRow ecritureRow = valEcriture.insert();
// ajout de l'ecriture
// SQLRow ecritureRow = valEcriture.insert();
SQLRow ecritureRow = valEcriture.getGraph().store(StoreMode.INSERT, false).getStoredRow(valEcriture);
 
// TODO Analytique
addAssocAnalytiqueFromProvider(ecritureRow, this.rowAnalytiqueSource);
return ecritureRow;
} else {
System.err.println("GenerationEcritures.java :: Error in values for insert in table " + GenerationEcritures.ecritureTable.getName() + " : " + valEcriture.toString());
throw new IllegalArgumentException("Erreur lors de la génération des écritures données incorrectes. " + valEcriture);
}
// TODO Analytique
addAssocAnalytiqueFromProvider(ecritureRow, this.rowAnalytiqueSource);
return ecritureRow;
 
} catch (SQLException e) {
System.err.println("Error insert row in " + GenerationEcritures.ecritureTable.getName() + " : " + e);
final SQLException eFinal = e;
368,27 → 378,41
return getNewMouvement(source, idSource, idPere, rowValsPiece);
}
 
protected TotalCalculator getValuesFromElement(SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon) {
return getValuesFromElement(false, false, "T_PV_HT", row, foreign, portHT, rowTVAPort, tableEchantillon, null);
protected TotalCalculator getValuesFromElement(SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, BigDecimal fraisDocHT, SQLRow rowTVAFraisDoc, SQLTable tableEchantillon) {
return getValuesFromElement(false, false, "T_PV_HT", row, foreign, portHT, rowTVAPort, fraisDocHT, rowTVAFraisDoc, tableEchantillon, null);
}
 
protected TotalCalculator getValuesFromElement(boolean intra, boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon,
SQLRow defaultCompte) {
protected TotalCalculator getValuesFromElement(boolean intra, boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, BigDecimal fraisDocHT,
SQLRow rowTVAFraisDoc, SQLTable tableEchantillon, SQLRow defaultCompte) {
 
TotalCalculator calc = new TotalCalculator("T_PA_HT", fieldTotalHT, null, achat, defaultCompte);
final SQLRow tiers;
if (achat) {
tiers = row.getForeign("ID_FOURNISSEUR");
} else {
tiers = row.getForeign("ID_CLIENT");
}
 
SQLRowAccessor rowCatCompta = null;
if (tiers.getObject("ID_CATEGORIE_COMPTABLE") != null && !tiers.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
rowCatCompta = tiers.getForeign("ID_CATEGORIE_COMPTABLE");
}
TotalCalculator calc = new TotalCalculator("T_PA_HT", fieldTotalHT, null, achat, defaultCompte, rowCatCompta);
calc.setIntraComm(intra);
 
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean bServiceActive = Boolean.valueOf(val);
 
calc.setServiceActive(bServiceActive != null && bServiceActive);
 
SQLBackgroundTableCacheItem cacheCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(compteTable);
if (row.getTable().contains("ID_COMPTE_PCE_SERVICE") && !row.isForeignEmpty("ID_COMPTE_PCE_SERVICE")) {
SQLRowAccessor serviceCompte = row.getForeign("ID_COMPTE_PCE_SERVICE");
if (!serviceCompte.isUndefined()) {
SQLRowAccessor serviceCompte = cacheCompte.getRowFromId(row.getForeignID("ID_COMPTE_PCE_SERVICE"));
if (serviceCompte != null && !serviceCompte.isUndefined()) {
calc.setRowDefaultCptService(serviceCompte);
}
}
if (row.getTable().contains("ID_COMPTE_PCE_VENTE") && !row.isForeignEmpty("ID_COMPTE_PCE_VENTE")) {
SQLRowAccessor produitCompte = row.getForeign("ID_COMPTE_PCE_VENTE");
SQLRowAccessor produitCompte = cacheCompte.getRowFromId(row.getForeignID("ID_COMPTE_PCE_VENTE"));
if (!produitCompte.isUndefined()) {
calc.setRowDefaultCptProduit(produitCompte);
}
395,11 → 419,14
}
long remise = 0;
BigDecimal totalAvtRemise = BigDecimal.ZERO;
OOXMLCache cacheRefRows = new OOXMLCache();
final List<? extends SQLRowAccessor> referentRows = cacheRefRows.getReferentRows(Arrays.asList(row), foreign);
if (row.getTable().contains("REMISE_HT")) {
remise = row.getLong("REMISE_HT");
if (remise != 0) {
List<SQLRow> rows = row.getReferentRows(foreign);
for (SQLRow sqlRow : rows) {
 
// List<SQLRow> rows = row.getReferentRows(foreign);
for (SQLRowAccessor sqlRow : referentRows) {
calc.addLine(sqlRow, sqlRow.getForeign("ID_ARTICLE"), 1, false);
}
 
429,10 → 456,10
}
calc.setRemise(valRemiseHTReel, totalAvtRemise);
 
List<SQLRow> rows = row.getReferentRows(foreign);
for (int i = 0; i < rows.size(); i++) {
SQLRow sqlRow = rows.get(i);
calc.addLine(sqlRow, sqlRow.getForeign("ID_ARTICLE"), i, i == rows.size() - 1);
// List<SQLRow> rows = row.getReferentRows(foreign);
for (int i = 0; i < referentRows.size(); i++) {
SQLRowAccessor sqlRow = referentRows.get(i);
calc.addLine(sqlRow, sqlRow.getForeign("ID_ARTICLE"), i, i == referentRows.size() - 1);
}
 
if (tableEchantillon != null) {
448,10 → 475,10
rowValsPort.put("ID_TAXE", rowTVAPort.getIDNumber());
 
final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
SQLRow rowDefaultCptPort;
if (rowTVAPort.getFloat("TAUX") > 0) {
rowDefaultCptPort = rowPrefsCompte.getForeign("ID_COMPTE_PCE_PORT_SOUMIS");
rowDefaultCptPort = cacheCompte.getRowFromId(rowPrefsCompte.getForeignID("ID_COMPTE_PCE_PORT_SOUMIS"));
if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
try {
rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteSoumisTVA");
460,7 → 487,7
}
}
} else {
rowDefaultCptPort = rowPrefsCompte.getForeign("ID_COMPTE_PCE_PORT_NON_SOUMIS");
rowDefaultCptPort = cacheCompte.getRowFromId(rowPrefsCompte.getForeignID("ID_COMPTE_PCE_PORT_NON_SOUMIS"));
if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
try {
rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteNonSoumisTVA");
472,8 → 499,21
final SQLRowValues rowValsArt = rowValsPort.putRowValues("ID_ARTICLE");
rowValsArt.put(achat ? "ID_COMPTE_PCE_ACHAT" : "ID_COMPTE_PCE", rowDefaultCptPort.getID());
rowValsArt.put("ID_TAXE_COMPLEMENTAIRE", null);
rowValsArt.put("ID_FAMILLE_ARTICLE", null);
calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
}
 
if (rowTVAFraisDoc != null && !rowTVAFraisDoc.isUndefined()) {
// Frais documents
SQLRowValues rowValsFraisDoc = new SQLRowValues(foreign);
rowValsFraisDoc.put(achat ? "T_PA_HT" : "T_PV_HT", fraisDocHT);
rowValsFraisDoc.put("QTE", 1);
rowValsFraisDoc.put("ID_TAXE", rowTVAFraisDoc.getIDNumber());
rowValsFraisDoc.put("SERVICE", Boolean.TRUE);
rowValsFraisDoc.put("ID_FAMILLE_ARTICLE", null);
calc.addLine(rowValsFraisDoc, null, 1, false);
}
 
calc.checkResult();
return calc;
}
646,4 → 686,5
}
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirClient.java
100,9 → 100,10
 
TotalCalculator calc;
if (rowClient.getTable().contains("ID_COMPTE_PCE_PRODUIT") && !rowClient.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
calc = getValuesFromElement(false, false, "T_PV_HT", avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, null, rowClient.getForeign("ID_COMPTE_PCE_PRODUIT"));
calc = getValuesFromElement(false, false, "T_PV_HT", avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, BigDecimal.ZERO, null, null,
rowClient.getForeign("ID_COMPTE_PCE_PRODUIT"));
} else {
calc = getValuesFromElement(avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, null);
calc = getValuesFromElement(avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, BigDecimal.ZERO, null, null);
}
Map<SQLRowAccessor, Map<SQLRowAccessor, BigDecimal>> taxeCompl = calc.getMapHtTaxeCompl();
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementVenteNG.java
63,7 → 63,12
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance)
throws Exception {
this(label, rowClient, ttc, d, modeReglement, source, mvtSource, createEncaisse, avance, rowClient.getString("NOM"), null);
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance, String tiers,
SQLRowAccessor cptTiers) throws Exception {
 
SQLRow typeRegRow = modeReglement.getForeignRow("ID_TYPE_REGLEMENT");
setRowAnalytiqueSource(source);
// iniatilisation des valeurs de la map
107,7 → 112,8
if (createEncaisse) {
SQLRowValues rowVals = new SQLRowValues(tableEncaisse);
rowVals.put("MONTANT", ttc.getLongValue());
rowVals.put("ID_CLIENT", rowClient.getID());
rowVals.put("ID_CLIENT", rowClient != null ? rowClient.getID() : null);
rowVals.put("TIERS", tiers);
rowVals.put("DATE", this.date);
if (typeRegRow.getID() >= TypeReglementSQLElement.TRAITE) {
Calendar c2 = modeReglement.getDate("DATE_VIREMENT");
154,9 → 160,9
 
Calendar c = modeReglement.getDate("DATE_DEPOT");
if (c != null) {
paiementCheque(c.getTime(), source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance);
paiementCheque(c.getTime(), source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance, tiers, cptTiers);
} else {
paiementCheque(this.date, source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance);
paiementCheque(this.date, source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance, tiers, cptTiers);
}
 
} else {
176,7 → 182,7
this.putValue("ID_JOURNAL", JournalSQLElement.CAISSES);
}
 
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
int idCompteClient = cptTiers != null && !cptTiers.isUndefined() ? cptTiers.getID() : rowClient.getInt("ID_COMPTE_PCE");
if (avance) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
if (idCompteClient <= 1) {
239,7 → 245,9
valEcheance.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
valEcheance.put("DATE", dateEch);
valEcheance.put("MONTANT", Long.valueOf(ttc.getLongValue()));
valEcheance.put("ID_CLIENT", rowClient.getID());
valEcheance.put("ID_CLIENT", rowClient == null ? null : rowClient.getID());
valEcheance.put("TIERS", tiers);
valEcheance.put("ID_COMPTE_PCE_TIERS", cptTiers == null || !cptTiers.isUndefined() ? null : cptTiers.getID());
if (source.getTable().equals(tableSaisieVenteFacture)) {
valEcheance.put("ID_SAISIE_VENTE_FACTURE", source.getID());
}
334,13 → 342,15
}
}
 
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, SQLRow rowClient, SQLRow modeRegl, SQLRow mvtSource, boolean avance) throws Exception {
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, SQLRow rowClient, SQLRow modeRegl, SQLRow mvtSource, boolean avance, String tiers, SQLRowAccessor cptTiers) throws Exception {
 
SQLRowValues valCheque = new SQLRowValues(base.getTable("CHEQUE_A_ENCAISSER"));
SQLPreferences prefs = SQLPreferences.getMemCached(valCheque.getTable().getDBRoot());
boolean createEcr = prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CREATE_ECR_CHQ, true);
 
valCheque.put("ID_CLIENT", rowClient.getID());
valCheque.put("ID_CLIENT", rowClient == null ? null : rowClient.getID());
valCheque.put("ID_COMPTE_PCE_TIERS", cptTiers == null ? null : cptTiers.getID());
valCheque.put("TIERS", tiers);
valCheque.put("SANS_VALEUR_ENCAISSEMENT", !createEcr);
final String foreignBanqueFieldName = "ID_" + BanqueSQLElement.TABLENAME;
if (valCheque.getTable().contains(foreignBanqueFieldName))
364,7 → 374,7
}
 
if (createEcr) {
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
int idCompteClient = cptTiers == null || cptTiers.isUndefined() ? rowClient.getInt("ID_COMPTE_PCE") : cptTiers.getID();
if (avance) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
if (idCompteClient <= 1) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirFournisseur.java
15,9 → 15,11
 
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.model.PrixHT;
import org.openconcerto.erp.model.PrixTTC;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
 
91,6 → 93,7
SQLRow rowEcr = ajoutEcriture();
// addAssocAnalytiqueFromProvider(rowEcr, avoirRow);
 
SQLRowAccessor taxe = TaxeCache.getCache().getRowFromId(avoirRow.getForeignID("ID_TAXE"));
if (prixTVA.getLongValue() > 0) {
// compte TVA
int idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_ACHAT");
100,9 → 103,19
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVAImmo");
}
} else {
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_ACHAT");
if (idCompteTVA <= 1) {
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVADeductible");
if (rowFourn.getBoolean("UE")) {
idCompteTVA = taxe.getForeignID("ID_COMPTE_PCE_DED_INTRA");
if (idCompteTVA <= 1) {
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
if (idCompteTVA <= 1) {
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
}
}
} else {
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_ACHAT");
if (idCompteTVA <= 1) {
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVADeductible");
}
}
}
 
112,9 → 125,12
ajoutEcriture();
 
if (rowFourn.getBoolean("UE")) {
int idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
int idCompteTVAIntra = taxe.getForeignID("ID_COMPTE_PCE_COLLECTE_INTRA");
if (idCompteTVAIntra <= 1) {
idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
if (idCompteTVAIntra <= 1) {
idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
}
}
this.putValue("ID_COMPTE_PCE", Integer.valueOf(idCompteTVAIntra));
this.putValue("DEBIT", Long.valueOf(prixTVA.getLongValue()));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientNormalSQLElement.java
189,4 → 189,8
return new ClientNormalSQLComponent(this);
}
 
@Override
protected String createCode() {
return "customerrelationship.customer";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CourrierClientSQLElement.java
337,6 → 337,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".mail";
return this.createCodeOfPackage() + ".mail";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/TypeLettreRelanceSQLElement.java
56,6 → 56,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".chaseletter.type";
return this.createCodeOfPackage() + ".chaseletter.type";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ContactSQLElement.java
13,15 → 13,14
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
 
import java.awt.event.ActionEvent;
 
import javax.swing.AbstractAction;
 
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
 
public class ContactSQLElement extends ContactSQLElementBase {
 
static public class ContactFournisseurSQLElement extends ContactSQLElement {
43,7 → 42,6
 
protected ContactSQLElement(String tableName) {
super(tableName);
this.setL18nLocation(Gestion.class);
PredicateRowAction action = new PredicateRowAction(new AbstractAction() {
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CompteClientTransactionSQLELement.java
43,6 → 43,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".account.transaction";
return this.createCodeOfPackage() + ".account.transaction";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ReferenceClientSQLElement.java
70,6 → 70,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".ref";
return this.createCodeOfPackage() + ".ref";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerCategorySQLElement.java
55,6 → 55,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".category";
return this.createCodeOfPackage() + ".category";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientNormalSQLComponent.java
13,41 → 13,8
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
86,11 → 53,46
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.component.InteractionMode;
 
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
// Client without CTech link (i.e. there's one and only table in the DB)
public class ClientNormalSQLComponent extends BaseSQLComponent {
 
private int idDefaultCompteClient = 1;
private JCheckBox checkAdrLivraison, checkAdrFacturation;
private JCheckBox checkAdrFacturation;
 
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
private ElementComboBox boxPays = null;
private final ElementComboBox boxTarif = new ElementComboBox();
97,7 → 99,7
 
protected boolean showMdr = true;
 
private ElementSQLObject componentPrincipale, componentLivraison, componentFacturation;
private ElementSQLObject componentPrincipale, componentFacturation;
private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
private JCheckBox boxGestionAutoCompte;
private Map<SQLField, JCheckBox> mapCheckLivraison = new HashMap<SQLField, JCheckBox>();
141,7 → 143,16
// Code
JLabel labelCode = new JLabel(getLabelFor("CODE"));
labelCode.setHorizontalAlignment(SwingConstants.RIGHT);
this.textCode = new JUniqueTextField();
this.textCode = new JUniqueTextField() {
@Override
public String getAutoRefreshNumber() {
if (getMode() == Mode.INSERTION) {
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
} else {
return null;
}
}
};
c.gridx++;
c.weightx = 0;
c.weighty = 0;
448,15 → 459,6
c.fill = GridBagConstraints.BOTH;
this.add(textInfos, c);
 
this.checkAdrLivraison.addActionListener(new ActionListener() {
 
public void actionPerformed(java.awt.event.ActionEvent e) {
boolean b = checkAdrLivraison.isSelected();
componentLivraison.setEditable((!b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
componentLivraison.setCreated(!b);
};
});
 
this.checkAdrFacturation.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
boolean b = checkAdrFacturation.isSelected();
479,9 → 481,6
this.addSQLObject(textInfos, "INFOS");
this.addSQLObject(this.compteSel, "ID_COMPTE_PCE");
 
this.checkAdrFacturation.setSelected(true);
this.checkAdrLivraison.setSelected(true);
 
}
 
private Component createAdressesComponent() {
501,6 → 500,7
this.componentPrincipale.setOpaque(false);
tabbedAdresse.add(getLabelFor("ID_ADRESSE"), this.componentPrincipale);
tabbedAdresse.setOpaque(false);
 
// Adr facturation
JPanel panelFacturation = new JPanel(new GridBagLayout());
panelFacturation.setOpaque(false);
507,15 → 507,30
GridBagConstraints cPanelF = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 1, 2, 1), 0, 0);
 
this.addView("ID_ADRESSE_F", DEC + ";" + SEP);
 
this.componentFacturation = (ElementSQLObject) this.getView("ID_ADRESSE_F");
this.componentFacturation.setOpaque(false);
this.componentFacturation.setCreatedUIVisible(false);
((AdresseSQLComponent) componentFacturation.getSQLChild()).setDestinataireVisible(true);
 
panelFacturation.add(this.componentFacturation, cPanelF);
 
this.checkAdrFacturation = new JCheckBox("Adresse de facturation identique à la principale");
this.checkAdrFacturation.setOpaque(false);
cPanelF.gridy++;
panelFacturation.add(this.checkAdrFacturation, cPanelF);
tabbedAdresse.add(getLabelFor("ID_ADRESSE_F"), panelFacturation);
tabbedAdresse.add(getLabelFor("ID_ADRESSE_F"), panelFacturation);
 
this.checkAdrFacturation.addActionListener(new ActionListener() {
 
public void actionPerformed(java.awt.event.ActionEvent e) {
boolean b = checkAdrFacturation.isSelected();
 
componentFacturation.setEditable(!b ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
componentFacturation.setCreated(!b);
}
});
checkAdrFacturation.setSelected(true);
 
Set<SQLField> fieldsAdr = getTable().getForeignKeys("ADRESSE");
List<SQLField> fieldsAdrOrder = new ArrayList<SQLField>(fieldsAdr);
Collections.sort(fieldsAdrOrder, new Comparator<SQLField>() {
536,13 → 551,13
GridBagConstraints cPanelL = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 1, 2, 1), 0, 0);
 
this.addView(fieldName, DEC + ";" + SEP);
this.componentLivraison = (ElementSQLObject) this.getView(fieldName);
this.componentLivraison.setOpaque(false);
this.componentLivraison.setCreatedUIVisible(false);
 
panelLivraison.add(this.componentLivraison, cPanelL);
final ElementSQLObject componentLivraison = (ElementSQLObject) this.getView(fieldName);
componentLivraison.setOpaque(false);
((AdresseSQLComponent) componentLivraison.getSQLChild()).setDestinataireVisible(true);
panelLivraison.add(componentLivraison, cPanelL);
 
checkAdrLivraison = new JCheckBox("Adresse de livraison identique à l'adresse principale");
final JCheckBox checkAdrLivraison = new JCheckBox("Adresse de livraison identique à l'adresse principale");
checkAdrLivraison.setOpaque(false);
cPanelL.gridy++;
panelLivraison.add(checkAdrLivraison, cPanelL);
553,6 → 568,7
 
public void actionPerformed(java.awt.event.ActionEvent e) {
boolean b = checkAdrLivraison.isSelected();
 
componentLivraison.setEditable((!b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
componentLivraison.setCreated(!b);
}
647,7 → 663,21
setCompteVisible(!(boxGestionAutoCompte.isSelected() && getSelectedID() <= 1));
}
});
 
c.gridwidth = 1;
c.gridy++;
c.gridx = 0;
c.weightx = 0;
p.add(new JLabel(getLabelFor("ID_COMPTE_PCE_SERVICE")), c);
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridx++;
c.weightx = 1;
ISQLCompteSelector compteSelService = new ISQLCompteSelector();
p.add(compteSelService, c);
this.addView(compteSelService, "ID_COMPTE_PCE_SERVICE");
}
 
return p;
}
 
749,16 → 779,20
public int insert(SQLRow order) {
 
// incrémentation du numéro auto
if (NumerotationAutoSQLElement.getNextNumero(ClientNormalSQLElement.class, new Date()).equalsIgnoreCase(this.textCode.getText().trim())) {
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.textCode.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
int val = this.tableNum.getRow(2).getInt("CLIENT_START");
val++;
rowVals.put("CLIENT_START", new Integer(val));
 
try {
rowVals.update(2);
} catch (SQLException e) {
e.printStackTrace();
final SQLRow rowNumAuto = this.tableNum.getRow(2);
if (rowNumAuto.getObject("CLIENT_START") != null) {
int val = rowNumAuto.getInt("CLIENT_START");
val++;
rowVals.put("CLIENT_START", new Integer(val));
 
try {
rowVals.update(2);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
 
778,7 → 812,7
SQLRow r;
 
vals.put("MARCHE_PUBLIC", Boolean.TRUE);
vals.put("CODE", NumerotationAutoSQLElement.getNextNumero(ClientNormalSQLElement.class, new Date()));
vals.put("CODE", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
 
// Mode de règlement par defaut
try {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLElement.java
14,11 → 14,13
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.reports.history.ui.HistoriqueClientFrame;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.light.LightUIElement;
26,8 → 28,11
import org.openconcerto.ui.light.LightUIPanel;
import org.openconcerto.ui.light.SimpleTextLine;
 
import java.awt.event.ActionEvent;
import java.util.List;
 
import javax.swing.AbstractAction;
 
public class CustomerSQLElement extends ClientNormalSQLElement {
 
public CustomerSQLElement() {
40,6 → 45,19
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
 
PredicateRowAction actionHistory = new PredicateRowAction(new AbstractAction("Historique client") {
 
@Override
public void actionPerformed(ActionEvent e) {
HistoriqueClientFrame histoFrame = new HistoriqueClientFrame();
int idClient = IListe.get(e).getSelectedId();
histoFrame.selectId(idClient);
histoFrame.setVisible(true);
}
}, true);
actionHistory.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionHistory);
 
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientDepartementSQLElement.java
55,6 → 55,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".department";
return this.createCodeOfPackage() + ".department";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/RelanceSQLElement.java
50,7 → 50,7
public class RelanceSQLElement extends ComptaSQLConfElement {
 
public RelanceSQLElement() {
super("RELANCE", "relance client", "relances clients");
super("RELANCE", "une relance client", "relances clients");
}
 
protected List<String> getListFields() {
300,6 → 300,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".chaseletter";
return this.createCodeOfPackage() + ".chaseletter";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLComponent.java
159,6 → 159,8
return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
} else if (id.equals("SITE_INTERNET")) {
return new TextFieldWithWebBrowsing();
} else if (id.equals("SIRET")) {
return new JTextField(20);
} else if (id.equals("DATE")) {
return new JDate(true);
} else if (id.equals("customerrelationship.customer.contacts")) {
263,7 → 265,7
 
int attempt = 0;
// on verifie qu'un client du meme numero n'a pas été inséré entre temps
if (!this.code.checkValidation(false)) {
if (this.code.getText().trim().length() > 0 && !this.code.checkValidation(false)) {
while (attempt < JUniqueTextField.RETRY_COUNT) {
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
this.code.setText(num);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ModeleCourrierClientSQLElement.java
88,6 → 88,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".mailtemplate";
return this.createCodeOfPackage() + ".mailtemplate";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerGroup.java
67,7 → 67,7
gProspect.addItem("ACCEPTE_EMAIL");
gProspect.addItem("ACCEPTE_COURRIER");
this.add(gProspect);
 
final Group gPayment = new Group("customerrelationship.customer.payment", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gPayment.addItem("RIB", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gPayment.addItem("CENTRE_GESTION", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
88,6 → 88,8
gState.addItem("ID_COMMERCIAL");
gState.addItem("ID_LANGUE");
gState.addItem("ID_TARIF");
gState.addItem("ID_CATEGORIE_COMPTABLE");
gState.addItem("ID_FRAIS_DOCUMENT");
 
final Group gCustomProduct = new Group("customerrelationship.customer.customproduct", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gCustomProduct.addItem("customerrelationship.customer.customproduct", new LayoutHints(true, true, true, true, true, true, true, true));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/action/NouveauContactAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/action/NouveauClientAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/action/ListeDesDepartementsClientsAction.java
13,32 → 13,12
package org.openconcerto.erp.core.customerrelationship.customer.action;
 
import org.openconcerto.erp.action.CreateListFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientDepartementSQLElement;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesDepartementsClientsAction extends CreateListFrameAbstractAction {
 
public ListeDesDepartementsClientsAction() {
super();
this.putValue(Action.NAME, "Liste des services clients");
public class ListeDesDepartementsClientsAction extends CreateIListFrameAbstractAction<ClientDepartementSQLElement> {
public ListeDesDepartementsClientsAction(final ComptaPropsConfiguration conf) {
super(conf, ClientDepartementSQLElement.class);
}
 
@Override
public String getTableName() {
return "CLIENT_DEPARTEMENT";
}
 
public JFrame createFrame() {
SQLElement eltClientDpt = Configuration.getInstance().getDirectory().getElement("CLIENT_DEPARTEMENT");
 
final ListeAddPanel panel = new ListeAddPanel(eltClientDpt);
IListFrame frame = new IListFrame(panel);
return frame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/action/ListeDesContactsAction.java
13,29 → 13,14
package org.openconcerto.erp.core.customerrelationship.customer.action;
 
import org.openconcerto.erp.action.CreateListFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class ListeDesContactsAction extends CreateIListFrameAbstractAction<ContactSQLElement> {
 
public class ListeDesContactsAction extends CreateListFrameAbstractAction {
 
public ListeDesContactsAction() {
super();
this.putValue(Action.NAME, "Liste des contacts");
public ListeDesContactsAction(final ComptaPropsConfiguration conf) {
super(conf, ContactSQLElement.class);
}
 
public JFrame createFrame() {
final ComptaBasePropsConfiguration conf = ((ComptaBasePropsConfiguration) Configuration.getInstance());
return new IListFrame(new ListeAddPanel(conf.getDirectory().getElement("CONTACT")));
}
 
@Override
public String getTableName() {
return "CONTACT";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/action/ListeDesClientsAction.java
13,47 → 13,31
package org.openconcerto.erp.core.customerrelationship.customer.action;
 
import org.openconcerto.erp.action.CreateListFrameAbstractAction;
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientNormalSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerSQLElement;
import org.openconcerto.erp.core.sales.invoice.ui.EcheanceRenderer;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSource;
 
import java.util.Set;
 
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JTable;
 
public class ListeDesClientsAction extends CreateListFrameAbstractAction {
public class ListeDesClientsAction extends CreateIListFrameAbstractAction<ClientNormalSQLElement> {
 
public ListeDesClientsAction() {
super();
this.putValue(Action.NAME, "Liste des clients");
public ListeDesClientsAction(final ComptaPropsConfiguration conf) {
super(conf, CustomerSQLElement.class);
}
 
@Override
public String getTableName() {
return "CLIENT";
}
protected void initFrame(IListFrame frame) {
super.initFrame(frame);
 
protected SQLTableModelSource getTableSource() {
SQLTable tableClient = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CLIENT");
return Configuration.getInstance().getDirectory().getElement(tableClient).getTableSource(true);
}
SQLTable tableModeReglement = getElem().getDirectory().getElement("MODE_REGLEMENT").getTable();
 
public JFrame createFrame() {
SQLTable tableClient = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CLIENT");
SQLTable tableModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT").getTable();
 
final ListeAddPanel panel = new ListeAddPanel(Configuration.getInstance().getDirectory().getElement(tableClient), new IListe(getTableSource()));
IListFrame frame = new IListFrame(panel);
 
// Renderer
final EcheanceRenderer rend = EcheanceRenderer.getInstance();
JTable jTable = frame.getPanel().getListe().getJTable();
69,8 → 53,7
}
}
 
panel.setSearchFullMode(true);
panel.setSelectRowOnAdd(false);
return frame;
frame.getPanel().setSearchFullMode(true);
frame.getPanel().setSelectRowOnAdd(false);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/action/NouveauCourrierClientAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/SaisieKmSQLElement.java
51,7 → 51,6
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
428,6 → 427,11
return id;
}
 
@Override
public Set<String> getPartialResetNames() {
return null;
}
 
public void loadMouvement(int idMvt) {
this.tableKm.loadMouvement(idMvt, false);
}
483,8 → 487,32
 
List<SQLRow> listEcr = rowSaisieKm.getForeignRow("ID_MOUVEMENT").getReferentRows(ecritureTable);
 
// Fix bug sur saisie journal qui ne mettait pas l'id mouvement sur la
// saisie
boolean fixMvt = false;
if (myListKmItem != null && rowSaisieKm.isForeignEmpty("ID_MOUVEMENT")) {
for (SQLRow rowKmElement : myListKmItem) {
if (!rowKmElement.isForeignEmpty("ID_ECRITURE")) {
SQLRow rowEcr = rowKmElement.getForeign("ID_ECRITURE");
if (!rowEcr.isForeignEmpty("ID_MOUVEMENT")) {
rowSaisieKm.createEmptyUpdateRow().put("ID_MOUVEMENT", rowEcr.getForeignID("ID_MOUVEMENT")).commit();
rowSaisieKm.fetchValues();
listEcr = rowSaisieKm.getForeignRow("ID_MOUVEMENT").getReferentRows(ecritureTable);
fixMvt = true;
break;
}
}
}
}
if (myListKmItem != null) {
 
// Mise à jour du nom de la pièce
final SQLRow mvt = rowSaisieKm.getForeign("ID_MOUVEMENT");
final SQLRow piece = mvt.getForeign("ID_PIECE");
String labelSaisie = rowSaisieKm.getString("NOM");
piece.createEmptyUpdateRow().put("NOM", (labelSaisie.length() == 0 ? "Saisie au km " : labelSaisie)).commit();
 
// Mise à jour des écritures
for (SQLRow rowKmElement : myListKmItem) {
 
int idCpt = ComptePCESQLElement.getId(rowKmElement.getString("NUMERO"), rowKmElement.getString("NOM"));
505,9 → 533,13
if (tableElt.contains("NOM_PIECE")) {
vals.put("NOM_PIECE", rowKmElement.getObject("NOM_PIECE"));
}
 
if (rowKmElement.getInt("ID_ECRITURE") > 1) {
 
SQLRow rowTmp = ecritureTable.getRow(rowKmElement.getInt("ID_ECRITURE"));
 
if (fixMvt) {
vals.put("ID_MOUVEMENT", rowSaisieKm.getObject("ID_MOUVEMENT"));
}
if (!rowTmp.getBoolean("VALIDE")) {
vals.update(rowKmElement.getInt("ID_ECRITURE"));
} else {
672,6 → 704,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".userentry";
return createCodeOfPackage() + ".userentry";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/NatureCompteSQLElement.java
25,7 → 25,7
public class NatureCompteSQLElement extends ComptaSQLConfElement {
 
public NatureCompteSQLElement() {
super("NATURE_COMPTE", "Nature du compte", "Nature du compte");
super("NATURE_COMPTE", "une nature du compte", "natures du compte");
}
 
protected List<String> getListFields() {
55,6 → 55,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".account.kind";
return createCodeOfPackage() + ".account.kind";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/RepartitionAnalytiqueElementSQLElement.java
52,6 → 52,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".distributionitem";
return createCodeOfPackage() + ".distributionitem";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AssociationAnalytiqueSQLElement.java
70,7 → 70,7
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".analytic.relation";
return createCodeOfPackage() + ".analytic.relation";
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AxeAnalytiqueSQLElement.java
53,6 → 53,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".analytic.axis";
return createCodeOfPackage() + ".analytic.axis";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/JournalSQLElement.java
123,6 → 123,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".book";
return createCodeOfPackage() + ".book";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AnalytiqueSQLElement.java
908,6 → 908,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".analytic";
return createCodeOfPackage() + ".analytic";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/MouvementSQLElement.java
232,7 → 232,7
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".entry";
return createCodeOfPackage() + ".entry";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ComptePCESQLElement.java
57,6 → 57,7
import javax.swing.AbstractAction;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
 
313,11 → 314,8
Object obEcriture = base.getDataSource().execute(reqEcriture, new ArrayListHandler());
 
List myListEcriture = (List) obEcriture;
 
if (myListEcriture.size() != 0) {
 
System.err.println("Impossible de supprimer un compte mouvementé!");
ExceptionHandler.handle("", new Exception("Impossible de supprimer un compte mouvementé!"));
JOptionPane.showMessageDialog(null, "Impossible de supprimer un compte mouvementé!");
} else {
super.archive(new TreesOfSQLRows(this, row), cutLinks);
}
437,7 → 435,7
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".code.enterprise";
return createCodeOfPackage() + ".code.enterprise";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ComptePCGSQLElement.java
167,6 → 167,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".code.national";
return createCodeOfPackage() + ".code.national";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AssociationCompteAnalytiqueSQLElement.java
153,6 → 153,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".analytic.account.relation";
return createCodeOfPackage() + ".analytic.account.relation";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java
18,6 → 18,7
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.accounting.ui.AssociationAnalytiquePanel;
import org.openconcerto.erp.core.finance.accounting.ui.ConsultationCompteFrame;
import org.openconcerto.erp.core.finance.accounting.ui.LettrageRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.ListEcritureRenderer;
46,6 → 47,7
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
91,6 → 93,59
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction("ID_MOUVEMENT").getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
 
PredicateRowAction consult = new PredicateRowAction(new AbstractAction("Consultation du compte") {
public void actionPerformed(ActionEvent event) {
SQLRowAccessor row = IListe.get(event).getSelectedRow();
consultationCompte(ComptePCESQLElement.getRow(row.getString("COMPTE_NUMERO"), row.getString("COMPTE_NOM")));
}
}, false);
consult.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(consult);
 
PredicateRowAction contre = new PredicateRowAction(new AbstractAction("Contrepassation") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.contrePassationPiece(IListe.get(event).getSelectedId());
}
}, false);
contre.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(contre);
// menuDroit.add(new AbstractAction("Valider le mouvement") {
// public void actionPerformed(ActionEvent event) {
// if (JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir valider le
// mouvement?") == JOptionPane.YES_OPTION) {
// EcritureSQLElement.validationEcritures(frame.getPanel().getListe().getSelectedRow().getInt("ID_MOUVEMENT"));
// }
// }
// });
 
PredicateRowAction clone = new PredicateRowAction(new AbstractAction("Dupliquer") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.dupliquer(IListe.get(event).fetchSelectedRow());
}
}, false);
clone.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(clone);
 
PredicateRowAction an = new PredicateRowAction(new AbstractAction("Gérer l'analytique") {
public void actionPerformed(ActionEvent event) {
PanelFrame frameAssoc = new PanelFrame(new AssociationAnalytiquePanel(IListe.get(event).getSelectedRow().asRow()), "Association analytique");
frameAssoc.setVisible(true);
}
}, false);
an.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(an);
 
PredicateRowAction show = new PredicateRowAction(new AbstractAction("Voir la source") {
public void actionPerformed(ActionEvent event) {
 
SQLRow row = IListe.get(event).fetchSelectedRow();
 
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
}
}, false);
show.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(show);
}
 
@Override
677,7 → 732,7
}
 
} else {
ExceptionHandler.handle("Impossible de supprimer le mouvement n°" + rowMvt.getInt("NUMERO") + " car il est validé.");
JOptionPane.showMessageDialog(null, "Impossible de supprimer le mouvement n°" + rowMvt.getInt("NUMERO") + " car il est validé.");
}
}
 
760,7 → 815,7
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".entry.item";
return createCodeOfPackage() + ".entry.item";
}
 
public static void dupliquer(SQLRow selectedRow) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ClasseCompteSQLElement.java
53,6 → 53,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".accountclass";
return createCodeOfPackage() + ".accountclass";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/TypeComptePCGSQLElement.java
51,6 → 51,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".account.type";
return createCodeOfPackage() + ".account.type";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/SaisieKmItemSQLElement.java
64,6 → 64,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".userentry.item";
return createCodeOfPackage() + ".userentry.item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/PieceSQLElement.java
68,6 → 68,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".piece";
return createCodeOfPackage() + ".piece";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/PosteAnalytiqueSQLElement.java
16,6 → 16,8
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
50,6 → 52,12
return list;
}
 
@Override
protected void _initComboRequest(ComboSQLRequest req) {
super._initComboRequest(req);
req.setWhere(new Where(getTable().getField("OBSOLETE"), "=", Boolean.FALSE));
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
public void addViews() {
83,6 → 91,12
this.add(box, c);
this.addRequiredSQLObject(box, "DEFAULT");
 
c.gridx++;
JCheckBox boxObs = new JCheckBox(getLabelFor("OBSOLETE"));
c.weightx = 1;
this.add(boxObs, c);
this.addRequiredSQLObject(boxObs, "OBSOLETE");
 
}
};
}
89,6 → 103,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".analytic.set";
return createCodeOfPackage() + ".analytic.set";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/CategorieComptableSQLElement.java
New file
0,0 → 1,145
/*
* 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.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.model.ISQLCompteSelector;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
public class CategorieComptableSQLElement extends ComptaSQLConfElement {
 
public CategorieComptableSQLElement() {
super("CATEGORIE_COMPTABLE", "une catégorie comptable", "catégories comptable");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
ListMap<String, String> map = new ListMap<String, String>();
map.add(null, "NOM");
return map;
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
@Override
protected void addViews() {
 
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
JLabel labelNom = new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT);
 
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
JTextField fieldNom = new JTextField(40);
DefaultGridBagConstraints.lockMinimumSize(fieldNom);
this.add(fieldNom, c);
 
JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE_VENTE"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy++;
this.add(labelTaxe, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteTaxe = new ISQLCompteSelector();
this.add(compteTaxe, c);
 
JLabel labelCompteVt = new JLabel(getLabelFor("ID_COMPTE_PCE_VENTE"), SwingConstants.RIGHT);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(labelCompteVt, c);
c.gridx++;
c.weightx = 1;
 
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteVt = new ISQLCompteSelector();
this.add(compteVt, c);
 
JLabel labelCompteAchat = new JLabel(getLabelFor("ID_COMPTE_PCE_ACHAT"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
c.gridx = 0;
c.gridy++;
this.add(labelCompteAchat, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteAchat = new ISQLCompteSelector();
this.add(compteAchat, c);
 
JLabel labelTaxeAchat = new JLabel(getLabelFor("ID_TAXE_ACHAT"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
c.gridx = 0;
c.gridy++;
this.add(labelTaxeAchat, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteTaxeAchat = new ISQLCompteSelector();
this.add(compteTaxeAchat, c);
 
// Spacer
c.gridy++;
c.weighty = 1;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(new JPanel(), c);
 
this.addSQLObject(compteAchat, "ID_COMPTE_PCE_ACHAT");
this.addSQLObject(compteVt, "ID_COMPTE_PCE_VENTE");
this.addSQLObject(compteTaxe, "ID_TAXE_VENTE");
this.addSQLObject(compteTaxeAchat, "ID_TAXE_ACHAT");
this.addRequiredSQLObject(fieldNom, "NOM");
 
}
};
}
 
@Override
protected String createCode() {
return "finance.accounting.category";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/DeviseHistoriqueSQLElement.java
14,7 → 14,7
package org.openconcerto.erp.core.finance.accounting.element;
 
import org.openconcerto.erp.core.finance.accounting.component.DeviseHistoriqueSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.SQLComponent;
 
21,7 → 21,7
import java.util.ArrayList;
import java.util.List;
 
public class DeviseHistoriqueSQLElement extends ConfSQLElement {
public class DeviseHistoriqueSQLElement extends ComptaSQLConfElement {
 
public DeviseHistoriqueSQLElement() {
super("DEVISE_HISTORIQUE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/RepartitionAnalytiqueSQLElement.java
55,6 → 55,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".distribution";
return createCodeOfPackage() + ".distribution";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ExerciceCommonSQLElement.java
13,9 → 13,8
package org.openconcerto.erp.core.finance.accounting.element;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRowValues;
32,16 → 31,12
 
import javax.swing.JLabel;
 
public class ExerciceCommonSQLElement extends ConfSQLElement {
public class ExerciceCommonSQLElement extends ComptaSQLConfElement {
 
public ExerciceCommonSQLElement(DBRoot root) {
super(root.getTable("EXERCICE_COMMON"), "un excercice", "exercices");
super(root.getTable("EXERCICE_COMMON"), "un exercice", "exercices");
}
 
public ExerciceCommonSQLElement() {
this(Configuration.getInstance().getRoot());
}
 
@Override
public boolean isPrivate() {
return true;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/FraisDocumentSQLElement.java
New file
0,0 → 1,178
/*
* 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.element;
 
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
 
import com.ibm.icu.math.BigDecimal;
 
public class FraisDocumentSQLElement extends ComptaSQLConfElement {
 
public FraisDocumentSQLElement() {
super("FRAIS_DOCUMENT");
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(2);
list.add("CODE");
list.add("NOM");
list.add("MONTANT_HT");
list.add("ID_TAXE");
list.add("MONTANT_TTC");
return list;
}
 
protected List<String> getComboFields() {
final List<String> list = new ArrayList<String>(2);
list.add("CODE");
list.add("NOM");
list.add("MONTANT_TTC");
return list;
}
 
@Override
public Set<String> getReadOnlyFields() {
Set<String> s = new HashSet<>();
s.add("MONTANT_TTC");
return s;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "CODE", "NOM");
 
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Code
final JLabel labelCode = new JLabel(getLabelFor("CODE"));
c.weightx = 0;
this.add(labelCode, c);
c.gridx++;
c.weightx = 1;
final JTextField textCode = new JTextField();
this.add(textCode, c);
 
// Nom
c.gridx++;
c.weightx = 0;
final JLabel labelNom = new JLabel(getLabelFor("NOM"));
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
final JTextField textNom = new JTextField();
this.add(textNom, c);
 
// Montant
c.gridy++;
c.gridx = 0;
c.weightx = 0;
 
final JLabel labelTaux = new JLabel(getLabelFor("MONTANT_HT"));
this.add(labelTaux, c);
c.gridx++;
c.weightx = 1;
final DeviseField textTaux = new DeviseField();
this.add(textTaux, c);
 
c.gridx++;
c.weightx = 0;
 
final JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE"));
this.add(labelTaxe, c);
c.gridx++;
c.weightx = 1;
final SQLRequestComboBox boxTaxe = new SQLRequestComboBox();
this.add(boxTaxe, c);
 
c.gridx++;
c.weightx = 0;
 
final JLabel labelTTC = new JLabel(getLabelFor("MONTANT_TTC"));
this.add(labelTTC, c);
c.gridx++;
c.weightx = 1;
final DeviseField textTTC = new DeviseField();
textTTC.setEditable(false);
this.add(textTTC, c);
 
this.addRequiredSQLObject(boxTaxe, "ID_TAXE");
boxTaxe.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
textTTC.setValue(getMontantTTC(textTaux, boxTaxe));
}
});
 
textTaux.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void update(DocumentEvent e) {
 
textTTC.setValue(getMontantTTC(textTaux, boxTaxe));
}
});
 
this.addRequiredSQLObject(textTTC, "MONTANT_TTC");
this.addRequiredSQLObject(textTaux, "MONTANT_HT");
this.addRequiredSQLObject(textNom, "NOM");
this.addRequiredSQLObject(textCode, "CODE");
}
 
public long getMontantTTC(DeviseField fieldHT, SQLRequestComboBox boxTVA) {
long l = 0;
 
long p = GestionDevise.parseLongCurrency(fieldHT.getText().trim());
if (!boxTVA.isEmpty()) {
Float t = TaxeCache.getCache().getTauxFromId(boxTVA.getWantedID());
if (t != null) {
l = new BigDecimal(p).multiply(new BigDecimal(t).movePointLeft(2).add(BigDecimal.ONE)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
}
}
 
return l;
}
 
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceSheet.java
142,6 → 142,13
} else {
w = w.and(new Where(tableCompte.getField("NUMERO"), (Object) this.compteDeb, (Object) this.compteEnd));
}
 
// FIXME use flag cloture
Where wCloture = new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%");
wCloture = wCloture.and(new Where(tableEcriture.getField("DATE"), "=", this.dateAu));
wCloture = wCloture.or(new Where(tableEcriture.getField("DATE"), "<", this.dateAu));
w = w.and(wCloture);
 
sel.setWhere(w);
 
String req = sel.asString() + " AND \"ECRITURE\".\"ID_COMPTE_PCE\" = \"COMPTE_PCE\".\"ID\" GROUP BY \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"ID\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator.java
14,20 → 14,19
package org.openconcerto.erp.core.finance.accounting.report;
 
import static org.openconcerto.task.config.ComptaBasePropsConfiguration.getStreamStatic;
 
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Color;
import java.awt.Desktop;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Date;
import java.util.Map;
 
import javax.swing.JOptionPane;
 
import com.ibm.icu.text.SimpleDateFormat;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
38,69 → 37,43
import com.lowagie.text.pdf.PdfWriter;
 
public abstract class PdfGenerator {
private int marginX, marginY;
private int offsetX, offsetY;
private int templateOffsetX, templateOffsetY;
 
private int offsetX;
private int offsetY;
private int templateOffsetX;
private int templateOffsetY;
private PdfContentByte cb;
private Document document;
private BaseFont bf, bfb;
private BaseFont bf;
private BaseFont bfb;
private int width;
private Map map;
private String fileNameIn, fileNameOut;
private Map<String, String> map;
private String fileNameIn;
private String fileNameOut;
private File directoryOut;
private File fOut;
 
public static void main(String[] args) {
new PdfGenerator_2033B().generateFrom(null);
// HashMap h = new HashMap();
// h.put("NOM","Front Software");
// new PdfGenerator_2033A().generateFrom(h);
}
 
PdfGenerator(String fileNameIn, String fileNameOut, String directoryOut) {
 
this.fileNameIn = "/Configuration/Template/PDF/" + fileNameIn;
this.fileNameOut = fileNameOut;
 
System.err.println("First folder " + directoryOut);
this.directoryOut = new File(directoryOut, String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
}
 
public void open(File f) {
if (Desktop.isDesktopSupported()) {
Desktop d = Desktop.getDesktop();
if (d.isSupported(Desktop.Action.OPEN)) {
 
try {
d.open(f.getCanonicalFile());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(null, "Cette action n'est pas supporté par votre système d'exploitation.");
}
} else {
JOptionPane.showMessageDialog(null, "Votre système d'exploitation n'est pas supporté.");
}
}
 
public void generateFrom(Map m) {
public void generateFrom(Map<String, String> m) {
try {
if (m == null) {
System.out.println("Filling with defaults");
System.err.println(this + " : filling with defaults");
}
this.map = m;
 
init();
 
this.cb.beginText();
generate();
this.cb.endText();
 
// step 5: we close the document
// FIXME ASK IF CLOSE WRITER
this.document.close();
System.out.println("done!");
} catch (FileNotFoundException e) {
ExceptionHandler.handle("Impossible de générer le fichier. \n" + e, e);
}
114,41 → 87,26
try {
reader = new PdfReader(getStreamStatic(this.fileNameIn));
 
// we retrieve the total number of pages
int n = reader.getNumberOfPages();
// we retrieve the size of the first page
Rectangle psize = reader.getPageSize(1);
 
final Rectangle psize = reader.getPageSize(1);
psize.setRight(psize.getRight() - this.templateOffsetX);
psize.setTop(psize.getTop() - this.templateOffsetY);
 
this.width = (int) psize.getWidth();
float height = psize.getHeight();
 
// step 1: creation of a document-object
int MARGIN = 32;
this.document = new Document(psize, MARGIN, MARGIN, MARGIN, MARGIN);
// step 2: we create a writer that listens to the document
int margin = 32;
this.document = new Document(psize, margin, margin, margin, margin);
if (!this.directoryOut.exists()) {
this.directoryOut.mkdirs();
}
System.err.println("Directory out " + this.directoryOut.getAbsolutePath());
File f = new File(this.directoryOut, this.fileNameOut);
if (f.exists()) {
f.renameTo(new File(this.directoryOut, "Old" + this.fileNameOut));
f = new File(this.directoryOut, this.fileNameOut);
}
final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
final String computedFileName = sdf.format(new Date()) + "-" + this.fileNameOut;
 
System.err.println("Creation du fichier " + f.getAbsolutePath());
 
writer = PdfWriter.getInstance(this.document, new FileOutputStream(f));
 
fOut = new File(this.directoryOut, computedFileName);
System.err.println("Creation du fichier " + fOut.getCanonicalPath());
writer = PdfWriter.getInstance(this.document, new FileOutputStream(fOut));
this.document.open();
// step 4: we add content
this.cb = writer.getDirectContent();
 
System.out.println("There are " + n + " pages in the document.");
 
this.document.newPage();
 
PdfImportedPage page1 = writer.getImportedPage(reader, 1);
160,10 → 118,8
 
} catch (FileNotFoundException fE) {
throw fE;
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException | DocumentException e) {
throw new IllegalStateException(e);
} finally {
if (reader != null) {
reader.close();
171,34 → 127,29
}
}
 
abstract public void generate();
public abstract void generate();
 
protected void setMargin(int i, int j) {
this.marginX = i;
this.marginY = j;
 
public File getGeneratedFile() {
return this.fOut;
}
 
protected void setOffset(int i, int j) {
this.offsetX = i;
this.offsetY = j;
 
}
 
protected void setTemplateOffset(int i, int j) {
this.templateOffsetX = i;
this.templateOffsetY = j;
 
}
 
protected void addSplittedText(String code, String string, int fromx, int y, double deltax) {
float x = fromx - this.offsetX - this.templateOffsetX;
int x = fromx - this.offsetX - this.templateOffsetX;
y = y - this.offsetY - this.templateOffsetY;
boolean error = false;
String s = string;
if (this.map != null) {
s = (String) this.map.get(code);
 
s = this.map.get(code);
}
if (s == null) {
s = code;
209,13 → 160,11
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
String sub = String.valueOf(c);
 
this.cb.showTextAligned(PdfContentByte.ALIGN_LEFT, sub, x, y, 0);
x += deltax;
}
 
if (error) {
 
this.cb.setColorStroke(Color.BLACK);
}
 
240,8 → 189,6
}
 
protected void addTextRight(String code, String string, int i, int j) {
// addText(PdfContentByte.ALIGN_RIGHT, code, string, i, j, 0);
 
int a = PdfContentByte.ALIGN_RIGHT;
int k = 0;
 
249,13 → 196,10
this.cb.showTextAligned(a, string, i, j, k);
else {
boolean error = false;
String s = (String) this.map.get(code);
String s = this.map.get(code);
if (s == null) {
System.out.println("Impossibe de trouver: " + code + " Set color red");
s = code;
error = true;
 
// cb.setColorFill(Color.RED);
} else {
if (s.equalsIgnoreCase("-0.0")) {
s = "0.0";
262,10 → 206,8
}
s = insertCurrencySpaces(s);
}
System.out.println("print " + s);
this.cb.showTextAligned(a, s, i, j, k);
if (error) {
System.out.println(" Set color black");
this.cb.setColorStroke(Color.BLACK);
}
}
273,23 → 215,17
}
 
private final void addText(int a, String code, String string, int i, int j, int k) {
 
if (this.map == null)
this.cb.showTextAligned(a, string, i, j, k);
else {
boolean error = false;
String s = (String) this.map.get(code);
String s = this.map.get(code);
if (s == null) {
System.out.println("Impossibe de trouver: " + code + " Set color red");
s = code;
error = true;
 
// cb.setColorFill(Color.RED);
}
System.out.println("print " + s);
this.cb.showTextAligned(a, s, i, j, k);
if (error) {
System.out.println(" Set color black");
this.cb.setColorStroke(Color.BLACK);
}
}
300,16 → 236,13
}
 
protected static String insertCurrencySpaces(String string) {
StringBuffer s = new StringBuffer();
final StringBuilder s = new StringBuilder();
for (int i = string.length() - 1; i >= 0; i--) {
 
s.insert(0, string.charAt(i));
if ((i - string.length()) % 3 == 0) {
s.insert(0, " ");
}
 
}
 
return s.toString().trim();
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map3310.java
17,7 → 17,6
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
25,10 → 24,6
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.GestionDevise;
 
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
38,12 → 33,11
 
public class Map3310 extends Thread {
 
private Map<String, Object> m;
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private Map<String, String> m;
private JProgressBar bar;
private Date dateDebut, dateFin;
 
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
private Date dateDebut;
private Date 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);
117,12 → 111,11
SQLRow rowCompteTVAImmo = tableCompte.getRow(idCompteTVAImmo);
 
PdfGenerator_3310 p = new PdfGenerator_3310();
this.m = new HashMap<String, Object>();
this.m = new HashMap<String, String>();
 
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"), this.dateDebut, this.dateFin);
long achatsIntra = this.sommeCompte.sommeCompteFils(rowCompteAchatIntra.getString("NUMERO"), this.dateDebut, this.dateFin);
193,12 → 186,7
 
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);
Gestion.openPDF(p.getGeneratedFile());
Map3310.this.bar.setValue(100);
}
});
206,9 → 194,7
}
 
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"));
215,7 → 201,6
dateFin = (Date) rowExercice.getObject("DATE_FIN");
dateDeb = (Date) rowExercice.getObject("DATE_DEB");
}
 
this.dateDebut = dateDeb;
this.dateFin = dateFin;
this.sommeCompte = new SommeCompte();
222,7 → 207,6
}
 
public Map3310(JProgressBar bar) {
 
this(bar, null, null);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator_3310.java
18,20 → 18,14
public class PdfGenerator_3310 extends PdfGenerator {
 
public PdfGenerator_3310() {
 
super("3310_2.pdf", "result_3310_2.pdf", TemplateNXProps.getInstance().getStringProperty("Location3310PDF"));
super("3310_2.pdf", "3310_2.pdf", TemplateNXProps.getInstance().getStringProperty("Location3310PDF"));
setTemplateOffset(0, 0);
setOffset(0, 0);
setMargin(32, 32);
}
 
public void generate() {
setFontBold(14);
 
// Copyright
setFontRoman(9);
String cc = "Document généré par le logiciel Bloc, (c) Front Software 2006";
 
setFontRoman(10);
long t = 53L;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java
16,15 → 16,12
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.utils.GestionDevise;
 
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
34,7 → 31,7
 
public class Map2033A extends Thread {
 
private Map<String, Object> m;
private Map<String, String> m;
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private JProgressBar bar;
private Date dateDebut, dateFin;
51,7 → 48,7
public void run() {
 
PdfGenerator_2033A p = new PdfGenerator_2033A();
this.m = new HashMap<String, Object>();
this.m = new HashMap();
 
SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
this.m.put("NOM", rowSociete.getString("TYPE") + " " + rowSociete.getString("NOM"));
860,11 → 857,7
 
SwingUtilities.invokeLater(new Runnable() {
public void run() {
 
final String file = TemplateNXProps.getInstance().getStringProperty("Location2033APDF") + File.separator + String.valueOf(Calendar.getInstance().get(Calendar.YEAR)) + File.separator
+ "result_2033A.pdf";
File f = new File(file);
Gestion.openPDF(f);
Gestion.openPDF(p.getGeneratedFile());
Map2033A.this.bar.setValue(100);
}
});
876,9 → 869,7
}
 
public Map2033A(JProgressBar bar, Date dateDeb, Date dateFin, SQLRow posteAnalytique) {
 
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"));
889,8 → 880,6
this.dateDebut = dateDeb;
this.dateFin = dateFin;
this.sommeCompte = new SommeCompte(posteAnalytique);
// this.sommeCompte.setRemoveClotureCompte(true);
 
}
 
public Map2033A(JProgressBar bar) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033B.java
16,15 → 16,12
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.utils.GestionDevise;
 
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
496,10 → 493,7
 
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final String file = TemplateNXProps.getInstance().getStringProperty("Location2033BPDF") + File.separator + String.valueOf(Calendar.getInstance().get(Calendar.YEAR)) + File.separator
+ "result_2033B.pdf";
File f = new File(file);
Gestion.openPDF(f);
Gestion.openPDF(p.getGeneratedFile());
Map2033B.this.bar.setValue(100);
}
});
510,7 → 504,6
}
 
public Map2033B(JProgressBar bar, Date dateDeb, Date dateFin, SQLRow rowPosteAnalytique) {
 
this.bar = bar;
 
if (dateDeb == null && dateFin == null) {
523,7 → 516,6
this.dateDeb = dateDeb;
this.dateFin = dateFin;
this.sommeCompte = new SommeCompte(rowPosteAnalytique);
// this.sommeCompte.setRemoveClotureCompte(true);
}
 
public Map2033B(JProgressBar b) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator_2033A.java
21,12 → 21,9
public class PdfGenerator_2033A extends PdfGenerator {
 
public PdfGenerator_2033A() {
 
super("2033A.pdf", "result_2033A.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033APDF"));
super("2033A.pdf", "2033A.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033APDF"));
setTemplateOffset(0, 0);
setOffset(0, 0);
setMargin(32, 32);
 
}
 
public void generate() {
50,23 → 47,17
}
 
final String adresse = rowAdresse.getString("RUE") + ", " + rowAdresse.getString("CODE_POSTAL") + " " + ville;
System.err.println(adresse);
addText("ADRESSE", adresse, 100, 759);
 
addSplittedText("SIRET", rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 82, 735, 17);
 
// addSplittedText("APE", rowSociete.getString("NUM_APE"), 366, 794 - 18 - 18, 16);
addSplittedText("CLOS1", "08202006", 502, 689, 9.7);
 
addSplittedText("CLOS1", "08202006", 502, 689, 9.7);
// addSplittedText("CLOS2", "08202006", 502, 707, 9.7);
 
addSplittedText("DUREE1", "12", 211 - 28, 758, 14);
// addSplittedText("DUREE2", "88", 366, 741, 14);
 
// Copyright
setFontRoman(9);
String cc = "Document généré par le logiciel Bloc, (c) Front Software 2006";
addText("", cc, getWidth() - 2, 16, 90);
addText("", "Document généré par le logiciel OpenConcerto", getWidth() - 2, 16, 90);
 
setFontRoman(10);
long t = 53L;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator_2033B.java
20,11 → 20,9
 
public class PdfGenerator_2033B extends PdfGenerator {
public PdfGenerator_2033B() {
super("2033B.pdf", "result_2033B.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033BPDF"));
super("2033B.pdf", "2033B.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033BPDF"));
setTemplateOffset(0, 0);
setOffset(0, 0);
setMargin(32, 32);
 
}
 
public void generate() {
35,12 → 33,10
setFontRoman(12);
 
addSplittedText("CLOS1", "08202006", 410, 790, 9.7);
// addSplittedText("CLOS2", "08202006", 502, 809, 9.7);
 
// Copyright
setFontRoman(9);
String cc = "Document généré par le logiciel Bloc, (c) Front Software 2006";
addText("", cc, getWidth() - 2, 460, 90);
addText("", "Document généré par le logiciel OpenConcerto", getWidth() - 2, 460, 90);
 
setFontRoman(10);
long t = 143785123456L;
49,7 → 45,6
int cellHeight = 18;
final int colN = 487;
for (; y > 720; y -= cellHeight) {
 
addTextRight("PRODUIT1." + yy, insertCurrencySpaces("" + t), 400, y);
addTextRight("PRODUIT2." + yy, insertCurrencySpaces("" + t), colN, y);
addTextRight("PRODUIT3." + yy, insertCurrencySpaces("" + t), 580, y);
57,7 → 52,6
}
y += 2;
for (; y > 630; y -= cellHeight) {
 
addTextRight("PRODUIT2." + yy, insertCurrencySpaces("" + t), colN, y);
addTextRight("PRODUIT3." + yy, insertCurrencySpaces("" + t), 580, y);
yy++;
176,7 → 170,6
//
addTextRight("T1." + yy, insertCurrencySpaces("" + t), 226, y);
addTextRight("T2." + yy, insertCurrencySpaces("" + t), 461, y);
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator_2033C.java
21,24 → 21,21
public class PdfGenerator_2033C extends PdfGenerator {
 
public PdfGenerator_2033C() {
super("2033C.pdf", "result_2033C.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033CPDF"));
super("2033C.pdf", "2033C.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033CPDF"));
setTemplateOffset(0, 0);
setOffset(0, 0);
setMargin(32, 32);
 
}
 
public void generate() {
setFontBold(14);
 
SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
final SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
addText("NOM", rowSociete.getString("TYPE") + " " + rowSociete.getString("NOM"), 245, 794);
setFontRoman(12);
 
// Copyright
setFontRoman(9);
String cc = "Document généré par le logiciel Bloc, (c) Front Software 2006";
addText("", cc, 350, 31, 0);
addText("", "Document généré par le logiciel OpenConcerto", 350, 31, 0);
 
setFontRoman(10);
long t = 785123456L;
45,7 → 42,6
int yy = 0;
int y = 724;
for (int i = 0; i < 10; i++) {
 
addTextRight("IMMO1." + yy, insertCurrencySpaces("" + t), 225, y);
addTextRight("IMMO2." + yy, insertCurrencySpaces("" + t), 316, y);
addTextRight("IMMO3." + yy, insertCurrencySpaces("" + t), 407, y);
57,12 → 53,10
y -= 18;
y -= 18;
for (int i = 0; i < 8; i++) {
 
addTextRight("AM1." + yy, insertCurrencySpaces("" + t), 282, y);
addTextRight("AM2." + yy, insertCurrencySpaces("" + t), 384, y);
addTextRight("AM3." + yy, insertCurrencySpaces("" + t), 486, y);
addTextRight("AM4." + yy, insertCurrencySpaces("" + t), 587, y);
 
yy++;
y -= 18;
}
71,13 → 65,11
y -= 18;
y -= 18;
for (int i = 0; i < 10; i++) {
 
addText("VAL1." + yy, "Nature", 40, y);
addTextRight("VAL2." + yy, insertCurrencySpaces("" + t), 219, y);
addTextRight("VAL3." + yy, insertCurrencySpaces("" + t), 293, y);
addTextRight("VAL4." + yy, insertCurrencySpaces("" + t), 367, y);
addTextRight("VAL5." + yy, insertCurrencySpaces("" + t), 441, y);
 
addTextRight("VAL6." + yy, insertCurrencySpaces("" + t), 515, y);
addTextRight("VAL7." + yy, insertCurrencySpaces("" + t), 587, y);
yy++;
89,7 → 81,6
addTextRight("TOT3." + yy, insertCurrencySpaces("" + t), 293 - 8, y);
addTextRight("TOT4." + yy, insertCurrencySpaces("" + t), 367 - 8, y);
addTextRight("TOT5." + yy, insertCurrencySpaces("" + t), 441 - 8, y);
 
addTextRight("TOT6." + yy, insertCurrencySpaces("" + t), 515 - 8, y);
addTextRight("TOT7." + yy, insertCurrencySpaces("" + t), 587, y);
yy++;
101,13 → 92,10
addTextRight("TOT7." + yy, insertCurrencySpaces("" + t), 587, y);
yy++;
y -= 18;
 
setFontBold(10);
y += 2;
addTextRight("TOT6." + yy, insertCurrencySpaces("" + t), 515 - 8, y);
addTextRight("TOT7." + yy, insertCurrencySpaces("" + t), 587, y);
yy++;
y -= 18;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator_2033E.java
21,18 → 21,15
public class PdfGenerator_2033E extends PdfGenerator {
 
public PdfGenerator_2033E() {
super("2033E.pdf", "result_2033E.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033E"));
super("2033E.pdf", "2033E.pdf", TemplateNXProps.getInstance().getStringProperty("Location2033E"));
setTemplateOffset(0, 0);
setOffset(0, 0);
setMargin(32, 32);
}
 
public void generate() {
setFontBold(14);
 
SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
final SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
addText("NOM", rowSociete.getString("TYPE") + " " + rowSociete.getString("NOM"), 138, 722);
 
setFontRoman(12);
addText("OUVERT", "1er janvier 2004", 105, 703);
addText("CLOS", "31 décembre 2004", 274, 703);
40,8 → 37,7
 
// Copyright
setFontRoman(9);
String cc = "Document généré par le logiciel Bloc, (c) Front Software 2006";
addText("", cc, 350, 161, 0);
addText("", "Document généré par le logiciel OpenConcerto", 350, 161, 0);
 
setFontRoman(10);
long t = 785123456L;
48,17 → 44,13
int yy = 0;
int y = 651;
for (int i = 0; i < 8; i++) {
 
addTextRight("PROD1." + yy, insertCurrencySpaces("" + t), 563, y);
 
yy++;
y -= 18;
}
y -= 18;
for (int i = 0; i < 11; i++) {
 
addTextRight("CONSO1." + yy, insertCurrencySpaces("" + t), 563, y);
 
yy++;
y -= 18;
}
66,10 → 58,6
 
//
addTextRight("TOT1." + yy, insertCurrencySpaces("" + t), 563, y);
 
yy++;
y -= 18;
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauComptePCEAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauComptePCGAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauAssociationCpteAnalytiqueAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouvelleEcritureAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauClotureManuelleAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauJournalAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauExerciceAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauGestionAnalytiqueAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesCategorieComptableAction.java
New file
0,0 → 1,34
/*
* 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.sql.Configuration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesCategorieComptableAction extends CreateFrameAbstractAction {
 
public ListeDesCategorieComptableAction() {
super();
this.putValue(Action.NAME, "Liste des catégories comptables");
}
 
public JFrame createFrame() {
return new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("CATEGORIE_COMPTABLE")));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauClotureSansAnouveauxAction.java
New file
0,0 → 1,37
/*
* 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.core.finance.accounting.ui.ClotureSansAnouveauxPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class NouveauClotureSansAnouveauxAction extends CreateFrameAbstractAction {
 
public NouveauClotureSansAnouveauxAction() {
super();
this.putValue(Action.NAME, "Assistant Clôture2");
}
 
@Override
public JFrame createFrame() {
final PanelFrame panelFrame = new PanelFrame(new ClotureSansAnouveauxPanel(), "Assistant Clôture2");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesEcrituresAction.java
141,67 → 141,26
frame.getPanel().setReloadVisible(true);
frame.getPanel().getListe().setModificationAllowed(false);
 
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
menuDroit.add(new AbstractAction("Consultation du compte") {
public void actionPerformed(ActionEvent event) {
SQLRowAccessor row = frame.getPanel().getListe().getSelectedRow();
((EcritureSQLElement) element).consultationCompte(ComptePCESQLElement.getRow(row.getString("COMPTE_NUMERO"), row.getString("COMPTE_NOM")));
}
});
menuDroit.add(new AbstractAction("Contrepassation") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.contrePassationPiece(frame.getPanel().getListe().getSelectedId());
}
});
// menuDroit.add(new AbstractAction("Valider le mouvement") {
// public void actionPerformed(ActionEvent event) {
// if (JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir valider le
// mouvement?") == JOptionPane.YES_OPTION) {
// EcritureSQLElement.validationEcritures(frame.getPanel().getListe().getSelectedRow().getInt("ID_MOUVEMENT"));
// }
// }
// });
// table.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseReleased(MouseEvent e) {
// if (e.getButton() == MouseEvent.BUTTON3) {
// JPopupMenu menuDroit = new JPopupMenu();
//
// if (e.getModifiersEx() == 128) {
// menuDroit.add(new AbstractAction("Mettre à jour les noms de piéces") {
// public void actionPerformed(ActionEvent event) {
//
// correctNomPiece();
// }
// });
// }
//
// menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
// }
// }
// });
 
menuDroit.add(new AbstractAction("Dupliquer") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.dupliquer(frame.getPanel().getListe().fetchSelectedRow());
}
});
 
menuDroit.add(new AbstractAction("Gérer l'analytique") {
public void actionPerformed(ActionEvent event) {
PanelFrame frameAssoc = new PanelFrame(new AssociationAnalytiquePanel(frame.getPanel().getListe().getSelectedRow().asRow()), "Association analytique");
frameAssoc.setVisible(true);
}
});
 
menuDroit.add(new AbstractAction("Voir la source") {
public void actionPerformed(ActionEvent event) {
 
SQLRow row = frame.getPanel().getListe().fetchSelectedRow();
 
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
}
});
 
if (e.getModifiersEx() == 128) {
menuDroit.add(new AbstractAction("Mettre à jour les noms de piéces") {
public void actionPerformed(ActionEvent event) {
 
correctNomPiece();
}
});
}
 
menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
}
}
});
 
frame.getPanel().getListe().getModel().invokeLater(new Runnable() {
public void run() {
int rowCount = frame.getPanel().getListe().getModel().getRowCount() - 1;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteGestCommPreferencePanel.java
24,6 → 24,7
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.TitledSeparator;
36,7 → 37,9
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 
public class CompteGestCommPreferencePanel extends DefaultPreferencePanel {
 
338,7 → 341,14
DefaultNXProps.getInstance().setProperty("HideAnalytique", String.valueOf(this.checkHideAnalytique.isSelected()));
DefaultNXProps.getInstance().store();
try {
this.rowPrefCompteVals.update();
final Object[] pb = this.rowPrefCompteVals.getInvalid();
if (pb != null) {
final SQLFieldTranslator trans = Configuration.getInstance().getTranslator();
JOptionPane.showMessageDialog(SwingUtilities.getRoot(this), "Impossible de valider les modifications! Le champ <"
+ trans.getLabelFor(this.rowPrefCompteVals.getTable().getField(pb[0].toString())) + "> pointe sur un compte invalide!(" + pb[1] + ")");
} else {
this.rowPrefCompteVals.update();
}
} catch (SQLException e) {
e.printStackTrace();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ClotureSansAnouveauxPanel.java
New file
0,0 → 1,517
/*
* 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.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.erp.element.objet.Compte;
import org.openconcerto.erp.generationEcritures.GenerationMvtVirement;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
public class ClotureSansAnouveauxPanel extends JPanel {
private final JDate dateOuv = new JDate();
private final JDate dateFerm = new JDate();
private SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
private final SQLTable societe = Configuration.getInstance().getBase().getTable("SOCIETE_COMMON");
private final SQLTable exercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON");
private final SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
// private final SQLRow rowExercice =
// this.exercice.getRow(this.rowSociete.getInt("ID_EXERCICE_COMMON"));
private final Map<Object, Long> mRAN = new HashMap<Object, Long>();
private JButton valider = new JButton("Valider");
private JButton annul = new JButton("Annuler");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private JLabel opEnCours = new JLabel("Etat: en attente de validation");
private JCheckBox boxValid = new JCheckBox("Je confirme avoir effectué toutes les opérations nécessaires.");
 
private JProgressBar bar = new JProgressBar(0, 4);
 
public ClotureSansAnouveauxPanel() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.gridx = 0;
c.gridy = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 1;
c.weightx = 0;
c.weighty = 0;
 
JLabel rappel = new JLabelBold("Opérations à effectuer avant de continuer: ");
JLabel label = new JLabel("- report des charges et produits constatés d'avance");
JLabel label2 = new JLabel("- report des charges à payer et produits à recevoir");
JLabel label3 = new JLabel("- impression du bilan, compte de résultat, grand livre, journaux et balance");
JLabel label5 = new JLabel("- génération les écritures comptables des payes");
JLabel label4 = new JLabel("Il est préférable de réaliser une sauvegarde avant de continuer.");
 
JLabel op = new JLabelBold("Opérations qui vont etre effectuées: ");
JLabel labelValid = new JLabel("- validation de toutes les écritures concernant la période de l'exercice.");
JLabel labelSoldeGestion = new JLabel("- soldes de tous les comptes de gestions 6* et 7*");
JLabel labelSoldeBilan = new JLabel("- soldes de tous les comptes de bilan");
JLabel labelAN = new JLabel("- report des à nouveaux");
 
c.gridy = GridBagConstraints.RELATIVE;
c.gridx = 0;
 
// Date de l'ancien exercice
// Calendar dDebut = this.rowExercice.getDate("DATE_DEB");
// Calendar dFin = this.rowExercice.getDate("DATE_FIN");
// JLabel labelAncienExercice = new JLabel("Clôture de l'exercice du " +
// dateFormat.format(dDebut.getTime()) + " au " + dateFormat.format(dFin.getTime()));
// this.add(labelAncienExercice, c);
c.insets = new Insets(10, 2, 1, 2);
this.add(rappel, c);
this.add(label, c);
this.add(label2, c);
this.add(label3, c);
this.add(label5, c);
this.add(label4, c);
 
c.insets = new Insets(15, 2, 1, 2);
this.add(op, c);
 
c.insets = new Insets(10, 2, 1, 2);
this.add(labelValid, c);
this.add(labelSoldeGestion, c);
this.add(labelSoldeBilan, c);
this.add(labelAN, c);
 
// Date du prochain exercice
c.gridwidth = 1;
c.gridy = GridBagConstraints.RELATIVE;
c.gridx = 0;
c.gridx = GridBagConstraints.RELATIVE;
c.fill = GridBagConstraints.NONE;
 
this.add(new JLabel("Date du nouvel exercice du "), c);
 
// dDebut.set(Calendar.YEAR, dDebut.get(Calendar.YEAR) + 1);
// this.dateOuv.setValue(dDebut.getTime());
this.add(this.dateOuv, c);
this.add(new JLabel("au"), c);
// dFin.set(Calendar.YEAR, dFin.get(Calendar.YEAR) + 1);
// this.dateFerm.setValue(dFin.getTime());
this.add(this.dateFerm, c);
 
c.gridx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 2;
c.weightx = 1;
this.add(this.opEnCours, c);
 
c.gridwidth = 4;
c.gridx = 0;
c.weightx = 1;
this.add(this.bar, c);
 
//
this.add(this.boxValid, c);
 
// Button
final JPanel buttonBar = new JPanel();
buttonBar.add(this.valider);
buttonBar.add(this.annul);
 
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
c.gridx = 0;
this.add(buttonBar, c);
 
final PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
ClotureSansAnouveauxPanel.this.valider.setEnabled(isDateValid());
}
};
// this.dateFerm.addValueListener(listener);
// this.dateOuv.addValueListener(listener);
 
// TODO afficher le deroulement de etapes apres validation
 
this.valider.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
 
valider.setEnabled(false);
dateFerm.setEnabled(false);
dateOuv.setEnabled(false);
 
new Thread(new Runnable() {
public void run() {
try {
clotureExercice();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// show OK works fine
Component comp = SwingUtilities.getRoot(ClotureSansAnouveauxPanel.this);
JOptionPane.showMessageDialog(ClotureSansAnouveauxPanel.this, "Exercice clôturé", "Fin de la clôture", JOptionPane.INFORMATION_MESSAGE);
if (comp != null) {
((JFrame) comp).dispose();
}
}
});
} catch (Exception ex) {
ExceptionHandler.handle("Erreur lors de la clôture", ex);
}
}
}).start();
 
}
});
 
// this.valider.setEnabled(isDateValid());
 
this.boxValid.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
ClotureSansAnouveauxPanel.this.valider.setEnabled(isDateValid());
}
});
 
this.annul.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
 
((JFrame) SwingUtilities.getRoot(ClotureSansAnouveauxPanel.this)).dispose();
}
});
}
 
private boolean isDateValid() {
// final Date d = (Date) this.rowExercice.getObject("DATE_FIN");
// return this.boxValid.isSelected() && (((!this.dateFerm.isEmpty()) &&
// (!this.dateOuv.isEmpty()) && (this.dateFerm.getValue().getTime() >
// this.dateOuv.getValue().getTime())
// && (this.dateOuv.getValue().getTime() > d.getTime())));
return true;
}
 
private final SQLTable tablePrefCompte = this.base.getTable("PREFS_COMPTE");
 
private void clotureExercice() throws SQLException {
 
final SQLRow rowPrefCompte = this.tablePrefCompte.getRow(2);
final int id_Compte_Bilan_Ouverture;
if (rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O") <= 1) {
id_Compte_Bilan_Ouverture = ComptePCESQLElement.getId("890");
} else {
id_Compte_Bilan_Ouverture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O");
}
 
final int id_Compte_Bilan_Cloture;
if (rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F") <= 1) {
id_Compte_Bilan_Cloture = ComptePCESQLElement.getId("891");
} else {
id_Compte_Bilan_Cloture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F");
}
 
// /*******************************************************************************************
// * Validation des écritures
// ******************************************************************************************/
// EcritureSQLElement.validationEcrituresBefore((Date)
// this.rowExercice.getObject("DATE_FIN"), true);
 
SQLUtils.executeAtomic(this.tablePrefCompte.getDBSystemRoot().getDataSource(), new SQLUtils.SQLFactory<Object>() {
@Override
public Object create() throws SQLException {
 
/*******************************************************************************************
* Solde des comptes de gestion 6* et 7* (génération du résultat)
******************************************************************************************/
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ClotureSansAnouveauxPanel.this.opEnCours.setText("En cours: solde des comptes 6 et 7");
}
});
long time = new Date().getTime();
System.err.println("Start :: " + time);
soldeCompte(false);
 
/*******************************************************************************************
* Solde des autres comptes (comptes de bilan)
******************************************************************************************/
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ClotureSansAnouveauxPanel.this.opEnCours.setText("En cours: solde des comptes autres que 6 et 7");
ClotureSansAnouveauxPanel.this.bar.setValue(1);
}
});
soldeCompte(true);
 
long time2 = new Date().getTime();
System.err.println("Stop :: " + time2);
System.err.println("Time :: " + (time2 - time));
 
/*******************************************************************************************
* Reouverture des comptes de bilan
******************************************************************************************/
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ClotureSansAnouveauxPanel.this.opEnCours.setText("En cours: report des à nouveaux");
ClotureSansAnouveauxPanel.this.bar.setValue(2);
}
});
// transfert du compte bilan fermeture vers le compte bilan ouverture
SQLTable ecritureTable = ClotureSansAnouveauxPanel.this.base.getTable("ECRITURE");
SQLTable compteTable = ClotureSansAnouveauxPanel.this.base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(ClotureSansAnouveauxPanel.this.base);
 
sel.addSelect(compteTable.getKey());
sel.addSelect(compteTable.getField("NUMERO"));
sel.addSelect(compteTable.getField("NOM"));
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
 
Where w = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", id_Compte_Bilan_Cloture);
w = w.and(new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey()));
sel.setWhere(w);
 
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\", \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
System.out.println(req);
 
Object ob = ClotureSansAnouveauxPanel.this.base.getDataSource().execute(req, new ArrayListHandler());
 
List myList = (List) ob;
 
if (myList.size() != 0) {
GenerationMvtVirement gen = new GenerationMvtVirement(1, id_Compte_Bilan_Cloture, 0, 0, "Fermeture du compte ", ClotureSansAnouveauxPanel.this.dateFerm.getDate(),
JournalSQLElement.OD, "Fermeture des comptes");
for (int i = 0; i < myList.size(); i++) {
 
Object[] objTmp = (Object[]) myList.get(i);
Compte cptTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(), objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(), ((Number) objTmp[4]).longValue());
// vecteurCompte.add(cptTmp);
 
long solde = cptTmp.getTotalDebit() - cptTmp.getTotalCredit();
 
if (solde != 0) {
if (solde > 0) {
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, 0, Math.abs(solde), "Fermeture du compte " + cptTmp.getNumero(),
ClotureSansAnouveauxPanel.this.dateFerm.getDate(), JournalSQLElement.OD, false);
 
} else {
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, Math.abs(solde), 0, "Fermeture du compte " + cptTmp.getNumero(),
ClotureSansAnouveauxPanel.this.dateFerm.getDate(), JournalSQLElement.OD, false);
}
gen.genereMouvement();
}
}
}
/*******************************************************************************************
* Validation des écritures de clotures
******************************************************************************************/
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ClotureSansAnouveauxPanel.this.opEnCours.setText("En cours: validation des écritures de l'exercice");
ClotureSansAnouveauxPanel.this.bar.setValue(3);
}
});
EcritureSQLElement.validationEcrituresBefore((Date) ClotureSansAnouveauxPanel.this.dateFerm.getDate(), true);
 
// // A nouveaux
// Object[] compteAnouveau = ClotureSansAnouveauxPanel.this.mRAN.keySet().toArray();
// GenerationMvtVirement genAnouveaux = new
// GenerationMvtVirement(id_Compte_Bilan_Ouverture, 1, 0, 0, "A nouveaux",
// ClotureSansAnouveauxPanel.this.dateOuv.getValue(), JournalSQLElement.OD,
// "A nouveaux");
// for (int i = 0; i < ClotureSansAnouveauxPanel.this.mRAN.keySet().size(); i++) {
//
// long solde =
// ClotureSansAnouveauxPanel.this.mRAN.get(compteAnouveau[i]).longValue();
//
// // if (solde != 0) {
// if (solde > 0) {
// genAnouveaux.setValues(id_Compte_Bilan_Ouverture,
// Integer.parseInt(compteAnouveau[i].toString()), 0, Math.abs(solde), "A nouveaux",
// ClotureSansAnouveauxPanel.this.dateOuv.getValue(),
// JournalSQLElement.OD, false);
// } else {
// genAnouveaux.setValues(id_Compte_Bilan_Ouverture,
// Integer.parseInt(compteAnouveau[i].toString()), Math.abs(solde), 0, "A nouveaux",
// ClotureSansAnouveauxPanel.this.dateOuv.getValue(),
// JournalSQLElement.OD, false);
// }
// genAnouveaux.genereMouvement();
// // }
// }
//
// // Fixé la nouvel date de l'exercice
// SQLRowValues valsExercice = new
// SQLRowValues(ClotureSansAnouveauxPanel.this.exercice);
// valsExercice.put("CLOTURE", Boolean.TRUE);
// valsExercice.update(ClotureSansAnouveauxPanel.this.rowExercice.getID());
//
// // Creation d'un nouvel exercice
// valsExercice.put("CLOTURE", Boolean.FALSE);
// valsExercice.put("DATE_DEB", new
// java.sql.Date(ClotureSansAnouveauxPanel.this.dateOuv.getValue().getTime()));
// valsExercice.put("DATE_FIN", new
// java.sql.Date(ClotureSansAnouveauxPanel.this.dateFerm.getValue().getTime()));
// valsExercice.put("ID_SOCIETE_COMMON",
// ClotureSansAnouveauxPanel.this.rowSociete.getID());
// SQLRow rowNewEx = valsExercice.insert();
//
// // mise a jour de l'exercice de la societe
// SQLRowValues rowValsSociete = new
// SQLRowValues(ClotureSansAnouveauxPanel.this.societe);
// rowValsSociete.put("ID_EXERCICE_COMMON", rowNewEx.getID());
// rowValsSociete.update(ClotureSansAnouveauxPanel.this.rowSociete.getID());
// // Recharge les informations de la societe pour pointer sur le nouvel exercice
// ComptaPropsConfiguration.getInstanceCompta().getRowSociete().fetchValues();
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
// ClotureSansAnouveauxPanel.this.bar.setValue(4);
// ClotureSansAnouveauxPanel.this.opEnCours.setText("Etat: clôture terminée");
// }
// });
 
return null;
}
});
}
 
private void soldeCompte(boolean compteBilan) throws SQLException {
 
String typeCompte;
int compteDest;
 
SQLRow rowPrefCompte = this.tablePrefCompte.getRow(2);
if (compteBilan) {
typeCompte = "^[^6-8].*$";
compteDest = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F");
if (compteDest <= 1) {
compteDest = ComptePCESQLElement.getId("891", "Bilan de clôture");
}
} else {
SommeCompte s = new SommeCompte();
long solde6 = s.soldeCompte(6, 6, true, this.dateOuv.getDate(), this.dateFerm.getDate());
long solde7 = s.soldeCompte(7, 7, true, this.dateOuv.getDate(), this.dateFerm.getDate());
long resultat = -solde7 - solde6;
System.err.println("Solde Résultat :::: " + solde7 + " __ " + solde6 + "__" + (solde7 - solde6));
typeCompte = "^(6|7).*$";
 
if (resultat > 0) {
compteDest = rowPrefCompte.getInt("ID_COMPTE_PCE_RESULTAT");
} else {
compteDest = rowPrefCompte.getInt("ID_COMPTE_PCE_RESULTAT_PERTE");
}
 
if (compteDest <= 1) {
if (resultat > 0) {
compteDest = ComptePCESQLElement.getId("120", "Résultat de l'exercice (bénéfice)");
} else {
compteDest = ComptePCESQLElement.getId("129", "Résultat de l'exercice (perte)");
}
}
}
 
// on récupére les comptes avec leurs totaux
SQLTable ecritureTable = this.base.getTable("ECRITURE");
SQLTable compteTable = this.base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(this.base);
 
sel.addSelect(compteTable.getKey());
sel.addSelect(compteTable.getField("NUMERO"));
sel.addSelect(compteTable.getField("NOM"));
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
 
Where w = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey());
 
String function = "REGEXP";
if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
// function = "SIMILAR TO";
// typeCompte = typeCompte.replace(".*", "%");
function = "~";
}
 
Where w2 = new Where(compteTable.getField("NUMERO"), function, typeCompte);
Where w3 = new Where(ecritureTable.getField("DATE"), "<=", this.dateFerm.getDate());
sel.setWhere(w.and(w2).and(w3));
 
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\", \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
System.err.println(req);
 
Object ob = this.base.getDataSource().execute(req, new ArrayListHandler());
 
List myList = (List) ob;
 
if (myList != null && myList.size() != 0) {
 
GenerationMvtVirement genFerm = new GenerationMvtVirement(1, compteDest, 0, 0, "Fermeture du compte ", this.dateFerm.getDate(), JournalSQLElement.OD, "Fermeture des comptes");
for (int i = 0; i < myList.size(); i++) {
 
Object[] objTmp = (Object[]) myList.get(i);
Compte cptTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(), objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(), ((Number) objTmp[4]).longValue());
 
long solde = cptTmp.getTotalDebit() - cptTmp.getTotalCredit();
 
// if (solde != 0) {
if (compteBilan) {
this.mRAN.put(objTmp[0], Long.valueOf(solde));
}
 
if (solde > 0) {
genFerm.setValues(cptTmp.getId(), compteDest, 0, Math.abs(solde), "Fermeture du compte " + cptTmp.getNumero(), this.dateFerm.getDate(), JournalSQLElement.OD, false);
} else {
 
genFerm.setValues(cptTmp.getId(), compteDest, Math.abs(solde), 0, "Fermeture du compte " + cptTmp.getNumero(), this.dateFerm.getDate(), JournalSQLElement.OD, false);
}
genFerm.genereMouvement();
}
// }
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptePayePreferencePanel.java
22,6 → 22,7
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
32,7 → 33,9
import java.sql.SQLException;
 
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 
public class ComptePayePreferencePanel extends DefaultPreferencePanel {
private ISQLCompteSelector selCompteAcompte, selCompteAcompteReglement, selCompteRemunPers;
124,7 → 127,14
this.rowPrefCompteVals.put("ID_COMPTE_PCE_PAYE", this.selCompteRemunPers.getValue());
 
try {
this.rowPrefCompteVals.update();
final Object[] pb = this.rowPrefCompteVals.getInvalid();
if (pb != null) {
final SQLFieldTranslator trans = Configuration.getInstance().getTranslator();
JOptionPane.showMessageDialog(SwingUtilities.getRoot(this), "Impossible de valider les modifications! Le champ <"
+ trans.getLabelFor(this.rowPrefCompteVals.getTable().getField(pb[0].toString())) + "> pointe sur un compte invalide!(" + pb[1] + ")");
} else {
this.rowPrefCompteVals.update();
}
} catch (SQLException e) {
e.printStackTrace();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieJournalPanel.java
13,10 → 13,8
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
36,6 → 34,8
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
42,7 → 42,6
import java.util.Date;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
49,6 → 48,7
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
81,6 → 81,17
return input;
}
});
this.addHierarchyListener(new HierarchyListener() {
public void hierarchyChanged(HierarchyEvent e) {
if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0)
if (isDisplayable()) {
listeEcr.addIListeActions(ecrElt.getRowActions());
 
} else {
listeEcr.removeIListeActions(ecrElt.getRowActions());
}
}
});
GridBagConstraints cListe = new DefaultGridBagConstraints();
cListe.fill = GridBagConstraints.BOTH;
cListe.gridwidth = 1;
157,10 → 168,25
 
final JCheckBox boxAutoInsert = new JCheckBox("Insertion automatique");
 
final SaisieJournalItemTable table = new SaisieJournalItemTable(defaultRowVals, boxAutoInsert);
JPanel panelBottom = new JPanel(new GridBagLayout());
GridBagConstraints cB = new DefaultGridBagConstraints();
 
panelBottom.add(new JLabel(TM.tr("accounting.editing.piece.label")), cB);
cB.gridx++;
final JTextField textPiece = new JTextField();
panelBottom.add(textPiece, cB);
 
final SaisieJournalItemTable table = new SaisieJournalItemTable(defaultRowVals, boxAutoInsert, textPiece);
table.setPanel(this);
 
split.setBottomComponent(table);
cB.gridwidth = GridBagConstraints.REMAINDER;
cB.weightx = 1;
cB.weighty = 1;
cB.fill = GridBagConstraints.BOTH;
cB.gridy++;
cB.gridx = 0;
panelBottom.add(table, cB);
split.setBottomComponent(panelBottom);
 
this.add(split, c);
 
201,7 → 227,7
 
@Override
public void actionPerformed(ActionEvent e) {
table.createSaisie(defaultRowVals);
table.createSaisie(defaultRowVals, textPiece);
}
});
buttonClose.addActionListener(new ActionListener() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieKmItemTable.java
93,16 → 93,19
final SQLTableElement tableElementNomEcriture = new SQLTableElement(tableElement.getField("NOM_ECRITURE"));
list.add(tableElementNomEcriture);
 
//
 
boolean kd = false;
this.debit = new SQLTableElement(tableElement.getField("DEBIT"), Long.class, this.deviseCellEditor);
list.add(this.debit);
this.credit = new SQLTableElement(tableElement.getField("CREDIT"), Long.class, this.deviseCellEditor);
list.add(this.credit);
if (!DefaultNXProps.getInstance().getBooleanValue("HideAnalytique")) {
if (!kd && !DefaultNXProps.getInstance().getBooleanValue("HideAnalytique")) {
final AnalytiqueItemTable analytiqueAssocTable = new AnalytiqueItemTable(true);
SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class,
new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable));
new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable)) {
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
return vals.getString("NUMERO") != null && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"));
};
};
list.add(eltPourcentAnalytique);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ImportEcriturePanel.java
169,7 → 169,7
}
 
} catch (Exception e) {
if (e.getMessage().toLowerCase().contains("file format")) {
if (e.getMessage() != null && e.getMessage().toLowerCase().contains("file format")) {
JOptionPane.showMessageDialog(ImportEcriturePanel.this, "Format de fichier non pris en charge");
} else {
ExceptionHandler.handle(frame, "Erreur lors de la lecture du fichier " + fileToImport.getAbsolutePath(), e);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieJournalItemTable.java
68,6 → 68,7
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
94,7 → 95,7
private final JCheckBox boxAutoInsert;
private boolean hideAnalytique = false;
 
public SaisieJournalItemTable(final SQLRowValues defaultRowVals, JCheckBox boxAutoInsert) {
public SaisieJournalItemTable(final SQLRowValues defaultRowVals, JCheckBox boxAutoInsert, final JTextField textField) {
setLayout(new GridBagLayout());
this.boxAutoInsert = boxAutoInsert;
final GridBagConstraints c = new DefaultGridBagConstraints();
146,7 → 147,7
 
@Override
public void actionPerformed(ActionEvent e) {
montantValid(defaultRowVals, true);
montantValid(defaultRowVals, true, textField);
}
});
final MultiLineTableCellEditor multiLineTableCellEditor = new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable);
258,7 → 259,7
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
montantValid(defaultRowVals, false);
montantValid(defaultRowVals, false, textField);
}
}
};
472,7 → 473,7
return Tuple2.create(c.getTime(), lib);
}
 
public void montantValid(final SQLRowValues defaultRowVals, final boolean fromAnalytique) {
public void montantValid(final SQLRowValues defaultRowVals, final boolean fromAnalytique, final JTextField textPiece) {
System.err.println("Enter");
final SQLRowValues vals = SaisieJournalItemTable.this.table.getSelectedRowValues();
final int selectedRow = SaisieJournalItemTable.this.table.getSelectedRow();
483,7 → 484,7
if (SaisieJournalItemTable.this.panel.getSelectedJournal() == SQLRow.NONEXISTANT_ID || SaisieJournalItemTable.this.panel.getSelectedMonth() == -1) {
JOptionPane.showMessageDialog(SaisieJournalItemTable.this.panel, "Impossible de créer la saisie si aucun journal ou aucun mois n'est sélectionné!");
} else {
createSaisie(defaultRowVals);
createSaisie(defaultRowVals, textPiece);
}
} else {
if (!fromAnalytique && !hideAnalytique && vals.getString("NUMERO") != null && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"))) {
517,11 → 518,12
 
}
 
public synchronized void createSaisie(final SQLRowValues defaultRowVals) {
public synchronized void createSaisie(final SQLRowValues defaultRowVals, JTextField pieceText) {
 
Tuple2<Date, String> t = getDateAndLabelFromSaisie();
final Date d = t.get0();
final String lib = t.get1();
String pieceLabel = pieceText.getText();
final String lib = pieceLabel == null || pieceLabel.trim().length() == 0 ? t.get1() : pieceLabel;
 
// Create saisieKM
SQLRowValues rowVAlsKM = new SQLRowValues(SaisieJournalItemTable.this.table.getRowValuesTableModel().getSQLElement().getTable().getForeignTable("ID_SAISIE_KM"));
536,12 → 538,17
table.updateField("ID_SAISIE_KM", id);
table.clear();
GenerationMvtSaisieKm gen = new GenerationMvtSaisieKm(id);
gen.genereMouvement();
int idMvt = gen.genereMouvement();
 
// maj de l'id du mouvement correspondant
SQLRowValues rowValsKMMvt = new SQLRowValues(SaisieJournalItemTable.this.table.getRowValuesTableModel().getSQLElement().getTable().getForeignTable("ID_SAISIE_KM"));
rowValsKMMvt.put("ID_MOUVEMENT", new Integer(idMvt));
rowValsKMMvt.update(id);
 
defaultRowVals.put("NOM_PIECE", "");
defaultRowVals.put("NOM_ECRITURE", "");
table.getRowValuesTableModel().addNewRow();
 
pieceText.setText("");
} catch (SQLException e) {
e.printStackTrace();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteCloturePreferencePanel.java
23,7 → 23,7
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
34,7 → 34,9
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 
public class CompteCloturePreferencePanel extends DefaultPreferencePanel {
private ISQLCompteSelector selCompteOuverture, selCompteFermeture, selCompteResultat, selCompteResultatPerte;
136,7 → 138,14
this.rowPrefCompteVals.put("CREATE_NUL_SOLDE_ECR", this.boxCompteSolde.isSelected());
 
try {
this.rowPrefCompteVals.update();
final Object[] pb = this.rowPrefCompteVals.getInvalid();
if (pb != null) {
final SQLFieldTranslator trans = Configuration.getInstance().getTranslator();
JOptionPane.showMessageDialog(SwingUtilities.getRoot(this), "Impossible de valider les modifications! Le champ <"
+ trans.getLabelFor(this.rowPrefCompteVals.getTable().getField(pb[0].toString())) + "> pointe sur un compte invalide!(" + pb[1] + ")");
} else {
this.rowPrefCompteVals.update();
}
} catch (SQLException e) {
e.printStackTrace();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/GrandLivrePanel.java
30,6 → 30,7
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.TableSorter;
 
42,7 → 43,6
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.concurrent.ExecutionException;
 
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
49,6 → 49,7
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
111,7 → 112,7
// On recupere les differentes classes
List<ClasseCompte> liste = ClasseCompte.getClasseCompte();
 
if (liste.size() != 0) {
if (!liste.isEmpty()) {
for (int k = 0; k < liste.size(); k++) {
 
final ClasseCompte ccTmp = liste.get(k);
119,9 → 120,7
new SwingWorker<JPanel, Object>() {
@Override
protected JPanel doInBackground() throws Exception {
// TODO Auto-generated method stub
return initClassePanel(ccTmp);
 
}
 
@Override
129,9 → 128,7
JPanel initClassePanel;
try {
initClassePanel = get();
 
initClassePanel.setOpaque(false);
 
final JScrollPane scrollPane = new JScrollPane(initClassePanel);
scrollPane.setOpaque(false);
scrollPane.setBorder(null);
138,13 → 135,8
scrollPane.getViewport().setOpaque(false);
// On créer les comptes de chaque classe
GrandLivrePanel.this.tabbedClasse.addTab(ccTmp.getNom(), scrollPane);
 
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
ExceptionHandler.handle("erreur " + ccTmp.getNom(), e);
}
fireLoading(false);
super.done();
195,9 → 187,7
String function = "REGEXP";
String match = cc.getTypeNumeroCompte();
if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
// function = "SIMILAR TO";
function = "~";
// match = cc.getTypeNumeroCompte().replace(".*", "%");
}
 
Where w = new Where(compteTable.getField("NUMERO"), function, match);
219,12 → 209,11
 
JLabel labelTotalClasse = new JLabel();
labelTotalClasse.setOpaque(false);
if (myList.size() != 0) {
if (!myList.isEmpty()) {
 
/***************************************************************************************
* Création des Panels de chaque compte
**************************************************************************************/
// c.weighty = 1;
for (int i = 0; i < myList.size(); i++) {
 
Object[] objTmp = (Object[]) myList.get(i);
285,7 → 274,6
// Total du Compte
JLabel labelCompteDebit = new JLabel("Total Debit : " + GestionDevise.currencyToString(compte.getTotalDebit()));
JLabel labelCompteCredit = new JLabel(" Credit : " + GestionDevise.currencyToString(compte.getTotalCredit()));
// labelCompte.setFont(new Font(labelCompte.getFont().getFontName(), Font.BOLD, 12));
labelCompteDebit.setHorizontalAlignment(SwingUtilities.LEFT);
labelCompteCredit.setHorizontalAlignment(SwingUtilities.LEFT);
 
305,45 → 293,39
 
public void actionPerformed(ActionEvent e) {
 
System.err.println(this.isShow);
// Afficher la JTable du compte
if (!this.isShow) {
// if (this.scroll == null) {
System.err.println(compte);
 
JTable tableCpt = createJTableCompte(compte);
if (tableCpt == null) {
JOptionPane.showMessageDialog(GrandLivrePanel.this, "Aucune écriture");
return;
} else {
this.scroll = new JScrollPane(tableCpt);
 
this.scroll = new JScrollPane(tableCpt);
// calcul de la taille du JScrollPane
Dimension d;
if (tableCpt.getPreferredSize().height > 200) {
d = new Dimension(this.scroll.getPreferredSize().width, 200);
} else {
d = new Dimension(this.scroll.getPreferredSize().width, tableCpt.getPreferredSize().height + 30);
}
this.scroll.setPreferredSize(d);
 
// calcul de la taille du JScrollPane
Dimension d;
System.err.println(tableCpt);
if (tableCpt.getPreferredSize().height > 200) {
d = new Dimension(this.scroll.getPreferredSize().width, 200);
} else {
d = new Dimension(this.scroll.getPreferredSize().width, tableCpt.getPreferredSize().height + 30);
c.gridy++;
c.gridwidth = 4;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
panelCompte.add(this.scroll, c);
 
}
this.scroll.setPreferredSize(d);
 
c.gridy++;
c.gridwidth = 4;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
panelCompte.add(this.scroll, c);
/*
* } else { this.scroll.setVisible(true); }
*/
 
} else {
// if (this.scroll != null) {
panelCompte.remove(this.scroll);
System.out.println("Hide scrollPane");
// this.scroll.setVisible(false);
 
// this.scroll.repaint();
if (this.scroll != null) {
panelCompte.remove(this.scroll);
}
panelCompte.repaint();
panelCompte.revalidate();
// }
}
 
this.isShow = !this.isShow;
376,7 → 358,7
 
// Gestion de la souris sur la JTable
tableTmp.addMouseListener(new MouseAdapter() {
 
@Override
public void mousePressed(final MouseEvent mE) {
 
if (mE.getButton() == MouseEvent.BUTTON3) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/AnalytiqueItemTable.java
13,6 → 13,7
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.DeviseCellEditor;
import org.openconcerto.erp.core.common.ui.RowValuesMultiLineEditTable;
import org.openconcerto.sql.Configuration;
151,16 → 152,18
@Override
public void tableChanged(TableModelEvent e) {
long totalReparti = 0;
if (totalArepartir != 0) {
for (int i = 0; i < model.getRowCount(); i++) {
totalReparti += model.getRowValuesAt(i).getLong("MONTANT");
// TODO Gestion répartition multi axe
if (totalArepartir != 0) {
for (int i = 0; i < model.getRowCount(); i++) {
totalReparti += model.getRowValuesAt(i).getLong("MONTANT");
}
 
getDefaultRowValues().put("POURCENT", new BigDecimal(totalReparti).divide(new BigDecimal(totalArepartir), DecimalUtils.HIGH_PRECISION).setScale(6, RoundingMode.HALF_UP));
getDefaultRowValues().put("MONTANT", totalArepartir - totalReparti);
buttonValider.setEnabled(totalReparti == totalArepartir);
} else {
buttonValider.setEnabled(true);
}
 
getDefaultRowValues().put("POURCENT", new BigDecimal(totalReparti).divide(new BigDecimal(totalArepartir), DecimalUtils.HIGH_PRECISION).setScale(6, RoundingMode.HALF_UP));
getDefaultRowValues().put("MONTANT", totalArepartir - totalReparti);
}
buttonValider.setEnabled(totalReparti == totalArepartir);
 
}
});
final RowValuesMultiLineEditTable multiTable = (RowValuesMultiLineEditTable) this.table;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PointagePanel.java
38,6 → 38,7
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.warning.JLabelWarning;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.Color;
import java.awt.Dimension;
74,6 → 75,8
import javax.swing.SwingWorker;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
public class PointagePanel extends JPanel {
 
241,6 → 244,7
this.dateDeb.addValueListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
changeListRequest();
PointagePanel.this.model.updateTotauxCompte();
}
});
 
250,6 → 254,7
this.dateFin.addValueListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
changeListRequest();
PointagePanel.this.model.updateTotauxCompte();
}
});
 
288,7 → 293,7
c.fill = GridBagConstraints.BOTH;
c.gridwidth = 4;
c.gridheight = 3;
this.model = new PointageModel(this.selCompte.getSelectedId());
this.model = new PointageModel(this.selCompte.getSelectedId(), this);
JTable table = new JTable(this.model);
table.setRowHeight(FontUtils.getPreferredRowHeight(table));
// AlternateTableCellRenderer.setAllColumns(table);
438,25 → 443,22
}
});
 
// Gestion du code de releve
this.codePointage.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
 
PointagePanel.this.warningPanel.setVisible((PointagePanel.this.codePointage.getText().trim().length() == 0));
PointagePanel.this.buttonPointer.setEnabled((PointagePanel.this.codePointage.getText().trim().length() != 0));
this.ecriturePanel.getListe().addListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
PointagePanel.this.model.updateTotauxCompte();
}
});
 
public void removeUpdate(DocumentEvent e) {
// Gestion du code de releve
this.codePointage.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void update(DocumentEvent e) {
PointagePanel.this.warningPanel.setVisible((PointagePanel.this.codePointage.getText().trim().length() == 0));
PointagePanel.this.buttonPointer.setEnabled((PointagePanel.this.codePointage.getText().trim().length() != 0));
PointagePanel.this.model.updateTotauxCompte();
}
 
public void insertUpdate(DocumentEvent e) {
 
PointagePanel.this.warningPanel.setVisible((PointagePanel.this.codePointage.getText().trim().length() == 0));
PointagePanel.this.buttonPointer.setEnabled((PointagePanel.this.codePointage.getText().trim().length() != 0));
}
});
 
changeListRequest();
502,6 → 504,18
menu.show(mE.getComponent(), mE.getPoint().x, mE.getPoint().y);
}
 
public Date getDateDeb() {
return this.dateDeb.getValue();
}
 
public Date getDateFin() {
return this.dateFin.getDate();
}
 
public String getCodePointage() {
return this.codePointage.getText();
}
 
/* Panel Warning no numero releve */
private void createPanelWarning() {
 
558,6 → 572,10
this.model.updateTotauxCompte();
}
 
public ListPanelEcritures getEcriturePanel() {
return ecriturePanel;
}
 
// Pointe la ligne passée en parametre
private void actionDepointage(int rowIndex) {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptaPrefTreeNode.java
34,6 → 34,7
import org.openconcerto.erp.preferences.MailRelancePreferencePanel;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.erp.preferences.NumerotationPreferencePanel;
import org.openconcerto.erp.preferences.PayPalPreferencePanel;
import org.openconcerto.erp.preferences.PayeGlobalPreferencePanel;
import org.openconcerto.erp.preferences.SauvegardeEnLignePreferencePanel;
import org.openconcerto.erp.preferences.SauvegardeFichierPreferencePanel;
51,7 → 52,7
import javax.swing.tree.DefaultMutableTreeNode;
 
public class ComptaPrefTreeNode extends DefaultMutableTreeNode {
public ComptaPrefTreeNode() {
public ComptaPrefTreeNode(final ModuleManager moduleManager) {
super(" Préférences");
 
// Globale
120,6 → 121,10
nsGlobale.add(new PrefTreeNode(GestionCommercialeGlobalPreferencePanel.class, "Gestion des piéces commericales", new String[] { "transfert", "numéro" }));
nsGlobale.add(new PrefTreeNode(MailRelancePreferencePanel.class, "Email de relance", new String[] { "relance", "mail" }));
 
// PayPal
final PrefTreeNode nPayPall = new PrefTreeNode(PayPalPreferencePanel.class, "PayPal", new String[] { "paypal", "facture" });
nsGlobale.add(nPayPall);
 
// Impression
final PrefTreeNode nPrint = new PrefTreeNode(EmptyPreferencePanel.class, "Impression", new String[] { "Impressions" });
final PrefTreeNode nPrintGestComm = new PrefTreeNode(ImpressionGestCommPreferencePanel.class, "Gestion commerciale", new String[] { "impression" });
157,9 → 162,10
final PrefTreeNode nMail = new PrefTreeNode(EmailNode.class, "EMail", new String[] { "email", "mail", "courriel" });
nsPoste.add(nMail);
 
 
// add preferences for modules
for (final AbstractModule module : ModuleManager.getInstance().getRunningModules().values()) {
for (final Entry<Boolean, List<ModulePreferencePanelDesc>> e : module.getPrefDescriptorsByLocation().entrySet()) {
for (final AbstractModule module : moduleManager.getRunningModules().values()) {
for (final Entry<Boolean, List<ModulePreferencePanelDesc>> e : module.getPrefDescriptorsByLocation(moduleManager.getRoot()).entrySet()) {
final DefaultMutableTreeNode node = e.getKey() ? nsPoste : nsGlobale;
final List<ModulePreferencePanelDesc> descs = e.getValue();
if (descs.size() > 1) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/GestionPlanComptableEFrame.java
152,7 → 152,7
eltComptePCE.archive(id);
} catch (SQLException e) {
e.printStackTrace();
ExceptionHandler.handle("Erreur lors de la suppression du compte.");
ExceptionHandler.handle("Erreur lors de la suppression du compte.", e);
}
System.out.println("Compte Supprimé");
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SuppressionEcrituresPanel.java
22,7 → 22,6
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.warning.JLabelWarning;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
60,7 → 59,7
// 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"));
JOptionPane.showMessageDialog(null, "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 : (");
115,19 → 114,19
SQLBase b = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
SQLTable tableMvt = b.getTable("MOUVEMENT");
 
SQLSelect sel = new SQLSelect(b);
SQLSelect sel = new SQLSelect();
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) {
if (!l.isEmpty()) {
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());
idS[i] = ((Number) tmp[0]).intValue();
}
 
return idS;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/CurrencyConverter.java
22,6 → 22,8
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.Tuple3;
 
import java.math.BigDecimal;
import java.util.ArrayList;
28,13 → 30,15
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
 
public class CurrencyConverter {
private String companyCurrencyCode;
private final DBRoot root;
 
private boolean useCache = false;
private String baseCurrencyCode;
 
public CurrencyConverter(DBRoot rootSociete, String companyCurrencyCode, String baseCurrencyCode) {
59,6 → 63,10
return baseCurrencyCode;
}
 
public void setUseCache(boolean useCache) {
this.useCache = useCache;
}
 
/**
* Converter an amount to an other currency
*/
73,6 → 81,14
return convert(amount, from, to, date, false);
}
 
Map<Tuple3<String, String, Date>, Tuple2<BigDecimal, BigDecimal>> cacheBiased = new HashMap<Tuple3<String, String, Date>, Tuple2<BigDecimal, BigDecimal>>();
Map<Tuple3<String, String, Date>, Tuple2<BigDecimal, BigDecimal>> cacheNotBiased = new HashMap<Tuple3<String, String, Date>, Tuple2<BigDecimal, BigDecimal>>();
 
public void clearCache() {
cacheBiased.clear();
cacheNotBiased.clear();
}
 
/**
* Converter an amount to an other currency at a precise date
*/
82,69 → 98,96
return amount;
}
 
// Clean date
final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.setTimeInMillis(date.getTime());
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
final Date d = c.getTime();
if (amount.signum() == 0) {
return BigDecimal.ZERO;
}
 
// Get conversion info
final List<SQLRow> rowsFrom = getRates(from, d);
final List<SQLRow> rowsTo = getRates(to, d);
BigDecimal r1 = null;
BigDecimal r2 = null;
 
// Récupération des taux par défaut dans DEVISE si aucun taux dans l'historique
List<SQLRow> rowsDevise = new ArrayList<SQLRow>();
if (rowsTo.isEmpty() || rowsFrom.isEmpty()) {
SQLSelect sel = new SQLSelect();
sel.addSelectStar(root.findTable("DEVISE"));
rowsDevise.addAll(SQLRowListRSH.execute(sel));
if (useCache) {
Tuple3<String, String, Date> key = Tuple3.create(from, to, date);
if (useBiased && cacheBiased.containsKey(key)) {
Tuple2<BigDecimal, BigDecimal> value = cacheBiased.get(key);
r1 = value.get0();
r2 = value.get1();
} else if (!useBiased && cacheNotBiased.containsKey(key)) {
Tuple2<BigDecimal, BigDecimal> value = cacheNotBiased.get(key);
r1 = value.get0();
r2 = value.get1();
}
}
 
if (rowsTo.isEmpty()) {
for (SQLRow sqlRow : rowsDevise) {
if (sqlRow.getString("CODE").equalsIgnoreCase(to)) {
r2 = (useBiased ? sqlRow.getBigDecimal("TAUX_COMMERCIAL") : sqlRow.getBigDecimal("TAUX"));
if (r1 == null || r2 == null) {
// Clean date
final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.setTimeInMillis(date.getTime());
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
final Date d = c.getTime();
 
// Get conversion info
final List<SQLRow> rowsFrom = getRates(from, d);
final List<SQLRow> rowsTo = getRates(to, d);
 
List<SQLRow> rows = new ArrayList<SQLRow>();
rows.addAll(rowsTo);
rows.addAll(rowsFrom);
// Pour le taux réel, on récupére celui de la veille
for (SQLRow sqlRow : rows) {
if (sqlRow.getString("DST").equals(from)) {
if (useBiased) {
if (r1 == null) {
r1 = sqlRow.getBigDecimal("TAUX_COMMERCIAL");
}
} else {
r1 = sqlRow.getBigDecimal("TAUX");
}
}
}
}
if (rowsFrom.isEmpty()) {
for (SQLRow sqlRow : rowsDevise) {
if (sqlRow.getString("CODE").equalsIgnoreCase(from)) {
r1 = (useBiased ? sqlRow.getBigDecimal("TAUX_COMMERCIAL") : sqlRow.getBigDecimal("TAUX"));
if (sqlRow.getString("DST").equals(to)) {
if (useBiased) {
if (r2 == null) {
r2 = sqlRow.getBigDecimal("TAUX_COMMERCIAL");
}
} else {
r2 = sqlRow.getBigDecimal("TAUX");
}
}
}
}
if (from.equals(this.baseCurrencyCode)) {
r1 = BigDecimal.ONE;
}
if (to.equals(this.baseCurrencyCode)) {
r2 = BigDecimal.ONE;
}
 
List<SQLRow> rows = new ArrayList<SQLRow>();
rows.addAll(rowsTo);
rows.addAll(rowsFrom);
for (SQLRow sqlRow : rows) {
if (sqlRow.getString("DST").equals(from)) {
if (useBiased) {
r1 = sqlRow.getBigDecimal("TAUX_COMMERCIAL");
} else {
r1 = sqlRow.getBigDecimal("TAUX");
if (r1 == null || r2 == null) {
// Récupération des taux par défaut dans DEVISE si aucun taux dans l'historique
List<SQLRow> rowsDevise = new ArrayList<SQLRow>();
if (rowsTo.isEmpty() || rowsFrom.isEmpty()) {
SQLSelect sel = new SQLSelect();
sel.addSelectStar(root.findTable("DEVISE"));
rowsDevise.addAll(SQLRowListRSH.execute(sel));
}
}
if (sqlRow.getString("DST").equals(to)) {
if (useBiased) {
r2 = sqlRow.getBigDecimal("TAUX_COMMERCIAL");
} else {
r2 = sqlRow.getBigDecimal("TAUX");
if (r2 == null) {
for (SQLRow sqlRow : rowsDevise) {
if (sqlRow.getString("CODE").equalsIgnoreCase(to)) {
r2 = (useBiased ? sqlRow.getBigDecimal("TAUX_COMMERCIAL") : sqlRow.getBigDecimal("TAUX"));
}
}
}
if (r1 == null) {
for (SQLRow sqlRow : rowsDevise) {
if (sqlRow.getString("CODE").equalsIgnoreCase(from)) {
r1 = (useBiased ? sqlRow.getBigDecimal("TAUX_COMMERCIAL") : sqlRow.getBigDecimal("TAUX"));
}
}
}
}
 
}
if (from.equals(this.baseCurrencyCode)) {
r1 = BigDecimal.ONE;
}
if (to.equals(this.baseCurrencyCode)) {
r2 = BigDecimal.ONE;
}
if (r1 == null) {
throw new IllegalStateException("No conversion rate for " + from);
}
151,6 → 194,15
if (r2 == null) {
throw new IllegalStateException("No conversion rate for " + to);
}
if (useCache) {
Tuple3<String, String, Date> key = Tuple3.create(from, to, date);
 
if (useBiased) {
cacheBiased.put(key, Tuple2.create(r1, r2));
} else {
cacheNotBiased.put(key, Tuple2.create(r1, r2));
}
}
final BigDecimal result = amount.multiply(r2, DecimalUtils.HIGH_PRECISION).divide(r1, DecimalUtils.HIGH_PRECISION);
return result;
}
164,6 → 216,7
w = w.and(new Where(t.getField("DATE"), "<=", d));
select.setWhere(w);
select.addFieldOrder(t.getField("DATE"), Order.desc());
// Limit pour récupérer le taux de la veille
select.setLimit(2);
final List<SQLRow> rows = SQLRowListRSH.execute(select);
return rows;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/PointageModel.java
14,13 → 14,18
package org.openconcerto.erp.core.finance.accounting.model;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.finance.accounting.ui.PointagePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.ITableModel;
 
import java.util.Date;
import java.util.List;
 
import javax.swing.SwingWorker;
32,32 → 37,35
 
private String[] titresCol;
private String[] titresRow;
private PointagePanel panel;
private long debitListe, creditListe, debitTotal, creditTotal, debitPointe, creditPointe, debitNonPointe, creditNonPointe, creditSelection, debitSelection;
 
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) {
 
public PointageModel(int idCpt, PointagePanel panel) {
this.creditNonPointe = 0;
this.creditTotal = 0;
this.creditPointe = 0;
this.creditSelection = 0;
 
this.panel = panel;
 
this.debitNonPointe = 0;
this.debitPointe = 0;
this.debitTotal = 0;
this.debitSelection = 0;
 
this.idCpt = idCpt;
this.titresCol = new String[6];
this.titresCol[0] = "Totaux";
this.titresCol[0] = "Totaux période";
this.titresCol[1] = "Pointé";
this.titresCol[2] = "Non Pointé";
this.titresCol[2] = "Relevé courant";
this.titresCol[3] = "Total";
 
this.titresCol[4] = "Sélection";
this.titresCol[5] = "Pointéé + sélection";
this.titresCol[5] = "Liste";
 
this.titresRow = new String[3];
this.titresRow[0] = "Débit";
74,7 → 82,6
}
 
public void updateSelection(int[] rowIndex) {
System.err.println("Update Selection");
this.creditSelection = 0;
this.debitSelection = 0;
 
101,18 → 108,34
this.fireTableDataChanged();
}
 
private SwingWorker<String, Object> workerUpdater;
 
public void updateTotauxCompte() {
final Date deb = panel.getDateDeb();
final Date fin = panel.getDateFin();
 
new SwingWorker<String, Object>() {
if (workerUpdater != null) {
workerUpdater.cancel(true);
}
 
workerUpdater = new SwingWorker<String, Object>() {
 
@Override
protected String doInBackground() throws Exception {
 
SQLSelect sel = new SQLSelect(base);
SQLSelect sel = new SQLSelect();
sel.addSelect(tableEcr.getField("CREDIT"), "SUM");
sel.addSelect(tableEcr.getField("DEBIT"), "SUM");
 
Where w = new Where(tableEcr.getField("ID_COMPTE_PCE"), "=", PointageModel.this.idCpt);
 
if (deb != null && fin != null) {
w = w.and(new Where(tableEcr.getField("DATE"), deb, fin));
} else if (deb != null) {
w = w.and(new Where(tableEcr.getField("DATE"), ">=", deb));
} else if (fin != null) {
w = w.and(new Where(tableEcr.getField("DATE"), "<=", fin));
}
sel.setWhere(w.and(new Where(tableEcr.getField("POINTEE"), "!=", "")));
 
String reqPointee = sel.toString();
123,7 → 146,7
 
PointageModel.this.creditPointe = 0;
PointageModel.this.debitPointe = 0;
if (myListPointee.size() != 0) {
if (!myListPointee.isEmpty()) {
 
for (int i = 0; i < myListPointee.size(); i++) {
Object[] objTmp = (Object[]) myListPointee.get(i);
137,19 → 160,19
}
}
 
sel.setWhere(w.and(new Where(tableEcr.getField("POINTEE"), "=", "")));
String reqNotPointee = sel.toString();
sel.setWhere(w.and(new Where(tableEcr.getField("POINTEE"), "=", panel.getCodePointage())));
String reqReleveCourant = sel.toString();
 
Object obNotPointee = base.getDataSource().execute(reqNotPointee, new ArrayListHandler());
Object obReleveCourant = base.getDataSource().execute(reqReleveCourant, new ArrayListHandler());
 
List myListNotPointee = (List) obNotPointee;
List myListReleveCourant = (List) obReleveCourant;
 
PointageModel.this.creditNonPointe = 0;
PointageModel.this.debitNonPointe = 0;
if (myListNotPointee.size() != 0) {
if (!myListReleveCourant.isEmpty()) {
 
for (int i = 0; i < myListNotPointee.size(); i++) {
Object[] objTmp = (Object[]) myListNotPointee.get(i);
for (int i = 0; i < myListReleveCourant.size(); i++) {
Object[] objTmp = (Object[]) myListReleveCourant.get(i);
 
if (objTmp[0] != null) {
PointageModel.this.creditNonPointe += ((Number) objTmp[0]).longValue();
161,6 → 184,45
}
}
 
sel.setWhere(w);
String reqReleveTotal = sel.toString();
 
Object obReleveTotal = base.getDataSource().execute(reqReleveTotal, new ArrayListHandler());
 
List myListReleveTotal = (List) obReleveTotal;
 
PointageModel.this.creditTotal = 0;
PointageModel.this.debitTotal = 0;
if (!myListReleveTotal.isEmpty()) {
 
for (int i = 0; i < myListReleveTotal.size(); i++) {
Object[] objTmp = (Object[]) myListReleveTotal.get(i);
 
if (objTmp[0] != null) {
PointageModel.this.creditTotal += ((Number) objTmp[0]).longValue();
}
 
if (objTmp[1] != null) {
PointageModel.this.debitTotal += ((Number) objTmp[1]).longValue();
}
}
}
 
PointageModel.this.creditListe = 0;
PointageModel.this.debitListe = 0;
IListe listeEcr = panel.getEcriturePanel().getListe();
for (int i = 0; i < listeEcr.getRowCount(); i++) {
 
final SQLRowValues rowAt = ITableModel.getLine(listeEcr.getModel(), i).getRow();
if (rowAt.getObject("CREDIT") != null) {
PointageModel.this.creditListe += rowAt.getLong("CREDIT");
}
 
if (rowAt.getObject("DEBIT") != null) {
PointageModel.this.debitListe += rowAt.getLong("DEBIT");
}
}
 
return null;
}
 
167,12 → 229,17
@Override
protected void done() {
 
if (isCancelled()) {
return;
}
PointageModel.this.fireTableDataChanged();
}
}.execute();
};
workerUpdater.execute();
 
}
 
@Override
public String getColumnName(int column) {
 
return this.titresCol[column];
205,61 → 272,61
 
if (columnIndex == 1) {
if (rowIndex == 0) {
return new Long(this.debitPointe);
return Long.valueOf(this.debitPointe);
}
if (rowIndex == 1) {
return new Long(this.creditPointe);
return Long.valueOf(this.creditPointe);
}
if (rowIndex == 2) {
return new Long(this.debitPointe - this.creditPointe);
return Long.valueOf(this.debitPointe - this.creditPointe);
}
}
 
if (columnIndex == 2) {
if (rowIndex == 0) {
return new Long(this.debitNonPointe);
return Long.valueOf(this.debitNonPointe);
}
if (rowIndex == 1) {
return new Long(this.creditNonPointe);
return Long.valueOf(this.creditNonPointe);
}
if (rowIndex == 2) {
return new Long(this.debitNonPointe - this.creditNonPointe);
return Long.valueOf(this.debitNonPointe - this.creditNonPointe);
}
}
 
if (columnIndex == 3) {
if (rowIndex == 0) {
return new Long(this.debitNonPointe + this.debitPointe);
return Long.valueOf(this.debitTotal);
}
if (rowIndex == 1) {
return new Long(this.creditNonPointe + this.creditPointe);
return Long.valueOf(this.creditTotal);
}
if (rowIndex == 2) {
return new Long((this.debitNonPointe - this.creditNonPointe) + (this.debitPointe - this.creditPointe));
return Long.valueOf(this.debitTotal - this.creditTotal);
}
}
 
if (columnIndex == 4) {
if (rowIndex == 0) {
return new Long(this.debitSelection);
return Long.valueOf(this.debitSelection);
}
if (rowIndex == 1) {
return new Long(this.creditSelection);
return Long.valueOf(this.creditSelection);
}
if (rowIndex == 2) {
return new Long(this.debitSelection - this.creditSelection);
return Long.valueOf(this.debitSelection - this.creditSelection);
}
}
 
if (columnIndex == 5) {
if (rowIndex == 0) {
return new Long(this.debitSelection + this.debitPointe);
return Long.valueOf(this.debitListe);
}
if (rowIndex == 1) {
return new Long(this.creditSelection + this.creditPointe);
return Long.valueOf(this.creditListe);
}
if (rowIndex == 2) {
return new Long(this.debitSelection - this.creditSelection + this.debitPointe - this.creditPointe);
return Long.valueOf(this.debitListe - this.creditListe);
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/SommeCompte.java
16,11 → 16,13
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
32,6 → 34,10
 
private SQLRow rowAnalytique = null;
 
private boolean removeClotureCompte = false;
 
private List<String> compteUsed = new ArrayList<String>();
 
public SommeCompte() {
this(null);
}
40,6 → 46,10
this.rowAnalytique = rowAnalytique;
}
 
public void setRemoveClotureCompte(boolean removeClotureCompte) {
this.removeClotureCompte = removeClotureCompte;
}
 
SQLTable ecritureTable = base.getTable("ECRITURE");
SQLTable compteTable = base.getTable("COMPTE_PCE");
 
61,10 → 71,12
* @return le solde debiteur
**********************************************************************************************/
public long sommeCompteFils(String numero, Date dateDebut, Date dateFin) {
 
this.compteUsed.add(numero.trim() + "%");
long sommeDebit = 0;
long sommeCredit = 0;
 
SQLSelect sel = new SQLSelect(base);
SQLSelect sel = new SQLSelect();
 
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
76,11 → 88,17
sel.addJoin("LEFT", ecritureTable.getField("ID_COMPTE_PCE"));
Where w2 = new Where(compteTable.getField("NUMERO"), "LIKE", numero.trim() + "%");
Where w3 = new Where(ecritureTable.getField("DATE"), dateDebut, dateFin);
sel.setWhere(w2.and(w3));
if (this.removeClotureCompte) {
Where w4 = new Where(ecritureTable.getField("NOM"), "NOT LIKE", "Fermeture du compte %");
sel.setWhere(w2.and(w3).and(w4));
} else {
sel.setWhere(w2.and(w3));
}
addAnalytiqueJoin(sel);
 
// String req = sel.asString() +
// " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
// " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY
// \"COMPTE_PCE\".\"NUMERO\"";
String req = sel.asString();
// System.out.println(req);
 
122,7 → 140,7
 
SQLTable ecritureTable = base.getTable("ECRITURE");
SQLTable compteTable = base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(base);
SQLSelect sel = new SQLSelect();
 
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
133,6 → 151,7
// compteTable.getField("ID"));
sel.addJoin("LEFT", ecritureTable.getField("ID_COMPTE_PCE"));
Where w2 = new Where(compteTable.getField("NUMERO"), "LIKE", String.valueOf(numeroStart) + "%");
this.compteUsed.add(String.valueOf(numeroStart) + "%");
Where w4 = new Where(ecritureTable.getField("DATE"), dateDebut, dateFin);
 
for (int i = numeroStart + 1; i < numeroEnd + 1; i++) {
139,17 → 158,25
Where w3;
if ((i == numeroEnd) && (!includeAllEnd)) {
w3 = new Where(compteTable.getField("NUMERO"), "=", String.valueOf(i));
this.compteUsed.add(String.valueOf(i));
} else {
w3 = new Where(compteTable.getField("NUMERO"), "LIKE", String.valueOf(i) + "%");
this.compteUsed.add(String.valueOf(i) + "%");
}
w2 = w2.or(w3);
}
if (this.removeClotureCompte) {
 
sel.setWhere(w2.and(w4));
Where w5 = new Where(ecritureTable.getField("NOM"), "NOT LIKE", "Fermeture du compte %");
sel.setWhere(w2.and(w4).and(w5));
} else {
sel.setWhere(w2.and(w4));
}
addAnalytiqueJoin(sel);
 
// String req = sel.asString() +
// " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
// " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY
// \"COMPTE_PCE\".\"NUMERO\"";
String req = sel.asString();
 
Object ob = base.getDataSource().execute(req, new ArrayListHandler());
177,7 → 204,7
 
SQLTable ecritureTable = base.getTable("ECRITURE");
SQLTable compteTable = base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(base);
SQLSelect sel = new SQLSelect();
 
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
190,6 → 217,7
// compteTable.getField("ID"));
 
Where w2 = new Where(sel.getAlias(compteTable).getField("NUMERO"), "LIKE", String.valueOf(numeroStart) + "%");
this.compteUsed.add(String.valueOf(numeroStart) + "%");
Where w4 = new Where(ecritureTable.getField("DATE"), dateDebut, dateFin);
 
for (int i = numeroStart + 1; i < numeroEnd + 1; i++) {
196,13 → 224,22
Where w3;
if ((i == numeroEnd) && (!includeAllEnd)) {
w3 = new Where(sel.getAlias(compteTable).getField("NUMERO"), "=", String.valueOf(i));
this.compteUsed.add(String.valueOf(i));
} else {
w3 = new Where(sel.getAlias(compteTable).getField("NUMERO"), "LIKE", String.valueOf(i) + "%");
this.compteUsed.add(String.valueOf(i) + "%");
}
w2 = w2.or(w3);
}
 
sel.setWhere(w2.and(w4));
if (this.removeClotureCompte) {
 
Where w5 = new Where(ecritureTable.getField("NOM"), "NOT LIKE", "Fermeture du compte %");
 
sel.setWhere(w2.and(w4).and(w5));
} else {
sel.setWhere(w2.and(w4));
}
addAnalytiqueJoin(sel);
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
 
233,7 → 270,7
 
SQLTable ecritureTable = base.getTable("ECRITURE");
SQLTable compteTable = base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(base);
SQLSelect sel = new SQLSelect();
 
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
245,6 → 282,7
// compteTable.getField("ID"));
 
Where w2 = new Where(sel.getAlias(compteTable).getField("NUMERO"), "LIKE", String.valueOf(numeroStart) + "%");
this.compteUsed.add(String.valueOf(numeroStart) + "%");
Where w4 = new Where(ecritureTable.getField("DATE"), dateDebut, dateFin);
 
for (int i = numeroStart + 1; i < numeroEnd + 1; i++) {
251,13 → 289,20
Where w3;
if ((i == numeroEnd) && (!includeAllEnd)) {
w3 = new Where(sel.getAlias(compteTable).getField("NUMERO"), "=", String.valueOf(i));
this.compteUsed.add(String.valueOf(i));
} else {
w3 = new Where(sel.getAlias(compteTable).getField("NUMERO"), "LIKE", String.valueOf(i) + "%");
this.compteUsed.add(String.valueOf(i) + "%");
}
w2 = w2.or(w3);
}
if (this.removeClotureCompte) {
Where w5 = new Where(ecritureTable.getField("NOM"), "NOT LIKE", "Fermeture du compte %");
 
sel.setWhere(w2.and(w4));
sel.setWhere(w2.and(w4).and(w5));
} else {
sel.setWhere(w2.and(w4));
}
addAnalytiqueJoin(sel);
String req = sel.asString();
 
303,7 → 348,15
 
Where w = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getField("ID"));
Where w2 = new Where(compteTable.getField("NUMERO"), "=", numero.trim());
sel.setWhere(w.and(w2));
this.compteUsed.add(numero.trim());
 
if (this.removeClotureCompte) {
Where w5 = new Where(ecritureTable.getField("NOM"), "NOT LIKE", "Fermeture du compte %");
 
sel.setWhere(w.and(w2).and(w5));
} else {
sel.setWhere(w.and(w2));
}
addAnalytiqueJoin(sel);
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
// System.out.println(req);
322,4 → 375,33
 
return sommeDebit - sommeCredit;
}
 
public void clearUsedCompte() {
this.compteUsed.clear();
}
 
public void getNonUsedCompte(Where where, Date dateDebut, Date dateFin) {
 
SQLSelect sel = new SQLSelect();
final SQLTable table = base.getTable("COMPTE_PCE");
final SQLTable tableEcr = base.getTable("ECRITURE");
final SQLField field = table.getField("NUMERO");
sel.addSelect(field);
 
for (String cpt : this.compteUsed) {
where = where.and(new Where(field, "NOT LIKE", cpt));
}
 
Where w2 = new Where(tableEcr.getField("ID_COMPTE_PCE"), "=", table.getKey());
w2 = w2.and(new Where(tableEcr.getField("DATE"), dateDebut, dateFin));
where = where.and(w2);
sel.setWhere(where);
sel.addGroupBy(field);
List<String> s = tableEcr.getBase().getDataSource().executeCol(sel.asString());
System.err.println("COMPTE NOT USED");
for (String string : s) {
System.err.println("Compte " + s);
}
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/component/DeviseHistoriqueSQLComponent.java
13,9 → 13,27
package org.openconcerto.erp.core.finance.accounting.component;
 
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLSelectJoin;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.cc.ITransformer;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
 
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
 
public class DeviseHistoriqueSQLComponent extends GroupSQLComponent {
 
public static final String ID = "accounting.currencyrate.history";
24,4 → 42,125
super(element);
}
 
@Override
public int insert(SQLRow order) {
int id = super.insert(order);
SQLRow row = getTable().getRow(id);
updateProduct(row);
return id;
}
 
@Override
public void update() {
super.update();
SQLRow row = getTable().getRow(getSelectedID());
updateProduct(row);
}
 
@Override
protected SQLRowValues createDefaults() {
CurrencyConverter c = new CurrencyConverter();
String companyCode = c.getCompanyCurrencyCode();
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("SRC", companyCode);
return rowVals;
}
 
private void updateProduct(SQLRow rowDeviseH) {
CurrencyConverter c = new CurrencyConverter();
String companyCode = c.getCompanyCurrencyCode();
final String srcCode = rowDeviseH.getString("SRC");
if (srcCode.equalsIgnoreCase(companyCode)) {
int ans = JOptionPane.showConfirmDialog(null, "Voulez vous actualiser les prix d'achats?", "Actualisation tarif", JOptionPane.YES_NO_OPTION);
 
if (ans == JOptionPane.YES_OPTION) {
SwingWorker<Object, Object> w = new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
final String codeDevise = rowDeviseH.getString("DST");
SQLRowValues rowValsARt = new SQLRowValues(getTable().getTable("ARTICLE"));
rowValsARt.putNulls("PA_HT", "PA_DEVISE");
rowValsARt.putRowValues("ID_DEVISE_HA").putNulls("CODE");
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsARt);
fetcher.addSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
SQLSelectJoin join = input.getJoin(getTable().getTable("ARTICLE").getField("ID_DEVISE_HA"));
input.setWhere(new Where(join.getJoinedTable().getField("CODE"), "=", codeDevise));
return input;
}
}, 0);
 
List<SQLRowValues> result = fetcher.fetch();
final Date date = new Date();
for (SQLRowValues sqRowValues : result) {
 
BigDecimal haDevise = sqRowValues.getBigDecimal("PA_DEVISE");
if (haDevise == null) {
haDevise = BigDecimal.ZERO;
}
 
final BigDecimal convert = c.convert(haDevise, codeDevise, companyCode, date, true).setScale(sqRowValues.getTable().getField("PA_DEVISE").getType().getDecimalDigits(),
RoundingMode.HALF_UP);
try {
sqRowValues.createEmptyUpdateRow().put("PA_HT", convert).put("PRIX_METRIQUE_HA_1", convert).commit();
} catch (SQLException e) {
e.printStackTrace();
}
 
}
 
// ARTICLE_FOURNISSEUR
SQLRowValues rowValsARtFour = new SQLRowValues(getTable().getTable("ARTICLE_FOURNISSEUR"));
rowValsARtFour.putNulls("PA_HT", "PA_DEVISE");
rowValsARtFour.putRowValues("ID_DEVISE_HA").putNulls("CODE");
SQLRowValuesListFetcher fetcherFourni = SQLRowValuesListFetcher.create(rowValsARtFour);
fetcherFourni.addSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
SQLSelectJoin join = input.getJoin(getTable().getTable("ARTICLE_FOURNISSEUR").getField("ID_DEVISE_HA"));
input.setWhere(new Where(join.getJoinedTable().getField("CODE"), "=", codeDevise));
return input;
}
}, 0);
 
List<SQLRowValues> resultFournisseur = fetcherFourni.fetch();
 
for (SQLRowValues sqRowValues : resultFournisseur) {
 
BigDecimal haDevise = sqRowValues.getBigDecimal("PA_DEVISE");
if (haDevise == null) {
haDevise = BigDecimal.ZERO;
}
 
final BigDecimal convert = c.convert(haDevise, codeDevise, companyCode, date, true).setScale(sqRowValues.getTable().getField("PA_DEVISE").getType().getDecimalDigits(),
RoundingMode.HALF_UP);
try {
sqRowValues.createEmptyUpdateRow().put("PA_HT", convert).put("PRIX_METRIQUE_HA_1", convert).commit();
} catch (SQLException e) {
e.printStackTrace();
}
 
}
return null;
}
 
@Override
protected void done() {
try {
get();
JOptionPane.showMessageDialog(null, "Mise à jour des tarifs terminées", "Mise à jour tarifs", JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
ExceptionHandler.handle("Erreur lors de la mise à jour des tarifs!", e);
}
}
};
w.run();
}
}
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/action/ResultatAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/model/TaxeCache.java
18,12 → 18,13
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.ExceptionHandler;
 
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
33,34 → 34,47
 
public final class TaxeCache {
 
static private final SQLSelect getSel() {
// FIXME récupérer les comptes de TVA pour eviter les fetchs
private static final SQLRowValuesListFetcher getSel() {
final DBRoot root = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete();
final SQLTable table = root.getTable("TAXE");
final SQLSelect sel = new SQLSelect();
sel.addSelectStar(table);
return sel;
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.putNulls("TAUX", "CODE", "NOM", "ID_TAXE", "DEFAULT");
List<String> compteFields = Arrays.asList("ID_COMPTE_PCE_COLLECTE", "ID_COMPTE_PCE_DED", "ID_COMPTE_PCE", "ID_COMPTE_PCE_VENTE", "ID_COMPTE_PCE_VENTE_SERVICE", "ID_COMPTE_PCE_COLLECTE_INTRA",
"ID_COMPTE_PCE_DED_INTRA");
for (String foreignFieldName : compteFields) {
rowVals.putRowValues(foreignFieldName).putNulls("NUMERO", "NOM");
}
return SQLRowValuesListFetcher.create(rowVals);
}
 
private transient final Map<Integer, Float> mapTaux = new HashMap<Integer, Float>();
private transient final Map<SQLRowAccessor, Float> mapRowTaux = new LinkedHashMap<SQLRowAccessor, Float>();
private final Map<Integer, Float> mapTaux = new HashMap<>();
private final Map<SQLRowAccessor, Float> mapRowTaux = new LinkedHashMap<>();
private static TaxeCache instance;
private transient SQLRow firstIdTaxe = null;
private SQLRow firstIdTaxe = null;
 
private TaxeCache() {
final SQLSelect sel = getSel();
loadCache();
}
 
final List<SQLRow> l = SQLRowListRSH.execute(sel);
for (SQLRow sqlRow : l) {
private void loadCache() {
 
this.mapRowTaux.clear();
this.mapTaux.clear();
this.firstIdTaxe = null;
 
final SQLRowValuesListFetcher sel = getSel();
 
final List<SQLRowValues> l = sel.fetch();
for (SQLRowValues sqlRow : l) {
this.mapRowTaux.put(sqlRow, sqlRow.getFloat("TAUX"));
this.mapTaux.put(sqlRow.getID(), sqlRow.getFloat("TAUX"));
if (sqlRow.getBoolean("DEFAULT")) {
this.firstIdTaxe = sqlRow;
this.firstIdTaxe = sqlRow.asRow();
}
}
}
 
synchronized public static TaxeCache getCache() {
public static synchronized TaxeCache getCache() {
if (instance == null) {
instance = new TaxeCache();
}
67,11 → 81,16
return instance;
}
 
public Float getTauxFromId(final int idTaux) {
return this.mapTaux.get(Integer.valueOf(idTaux));
public synchronized Float getTauxFromId(final int idTaux) {
Float f = this.mapTaux.get(Integer.valueOf(idTaux));
if (f == null) {
loadCache();
f = this.mapTaux.get(Integer.valueOf(idTaux));
}
return f;
}
 
public SQLRowAccessor getRowFromId(final int idTaux) {
public synchronized SQLRowAccessor getRowFromId(final int idTaux) {
Set<SQLRowAccessor> s = mapRowTaux.keySet();
for (SQLRowAccessor r : s) {
if (r.getID() == idTaux) {
78,18 → 97,23
return r;
}
}
loadCache();
for (SQLRowAccessor r : s) {
if (r.getID() == idTaux) {
return r;
}
}
return null;
 
}
 
public SQLRow getFirstTaxe() {
public synchronized SQLRow getFirstTaxe() {
if (this.firstIdTaxe == null) {
final SQLSelect sel = getSel();
sel.setWhere(new Where(sel.getTable("TAXE").getField("DEFAULT"), "=", Boolean.TRUE));
final List<SQLRow> rows = SQLRowListRSH.execute(sel);
final SQLRowValuesListFetcher sel = getSel();
final List<SQLRowValues> rows = sel.fetch(new Where(sel.getReq().getTable("TAXE").getField("DEFAULT"), "=", Boolean.TRUE));
if (rows != null && !rows.isEmpty()) {
 
this.firstIdTaxe = rows.get(0);
this.firstIdTaxe = rows.get(0).asRow();
} else {
ExceptionHandler.handle("Aucune TVA par défaut définie!", new IllegalArgumentException("Aucune TVA par défaut définie!"));
return mapRowTaux.keySet().iterator().next().asRow();
99,17 → 123,23
return this.firstIdTaxe;
}
 
public Integer getIdFromTaux(Float tax) {
Set<Integer> s = (Set<Integer>) mapTaux.keySet();
public synchronized Integer getIdFromTaux(Float tax) {
Set<Integer> s = mapTaux.keySet();
for (Integer integer : s) {
if (this.mapTaux.get(integer).equals(tax)) {
return integer;
}
}
loadCache();
for (Integer integer : s) {
if (this.mapTaux.get(integer).equals(tax)) {
return integer;
}
}
return null;
}
 
public Set<SQLRowAccessor> getAllTaxe() {
public synchronized Set<SQLRowAccessor> getAllTaxe() {
return Collections.unmodifiableSet(this.mapRowTaux.keySet());
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/EcoTaxeSQLElement.java
15,7 → 15,7
 
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
27,7 → 27,7
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class EcoTaxeSQLElement extends ConfSQLElement {
public class EcoTaxeSQLElement extends ComptaSQLConfElement {
 
public EcoTaxeSQLElement() {
super("ECOTAXE", "une écotaxe", "écotaxes");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/TaxeSQLElement.java
186,6 → 186,8
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
c.weightx = 0;
this.add(labelCompteColIntra, c);
c.gridx++;
c.weightx = 1;
226,4 → 228,8
};
}
 
@Override
protected String createCode() {
return "finance.tax";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/DepotChequeElementSQLElement.java
New file
0,0 → 1,81
/*
* 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.payment.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.SQLRow;
 
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
public class DepotChequeElementSQLElement extends ComptaSQLConfElement {
 
public DepotChequeElementSQLElement() {
super("DEPOT_CHEQUE_ELEMENT", "un chéque déposé", "chèques déposés");
}
 
@Override
protected String getParentFFName() {
return "ID_DEPOT_CHEQUE";
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("MONTANT");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("MONTANT");
return l;
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
@Override
public SQLComponent createComponent() {
return new UISQLComponent(this) {
public void addViews() {
this.addView("DATE");
}
};
}
 
@Override
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
for (SQLRow row : trees.getRows()) {
if (row.getObject("ID_CHEQUE_A_ENCAISSER") != null && !row.isForeignEmpty("ID_CHEQUE_A_ENCAISSER")) {
row.getForeign("ID_CHEQUE_A_ENCAISSER").createEmptyUpdateRow().put("ENCAISSE", Boolean.FALSE).commit();
}
}
super.archive(trees, cutLinks);
}
 
@Override
protected String createCode() {
return createCodeOfPackage() + ".depot.item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ReglerMontantSQLElement.java
47,6 → 47,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".regulation";
return createCodeOfPackage() + ".regulation";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/SEPAMandateSQLElement.java
113,7 → 113,7
// TODO rename createCodeFromPackage() to createCodeOfPackage() and change createCode()
// implementation to use a new createCodeFromPackage() which uses the class name (w/o
// SQLElement suffix)
return this.createCodeFromPackage() + ".SEPAMandate";
return this.createCodeOfPackage() + ".SEPAMandate";
}
 
public final SQLRowValues createRecurrent(final Number idClient, final String mandateIdent, final Date dateOfSignature) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/TypeReglementSQLElement.java
42,7 → 42,7
public static final int PRELEVEMENT = 10;
 
public TypeReglementSQLElement() {
super("TYPE_REGLEMENT", "Type de règlement", "Type de règlement");
super("TYPE_REGLEMENT", "un type de règlement", "types de règlement");
}
 
protected List<String> getListFields() {
114,6 → 114,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".type";
return createCodeOfPackage() + ".type";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/EncaisserMontantElementSQLElement.java
59,6 → 59,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".item";
return createCodeOfPackage() + ".item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ReglerMontantElementSQLElement.java
59,6 → 59,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + "supplier.item";
return createCodeOfPackage() + "supplier.item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ModeDeReglementSQLElement.java
120,6 → 120,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".mode";
return createCodeOfPackage() + ".mode";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/DepotChequeSQLElement.java
New file
0,0 → 1,90
/*
* 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.payment.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.finance.payment.component.DepotChequeSQLComponent;
import org.openconcerto.erp.generationDoc.gestcomm.DepotChequeXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElementLinksSetup;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.element.SQLElementLink.LinkType;
import org.openconcerto.sql.model.SQLRow;
 
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
public class DepotChequeSQLElement extends ComptaSQLConfElement {
 
public DepotChequeSQLElement() {
super("DEPOT_CHEQUE", "un dépot de chèque", "dépots de chèque");
MouseSheetXmlListeListener listener = new MouseSheetXmlListeListener(DepotChequeXmlSheet.class);
getRowActions().addAll(listener.getRowActions());
}
 
@Override
protected void setupLinks(SQLElementLinksSetup links) {
super.setupLinks(links);
links.get("ID_MOUVEMENT").setType(LinkType.ASSOCIATION);
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("NOM");
l.add("ID_BANQUE");
l.add("MONTANT");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("MONTANT");
return l;
}
 
public SQLComponent createComponent() {
return new DepotChequeSQLComponent(this);
};
 
@Override
public Set<String> getReadOnlyFields() {
Set<String> s = new HashSet<>();
s.add("MONTANT");
return s;
}
 
@Override
protected String createCode() {
return createCodeOfPackage() + ".depot";
}
 
@Override
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
for (SQLRow row : trees.getRows()) {
List<SQLRow> rowCheques = row.getReferentRows(getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
for (SQLRow depotElt : rowCheques) {
if (depotElt.getObject("ID_CHEQUE_A_ENCAISSER") != null && !depotElt.isForeignEmpty("ID_CHEQUE_A_ENCAISSER")) {
depotElt.getForeign("ID_CHEQUE_A_ENCAISSER").createEmptyUpdateRow().put("ENCAISSE", Boolean.FALSE).commit();
}
}
}
super.archive(trees, cutLinks);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeAEncaisserSQLElement.java
192,6 → 192,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cheque";
return createCodeOfPackage() + ".cheque";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeAvoirClientSQLElement.java
167,6 → 167,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cheque.due";
return createCodeOfPackage() + ".cheque.due";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/EncaisserMontantSQLElement.java
20,7 → 20,6
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRow;
33,9 → 32,6
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.EditPanelListener;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
167,4 → 163,9
 
super.archive(trees, cutLinks);
}
 
@Override
protected String createCodeSuffix() {
return ".category";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeFournisseurSQLElement.java
167,6 → 167,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cheque.supplier";
return createCodeOfPackage() + ".cheque.supplier";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/SDDMessageSQLElement.java
85,7 → 85,7
import org.jdom2.Namespace;
 
public final class SDDMessageSQLElement extends ComptaSQLConfElement {
static final String TABLE_NAME = "SEPA_DIRECT_DEBIT_MESSAGE";
static public final String TABLE_NAME = "SEPA_DIRECT_DEBIT_MESSAGE";
static public final String XML_LOCATION_PREF_KEY = "SDD.XML.location";
public static final String SERIAL_MD = "SDD_MESSAGE_SERIAL";
 
172,7 → 172,7
// TODO rename createCodeFromPackage() to createCodeOfPackage() and change createCode()
// implementation to use a new createCodeFromPackage() which uses the class name (w/o
// SQLElement suffix)
return this.createCodeFromPackage() + ".SDDMessage";
return this.createCodeOfPackage() + ".SDDMessage";
}
 
public final void exportXML(final Component comp, final List<? extends SQLRowAccessor> messages) {
238,6 → 238,7
static private final class InvoicesByPaymentInfo {
private final Date lowerBound, upperBound;
 
// { collection date -> { sequence type -> invoice } }
private final NavigableMap<Date, ListMap<String, InvoiceElem>> map = new TreeMap<>();
private final Set<Number> lockedInvoicesIDs = new HashSet<>();
private BigDecimal sum = BigDecimal.ZERO;
278,6 → 279,7
if (!mandate.getBoolean("ACTIVE"))
throw new IllegalStateException("Inactive mandate for " + invoice);
// needed otherwise would have to update seqType while generating
// MAYBE sum all invoices for a single mandate, but which date to choose ?
if (!this.invoiceMandates.add(mandate.getString("MandateIdentification")))
return IgnoreReason.DUPLICATE_MANDATE;
 
405,7 → 407,7
final SQLRowValues invoiceVals = new SQLRowValues(invoiceT);
invoiceVals.putRowValues("ID_CLIENT").putNulls("NOM", "BIC", "IBAN");
invoiceVals.putRowValues("ID_MODE_REGLEMENT").putNulls("AJOURS", "LENJOUR").putRowValues("ID_SEPA_MANDATE").setAllToNull();
invoiceVals.putNulls("NET_A_PAYER", "DATE", "NUMERO");
invoiceVals.putNulls("NET_A_PAYER", "DATE", "NUMERO", "NOM");
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(invoiceVals);
fetcher.setReturnedRowsUnmodifiable(true);
// required for locking rows and to make sure that there's a SEPA Mandate
622,7 → 624,9
 
res.addContent(new Element("Purp", painNS).addContent(new Element("Cd", painNS).setText("OTHR")));
 
// TODO <RmtInf><Ustrd>ligne de facture avec n° d'abonnement et indice de paiement.
final String info = (invoice.getString("NUMERO") + ' ' + invoice.getString("NOM")).trim();
if (!info.isEmpty())
res.addContent(new Element("RmtInf", painNS).addContent(elemCreator.create("Ustrd").setText(elemCreator.shortenText(info, 140))));
 
return res;
}
642,6 → 646,8
}
 
static private final class ElementCreator {
static private final String TRUNCATED_SUFFIX = "...";
static private final int TRUNCATED_SUFFIX_LENGTH = TRUNCATED_SUFFIX.length();
private final Namespace painNS;
private final SQLFieldTranslator fieldTrans;
 
668,6 → 674,12
throw new MissingInfoException(label == null ? elemName : label);
return create(elemName).setText(text);
}
 
protected String shortenText(final String text, final int maxLength) {
if (maxLength <= TRUNCATED_SUFFIX_LENGTH || text.length() <= maxLength)
return text;
return text.substring(0, maxLength - TRUNCATED_SUFFIX_LENGTH) + TRUNCATED_SUFFIX;
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/NouveauDecaissementChequeAvoirAction.java
13,25 → 13,20
package org.openconcerto.erp.core.finance.payment.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.action.GenericElementFrameAction;
import org.openconcerto.erp.core.finance.payment.element.ChequeAvoirClientSQLElement;
import org.openconcerto.erp.core.finance.payment.ui.ListeDesChequesAvoirADecaisserPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.view.IListFrame;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauDecaissementChequeAvoirAction extends GenericElementFrameAction<ChequeAvoirClientSQLElement, IListFrame> {
 
public class NouveauDecaissementChequeAvoirAction extends CreateFrameAbstractAction {
 
public NouveauDecaissementChequeAvoirAction() {
super();
this.putValue(Action.NAME, "Chèques d'avoir à décaisser");
public NouveauDecaissementChequeAvoirAction(final PropsConfiguration conf) {
super(conf.getDirectory().getElement(ChequeAvoirClientSQLElement.class));
}
 
@Override
public JFrame createFrame() {
ListeDesChequesAvoirADecaisserPanel panel = new ListeDesChequesAvoirADecaisserPanel(Configuration.getInstance().getDirectory().getElement(ChequeAvoirClientSQLElement.class));
return new IListFrame(panel);
protected IListFrame instantiateFrame() {
return new IListFrame(new ListeDesChequesAvoirADecaisserPanel(getElem()));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/ListeDesDepostChequesAction.java
New file
0,0 → 1,40
/*
* 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.payment.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.finance.accounting.ui.ListeGestCommEltPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.IListFrame;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesDepostChequesAction extends CreateFrameAbstractAction {
 
public ListeDesDepostChequesAction() {
super();
this.putValue(Action.NAME, "Liste des dépôts de chèque");
}
 
public JFrame createFrame() {
final SQLElement elt = Configuration.getInstance().getDirectory().getElement("DEPOT_CHEQUE");
ListeGestCommEltPanel panel = new ListeGestCommEltPanel(elt);
panel.setAddVisible(false);
IListFrame frame = new IListFrame(panel);
return frame;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/NouveauListeDesChequesADecaisserAction.java
13,25 → 13,20
package org.openconcerto.erp.core.finance.payment.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.action.GenericElementFrameAction;
import org.openconcerto.erp.core.finance.payment.element.ChequeFournisseurSQLElement;
import org.openconcerto.erp.core.finance.payment.ui.ListeDesChequesADecaisserPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.view.IListFrame;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauListeDesChequesADecaisserAction extends GenericElementFrameAction<ChequeFournisseurSQLElement, IListFrame> {
 
public class NouveauListeDesChequesADecaisserAction extends CreateFrameAbstractAction {
 
public NouveauListeDesChequesADecaisserAction() {
super();
this.putValue(Action.NAME, "Chèques fournisseurs à décaisser");
public NouveauListeDesChequesADecaisserAction(final PropsConfiguration conf) {
super(conf.getDirectory().getElement(ChequeFournisseurSQLElement.class));
}
 
public JFrame createFrame() {
ListeDesChequesADecaisserPanel panel = new ListeDesChequesADecaisserPanel(Configuration.getInstance().getDirectory().getElement(ChequeFournisseurSQLElement.class));
return new IListFrame(panel);
@Override
protected IListFrame instantiateFrame() {
return new IListFrame(new ListeDesChequesADecaisserPanel(getElem()));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/NouveauListeDesChequesAEncaisserAction.java
13,25 → 13,20
package org.openconcerto.erp.core.finance.payment.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.action.GenericElementFrameAction;
import org.openconcerto.erp.core.finance.payment.element.ChequeAEncaisserSQLElement;
import org.openconcerto.erp.core.finance.payment.ui.ListeDesChequesAEncaisserPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.view.IListFrame;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauListeDesChequesAEncaisserAction extends GenericElementFrameAction<ChequeAEncaisserSQLElement, IListFrame> {
 
public class NouveauListeDesChequesAEncaisserAction extends CreateFrameAbstractAction {
 
public NouveauListeDesChequesAEncaisserAction() {
super();
this.putValue(Action.NAME, "Chèques à encaisser");
public NouveauListeDesChequesAEncaisserAction(final PropsConfiguration conf) {
super(conf.getDirectory().getElement(ChequeAEncaisserSQLElement.class));
}
 
public JFrame createFrame() {
ListeDesChequesAEncaisserPanel panel = new ListeDesChequesAEncaisserPanel(Configuration.getInstance().getDirectory().getElement(ChequeAEncaisserSQLElement.class));
return new IListFrame(panel);
@Override
protected IListFrame instantiateFrame() {
return new IListFrame(new ListeDesChequesAEncaisserPanel(getElem()));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/ListeDesTraitesAbstractAction.java
15,12 → 15,10
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
43,14 → 41,8
@Override
public final JFrame createFrame() {
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(this.table);
final SQLField modeReglF = this.table.getField("ID_MODE_REGLEMENT");
final SQLTable modeReglT = this.table.getForeignTable(modeReglF.getName());
 
Where wPrev = new Where(modeReglF, "=", modeReglT.getKey());
wPrev = wPrev.and(new Where(modeReglT.getField("ID_TYPE_REGLEMENT"), ">=", TypeReglementSQLElement.TRAITE));
wPrev = wPrev.and(new Where(this.echeanceField, ">", 1));
final SQLTableModelSourceOnline src = elt.getTableSource(true);
src.getReq().setWhere(wPrev);
 
IListFrame frame = new IListFrame(new ListeViewPanel(elt, new IListe(src)));
frame.getPanel().setAddVisible(false);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/ui/ListeDesChequesAEncaisserPanel.java
21,6 → 21,8
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.GestionDevise;
28,6 → 30,7
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
37,6 → 40,7
import javax.swing.text.JTextComponent;
 
public class ListeDesChequesAEncaisserPanel extends ChequeListPanel {
private JTextField fieldLabel;
 
public ListeDesChequesAEncaisserPanel(final ChequeAEncaisserSQLElement elem) {
super(elem);
49,7 → 53,10
 
@Override
protected JTextComponent createLabelText() {
return new JTextField();
if (fieldLabel == null) {
this.fieldLabel = new JTextField();
}
return fieldLabel;
}
 
@Override
59,7 → 66,39
@Override
public void actionPerformed(ActionEvent e) {
final String s = text.getText();
getModel().valideDepot(banqueSelect.getSelectedRow(), dateDepot.getDate(), checkImpression.isSelected(), s);
SQLRowValues rowValsDepot = new SQLRowValues(element.getTable().getTable("DEPOT_CHEQUE"));
rowValsDepot.put("DATE", dateDepot.getValue());
rowValsDepot.put("NOM", fieldLabel.getText());
final SQLRow selectedBanque = banqueSelect.getSelectedRow();
if (selectedBanque != null) {
rowValsDepot.put("ID_" + selectedBanque.getTable().getName(), selectedBanque.getID());
}
List<SQLRowValues> chq = getListe().getSelectedRows();
for (SQLRowValues sqlRowValues : chq) {
SQLRow rowChq = sqlRowValues.asRow();
rowChq.fetchValues();
SQLRowValues rowValsDepotElt = new SQLRowValues(element.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
rowValsDepotElt.put("ID_DEPOT_CHEQUE", rowValsDepot);
if (rowChq.getObject("ID_CLIENT") != null && !rowChq.isForeignEmpty("ID_CLIENT")) {
rowValsDepotElt.put("ID_CLIENT", rowChq.getForeignID("ID_CLIENT"));
}
rowValsDepotElt.put("TIERS", rowChq.getString("TIERS"));
rowValsDepotElt.put("ID_CHEQUE_A_ENCAISSER", rowChq.getID());
if (rowChq.getObject("DATE") != null) {
rowValsDepotElt.put("DATE", rowChq.getObject("DATE"));
} else if (rowChq.getObject("DATE_VENTE") != null) {
rowValsDepotElt.put("DATE", rowChq.getObject("DATE_VENTE"));
}
rowValsDepotElt.put("BANQUE", (rowChq.getObject("ETS") == null ? "" : rowChq.getObject("ETS")));
if (rowChq.getObject("ID_MOUVEMENT") != null && !rowChq.isForeignEmpty("ID_MOUVEMENT")) {
rowValsDepotElt.put("PIECE", rowChq.getForeign("ID_MOUVEMENT").getForeign("ID_PIECE").getString("NOM"));
}
rowValsDepotElt.put("NUMERO", (rowChq.getObject("NUMERO") == null ? "" : rowChq.getObject("NUMERO")));
rowValsDepotElt.put("MONTANT", rowChq.getObject("MONTANT"));
}
EditFrame frame = new EditFrame(element.getDirectory().getElement("DEPOT_CHEQUE"), EditMode.CREATION);
frame.getSQLComponent().select(rowValsDepot);
frame.setVisible(true);
text.setText("");
}
});
78,7 → 117,7
 
String price = GestionDevise.currencyToString(rowCheque.getLong("MONTANT"));
SQLRow rowClient = rowCheque.getForeignRow("ID_CLIENT");
String nomClient = rowClient.getString("NOM");
String nomClient = rowClient == null ? rowCheque.getString("TIERS") : rowClient.getString("NOM");
String piece = "";
SQLRow rowMvt = rowCheque.getForeignRow("ID_MOUVEMENT");
if (rowMvt != null) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/ui/GestionChequesRenderer.java
23,7 → 23,7
 
public class GestionChequesRenderer extends DefaultTableCellRenderer {
 
private final static Color couleurChequeValide = new Color(255, 128, 64);
private static final Color CHEQUE_VALIDE_COLOR = new Color(255, 128, 64);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
 
@Override
30,8 → 30,8
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final Component res = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
final Color fgColor;
if (!isSelected && System.currentTimeMillis() > ((Date) value).getTime()) {
fgColor = couleurChequeValide;
if (value != null && !isSelected && System.currentTimeMillis() > ((Date) value).getTime()) {
fgColor = CHEQUE_VALIDE_COLOR;
} else {
fgColor = table.getForeground();
}
41,6 → 41,10
 
@Override
protected void setValue(Object value) {
super.setValue(dateFormat.format((Date) value));
if (value == null) {
super.setValue(null);
} else {
super.setValue(dateFormat.format((Date) value));
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/ui/DepotChequeTable.java
New file
0,0 → 1,152
/*
* 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.payment.ui;
 
import org.openconcerto.erp.core.common.ui.DeviseCellEditor;
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.KeyTableCellRenderer;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.table.TimestampTableCellEditor;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.sql.Timestamp;
import java.util.List;
import java.util.Vector;
 
import javax.swing.DefaultCellEditor;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ToolTipManager;
 
public class DepotChequeTable extends JPanel {
protected RowValuesTable table;
protected SQLTableElement montant;
protected RowValuesTableModel model;
 
public DepotChequeTable() {
init();
uiInit();
}
 
/**
*
*/
protected void init() {
 
final SQLElement e = getSQLElement();
 
final List<SQLTableElement> list = new Vector<SQLTableElement>();
 
final SQLTableElement tableElement_Chq = new SQLTableElement(e.getTable().getField("ID_CHEQUE_A_ENCAISSER"), Integer.class, new DefaultCellEditor(new JTextField()));
tableElement_Chq.setRenderer(new KeyTableCellRenderer(e.getForeignElement("ID_CHEQUE_A_ENCAISSER")));
list.add(tableElement_Chq);
 
final SQLTableElement tableElement_Client = new SQLTableElement(e.getTable().getField("ID_CLIENT"), Integer.class, new DefaultCellEditor(new JTextField()));
tableElement_Client.setRenderer(new KeyTableCellRenderer(e.getForeignElement("ID_CLIENT")));
list.add(tableElement_Client);
 
// Tiers
final SQLTableElement tiersElement = new SQLTableElement(e.getTable().getField("TIERS"));
list.add(tiersElement);
 
// Date
final SQLTableElement numeroElement = new SQLTableElement(e.getTable().getField("NUMERO"));
list.add(numeroElement);
 
// Date
final SQLTableElement banqueElement = new SQLTableElement(e.getTable().getField("BANQUE"));
list.add(banqueElement);
 
// Date
final SQLTableElement pieceElement = new SQLTableElement(e.getTable().getField("PIECE"));
list.add(pieceElement);
 
// Date
final SQLTableElement dateElement = new SQLTableElement(e.getTable().getField("DATE"), Timestamp.class, new TimestampTableCellEditor());
list.add(dateElement);
 
// Total HT
this.montant = new SQLTableElement(e.getTable().getField("MONTANT"), Long.class, new DeviseCellEditor());
this.montant.setRenderer(new DeviseNiceTableCellRenderer());
list.add(this.montant);
 
this.model = new RowValuesTableModel(e, list, e.getTable().getField("MONTANT"), false);
 
this.table = new RowValuesTable(this.model, null, true);
 
this.table.setEditable(false);
 
ToolTipManager.sharedInstance().unregisterComponent(this.table);
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
 
}
 
/**
*
*/
protected void uiInit() {
// Ui init
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.weightx = 1;
 
c.fill = GridBagConstraints.BOTH;
c.weighty = 1;
 
this.add(new JScrollPane(this.table), c);
this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
}
 
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement("DEPOT_CHEQUE_ELEMENT");
}
 
public void updateField(String field, int id) {
this.table.updateField(field, id);
}
 
public RowValuesTable getRowValuesTable() {
return this.table;
}
 
public void insertFrom(String field, int id) {
this.table.insertFrom(field, id);
}
 
public void insertFrom(SQLRowValues rowVals) {
this.table.insertFrom(rowVals);
}
 
public RowValuesTableModel getModel() {
return this.table.getRowValuesTableModel();
}
 
public SQLTableElement getMontantElement() {
return this.montant;
}
 
public void refreshTable() {
this.table.repaint();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/DepotChequeSQLComponent.java
New file
0,0 → 1,211
/*
* 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.payment.component;
 
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.payment.ui.DepotChequeTable;
import org.openconcerto.erp.generationEcritures.GenerationMvtDepotChequeClient;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
public class DepotChequeSQLComponent extends BaseSQLComponent {
 
private DepotChequeTable table = new DepotChequeTable();
 
private JTextField nom = new JTextField();
private DeviseField montant = new DeviseField(10);
private JDate date;
private ElementComboBox boxBanque = new ElementComboBox(true);
 
public DepotChequeSQLComponent(SQLElement elt) {
super(elt);
}
 
@Override
public void addViews() {
this.setLayout(new GridBagLayout());
 
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
this.add(new JLabelBold("Chèques"), c);
c.gridy++;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.add(this.table, c);
this.table.getRowValuesTable().setEnabled(false);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
c.gridy++;
c.weighty = 0;
 
// Client
c.gridx = 0;
c.gridy++;
c.weightx = 0;
final String itemName = "ID_" + getDirectory().getElement(BanqueSQLElement.class).getTable().getName();
this.add(new JLabel(getLabelFor(itemName), SwingConstants.RIGHT), c);
 
c.gridx++;
c.weightx = 1;
c.gridwidth = 1;
this.add(this.boxBanque, c);
c.gridwidth = 1;
 
// Date
this.date = new JDate(true);
c.gridx = GridBagConstraints.RELATIVE;
c.weightx = 0;
c.gridwidth = 1;
this.add(new JLabel("Date"), c);
// c.gridx++;
c.weightx = 0;
this.add(this.date, c);
 
this.addSQLObject(this.boxBanque, itemName);
 
// Nom
c.gridy++;
c.gridx = 0;
final JLabel label = new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT);
c.weightx = 0;
this.add(label, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = 2;
this.add(this.nom, c);
 
// Montant
c.gridwidth = 1;
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(new JLabel("Montant encaissé", SwingConstants.RIGHT), c);
 
c.gridx++;
c.gridwidth = 3;
c.fill = GridBagConstraints.NONE;
this.add(this.montant, c);
 
this.addRequiredSQLObject(this.date, "DATE");
this.addRequiredSQLObject(this.montant, "MONTANT");
 
this.addSQLObject(this.nom, "NOM");
DefaultGridBagConstraints.lockMinimumSize(this.montant);
 
final TableModelListener tableListener = new TableModelListener() {
 
@Override
public void tableChanged(TableModelEvent e) {
final RowValuesTableModel model = table.getRowValuesTable().getRowValuesTableModel();
if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == model.getColumnIndexForElement(table.getMontantElement())) {
 
final int rowCount = model.getRowCount();
long total = 0;
for (int i = 0; i < rowCount; i++) {
Number nHT = (Number) model.getValueAt(i, model.getColumnIndexForElement(table.getMontantElement()));
if (nHT != null) {
total += nHT.longValue();
}
}
 
montant.setText(GestionDevise.currencyToString(total));
 
}
}
};
 
this.table.getRowValuesTable().getRowValuesTableModel().addTableModelListener(tableListener);
 
}
 
@Override
public void select(SQLRowAccessor r) {
super.select(r);
if (r != null && r.getID() > 1) {
this.table.insertFrom("ID_DEPOT_CHEQUE", r.getID());
} else if (r != null && r instanceof SQLRowValues) {
this.table.insertFrom((SQLRowValues) r);
 
}
}
 
@Override
public int insert(SQLRow order) {
 
int id = super.insert(order);
try {
this.table.updateField("ID_DEPOT_CHEQUE", id);
 
System.err.println("Génération des ecritures du reglement");
GenerationMvtDepotChequeClient depotGen = new GenerationMvtDepotChequeClient(getTable().getRow(id));
depotGen.genere();
 
} catch (Exception e) {
ExceptionHandler.handle("Erreur lors de la génération des ecritures du reglement", e);
}
return id;
}
 
@Override
public void update() {
final int id = this.getSelectedID();
super.update();
this.table.updateField("ID_DEPOT_CHEQUE", id);
SQLRow row = getTable().getRow(id);
int idMvt = row.getInt("ID_MOUVEMENT");
 
// on supprime tout ce qui est lié à la facture
try {
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
eltEcr.archiveMouvementProfondeur(idMvt, false);
 
GenerationMvtDepotChequeClient depotGen = new GenerationMvtDepotChequeClient(row);
depotGen.genere();
} catch (Exception e) {
e.printStackTrace();
}
}
 
@Override
protected SQLRowValues createDefaults() {
this.table.getModel().clearRows();
 
return new SQLRowValues(getTable());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/EncaisserMontantSQLComponent.java
182,6 → 182,10
this.addRequiredSQLObject(this.montant, "MONTANT");
 
this.addSQLObject(this.nom, "NOM");
 
this.addSQLObject(new ElementComboBox(), "ID_COMPTE_PCE_TIERS");
this.addSQLObject(new JTextField(), "TIERS");
DefaultGridBagConstraints.lockMinimumSize(this.montant);
 
final TableModelListener tableListener = new TableModelListener() {
323,7 → 327,8
System.err.println("Liste des échéances vides pour l'encaissement ID " + id);
Thread.dumpStack();
}
new GenerationReglementVenteNG(label, clientRow, ttc, row.getDate("DATE").getTime(), rowModeRegl, row, l.get(0).getForeignRow("ID_MOUVEMENT_ECHEANCE"), false);
new GenerationReglementVenteNG(label, clientRow, ttc, row.getDate("DATE").getTime(), rowModeRegl, row, l.get(0).getForeignRow("ID_MOUVEMENT_ECHEANCE"), false, false,
row.getString("TIERS"), row.getForeign("ID_COMPTE_PCE_TIERS"));
 
// Mise a jour du montant de l'echeance
boolean supplement = false;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouveauInfosSalariePayeAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleRubriqueCotisationAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleRubriqueBrutAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleFichePayeAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleCaisseCotisationAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleRubriqueNetAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouveauCumulCongesAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouveauCumulAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleVariableSalarieAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouveauClassementConventionnelAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouveauReglementPayeAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouveauProfiPayelAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouveauRegimeBaseAction.java
13,22 → 13,14
package org.openconcerto.erp.core.humanresources.payroll.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.humanresources.payroll.element.RegimeBaseSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauRegimeBaseAction extends CreateEditFrameAbstractAction<RegimeBaseSQLElement> {
 
public class NouveauRegimeBaseAction extends CreateFrameAbstractAction {
 
public NouveauRegimeBaseAction() {
super();
this.putValue(Action.NAME, "Choix des régimes");
public NouveauRegimeBaseAction(final PropsConfiguration conf) {
super(conf, RegimeBaseSQLElement.class);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("REGIME_BASE"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/ListeDesVariablesPayes.java
14,7 → 14,7
package org.openconcerto.erp.core.humanresources.payroll.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
 
24,7 → 24,6
import javax.swing.JButton;
import javax.swing.JFrame;
 
 
public class ListeDesVariablesPayes extends CreateFrameAbstractAction {
 
public ListeDesVariablesPayes() {
34,8 → 33,8
 
public JFrame createFrame() {
 
final NouvelleVariablePayeAction actionNewVar = new NouvelleVariablePayeAction();
final ListeAddPanel listeVar = new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("VARIABLE_PAYE")) {
final NouvelleVariablePayeAction actionNewVar = new NouvelleVariablePayeAction(ComptaPropsConfiguration.getInstanceCompta());
final ListeAddPanel listeVar = new ListeAddPanel(actionNewVar.getElem()) {
protected void handleAction(JButton source, ActionEvent evt) {
 
if (source == this.buttonAjouter) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleVariablePayeAction.java
13,22 → 13,14
package org.openconcerto.erp.core.humanresources.payroll.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouvelleVariablePayeAction extends CreateEditFrameAbstractAction<VariablePayeSQLElement> {
 
public class NouvelleVariablePayeAction extends CreateFrameAbstractAction {
 
public NouvelleVariablePayeAction() {
super();
this.putValue(Action.NAME, "Test variable");
public NouvelleVariablePayeAction(final PropsConfiguration conf) {
super(conf, VariablePayeSQLElement.class);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("VARIABLE_PAYE"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelleSaisieKmAction.java
13,30 → 13,14
package org.openconcerto.erp.core.humanresources.payroll.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.finance.accounting.element.SaisieKmSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouvelleSaisieKmAction extends CreateEditFrameAbstractAction<SaisieKmSQLElement> {
 
public class NouvelleSaisieKmAction extends CreateFrameAbstractAction {
public NouvelleSaisieKmAction() {
super();
this.putValue(Action.NAME, "Ecritures comptables");
public NouvelleSaisieKmAction(final PropsConfiguration conf) {
super(conf, SaisieKmSQLElement.class);
}
 
@Override
public JFrame createFrame() {
final EditFrame editFrame = new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_KM")) {
@Override
public void inserted(int id) {
super.inserted(id);
if (getPanel().alwaysVisible()) {
getSQLComponent().resetValue();
}
}
};
return editFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/NouvelAcompteAction.java
13,21 → 13,14
package org.openconcerto.erp.core.humanresources.payroll.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.humanresources.payroll.element.AcompteSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouvelAcompteAction extends CreateEditFrameAbstractAction<AcompteSQLElement> {
 
public class NouvelAcompteAction extends CreateFrameAbstractAction {
public NouvelAcompteAction() {
super();
this.putValue(Action.NAME, "Acompte");
public NouvelAcompteAction(final PropsConfiguration conf) {
super(conf, AcompteSQLElement.class);
}
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("ACOMPTE"));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/component/VariableRowTreeNode.java
18,21 → 18,36
public class VariableRowTreeNode extends FormuleTreeNode {
 
private SQLRow row;
private String label;
 
public VariableRowTreeNode(SQLRow row) {
this.row = row;
setLabelFromRow();
}
 
private void setLabelFromRow() {
this.label = "";
if (this.row != null) {
if (this.row.contains("CODE")) {
this.label = this.row.getString("CODE") + " - " + this.row.getString("NOM");
} else {
this.label = this.row.getString("NOM");
}
}
 
}
 
public String getName() {
return (this.row == null) ? "" : this.row.getString("NOM");
return this.label;
}
 
@Override
public String toString() {
return (this.row == null) ? "" : this.row.getString("NOM");
return this.label;
}
 
public String getTextValue() {
return (this.row == null) ? "" : this.row.getString("NOM");
return this.label;
}
 
public String getTextInfosValue() {
45,6 → 60,7
 
public void setRow(SQLRow row) {
this.row = row;
setLabelFromRow();
}
 
public int getID() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/PeriodeValiditeSQLElement.java
13,9 → 13,10
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
29,10 → 30,10
 
import javax.swing.JCheckBox;
 
public class PeriodeValiditeSQLElement extends ConfSQLElement {
public class PeriodeValiditeSQLElement extends ComptaSQLConfElement {
 
public PeriodeValiditeSQLElement() {
super("PERIODE_VALIDITE", "une période de validité", "périodes de validité");
public PeriodeValiditeSQLElement(final DBRoot root) {
super(root.getTable("PERIODE_VALIDITE"), "une période de validité", "périodes de validité");
}
 
protected List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ProfilPayeSQLElement.java
13,18 → 13,32
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.JNiceButton;
import org.openconcerto.erp.core.humanresources.payroll.component.VariableRowTreeNode;
import org.openconcerto.erp.core.humanresources.payroll.ui.ProfilPayeModel;
import org.openconcerto.erp.model.FichePayeModel;
import org.openconcerto.erp.model.RubriquePayeTree;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.table.AlternateTableCellRenderer;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
33,11 → 47,14
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
46,10 → 63,47
import javax.swing.SwingConstants;
import javax.swing.tree.TreePath;
 
public class ProfilPayeSQLElement extends ConfSQLElement {
public class ProfilPayeSQLElement extends ComptaSQLConfElement {
 
public ProfilPayeSQLElement() {
super("PROFIL_PAYE", "un profil de paye", "profils de paye");
public ProfilPayeSQLElement(final DBRoot root) {
super(root.getTable("PROFIL_PAYE"), "un profil de paye", "profils de paye");
 
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Actualiser les salariés liès au profil") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
SQLRowAccessor rowSel = IListe.get(e).getSelectedRow();
 
// Listes des rubriques du profil
SQLSelect selAllIDProfilElt = new SQLSelect();
SQLTable tableProfilElt = getTable().getTable("PROFIL_PAYE_ELEMENT");
selAllIDProfilElt.addSelectStar(tableProfilElt);
selAllIDProfilElt.setWhere(new Where(tableProfilElt.getField("ID_PROFIL_PAYE"), "=", rowSel.getID()));
selAllIDProfilElt.addFieldOrder(tableProfilElt.getField("POSITION"));
List<SQLRow> profilElt = SQLRowListRSH.execute(selAllIDProfilElt);
 
SQLSelect selSal = new SQLSelect();
selSal.addSelectStar(getTable().getDBRoot().findTable("SALARIE"));
List<SQLRow> rowSal = SQLRowListRSH.execute(selSal);
 
int updateSalCount = 0;
for (SQLRow sqlRow : rowSal) {
 
SQLRow rowFichePaye = sqlRow.getForeign("ID_FICHE_PAYE");
 
if (rowFichePaye.getObject("ID_PROFIL_PAYE") != null && rowFichePaye.getForeignID("ID_PROFIL_PAYE") == rowSel.getID()) {
loadFromProfil(rowFichePaye, profilElt);
updateSalCount++;
}
}
 
JOptionPane.showMessageDialog(null, updateSalCount + " mis à jour!", "Actualisation bulletin", JOptionPane.INFORMATION_MESSAGE);
 
}
}, true);
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(action);
}
 
protected List<String> getListFields() {
231,4 → 285,43
protected String createCode() {
return "humanresources.payroll.template";
}
 
public void loadFromProfil(SQLRow rowFichePaye, List<SQLRow> rowProfilElt) {
 
System.err.println("Load from profil");
 
// resetValueFiche();
 
// Supression des anciennes rubriques du bulletin
final SQLTable ficheEltTable = rowFichePaye.getTable().getTable("FICHE_PAYE_ELEMENT");
UpdateBuilder archiveElt = new UpdateBuilder(ficheEltTable);
archiveElt.setObject("ARCHIVE", 1);
archiveElt.setWhere(new Where(ficheEltTable.getField("ID_FICHE_PAYE"), "=", rowFichePaye.getID()));
getTable().getDBSystemRoot().getDataSource().execute(archiveElt.asString());
 
// this.vectRubrique = new Vector();
SQLRowValues rowValsFiche = rowFichePaye.createEmptyUpdateRow();
int position = 1;
for (SQLRow profilLigne : rowProfilElt) {
SQLRowValues rowVals = new SQLRowValues(ficheEltTable);
 
String source = profilLigne.getString("SOURCE");
int idSource = profilLigne.getInt("IDSOURCE");
rowVals.put("NOM", getTable().getTable(source).getRow(idSource).getString("NOM"));
rowVals.put("SOURCE", source);
rowVals.put("IDSOURCE", idSource);
rowVals.put("POSITION", position);
rowVals.put("ID_FICHE_PAYE", rowValsFiche);
position++;
}
try {
rowValsFiche.commit();
 
// actualisation de la fiche
FichePayeModel model = new FichePayeModel(rowValsFiche.getID());
model.loadAllElements();
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors de la mise à jour du bulletin!", e);
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/TypePreavisSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class TypePreavisSQLElement extends AbstractCodeCommonSQLElement {
public TypePreavisSQLElement() {
super("TYPE_PREAVIS", "un type de préavis", "types de préavis");
public TypePreavisSQLElement(final DBRoot root) {
super(root.getTable("TYPE_PREAVIS"), "un type de préavis", "types de préavis");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CoefficientPrimeSQLElement.java
129,6 → 129,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".coeffPrime";
return createCodeOfPackage() + ".coeffPrime";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AyantDroitSQLElement.java
57,7 → 57,7
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".ayantdroit";
return createCodeOfPackage() + ".ayantdroit";
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeStatutCategorielSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".convention.category.code";
return createCodeOfPackage() + ".convention.category.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeCaractActiviteSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".convention.code";
return createCodeOfPackage() + ".convention.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/PasSQLElement.java
New file
0,0 → 1,104
/*
* 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.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class PasSQLElement extends ComptaSQLConfElement {
public PasSQLElement() {
super("PAS", "un détail de PAS", "détails PAS");
}
 
public List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("CODE_PAS");
l.add("TAUX_PAS");
l.add("ID_TYPE_TAUX_PAS");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("CODE_PAS");
l.add("TAUX_PAS");
l.add("ID_TYPE_TAUX_PAS");
return l;
}
 
@Override
public boolean isPrivate() {
return true;
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
public void addViews() {
 
this.setLayout(new GridBagLayout());
 
GridBagConstraints cPanel = new DefaultGridBagConstraints();
 
// Taux
JLabel labelTaux = new JLabel(getLabelFor("TAUX_PAS"));
this.add(labelTaux, cPanel);
JTextField textTaux = new JTextField(10);
cPanel.gridx++;
this.add(textTaux, cPanel);
 
// Type
cPanel.gridx++;
JLabel labelType = new JLabel(getLabelFor("ID_TYPE_TAUX_PAS"));
this.add(labelType, cPanel);
ElementComboBox boxType = new ElementComboBox();
cPanel.gridx++;
this.add(boxType, cPanel);
 
// cotisation salariale
cPanel.gridx = 0;
cPanel.gridy++;
JLabel labelCCode = new JLabel(getLabelFor("CODE_PAS"));
this.add(labelCCode, cPanel);
JTextField textCode = new JTextField(10);
cPanel.gridx++;
this.add(textCode, cPanel);
 
this.addRequiredSQLObject(boxType, "ID_TYPE_TAUX_PAS");
this.addSQLObject(textCode, "CODE_PAS");
this.addRequiredSQLObject(textTaux, "TAUX_PAS");
}
};
}
 
@Override
protected String createCode() {
return createCodeOfPackage() + ".pas";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/VariableSalarieSQLElement.java
41,7 → 41,7
 
String field = sqlField.getName();
if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.endsWith("_DEFAULT_VAL")) {
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.endsWith("_DEFAULT_VAL") && !field.endsWith("_CUMUL_VAL")) {
l.add(field);
}
}
76,6 → 76,7
this.add(new JLabel("Nom de la variable"), c);
this.add(new JLabel("Valeur période courante"), c);
this.add(new JLabel("Valeur d'initialisation par défaut(prochain bulletin)"), c);
this.add(new JLabel("Cumuls"), c);
 
final List<String> listFields = getListFields();
 
92,7 → 93,13
this.addView(textFieldValDef, fieldName + "_DEFAULT_VAL");
 
}
if (getTable().contains(fieldName + "_CUMUL_VAL")) {
final JTextField textFieldValDef = new JTextField(15);
this.add(textFieldValDef, c);
this.addView(textFieldValDef, fieldName + "_CUMUL_VAL");
 
}
 
// if (pos % 2 == 0) {
// this.addSQLObject(new JTextField(15), i, "left");
// } else {
106,6 → 113,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".employe.variable";
return createCodeOfPackage() + ".employe.variable";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/DSNTypeSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class DSNTypeSQLElement extends AbstractCodeCommonSQLElement {
public DSNTypeSQLElement() {
super("DSN_TYPE", "une type de DSN", "types de DSN");
public DSNTypeSQLElement(final DBRoot root) {
super(root.getTable("DSN_TYPE"), "une type de DSN", "types de DSN");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratRegimeVieillesseSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class ContratRegimeVieillesseSQLElement extends AbstractCodeCommonSQLElement {
public ContratRegimeVieillesseSQLElement() {
super("CONTRAT_REGIME_VIEILLESSE", "un régime de vieillesse", "régimes de vieillesse");
public ContratRegimeVieillesseSQLElement(final DBRoot root) {
super(root.getTable("CONTRAT_REGIME_VIEILLESSE"), "un régime de vieillesse", "régimes de vieillesse");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/MotifRepriseArretTravailSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class MotifRepriseArretTravailSQLElement extends AbstractCodeCommonSQLElement {
public MotifRepriseArretTravailSQLElement() {
super("MOTIF_REPRISE_ARRET_TRAVAIL", "un motif de reprise d'arrêt de travail", "motifs de reprise d'arrêt de travail");
public MotifRepriseArretTravailSQLElement(final DBRoot root) {
super(root.getTable("MOTIF_REPRISE_ARRET_TRAVAIL"), "un motif de reprise d'arrêt de travail", "motifs de reprise d'arrêt de travail");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueBrutSQLElement.java
13,15 → 13,18
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
import org.openconcerto.erp.core.humanresources.payroll.component.FormuleTreeNode;
import org.openconcerto.erp.core.humanresources.payroll.component.RubriqueSQLComponent;
import org.openconcerto.erp.core.humanresources.payroll.component.VariableTree;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
49,10 → 52,10
import javax.swing.SwingConstants;
import javax.swing.tree.TreePath;
 
public class RubriqueBrutSQLElement extends ConfSQLElement {
public class RubriqueBrutSQLElement extends ComptaSQLConfElement {
 
public RubriqueBrutSQLElement() {
super("RUBRIQUE_BRUT", "une rubrique de brut", "rubriques de brut");
public RubriqueBrutSQLElement(final DBRoot root) {
super(root.getTable("RUBRIQUE_BRUT"), "une rubrique de brut", "rubriques de brut");
}
 
protected List<String> getListFields() {
63,9 → 66,9
l.add("BASE");
l.add("TAUX");
l.add("MONTANT");
l.add("PART_BRUT");
l.add("COTISABLE");
l.add("PART_CP");
l.add("IMPOSABLE");
l.add("TAXABLE_CM");
 
return l;
}
283,7 → 286,7
 
// SQLElement eltType =
// Configuration.getInstance().getDirectory().getElement("TYPE_RUBRIQUE_BRUT");
ElementComboBox comboSelTypeRubrique = new ElementComboBox(false);
SQLRequestComboBox comboSelTypeRubrique = new SQLRequestComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeRubrique, cPanel);
295,7 → 298,7
cPanel.weightx = 0;
panelProp.add(labelSelTypeRubriqueImpression, cPanel);
 
ElementComboBox comboSelTypeImpression = new ElementComboBox(false);
SQLRequestComboBox comboSelTypeImpression = new SQLRequestComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeImpression, cPanel);
306,9 → 309,18
cPanel.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
cPanel.gridwidth = GridBagConstraints.REMAINDER;
JCheckBox checkImpo = new JCheckBox(getLabelFor("IMPOSABLE"));
JCheckBox checkImpo = new JCheckBox(getLabelFor("TAXABLE_CM"));
panelProp.add(checkImpo, cPanel);
 
// Participation à la base cotisable
cPanel.gridx = 1;
cPanel.weightx = 1;
cPanel.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
cPanel.gridwidth = GridBagConstraints.REMAINDER;
JCheckBox checkCotis = new JCheckBox(getLabelFor("COTISABLE"));
panelProp.add(checkCotis, cPanel);
 
// Participation à la base brute
cPanel.gridx = 1;
cPanel.weightx = 1;
362,8 → 374,9
this.addRequiredSQLObject(comboSelTypeRubrique, "ID_TYPE_RUBRIQUE_BRUT");
this.addRequiredSQLObject(comboSelTypeImpression, "ID_IMPRESSION_RUBRIQUE");
this.addSQLObject(checkBrut, "PART_BRUT");
this.addSQLObject(checkCotis, "COTISABLE");
this.addSQLObject(checkCP, "PART_CP");
this.addSQLObject(checkImpo, "IMPOSABLE");
this.addSQLObject(checkImpo, "TAXABLE_CM");
 
selSalarie.addValueListener(new PropertyChangeListener() {
 
374,6 → 387,16
}
});
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("TAXABLE_CM", Boolean.TRUE);
rowVals.put("COTISABLE", Boolean.TRUE);
rowVals.put("PART_BRUT", Boolean.TRUE);
 
return rowVals;
}
};
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueCotisationSQLElement.java
13,6 → 13,7
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
import org.openconcerto.erp.core.humanresources.payroll.component.FormuleTreeNode;
import org.openconcerto.erp.core.humanresources.payroll.component.RubriqueSQLComponent;
20,11 → 21,12
import org.openconcerto.erp.core.humanresources.payroll.report.LignePayeSimplifieeComboBox;
import org.openconcerto.erp.core.humanresources.payroll.report.LignePayeSimplifieeRowItemView;
import org.openconcerto.erp.core.humanresources.payroll.report.LigneSimplifieeCellRenderer;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
55,10 → 57,10
 
// FIXME bug Layout
 
public class RubriqueCotisationSQLElement extends ConfSQLElement {
public class RubriqueCotisationSQLElement extends ComptaSQLConfElement {
 
public RubriqueCotisationSQLElement() {
super("RUBRIQUE_COTISATION", "une rubrique de cotisation", "rubriques de cotisation");
public RubriqueCotisationSQLElement(final DBRoot root) {
super(root.getTable("RUBRIQUE_COTISATION"), "une rubrique de cotisation", "rubriques de cotisation");
}
 
@Override
237,7 → 239,7
cPanel.weightx = 0;
panelProp.add(labelSelTypeImpression, cPanel);
 
ElementComboBox comboSelTypeImpression = new ElementComboBox(false);
SQLRequestComboBox comboSelTypeImpression = new SQLRequestComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeImpression, cPanel);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeIdccSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".conventions.code";
return createCodeOfPackage() + ".conventions.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AbstractCodeSQLElement.java
16,6 → 16,7
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
32,6 → 33,10
super(tableName, singular, plural);
}
 
public AbstractCodeSQLElement(final SQLTable table, final String singular, final String plural) {
super(table, singular, plural);
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(2);
list.add("CODE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CaisseModePaiementSQLElement.java
13,14 → 13,16
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class CaisseModePaiementSQLElement extends AbstractCodeSQLElement {
 
public CaisseModePaiementSQLElement() {
super("CAISSE_MODE_PAIEMENT", "un mode de paiement", "modes de paiement");
public CaisseModePaiementSQLElement(final DBRoot root) {
super(root.getTable("CAISSE_MODE_PAIEMENT"), "un mode de paiement", "modes de paiement");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".mode.paiement";
return createCodeOfPackage() + ".mode.paiement";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ReglementPayeSQLElement.java
244,6 → 244,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".payment";
return createCodeOfPackage() + ".payment";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CaisseCotisationSQLElement.java
13,12 → 13,13
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.humanresources.payroll.ui.CaisseCotisationRenseignementTable;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
39,10 → 40,10
import javax.swing.JPanel;
import javax.swing.JTextField;
 
public class CaisseCotisationSQLElement extends ConfSQLElement {
public class CaisseCotisationSQLElement extends ComptaSQLConfElement {
 
public CaisseCotisationSQLElement() {
super("CAISSE_COTISATION", "une caisse", "caisses");
public CaisseCotisationSQLElement(final DBRoot root) {
super(root.getTable("CAISSE_COTISATION"), "une caisse", "caisses");
}
 
protected List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CaisseCotisationRenseignentSQLElement.java
13,33 → 13,25
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.ListMap;
public class CaisseCotisationRenseignentSQLElement extends ComptaSQLConfElement {
 
public class CaisseCotisationRenseignentSQLElement extends ConfSQLElement {
 
public CaisseCotisationRenseignentSQLElement() {
super("CAISSE_COTISATION_RENSEIGNEMENT", "une caisse renseignement", "caisses renseignements");
public CaisseCotisationRenseignentSQLElement(final DBRoot root) {
super(root.getTable("CAISSE_COTISATION_RENSEIGNEMENT"), "une caisse renseignement", "caisses renseignements");
}
 
protected List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/MotifFinContratSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class MotifFinContratSQLElement extends AbstractCodeCommonSQLElement {
public MotifFinContratSQLElement() {
super("MOTIF_FIN_CONTRAT", "un motif de fin de contrat", "motifs de fin de contrat");
public MotifFinContratSQLElement(final DBRoot root) {
super(root.getTable("MOTIF_FIN_CONTRAT"), "un motif de fin de contrat", "motifs de fin de contrat");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeBaseAssujettieSQLElement.java
13,12 → 13,13
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
public class CodeBaseAssujettieSQLElement extends AbstractCodeCommonSQLElement {
 
public CodeBaseAssujettieSQLElement() {
super("CODE_BASE_ASSUJETTIE", "un code de base assujettie", "codes base assujettie");
public CodeBaseAssujettieSQLElement(final DBRoot root) {
super(root.getTable("CODE_BASE_ASSUJETTIE"), "un code de base assujettie", "codes base assujettie");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/TypeRubriqueNetSQLElement.java
13,10 → 13,12
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class TypeRubriqueNetSQLElement extends AbstractTypeRubriqueSQLElement {
 
public TypeRubriqueNetSQLElement() {
super("TYPE_RUBRIQUE_NET", "un type de rubrique net", "types de rubrique net");
public TypeRubriqueNetSQLElement(final DBRoot root) {
super(root.getTable("TYPE_RUBRIQUE_NET"), "un type de rubrique net", "types de rubrique net");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeDroitContratSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".rights.code";
return createCodeOfPackage() + ".rights.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratSalarieSQLElement.java
390,6 → 390,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".contract.employe";
return createCodeOfPackage() + ".contract.employe";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratRegimeMaladieSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class ContratRegimeMaladieSQLElement extends AbstractCodeCommonSQLElement {
public ContratRegimeMaladieSQLElement() {
super("CONTRAT_REGIME_MALADIE", "un régime de maladie", "régimes de maladie");
public ContratRegimeMaladieSQLElement(final DBRoot root) {
super(root.getTable("CONTRAT_REGIME_MALADIE"), "un régime de maladie", "régimes de maladie");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeEmploiSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".job.code";
return createCodeOfPackage() + ".job.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AyantDroitTypeSQLElement.java
13,14 → 13,16
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class AyantDroitTypeSQLElement extends AbstractCodeSQLElement {
 
public AyantDroitTypeSQLElement() {
super("AYANT_DROIT_TYPE", "un type d'ayant droit", "types d'ayant droit");
public AyantDroitTypeSQLElement(final DBRoot root) {
super(root.getTable("AYANT_DROIT_TYPE"), "un type d'ayant droit", "types d'ayant droit");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".type.ayantdroit";
return createCodeOfPackage() + ".type.ayantdroit";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeStatutCategorielConventionnelSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".convention.status.code";
return createCodeOfPackage() + ".convention.status.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AbstractTypeRubriqueSQLElement.java
13,9 → 13,10
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.ListMap;
 
import java.util.ArrayList;
23,12 → 24,12
 
import javax.swing.JTextField;
 
public abstract class AbstractTypeRubriqueSQLElement extends ConfSQLElement {
public abstract class AbstractTypeRubriqueSQLElement extends ComptaSQLConfElement {
 
private static final String NOM = "NOM";
 
public AbstractTypeRubriqueSQLElement(final String tableName, final String singular, final String plural) {
super(tableName, singular, plural);
public AbstractTypeRubriqueSQLElement(final SQLTable table, final String singular, final String plural) {
super(table, singular, plural);
}
 
public List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CumulsPayeSQLElement.java
162,6 → 162,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".total";
return createCodeOfPackage() + ".total";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeTypeRubriqueBrutSQLElement.java
14,9 → 14,10
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.config.DsnBrutCode;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.component.ComboLockedMode;
import org.openconcerto.ui.component.ITextCombo;
30,10 → 31,10
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class CodeTypeRubriqueBrutSQLElement extends ConfSQLElement {
public class CodeTypeRubriqueBrutSQLElement extends ComptaSQLConfElement {
 
public CodeTypeRubriqueBrutSQLElement() {
super("CODE_TYPE_RUBRIQUE_BRUT", "un code rubrique de brut", "codes rubrique de brut");
public CodeTypeRubriqueBrutSQLElement(final DBRoot root) {
super(root.getTable("CODE_TYPE_RUBRIQUE_BRUT"), "un code rubrique de brut", "codes rubrique de brut");
}
 
protected List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeContratTravailSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".contract.code";
return createCodeOfPackage() + ".contract.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/TypeRubriqueBrutSQLElement.java
13,10 → 13,12
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class TypeRubriqueBrutSQLElement extends AbstractTypeRubriqueSQLElement {
 
public TypeRubriqueBrutSQLElement() {
super("TYPE_RUBRIQUE_BRUT", "un type de rubrique brut", "types de rubrique brut");
public TypeRubriqueBrutSQLElement(final DBRoot root) {
super(root.getTable("TYPE_RUBRIQUE_BRUT"), "un type de rubrique brut", "types de rubrique brut");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/InfosSalariePayeSQLElement.java
44,7 → 44,7
public class InfosSalariePayeSQLElement extends ComptaSQLConfElement {
 
public InfosSalariePayeSQLElement() {
super("INFOS_SALARIE_PAYE", "des informations salarié-paye", "informations salariés-payes");
super("INFOS_SALARIE_PAYE", "une fiche d'informations salarié-paye", "fiches d'informations salariés-payes");
}
 
@Override
512,6 → 512,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".info";
return createCodeOfPackage() + ".info";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RegimeBaseSQLElement.java
124,6 → 124,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".base";
return createCodeOfPackage() + ".base";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueNetSQLElement.java
14,17 → 14,19
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.config.DsnBrutCode;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
import org.openconcerto.erp.core.humanresources.payroll.component.FormuleTreeNode;
import org.openconcerto.erp.core.humanresources.payroll.component.RubriqueSQLComponent;
import org.openconcerto.erp.core.humanresources.payroll.component.VariableTree;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.ListMap;
56,10 → 58,10
 
// TODO FRAIS NATURE
// FIXME rubrique.code must have a java var syntax
public class RubriqueNetSQLElement extends ConfSQLElement {
public class RubriqueNetSQLElement extends ComptaSQLConfElement {
 
public RubriqueNetSQLElement() {
super("RUBRIQUE_NET", "une rubrique de net", "rubriques de net");
public RubriqueNetSQLElement(final DBRoot root) {
super(root.getTable("RUBRIQUE_NET"), "une rubrique de net", "rubriques de net");
}
 
protected List<String> getListFields() {
282,7 → 284,7
panelProp.add(labelSelTypeRubrique, cPanel);
cPanel.anchor = GridBagConstraints.NORTHWEST;
 
ElementComboBox comboSelType = new ElementComboBox(true, 20);
SQLRequestComboBox comboSelType = new SQLRequestComboBox(true, 20);
 
cPanel.gridx++;
panelProp.add(comboSelType, cPanel);
295,7 → 297,7
panelProp.add(labelSelTypeRubriqueImpression, cPanel);
cPanel.anchor = GridBagConstraints.NORTHWEST;
 
ElementComboBox comboSelTypeImpression = new ElementComboBox(true, 20);
SQLRequestComboBox comboSelTypeImpression = new SQLRequestComboBox(true, 20);
cPanel.gridx++;
c.fill = GridBagConstraints.NONE;
c.weightx = 0;
449,9 → 451,6
this.addRequiredSQLObject(comboSelTypeImpression, "ID_IMPRESSION_RUBRIQUE");
this.addRequiredSQLObject(comboSelType, "ID_TYPE_RUBRIQUE_NET");
 
comboSelType.setButtonsVisible(false);
comboSelTypeImpression.setButtonsVisible(false);
 
selSalarie.addValueListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
// TODO Auto-generated method stub
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ModeReglementPayeSQLElement.java
56,6 → 56,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".payment.type";
return createCodeOfPackage() + ".payment.type";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ImpressionRubriqueSQLElement.java
13,9 → 13,10
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
import java.util.ArrayList;
23,9 → 24,9
 
import javax.swing.JTextField;
 
public class ImpressionRubriqueSQLElement extends ConfSQLElement {
public ImpressionRubriqueSQLElement() {
super("IMPRESSION_RUBRIQUE", "une impression de rubrique", "impressions de rubrique");
public class ImpressionRubriqueSQLElement extends ComptaSQLConfElement {
public ImpressionRubriqueSQLElement(final DBRoot root) {
super(root.getTable("IMPRESSION_RUBRIQUE"), "une impression de rubrique", "impressions de rubrique");
}
 
public List<String> getListFields() {
53,9 → 54,7
public SQLComponent createComponent() {
return new UISQLComponent(this) {
public void addViews() {
this.addRequiredSQLObject(new JTextField(), "NOM", "right");
 
this.addSQLObject(new JTextField(), "NOM", "left");
this.addRequiredSQLObject(new JTextField(), "NOM", "left");
}
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueCommSQLElement.java
13,15 → 13,17
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
import org.openconcerto.erp.core.humanresources.payroll.component.FormuleTreeNode;
import org.openconcerto.erp.core.humanresources.payroll.component.RubriqueSQLComponent;
import org.openconcerto.erp.core.humanresources.payroll.component.VariableTree;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
47,10 → 49,10
import javax.swing.SwingConstants;
import javax.swing.tree.TreePath;
 
public class RubriqueCommSQLElement extends ConfSQLElement {
public class RubriqueCommSQLElement extends ComptaSQLConfElement {
 
public RubriqueCommSQLElement() {
super("RUBRIQUE_COMM", "une rubrique de commentaire", "rubriques de commentaire");
public RubriqueCommSQLElement(final DBRoot root) {
super(root.getTable("RUBRIQUE_COMM"), "une rubrique de commentaire", "rubriques de commentaire");
}
 
protected List<String> getListFields() {
236,7 → 238,7
cPanel.weightx = 0;
panelProp.add(labelSelTypeImpression, cPanel);
 
ElementComboBox comboSelTypeImpression = new ElementComboBox(false);
SQLRequestComboBox comboSelTypeImpression = new SQLRequestComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeImpression, cPanel);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratMotifRecoursSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class ContratMotifRecoursSQLElement extends AbstractCodeCommonSQLElement {
public ContratMotifRecoursSQLElement() {
super("CONTRAT_MOTIF_RECOURS", "un motif de recours", "motifs de recours");
public ContratMotifRecoursSQLElement(final DBRoot root) {
super(root.getTable("CONTRAT_MOTIF_RECOURS"), "un motif de recours", "motifs de recours");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/SalarieSQLElement.java
225,6 → 225,13
scrollReglPaye.setBorder(null);
this.tabbedPane.add("Règlement", scrollReglPaye);
 
// Pas
this.addView("ID_PAS", REQ + ";" + DEC + ";" + SEP);
ElementSQLObject eltPas = (ElementSQLObject) this.getView("ID_PAS");
JScrollPane scrollPas = new JScrollPane(eltPas);
scrollPas.setBorder(null);
this.tabbedPane.add("PAS", scrollPas);
 
// Infos salarie-paye
this.addView("ID_INFOS_SALARIE_PAYE", REQ + ";" + DEC + ";" + SEP);
ElementSQLObject eltInfosPaye = (ElementSQLObject) this.getView("ID_INFOS_SALARIE_PAYE");
388,6 → 395,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".employe";
return createCodeOfPackage() + ".employe";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeCaisseTypeRubriqueSQLElement.java
13,11 → 13,12
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
public class CodeCaisseTypeRubriqueSQLElement extends AbstractCodeCommonSQLElement {
public CodeCaisseTypeRubriqueSQLElement() {
super("CODE_CAISSE_TYPE_RUBRIQUE", "un code rubrique de cotisation", "codes rubrique de cotisation");
public CodeCaisseTypeRubriqueSQLElement(final DBRoot root) {
super(root.getTable("CODE_CAISSE_TYPE_RUBRIQUE"), "un code rubrique de cotisation", "codes rubrique de cotisation");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ProfilPayeElementSQLElement.java
13,9 → 13,10
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.DBRoot;
 
import java.util.ArrayList;
import java.util.List;
22,9 → 23,9
 
import javax.swing.JTextField;
 
public class ProfilPayeElementSQLElement extends ConfSQLElement {
public ProfilPayeElementSQLElement() {
super("PROFIL_PAYE_ELEMENT", "un élément d'un profil de paye", "éléments de profils de paye");
public class ProfilPayeElementSQLElement extends ComptaSQLConfElement {
public ProfilPayeElementSQLElement(final DBRoot root) {
super(root.getTable("PROFIL_PAYE_ELEMENT"), "un élément d'un profil de paye", "éléments de profils de paye");
}
 
public List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeCotisationEtablissementSQLElement.java
13,17 → 13,18
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
public class CodeCotisationEtablissementSQLElement extends AbstractCodeSQLElement {
 
public CodeCotisationEtablissementSQLElement() {
super("CODE_COTISATION_ETABLISSEMENT", "un code de cotisation établissement", "codes de cotisation établissement");
public CodeCotisationEtablissementSQLElement(final DBRoot root) {
super(root.getTable("CODE_COTISATION_ETABLISSEMENT"), "un code de cotisation établissement", "codes de cotisation établissement");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cotisation.etablissement.code";
return createCodeOfPackage() + ".cotisation.etablissement.code";
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratDetacheExpatrieSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class ContratDetacheExpatrieSQLElement extends AbstractCodeCommonSQLElement {
public ContratDetacheExpatrieSQLElement() {
super("CONTRAT_DETACHE_EXPATRIE", "un détaché expatrié", "détachés expatrié");
public ContratDetacheExpatrieSQLElement(final DBRoot root) {
super(root.getTable("CONTRAT_DETACHE_EXPATRIE"), "un détaché expatrié", "détachés expatrié");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/MotifArretTravailSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class MotifArretTravailSQLElement extends AbstractCodeCommonSQLElement {
public MotifArretTravailSQLElement() {
super("MOTIF_ARRET_TRAVAIL", "un motif d'arrêt de travail", "motifs d'arrêt de travail");
public MotifArretTravailSQLElement(final DBRoot root) {
super(root.getTable("MOTIF_ARRET_TRAVAIL"), "un motif d'arrêt de travail", "motifs d'arrêt de travail");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ClassementConventionnelSQLElement.java
147,6 → 147,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".convention";
return createCodeOfPackage() + ".convention";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/VariablePayeSQLElement.java
14,6 → 14,7
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
import org.openconcerto.erp.core.humanresources.payroll.component.FormuleTreeNode;
import org.openconcerto.erp.core.humanresources.payroll.component.VariableRowTreeNode;
20,9 → 21,9
import org.openconcerto.erp.core.humanresources.payroll.component.VariableTree;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
49,9 → 50,9
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
61,6 → 62,7
import javax.swing.AbstractAction;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
74,7 → 76,7
import org.jedit.CTokenMarker;
 
// FIXME retirer le scrolling de l'edit frame pour scroller uniquement sur l'arbre des variables
public class VariablePayeSQLElement extends ConfSQLElement {
public class VariablePayeSQLElement extends ComptaSQLConfElement {
 
private final static ValidState VAR_ALREADY_EXIST = ValidState.createInvalid("Cette variable existe déjà !");
private final static ValidState VAR_NAME_NOT_CORRECT = ValidState.createInvalid("Nom de variable incorrect !");
88,8 → 90,8
return tableVarSal;
}
 
public VariablePayeSQLElement() {
super("VARIABLE_PAYE", "une variable de paye", "variables de paye");
public VariablePayeSQLElement(final DBRoot root) {
super(root.getTable("VARIABLE_PAYE"), "une variable de paye", "variables de paye");
}
 
protected List<String> getListFields() {
198,6 → 200,7
SQLTable tableVar = baseCommon.getTable("VARIABLE_PAYE");
SQLTable tableCumulsConges = base.getTable("CUMULS_CONGES");
SQLTable tableCumulsPaye = base.getTable("CUMULS_PAYE");
SQLTable tablePAS = base.getTable("PAS");
 
Map<String, List<?>> mapTree = new HashMap<String, List<?>>();
 
218,6 → 221,11
varSal.add(field);
}
 
for (SQLField field : tablePAS.getContentFields()) {
 
varSal.add(field);
}
 
mapTree.put("Infos période", varSal);
 
List<SQLField> l = new ArrayList<SQLField>();
664,21 → 672,36
// Archive la variable si elle n'est pas utilisé dans une formule
private void secureArchiveVariable(SQLRow row, boolean cutLinks) throws SQLException {
 
// FIXME verifier que la variable n'est pas utilisée dans une rubrique
if (row != null) {
SQLSelect sel = new SQLSelect();
sel.addSelect(getTable().getField("ID"));
System.err.println("Check variable");
sel.setWhere(new Where(getTable().getField("FORMULE"), "LIKE", "%" + row.getString("NOM") + "%"));
sel.andWhere(new Where(getTable().getField("ID"), "!=", row.getID()));
// Test si la variable n'est pas utilisée dans une autre variable
SQLSelect selCheckVar = new SQLSelect();
selCheckVar.addSelect(getTable().getField("ID"));
final String patternMatching = "%" + row.getString("NOM") + "%";
selCheckVar.setWhere(new Where(getTable().getField("FORMULE"), "LIKE", patternMatching));
selCheckVar.andWhere(new Where(getTable().getField("ID"), "!=", row.getID()));
String reqCheckVar = selCheckVar.asString();
List<Object> l = getTable().getBase().getDataSource().executeA(reqCheckVar);
if (l.isEmpty()) {
l = checkVariableInRubrique(patternMatching, "RUBRIQUE_BRUT", Arrays.asList("BASE", "TAUX", "MONTANT"));
if (l.isEmpty()) {
l = checkVariableInRubrique(patternMatching, "RUBRIQUE_COTISATION", Arrays.asList("BASE", "TX_SAL", "TX_PAT"));
if (l.isEmpty()) {
l = checkVariableInRubrique(patternMatching, "RUBRIQUE_NET", Arrays.asList("BASE", "TAUX", "MONTANT"));
if (l.isEmpty()) {
super.archive(new TreesOfSQLRows(this, row), true);
} else {
JOptionPane.showMessageDialog(null, "Suppression impossible, cette variable est référencée dans une rubrique de net!");
}
 
String req = sel.asString();
List l = (List) getTable().getBase().getDataSource().execute(req, new ArrayListHandler());
if (l.size() == 0) {
super.archive(new TreesOfSQLRows(this, row), true);
} else {
JOptionPane.showMessageDialog(null, "Suppression impossible, cette variable est référencée dans une rubrique de cotisation!");
}
 
} else {
JOptionPane.showMessageDialog(null, "Suppression impossible, cette variable est référencée dans une rubrique de brut!");
}
} else {
System.err.println("Suppression impossible, cette variable est référencée par une autre.");
ExceptionHandler.handle("Suppression impossible, cette variable est référencée par une autre.");
JOptionPane.showMessageDialog(null, "Suppression impossible, cette variable est référencée par une autre.");
}
 
} else {
686,6 → 709,20
}
}
 
private List checkVariableInRubrique(final String patternMatching, final String tableRub, List<String> fieldsToCheck) {
 
SQLSelect selBrut = new SQLSelect();
final SQLTable tableRubBrut = getTable().getDBRoot().findTable(tableRub);
selBrut.addSelect(tableRubBrut.getField("ID"));
for (String fieldToCheck : fieldsToCheck) {
selBrut.setWhere(new Where(tableRubBrut.getField(fieldToCheck), "LIKE", patternMatching));
}
 
String reqCheckBrut = selBrut.asString();
return getTable().getBase().getDataSource().executeA(reqCheckBrut);
 
}
 
@Override
protected String createCode() {
return "humanresources.payroll.payment.variable";
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratPrevoyanceSQLElement.java
260,4 → 260,10
}
};
}
 
@Override
protected String createCodeSuffix() {
return ".anticipation.contract";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeStatutProfSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".convention.job.code";
return createCodeOfPackage() + ".convention.job.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CumulsCongesSQLElement.java
92,6 → 92,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".vacation.total";
return createCodeOfPackage() + ".vacation.total";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/FichePayeElementSQLElement.java
77,6 → 77,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".payslip.item";
return createCodeOfPackage() + ".payslip.item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodePenibiliteSQLElement.java
13,17 → 13,18
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
public class CodePenibiliteSQLElement extends AbstractCodeSQLElement {
 
public CodePenibiliteSQLElement() {
super("CODE_PENIBILITE", "un code de pénibilité", "codes de pénibilité");
public CodePenibiliteSQLElement(final DBRoot root) {
super(root.getTable("CODE_PENIBILITE"), "un code de pénibilité", "codes de pénibilité");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cotisation.penibilite.code";
return createCodeOfPackage() + ".cotisation.penibilite.code";
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/TypeTauxPasSQLElement.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.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
public class TypeTauxPasSQLElement extends AbstractCodeCommonSQLElement {
 
public TypeTauxPasSQLElement(final DBRoot root) {
super(root.getTable("TYPE_TAUX_PAS"), "un type de taux de PAS", "types de taux de PAS");
}
 
@Override
protected String createCode() {
return "humanresources.type.pas.code";
 
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "CODE");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AcompteSQLElement.java
37,7 → 37,7
public class AcompteSQLElement extends ComptaSQLConfElement {
 
public AcompteSQLElement() {
super("ACOMPTE", "un acompte", "acompte");
super("ACOMPTE", "un acompte", "acomptes");
}
 
protected List<String> getListFields() {
129,6 → 129,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".advance";
return createCodeOfPackage() + ".advance";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/FichePayeSQLElement.java
164,22 → 164,23
 
this.setLayout(new GridBagLayout());
 
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Tree elt Fiche de Paye On the left
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
c.gridheight = GridBagConstraints.REMAINDER;
final RubriquePayeTree tree = new RubriquePayeTree();
tree.expandRow(0);
JPanel panelLeft = new JPanel(new GridBagLayout());
GridBagConstraints cLeft = new DefaultGridBagConstraints();
cLeft.fill = GridBagConstraints.BOTH;
cLeft.weightx = 1;
cLeft.weighty = 1;
cLeft.gridheight = GridBagConstraints.REMAINDER;
panelLeft.add(tree, cLeft);
this.paneTreeLeft = new JScrollPane(tree);
// this.add(this.paneTreeLeft, c);
 
// Panel Fiche paye on the right
// Salarie
JPanel panelRight = new JPanel();
panelRight.setLayout(new GridBagLayout());
JPanel panelRight = new JPanel(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
// Tree elt Fiche de Paye On the left
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.weighty = 0;
190,13 → 191,7
panelRight.add(this.selSalCombo, c);
 
// Mois
c.gridy++;
// c.gridx++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.weighty = 0;
c.gridheight = 1;
c.gridwidth = 3;
 
JLabel labelMois = new JLabel("Fiche de paye du mois de");
this.selMois = new ElementComboBox(true, 20);
JLabel labelDu = new JLabel("Du");
208,40 → 203,63
JLabel labelAnnee = new JLabel("Année");
this.textAnnee = new JTextField();
{
this.pDate = new JPanel();
this.pDate = new JPanel(new GridBagLayout());
GridBagConstraints cDate = new DefaultGridBagConstraints();
cDate.weightx = 0;
cDate.gridx = GridBagConstraints.RELATIVE;
this.pDate.setOpaque(false);
this.pDate.add(labelMois);
this.pDate.add(this.selMois);
this.pDate.add(labelAnnee);
this.pDate.add(this.textAnnee);
this.pDate.add(labelDu);
this.pDate.add(this.dateDu);
this.pDate.add(labelAu);
this.pDate.add(this.dateAu);
this.pDate.add(labelMois, cDate);
cDate.weightx = 1;
this.pDate.add(this.selMois, cDate);
cDate.weightx = 0;
this.pDate.add(labelAnnee, cDate);
cDate.weightx = 1;
this.pDate.add(this.textAnnee, cDate);
cDate.weightx = 0;
this.pDate.add(labelDu, cDate);
cDate.weightx = 0;
this.pDate.add(this.dateDu, cDate);
cDate.weightx = 0;
this.pDate.add(labelAu, cDate);
cDate.weightx = 0;
this.pDate.add(this.dateAu, cDate);
 
c.gridy++;
// c.gridx++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.weighty = 0;
c.gridheight = 1;
c.gridwidth = 2;
panelRight.add(this.pDate, c);
}
c.gridx += 2;
c.weightx = 1;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
panelRight.add(new JPanel(), c);
// c.gridx += 2;
// c.weightx = 1;
// c.gridwidth = 1;
// c.fill = GridBagConstraints.HORIZONTAL;
// panelRight.add(new JPanel(), c);
 
// Action Button
c.gridx++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0;
c.weighty = 0;
 
JPanel pButtons = new JPanel();
JPanel pButtons = new JPanel(new GridBagLayout());
pButtons.setOpaque(false);
JButton buttonUp = new JNiceButton(IListFrame.class.getResource("fleche_haut.png"));
JButton buttonDown = new JNiceButton(IListFrame.class.getResource("fleche_bas.png"));
JButton buttonRemove = new JNiceButton(SQLComponent.class.getResource("delete.png"));
{
pButtons.add(buttonUp);
pButtons.add(buttonDown);
pButtons.add(buttonRemove);
GridBagConstraints cButtons = new DefaultGridBagConstraints();
cButtons.weightx = 0;
cButtons.fill = GridBagConstraints.NONE;
cButtons.gridx = GridBagConstraints.RELATIVE;
pButtons.add(buttonUp, cButtons);
pButtons.add(buttonDown, cButtons);
pButtons.add(buttonRemove, cButtons);
}
c.gridx += 2;
c.fill = GridBagConstraints.NONE;
c.weightx = 0;
c.weighty = 0;
c.gridwidth = 1;
panelRight.add(pButtons, c);
 
// Table
248,7 → 266,7
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
c.gridx = 1;
c.gridx = 0;
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
this.model = new FichePayeModel(1);
259,21 → 277,21
table.setDefaultRenderer(Float.class, rend);
 
// Import profil
c.gridx = 1;
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.weighty = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
JLabel labelProfil = new JLabel("Importer depuis un profil prédéfini");
JLabel labelProfil = new JLabel("Lié à un profil prédéfini");
panelRight.add(labelProfil, c);
c.gridwidth = 1;
 
this.comboSelProfil = new ElementComboBox();
// this.comboSelProfil = new ElementComboBox();
this.comboSelProfil.setListIconVisible(false);
c.gridx++;
c.gridwidth = 1;
c.weightx = 1;
 
// this.comboSelProfil.init(eltProfil.getTable().getField("NOM"), null);
panelRight.add(this.comboSelProfil, c);
280,12 → 298,13
 
JButton buttonImportProfil = new JButton("Importer");
c.gridx++;
c.weightx = 0;
panelRight.add(buttonImportProfil, c);
 
// Total Periode
JPanel panelTotal = new JPanel();
JPanel panelTotal = new JPanel(new GridBagLayout());
panelTotal.setBorder(BorderFactory.createTitledBorder("Total période"));
panelTotal.setLayout(new GridBagLayout());
 
GridBagConstraints cPanel = new DefaultGridBagConstraints();
 
JLabel labelInfosConges = new JLabel(getLabelFor("DETAILS_CONGES"));
389,8 → 408,11
textCice.setEnabled(false);
this.addSQLObject(textCice, "CICE");
 
c.gridx = 1;
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.weighty = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
panelRight.add(panelTotal, c);
 
408,14 → 430,15
this.buttonGenCompta = new JButton("Generer la comptabilité");
// panelRight.add(buttonGenCompta, c);
 
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 1;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), c);
GridBagConstraints cGlobal = new DefaultGridBagConstraints();
cGlobal.gridx = 0;
cGlobal.gridy = 0;
cGlobal.gridwidth = 1;
cGlobal.gridheight = 1;
cGlobal.fill = GridBagConstraints.BOTH;
cGlobal.weightx = 1;
cGlobal.weighty = 1;
this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), cGlobal);
 
// Listeners
this.buttonGenCompta.addActionListener(new ActionListener() {
742,11 → 765,12
 
// Calcul des congés
SQLRow rowCumulConge = rowSal.getForeignRow("ID_CUMULS_CONGES");
SQLRow rowVarSal = row.getForeignRow("ID_VARIABLE_SALARIE");
SQLRow rowVarSalFiche = row.getForeignRow("ID_VARIABLE_SALARIE");
SQLRow rowVarSal = rowSal.getForeignRow("ID_VARIABLE_SALARIE");
float congeCumule = rowCumulConge.getFloat("ACQUIS");
float congeRestant = rowCumulConge.getFloat("RESTANT");
 
float prisPeriode = rowVarSal.getFloat("CONGES_PRIS");
float prisPeriode = rowVarSalFiche.getFloat("CONGES_PRIS");
 
congeRestant += prisPeriode;
congeCumule -= row.getFloat("CONGES_ACQUIS");
761,6 → 785,23
e.printStackTrace();
}
 
// Annulation du cumul des variables
final SQLRowValues rowVals = rowVarSal.asRowValues();
for (final SQLField field : rowVarSalFiche.getTable().getContentFields()) {
if (!field.getName().endsWith("_DEFAULT_VAL") && !field.getName().endsWith("_CUMUL_VAL")) {
if (rowVarSalFiche.getTable().contains(field.getName() + "_CUMUL_VAL")) {
final float valPeriode = rowVarSalFiche.getObject(field.getName()) == null ? 0.0F : rowVarSalFiche.getFloat(field.getName());
final float valCumul = rowVarSal.getObject(field.getName() + "_CUMUL_VAL") == null ? 0.0F : rowVarSal.getFloat(field.getName() + "_CUMUL_VAL");
rowVals.put(field.getName() + "_CUMUL_VAL", valCumul - valPeriode);
}
 
}
}
try {
rowVals.update();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
958,7 → 999,12
// Remise à 0 des variables sal
final SQLRowValues rowVals = new SQLRowValues(tableVariableSal);
for (final SQLField field : tableVariableSal.getContentFields()) {
if (!field.getName().endsWith("_DEFAULT_VAL")) {
if (!field.getName().endsWith("_DEFAULT_VAL") && !field.getName().endsWith("_CUMUL_VAL")) {
if (tableVariableSal.contains(field.getName() + "_CUMUL_VAL")) {
final float valPeriode = rowVarSal.getObject(field.getName()) == null ? 0.0F : rowVarSal.getFloat(field.getName());
final float valCumul = rowVarSal.getObject(field.getName() + "_CUMUL_VAL") == null ? 0.0F : rowVarSal.getFloat(field.getName() + "_CUMUL_VAL");
rowVals.put(field.getName() + "_CUMUL_VAL", valCumul + valPeriode);
}
if (tableVariableSal.contains(field.getName() + "_DEFAULT_VAL")) {
rowVals.put(field.getName(), rowVarSal.getObject(field.getName() + "_DEFAULT_VAL"));
} else {
968,6 → 1014,7
rowVals.put(field.getName(), Float.valueOf(0));
}
}
 
}
}
rowVals.put("HEURE_TRAV", rowSalInfosPaye.getObject("DUREE_MOIS"));
1025,7 → 1072,7
final SQLRow rowSal = rowFiche.getForeignRow("ID_SALARIE");
 
final SQLRowValues rowValsFiche = new SQLRowValues(tableFiche);
for (final String fk : Arrays.asList("ID_VARIABLE_SALARIE", "ID_CUMULS_CONGES", "ID_CUMULS_PAYE", "ID_REGLEMENT_PAYE")) {
for (final String fk : Arrays.asList("ID_PAS", "ID_VARIABLE_SALARIE", "ID_CUMULS_CONGES", "ID_CUMULS_PAYE", "ID_REGLEMENT_PAYE")) {
final SQLRow fRow = rowSal.getForeignRow(fk);
final SQLRowValues copy = dir.getElement(fRow.getTable()).createCopy(fRow, null);
// make sure the copy will be inserted by the update()
1075,6 → 1122,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".payslip";
return createCodeOfPackage() + ".payslip";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/TypeComposantBaseAssujettieSQLElement.java
13,17 → 13,18
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
public class TypeComposantBaseAssujettieSQLElement extends AbstractCodeSQLElement {
 
public TypeComposantBaseAssujettieSQLElement() {
super("TYPE_COMPOSANT_BASE_ASSUJETTIE", "un type de composant de base assujettie", "types de composant de base assujettie");
public TypeComposantBaseAssujettieSQLElement(final DBRoot root) {
super(root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE"), "un type de composant de base assujettie", "types de composant de base assujettie");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".composant.base.type";
return createCodeOfPackage() + ".composant.base.type";
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratModaliteTempsSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class ContratModaliteTempsSQLElement extends AbstractCodeCommonSQLElement {
public ContratModaliteTempsSQLElement() {
super("CONTRAT_MODALITE_TEMPS", "une modalité de temps", "modalité de temps");
public ContratModaliteTempsSQLElement(final DBRoot root) {
super(root.getTable("CONTRAT_MODALITE_TEMPS"), "une modalité de temps", "modalité de temps");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeRegimeSQLElement.java
21,6 → 21,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".governement.code";
return createCodeOfPackage() + ".governement.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/DSNNatureSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class DSNNatureSQLElement extends AbstractCodeCommonSQLElement {
public DSNNatureSQLElement() {
super("DSN_NATURE", "une nature de DSN", "natures de DSN");
public DSNNatureSQLElement(final DBRoot root) {
super(root.getTable("DSN_NATURE"), "une nature de DSN", "natures de DSN");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratDispositifPolitiqueSQLElement.java
13,9 → 13,11
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class ContratDispositifPolitiqueSQLElement extends AbstractCodeCommonSQLElement {
public ContratDispositifPolitiqueSQLElement() {
super("CONTRAT_DISPOSITIF_POLITIQUE", "un dispositif politique", "dispositifs politique");
public ContratDispositifPolitiqueSQLElement(final DBRoot root) {
super(root.getTable("CONTRAT_DISPOSITIF_POLITIQUE"), "un dispositif politique", "dispositifs politique");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeCotisationIndividuelleSQLElement.java
13,17 → 13,18
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.utils.ListMap;
 
public class CodeCotisationIndividuelleSQLElement extends AbstractCodeSQLElement {
 
public CodeCotisationIndividuelleSQLElement() {
super("CODE_COTISATION_INDIVIDUELLE", "un code de cotisation individuelle", "codes de cotisation individuelle");
public CodeCotisationIndividuelleSQLElement(final DBRoot root) {
super(root.getTable("CODE_COTISATION_INDIVIDUELLE"), "un code de cotisation individuelle", "codes de cotisation individuelle");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cotisation.individuelle.code";
return createCodeOfPackage() + ".cotisation.individuelle.code";
}
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AyantDroitContratPrevSQLElement.java
54,7 → 54,7
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".contrat.ayantdroit";
return createCodeOfPackage() + ".contrat.ayantdroit";
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AbstractCodeCommonSQLElement.java
13,9 → 13,10
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
26,10 → 27,10
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public abstract class AbstractCodeCommonSQLElement extends ConfSQLElement {
public abstract class AbstractCodeCommonSQLElement extends ComptaSQLConfElement {
 
public AbstractCodeCommonSQLElement(final String tableName, final String singular, final String plural) {
super(tableName, singular, plural);
public AbstractCodeCommonSQLElement(final SQLTable table, final String singular, final String plural) {
super(table, singular, plural);
}
 
protected List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/LignePayeSimplifiee.java
22,8 → 22,8
 
SANTE_SECURITE("sante.securite"), SANTE_COMPLEMENAIRE_DECES("sante.complementaire.deces"), SANTE_COMPLEMENAIRE_SANTE("sante.complementaire.sante"), ACCIDENTS_TRAVAIL(
"accident.accident"), RETRAITE_SECURITE_PLAF("retraite.securite.plaf"), RETRAITE_SECURITE_NON_PLAF("retraite.securite.non.plaf"), RETRAITE_COMPLEMENTAIRE_T1(
"retraite.tranche1"), RETRAITE_COMPLEMENTAIRE_T2("retraite.tranche2"), RETRAITE_COMPLEMENTAIRE_TA("retraite.trancheA"), RETRAITE_COMPLEMENTAIRE_GMP(
"retraite.GMP"), RETRAITE_COMPLEMENTAIRE_TB("retraite.trancheB"), RETRAITE_COMPLEMENTAIRE_TC("retraite.trancheC"), RETRAITE_SUPPLEMENTAIRE(
"retraite.tranche1"), RETRAITE_COMPLEMENTAIRE_T2("retraite.tranche2"), RETRAITE_COMPLEMENTAIRE_TA_2019_REMOVE("retraite.trancheA"), RETRAITE_COMPLEMENTAIRE_GMP_2019_REMOVE(
"retraite.GMP"), RETRAITE_COMPLEMENTAIRE_TB_2019_REMOVE("retraite.trancheB"), RETRAITE_COMPLEMENTAIRE_TC_2019_REMOVE("retraite.trancheC"), RETRAITE_SUPPLEMENTAIRE(
"retraite.supplementaire"), FAMILLE_ALLOCATIONS("famille.famille.allocations"), ASSURANCE_CHOMAGE_CHOMAGE("chomage.chomage"), ASSURANCE_CHOMAGE_APEC(
"chomage.apec"), COTISATIONS_STATUAIRES("cotisations.statuaires.ligne"), AUTRES_CONTRIBUTIONS("autres.contributions.ligne"), CSG_NON_IMP(
"csg.nonimp.ligne"), CSG_IMP("csg.imp.ligne"), ALLEGEMENT_COTISATIONS("allegement.cotisations.ligne"), IGNORE("paye.simplifie.ignore");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/FichePayeSheetXML.java
210,7 → 210,7
SQLRowValues rowValsCotis = new SQLRowValues(tableFichePayeElt);
 
rowValsCotis.put("ID_STYLE", eltStyle.getAllStyleByName().get("Titre 2"));
rowValsCotis.put("NOM", "Cotisations sociales");
rowValsCotis.put("NOM", "Cotisations et contributions sociales");
// rowValsCotis.put("NB_BASE", BigDecimal.ZERO);
// rowValsCotis.put("TAUX_SAL", BigDecimal.ZERO);
// rowValsCotis.put("MONTANT_SAL_AJ", BigDecimal.ZERO);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/GroupePayeSimplifiee.java
25,18 → 25,18
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_TA,
LignePayeSimplifiee.RETRAITE_COMPLEMENTAIRE_GMP, LignePayeSimplifiee.RETRAITE_COMPLEMENTAIRE_TB, LignePayeSimplifiee.RETRAITE_COMPLEMENTAIRE_TC,
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));
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;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/LignePayeSimplifieeComboBox.java
28,7 → 28,7
import javax.swing.JComboBox;
import javax.swing.JComponent;
 
public class LignePayeSimplifieeComboBox extends JComboBox implements ValueWrapper<LignePayeSimplifiee>, Documented, RowItemViewComponent {
public class LignePayeSimplifieeComboBox extends JComboBox<LignePayeSimplifiee> implements ValueWrapper<LignePayeSimplifiee>, Documented, RowItemViewComponent {
private final ValueChangeSupport<LignePayeSimplifiee> supp;
 
public LignePayeSimplifieeComboBox() {
43,7 → 43,9
});
 
for (LignePayeSimplifiee etat : LignePayeSimplifiee.values()) {
addItem(etat);
if (!etat.name().endsWith("_REMOVE")) {
addItem(etat);
}
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/timesheet/element/PointageSQLElement.java
13,9 → 13,10
package org.openconcerto.erp.core.humanresources.timesheet.element;
 
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.JDate;
 
24,10 → 25,10
 
import javax.swing.JTextField;
 
public class PointageSQLElement extends ConfSQLElement {
public class PointageSQLElement extends ComptaSQLConfElement {
 
public PointageSQLElement() {
super("POINTAGE", "un pointage", "pointages");
public PointageSQLElement(final DBRoot root) {
super(root.getTable("POINTAGE"));
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/SituationFamilialeSQLElement.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/element/SituationFamilialeSQLElement.java
New file
0,0 → 1,75
/*
* 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.employe.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class SituationFamilialeSQLElement extends ComptaSQLConfElement {
 
public SituationFamilialeSQLElement() {
super("SITUATION_FAMILIALE", "une situation familiale", "Situations familiale");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
public void addViews() {
 
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridx = GridBagConstraints.RELATIVE;
 
JTextField textNom = new JTextField();
JLabel labelNom = new JLabel(getLabelFor("NOM"));
 
this.add(labelNom, c);
this.add(textNom, c);
 
this.addSQLObject(textNom, "NOM");
}
};
}
 
@Override
protected String createCodeSuffix() {
return ".family.situation";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/element/CommercialSQLComponent.java
240,6 → 240,24
ElementComboBox comboUser = new ElementComboBox(true, 25);
panelInfos.add(comboUser, c);
 
if (getTable().contains("ID_POLE_PRODUIT")) {
 
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
c.weightx = 0;
final JLabel labelPoleProduit = new JLabel(getLabelFor("ID_POLE_PRODUIT"));
labelPoleProduit.setHorizontalAlignment(SwingConstants.RIGHT);
panelInfos.add(labelPoleProduit, c);
c.gridx++;
c.weightx = 1;
 
c.gridwidth = GridBagConstraints.REMAINDER;
ElementComboBox comboPole = new ElementComboBox(true, 25);
panelInfos.add(comboPole, c);
this.addView(comboPole, "ID_POLE_PRODUIT");
}
 
c.weighty = 1;
c.gridy++;
JPanel panelLayouter = new JPanel();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/element/EtatCivilSQLElement.java
285,6 → 285,19
c.gridwidth = 1;
c.weightx = 0;
 
c.weightx = 0;
c.gridwidth = 1;
c.gridx++;
panelSituation.add(new JLabel(getLabelFor("NTT"), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = 1;
c.weightx = 1;
JTextField fieldNTT = new JTextField();
panelSituation.add(fieldCNPS, c);
c.weightx = 0;
c.gridwidth = 1;
addView(fieldNTT, "NTT");
 
// Nombre d'enfants
JLabel labelNombreEnfants = new JLabel(getLabelFor("NB_ENFANTS"));
labelNombreEnfants.setHorizontalAlignment(SwingConstants.RIGHT);
509,6 → 522,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".info";
return this.createCodeOfPackage() + ".info";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/element/ObjectifSQLElement.java
69,4 → 69,10
}
};
}
 
@Override
protected String createCodeSuffix() {
return ".commercial.goal";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/element/CommercialSQLElement.java
23,7 → 23,7
public class CommercialSQLElement extends ComptaSQLConfElement {
 
public CommercialSQLElement() {
super("COMMERCIAL", "un commercial", "commerciaux");
super("COMMERCIAL");
}
 
public CommercialSQLElement(String tableName, String singular, String plural) {
37,6 → 37,9
l.add("FONCTION");
l.add("TEL_STANDARD");
l.add("TEL_DIRECT");
if (getTable().contains("ID_POLE_PRODUIT")) {
l.add("ID_POLE_PRODUIT");
}
return l;
}
 
66,6 → 69,6
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".salesman";
return this.createCodeOfPackage() + ".salesman";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/report/N4DS.java
91,7 → 91,7
 
final SQLElement infosElt = eltSalarie.getForeignElement("ID_INFOS_SALARIE_PAYE");
// Date d1 = new Date(116, 0, 1);
Date d2 = new Date(116, 11, 31);
Date d2 = new Date(117, 11, 31);
 
Where w = new Where(infosElt.getTable().getKey(), "=", eltSalarie.getTable().getField("ID_INFOS_SALARIE_PAYE"));
w = w.and(new Where(infosElt.getTable().getField("DATE_ARRIVE"), "<=", d2));
186,7 → 186,7
write("S80.G01.00.006", rowSociete.getString("NUM_APE"));
 
// FIXME Code section prud'homale
write("S80.G01.00.007.001", "04");
// write("S80.G01.00.007.001", "04");
 
// TODO stecion principale dérogatoire
// write( "S80.G01.00.004.001", "2");
243,7 → 243,7
SQLSelect sel = new SQLSelect();
sel.addSelect(eltSalarie.getTable().getKey());
// Date d1 = new Date(116, 0, 1);
Date d2 = new Date(116, 11, 31);
Date d2 = new Date(117, 11, 31);
Where w = new Where(eltSalarie.getTable().getField("ID_INFOS_SALARIE_PAYE"), "=", eltInfos.getTable().getKey());
w = w.and(new Where(eltInfos.getTable().getField("DATE_SORTIE"), "=", (Date) null).or(new Where(eltInfos.getTable().getField("DATE_SORTIE"), "<=", d2)));
w = w.and(new Where(eltInfos.getTable().getField("DATE_ARRIVE"), "=", (Date) null).or(new Where(eltInfos.getTable().getField("DATE_ARRIVE"), "<=", d2)));
279,10 → 279,10
write("S20.G01.00.002", normalizeString2(rowSociete.getString("NOM")));
 
// FIXME Debut periode
write("S20.G01.00.003.001", "01012016");
write("S20.G01.00.003.001", "01012017");
 
// FIXME Fin periode
write("S20.G01.00.003.002", "31122016");
write("S20.G01.00.003.002", "31122017");
 
// Code nature
write("S20.G01.00.004.001", "01");
422,7 → 422,7
write("S10.G01.00.010", "02");
 
// Norme utilisée
write("S10.G01.00.011", "V01X11");
write("S10.G01.00.011", "V01X12");
 
// Code table char
write("S10.G01.00.012", "01");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/report/N4DSSalarie.java
43,8 → 43,8
private ComptaPropsConfiguration conf = ((ComptaPropsConfiguration) Configuration.getInstance());
private N4DS n4ds;
 
Date d = new Date(116, 0, 1);
Date d2 = new Date(116, 11, 31);
Date d = new Date(117, 0, 1);
Date d2 = new Date(117, 11, 31);
 
DecimalFormat decimalFormat = new DecimalFormat("0.00");
 
63,7 → 63,7
writeS44(row);
writeS45(row);
writeS48(row);
writeS65(row);
//writeS65(row);
}
 
private void writeS45(final SQLRow rowSalarie) throws IOException {
268,8 → 268,8
n4ds.write("S40.G10.05.012.001", rowCodeContrat.getString("CODE"));
 
// code droit contrat
SQLRow rowCodeDroitContrat = rowContrat.getForeignRow("ID_CODE_DROIT_CONTRAT");
n4ds.write("S40.G10.05.012.002", rowCodeDroitContrat.getString("CODE"));
// SQLRow rowCodeDroitContrat = rowContrat.getForeignRow("ID_CODE_DROIT_CONTRAT");
// n4ds.write("S40.G10.05.012.002", rowCodeDroitContrat.getString("CODE"));
 
// Code intitulé du contrat de travail
n4ds.write("S40.G10.05.012.003", "90");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/action/NouveauCommercialAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/action/NouveauSalarieAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/Attachment.java
15,6 → 15,7
 
import org.openconcerto.sql.model.SQLRowValues;
 
import java.io.File;
import java.io.Serializable;
 
public class Attachment implements Serializable {
37,7 → 38,7
this.mimeType = rowAttachment.getString("MIMETYPE");
this.fileName = rowAttachment.getString("FILENAME");
this.fileSize = rowAttachment.getInt("FILESIZE");
this.storagePath = rowAttachment.getString("STORAGE_PATH");
this.storagePath = rowAttachment.getString("STORAGE_PATH").replace('\\', File.separatorChar);
this.storageFileName = rowAttachment.getString("STORAGE_FILENAME");
this.sourceTable = rowAttachment.getString("SOURCE_TABLE");
this.sourceId = rowAttachment.getInt("SOURCE_ID");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentUtils.java
13,18 → 13,6
package org.openconcerto.erp.core.edm;
 
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
 
import javax.swing.JOptionPane;
 
import eu.medsea.mimeutil.MimeType;
import eu.medsea.mimeutil.MimeUtil;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
import org.openconcerto.erp.storage.StorageEngine;
37,6 → 25,16
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.sync.SyncClient;
 
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.sql.SQLException;
import java.util.List;
 
import javax.swing.JOptionPane;
 
public class AttachmentUtils {
 
public void uploadFile(File inFile, SQLRowAccessor rowSource, int idParent) {
51,7 → 49,7
int id = rowAttachment.getID();
 
final String folderId = String.valueOf((id / 1000) * 1000);
String subDir = "EDM" + File.separator + folderId;
String subDir = "EDM/" + folderId;
String fileNameID = String.valueOf(id);
String ext = "";
 
68,7 → 66,6
if (isOnCloud) {
 
String remotePath = subDir;
remotePath = remotePath.replace('\\', '/');
List<StorageEngine> engines = StorageEngines.getInstance().getActiveEngines();
for (StorageEngine storageEngine : engines) {
if (storageEngine.isConfigured() && storageEngine.allowAutoStorage()) {
124,13 → 121,8
rowValsAttachment.put("NAME", name);
rowValsAttachment.put("SOURCE_TABLE", rowSource.getTable().getName());
rowValsAttachment.put("SOURCE_ID", rowSource.getID());
Collection<MimeType> mimeTypes = MimeUtil.getMimeTypes(inFile);
if (mimeTypes != null && !mimeTypes.isEmpty()) {
final MimeType mimeType = (MimeType) mimeTypes.toArray()[0];
rowValsAttachment.put("MIMETYPE", mimeType.getMediaType() + "/" + mimeType.getSubType());
} else {
rowValsAttachment.put("MIMETYPE", "application/octet-stream");
}
final String mimeType = Files.probeContentType(inFile.toPath());
rowValsAttachment.put("MIMETYPE", mimeType != null ? mimeType : "application/octet-stream");
rowValsAttachment.put("FILENAME", fileName);
rowValsAttachment.put("FILESIZE", inFile.length());
rowValsAttachment.put("STORAGE_PATH", subDir);
189,17 → 181,24
// Get file out
File dirRoot = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(AttachmentSQLElement.DIRECTORY_PREFS);
File storagePathFile = new File(dirRoot, subDir);
File fileIn = new File(storagePathFile, fileName);
if (fileIn.exists()) {
final File outFile = new File(f, fileName);
try {
FileUtils.copyFile(fileIn, outFile);
} catch (IOException e) {
ExceptionHandler.handle("Impossible de copier le fichier vers le fichier temporaire de réception", e);
File fileIn;
try {
fileIn = new File(storagePathFile, fileName).getCanonicalFile();
if (fileIn.exists()) {
final File outFile = new File(f, fileName);
try {
FileUtils.copyFile(fileIn, outFile);
} catch (IOException e) {
ExceptionHandler.handle("Impossible de copier le fichier vers le fichier temporaire de réception", e);
return null;
}
} else {
JOptionPane.showMessageDialog(null, "Le fichier n'existe pas sur le serveur!\n" + fileIn.getAbsolutePath(), "Erreur fichier", JOptionPane.ERROR_MESSAGE);
return null;
}
} else {
JOptionPane.showMessageDialog(null, "Le fichier n'existe pas sur le serveur!", "Erreur fichier", JOptionPane.ERROR_MESSAGE);
} catch (IOException e1) {
ExceptionHandler.handle("Impossible de trouver le fichier\n" + storagePathFile + File.pathSeparator + fileName, e1);
return null;
}
}
final File outFile = new File(f, fileName);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentSQLElement.java
13,13 → 13,13
package org.openconcerto.erp.core.edm;
 
import java.util.ArrayList;
import java.util.List;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
 
import java.util.ArrayList;
import java.util.List;
 
public class AttachmentSQLElement extends ComptaSQLConfElement {
 
public static final String DIRECTORY_PREFS = "EDMdirectory";
64,6 → 64,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".attachment";
return "edm.attachment";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/tasks/planning/element/TacheSQLElement.java
13,7 → 13,7
package org.openconcerto.erp.core.tasks.planning.element;
 
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
 
22,7 → 22,7
 
import javax.swing.JTextField;
 
public class TacheSQLElement extends ConfSQLElement {
public class TacheSQLElement extends ComptaSQLConfElement {
 
public TacheSQLElement() {
super("TACHE_COMMON", "une tache", "taches");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/price/element/TarifSQLElement.java
103,4 → 103,10
}
};
}
 
@Override
protected String createCodeSuffix() {
return ".list";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/price/element/DeviseSQLElement.java
13,10 → 13,9
package org.openconcerto.erp.core.sales.price.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.finance.accounting.model.Currency;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.ui.DefaultGridBagConstraints;
32,16 → 31,12
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class DeviseSQLElement extends ConfSQLElement {
public class DeviseSQLElement extends ComptaSQLConfElement {
 
public DeviseSQLElement(DBRoot root) {
super(root.getTable("DEVISE"), "une devise", "devises");
}
 
public DeviseSQLElement() {
this(Configuration.getInstance().getRoot());
}
 
@Override
public boolean isShared() {
return true;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/element/TransferShipmentSQLElement.java
43,6 → 43,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".transfer";
return createCodeOfPackage() + ".transfer";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/element/BonDeLivraisonItemSQLElement.java
39,6 → 39,7
final List<String> l = new ArrayList<String>();
l.add("CODE");
l.add("NOM");
l.add("PA_HT");
l.add("PV_HT");
l.add("QTE");
l.add("QTE_LIVREE");
45,6 → 46,8
l.add("QTE_A_LIVRER");
l.add("ID_TAXE");
l.add("POIDS");
l.add("T_PA_HT");
l.add("T_PV_HT");
return l;
}
 
117,6 → 120,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".item";
return createCodeOfPackage() + ".item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/element/BonDeLivraisonSQLElement.java
26,18 → 26,26
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.SQLName;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.ListMap;
 
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
public class BonDeLivraisonSQLElement extends ComptaSQLConfElement {
50,7 → 58,7
}
 
public BonDeLivraisonSQLElement() {
this("un bon de livraison", "Bons de livraison");
this("un bon de livraison", "bons de livraison");
}
 
@Override
64,8 → 72,9
}
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
final List<String> l = new ArrayList<>();
l.add("NUMERO");
l.add("DATE");
l.add("ID_CLIENT");
80,8 → 89,9
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
final List<String> l = new ArrayList<>(2);
l.add("NUMERO");
l.add("DATE");
return l;
101,38 → 111,43
return new BonDeLivraisonSQLComponent();
}
 
public List<Object> getCmdClientFrom(int blOrigin) {
public List<Object> getSourceTrRowsFrom(int blOrigin, String tableSourceItems, String tableSourceRoot) {
SQLTable tableBLElement = getTable().getTable("BON_DE_LIVRAISON_ELEMENT");
SQLTable tableCmdElement = getTable().getTable("COMMANDE_CLIENT_ELEMENT");
String up = "SELECT DISTINCT c2.\"ID_COMMANDE_CLIENT\" FROm " + new SQLName(tableBLElement.getDBRoot().getName(), tableBLElement.getName()).quote() + " b2, "
SQLTable tableCmdElement = getTable().getTable(tableSourceItems);
String idRoot = "c2.\"" + getTable().getTable(tableSourceRoot).getKey().getFieldName() + "\"";
String up = "SELECT DISTINCT c2.\"ID_" + tableSourceRoot + "\" FROm " + new SQLName(tableBLElement.getDBRoot().getName(), tableBLElement.getName()).quote() + " b2, "
+ new SQLName(tableCmdElement.getDBRoot().getName(), tableCmdElement.getName()).quote() + " c2 WHERE b2.\"ID_BON_DE_LIVRAISON\"=" + blOrigin
+ " AND c2.\"ARCHIVE\"=0 AND b2.\"ARCHIVE\"=0 AND c2.\"ID\">1 AND b2.\"ID\">1 AND b2.\"ID_COMMANDE_CLIENT_ELEMENT\"=c2.\"ID\"";
List<Object> cmds = getTable().getDBSystemRoot().getDataSource().executeCol(up);
return cmds;
+ " AND c2.\"ARCHIVE\"=0 AND b2.\"ARCHIVE\"=0 AND " + idRoot + ">1 AND b2.\"ID\">1 AND b2.\"ID_" + tableSourceItems + "\"=" + idRoot;
return getTable().getDBSystemRoot().getDataSource().executeCol(up);
}
 
public void updateCmdClientElement(List<Object> cmds, int idblOrigin) {
SQLTable tableBLElement = getTable().getTable("BON_DE_LIVRAISON_ELEMENT");
SQLTable tableCmdElement = getTable().getTable("COMMANDE_CLIENT_ELEMENT");
UpdateBuilder build = new UpdateBuilder(tableCmdElement);
build.set("QTE_LIVREE", "(SELECT SUM(b.\"QTE_LIVREE\" * b.\"QTE_UNITAIRE\") from " + new SQLName(tableBLElement.getDBRoot().getName(), tableBLElement.getName()).quote()
+ " b where c.\"ID\"=b.\"ID_COMMANDE_CLIENT_ELEMENT\" AND c.\"ID\">1 AND c.\"ARCHIVE\"=0 AND b.\"ID\">1 AND b.\"ARCHIVE\"=0 )");
AliasedTable alias = new AliasedTable(tableCmdElement, "c");
build.setWhere(new Where(alias.getField("ID_COMMANDE_CLIENT"), cmds));
public void updateQteLivree(List<Object> items, String tableItems, String tableRoot) {
if (items != null && !items.isEmpty()) {
SQLTable tableBLElement = getTable().getTable("BON_DE_LIVRAISON_ELEMENT");
SQLTable tableCmdElement = getTable().getTable(tableItems);
String itemsKey = "c.\"" + getTable().getTable(tableItems).getKey().getName() + "\"";
UpdateBuilder build = new UpdateBuilder(tableCmdElement);
build.set("QTE_LIVREE", "(SELECT SUM(b.\"QTE_LIVREE\" * b.\"QTE_UNITAIRE\") from " + new SQLName(tableBLElement.getDBRoot().getName(), tableBLElement.getName()).quote() + " b where "
+ itemsKey + "=b.\"ID_" + tableItems + "\" AND " + itemsKey + ">1 AND c.\"ARCHIVE\"=0 AND b.\"ID\">1 AND b.\"ARCHIVE\"=0 )");
AliasedTable alias = new AliasedTable(tableCmdElement, "c");
build.setWhere(new Where(alias.getField("ID_" + tableRoot), items));
 
getTable().getDBSystemRoot().getDataSource().execute(build.asString().replaceAll(" SET", " c SET "));
getTable().getDBSystemRoot().getDataSource().execute(build.asString().replaceAll(" SET", " c SET "));
}
}
 
@Override
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
 
List<Object> cmds = null;
List<Integer> ids = new ArrayList<Integer>();
List<Object> cmds = new ArrayList<>();
List<Object> devis = new ArrayList<>();
List<Integer> ids = new ArrayList<>();
for (SQLRow row : trees.getRows()) {
 
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
 
cmds = getCmdClientFrom(row.getID());
cmds.addAll(getSourceTrRowsFrom(row.getID(), "COMMANDE_CLIENT_ELEMENT", "COMMANDE_CLIENT"));
devis.addAll(getSourceTrRowsFrom(row.getID(), "DEVIS_ELEMENT", "DEVIS"));
ids.add(row.getID());
if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
 
155,9 → 170,34
}
}
super.archive(trees, cutLinks);
for (Integer id : ids) {
 
updateCmdClientElement(cmds, id);
}
updateQteLivree(devis, "DEVIS_ELEMENT", "DEVIS");
updateQteLivree(cmds, "COMMANDE_CLIENT_ELEMENT", "COMMANDE_CLIENT");
 
}
 
public RowAction getCloneAction() {
return new RowAction(new AbstractAction() {
 
public void actionPerformed(ActionEvent e) {
SQLRowAccessor selectedRow = IListe.get(e).getSelectedRow();
 
EditFrame editFrame = new EditFrame(BonDeLivraisonSQLElement.this, EditPanel.CREATION);
 
((BonDeLivraisonSQLComponent) editFrame.getSQLComponent()).duplicate(selectedRow.getID());
editFrame.setVisible(true);
}
}, true, "sales.quote.clone") {
@Override
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowValues> selection) {
return (selection != null && selection.size() == 1);
}
};
}
 
@Override
protected String createCodeSuffix() {
return ".delivery.note";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/action/NouveauBonLivraisonAction.java
13,22 → 13,14
package org.openconcerto.erp.core.sales.shipment.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauBonLivraisonAction extends CreateEditFrameAbstractAction<BonDeLivraisonSQLElement> {
 
public class NouveauBonLivraisonAction extends CreateFrameAbstractAction {
 
public NouveauBonLivraisonAction() {
super();
this.putValue(Action.NAME, "Bon de livraison");
public NouveauBonLivraisonAction(final PropsConfiguration conf) {
super(conf, BonDeLivraisonSQLElement.class);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/action/ListeDesBonsDeLivraisonAction.java
13,14 → 13,15
package org.openconcerto.erp.core.sales.shipment.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.action.CreateListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonSQLElement;
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
28,7 → 29,6
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
37,8 → 37,6
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.state.WindowStateManager;
import org.openconcerto.ui.table.PercentTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
46,7 → 44,6
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.io.File;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
55,20 → 52,19
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
 
public class ListeDesBonsDeLivraisonAction extends CreateFrameAbstractAction {
public class ListeDesBonsDeLivraisonAction extends CreateListFrameAbstractAction<BonDeLivraisonSQLElement, JFrame> {
 
public ListeDesBonsDeLivraisonAction() {
super();
this.putValue(Action.NAME, "Liste des bons de livraison");
public ListeDesBonsDeLivraisonAction(final ComptaPropsConfiguration conf) {
super(conf, BonDeLivraisonSQLElement.class);
}
 
public JFrame createFrame() {
final JFrame frame = new JFrame("Bons de livraison");
@Override
protected JFrame instantiateFrame() {
final JFrame frame = new JFrame(String.valueOf(getValue(NAME)));
PredicateRowAction toInvoiceAction = new PredicateRowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
transfertFactureClient(IListe.get(e).getSelectedRows());
78,25 → 74,20
 
// Tabs
final JTabbedPane tabs = new JTabbedPane();
tabs.addTab("Toutes les livraisons", createAllDeliveryPanel(toInvoiceAction));
tabs.addTab("Livraisons non facturées", createDeliveryWithoutInvoicePanel(toInvoiceAction));
tabs.addTab("Livraisons facturées", createDeliveryWithInvoicePanel());
tabs.addTab(TM.tr("sales.shipment.allShipments"), createAllDeliveryPanel(toInvoiceAction));
tabs.addTab(TM.tr("sales.shipment.nonInvoicedShipments"), createDeliveryWithoutInvoicePanel(toInvoiceAction));
tabs.addTab(TM.tr("sales.shipment.invoicedShipments"), createDeliveryWithInvoicePanel());
frame.setContentPane(tabs);
 
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
FrameUtil.setBounds(frame);
final File file = IListFrame.getConfigFile(eltCmd, frame.getClass());
if (file != null)
new WindowStateManager(frame, file).loadState();
return frame;
}
 
private ListeAddPanel getPanel(final SQLElement eltCmd, final SQLTableModelSourc