OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 141 → Rev 142

/trunk/OpenConcerto/lib/mime_util.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/mime_util.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/icudata_56.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/icudata_56.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/jOpenCalendar.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/mysql-connector-java-5.1.40-bin.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/mysql-connector-java-5.1.40-bin.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/accessors-smart-1.1.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/accessors-smart-1.1.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/jOpenDocument-1.4rc2.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/DS_Desktop_Notify.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/DS_Desktop_Notify.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/json-smart-2.2.1.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/json-smart-2.2.1.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/jopendocument/link/OOConnexion.java
117,15 → 117,33
}
 
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.out.println("Usage : " + OOConnexion.class.getName() + " officeFile");
if (args.length == 0 || args.length > 2) {
System.out.println("Usage : " + OOConnexion.class.getName() + " officeFile | --type param");
System.out.println("Open officeFile in the default installation of LibreOffice");
System.out.println("--type is either file or url");
System.exit(1);
}
final OOConnexion conn = OOConnexion.create();
if (conn == null)
throw new IllegalStateException("No Office found");
conn.loadDocument(new File(args[0]), false);
final boolean file;
final String arg;
if (args.length == 1) {
file = true;
arg = args[0];
} else if (args[0].equals("--file")) {
file = true;
arg = args[1];
} else if (args[0].equals("--url")) {
file = false;
arg = args[1];
} else {
throw new IllegalArgumentException("Type not valid : " + args[0]);
}
if (file)
conn.loadDocument(new File(arg), false);
else
conn.loadDocumentFromURLAsync(arg, false);
conn.closeConnexion();
}
 
/trunk/OpenConcerto/src/org/jopenchart/sample/devguide/PieChartSample.java
63,14 → 63,13
 
private static void chart3() {
PieChartWithSeparatedLabels c = new PieChartWithSeparatedLabels();
c.setInnerDimension(50, 50);
c.addLabel(new Label("AAAAAA"), Color.red);
c.addLabel(new Label("BBBB"));
c.addLabel(new Label("CCCCCCCCCCCCCCCCCCCCCCCCCCCC"));
c.addLabel(new Label("D"));
c.addLabel(new Label("EEE"));
c.addLabel(new Label("FFF"));
c.addLabel(new Label("GG"));
c.addLabel(new Label("HHH"));
 
c.setDimension(new Dimension(400, 200));
 
ArrayList<Number> l = new ArrayList<Number>();
/trunk/OpenConcerto/src/org/openconcerto/task/TodoListPanel.java
14,8 → 14,11
package org.openconcerto.task;
 
import static org.openconcerto.task.TM.getTM;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.DBSystemRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
38,7 → 41,6
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.SwingWorker2;
import org.openconcerto.utils.TableSorter;
import org.openconcerto.utils.Tuple3;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.Color;
55,8 → 57,6
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
95,8 → 95,6
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
 
import org.apache.commons.dbutils.ResultSetHandler;
 
public class TodoListPanel extends JPanel implements ModelStateListener {
 
// Actions
263,10 → 261,10
}
 
private void initViewableUsers(final User currentUser) {
final SwingWorker2<List<Tuple3<String, Integer, String>>, Object> worker = new SwingWorker2<List<Tuple3<String, Integer, String>>, Object>() {
final SwingWorker2<List<User>, Object> worker = new SwingWorker2<List<User>, Object>() {
 
@Override
protected List<Tuple3<String, Integer, String>> doInBackground() throws Exception {
protected List<User> doInBackground() throws Exception {
final List<Integer> canViewUsers = new ArrayList<Integer>();
for (final UserTaskRight right : UserTaskRight.getUserTaskRight(currentUser)) {
if (right.canRead())
276,30 → 274,15
final SQLTable userT = UserManager.getInstance().getTable();
final DBSystemRoot systemRoot = Configuration.getInstance().getSystemRoot();
final SQLSelect select1 = new SQLSelect(systemRoot, false);
select1.addSelect(userT.getKey());
select1.addSelect(userT.getField("NOM"));
select1.addSelect(userT.getField("PRENOM"));
select1.addSelect(userT.getField("SURNOM"));
select1.addSelectStar(userT);
final Where meWhere = new Where(userT.getKey(), "=", currentUser.getId());
final Where canViewWhere = new Where(userT.getKey(), canViewUsers);
select1.setWhere(meWhere.or(canViewWhere));
 
final List<Tuple3<String, Integer, String>> result = new ArrayList<Tuple3<String, Integer, String>>();
userT.getDBSystemRoot().getDataSource().execute(select1.asString(), new ResultSetHandler() {
public Object handle(ResultSet rs) throws SQLException {
while (rs.next()) {
String displayName = rs.getString(4).trim();
if (displayName.length() == 0) {
displayName = rs.getString(3).trim() + " " + rs.getString(2).trim().toUpperCase();
final List<User> result = new ArrayList<User>();
for (final SQLRow r : SQLRowListRSH.execute(select1)) {
result.add(new User(r));
}
final int uId = rs.getInt(1);
final String name = rs.getString(2);
result.add(new Tuple3<String, Integer, String>(displayName, uId, name));
 
}
return null;
}
});
return result;
}
 
306,15 → 289,18
@Override
protected void done() {
try {
final List<Tuple3<String, Integer, String>> tuples = get();
for (Tuple3<String, Integer, String> tuple3 : tuples) {
final JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem(tuple3.get0());
final List<User> tuples = get();
for (final User user : tuples) {
String displayName = user.getNickName();
if (displayName.length() == 0) {
displayName = user.getFirstName() + " " + user.getName().toUpperCase();
}
final JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem(displayName);
TodoListPanel.this.comboUser.add(checkBoxMenuItem);
 
final int uId = tuple3.get1();
final String name = tuple3.get2();
final int uId = user.getId();
 
TodoListPanel.this.users.add(new User(uId, name));
TodoListPanel.this.users.add(user);
checkBoxMenuItem.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent e) {
/trunk/OpenConcerto/src/org/openconcerto/task/config/TaskPropsConfiguration.java
36,7 → 36,7
try {
// try to read the file from within the jar, but allow it to be overridden by an
// external file
final File confFile = getConfFile(PRODUCT_INFO.getName());
final File confFile = getConfFile(PRODUCT_INFO);
final Properties props;
if (confFile.exists()) {
props = create(new FileInputStream(confFile), defaults);
/trunk/OpenConcerto/src/org/openconcerto/task/config/ComptaBasePropsConfiguration.java
13,18 → 13,6
package org.openconcerto.task.config;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;
 
import javax.swing.JOptionPane;
 
import com.jcraft.jsch.Session;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.element.ConfSQLElement;
39,26 → 27,36
import org.openconcerto.sql.users.UserCommonSQLElement;
import org.openconcerto.sql.users.rights.RightSQLElement;
import org.openconcerto.sql.users.rights.UserRightSQLElement;
import org.openconcerto.task.element.FWKListPrefs;
import org.openconcerto.task.element.FWKSessionState;
import org.openconcerto.task.element.TaskRightSQLElement;
import org.openconcerto.task.element.TaskSQLElement;
import org.openconcerto.utils.BaseDirs;
import org.openconcerto.utils.DesktopEnvironment;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.LogUtils;
import org.openconcerto.utils.ProductInfo;
 
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;
 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
 
import com.jcraft.jsch.Session;
 
public abstract class ComptaBasePropsConfiguration extends PropsConfiguration {
 
public abstract void setUpSocieteDataBaseConnexion(int base);
 
public static File getConfFile(final String appName) {
return getConfFile(appName, new File("."));
}
 
public static File getConfFile(final String appName, final File wd) {
public static File getConfFile(final ProductInfo info) {
final String confFilePath = System.getProperty("gestion.confFile");
final File wdFile = new File(wd + "/Configuration", "main.properties");
final File wdFile = new File("Configuration", "main.properties");
final File confFile;
if (confFilePath != null) {
confFile = new File(confFilePath);
65,8 → 63,18
} else if (wdFile.isFile()) {
confFile = wdFile;
} else {
confFile = new File(DesktopEnvironment.getDE().getPreferencesFolder(appName), "main.properties");
// we added organisation name, so migrate preferences
final File prefsFolder = BaseDirs.create(info).getPreferencesFolder();
if (!prefsFolder.exists()) {
try {
final File oldDir = DesktopEnvironment.getDE().getPreferencesFolder(info.getName());
Configuration.migrateToNewDir(oldDir, prefsFolder);
} catch (IOException ex) {
throw new IllegalStateException("Couldn't migrate preferences dir", ex);
}
}
confFile = new File(prefsFolder, "main.properties");
}
return confFile;
}
 
128,9 → 136,11
try {
Thread.sleep(1000);
if (!conn.isConnected()) {
JOptionPane.showMessageDialog(null, "Coupure réseau", "Liaison sécurisée déconnectée!\nVérifiez votre connexion internet et relancez le logiciel.",
JOptionPane.ERROR_MESSAGE);
System.exit(1);
if (!GraphicsEnvironment.isHeadless()) {
JOptionPane.showMessageDialog(null, "Liaison sécurisée déconnectée!\nVérifiez votre connexion internet et relancez le logiciel.");
} else {
ExceptionHandler.die("Liaison sécurisée déconnectée!\nVérifiez votre connexion internet et relancez le logiciel.");
}
break;
}
} catch (InterruptedException e) {
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportFEC.java
25,7 → 25,6
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
42,20 → 41,15
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
public class ExportFEC extends AbstractExport {
static private final Charset CHARSET = StringUtils.ISO8859_15;
static private final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("##0.00", DecimalFormatSymbols.getInstance(Locale.FRANCE));
 
private static final char ZONE_SEPARATOR = '\t';
private static final char RECORD_SEPARATOR = '\n';
private static final char REPLACEMENT = ' ';
static private final List<String> COLS = Arrays.asList("JournalCode", "JournalLib", "EcritureNum", "EcritureDate", "CompteNum", "CompteLib", "CompAuxNum", "CompAuxLib", "PieceRef", "PieceDate",
"EcritureLib", "Debit", "Credit", "EcritureLet", "DateLet", "ValidDate", "Montantdevise", "Idevise");
 
static private String formatCents(final Number n) {
return DECIMAL_FORMAT.format(BigDecimal.valueOf(n.longValue()).movePointLeft(2));
}
 
private final DecimalFormat format = new DecimalFormat("##0.00", DecimalFormatSymbols.getInstance(Locale.FRANCE));
private List<Object[]> data;
private final char zoneSep = '\t';
private final char recordSep = '\n';
private final char replacement = ' ';
 
private final boolean cloture;
 
103,27 → 97,29
}
 
private final void addAmountField(final List<String> line, final Number cents) {
line.add(formatCents(cents));
final String formattedAmount = format.format(BigDecimal.valueOf(cents.longValue()).movePointLeft(2));
line.add(formattedAmount);
}
 
private final void addField(final List<String> line, final String s) {
if (this.zoneSep == this.replacement || this.recordSep == this.replacement)
throw new IllegalStateException("Wrong separators");
if (s == null) {
throw new NullPointerException("Valeur manquante pour remplir la ligne : " + line);
}
// TODO remove \r
line.add(s.trim().replace(this.zoneSep, this.replacement).replace(this.recordSep, this.replacement));
line.add(s.trim().replace(ZONE_SEPARATOR, REPLACEMENT).replace(RECORD_SEPARATOR, REPLACEMENT));
}
 
@Override
protected void export(OutputStream out) throws IOException {
final Writer bufOut = new OutputStreamWriter(out, CHARSET);
final Writer bufOut = new OutputStreamWriter(out, StringUtils.ISO8859_15);
final DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
final int fieldsCount = COLS.size();
 
for (final String colName : COLS) {
bufOut.write(colName);
bufOut.write(this.zoneSep);
bufOut.write(ZONE_SEPARATOR);
}
bufOut.write(this.recordSep);
bufOut.write(RECORD_SEPARATOR);
 
final List<String> line = new ArrayList<String>(fieldsCount);
for (final Object[] array : this.data) {
139,9 → 135,21
final String ecritureDate = dateFormat.format(array[3]);
line.add(ecritureDate);
// CompteNum
if (array[4] != null) {
addField(line, (String) array[4]);
} else {
bufOut.close();
JOptionPane.showMessageDialog(new JFrame(), "Une écriture n'a pas de numéro de compte :\n" + line, "Erreur FEC", JOptionPane.ERROR_MESSAGE);
return;
}
// CompteLib
if (array[5] != null) {
addField(line, (String) array[5]);
} else {
bufOut.close();
JOptionPane.showMessageDialog(new JFrame(), "Une écriture n'a pas de libellé de compte pour le compte " + array[4].toString() + " :\n" + line, "Erreur FEC", JOptionPane.ERROR_MESSAGE);
return;
}
// CompAuxNum
addEmptyField(line);
// CompAuxLib
193,9 → 201,9
// blank field
if (zone != null)
bufOut.write(zone);
bufOut.write(this.zoneSep);
bufOut.write(ZONE_SEPARATOR);
}
bufOut.write(this.recordSep);
bufOut.write(RECORD_SEPARATOR);
}
bufOut.close();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/ITreeSelection.java
28,7 → 28,6
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.valuewrapper.ValueWrapper;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.SwingWorker2;
import org.openconcerto.utils.checks.EmptyChangeSupport;
import org.openconcerto.utils.checks.EmptyListener;
import org.openconcerto.utils.checks.EmptyObj;
50,6 → 49,7
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeCellRenderer;
294,8 → 294,7
}
 
private void loadTree() {
 
final SwingWorker2<List<SQLRow>, Object> worker = new SwingWorker2<List<SQLRow>, Object>() {
new SwingWorker<List<SQLRow>, Object>() {
@Override
protected List<SQLRow> doInBackground() throws Exception {
final SQLTable table = element.getTable();
310,10 → 309,15
try {
l = get();
if (l != null) {
Map<Integer, SQLRow> familles = new HashMap<Integer, SQLRow>();
for (int i = 0; i < l.size(); i++) {
SQLRow row = l.get(i);
addNewNode(row, row.getInt("ID_" + element.getTable().getName() + "_PERE"));
familles.put(row.getID(), row);
}
for (int i = 0; i < l.size(); i++) {
SQLRow row = l.get(i);
addNewNode(familles, row, row.getInt("ID_" + element.getTable().getName() + "_PERE"));
}
expandRow(0);
}
} catch (InterruptedException e) {
322,8 → 326,7
ExceptionHandler.handle("", e);
}
}
};
worker.execute();
}.execute();
}
 
/**
332,9 → 335,15
* @param id
* @param idPere
*/
private void addNewNode(SQLRow row, int idPere) {
private void addNewNode(Map<Integer, SQLRow> familles, SQLRow row, int idPere) {
 
if (this.mapNode.get(row.getID()) == null) {
ITreeSelectionNode nodePere = this.mapNode.get(Integer.valueOf(idPere));
if (idPere > 1 && nodePere == null && familles != null) {
SQLRow rowPere = familles.get(idPere);
addNewNode(familles, rowPere, rowPere.getInt("ID_" + element.getTable().getName() + "_PERE"));
nodePere = this.mapNode.get(Integer.valueOf(idPere));
}
ITreeSelectionNode newNode = new ITreeSelectionNode(row);
this.mapNode.put(row.getID(), newNode);
 
348,6 → 357,7
}
}
}
}
 
/**
* Ajoute un noeud dans l'arbre dans l'ordre alphabétique
412,7 → 422,7
public void rowAdded(SQLTable table, int id) {
final SQLRow row = table.getRow(id);
int idPere = row.getInt("ID_" + element.getTable().getName() + "_PERE");
addNewNode(row, idPere);
addNewNode(null, row, idPere);
}
 
public void rowDeleted(SQLTable table, int id) {
/trunk/OpenConcerto/src/org/openconcerto/erp/model/MouseSheetXmlListeListener.java
37,21 → 37,16
import java.io.File;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.print.PrintService;
import javax.print.attribute.Attribute;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.Size2DSyntax;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.MediaPrintableArea;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.PageRanges;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JOptionPane;
68,7 → 63,6
private boolean generateIsVisible = true;
private boolean previewHeader = false;
private boolean showHeader = false;
private boolean printHeader = false;
private boolean generateHeader = false;
 
public MouseSheetXmlListeListener(Class<? extends AbstractSheetXml> clazz) {
99,6 → 93,20
return null;
}
 
public List<AbstractSheetXml> createAbstractSheets(List<SQLRow> rows) {
final List<AbstractSheetXml> sheets = new ArrayList<AbstractSheetXml>(rows.size());
try {
final Constructor<? extends AbstractSheetXml> ctor = getSheetClass().getConstructor(SQLRow.class);
for (SQLRow row : rows) {
AbstractSheetXml sheet = ctor.newInstance(row);
sheets.add(sheet);
}
} catch (Exception e) {
ExceptionHandler.handle("sheet creation error", e);
}
return sheets;
}
 
protected String getMailObject(SQLRow row) {
return "";
}
111,16 → 119,20
this.generateHeader = generateHeader;
}
 
public void setPrintHeader(boolean printHeader) {
this.printHeader = printHeader;
}
 
public void setShowHeader(boolean showHeader) {
this.showHeader = showHeader;
}
 
protected void sendMail(final AbstractSheetXml sheet, final boolean readOnly) {
List<AbstractSheetXml> l = new ArrayList<AbstractSheetXml>(1);
l.add(sheet);
sendMail(l, readOnly);
}
 
protected void sendMail(final List<AbstractSheetXml> sheets, final boolean readOnly) {
String mail = "";
 
for (AbstractSheetXml sheet : sheets) {
final SQLRow row = sheet.getSQLRow();
Set<SQLField> setContact = null;
SQLTable tableContact = Configuration.getInstance().getRoot().findTable("CONTACT");
130,8 → 142,6
SQLTable tableClient = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("CLIENT");
setClient = row.getTable().getForeignKeys(tableClient);
 
String mail = "";
 
for (SQLField field : setContact) {
if (mail == null || mail.trim().length() == 0) {
mail = row.getForeignRow(field.getName()).getString("EMAIL");
165,13 → 175,10
if (mail == null || mail.trim().length() == 0) {
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
if (base.containsTable("MONTEUR")) {
 
SQLTable tableM = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MONTEUR");
Set<SQLField> setM = null;
setM = row.getTable().getForeignKeys(tableM);
 
if (setM != null) {
 
for (SQLField field : setM) {
SQLRow rowM = row.getForeignRow(field.getName());
if (rowM.getForeignRow("ID_CONTACT_FOURNISSEUR") != null && !rowM.getForeignRow("ID_CONTACT_FOURNISSEUR").isUndefined()) {
201,25 → 208,28
}
}
}
 
}
final String adresseMail = mail;
 
final String subject = sheet.getReference();
final String subject = sheets.get(0).getReference();
 
if (readOnly) {
 
final Thread t = new Thread() {
@Override
public void run() {
final File f;
final List<File> files = new ArrayList<File>();
try {
f = sheet.getOrCreatePDFDocumentFile(true);
for (AbstractSheetXml sheet : sheets) {
files.add(sheet.getOrCreatePDFDocumentFile(true).getAbsoluteFile());
}
 
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
try {
EmailComposer.getInstance().compose(adresseMail, subject + (subject.trim().length() == 0 ? "" : ", ") + f.getName(), getMailObject(row), f.getAbsoluteFile());
EmailComposer.getInstance().compose(adresseMail, subject + (subject.trim().length() == 0 ? "" : ", ") + files.get(0).getName(),
getMailObject(sheets.get(0).getSQLRow()), files.toArray(new File[files.size()]));
} catch (Exception e) {
ExceptionHandler.handle("Impossible de charger le document PDF dans l'email!", e);
}
230,12 → 240,15
}
}
};
 
t.start();
} else {
try {
EmailComposer.getInstance().compose(adresseMail, subject + (subject.trim().length() == 0 ? "" : ", ") + sheet.getGeneratedFile().getName(), getMailObject(row),
sheet.getGeneratedFile().getAbsoluteFile());
final List<File> files = new ArrayList<File>();
for (AbstractSheetXml sheet : sheets) {
files.add(sheet.getGeneratedFile().getAbsoluteFile());
}
EmailComposer.getInstance().compose(adresseMail, subject + (subject.trim().length() == 0 ? "" : ", ") + sheets.get(0).getGeneratedFile().getName(),
getMailObject(sheets.get(0).getSQLRow()), files.toArray(new File[files.size()]));
} catch (Exception exn) {
ExceptionHandler.handle(null, "Impossible de créer le courriel", exn);
}
259,6 → 272,7
}
 
}, this.previewHeader, "document.modify") {
 
@Override
public boolean enabledFor(IListeEvent evt) {
 
307,6 → 321,7
createAbstractSheet(IListe.get(ev).fetchSelectedRow()).openDocument(false);
}
}, this.showHeader, "document.modify") {
 
@Override
public boolean enabledFor(IListeEvent evt) {
return evt.getSelectedRow() != null && evt.getTotalRowCount() >= 1 && createAbstractSheet(evt.getSelectedRow().asRow()).getGeneratedFile().exists();
323,7 → 338,8
public void actionPerformed(final ActionEvent ev) {
//
final IListe ilist = IListe.get(ev);
AbstractSheetXml firstSheet = createAbstractSheet(ilist.fetchRow(IListe.get(ev).getSelectedRow().getID()));
final SQLRow asRow = IListe.get(ev).getSelectedRow().asRow();
AbstractSheetXml firstSheet = createAbstractSheet(asRow);
final String printerName = firstSheet.getPrinter();
// Printer configuration
final PrinterJob printJob = PrinterJob.getPrinterJob();
396,7 → 412,7
});
if (!pFrame.isCancelled()) {
SQLRowValues r = rows.get(i);
AbstractSheetXml sheet = createAbstractSheet(IListe.get(ev).fetchRow(r.getID()));
AbstractSheetXml sheet = createAbstractSheet(r.asRow());
sheet.printDocument(printJob);
}
}
412,6 → 428,7
 
}
}, false, "document.print") {
 
@Override
public boolean enabledFor(IListeEvent evt) {
return evt.getSelectedRow() != null && evt.getSelectedRows().size() > 0;
424,9 → 441,17
 
l.add(new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent ev) {
sendMail(createAbstractSheet(IListe.get(ev).fetchSelectedRow()), true);
 
final List<SQLRowValues> selectedRows = IListe.get(ev).getSelectedRows();
final SQLTable table = IListe.get(ev).getSource().getPrimaryTable();
final List<SQLRow> rows = new ArrayList<SQLRow>();
for (SQLRowValues r : selectedRows) {
rows.add(table.getRow(r.getID()));
}
sendMail(createAbstractSheets(rows), true);
}
}, false, "document.pdf.send.email") {
 
@Override
public boolean enabledFor(IListeEvent evt) {
return evt.getSelectedRow() != null && evt.getTotalRowCount() >= 1 && createAbstractSheet(evt.getSelectedRow().asRow()).getGeneratedFile().exists();
435,9 → 460,16
 
l.add(new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent ev) {
sendMail(createAbstractSheet(IListe.get(ev).fetchSelectedRow()), false);
final List<SQLRowValues> selectedRows = IListe.get(ev).getSelectedRows();
final SQLTable table = IListe.get(ev).getSource().getPrimaryTable();
final List<SQLRow> rows = new ArrayList<SQLRow>();
for (SQLRowValues r : selectedRows) {
rows.add(table.getRow(r.getID()));
}
sendMail(createAbstractSheets(rows), false);
}
}, false, "document.send.email") {
 
@Override
public boolean enabledFor(IListeEvent evt) {
return evt.getSelectedRow() != null && evt.getTotalRowCount() >= 1 && createAbstractSheet(evt.getSelectedRow().asRow()).getGeneratedFile().exists();
518,6 → 550,7
}
}
}, false, false, "document.create") {
 
@Override
public boolean enabledFor(List<SQLRowValues> selection) {
return selection != null && selection.size() == 1;
/trunk/OpenConcerto/src/org/openconcerto/erp/model/FichePayeModel.java
621,12 → 621,18
Object ob = rowVals.getObject("VALIDE");
boolean b = (ob == null) ? false : new Boolean(ob.toString()).booleanValue();
 
if (rowVals.getObject("ID_FICHE_PAYE") != null && !rowVals.isForeignEmpty("ID_FICHE_PAYE") && rowVals.getForeign("ID_FICHE_PAYE").getBoolean("VALIDE")) {
b = true;
}
 
return b;
}
 
private void updateValueFiche() {
 
if (!tableFichePaye.getRow(idFiche).getBoolean("VALIDE")) {
SQLRowValues rowValsFiche = new SQLRowValues(tableFichePaye);
 
rowValsFiche.put("SAL_BRUT", this.salBrut);
rowValsFiche.put("NET_IMP", this.netImp.add(this.salBrut));
rowValsFiche.put("NET_A_PAYER", this.netAPayer.add(this.salBrut));
640,6 → 646,7
e.printStackTrace();
}
}
}
 
/***********************************************************************************************
* Charge un élément d'une rubrique de brut
/trunk/OpenConcerto/src/org/openconcerto/erp/rights/GroupUIComboRightEditor.java
14,6 → 14,7
package org.openconcerto.erp.rights;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.DBRoot;
40,8 → 41,6
 
public class GroupUIComboRightEditor implements RightEditor {
 
public static final String ID_RIGHT = "GROUP_ITEM_SHOW";
 
@Override
public void setValue(final String object, final DBRoot root, final SQLElementDirectory directory, final JComponent editorComponent) {
SQLField f = Configuration.getInstance().getFieldMapper().getSQLFieldForItem(object);
68,7 → 67,7
}
 
public static void register() {
RightEditorManager.getInstance().register(ID_RIGHT, new GroupUIComboRightEditor());
RightEditorManager.getInstance().register(GroupSQLComponent.ITEM_RIGHT_CODE, new GroupUIComboRightEditor());
}
 
private class SQLElementComboItem {
/trunk/OpenConcerto/src/org/openconcerto/erp/utils/ActionDB.java
71,10 → 71,10
final DBRoot baseSQLDefault = sysRoot.getRoot(baseDefault);
log(l, "Traitement des " + baseSQLDefault.getChildrenNames().size() + " tables");
 
final SQLCreateRoot createRoot = baseSQLDefault.getDefinitionSQL(sysRoot.getServer().getSQLSystem());
final SQLCreateRoot createRoot = baseSQLDefault.getDefinitionSQL(sysRoot.getSyntax());
final SQLDataSource ds = sysRoot.getDataSource();
// be safe don't add DROP SCHEMA
final List<String> sql = createRoot.asStringList(newBase, false, true, EnumSet.of(ConcatStep.ADD_FOREIGN));
final List<String> sql = createRoot.asStringList(newBase, false, true, EnumSet.of(ConcatStep.ADD_CONSTRAINT));
// create root
ds.execute(sql.get(0));
// create tables (without constraints)
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/TemplateNXProps.java
15,11 → 15,11
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
import org.openconcerto.erp.core.finance.accounting.report.BalanceSheet;
import org.openconcerto.erp.core.finance.accounting.report.GrandLivreSheet;
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheetXML;
import org.openconcerto.erp.core.humanresources.payroll.report.EtatChargesPayeSheet;
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheet;
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
import org.openconcerto.erp.core.humanresources.payroll.report.LivrePayeSheet;
import org.openconcerto.erp.core.sales.invoice.report.ListeVenteXmlSheet;
123,6 → 123,11
propertyDefaultPDFDirectory = propertyDefaultDirectory;
}
 
final String propertyAtt = getProperty(AttachmentSQLElement.DIRECTORY_PREFS);
if (propertyAtt != null && propertyAtt.trim().length() > 0) {
storage.addDocumentDirectory(AttachmentSQLElement.DIRECTORY_PREFS, new File(propertyAtt));
}
 
storage.setPDFDefaultDirectory(new File(propertyDefaultPDFDirectory));
 
 
185,6 → 190,7
System.err.println("Warning: registering known template id : " + templateId + " with property base name: " + propertyBaseName);
}
final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
 
final String propertyOO = getProperty(propertyBaseName + "OO");
if (propertyOO != null) {
storage.addDocumentDirectory(templateId, new File(propertyOO));
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/AttachmentPreferencePanel.java
New file
0,0 → 1,130
/*
* 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.preferences;
 
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
import org.openconcerto.utils.FileUtils;
 
import java.awt.Color;
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.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
 
public class AttachmentPreferencePanel extends DefaultPreferencePanel {
 
private JTextField textTemplate;
private JFileChooser fileChooser = null;
 
public AttachmentPreferencePanel() {
this.setLayout(new GridBagLayout());
final GridBagConstraints cPanel = new DefaultGridBagConstraints();
cPanel.weighty = 0;
cPanel.anchor = GridBagConstraints.WEST;
/*******************************************************************************************
* Emplacement
******************************************************************************************/
this.add(new JLabel("Destination des documents GED"), cPanel);
cPanel.gridx++;
cPanel.weightx = 1;
this.textTemplate = new JTextField();
this.add(this.textTemplate, cPanel);
 
final JButton buttonTemplate = new JButton("...");
cPanel.gridx++;
cPanel.weightx = 0;
cPanel.fill = GridBagConstraints.NONE;
this.add(buttonTemplate, cPanel);
 
buttonTemplate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
directoryChoose();
}
});
 
setValues();
}
 
public void storeValues() {
 
final File z = new File(".");
final File f = new File(this.textTemplate.getText());
try {
TemplateNXProps.getInstance().setProperty(AttachmentSQLElement.DIRECTORY_PREFS, FileUtils.relative(z, f));
DocumentLocalStorageManager.getInstance().addDocumentDirectory(AttachmentSQLElement.DIRECTORY_PREFS, new File(FileUtils.relative(z, f)));
} catch (IOException e) {
e.printStackTrace();
}
TemplateNXProps.getInstance().store();
}
 
public void restoreToDefaults() {
 
}
 
public String getTitleName() {
return "Emplacement des modèles";
}
 
private void setValues() {
try {
final File f = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(AttachmentSQLElement.DIRECTORY_PREFS);
if (f.exists()) {
this.textTemplate.setForeground(UIManager.getColor("TextField.foreground"));
} else {
this.textTemplate.setForeground(Color.RED);
}
this.textTemplate.setText(f.getCanonicalPath());
 
} catch (IOException e) {
e.printStackTrace();
}
}
 
private void directoryChoose() {
 
if (this.fileChooser == null) {
this.fileChooser = new JFileChooser();
this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}
this.fileChooser.setCurrentDirectory(new File(AttachmentPreferencePanel.this.textTemplate.getText()));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
 
if (AttachmentPreferencePanel.this.fileChooser.showDialog(AttachmentPreferencePanel.this, "Sélectionner") == JFileChooser.APPROVE_OPTION) {
File selectedFile = AttachmentPreferencePanel.this.fileChooser.getSelectedFile();
if (selectedFile.exists()) {
AttachmentPreferencePanel.this.textTemplate.setForeground(UIManager.getColor("TextField.foreground"));
} else {
AttachmentPreferencePanel.this.textTemplate.setForeground(Color.RED);
}
AttachmentPreferencePanel.this.textTemplate.setText(selectedFile.getPath());
}
}
});
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/GestionCommercialeGlobalPreferencePanel.java
17,6 → 17,7
package org.openconcerto.erp.preferences;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.ui.preferences.JavaPrefPreferencePanel;
34,6 → 35,7
public static String ADDRESS_SPEC = "AddressSpec";
public static String GESTION_TIMBRE_FISCAL = "GestionTimbreFiscal";
public static String TAUX_TIMBRE_FISCAL = "TauxTimbreFiscal";
public static String BARCODE_INSERTION = "BarcodeInsertion";
 
public GestionCommercialeGlobalPreferencePanel() {
super("Gestion des pièces commerciales", null);
70,6 → 72,18
tauxTimbreFisc.setDefaultValue(Double.valueOf(1));
this.addView(tauxTimbreFisc);
 
PrefView<Boolean> ecoColumns = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Afficher les colonnes éco-contributions", AbstractArticleItemTable.SHOW_ECO_CONTRIBUTION_COLUMNS);
ecoColumns.setDefaultValue(Boolean.FALSE);
this.addView(ecoColumns);
 
PrefView<Boolean> ecoTotal = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Afficher le total de l'éco-contribution", AbstractArticleItemTable.SHOW_TOTAL_ECO_CONTRIBUTION);
ecoTotal.setDefaultValue(Boolean.FALSE);
this.addView(ecoTotal);
 
PrefView<Boolean> barcodeInsert = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Insérer des lignes dans le corps avec la douchette", BARCODE_INSERTION);
barcodeInsert.setDefaultValue(Boolean.FALSE);
this.addView(barcodeInsert);
 
ButtonGroup group = new ButtonGroup();
group.add((JCheckBox) viewMultiTransfert.getVW().getComp());
group.add((JCheckBox) viewTransfert.getVW().getComp());
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/GestionClientPreferencePanel.java
26,6 → 26,7
public class GestionClientPreferencePanel extends JavaPrefPreferencePanel {
public static String LOAD_CITIES = "LoadCities";
public static String DISPLAY_CLIENT_DPT = "DisplayClientDpt";
public static String DISPLAY_CLIENT_PCE = "DisplayClientPCE";
 
public GestionClientPreferencePanel() {
super("Gestion des clients", null);
41,5 → 42,9
PrefView<Boolean> viewCity = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Charger les villes connues", LOAD_CITIES);
viewCity.setDefaultValue(Boolean.TRUE);
this.addView(viewCity);
 
PrefView<Boolean> viewPCE = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Voir le compte comptable dans les sélecteurs et les listes", DISPLAY_CLIENT_PCE);
viewPCE.setDefaultValue(Boolean.FALSE);
this.addView(viewPCE);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/TemplatePreferencePanel.java
18,6 → 18,7
import org.openconcerto.erp.generationDoc.TemplateManager;
import org.openconcerto.erp.generationDoc.TemplateProvider;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
import org.openconcerto.ui.table.TablePopupMouseListener;
120,7 → 121,7
bSync = new JButton("Synchroniser");
bSync.setEnabled(false);
bSync.setOpaque(false);
if (!UserManager.getUser().getRights().haveRight("SYNC_TEMPLATE")) {
if (!UserRightsManager.getCurrentUserRights().haveRight("SYNC_TEMPLATE")) {
bSync.setToolTipText("Vous n'avez pas les droits suffisants pour synchroniser les modèles!");
}
c.gridx++;
219,7 → 220,7
bUndo.setEnabled(false);
} else {
bModify.setEnabled(true);
bSync.setEnabled(UserManager.getUser().getRights().haveRight("SYNC_TEMPLATE"));
bSync.setEnabled(UserRightsManager.getCurrentUserRights().haveRight("SYNC_TEMPLATE"));
bUndo.setEnabled(true);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/PayeGlobalPreferencePanel.java
25,6 → 25,7
 
public class PayeGlobalPreferencePanel extends JavaPrefPreferencePanel {
public static String ASSIETTE_CSG = "AssietteCSG";
public static String DSN_CVAE = "DsnCVAE";
 
public PayeGlobalPreferencePanel() {
super("Paye", null);
37,5 → 38,9
PrefView<Double> viewCSG = new PrefView<Double>(PrefType.DOUBLE_TYPE, "Assiette CSG", ASSIETTE_CSG);
viewCSG.setDefaultValue(0.9825D);
this.addView(viewCSG);
 
PrefView<Boolean> viewCVAE = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Entreprise assujettie à la CVAE", DSN_CVAE);
viewCVAE.setDefaultValue(Boolean.FALSE);
this.addView(viewCVAE);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/config/DSNInstallationUtils.java
15,6 → 15,7
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLName;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
24,6 → 25,7
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.Inserter;
import org.openconcerto.sql.request.Inserter.Insertion;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ReOrder;
import org.openconcerto.sql.utils.SQLCreateTable;
32,7 → 34,9
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class DSNInstallationUtils {
 
48,7 → 52,11
}
 
private void insertValues(List<Tuple2<String, String>> values, SQLTable table) throws SQLException {
SQLSelect sel = new SQLSelect();
sel.addSelect(table.getField("CODE"));
List<String> codes = (List<String>) table.getDBSystemRoot().getDataSource().executeA(sel.asString());
for (Tuple2<String, String> tuple2 : values) {
if (!codes.contains(tuple2.get0())) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("CODE", tuple2.get0());
rowVals.put("NOM", tuple2.get1());
55,6 → 63,7
rowVals.commit();
}
}
}
 
public void updateDSNCommonTable(final DBRoot root) throws SQLException {
 
142,6 → 151,34
}
}
 
if (!root.contains("TYPE_PREAVIS")) {
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "TYPE_PREAVIS");
createTableMotif.addVarCharColumn("CODE", 25);
createTableMotif.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableMotif.asString());
insertUndef(createTableMotif);
root.refetchTable("TYPE_PREAVIS");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("TYPE_PREAVIS");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
v.add(Tuple2.create("01", "préavis effectué et payé"));
v.add(Tuple2.create("02", "préavis non effectué et payé"));
v.add(Tuple2.create("03", "préavis non effectué et non payé"));
v.add(Tuple2.create("10", "préavis non effectué non payé dans le cadre d’un contrat de sécurisation professionnelle (CSP)"));
v.add(Tuple2.create("50", "préavis non effectué et payé dans le cadre d’un congé de reclassement"));
v.add(Tuple2.create("51", "préavis non effectué et payé dans le cadre d’un congé de mobilité"));
v.add(Tuple2.create("60", "Délai de prévenance"));
v.add(Tuple2.create("90", "pas de clause de préavis applicable"));
 
insertValues(v, table);
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_PREAVIS", ex);
}
}
 
if (!root.contains("CODE_BASE_ASSUJETTIE")) {
final SQLCreateTable createTableCodeBase = new SQLCreateTable(root, "CODE_BASE_ASSUJETTIE");
createTableCodeBase.addVarCharColumn("CODE", 25);
210,6 → 247,16
root.getSchema().updateVersion();
}
 
SQLTable tableRubNet = root.getTable("RUBRIQUE_NET");
if (!tableRubNet.contains("ID_CODE_TYPE_RUBRIQUE_BRUT")) {
 
AlterTable alterTableNet = new AlterTable(tableRubNet);
alterTableNet.addForeignColumn("ID_CODE_TYPE_RUBRIQUE_BRUT", root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
root.getBase().getDataSource().execute(alterTableNet.asString());
root.refetchTable("RUBRIQUE_NET");
root.getSchema().updateVersion();
}
 
if (!root.contains("DSN_REGIME_LOCAL")) {
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_REGIME_LOCAL");
createTableMotif.addVarCharColumn("CODE", 25);
554,8 → 601,501
 
DSNUpdateRubrique dsnUpdateRubrique = new DSNUpdateRubrique(root);
dsnUpdateRubrique.updateRubriqueCotisation();
 
// PHASE 3
{
SQLTable tableCaisseCotisation = root.findTable("CAISSE_COTISATION");
if (!tableCaisseCotisation.contains("ORG_PROTECTION_SOCIALE")) {
final AlterTable alterCaisse = new AlterTable(tableCaisseCotisation);
alterCaisse.addBooleanColumn("ORG_PROTECTION_SOCIALE", Boolean.FALSE, false);
alterCaisse.addBooleanColumn("URSSAF", Boolean.FALSE, false);
 
root.getBase().getDataSource().execute(alterCaisse.asString());
root.refetchTable("CAISSE_COTISATION");
root.getSchema().updateVersion();
 
{
UpdateBuilder upCaisse = new UpdateBuilder(tableCaisseCotisation);
upCaisse.setObject("ORG_PROTECTION_SOCIALE", Boolean.TRUE);
upCaisse.setWhere(new Where(tableCaisseCotisation.getField("NOM"), Arrays.asList("URSSAF", "AGIRC", "ARRCO")));
root.getBase().getDataSource().execute(upCaisse.asString());
}
{
UpdateBuilder upCaisse = new UpdateBuilder(tableCaisseCotisation);
upCaisse.setObject("URSSAF", Boolean.TRUE);
upCaisse.setWhere(new Where(tableCaisseCotisation.getField("NOM"), Arrays.asList("URSSAF")));
root.getBase().getDataSource().execute(upCaisse.asString());
}
}
if (!root.contains("CAISSE_MODE_PAIEMENT")) {
final SQLCreateTable createCaisseMode = new SQLCreateTable(root, "CAISSE_MODE_PAIEMENT");
createCaisseMode.addVarCharColumn("CODE", 25);
createCaisseMode.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createCaisseMode.asString());
insertUndef(createCaisseMode);
root.refetchTable("CAISSE_MODE_PAIEMENT");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("CAISSE_MODE_PAIEMENT");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
v.add(Tuple2.create("01", "chèque"));
v.add(Tuple2.create("02", "virement"));
v.add(Tuple2.create("03", "prélèvement"));
v.add(Tuple2.create("04", "titre inter-bancaire de paiement"));
v.add(Tuple2.create("05", "prélèvement SEPA"));
v.add(Tuple2.create("06", "versement réalisé par un autre établissement"));
 
insertValues(v, table);
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CAISSE_MODE_PAIEMENT", ex);
}
 
final SQLCreateTable createCaisseREnseignement = new SQLCreateTable(root, "CAISSE_COTISATION_RENSEIGNEMENT");
createCaisseREnseignement.addVarCharColumn("IDENTIFIANT", 256);
createCaisseREnseignement.addVarCharColumn("SIRET", 256);
createCaisseREnseignement.addVarCharColumn("BIC", 256);
createCaisseREnseignement.addVarCharColumn("IBAN", 256);
createCaisseREnseignement.addVarCharColumn("ENTITE_AFFECTATION", 256);
createCaisseREnseignement.addBooleanColumn("ORGANISME_COMPLEMENTAIRE", Boolean.FALSE, false);
createCaisseREnseignement.addBooleanColumn("PAIEMENT_TRIMESTRIEL", Boolean.FALSE, false);
createCaisseREnseignement.addVarCharColumn("CODE_DELEGATAIRE", 256);
createCaisseREnseignement.addForeignColumn("ID_CAISSE_MODE_PAIEMENT", root.getTable("CAISSE_MODE_PAIEMENT"));
createCaisseREnseignement.addForeignColumn("ID_CAISSE_COTISATION", root.getTable("CAISSE_COTISATION"));
createCaisseREnseignement.addForeignColumn("ID_SOCIETE_COMMON", root.getTable("SOCIETE_COMMON"));
root.getBase().getDataSource().execute(createCaisseREnseignement.asString());
insertUndef(createCaisseREnseignement);
root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
root.getSchema().updateVersion();
}
SQLTable tableCR = root.getTable("CAISSE_COTISATION_RENSEIGNEMENT");
if (!tableCR.contains("PAIEMENT_TRIMESTRIEL")) {
AlterTable alter = new AlterTable(tableCR);
alter.addBooleanColumn("PAIEMENT_TRIMESTRIEL", Boolean.FALSE, false);
root.getBase().getDataSource().execute(alter.asString());
root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
root.getSchema().updateVersion();
}
}
 
if (!root.contains("TYPE_COMPOSANT_BASE_ASSUJETTIE")) {
final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "TYPE_COMPOSANT_BASE_ASSUJETTIE");
createTableTypeComposant.addVarCharColumn("CODE", 25);
createTableTypeComposant.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableTypeComposant.asString());
insertUndef(createTableTypeComposant);
root.refetchTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
 
v.add(Tuple2.create("01", "Montant du SMIC retenu pour le calcul de la Réduction générale des cotisations patronales de sécurité sociale"));
v.add(Tuple2.create("02", "Montant du SMIC retenu pour le calcul du crédit d'impôt compétitivité-emploi"));
v.add(Tuple2.create("03", "Contributions patronales à des régimes complémentaires de retraite"));
v.add(Tuple2.create("04", "Contributions patronales destinées au financement des prestations de prévoyance complémentaire"));
v.add(Tuple2.create("05", "Contributions patronales destinées au financement des prestations de retraite supplémentaire"));
v.add(Tuple2.create("06", "Plafond calculé pour salarié poly-employeurs"));
v.add(Tuple2.create("10", "Salaire brut Prévoyance"));
v.add(Tuple2.create("11", "Tranche A Prévoyance"));
v.add(Tuple2.create("12", "Tranche 2 Prévoyance"));
v.add(Tuple2.create("13", "Tranche B Prévoyance"));
v.add(Tuple2.create("14", "Tranche C Prévoyance"));
v.add(Tuple2.create("15", "Tranche D Prévoyance"));
v.add(Tuple2.create("16", "Tranche D1 Prévoyance"));
v.add(Tuple2.create("17", "Base spécifique Prévoyance"));
v.add(Tuple2.create("18", "Base forfaitaire Prévoyance"));
v.add(Tuple2.create("19", "Base fictive Prévoyance reconstituée"));
v.add(Tuple2.create("20", "Montant forfaitaire Prévoyance"));
v.add(Tuple2.create("21", "Montant Prévoyance libre ou exceptionnel"));
v.add(Tuple2.create("22", "Montant des indemnités journalières CRPCEN"));
v.add(Tuple2.create("90", "Retenue sur salaire"));
v.add(Tuple2.create("91", "Base de taxe sur les salaires au taux normal"));
 
insertValues(v, table);
 
AlterTable tableRubCotis = new AlterTable(tableRubCot);
tableRubCotis.addForeignColumn("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE", root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE"));
root.getBase().getDataSource().execute(tableRubCotis.asString());
root.refetchTable(tableRubCot.getName());
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_COMPOSANT_BASE_ASSUJETTIE", ex);
}
}
if (!root.contains("CODE_COTISATION_INDIVIDUELLE")) {
final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_COTISATION_INDIVIDUELLE");
createTableTypeComposant.addVarCharColumn("CODE", 25);
createTableTypeComposant.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableTypeComposant.asString());
insertUndef(createTableTypeComposant);
root.refetchTable("CODE_COTISATION_INDIVIDUELLE");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("CODE_COTISATION_INDIVIDUELLE");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
 
v.add(Tuple2.create("001", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1979)"));
v.add(Tuple2.create("002", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1987)"));
v.add(Tuple2.create("003", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1992)"));
v.add(Tuple2.create("004", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat d'accès à l'emploi"));
v.add(Tuple2.create("006", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat d'accompagnement dans l'emploi"));
v.add(Tuple2.create("008", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat de professionnalisation"));
v.add(Tuple2.create("009", "Exonération de cotisations applicable aux associations intermédiaires"));
v.add(Tuple2.create("010", "Exonération de cotisations applicable aux entreprises des bassins d'emploi à redynamiser"));
v.add(Tuple2.create("011", "Exonération de cotisations applicable au créateur ou repreneur d'entreprise"));
v.add(Tuple2.create("012", "Exonération de cotisations applicable dans les DOM"));
v.add(Tuple2.create("013", "Exonération de cotisations applicable aux entreprises et associations d'aide à domicile"));
v.add(Tuple2.create("014", "Exonérations de cotisations applicable aux entreprises innovantes ou universitaires"));
v.add(Tuple2.create("015", "Exonération de cotisations applicable aux entreprises en zones franches urbaines"));
v.add(Tuple2.create("016", "Exonération de cotisations applicable aux organismes d'intérêt général en zones de revitalisation rurale"));
v.add(Tuple2.create("017", "Exonération de cotisations applicable aux structures agréées de l'aide sociale"));
v.add(Tuple2.create("018", "Réduction générale des cotisations patronales de sécurité sociale"));
v.add(Tuple2.create("019", "Réduction de cotisations applicable aux entreprises des zones de restructuration de la défense"));
v.add(Tuple2.create("020", "Réduction de cotisations au titre de l'embauche du 1er au 50ème salarié en zones de revitalisation rurale"));
v.add(Tuple2.create("021", "Déduction patronale au titre des heures supplémentaires"));
v.add(Tuple2.create("022", "Exonération de cotisations applicable à une gratification de stage"));
v.add(Tuple2.create("023", "Exonération de cotisation des sommes provenant d'un CET et réaffectées à un PERCO ou à un régime de retraite supplémentaire"));
v.add(Tuple2.create("025", "Exonération de cotisations au titre de l’emploi d’un salarié en chantier et atelier d'insertion"));
v.add(Tuple2.create("027", "Exonération Personnel technique CUMA, hors ateliers"));
v.add(Tuple2.create("028", "Réduction Travailleur Occasionnel"));
v.add(Tuple2.create("029", "CNIEG Réduction employeurs petit pool"));
v.add(Tuple2.create("030", "Camieg Cotisation employeurs Régime spécial Complémentaire"));
v.add(Tuple2.create("031", "Camieg Cotisation salariés Régime spécial Complémentaire"));
v.add(Tuple2.create("032", "Camieg Cotisation salariés Régime spécial Solidarité"));
v.add(Tuple2.create("033", "CNIEG Cotisation employeurs complément d'invalidité"));
v.add(Tuple2.create("034", "CNIEG Cotisation employeurs régime de droit commun (population adossée)"));
v.add(Tuple2.create("035", "CNIEG Cotisation employeurs Régime spécial (population adossée)"));
v.add(Tuple2.create("036", "CNIEG Cotisation employeurs régime spécial (population non adossée)"));
v.add(Tuple2.create("037", "CNIEG Cotisation salariés régime de droit commun (population adossée)"));
v.add(Tuple2.create("038", "CNIEG Cotisation salariés régime spécial (population non adossée)"));
v.add(Tuple2.create("039", "CNIEG Cotisations employeurs petit pool"));
v.add(Tuple2.create("040", "Cotisation AC : assurance chômage sur rémunérations brutes après déduction, limitées à 4 fois le plafond de la SS"));
v.add(Tuple2.create("041", "Cotisation AC majorée 1 : application d’une majoration AC + 0,5% sur les contrats d’usage inférieurs ou égaux à 3 mois"));
v.add(Tuple2.create("042", "Cotisation AC majorée 2 : application d’une majoration AC + 3% sur les contrats d’accroissement temporaire d’activité inférieurs ou égaux à 1 mois"));
v.add(Tuple2.create("043",
"Cotisation AC majorée 3 : application d’une majoration AC + 1,5% sur les contrats d’accroissement temporaire d’activité supérieurs à 1 mois mais inférieurs ou égaux à 3 mois"));
v.add(Tuple2.create("044", "Exonération de cotisation chômage pour les moins de 26 ans"));
v.add(Tuple2.create("045", "Cotisation Accident du travail"));
v.add(Tuple2.create("046", "Cotisation AEF Bourse de l'emploi"));
v.add(Tuple2.create("047", "Cotisation AEF CESA"));
v.add(Tuple2.create("048", "Cotisation AGS : assurance garantie des salaires sur rémunérations brutes après déduction, limitées à 4 fois le plafond de la sécurité sociale"));
v.add(Tuple2.create("049", "Cotisation Allocation de logement (FNAL)"));
v.add(Tuple2.create("051", "Cotisation Formation professionnelle ADEFA"));
v.add(Tuple2.create("052", "Cotisation AFNCA, ANEFA, PROVEA, ASCPA"));
v.add(Tuple2.create("053", "Cotisation Formation professionnelle additionnelle FAFSEA"));
v.add(Tuple2.create("054", "Cotisation Formation professionnelle AREFA"));
v.add(Tuple2.create("055", "Cotisation Formation professionnelle CEREFAR"));
v.add(Tuple2.create("056", "Cotisation Formation professionnelle FAFSEA"));
v.add(Tuple2.create("057", "Cotisation Formation professionnelle FAFSEA CDD"));
v.add(Tuple2.create("058", "Cotisation Formation professionnelle FAFSEA des communes forestières"));
v.add(Tuple2.create("059", "Cotisation individuelle Prévoyance-Assurance-Mutuelle pour la période et l'affiliation concernées"));
v.add(Tuple2.create("060", "Cotisation IRCANTEC Tranche A"));
v.add(Tuple2.create("061", "Cotisation IRCANTEC Tranche B"));
v.add(Tuple2.create("063", "RETA Montant de cotisation Arrco"));
v.add(Tuple2.create("064", "RETC Montant de cotisation Agirc"));
v.add(Tuple2.create("065", "Cotisation CRPCEN"));
v.add(Tuple2.create("066", "Cotisation caisse de congés spectacles"));
v.add(Tuple2.create("068", "Contribution solidarité autonomie"));
v.add(Tuple2.create("069", "Contribution sur avantage de pré-retraite entreprise à dater du 11/10/2007 (CAPE)"));
v.add(Tuple2.create("070", "Contribution sur avantage de pré-retraite entreprise aux taux normal (CAPE)"));
v.add(Tuple2.create("071", "Contribution forfait social"));
v.add(Tuple2.create("072", "Contribution sociale généralisée/salaires partiellement déductibles"));
v.add(Tuple2.create("073", "CSG/CRDS sur participation intéressement épargne salariale"));
v.add(Tuple2.create("074", "Cotisation Allocation familiale taux normal "));
v.add(Tuple2.create("075", "Cotisation Assurance Maladie"));
v.add(Tuple2.create("076", "Cotisation Assurance Vieillesse"));
v.add(Tuple2.create("077", "Montant de la retenue à la source effectuée sur les salaires versés aux personnes domiciliées hors de France"));
v.add(Tuple2.create("078", "Pénalité de 1% emploi sénior"));
v.add(Tuple2.create("079", "Remboursement de la dette sociale"));
v.add(Tuple2.create("081", "Versement transport"));
v.add(Tuple2.create("082", "Versement transport additionnel"));
v.add(Tuple2.create("086", "Cotisation pénibilité mono exposition"));
v.add(Tuple2.create("087", "Cotisation pénibilité multi exposition"));
v.add(Tuple2.create("088", "Exonération versement transport"));
v.add(Tuple2.create("089", "Exonération Contrat Initiative Emploi"));
v.add(Tuple2.create("090", "Exonération accueillants familiaux"));
v.add(Tuple2.create("091", "Cotisation Service de santé au travail"));
v.add(Tuple2.create("092", "Cotisation Association pour l'emploi des cadres ingénieurs et techniciens de l'agriculture (APECITA)"));
v.add(Tuple2.create("093", "Contribution sur indemnités de mise à la retraite"));
v.add(Tuple2.create("094", "Exonération cotisations Allocations familiales (SICAE)"));
v.add(Tuple2.create("096", "Cotisation CRPNPAC au fonds de retraite"));
v.add(Tuple2.create("097", "Cotisation CRPNPAC au fonds d'assurance"));
v.add(Tuple2.create("098", "Cotisation CRPNPAC au fonds de majoration"));
v.add(Tuple2.create("099", "Contribution stock options"));
v.add(Tuple2.create("100", "Contribution pour le financement des organisations syndicales de salariés et organisations professionnelles d'employeurs"));
v.add(Tuple2.create("101", "Association Mutualisation du Coût Inaptitude"));
v.add(Tuple2.create("102", "Cotisation Allocation Familiale - taux réduit"));
v.add(Tuple2.create("103", "Contribution actions gratuites"));
v.add(Tuple2.create("226", "Assiette du Versement Transport"));
v.add(Tuple2.create("901", "Cotisation épargne retraite"));
 
insertValues(v, table);
 
List<Tuple2<String, String>> vCodeBase = new ArrayList<Tuple2<String, String>>();
vCodeBase.add(Tuple2.create("15", "CNIEG-Assiette brute du régime spécial"));
vCodeBase.add(Tuple2.create("16", "CNIEG-Assiette brute du complément invalidité"));
vCodeBase.add(Tuple2.create("17", "CNIEG - Assiette brute du petit pool"));
vCodeBase.add(Tuple2.create("18", "Camieg - assiette brute plafonnée"));
vCodeBase.add(Tuple2.create("19", "Assiette CRPCEN"));
vCodeBase.add(Tuple2.create("20", "CIBTP - Base brute de cotisations congés payés"));
vCodeBase.add(Tuple2.create("21", "CIBTP - Base brute de cotisations OPPBTP permanents"));
vCodeBase.add(Tuple2.create("22", "Base brute spécifique"));
vCodeBase.add(Tuple2.create("23", "Base exceptionnelle (Agirc Arrco)"));
vCodeBase.add(Tuple2.create("24", "Base plafonnée spécifique"));
vCodeBase.add(Tuple2.create("25", "Assiette de contribution libératoire"));
vCodeBase.add(Tuple2.create("27", "Assiette Caisse de congés spectacles"));
vCodeBase.add(Tuple2.create("28", "Base IRCANTEC cotisée"));
vCodeBase.add(Tuple2.create("29", "Base IRCANTEC non cotisée (arrêt de travail)"));
vCodeBase.add(Tuple2.create("31", "Eléments de cotisation Prévoyance, Santé, retraite supplémentaire"));
vCodeBase.add(Tuple2.create("33", "Assiette Contribution sur les avantages de préretraite entreprise"));
vCodeBase.add(Tuple2.create("34", "CIBTP -Base plafonnée de cotisations intempéries gros oeuvre travaux publics"));
vCodeBase.add(Tuple2.create("35", "CIBTP -Base plafonnée de cotisations intempéries second oeuvre"));
vCodeBase.add(Tuple2.create("36", "CIBTP -Base \"A\" de cotisations organisme professionnel BTP"));
vCodeBase.add(Tuple2.create("37", "Assiette de pénibilité"));
vCodeBase.add(Tuple2.create("38", "Rémunération pour le calcul de la réduction Travailleur Occasionnel"));
vCodeBase.add(Tuple2.create("39", "CIBTP -Base \"B\" de cotisations organisme professionnel BTP"));
vCodeBase.add(Tuple2.create("40", "CIBTP -Base \"C\" de cotisations organisme professionnel BTP"));
vCodeBase.add(Tuple2.create("41", "CRPNPAC-Assiette soumise au taux normal (non-plafonnée)"));
vCodeBase.add(Tuple2.create("42", "CRPNPAC-Assiette soumise au taux majoré (non-plafonnée)"));
vCodeBase.add(Tuple2.create("43", "Base plafonnée exceptionnelle Agirc Arrco"));
vCodeBase.add(Tuple2.create("44", "Assiette du forfait social à 16%"));
vCodeBase.add(Tuple2.create("45", "Base plafonnée ICP Agirc-Arrco"));
vCodeBase.add(Tuple2.create("90", "Autre revenu net imposable"));
insertValues(vCodeBase, root.getTable("CODE_BASE_ASSUJETTIE"));
 
AlterTable tableRubCotis = new AlterTable(tableRubCot);
tableRubCotis.addForeignColumn("ID_CODE_COTISATION_INDIVIDUELLE", root.getTable("CODE_COTISATION_INDIVIDUELLE"));
root.getBase().getDataSource().execute(tableRubCotis.asString());
root.refetchTable(tableRubCot.getName());
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_COTISATION_INDIVIDUELLE", ex);
}
{
final SQLTable tableCodeBase = root.getTable("CODE_BASE_ASSUJETTIE");
SQLSelect selCodeBase = new SQLSelect();
selCodeBase.addSelectStar(tableCodeBase);
List<SQLRow> rowsCodeBase = SQLRowListRSH.execute(selCodeBase);
Map<String, SQLRow> mapCodeBase = new HashMap<String, SQLRow>();
for (SQLRow sqlRow : rowsCodeBase) {
 
final String string = sqlRow.getString("CODE");
mapCodeBase.put(string, sqlRow);
}
final SQLTable tableCodeTypeComp = root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
SQLSelect selCodeTypeComp = new SQLSelect();
selCodeTypeComp.addSelectStar(tableCodeTypeComp);
List<SQLRow> rowsTypeComp = SQLRowListRSH.execute(selCodeTypeComp);
Map<String, SQLRow> mapTypeComp = new HashMap<String, SQLRow>();
for (SQLRow sqlRow : rowsTypeComp) {
final String string = sqlRow.getString("CODE");
mapTypeComp.put(string, sqlRow);
}
final SQLTable tableCodeCotInd = root.getTable("CODE_COTISATION_INDIVIDUELLE");
SQLSelect selCodeCodeInd = new SQLSelect();
selCodeCodeInd.addSelectStar(tableCodeCotInd);
List<SQLRow> rowsCodeInd = SQLRowListRSH.execute(selCodeCodeInd);
Map<String, SQLRow> mapCodeInd = new HashMap<String, SQLRow>();
for (SQLRow sqlRow : rowsCodeInd) {
final String string = sqlRow.getString("CODE");
mapCodeInd.put(string, sqlRow);
}
final SQLTable tableCaisse = root.getTable("CAISSE_COTISATION");
SQLSelect selCodeCodeCaisse = new SQLSelect();
selCodeCodeCaisse.addSelectStar(tableCaisse);
List<SQLRow> rowsCodeCaisse = SQLRowListRSH.execute(selCodeCodeCaisse);
Map<String, SQLRow> mapCodeCaisse = new HashMap<String, SQLRow>();
for (SQLRow sqlRow : rowsCodeCaisse) {
final String string = sqlRow.getString("NOM");
mapCodeCaisse.put(string, sqlRow);
}
if (mapCodeCaisse.containsKey("ARRCO")) {
UpdateBuilder updaterRubCot = new UpdateBuilder(tableRubCot);
updaterRubCot.setObject("ID_CODE_BASE_ASSUJETTIE", mapCodeBase.get("02").getID());
updaterRubCot.setObject("ID_CODE_COTISATION_INDIVIDUELLE", mapCodeInd.get("063").getID());
// updaterRubCot.setObject("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE",
// mapTypeComp.get("03").getID());
updaterRubCot.setWhere(new Where(tableRubCot.getField("ID_CAISSE_COTISATION"), "=", mapCodeCaisse.get("ARRCO").getID()));
root.getBase().getDataSource().execute(updaterRubCot.asString());
}
if (mapCodeCaisse.containsKey("AGIRC")) {
UpdateBuilder updaterRubCot = new UpdateBuilder(tableRubCot);
updaterRubCot.setObject("ID_CODE_BASE_ASSUJETTIE", mapCodeBase.get("03").getID());
updaterRubCot.setObject("ID_CODE_COTISATION_INDIVIDUELLE", mapCodeInd.get("064").getID());
// updaterRubCot.setObject("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE",
// mapTypeComp.get("03").getID());
updaterRubCot.setWhere(new Where(tableRubCot.getField("ID_CAISSE_COTISATION"), "=", mapCodeCaisse.get("AGIRC").getID()));
root.getBase().getDataSource().execute(updaterRubCot.asString());
}
}
}
 
if (!tableRubNet.contains("ID_CODE_COTISATION_INDIVIDUELLE")) {
AlterTable alterRubNet = new AlterTable(tableRubNet);
alterRubNet.addForeignColumn("ID_CODE_COTISATION_INDIVIDUELLE", root.getTable("CODE_COTISATION_INDIVIDUELLE"));
root.getBase().getDataSource().execute(alterRubNet.asString());
root.refetchTable(tableRubNet.getName());
root.getSchema().updateVersion();
}
if (!tableRubNet.contains("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE")) {
AlterTable alterRubNet = new AlterTable(tableRubNet);
alterRubNet.addForeignColumn("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE", root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE"));
root.getBase().getDataSource().execute(alterRubNet.asString());
root.refetchTable(tableRubNet.getName());
root.getSchema().updateVersion();
}
if (!tableRubNet.contains("ID_CODE_BASE_ASSUJETTIE")) {
AlterTable alterRubNet = new AlterTable(tableRubNet);
alterRubNet.addForeignColumn("ID_CODE_BASE_ASSUJETTIE", root.getTable("CODE_BASE_ASSUJETTIE"));
root.getBase().getDataSource().execute(alterRubNet.asString());
root.refetchTable(tableRubNet.getName());
root.getSchema().updateVersion();
}
 
if (!tableRubNet.contains("ID_CAISSE_COTISATION")) {
AlterTable alterRubNet = new AlterTable(tableRubNet);
alterRubNet.addForeignColumn("ID_CAISSE_COTISATION", root.getTable("CAISSE_COTISATION"));
root.getBase().getDataSource().execute(alterRubNet.asString());
root.refetchTable(tableRubNet.getName());
root.getSchema().updateVersion();
}
 
if (!root.contains("CODE_COTISATION_ETABLISSEMENT")) {
final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_COTISATION_ETABLISSEMENT");
createTableTypeComposant.addVarCharColumn("CODE", 25);
createTableTypeComposant.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableTypeComposant.asString());
insertUndef(createTableTypeComposant);
root.refetchTable("CODE_COTISATION_ETABLISSEMENT");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("CODE_COTISATION_ETABLISSEMENT");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
 
v.add(Tuple2.create("001", "Cotisation ADPFA (Association pour le Développement du Paritarisme des Fleuristes et Animaliers)"));
v.add(Tuple2.create("002", "Cotisation APNAB (Association Paritaire Nationale pour le développement de la négociation collective dans l'Artisanat du Bâtiment)"));
v.add(Tuple2.create("003 ", "Cotisation sur assiette avec congés payés CCCA-BTP (Comité de Concertation et de Coordination de l'apprentissage du Bâtiment et des Travaux Publics)"));
v.add(Tuple2.create("004 ", "Cotisation CPPNTT (Commission Paritaire Professionnelle Nationale du Travail Temporaire)"));
v.add(Tuple2.create("005 ", "Cotisation Développement du paritarisme"));
v.add(Tuple2.create("006 ", "Cotisation Dialogue social"));
v.add(Tuple2.create("007 ", "Cotisation FAF (Fonds d'Assurance formation)"));
v.add(Tuple2.create("009 ", "Cotisation FAPS (Fonds d'action professionnelle et sociale)"));
v.add(Tuple2.create("010 ", "Cotisation FASTT (Fonds d'Action Sociale du Travail Temporaire)"));
v.add(Tuple2.create("011 ", "Cotisation Fonds de péréquation"));
v.add(Tuple2.create("012 ", "Cotisation IFC (Indemnités de fin de carrière)"));
v.add(Tuple2.create("017 ", "Cotisation ORGA (Organisations Syndicales du Travail Temporaire)"));
v.add(Tuple2.create("018 ", "Cotisation Promotion et recrutement"));
v.add(Tuple2.create("019 ", "Cotisations attachées à une population de non salariés ayants"));
v.add(Tuple2.create("020 ", "Cotisations attachées à une population de non salariés retraités"));
v.add(Tuple2.create("021 ", "Cotisations FMSE (Fond national agricole de mutualisation des risques sanitaires et environnementaux)"));
v.add(Tuple2.create("022 ", "Cotisations VAL'HOR (association française pour la valorisation des produits et métiers de l'horticulture et du paysage)"));
v.add(Tuple2.create("023 ", "Chiffre d'affaire"));
v.add(Tuple2.create("024 ", "Nombre d'heures d'intérim"));
v.add(Tuple2.create("025 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Rente"));
v.add(Tuple2.create("026 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Prime"));
v.add(Tuple2.create("027 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Dotations"));
v.add(Tuple2.create("028 ", "Contribution additionnelle sur les rentes liquidées"));
v.add(Tuple2.create("029 ", "Contribution aux régimes supplémentaires de retraite à prestations définies. Rente à taux 7%"));
v.add(Tuple2.create("030 ", "Contribution aux régimes supplémentaires de retraite à prestations définies. Rente à taux 14%"));
v.add(Tuple2.create("031 ", "Contribution additionnelle de solidarité pour l'autonomie"));
v.add(Tuple2.create("032 ", "Contribution Sociale généralisée au taux de 3,80% + RDS sur revenu de remplacement "));
v.add(Tuple2.create("033 ", "Contribution Sociale généralisée au taux de 6,20% + RDS sur revenu de remplacement "));
v.add(Tuple2.create("034 ", "Contribution Sociale généralisée au taux de 6,60% + RDS sur revenu de remplacement "));
v.add(Tuple2.create("035 ", "Contribution Sociale généralisée au taux de 7,50% + RDS sur revenu de remplacement "));
v.add(Tuple2.create("036 ", "Cotisation TTC sur assiette CDD avec congés payés pour le secteur du BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
v.add(Tuple2.create("037 ", "Cotisation TTC sur assiette avec congés payés pour le secteur du BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
v.add(Tuple2.create("038 ", "Cotisation TTC sur assiette sans congés payés (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
v.add(Tuple2.create("039 ",
"Cotisation TTC sur assiette avec congés payés pour les salariés non soumis à la cotisation CCCA-BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
v.add(Tuple2.create("040 ",
"Cotisation TTC sur assiette hors congés payés pour les salariés non soumis à la cotisation CCCA-BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
v.add(Tuple2.create("041 ", "Cotisation maladie sur les avantages de préretraite"));
v.add(Tuple2.create("042 ", "Cotisation maladie sur les avantages de retraite"));
v.add(Tuple2.create("043 ", "Cotisation maladie Alsace-Moselle sur les avantages de retraite"));
v.add(Tuple2.create("044 ", "Cotisation forfait social à 8%"));
v.add(Tuple2.create("045 ", "Cotisation forfait social à 20%"));
v.add(Tuple2.create("090 ", "Cotisation spécifique Prévoyance"));
 
insertValues(v, table);
 
AlterTable tableRubCotis = new AlterTable(tableRubCot);
tableRubCotis.addForeignColumn("ID_CODE_COTISATION_ETABLISSEMENT", root.getTable("CODE_COTISATION_ETABLISSEMENT"));
root.getBase().getDataSource().execute(tableRubCotis.asString());
root.refetchTable(tableRubCot.getName());
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_COTISATION_ETABLISSEMENT", ex);
}
}
 
if (!root.contains("CODE_PENIBILITE")) {
final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_PENIBILITE");
createTableTypeComposant.addVarCharColumn("CODE", 25);
createTableTypeComposant.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableTypeComposant.asString());
insertUndef(createTableTypeComposant);
root.refetchTable("CODE_PENIBILITE");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("CODE_PENIBILITE");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
 
v.add(Tuple2.create("01", "les manutentions manuelles de charges"));
v.add(Tuple2.create("02", "les postures pénibles (positions forcées des articulations)"));
v.add(Tuple2.create("03", "les vibrations mécaniques"));
v.add(Tuple2.create("04", "les agents chimiques dangereux"));
v.add(Tuple2.create("05", "les activités exercées en milieu hyperbare"));
v.add(Tuple2.create("06", "les températures extrêmes"));
v.add(Tuple2.create("07", "le bruit"));
v.add(Tuple2.create("08", "le travail de nuit"));
v.add(Tuple2.create("09", "le travail en équipes successives alternantes"));
v.add(Tuple2.create("10", "le travail répétitif (répétition d'un même geste, à une cadence contrainte avec un temps de cycle défini)"));
v.add(Tuple2.create("99", "annulation"));
 
insertValues(v, table);
 
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_PENIBILITE", ex);
}
}
 
if (!root.contains("AYANT_DROIT_TYPE")) {
final SQLCreateTable createTableTypeAyantDroit = new SQLCreateTable(root, "AYANT_DROIT_TYPE");
createTableTypeAyantDroit.addVarCharColumn("CODE", 25);
createTableTypeAyantDroit.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableTypeAyantDroit.asString());
insertUndef(createTableTypeAyantDroit);
root.refetchTable("AYANT_DROIT_TYPE");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("AYANT_DROIT_TYPE");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
 
v.add(Tuple2.create("01", "Adultes (conjoint, concubin, pacs)"));
v.add(Tuple2.create("02", "Enfant"));
v.add(Tuple2.create("03", "Autre (ascendant, collatéraux, ...)"));
 
insertValues(v, table);
 
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "AYANT_DROIT_TYPE", ex);
}
}
 
}
 
public void updateDSN(final DBRoot root) throws SQLException {
final SQLTable tableCodeStatutCat = root.getTable("CODE_STATUT_CATEGORIEL");
SQLRow rowNonCadre = tableCodeStatutCat.getRow(4);
566,7 → 1106,18
if (rowSansStatut != null) {
rowSansStatut.createEmptyUpdateRow().put("CODE", "99").commit();
}
// 04 non cadre
UpdateBuilder up04 = new UpdateBuilder(tableCodeStatutCat);
up04.setObject("NOM", "Non cadre");
up04.setWhere(new Where(tableCodeStatutCat.getField("CODE"), "=", "04"));
root.getBase().getDataSource().execute(up04.asString());
 
// 99 - pas de retraite complémentaire
UpdateBuilder up99 = new UpdateBuilder(tableCodeStatutCat);
up99.setObject("NOM", "Pas de retraite complémentaire");
up99.setWhere(new Where(tableCodeStatutCat.getField("CODE"), "=", "99"));
root.getBase().getDataSource().execute(up99.asString());
 
if (!root.contains("ARRET_TRAVAIL")) {
 
final SQLCreateTable createTable = new SQLCreateTable(root, "ARRET_TRAVAIL");
591,6 → 1142,37
}
}
 
if (!root.contains("FIN_CONTRAT")) {
 
final SQLCreateTable createTable = new SQLCreateTable(root, "FIN_CONTRAT");
createTable.addForeignColumn("FICHE_PAYE");
createTable.addForeignColumn("ID_MOTIF_FIN_CONTRAT", root.findTable("MOTIF_FIN_CONTRAT"));
createTable.addDateAndTimeColumn("DATE_FIN");
createTable.addDateAndTimeColumn("DATE_NOTIFICATION");
createTable.addDateAndTimeColumn("DATE_SIGNATURE_CONVENTION");
createTable.addDateAndTimeColumn("DATE_ENGAGEMENT_PROCEDURE");
createTable.addDateAndTimeColumn("DERNIER_JOUR_TRAV_PAYE");
createTable.addBooleanColumn("TRANSACTION_EN_COURS", Boolean.FALSE, false);
createTable.addBooleanColumn("PORTABILITE_PREVOYANCE", Boolean.FALSE, false);
createTable.addIntegerColumn("NB_DIF_RESTANT", null, true);
createTable.addIntegerColumn("NB_MOIS_CSP", null, true);
createTable.addDecimalColumn("SALAIRE_NET_HORAIRE", 16, 8, null, true);
createTable.addDecimalColumn("INDEMNITE_VERSE", 16, 8, null, true);
createTable.addForeignColumn("ID_TYPE_PREAVIS", root.findTable("TYPE_PREAVIS"));
createTable.addDateAndTimeColumn("DATE_DEBUT_PREAVIS");
createTable.addDateAndTimeColumn("DATE_FIN_PREAVIS");
createTable.addVarCharColumn("INFOS", 2048);
 
try {
root.getBase().getDataSource().execute(createTable.asString());
insertUndef(createTable);
root.refetchTable("FIN_CONTRAT");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "FIN_CONTRAT", ex);
}
}
 
if (!root.contains("REPRISE_TRAVAIL")) {
 
final SQLCreateTable createTable = new SQLCreateTable(root, "REPRISE_TRAVAIL");
659,6 → 1241,13
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
if (!tableDsn.contains("ID_FIN_CONTRAT")) {
AlterTable alter = new AlterTable(tableDsn);
alter.addForeignColumn("ID_FIN_CONTRAT", root.findTable("FIN_CONTRAT"));
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
 
if (!tableDsn.contains("ID_REPRISE_TRAVAIL")) {
AlterTable alter = new AlterTable(tableDsn);
alter.addForeignColumn("ID_REPRISE_TRAVAIL", root.findTable("REPRISE_TRAVAIL"));
678,7 → 1267,35
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
if (!tableDsn.contains("NUMERO_REFERENCE")) {
AlterTable alter = new AlterTable(tableDsn);
alter.addVarCharColumn("NUMERO_REFERENCE", 256);
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
if (!tableDsn.contains("ID_DECLARATION_DSN_ANNULATION")) {
AlterTable alter = new AlterTable(tableDsn);
alter.addForeignColumn("ID_DECLARATION_DSN_ANNULATION", tableDsn);
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
if (!tableDsn.contains("EFFECTIF_CVAE")) {
AlterTable alter = new AlterTable(tableDsn);
alter.addIntegerColumn("EFFECTIF_CVAE", null, true);
alter.addVarCharColumn("CODE_INSEE_CVAE", 32);
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
root.refetchTable(tableDsn.getName());
}
 
if (!tableDsn.contains("PERIODE_CVAE_DEBUT")) {
AlterTable alter = new AlterTable(tableDsn);
alter.addColumn("PERIODE_CVAE_DEBUT", "date");
alter.addColumn("PERIODE_CVAE_FIN", "date");
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
 
// if (!root.contains("FIN_CONTRAT")) {
//
// final SQLCreateTable createTable = new SQLCreateTable(root, "FIN_CONTRAT");
815,7 → 1432,153
createEmptyUpdateRow.commit();
}
}
if (!root.contains("CONTRAT_PREVOYANCE")) {
 
final SQLCreateTable createTable = new SQLCreateTable(root, "CONTRAT_PREVOYANCE");
createTable.addVarCharColumn("REFERENCE", 256);
createTable.addDateAndTimeColumn("DATE_DEBUT");
createTable.addDateAndTimeColumn("DATE_FIN");
createTable.addVarCharColumn("CODE_ORGANISME", 256);
createTable.addVarCharColumn("CODE_DELEGATAIRE", 256);
createTable.addVarCharColumn("CODE_UNIQUE", 256);
createTable.addVarCharColumn("NOM", 256);
try {
root.getBase().getDataSource().execute(createTable.asString());
insertUndef(createTable);
root.refetchTable("CONTRAT_PREVOYANCE");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE", ex);
}
}
if (!root.getTable("CONTRAT_PREVOYANCE").contains("COTISATION_ETABLISSEMENT")) {
AlterTable tableContratP = new AlterTable(root.getTable("CONTRAT_PREVOYANCE"));
tableContratP.addBooleanColumn("COTISATION_ETABLISSEMENT", Boolean.FALSE, false);
root.getBase().getDataSource().execute(tableContratP.asString());
root.refetchTable("CONTRAT_PREVOYANCE");
root.getSchema().updateVersion();
}
 
if (!root.contains("CONTRAT_PREVOYANCE_CONTRAT_SALARIE")) {
 
final SQLCreateTable createTableSal = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_CONTRAT_SALARIE");
final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
createTableSal.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
createTableSal.addVarCharColumn("CODE_OPTION", 256);
createTableSal.addVarCharColumn("CODE_POPULATION", 256);
createTableSal.addIntegerColumn("NB_ENFANT_CHARGE", null, true);
createTableSal.addIntegerColumn("NB_ADULTE_AYANT_DROIT", null, true);
createTableSal.addIntegerColumn("NB_AYANT_DROIT", null, true);
createTableSal.addIntegerColumn("NB_AYANT_DROIT_AUTRE", null, true);
createTableSal.addIntegerColumn("NB_ENFANT_AYANT_DROIT", null, true);
 
try {
root.getBase().getDataSource().execute(createTableSal.asString());
insertUndef(createTableSal);
root.refetchTable("CONTRAT_PREVOYANCE_CONTRAT_SALARIE");
root.getSchema().updateVersion();
 
String up = "UPDATE " + new SQLName(root.getName(), tableInfosSalarie.getName()).quote() + " i SET \"ID_SALARIE\" = (SELECT s.\"ID\" FROM "
+ new SQLName(root.getName(), tableInfosSalarie.getForeignTable("ID_SALARIE").getName()).quote() + " s WHERE s.\"ID_INFOS_SALARIE_PAYE\"=i.\"ID\" and s.\"ARCHIVE\"=0)"
+ " WHERE i.\"ID\" IN (SELECT i2.\"ID_INFOS_SALARIE_PAYE\" FROM " + new SQLName(root.getName(), tableInfosSalarie.getForeignTable("ID_SALARIE").getName()).quote();
up += " i2 WHERE i2.\"ARCHIVE\"=0)";
 
root.getBase().getDataSource().execute(up);
 
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_SALARIE", ex);
}
}
if (!root.contains("CONTRAT_PREVOYANCE_RUBRIQUE"))
 
{
 
final SQLCreateTable createTableRub = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_RUBRIQUE");
createTableRub.addForeignColumn("ID_RUBRIQUE_COTISATION", root.findTable("RUBRIQUE_COTISATION"));
createTableRub.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
 
try {
root.getBase().getDataSource().execute(createTableRub.asString());
insertUndef(createTableRub);
root.refetchTable("CONTRAT_PREVOYANCE_RUBRIQUE");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_RUBRIQUE", ex);
}
}
 
if (!root.contains("CONTRAT_PREVOYANCE_RUBRIQUE_NET"))
 
{
 
final SQLCreateTable createTableRub = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_RUBRIQUE_NET");
createTableRub.addForeignColumn("ID_RUBRIQUE_NET", root.findTable("RUBRIQUE_NET"));
createTableRub.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
 
try {
root.getBase().getDataSource().execute(createTableRub.asString());
insertUndef(createTableRub);
root.refetchTable("CONTRAT_PREVOYANCE_RUBRIQUE_NET");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_RUBRIQUE_NET", ex);
}
}
if (!root.contains("AYANT_DROIT")) {
 
final SQLCreateTable createTableAyantDroit = new SQLCreateTable(root, "AYANT_DROIT");
createTableAyantDroit.addVarCharColumn("NOM", 256);
createTableAyantDroit.addForeignColumn("ID_SALARIE", root.findTable("SALARIE"));
createTableAyantDroit.addForeignColumn("ID_AYANT_DROIT_TYPE", root.findTable("AYANT_DROIT_TYPE"));
createTableAyantDroit.addBooleanColumn("REGIME_ALSACE", Boolean.FALSE, false);
createTableAyantDroit.addVarCharColumn("NIR", 256);
createTableAyantDroit.addVarCharColumn("PRENOMS", 256);
createTableAyantDroit.addVarCharColumn("CODE_ORGANISME_AFFILIATION", 256);
createTableAyantDroit.addVarCharColumn("CODE_OPTION", 256);
createTableAyantDroit.addVarCharColumn("NIR_OUVRANT_DROIT", 256);
createTableAyantDroit.addDateAndTimeColumn("DATE_DEBUT_RATTACHEMENT");
createTableAyantDroit.addDateAndTimeColumn("DATE_FIN_RATTACHEMENT");
createTableAyantDroit.addDateAndTimeColumn("DATE_NAISSANCE");
try {
root.getBase().getDataSource().execute(createTableAyantDroit.asString());
insertUndef(createTableAyantDroit);
root.refetchTable("AYANT_DROIT");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "AYANT_DROIT", ex);
}
 
final SQLCreateTable createTablePrevAyant = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_AYANT_DROIT");
createTablePrevAyant.addForeignColumn("ID_AYANT_DROIT", root.getTable("AYANT_DROIT"));
createTablePrevAyant.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
 
try {
root.getBase().getDataSource().execute(createTablePrevAyant.asString());
insertUndef(createTablePrevAyant);
root.refetchTable("CONTRAT_PREVOYANCE_AYANT_DROIT");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_AYANT_DROIT", ex);
}
}
if (!root.contains("CODE_PENIBILITE_CONTRAT_SALARIE")) {
 
final SQLCreateTable createTableSal = new SQLCreateTable(root, "CODE_PENIBILITE_CONTRAT_SALARIE");
final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
createTableSal.addForeignColumn("ID_CODE_PENIBILITE", root.findTable("CODE_PENIBILITE"));
 
try {
root.getBase().getDataSource().execute(createTableSal.asString());
insertUndef(createTableSal);
root.refetchTable("CODE_PENIBILITE_CONTRAT_SALARIE");
root.getSchema().updateVersion();
 
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_PENIBILITE_CONTRAT_SALARIE", ex);
}
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/config/Benchmark.java
New file
0,0 → 1,105
/*
* 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.config;
 
import org.openconcerto.sql.model.IResultSetHandler;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
 
import org.apache.commons.dbutils.ResultSetHandler;
 
public class Benchmark {
public Benchmark() {
 
}
 
public static void main(String[] args) throws IOException {
Benchmark b = new Benchmark();
b.testWriteHD();
System.err.println(b.testCPU());
}
 
public String testDB() {
IResultSetHandler h = new IResultSetHandler(new ResultSetHandler() {
 
@Override
public Object handle(ResultSet arg0) throws SQLException {
return null;
}
}, false, false);
long t1 = System.currentTimeMillis();
int c = 0;
SQLSelect s = new SQLSelect();
SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRoot().getDBSystemRoot().findTable("FWK_SCHEMA_METADATA");
s.addSelect(t.getField("NAME"));
final SQLDataSource dataSource = ComptaPropsConfiguration.getInstanceCompta().getRoot().getDBSystemRoot().getDataSource();
for (int i = 0; i < 1000000; i++) {
final String sql = s.asString();
dataSource.execute(sql, h);
long t2 = System.currentTimeMillis();
if (t2 > t1 + 2000) {
c = i;
break;
}
}
return (c / 2) + " req/s";
}
 
public String testCPU() {
long t0 = System.currentTimeMillis();
double b[] = new double[1024 * 1024 * 50];
for (int i = 0; i < b.length; i++) {
b[i] = i * 456;
}
for (int k = 0; k < 10; k++) {
for (int i = k; i < b.length - 2; i++) {
b[i] = b[i] + b[i + 1] + 1 / b[i + 2];
}
}
long t1 = System.currentTimeMillis();
final long time = t1 - t0;
double speed = b.length / time;
 
return Math.round(speed / 100) + " R/s";
}
 
public String testWriteHD() throws IOException {
long t0 = System.currentTimeMillis();
long nbTest = 2;
final int size = 100 * 1024 * 1024;
for (int i = 0; i < nbTest; i++) {
File f = File.createTempFile("benchmark", ".raw");
FileOutputStream fOp = new FileOutputStream(f);
 
byte[] b = new byte[size];
fOp.write(b);
fOp.flush();
fOp.close();
f.delete();
}
long t1 = System.currentTimeMillis();
final long time = t1 - t0;
long s = nbTest * size;
double speed = s / time;
String result = Math.round(speed / 1000) + " MB/s";
return result;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mapping-KD_fr.xml
34,6 → 34,9
<FIELD name="DATE_PREV" label="Intervention prévue le" />
<FIELD name="INDICE_0" label="Indice Syntec de base" />
<FIELD name="SEND_POST_MAIL" label="Envoyer une copie du rapport par courrier" />
<FIELD name="ID_USER_COMMON_SAISIE" label="Opératrice de saisie" />
<FIELD name="TEMPS_SAISIE" label="Temps de saisie" />
<FIELD name="DATE_SAISIE_REELLE" label="Date de saisie réelle" />
</TABLE>
 
<TABLE name="DEVIS_ELEMENT">
/trunk/OpenConcerto/src/org/openconcerto/erp/config/translation_en.xml
194,6 → 194,7
<action id="sales.invoice.clone" label="Copy from" />
<action id="sales.invoice.info.show" label="Customer info" />
<action id="sales.invoice.create.supplier.order" label="Transfer to supplier order" />
<action id="sales.invoice.cancel.credit" label="Cancel credit" />
<action id="sales.shipment.create.invoice" label="Transfer to invoice" />
 
<!-- Document -->
/trunk/OpenConcerto/src/org/openconcerto/erp/config/ComptaPropsConfiguration.java
27,6 → 27,7
import org.openconcerto.erp.core.common.element.StyleSQLElement;
import org.openconcerto.erp.core.common.element.TitrePersonnelSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientDepartementSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CompteClientTransactionSQLELement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement.ContactAdministratifSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement.ContactFournisseurSQLElement;
37,6 → 38,7
import org.openconcerto.erp.core.customerrelationship.customer.element.ReferenceClientSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.RelanceSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.TypeLettreRelanceSQLElement;
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.AssociationAnalytiqueSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.AssociationCompteAnalytiqueSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.AxeAnalytiqueSQLElement;
54,6 → 56,7
import org.openconcerto.erp.core.finance.accounting.element.SaisieKmItemSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.SaisieKmSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.TypeComptePCGSQLElement;
import org.openconcerto.erp.core.finance.accounting.model.Currency;
import org.openconcerto.erp.core.finance.payment.element.ChequeAEncaisserSQLElement;
import org.openconcerto.erp.core.finance.payment.element.ChequeAvoirClientSQLElement;
import org.openconcerto.erp.core.finance.payment.element.ChequeFournisseurSQLElement;
64,6 → 67,7
import org.openconcerto.erp.core.finance.payment.element.ReglerMontantSQLElement;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.erp.core.finance.tax.element.EcoTaxeSQLElement;
import org.openconcerto.erp.core.finance.tax.element.TaxeComplementaireSQLElement;
import org.openconcerto.erp.core.finance.tax.element.TaxeSQLElement;
import org.openconcerto.erp.core.humanresources.employe.SituationFamilialeSQLElement;
import org.openconcerto.erp.core.humanresources.employe.element.CommercialSQLElement;
70,15 → 74,24
import org.openconcerto.erp.core.humanresources.employe.element.EtatCivilSQLElement;
import org.openconcerto.erp.core.humanresources.employe.element.ObjectifSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.AcompteSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.AyantDroitContratPrevSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.AyantDroitSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.AyantDroitTypeSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationRenseignentSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseModePaiementSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ClassementConventionnelSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeBaseAssujettieSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCaisseTypeRubriqueSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCaractActiviteSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeContratTravailSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCotisationEtablissementSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCotisationIndividuelleSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeDroitContratSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeEmploiSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeIdccSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodePenibiliteContratSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodePenibiliteSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeRegimeSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutCategorielConventionnelSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutCategorielSQLElement;
89,6 → 102,10
import org.openconcerto.erp.core.humanresources.payroll.element.ContratDispositifPolitiqueSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratModaliteTempsSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratMotifRecoursSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceRubriqueNetSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceRubriqueSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceSalarieSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratRegimeMaladieSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratRegimeVieillesseSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratSalarieSQLElement;
113,6 → 130,8
import org.openconcerto.erp.core.humanresources.payroll.element.RubriqueCotisationSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.RubriqueNetSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.SalarieSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.TypeComposantBaseAssujettieSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.TypePreavisSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.TypeRubriqueBrutSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.TypeRubriqueNetSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement;
132,11 → 151,14
import org.openconcerto.erp.core.sales.pos.element.CaisseTicketSQLElement;
import org.openconcerto.erp.core.sales.pos.element.SaisieVenteComptoirSQLElement;
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
import org.openconcerto.erp.core.sales.price.element.DeviseSQLElement;
import org.openconcerto.erp.core.sales.price.element.TarifSQLElement;
import org.openconcerto.erp.core.sales.product.element.ArticleDesignationSQLElement;
import org.openconcerto.erp.core.sales.product.element.ArticleTarifSQLElement;
import org.openconcerto.erp.core.sales.product.element.EcoContributionSQLElement;
import org.openconcerto.erp.core.sales.product.element.FamilleArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.FamilleEcoContributionSQLElement;
import org.openconcerto.erp.core.sales.product.element.MetriqueSQLElement;
import org.openconcerto.erp.core.sales.product.element.ModeVenteArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.ProductItemSQLElement;
178,6 → 200,7
import org.openconcerto.erp.generationDoc.provider.AdresseVilleClientValueProvider;
import org.openconcerto.erp.generationDoc.provider.AdresseVilleNomClientValueProvider;
import org.openconcerto.erp.generationDoc.provider.DateBLProvider;
import org.openconcerto.erp.generationDoc.provider.DateProvider;
import org.openconcerto.erp.generationDoc.provider.FacturableValueProvider;
import org.openconcerto.erp.generationDoc.provider.FormatedGlobalQtyTotalProvider;
import org.openconcerto.erp.generationDoc.provider.LabelAccountInvoiceProvider;
205,6 → 228,7
import org.openconcerto.erp.generationEcritures.provider.SupplyOrderAccountingRecordsProvider;
import org.openconcerto.erp.injector.AchatAvoirSQLInjector;
import org.openconcerto.erp.injector.ArticleCommandeEltSQLInjector;
import org.openconcerto.erp.injector.BonFactureEltSQLInjector;
import org.openconcerto.erp.injector.BonFactureSQLInjector;
import org.openconcerto.erp.injector.BonReceptionFactureFournisseurSQLInjector;
import org.openconcerto.erp.injector.BrFactureAchatSQLInjector;
224,6 → 248,8
import org.openconcerto.erp.injector.FactureBonSQLInjector;
import org.openconcerto.erp.injector.FactureCommandeSQLInjector;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.erp.storage.CloudStorageEngine;
import org.openconcerto.erp.storage.StorageEngines;
242,16 → 268,17
import org.openconcerto.sql.model.SQLServer;
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.task.TacheActionManager;
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
import org.openconcerto.task.element.FWKListPrefs;
import org.openconcerto.task.element.FWKSessionState;
import org.openconcerto.utils.BaseDirs;
import org.openconcerto.utils.DesktopEnvironment;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.NetUtils;
import org.openconcerto.utils.ProductInfo;
import org.openconcerto.utils.StringInputStream;
import org.openconcerto.utils.SwingWorker2;
 
import java.awt.Color;
import java.awt.Font;
286,6 → 313,10
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
 
import eu.medsea.mimeutil.MimeUtil;
import eu.medsea.mimeutil.detector.ExtensionMimeDetector;
import eu.medsea.mimeutil.detector.MagicMimeMimeDetector;
 
/***************************************************************************************************
* Configuration de la gestion: Une base commune "Common" --> société, user, tasks. Une base
* par défaut pour créer une société "Default". Un fichier mapping.xml pour la base commune.
345,16 → 376,12
}
}
 
public static File getConfFile() {
return getConfFile(APP_NAME);
}
 
public static ComptaPropsConfiguration create() {
return create(false);
}
 
public static ComptaPropsConfiguration create(final boolean nullAllowed) {
return create(nullAllowed, getConfFile());
return create(nullAllowed, getConfFile(productInfo));
}
 
public static ComptaPropsConfiguration create(final boolean nullAllowed, final File confFile) {
401,9 → 428,10
private boolean isOnCloud;
private boolean isPortable;
private File portableDir = null;
private Currency currency = null;
 
// isMain=true also set up some VM wide settings
ComptaPropsConfiguration(Properties props, final boolean inWebstart, final boolean main) {
public ComptaPropsConfiguration(Properties props, final boolean inWebstart, final boolean main) {
super(props, productInfo);
this.isMain = main;
this.inWebstart = inWebstart;
440,9 → 468,7
 
//
String token = getToken();
SwingWorker2.setMaxWorkerThreads(4);
if (token != null) {
SwingWorker2.setMaxWorkerThreads(2);
this.isServerless = false;
this.isOnCloud = true;
if (this.getProperty("storage.server") == null) {
488,9 → 514,13
// FIXME
// Local database
{
if (getProperty("server.login") == null) {
setProperty("server.login", "openconcerto");
}
if (getProperty("server.password") == null) {
setProperty("server.password", "openconcerto");
}
}
this.setProperty("server.ip", getProperty("server.ip").replace(DATA_DIR_VAR, getDataDir().getPath()));
final SQLSystem system = getSystem();
this.isServerless = system == SQLSystem.H2 && system.getHostname(getServerIp()) == null;
506,6 → 536,9
registerAccountingProvider();
registerCellValueProvider();
}
 
MimeUtil.registerMimeDetector(ExtensionMimeDetector.class.getName());
MimeUtil.registerMimeDetector(MagicMimeMimeDetector.class.getName());
}
 
private void registerAccountingProvider() {
539,6 → 572,7
MergedGlobalQtyTotalProvider.register();
PaiementRemainedProvider.register();
RemiseProvider.register();
DateProvider.register();
RemiseTotalProvider.register();
RecapFactureProvider.register();
RestantAReglerProvider.register();
632,20 → 666,29
}
 
@Override
protected String getAppIDSuffix() {
public String getAppVariant() {
if (inWebstart())
// so we don't remove files of a normal GestionNX
return super.getAppIDSuffix() + "-webstart";
return super.getAppVariant() + "-webstart";
else
return super.getAppIDSuffix();
return super.getAppVariant();
}
 
@Override
public File getConfDir() {
protected BaseDirs createBaseDirs() {
if (isPortable()) {
return BaseDirs.createPortable(getPortableDir(), this.getProductInfo(), this.getAppVariant());
} else {
return super.createBaseDirs();
}
}
 
@Override
protected final File getOldConfDir() {
if (isPortable) {
return getWD();
} else {
return Gestion.MAC_OS_X ? new File(System.getProperty("user.home") + "/Library/Application Support/" + getAppID()) : super.getConfDir();
return Gestion.MAC_OS_X ? new File(System.getProperty("user.home") + "/Library/Application Support/" + getAppID()) : super.getOldConfDir();
}
}
 
661,8 → 704,13
return this.inWebstart;
}
 
@Deprecated
public File getOldDataDir() {
return new File(this.getOldConfDir(), "DBData");
}
 
public File getDataDir() {
return new File(this.getConfDir(), "DBData");
return new File(this.getBaseDirs().getAppDataFolder(), "DBData");
}
 
private final void createDB(final DBSystemRoot sysRoot) {
724,6 → 772,7
dir.addSQLElement(new SocieteCommonSQLElement());
 
// DSN
dir.addSQLElement(CaisseCotisationRenseignentSQLElement.class);
dir.addSQLElement(CodeBaseAssujettieSQLElement.class);
dir.addSQLElement(ContratModaliteTempsSQLElement.class);
dir.addSQLElement(CodeCaisseTypeRubriqueSQLElement.class);
736,8 → 785,13
dir.addSQLElement(ContratRegimeVieillesseSQLElement.class);
dir.addSQLElement(MotifFinContratSQLElement.class);
dir.addSQLElement(MotifRepriseArretTravailSQLElement.class);
dir.addSQLElement(TypePreavisSQLElement.class);
dir.addSQLElement(DSNNatureSQLElement.class);
 
// ECO
dir.addSQLElement(FamilleEcoContributionSQLElement.class);
dir.addSQLElement(EcoContributionSQLElement.class);
 
return dir;
}
 
745,6 → 799,8
try {
SQLElementDirectory dir = this.getDirectory();
 
dir.addSQLElement(AttachmentSQLElement.class);
 
dir.addSQLElement(ArticleTarifSQLElement.class);
dir.addSQLElement(ReliquatBRSQLElement.class);
dir.addSQLElement(ReliquatSQLElement.class);
812,6 → 868,7
dir.addSQLElement(new ChequeFournisseurSQLElement());
dir.addSQLElement(new CustomerCategorySQLElement());
dir.addSQLElement(new CustomerSQLElement());
dir.addSQLElement(new CompteClientTransactionSQLELement());
dir.addSQLElement(new CourrierClientSQLElement());
 
dir.addSQLElement(new ClassementConventionnelSQLElement());
829,6 → 886,13
dir.addSQLElement(new ComptePCGSQLElement());
 
dir.addSQLElement(new ContratSalarieSQLElement());
dir.addSQLElement(ContratPrevoyanceSQLElement.class);
dir.addSQLElement(ContratPrevoyanceRubriqueSQLElement.class);
dir.addSQLElement(ContratPrevoyanceRubriqueNetSQLElement.class);
dir.addSQLElement(ContratPrevoyanceSalarieSQLElement.class);
dir.addSQLElement(AyantDroitSQLElement.class);
dir.addSQLElement(AyantDroitTypeSQLElement.class);
dir.addSQLElement(AyantDroitContratPrevSQLElement.class);
 
dir.addSQLElement(new CodeRegimeSQLElement());
dir.addSQLElement(new CodeEmploiSQLElement());
839,6 → 903,13
dir.addSQLElement(new CodeStatutCategorielSQLElement());
dir.addSQLElement(CodeStatutCategorielConventionnelSQLElement.class);
dir.addSQLElement(new CodeStatutProfSQLElement());
dir.addSQLElement(CaisseModePaiementSQLElement.class);
dir.addSQLElement(CodeCotisationIndividuelleSQLElement.class);
dir.addSQLElement(CodeCotisationEtablissementSQLElement.class);
dir.addSQLElement(CodePenibiliteSQLElement.class);
dir.addSQLElement(CodePenibiliteContratSQLElement.class);
dir.addSQLElement(TypeComposantBaseAssujettieSQLElement.class);
 
dir.addSQLElement(new CumulsCongesSQLElement());
dir.addSQLElement(new CumulsPayeSQLElement());
 
917,6 → 988,7
 
dir.addSQLElement(TarifSQLElement.class);
dir.addSQLElement(new TaxeSQLElement());
dir.addSQLElement(TaxeComplementaireSQLElement.class);
dir.addSQLElement(TicketCaisseSQLElement.class);
 
dir.addSQLElement(new TypeComptePCGSQLElement());
979,6 → 1051,7
new CommandeBlEltSQLInjector(rootSociete);
new CommandeBlSQLInjector(rootSociete);
new BonFactureSQLInjector(rootSociete);
new BonFactureEltSQLInjector(rootSociete);
new CommandeFactureClientSQLInjector(rootSociete);
new CommandeBrSQLInjector(rootSociete);
new BonReceptionFactureFournisseurSQLInjector(rootSociete);
1013,11 → 1086,17
showAs.show(root.getTable("ASSOCIATION_ANALYTIQUE").getField("ID_ECRITURE"), lEcr);
 
showAs.show("CHEQUE_A_ENCAISSER", "MONTANT", "ID_CLIENT");
 
if (getRootSociete().getTable("CLIENT").getFieldsName().contains("LOCALISATION")) {
showAs.show("CLIENT", "NOM", "LOCALISATION");
} else {
SQLPreferences prefs = new SQLPreferences(root);
if (prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_PCE, false)) {
showAs.show("CLIENT", "ID_PAYS", "GROUPE", "NOM", "ID_COMPTE_PCE");
} else {
showAs.show("CLIENT", "ID_PAYS", "GROUPE", "NOM");
}
}
 
showAs.show(BanqueSQLElement.TABLENAME, "NOM");
 
1133,8 → 1212,19
TemplateNXProps.getInstance();
// Prefetch undefined
rootSociete.getTables().iterator().next().getUndefinedID();
SQLPreferences pref = new SQLPreferences(rootSociete);
if (pref.getBoolean(GestionCommercialeGlobalPreferencePanel.BARCODE_INSERTION, false)) {
this.barcodeReader = new BarcodeReader(80);
this.barcodeReader.start();
}
}
 
private BarcodeReader barcodeReader = null;
 
public BarcodeReader getBarcodeReader() {
return barcodeReader;
}
 
private void configureGlobalMapper() {
 
FieldMapper fieldMapper = new FieldMapper(this.getRootSociete());
1184,7 → 1274,7
}
 
public Image getCustomLogo() {
final File dir = new File(getConfFile().getParent());
final File dir = new File(getConfFile(getProductInfo()).getParent());
final File file = new File(dir, "logo.png");
 
BufferedImage im = null;
1217,4 → 1307,12
}
return im;
}
 
public synchronized Currency getCurrency() {
if (currency == null) {
String code = getRowSociete().getForeign("ID_DEVISE").getString("CODE");
currency = new Currency(code);
}
return currency;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_en.xml
738,7 → 738,12
<FIELD name="TEL_MOBILE" label="Mobile phone" />
<FIELD name="TEL_PERSONEL" label="Personal phone" />
</TABLE>
 
<TABLE name="COMPTE_CLIENT_TRANSACTION">
<FIELD name="ID_CLIENT" label="Customer" />
<FIELD name="DATE" label="Date" />
<FIELD name="MONTANT" label="Amount" />
<FIELD name="ID_REGLEMENT" label="Payment" />
</TABLE>
<TABLE name="COMPTE_PCE">
<FIELD name="NUMERO" label="Number" />
<FIELD name="NOM" label="Account" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mapping_fr.xml
16,6 → 16,31
<FIELD name="NUMERO_CANTON" label="Numéro canton" />
<FIELD name="NUMERO_COMMUNE" label="Numéro commune" />
</TABLE>
<TABLE name="AYANT_DROIT_TYPE">
<FIELD name="NOM" label="Type de l'ayant droit" />
<FIELD name="CODE" label="Code type de l'ayant droit" />
</TABLE>
 
<TABLE name="CODE_CAISSE_TYPE_RUBRIQUE">
<FIELD name="NOM" label="Libellé" />
<FIELD name="CODE" label="Code CTP URSSAF (S21.G00.23)" />
</TABLE>
 
<TABLE name="CODE_BASE_ASSUJETTIE">
<FIELD name="NOM" label="Libellé" />
<FIELD name="CODE" label="Code Base assujettie (S21.G00.78.001)" />
</TABLE>
 
<TABLE name="TYPE_COMPOSANT_BASE_ASSUJETTIE">
<FIELD name="NOM" label="Libellé" />
<FIELD name="CODE" label="Code Composant base assujettie (S21.G00.79)" />
</TABLE>
 
<TABLE name="CODE_COTISATION_INDIVIDUELLE">
<FIELD name="NOM" label="Libellé" />
<FIELD name="CODE" label="Code cotisation individuelle (S21.G00.81)" />
</TABLE>
 
<TABLE name="BANQUE_POLE_PRODUIT">
<FIELD name="NOM" label="Nom" />
<FIELD name="NUMERO_RUE" label="Numéro de rue" />
53,19 → 78,30
<FIELD name="ID_ADRESSE_COMMON" label="Adresse" />
<FIELD name="TEL" label="Téléphone" titlelabel="Tél." />
<FIELD name="MAIL" label="Courriel" />
<FIELD name="ORG_PROTECTION_SOCIALE" label="Org. protection sociale (inclus en DSN)" />
<FIELD name="TEL_PORTABLE" label="Téléphone portable" titlelabel="Tél. portable" />
<FIELD name="ID_COMPTE_PCE_TIERS" label="Compte tiers" />
<FIELD name="ID_COMPTE_PCE_CHARGE" label="Compte charges" />
<FIELD name="NUMERO_COMPTE_PCE" label="Numéro compte tiers" />
<FIELD name="NUMERO_COMPTE_PCE_CHARGES" label="Numéro de compte de charges" />
</TABLE>
<TABLE name="CAISSE_COTISATION">
<FIELD name="NOM" label="Libellé" />
<FIELD name="ID_ADRESSE_COMMON" label="Adresse" />
<FIELD name="TEL" label="Téléphone" titlelabel="Tél." />
<FIELD name="MAIL" label="Courriel" />
<FIELD name="TEL_PORTABLE" label="Téléphone portable" titlelabel="Tél. portable" />
<FIELD name="ID_COMPTE_PCE_TIERS" label="Compte tiers" />
<FIELD name="ID_COMPTE_PCE_CHARGE" label="Compte charges" />
<TABLE name="CAISSE_MODE_PAIEMENT">
<FIELD name="NOM" label="Mode de paiement" />
<FIELD name="CODE" label="Code" />
</TABLE>
<TABLE name="CAISSE_COTISATION_RENSEIGNEMENT">
<FIELD name="IDENTIFIANT" label="Identifiant Organisme de Protection Sociale" />
<FIELD name="SIRET" label="SIRET Payeur" />
<FIELD name="BIC" label="BIC du compte prélevé" />
<FIELD name="IBAN" label="IBAN du compte prélevé" />
<FIELD name="ENTITE_AFFECTATION" label="Entité d'affectation des opérations" />
<FIELD name="CODE_DELEGATAIRE" label="Code délégataire" />
<FIELD name="ORGANISME_COMPLEMENTAIRE" label="Organisme complémentaire" />
<FIELD name="ID_CAISSE_MODE_PAIEMENT" label="Mode de paiement" />
<FIELD name="PAIEMENT_TRIMESTRIEL" label="Paiement trimestriel" />
<FIELD name="ID_CAISSE_COTISATION" label="Caisse de cotisations" />
<FIELD name="ID_SOCIETE_COMMON" label="Société" />
</TABLE>
 
<TABLE name="DEVISE">
<FIELD name="CODE" label="Code" />
89,6 → 125,15
<FIELD name="PV_HT" label="Prix HT" />
<FIELD name="PV_TTC" label="Prix TTC" />
</TABLE>
<TABLE name="ECO_CONTRIBUTION">
<FIELD name="CODE" label="Code" />
<FIELD name="NOM" label="Libellé" />
<FIELD name="ID_FAMILLE_ECO_CONTRIBUTION" label="Famille d'éco-contribution" />
<FIELD name="TAUX" label="Valeur" />
</TABLE>
<TABLE name="FAMILLE_ECO_CONTRIBUTION">
<FIELD name="NOM" label="Libellé" />
</TABLE>
<TABLE name="EXERCICE_COMMON">
<FIELD name="NUMERO" label="Nom" />
<FIELD name="DATE_DEB" label="Date de début" titlelabel="Début" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/DefaultMenuConfiguration.java
41,6 → 41,7
import org.openconcerto.erp.core.finance.accounting.action.ImpressionJournauxAnalytiqueAction;
import org.openconcerto.erp.core.finance.accounting.action.ImpressionLivrePayeAction;
import org.openconcerto.erp.core.finance.accounting.action.ImpressionRepartitionAnalytiqueAction;
import org.openconcerto.erp.core.finance.accounting.action.ListeDesComptesAction;
import org.openconcerto.erp.core.finance.accounting.action.ListeDesDevisesAction;
import org.openconcerto.erp.core.finance.accounting.action.ListeDesEcrituresAction;
import org.openconcerto.erp.core.finance.accounting.action.ListeDesEcrituresAnalytiquesAction;
63,13 → 64,18
import org.openconcerto.erp.core.finance.payment.action.NouveauDecaissementChequeAvoirAction;
import org.openconcerto.erp.core.finance.payment.action.NouveauListeDesChequesADecaisserAction;
import org.openconcerto.erp.core.finance.payment.action.NouveauListeDesChequesAEncaisserAction;
import org.openconcerto.erp.core.finance.tax.action.ReportingEcoContributionPanel;
import org.openconcerto.erp.core.humanresources.ListeDesContactsAdministratif;
import org.openconcerto.erp.core.humanresources.employe.action.ListeDesAyantsDroitsAction;
import org.openconcerto.erp.core.humanresources.employe.action.ListeDesCaissesCotisationsAction;
import org.openconcerto.erp.core.humanresources.employe.action.ListeDesCommerciauxAction;
import org.openconcerto.erp.core.humanresources.employe.action.ListeDesContratsPrevoyanceAction;
import org.openconcerto.erp.core.humanresources.employe.action.ListeDesSalariesAction;
import org.openconcerto.erp.core.humanresources.employe.action.ListeDesSecretairesAction;
import org.openconcerto.erp.core.humanresources.employe.action.N4DSAction;
import org.openconcerto.erp.core.humanresources.payroll.action.ClotureMensuellePayeAction;
import org.openconcerto.erp.core.humanresources.payroll.action.EditionFichePayeAction;
import org.openconcerto.erp.core.humanresources.payroll.action.ListeDesInfosSalariePayeAction;
import org.openconcerto.erp.core.humanresources.payroll.action.ListeDesProfilsPayeAction;
import org.openconcerto.erp.core.humanresources.payroll.action.ListeDesRubriquesDePayeAction;
import org.openconcerto.erp.core.humanresources.payroll.action.ListeDesVariablesPayes;
96,10 → 102,12
import org.openconcerto.erp.core.sales.invoice.action.NouveauSaisieVenteComptoirAction;
import org.openconcerto.erp.core.sales.invoice.action.NouveauSaisieVenteFactureAction;
import org.openconcerto.erp.core.sales.order.action.ListeDesCommandesClientAction;
import org.openconcerto.erp.core.sales.order.action.ListeDesElementsACommanderClientAction;
import org.openconcerto.erp.core.sales.order.action.NouvelleCommandeClientAction;
import org.openconcerto.erp.core.sales.pos.action.ListeDesCaissesTicketAction;
import org.openconcerto.erp.core.sales.product.action.FamilleArticleAction;
import org.openconcerto.erp.core.sales.product.action.ListeDesArticlesAction;
import org.openconcerto.erp.core.sales.product.action.ListeEcoContributionAction;
import org.openconcerto.erp.core.sales.quote.action.ListeDesDevisAction;
import org.openconcerto.erp.core.sales.quote.action.ListeDesElementsDevisAction;
import org.openconcerto.erp.core.sales.quote.action.ListeDesElementsPropositionsAction;
106,10 → 114,12
import org.openconcerto.erp.core.sales.quote.action.NouveauDevisAction;
import org.openconcerto.erp.core.sales.quote.action.NouvellePropositionAction;
import org.openconcerto.erp.core.sales.shipment.action.ListeDesBonsDeLivraisonAction;
import org.openconcerto.erp.core.sales.shipment.action.ListeDesReliquatsBonsLivraisonsAction;
import org.openconcerto.erp.core.sales.shipment.action.NouveauBonLivraisonAction;
import org.openconcerto.erp.core.supplychain.credit.action.ListeDesAvoirsFournisseurAction;
import org.openconcerto.erp.core.supplychain.credit.action.NouvelAvoirFournisseurAction;
import org.openconcerto.erp.core.supplychain.order.action.ListeDesCommandesAction;
import org.openconcerto.erp.core.supplychain.order.action.ListeDesElementsACommanderAction;
import org.openconcerto.erp.core.supplychain.order.action.ListeDesFacturesFournisseurAction;
import org.openconcerto.erp.core.supplychain.order.action.ListeSaisieAchatAction;
import org.openconcerto.erp.core.supplychain.order.action.NouveauSaisieAchatAction;
134,12 → 144,12
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.LockAdminUserRight;
import org.openconcerto.sql.users.rights.UserRights;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.utils.BackupPanel;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
164,7 → 174,7
}
 
private void createMenuGroup(Group mGroup) {
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
 
mGroup.add(createFilesMenuGroup());
225,7 → 235,7
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
 
final Boolean bModeVenteComptoir = DefaultNXProps.getInstance().getBooleanValue("ArticleVenteComptoir", true);
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
final Group accountingGroup = new Group("accounting");
if (rights.haveRight(ComptaUserRight.MENU)) {
accountingGroup.addItem("accounting.entry.create");
269,12 → 279,13
 
private Group createOrganizationMenuGroup() {
final Group group = new Group(MainFrame.STRUCTURE_MENU);
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
 
if (rights.haveRight(ComptaUserRight.MENU)) {
final Group gAccounting = new Group("menu.organization.accounting", LayoutHints.DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS);
gAccounting.addItem("accounting.chart");
gAccounting.addItem("accounting.list");
gAccounting.addItem("accounting.journal");
gAccounting.addItem("accounting.checkDB");
gAccounting.addItem("accounting.currency");
290,6 → 301,7
group.add(gUser);
}
 
group.addItem("product.ecotax");
group.addItem("office.contact.list");
group.addItem("salesman.list");
 
310,6 → 322,7
group.addItem("payroll.list.report.print");
group.addItem("payroll.profile.list");
group.addItem("payroll.history");
group.addItem("payroll.infos.history");
group.addItem("payroll.create");
group.addItem("payroll.deposit.create");
group.addItem("employee.list");
316,6 → 329,9
final Group groupConfig = new Group("menu.payroll.config", LayoutHints.DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS);
groupConfig.addItem("payroll.section");
groupConfig.addItem("payroll.variable");
groupConfig.addItem("payroll.caisse");
groupConfig.addItem("employee.contrat.prev.list");
// groupConfig.addItem("employee.contrat.prev.ayantdroit.list");
group.add(groupConfig);
group.addItem("payroll.closing");
return group;
323,7 → 339,7
 
public Group createPaymentMenuGroup() {
final Group group = new Group(MainFrame.PAYMENT_MENU);
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
 
if (rights.haveRight(ComptaUserRight.MENU) || rights.haveRight(ComptaUserRight.POINTAGE_LETTRAGE)) {
group.addItem("payment.checking.create");
369,6 → 385,7
group.addItem("sales.product.margin.graph");
group.addItem("sales.product.family.graph");
group.addItem("sales.list.graph");
group.addItem("sales.report.ecocontribution");
return group;
}
 
414,7 → 431,7
 
final Boolean bModeVenteComptoir = DefaultNXProps.getInstance().getBooleanValue("ArticleVenteComptoir", true);
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
 
Group gCustomer = new Group("menu.list.customer", LayoutHints.DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS);
gCustomer.addItem("customer.list");
436,6 → 453,9
 
gCustomer.addItem("customer.order.list");
gCustomer.addItem("customer.delivery.list");
if (configuration.getRootSociete().contains("RELIQUAT_BR")) {
gCustomer.addItem("customer.delivery.reliquat.list");
}
group.add(gCustomer);
 
boolean useListDesVentesAction = bModeVenteComptoir;
469,6 → 489,8
gProduct.addItem("product.list");
// gProduct.addItem("product.supplychain.list");
gProduct.addItem("stock.io.list");
gProduct.addItem("customer.order.waiting");
gProduct.addItem("supplier.order.waiting");
group.add(gProduct);
 
return group;
488,53 → 510,52
* Actions
*/
private void registerFilesMenuActions(final MenuAndActions mManager) {
mManager.registerAction("backup", new SauvegardeBaseAction());
mManager.registerAction("modules", new AbstractAction() {
mManager.putAction(new SauvegardeBaseAction(), "backup");
mManager.putAction(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
FrameUtil.show(ModuleFrame.getInstance());
}
});
}, "modules");
if (!Gestion.MAC_OS_X) {
mManager.registerAction("preferences", new PreferencesAction());
mManager.registerAction("quit", new AbstractAction() {
mManager.putAction(new PreferencesAction(), "preferences");
mManager.putAction(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
MainFrame.getInstance().quit();
}
});
}, "quit");
}
}
 
private void registerCreationMenuActions(final MenuAndActions mManager) {
final Boolean bModeVenteComptoir = DefaultNXProps.getInstance().getBooleanValue("ArticleVenteComptoir", true);
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
 
if (rights.haveRight(ComptaUserRight.MENU)) {
mManager.registerAction("accounting.entry.create", new NouvelleSaisieKmAction());
mManager.putAction(new NouvelleSaisieKmAction(), "accounting.entry.create");
}
 
 
mManager.registerAction("customer.quote.create", new NouveauDevisAction());
mManager.putAction(new NouveauDevisAction(), "customer.quote.create");
 
mManager.registerAction("customer.delivery.create", new NouveauBonLivraisonAction());
mManager.registerAction("customer.order.create", new NouvelleCommandeClientAction());
mManager.putAction(new NouveauBonLivraisonAction(), "customer.delivery.create");
mManager.putAction(new NouvelleCommandeClientAction(), "customer.order.create");
if (bModeVenteComptoir && rights.haveRight("VENTE_COMPTOIR")) {
mManager.registerAction("pos.sale.create", new NouveauSaisieVenteComptoirAction());
mManager.putAction(new NouveauSaisieVenteComptoirAction(), "pos.sale.create");
}
mManager.registerAction("customer.invoice.create", new NouveauSaisieVenteFactureAction());
mManager.putAction(new NouveauSaisieVenteFactureAction(), "customer.invoice.create");
 
mManager.registerAction("customer.credit.create", new NouveauAvoirClientAction());
mManager.putAction(new NouveauAvoirClientAction(), "customer.credit.create");
 
if (rights.haveRight(NXRights.LOCK_MENU_ACHAT.getCode())) {
 
mManager.registerAction("supplier.order.create", new NouvelleCommandeAction());
mManager.registerAction("supplier.receipt.create", new NouveauBonReceptionAction());
mManager.registerAction("supplier.purchase.create", new NouveauSaisieAchatAction());
mManager.registerAction("supplier.invoice.purchase.create", new NouvelleFactureFournisseurAction());
mManager.registerAction("supplier.credit.create", new NouvelAvoirFournisseurAction());
mManager.registerAction("stock.io.create", new NouvelleSaisieMouvementStockAction());
mManager.putAction(new NouvelleCommandeAction(), "supplier.order.create");
mManager.putAction(new NouveauBonReceptionAction(), "supplier.receipt.create");
mManager.putAction(new NouveauSaisieAchatAction(), "supplier.purchase.create");
mManager.putAction(new NouvelleFactureFournisseurAction(), "supplier.invoice.purchase.create");
mManager.putAction(new NouvelAvoirFournisseurAction(), "supplier.credit.create");
mManager.putAction(new NouvelleSaisieMouvementStockAction(), "stock.io.create");
}
 
}
542,43 → 563,46
private void registerListMenuActions(final MenuAndActions mManager) {
final Boolean bModeVenteComptoir = DefaultNXProps.getInstance().getBooleanValue("ArticleVenteComptoir", true);
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
 
mManager.registerAction("customer.list", new ListeDesClientsAction());
mManager.putAction(new ListeDesClientsAction(), "customer.list");
SQLPreferences prefs = SQLPreferences.getMemCached(configuration.getRootSociete());
if (prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false)) {
mManager.registerAction("customer.department.list", new ListeDesDepartementsClientsAction());
mManager.putAction(new ListeDesDepartementsClientsAction(), "customer.department.list");
}
mManager.registerAction("contact.list", new ListeDesContactsAction());
mManager.putAction(new ListeDesContactsAction(), "contact.list");
 
if (rights.haveRight(NXRights.ACCES_HISTORIQUE.getCode())) {
mManager.registerAction("customer.history", new NouvelHistoriqueListeClientAction());
mManager.putAction(new NouvelHistoriqueListeClientAction(), "customer.history");
}
 
 
mManager.registerAction("customer.quote.list", new ListeDesDevisAction());
mManager.putAction(new ListeDesDevisAction(), "customer.quote.list");
 
 
mManager.registerAction("customer.order.list", new ListeDesCommandesClientAction());
mManager.registerAction("customer.delivery.list", new ListeDesBonsDeLivraisonAction());
mManager.putAction(new ListeDesCommandesClientAction(), "customer.order.list");
mManager.putAction(new ListeDesBonsDeLivraisonAction(), "customer.delivery.list");
if (configuration.getRootSociete().contains("RELIQUAT_BL")) {
mManager.registerAction("customer.delivery.reliquat.list", new ListeDesReliquatsBonsLivraisonsAction());
}
 
boolean useListDesVentesAction = bModeVenteComptoir;
if (useListDesVentesAction) {
mManager.registerAction("sales.list", new ListeDesVentesAction());
mManager.putAction(new ListeDesVentesAction(), "sales.list");
 
} else {
 
mManager.registerAction("customer.invoice.list", new ListeSaisieVenteFactureAction());
mManager.putAction(new ListeSaisieVenteFactureAction(), "customer.invoice.list");
}
 
mManager.registerAction("customer.credit.list", new ListeDesAvoirsClientsAction());
mManager.putAction(new ListeDesAvoirsClientsAction(), "customer.credit.list");
 
mManager.registerAction("supplier.list", new ListeDesFournisseursAction());
mManager.registerAction("supplier.contact.list", new ListeDesContactsFournisseursAction());
mManager.registerAction("supplier.history", new NouvelHistoriqueListeFournAction());
mManager.putAction(new ListeDesFournisseursAction(), "supplier.list");
mManager.putAction(new ListeDesContactsFournisseursAction(), "supplier.contact.list");
mManager.putAction(new NouvelHistoriqueListeFournAction(), "supplier.history");
if (rights.haveRight(NXRights.LOCK_MENU_ACHAT.getCode())) {
mManager.registerAction("supplier.order.list", new ListeDesCommandesAction());
mManager.registerAction("supplier.receipt.reliquat.list", new ListeDesReliquatsBonsReceptionsAction());
mManager.putAction(new ListeDesCommandesAction(), "supplier.order.list");
mManager.putAction(new ListeDesReliquatsBonsReceptionsAction(), "supplier.receipt.reliquat.list");
mManager.registerAction("supplier.receipt.list", new ListeDesBonsReceptionsAction());
mManager.registerAction("supplier.purchase.list", new ListeSaisieAchatAction());
mManager.registerAction("supplier.invoice.purchase.list", new ListeDesFacturesFournisseurAction());
588,8 → 612,11
mManager.registerAction("product.list", new ListeDesArticlesAction());
mManager.registerAction("product.supplychain.list", new ListeDesArticlesFournisseurAction());
mManager.registerAction("stock.io.list", new ListeDesMouvementsStockAction());
mManager.registerAction("customer.order.waiting", new ListeDesElementsACommanderClientAction());
mManager.registerAction("supplier.order.waiting", new ListeDesElementsACommanderAction());
 
 
 
}
 
public void registerAccountingMenuActions(final MenuAndActions mManager) {
634,53 → 661,70
mManager.registerAction("sales.product.family.graph", new VenteArticleFamilleGraphAction());
mManager.registerAction("sales.list.graph", new EtatVenteAction());
 
mManager.registerAction("sales.report.ecocontribution", new AbstractAction("Reporting Eco Contribution") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
PanelFrame frame = new PanelFrame(new ReportingEcoContributionPanel(), "Reporting Eco Contribution");
frame.setVisible(true);
}
});
 
}
 
public void registerPaymentMenuActions(final MenuAndActions mManager) {
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
 
if (rights.haveRight(ComptaUserRight.MENU) || rights.haveRight(ComptaUserRight.POINTAGE_LETTRAGE)) {
mManager.registerAction("payment.checking.create", new NouveauPointageAction());
mManager.registerAction("payment.reconciliation.create", new NouveauLettrageAction());
mManager.putAction(new NouveauPointageAction(), "payment.checking.create");
mManager.putAction(new NouveauLettrageAction(), "payment.reconciliation.create");
}
 
if (rights.haveRight(NXRights.GESTION_ENCAISSEMENT.getCode())) {
mManager.registerAction("customer.invoice.unpaid.list", new ListesFacturesClientsImpayeesAction());
mManager.registerAction("customer.dept.list", new ListeDebiteursAction());
mManager.registerAction("customer.payment.list", new ListeDesEncaissementsAction());
mManager.registerAction("customer.payment.followup.list", new ListeDesRelancesAction());
mManager.registerAction("customer.payment.check.pending.list", new ListeDesChequesAEncaisserAction());
mManager.registerAction("customer.payment.check.pending.create", new NouveauListeDesChequesAEncaisserAction());
mManager.registerAction("customer.credit.check.list", new ListeDesChequesAvoirAction());
mManager.registerAction("customer.credit.check.create", new NouveauDecaissementChequeAvoirAction());
mManager.putAction(new ListesFacturesClientsImpayeesAction(), "customer.invoice.unpaid.list");
mManager.putAction(new ListeDebiteursAction(), "customer.dept.list");
mManager.putAction(new ListeDesEncaissementsAction(), "customer.payment.list");
mManager.putAction(new ListeDesRelancesAction(), "customer.payment.followup.list");
mManager.putAction(new ListeDesChequesAEncaisserAction(), "customer.payment.check.pending.list");
mManager.putAction(new NouveauListeDesChequesAEncaisserAction(), "customer.payment.check.pending.create");
mManager.putAction(new ListeDesChequesAvoirAction(), "customer.credit.check.list");
mManager.putAction(new NouveauDecaissementChequeAvoirAction(), "customer.credit.check.create");
}
if (rights.haveRight(NXRights.LOCK_MENU_ACHAT.getCode())) {
mManager.registerAction("supplier.invoice.unpaid.list", new ListesFacturesFournImpayeesAction());
mManager.registerAction("supplier.bill.list", new ListeDesTraitesFournisseursAction());
mManager.registerAction("supplier.payment.check.list", new ListeDesChequesFournisseursAction());
mManager.registerAction("supplier.payment.check.pending.list", new NouveauListeDesChequesADecaisserAction());
mManager.putAction(new ListesFacturesFournImpayeesAction(), "supplier.invoice.unpaid.list");
mManager.putAction(new ListeDesTraitesFournisseursAction(), "supplier.bill.list");
mManager.putAction(new ListeDesChequesFournisseursAction(), "supplier.payment.check.list");
mManager.putAction(new NouveauListeDesChequesADecaisserAction(), "supplier.payment.check.pending.list");
}
 
}
 
private void registerPayrollMenuActions(final MenuAndActions mManager) {
mManager.registerAction("payroll.list.report.print", new ImpressionLivrePayeAction());
mManager.registerAction("payroll.profile.list", new ListeDesProfilsPayeAction());
mManager.registerAction("payroll.history", new NouvelHistoriqueFichePayeAction());
mManager.registerAction("payroll.create", new EditionFichePayeAction());
mManager.registerAction("payroll.deposit.create", new NouvelAcompteAction());
mManager.registerAction("employee.list", new ListeDesSalariesAction());
mManager.registerAction("payroll.section", new ListeDesRubriquesDePayeAction());
mManager.registerAction("payroll.variable", new ListeDesVariablesPayes());
mManager.registerAction("payroll.closing", new ClotureMensuellePayeAction());
mManager.putAction(new ImpressionLivrePayeAction(), "payroll.list.report.print");
mManager.putAction(new ListeDesProfilsPayeAction(), "payroll.profile.list");
mManager.putAction(new NouvelHistoriqueFichePayeAction(), "payroll.history");
mManager.putAction(new EditionFichePayeAction(), "payroll.create");
mManager.putAction(new NouvelAcompteAction(), "payroll.deposit.create");
mManager.putAction(new ListeDesSalariesAction(), "employee.list");
mManager.putAction(new ListeDesContratsPrevoyanceAction(), "employee.contrat.prev.list");
mManager.putAction(new ListeDesCaissesCotisationsAction(), "payroll.caisse");
mManager.putAction(new ListeDesAyantsDroitsAction(), "employee.contrat.prev.ayantdroit.list");
 
mManager.putAction(new ListeDesRubriquesDePayeAction(), "payroll.section");
mManager.putAction(new ListeDesVariablesPayes(), "payroll.variable");
mManager.putAction(new ListeDesInfosSalariePayeAction(), "payroll.infos.history");
mManager.putAction(new ClotureMensuellePayeAction(), "payroll.closing");
 
}
 
public void registerOrganizationMenuActions(final MenuAndActions mManager) {
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final UserRights rights = UserRightsManager.getCurrentUserRights();
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
if (rights.haveRight(ComptaUserRight.MENU)) {
mManager.putAction(new GestionPlanComptableEAction(), "accounting.chart");
mManager.putAction(new ListeDesComptesAction(), "accounting.list");
 
mManager.putAction(new ListeDesJournauxAction(), "accounting.journal");
mManager.putAction(new ListeDesDevisesAction(), "accounting.currency");
mManager.putAction(new ListeDesTauxDeChangeAction(), "accounting.currency.rates");
690,32 → 734,33
final DBRoot rootSociete = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
final SQLSelect sel = CorrectMouvement.createUnbalancedSelect(rootSociete);
final List<?> ids = rootSociete.getDBSystemRoot().getDataSource().executeCol(sel.asString());
JOptionPane.showMessageDialog((Component) e.getSource(), "Il y a " + ids.size() + " mouvement(s) non équilibré(s).", "Résultat", ids.size() == 0 ? JOptionPane.INFORMATION_MESSAGE
: JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog((Component) e.getSource(), "Il y a " + ids.size() + " mouvement(s) non équilibré(s).", "Résultat",
ids.size() == 0 ? JOptionPane.INFORMATION_MESSAGE : JOptionPane.WARNING_MESSAGE);
}
}, "accounting.checkDB");
}
mManager.putAction(new ListeEcoContributionAction(), "product.ecotax");
 
if (rights.haveRight(LockAdminUserRight.LOCK_MENU_ADMIN)) {
mManager.registerAction("user.list", new ListeDesUsersCommonAction());
mManager.registerAction("user.right.list", new GestionDroitsAction());
mManager.registerAction("user.task.right", new TaskAdminAction());
mManager.putAction(new ListeDesUsersCommonAction(), "user.list");
mManager.putAction(new GestionDroitsAction(), "user.right.list");
mManager.putAction(new TaskAdminAction(), "user.task.right");
}
 
mManager.registerAction("office.contact.list", new ListeDesContactsAdministratif());
mManager.registerAction("salesman.list", new ListeDesCommerciauxAction());
mManager.registerAction("pos.list", new ListeDesCaissesTicketAction());
mManager.putAction(new ListeDesContactsAdministratif(), "office.contact.list");
mManager.putAction(new ListeDesCommerciauxAction(), "salesman.list");
mManager.putAction(new ListeDesCaissesTicketAction(), "pos.list");
 
 
mManager.registerAction("enterprise.list", new ListeDesSocietesCommonsAction());
mManager.putAction(new ListeDesSocietesCommonsAction(), "enterprise.list");
 
mManager.registerAction("divison.bank.list", new ListeBanqueAction());
mManager.registerAction("enterprise.create", new NouvelleSocieteAction());
mManager.putAction(new ListeBanqueAction(), "divison.bank.list");
mManager.putAction(new NouvelleSocieteAction(), "enterprise.create");
}
 
private void registerHelpMenuActions(final MenuAndActions mManager) {
mManager.registerAction("information", AboutAction.getInstance());
mManager.registerAction("tips", new AstuceAction());
mManager.putAction(AboutAction.getInstance(), "information");
mManager.putAction(new AstuceAction(), "tips");
}
 
private void registerHelpTestActions(final MenuAndActions mManager) {
/trunk/OpenConcerto/src/org/openconcerto/erp/config/update/Updater_1_5.java
New file
0,0 → 1,313
/*
* 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.config.update;
 
import org.openconcerto.erp.config.InstallationPanel;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLField.Properties;
import org.openconcerto.sql.model.SQLName;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.SQLCreateTable;
 
import java.math.BigDecimal;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
 
public class Updater_1_5 {
private static final String COMPTE_CLIENT_TRANSACTION = "COMPTE_CLIENT_TRANSACTION";
 
public static void update(final DBRoot root) throws SQLException {
// Champ obsolete sur compte
SQLTable tableCompte = root.getTable("COMPTE_PCE");
if (!tableCompte.contains("OBSOLETE")) {
final AlterTable alter = new AlterTable(tableCompte);
alter.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
tableCompte.getBase().getDataSource().execute(alter.asString());
tableCompte.getSchema().updateVersion();
tableCompte.fetchFields();
}
 
// Transaction du solde
if (!root.contains(COMPTE_CLIENT_TRANSACTION)) {
final SQLCreateTable createTable = new SQLCreateTable(root, COMPTE_CLIENT_TRANSACTION);
createTable.addForeignColumn("CLIENT");
createTable.addDateAndTimeColumn("DATE");
createTable.addDecimalColumn("MONTANT", 16, 6, BigDecimal.valueOf(0), false);
createTable.addForeignColumn("MODE_REGLEMENT");
createTable.addForeignColumn("MOUVEMENT");
try {
root.getBase().getDataSource().execute(createTable.asString());
InstallationPanel.insertUndef(createTable);
root.refetchTable(COMPTE_CLIENT_TRANSACTION);
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + COMPTE_CLIENT_TRANSACTION, ex);
}
}
// Solde
final SQLTable tClient = root.getTable("CLIENT");
if (!tClient.contains("SOLDE_COMPTE")) {
final AlterTable alterClient = new AlterTable(tClient);
alterClient.addDecimalColumn("SOLDE_COMPTE", 16, 6, BigDecimal.valueOf(0), false);
tClient.getBase().getDataSource().execute(alterClient.asString());
tClient.getSchema().updateVersion();
tClient.fetchFields();
}
 
final SQLTable tCompteClient = root.getTable("COMPTE_CLIENT_TRANSACTION");
if (!tCompteClient.contains("ID_MOUVEMENT")) {
final AlterTable alterClient = new AlterTable(tCompteClient);
alterClient.addForeignColumn("ID_MOUVEMENT", root.getTable("MOUVEMENT"));
tClient.getBase().getDataSource().execute(alterClient.asString());
tClient.getSchema().updateVersion();
tClient.fetchFields();
}
 
final SQLTable tCmdClient = root.getTable("COMMANDE_CLIENT");
if (!tCmdClient.contains("DATE_LIVRAISON_PREV")) {
final AlterTable alterCmdClient = new AlterTable(tCmdClient);
alterCmdClient.addColumn("DATE_LIVRAISON_PREV", "date");
tCmdClient.getBase().getDataSource().execute(alterCmdClient.asString());
tCmdClient.getSchema().updateVersion();
tCmdClient.fetchFields();
}
 
{
// Ajout du champ SANS_VALEUR_ENCAISSEMENT pour gérer les anciens cheques sans le compte
// 511
List<String> tablesCheque = Arrays.asList("CHEQUE_A_ENCAISSER", "CHEQUE_FOURNISSEUR");
 
for (String string : tablesCheque) {
 
final SQLTable table = root.getTable(string);
if (!table.contains("SANS_VALEUR_ENCAISSEMENT")) {
AlterTable alterElt = new AlterTable(table);
alterElt.addBooleanColumn("SANS_VALEUR_ENCAISSEMENT", Boolean.FALSE, false);
table.getBase().getDataSource().execute(alterElt.asString());
root.refetchTable(string);
root.getSchema().updateVersion();
UpdateBuilder upBuilder = new UpdateBuilder(table);
upBuilder.setObject("SANS_VALEUR_ENCAISSEMENT", Boolean.TRUE);
table.getBase().getDataSource().execute(upBuilder.asString());
}
}
 
SQLTable tableEncElt = root.getTable("ENCAISSER_MONTANT_ELEMENT");
if (tableEncElt.getField("DATE").getType().getType() == Types.TIMESTAMP) {
AlterTable t = new AlterTable(tableEncElt);
t.alterColumn("DATE", EnumSet.allOf(Properties.class), "date", null, Boolean.TRUE);
tableEncElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableEncElt.getName());
root.getSchema().updateVersion();
}
}
 
// TVA Intra
final SQLTable tTva = root.getTable("TAXE");
if (!tTva.contains("ID_COMPTE_PCE_COLLECTE_INTRA")) {
final AlterTable alterTaxe = new AlterTable(tTva);
alterTaxe.addForeignColumn("ID_COMPTE_PCE_COLLECTE_INTRA", root.getTable("COMPTE_PCE"));
alterTaxe.addForeignColumn("ID_COMPTE_PCE_DED_INTRA", root.getTable("COMPTE_PCE"));
tTva.getBase().getDataSource().execute(alterTaxe.asString());
tTva.getSchema().updateVersion();
tTva.fetchFields();
}
 
if (!root.contains("TAXE_COMPLEMENTAIRE")) {
final SQLCreateTable createTable = new SQLCreateTable(root, "TAXE_COMPLEMENTAIRE");
createTable.addForeignColumn("ID_COMPTE_PCE_PRODUITS", root.getTable("COMPTE_PCE"));
createTable.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
createTable.addDecimalColumn("POURCENT", 16, 6, BigDecimal.valueOf(0), false);
createTable.addVarCharColumn("CODE", 25);
createTable.addVarCharColumn("NOM", 256);
 
try {
root.getBase().getDataSource().execute(createTable.asString());
InstallationPanel.insertUndef(createTable);
root.refetchTable("TAXE_COMPLEMENTAIRE");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "TAXE_COMPLEMENTAIRE", ex);
}
 
SQLTable tableArt = root.getTable("ARTICLE");
final AlterTable alterArt = new AlterTable(tableArt);
alterArt.addForeignColumn("ID_TAXE_COMPLEMENTAIRE", root.getTable("TAXE_COMPLEMENTAIRE"));
tableArt.getBase().getDataSource().execute(alterArt.asString());
tableArt.getSchema().updateVersion();
tableArt.fetchFields();
}
 
// GED
if (!root.contains("ATTACHMENT")) {
final SQLCreateTable createTable = new SQLCreateTable(root, "ATTACHMENT");
createTable.addVarCharColumn("SOURCE_TABLE", 128);
createTable.addIntegerColumn("SOURCE_ID", 0);
createTable.addVarCharColumn("NAME", 256);
createTable.addVarCharColumn("MIMETYPE", 256);
createTable.addVarCharColumn("FILENAME", 256);
createTable.addLongColumn("FILESIZE", 0L, false);
createTable.addVarCharColumn("STORAGE_PATH", 256);
createTable.addVarCharColumn("STORAGE_FILENAME", 256);
createTable.addVarCharColumn("DIRECTORY", 256);
createTable.addVarCharColumn("THUMBNAIL", 256);
createTable.addIntegerColumn("THUMBNAIL_WIDTH", 32);
createTable.addIntegerColumn("THUMBNAIL_HEIGHT", 32);
createTable.addVarCharColumn("TAG", 128);
createTable.addIntegerColumn("VERSION", 0);
createTable.addVarCharColumn("HASH", 32);
 
try {
root.getBase().getDataSource().execute(createTable.asString());
InstallationPanel.insertUndef(createTable);
root.refetchTable("ATTACHMENT");
root.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "ATTACHMENT", ex);
}
}
SQLTable tableAttachment = root.getTable("ATTACHMENT");
if (!tableAttachment.contains("DIRECTORY")) {
final AlterTable alter = new AlterTable(tableAttachment);
alter.addVarCharColumn("STORAGE_FILENAME", 256);
alter.addVarCharColumn("DIRECTORY", 256);
tableAttachment.getBase().getDataSource().execute(alter.asString());
tableAttachment.getSchema().updateVersion();
tableAttachment.fetchFields();
}
 
if (!tableAttachment.contains("VERSION")) {
final AlterTable alter = new AlterTable(tableAttachment);
alter.addIntegerColumn("VERSION", 0);
alter.addVarCharColumn("HASH", 32);
alter.addVarCharColumn("INFOS", 8000);
tableAttachment.getBase().getDataSource().execute(alter.asString());
tableAttachment.getSchema().updateVersion();
tableAttachment.fetchFields();
}
 
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE");
for (String string : gedTable) {
SQLTable tableGED = root.getTable(string);
if (!tableGED.contains("ATTACHMENTS")) {
final AlterTable alter = new AlterTable(tableGED);
alter.addIntegerColumn("ATTACHMENTS", 0);
tableGED.getBase().getDataSource().execute(alter.asString());
tableGED.getSchema().updateVersion();
tableGED.fetchFields();
}
}
 
// gestion articles en attente
{
 
// Vente
SQLTable tableBLElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
if (!tableBLElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
AlterTable t = new AlterTable(tableBLElt);
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
tableBLElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableBLElt.getName());
root.getSchema().updateVersion();
}
 
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
if (!tableVFElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
AlterTable t = new AlterTable(tableVFElt);
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
tableVFElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableVFElt.getName());
root.getSchema().updateVersion();
}
 
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
if (!tableCmdElt.contains("LIVRE")) {
AlterTable t = new AlterTable(tableCmdElt);
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
t.addBooleanColumn("LIVRE", Boolean.TRUE, false);
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
tableCmdElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableCmdElt.getName());
root.getSchema().updateVersion();
 
SQLTable tableCmdCli = root.getTable("COMMANDE_CLIENT");
SQLTable tableTR = root.getTable("TR_COMMANDE_CLIENT");
SQLTable tableBL = root.getTable("BON_DE_LIVRAISON");
SQLTable tableFactC = root.getTable("SAISIE_VENTE_FACTURE");
String sel = "SELECT t.\"ID_COMMANDE_CLIENT\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote()
+ " c ," + new SQLName(root.getName(), tableBL.getName()).quote() + " b ," + new SQLName(root.getName(), tableFactC.getName()).quote()
+ " f WHERE c.\"ID\"=t.\"ID_COMMANDE_CLIENT\" AND f.\"ID\"=t.\"ID_SAISIE_VENTE_FACTURE\""
+ " AND b.\"ID\"=t.\"ID_BON_DE_LIVRAISON\" AND b.\"ARCHIVE\" = 0 AND f.\"ID\" > 1 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND f.\"ARCHIVE\" = 0 AND t.\"ARCHIVE\" = 0 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE_CLIENT\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\") OR SUM(f.\"T_HT\")>=SUM(c.\"T_HT\")) ";
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
UpdateBuilder build = new UpdateBuilder(tableCmdElt);
build.set("QTE_LIVREE", "\"QTE\"*\"QTE_UNITAIRE\"");
build.setObject("LIVRE_FORCED", Boolean.TRUE);
final Where where = new Where(tableCmdElt.getField("ID_COMMANDE_CLIENT"), cmd);
build.setWhere(where);
// String up = "UPDATE " + new SQLName(root.getName(),
// tableCmdElt.getName()).quote()
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
// \"ID_COMMANDE_CLIENT\" IN []";
}
 
// Achat
 
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
if (!tableBRElt.contains("ID_COMMANDE_ELEMENT")) {
AlterTable t = new AlterTable(tableBRElt);
t.addForeignColumn("ID_COMMANDE_ELEMENT", root.getTable("COMMANDE_ELEMENT"));
tableBRElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableBRElt.getName());
root.getSchema().updateVersion();
}
 
SQLTable tableCmdFElt = root.getTable("COMMANDE_ELEMENT");
if (!tableCmdFElt.contains("RECU")) {
AlterTable t = new AlterTable(tableCmdFElt);
t.addBooleanColumn("RECU_FORCED", Boolean.FALSE, false);
t.addBooleanColumn("RECU", Boolean.TRUE, false);
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
tableCmdFElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableCmdFElt.getName());
root.getSchema().updateVersion();
 
SQLTable tableCmdCli = root.getTable("COMMANDE");
SQLTable tableTR = root.getTable("TR_COMMANDE");
SQLTable tableBR = root.getTable("BON_RECEPTION");
String sel = "SELECT t.\"ID_COMMANDE\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote() + " c ,"
+ new SQLName(root.getName(), tableBR.getName()).quote() + " b WHERE c.\"ID\"=t.\"ID_COMMANDE\""
+ " AND b.\"ID\"=t.\"ID_BON_RECEPTION\" AND b.\"ARCHIVE\" = 0 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND t.\"ARCHIVE\" = 0 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\")) ";
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
build.setObject("RECU_FORCED", Boolean.TRUE);
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
build.setWhere(where);
// String up = "UPDATE " + new SQLName(root.getName(),
// tableCmdElt.getName()).quote()
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
// \"ID_COMMANDE_CLIENT\" IN []";
}
 
}
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/config/ServerConfigListModel.java
13,8 → 13,6
package org.openconcerto.erp.config;
 
import org.openconcerto.sql.Configuration;
 
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
57,8 → 55,7
return;
}
ServerFinder f = new ServerFinder();
File fH2 = new File(Configuration.getDefaultConfDir(), "OpenConcerto-GESTION_DEFAULT/DBData");
if (ServerFinderPanel.containsValidH2DB(fH2)) {
for (final File fH2 : ServerFinderPanel.searchValidH2DB()) {
final ServerFinderConfig c = new ServerFinderConfig();
c.setType(ServerFinderConfig.H2);
c.setFile(fH2);
65,14 → 62,6
c.setProduct("H2 OpenConcerto found");
confs.add(c);
}
fH2 = new File(Configuration.getDefaultConfDir(), "OpenConcerto/DBData");
if (ServerFinderPanel.containsValidH2DB(fH2)) {
final ServerFinderConfig c = new ServerFinderConfig();
c.setType(ServerFinderConfig.H2);
c.setFile(fH2);
c.setProduct("H2 OpenConcerto found");
confs.add(c);
}
List<String> l = f.getIPsToScan();
int stop = l.size();
for (int i = 0; i < stop; i++) {
/trunk/OpenConcerto/src/org/openconcerto/erp/config/ServerFinderPanel.java
14,17 → 14,19
package org.openconcerto.erp.config;
 
import org.openconcerto.erp.core.sales.pos.ui.ConfigCaissePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLSchema;
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.VFlowLayout;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DesktopEnvironment;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.ProductInfo;
import org.openconcerto.utils.PropertiesUtils;
 
import java.awt.Component;
42,7 → 44,12
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
82,6 → 89,7
private JTabbedPane tabbedPane;
 
public static void main(String[] args) {
System.setProperty(SQLRowAccessor.ACCESS_DB_IF_NEEDED_PROP, "true");
System.setProperty(org.openconcerto.sql.PropsConfiguration.REDIRECT_TO_FILE, "true");
System.setProperty(SQLBase.ALLOW_OBJECT_REMOVAL, "true");
// this class is used to edit a configuration, not to modify the DB
100,7 → 108,7
} catch (Exception e) {
System.out.println("Logs désactivés : " + e.getMessage());
}
final File confFile = ComptaPropsConfiguration.getConfFile();
final File confFile = ComptaPropsConfiguration.getConfFile(ProductInfo.getInstance());
System.out.println("Reading configuration from: " + confFile.getAbsolutePath());
 
SwingUtilities.invokeLater(new Runnable() {
125,7 → 133,6
panel.tabbedPane.addTab("Cloud", new CloudPanel(panel));
f.setContentPane(panel);
f.pack();
f.setMinimumSize(new Dimension(f.getWidth(), f.getHeight()));
f.setLocationRelativeTo(null);
f.setVisible(true);
}
132,18 → 139,49
});
}
 
protected void fillWithDefaultH2Config() {
this.props.setProperty("server.driver", "h2");
this.props.setProperty("customer", "Gestion_Default");
this.props.setProperty("systemRoot", "OpenConcerto");
this.props.setProperty("base.root", "Common");
this.props.setProperty("server.ip", "file:${data.dir}/");
protected final void fillWithDefaultH2Config() {
fillWithDefaultH2Config(this.props);
}
 
static protected Properties fillWithDefaultH2Config(final Properties props) {
props.setProperty("server.driver", "h2");
props.setProperty("customer", "Gestion_Default");
props.setProperty("systemRoot", "OpenConcerto");
props.setProperty("base.root", "Common");
props.setProperty("server.ip", "file:${data.dir}/");
return props;
}
 
public static final String getDefaultSystemRootName() {
return ComptaPropsConfiguration.APP_NAME;
}
 
private static final List<File> getDBDataDirs(final Properties props) {
final ComptaPropsConfiguration conf = new ComptaPropsConfiguration(props, false, false);
return Arrays.asList(conf.getDataDir(), conf.getOldDataDir());
}
 
public static final Set<File> getH2DBCandidates() {
final Properties props = fillWithDefaultH2Config(new Properties());
assert props.containsKey("customer");
final List<File> dirs1 = getDBDataDirs(props);
props.remove("customer");
final List<File> dirs2 = getDBDataDirs(props);
final LinkedHashSet<File> res = new LinkedHashSet<File>();
res.addAll(dirs1);
res.addAll(dirs2);
return res;
}
 
public static final List<File> searchValidH2DB() {
final List<File> res = new ArrayList<File>();
for (final File dir : getH2DBCandidates()) {
if (containsValidH2DB(dir))
res.add(dir);
}
return res;
}
 
public static final boolean containsValidH2DB(File dir) {
return testH2DBDir(dir) == null;
}
181,17 → 219,7
 
if (!this.confFile.exists()) {
System.out.println("Unable to find: " + this.confFile.getAbsolutePath());
 
final File dir1 = new File(Configuration.getDefaultConfDir(), ComptaPropsConfiguration.APP_NAME + "-GESTION_DEFAULT/DBData");
final File dir2 = new File(Configuration.getDefaultConfDir(), ComptaPropsConfiguration.APP_NAME + "/DBData");
final File validDir;
if (containsValidH2DB(dir1)) {
validDir = dir1;
} else if (containsValidH2DB(dir2)) {
validDir = dir2;
} else {
validDir = null;
}
final File validDir = CollectionUtils.getFirst(searchValidH2DB());
if (validDir != null) {
System.out.println("Found DB in " + validDir);
updateUIForMode(SQLSystem.H2);
/trunk/OpenConcerto/src/org/openconcerto/erp/config/InstallationPanel.java
13,6 → 13,7
package org.openconcerto.erp.config;
 
import org.openconcerto.erp.config.update.Updater_1_5;
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
import org.openconcerto.erp.modules.ModuleManager;
21,6 → 22,7
import org.openconcerto.sql.changer.convert.ChangeIDToInt;
import org.openconcerto.sql.changer.correct.CorrectOrder;
import org.openconcerto.sql.changer.correct.FixSerial;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.DBSystemRoot;
47,6 → 49,8
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ChangeTable;
import org.openconcerto.sql.utils.ChangeTable.ClauseType;
import org.openconcerto.sql.utils.ChangeTable.DeferredClause;
import org.openconcerto.sql.utils.ReOrder;
import org.openconcerto.sql.utils.SQLCreateMoveableTable;
import org.openconcerto.sql.utils.SQLCreateTable;
90,7 → 94,7
public class InstallationPanel extends JPanel {
private static final boolean DEBUG_FK = false;
 
static private void insertUndef(final SQLCreateTable ct) throws SQLException {
static public void insertUndef(final SQLCreateTable ct) throws SQLException {
// check that we can use insertReturnFirstField()
if (ct.getPrimaryKey().size() != 1)
throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
302,6 → 306,10
final DSNInstallationUtils dsnUtils = new DSNInstallationUtils();
dsnUtils.updateDSNCommonTable(conf.getRoot());
 
// ECo contribution
final EcoContributionInstallationUtils ecoUtils = new EcoContributionInstallationUtils();
ecoUtils.updateEcoCommonTable(conf.getRoot());
 
// we need to upgrade all roots
// ///////////////////////////
conf.getSystemRoot().mapAllRoots();
373,11 → 381,15
updateToV1Dot4(root);
// DSN
dsnUtils.updateDSN(root);
// Eco contribution
ecoUtils.updateEco(root);
updateStyle(root);
createBanque(root);
createAssocAnalytique(root, conf);
updateStock(root);
updateVille(root.getTable("ADRESSE"));
 
Updater_1_5.update(root);
return null;
}
 
1747,6 → 1759,65
}
}
 
SQLTable tableInfosSal = root.getTable("INFOS_SALARIE_PAYE");
if (!tableInfosSal.contains("ID_SALARIE")) {
// Ajout INFOS_SALARIE_PAYE.ID_SALARIE
AlterTable t = new AlterTable(tableInfosSal);
t.addForeignColumn("ID_SALARIE", root.getTable("SALARIE"));
 
try {
 
tableInfosSal.getBase().getDataSource().execute(t.asString());
tableInfosSal.getSchema().updateVersion();
tableInfosSal.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableInfosSal.getName(), ex);
}
 
// Ajout CONTRAT.DEBUT_CONTRAT
SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
AlterTable tContrat = new AlterTable(tableContrat);
tContrat.addDateAndTimeColumn("DATE_DEBUT");
tContrat.addDateAndTimeColumn("DATE_MODIFICATION");
// tContrat.addForeignColumn("ID_INFOS_SALARIE_PAYE_MODIFIE", tableInfosSal);
try {
tableContrat.getBase().getDataSource().execute(tContrat.asString());
tableContrat.getSchema().updateVersion();
tableContrat.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableContrat.getName(), ex);
}
 
// Ajout FICHE_PAYE.INFOS_SALARIE_PAYE
SQLTable tableFichePaye = root.getTable("FICHE_PAYE");
AlterTable tFicheSal = new AlterTable(tableFichePaye);
tFicheSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", root.getTable("INFOS_SALARIE_PAYE"));
try {
 
tableFichePaye.getBase().getDataSource().execute(tFicheSal.asString());
tableFichePaye.getSchema().updateVersion();
tableFichePaye.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableFichePaye.getName(), ex);
}
 
{
// Mise à jour des dates de début de contrat
UpdateBuilder builderContrat = new UpdateBuilder(tableContrat);
builderContrat.addBackwardVirtualJoin(tableInfosSal, "ID_CONTRAT_SALARIE");
builderContrat.setFromVirtualJoinField("DATE_DEBUT", tableInfosSal.getAlias(), "DATE_ARRIVE");
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderContrat.asString());
}
{
// Mise à jour des INFOS_SALARIE_PAYE dans les fiches
SQLTable tableSalarie = root.getTable("SALARIE");
UpdateBuilder builderFiche = new UpdateBuilder(tableFichePaye);
builderFiche.addForwardVirtualJoin(tableSalarie, "ID_SALARIE");
builderFiche.setFromVirtualJoinField("ID_INFOS_SALARIE_PAYE", tableSalarie.getAlias(), "ID_INFOS_SALARIE_PAYE");
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderFiche.asString());
}
}
 
// Cumuls paye
SQLTable tableCumulsPaye = root.getTable("CUMULS_PAYE");
 
1757,11 → 1828,35
tCumuls.alterColumn("SAL_BRUT_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
tCumuls.alterColumn("NET_A_PAYER_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
tCumuls.alterColumn("CSG_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
if (!tableCumulsPaye.contains("HEURE_TRAV")) {
tCumuls.addDecimalColumn("HEURE_TRAV", 16, 2, BigDecimal.ZERO, false);
if (tableCumulsPaye.contains("HEURE_TRAV") && !tableCumulsPaye.contains("HEURE_TRAV_C")) {
 
AlterTable tColumnNameCumuls = new AlterTable(tableCumulsPaye);
 
tColumnNameCumuls.addClause(new DeferredClause() {
@Override
public String asString(ChangeTable<?> ct, SQLName tableName) {
return (root.getServer().getSQLSystem() == SQLSystem.POSTGRESQL ? "RENAME COLUMN \"HEURE_TRAV\" TO \"HEURE_TRAV_C\"" : "ALTER COLUMN \"HEURE_TRAV\" RENAME TO \"HEURE_TRAV_C\"");
}
 
@Override
public ClauseType getType() {
return ClauseType.OTHER;
}
});
try {
 
tableCumulsPaye.getBase().getDataSource().execute(tColumnNameCumuls.asString());
tableCumulsPaye.getSchema().updateVersion();
tableCumulsPaye.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la modification du champ de la table " + tableCumulsPaye.getName(), ex);
}
} else if (!tableCumulsPaye.contains("HEURE_TRAV_C")) {
tCumuls.addDecimalColumn("HEURE_TRAV_C", 16, 2, BigDecimal.ZERO, false);
}
 
try {
 
tableCumulsPaye.getBase().getDataSource().execute(tCumuls.asString());
tableCumulsPaye.getSchema().updateVersion();
tableCumulsPaye.fetchFields();
2265,7 → 2360,10
if (tableClient != null) {
AlterTable t = new AlterTable(tableClient);
boolean upClient = false;
 
if (!tableClient.contains("REMIND_DATE")) {
t.addDateAndTimeColumn("REMIND_DATE");
upClient = true;
}
if (!tableClient.contains("BLOQUE_LIVRAISON")) {
t.addBooleanColumn("BLOQUE_LIVRAISON", false, false);
upClient = true;
2361,6 → 2459,8
createTaskTable.addForeignColumn(createTaskGroupTable);
createTaskTable.addLongColumn("SOURCE_ID", null, true);
createTaskTable.addVarCharColumn("SOURCE_TABLE", 256);
createTaskTable.addVarCharColumn("UID", 1024);
createTaskTable.addVarCharColumn("LOCATION", 4096);
try {
root.getDBSystemRoot().getDataSource().execute(createTaskGroupTable.asString());
insertUndef(createTaskGroupTable);
2367,6 → 2467,9
root.getDBSystemRoot().getDataSource().execute(createTaskTable.asString());
insertUndef(createTaskTable);
tableDevis.getSchema().updateVersion();
root.refetchTable("CALENDAR_ITEM_GROUP");
root.refetchTable("CALENDAR_ITEM");
 
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
}
2478,8 → 2581,34
if (numerotationFixed) {
rNumerotation.commit();
}
 
//
 
final SQLTable tableCalendarItem = root.getTable("CALENDAR_ITEM");
if (tableCalendarItem != null) {
final AlterTable tVF = new AlterTable(tableCalendarItem);
boolean needUpdate = false;
if (!tableCalendarItem.getFieldsName().contains("UID")) {
tVF.addVarCharColumn("UID", 1024);
needUpdate = true;
}
if (!tableCalendarItem.getFieldsName().contains("LOCATION")) {
tVF.addVarCharColumn("LOCATION", 4096);
needUpdate = true;
}
if (needUpdate) {
try {
tableCalendarItem.getBase().getDataSource().execute(tVF.asString());
tableCalendarItem.getSchema().updateVersion();
tableCalendarItem.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout de UID sur la table CALENDAR_ITEM", ex);
}
}
}
 
}
 
private void updateStyle(final DBRoot root) throws SQLException {
SQLTable style = root.getTable("STYLE");
SQLRowValues rowVals = new SQLRowValues(style);
3622,7 → 3751,7
CorrectOrder orderCorrect = new CorrectOrder(sysRoot);
orderCorrect.change(tableCommercial);
 
new AddFK(sysRoot).changeAll(root);
// new AddFK(sysRoot).changeAll(root);
sysRoot.reload(Collections.singleton(root.getName()));
 
try {
3811,9 → 3940,9
rowValsUserRight.put("HAVE_RIGHT", Boolean.TRUE);
rowValsUserRight.commit();
}
if (!codes.contains("GROUP_ITEM_SHOW")) {
if (!codes.contains(GroupSQLComponent.ITEM_RIGHT_CODE)) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("CODE", "GROUP_ITEM_SHOW");
rowVals.put("CODE", GroupSQLComponent.ITEM_RIGHT_CODE);
rowVals.put("NOM", "Autoriser à visualiser un champ");
String desc = "Autorise un utilisateur à visualiser le champ spécifié en objet dans une interface.";
rowVals.put("DESCRIPTION", desc);
4092,6 → 4221,16
alter = true;
}
 
if (!table.getFieldsName().contains("ID_COMPTE_PCE_AVANCE_CLIENT")) {
t.addForeignColumn("ID_COMPTE_PCE_AVANCE_CLIENT", root.getTable("COMPTE_PCE"));
alter = true;
}
 
if (!table.getFieldsName().contains("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT")) {
t.addForeignColumn("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", root.getTable("COMPTE_PCE"));
alter = true;
}
 
if (!table.getFieldsName().contains("ID_COMPTE_PCE_PORT_NON_SOUMIS")) {
t.addForeignColumn("ID_COMPTE_PCE_PORT_NON_SOUMIS", root.getTable("COMPTE_PCE"));
alter = true;
4128,8 → 4267,22
rowVals.commit();
}
 
if (!prefs.contains("AvanceClients")) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("NOM", "AvanceClients");
rowVals.put("NUMERO_DEFAULT", "4191");
rowVals.commit();
}
 
if (!prefs.contains("ValeurEncaissement")) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("NOM", "ValeurEncaissement");
rowVals.put("NUMERO_DEFAULT", "511");
rowVals.commit();
}
 
}
 
private void updateSocieteTable(DBRoot root) throws SQLException {
SQLTable table = root.findTable("SOCIETE_COMMON");
boolean alter = false;
/trunk/OpenConcerto/src/org/openconcerto/erp/config/SQLElementNames_fr.xml
3,4 → 3,5
<element refid="CONTACT_FOURNISSEUR" nameClass="masculine" name="contact fournisseur" namePlural="contacts fournisseurs" />
<element refid="CONTACT_ADMINISTRATIF" nameClass="masculine" name="contact administratif" namePlural="contacts administratifs" />
<element refid="CATEGORIE_CLIENT" nameClass="feminine" name="Catégorie de client" />
<element refid="FAMILLE_ECO_CONTRIBUTION" nameClass="feminine" name="Famille d'éco contribution" />
</translations>
/trunk/OpenConcerto/src/org/openconcerto/erp/config/translation_fr.xml
35,7 → 35,7
<menu id="menu.list" label="Gestion" />
<menu id="menu.list.customer" label="Gestion des clients" />
<menu id="customer.list" label="Liste des clients" />
<menu id="contact.list" label="Liste des contacts" />
<menu id="contact.list" label="Liste des contacts clients" />
<menu id="customer.history" label="Historique des clients" />
<menu id="customer.quote.list" label="Liste des devis" />
<menu id="customer.proposal.list" label="Liste des propositions" />
57,13 → 57,13
<menu id="customer.credit.list" label="Liste des avoirs" />
<menu id="menu.list.supplier" label="Fournisseurs" />
<menu id="supplier.list" label="Liste des fournisseurs" />
<menu id="supplier.contact.list" label="Liste des contact fournisseur" />
<menu id="supplier.contact.list" label="Liste des contacts fournisseurs" />
<menu id="supplier.history" label="Historique des fournisseurs" />
<menu id="supplier.order.list" label="Liste des commandes fournisseur" />
<menu id="supplier.order.list" label="Liste des commandes fournisseurs" />
<menu id="supplier.receipt.list" label="Liste des bons de réception" />
<menu id="supplier.purchase.list" label="Liste des saisies d'achat" />
<menu id="supplier.invoice.purchase.list" label="Liste des factures fournisseurs" />
<menu id="supplier.credit.list" label="Liste des avoirs fournisseur" />
<menu id="supplier.credit.list" label="Liste des avoirs fournisseurs" />
<menu id="product.list" label="Liste des articles" />
<menu id="product.reference.list" label="Liste des références" />
<menu id="stock.io.list" label="Listes des mouvements de stock" />
195,6 → 195,7
<action id="sales.invoice.clone" label="Créer à partir de" />
<action id="sales.invoice.info.show" label="Détails client" />
<action id="sales.invoice.create.supplier.order" label="Transférer en commande" />
<action id="sales.invoice.cancel.credit" label="Annuler l'avoir affecté" />
<action id="sales.shipment.create.invoice" label="Transfert en facture" />
 
<!-- Document -->
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_fr.xml
92,6 → 92,8
</TABLE>
 
<TABLE name="ARTICLE">
<FIELD name="ID_TAXE_COMPLEMENTAIRE" label="Taxe complémentaire" />
<FIELD name="ID_ECO_CONTRIBUTION" label="Eco contribution" />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" titlelabel="Unité de vente" />
<FIELD name="QTE_ACHAT" label="Quantité multiple d'achat à respecter" titlelabel="Quantité multiple d'achat à respecter" />
<FIELD name="CODE_BARRE" label="Code barres" titlelabel="Code barres" />
175,6 → 177,12
<FIELD name="ID_REPARTITION_ANALYTIQUE" label="Répartition" titlelabel="Répartition" />
</TABLE>
 
<TABLE name="ATTACHMENT">
<FIELD name="SOURCE_TABLE" label="Compte" titlelabel="Compte" />
<FIELD name="SOURCE_ID" label="Axe" titlelabel="Axe" />
<FIELD name="NAME" label="Répartition" titlelabel="Répartition" />
</TABLE>
 
<TABLE name="AVIS_INTERVENTION">
<FIELD name="ID_SECRETAIRE" label="Secretaire" titlelabel="Secretaire" />
<FIELD name="ID_FICHE_RENDEZ_VOUS" label="Fiche de rendez vous" titlelabel="Fiche de rendez vous" />
218,9 → 226,13
<FIELD name="MOTIF" label="Motif" titlelabel="Motif" />
<FIELD name="T_DEVISE" label="Total Devise" titlelabel="Total Devise" />
<FIELD name="ID_MODELE" label="Modèle" />
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
 
<TABLE name="AVOIR_CLIENT_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="RETOUR_STOCK" label="Remettre en stock" />
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille d'article" />
<FIELD name="NB_COLIS" label="Nb Colis" titlelabel="Nb Colis" />
311,6 → 323,21
<FIELD name="NOM" label="Axe" titlelabel="Axe" />
</TABLE>
 
<TABLE name="AYANT_DROIT">
<FIELD name="NOM" label="Nom de l'ayant droit" />
<FIELD name="PRENOMS" label="Prénoms de l'ayant droit" />
<FIELD name="ID_AYANT_DROIT_TYPE" label="Type d'ayant droit" />
<FIELD name="REGIME_ALSACE" label="Bénéficiant régime Alsace Lorraine" />
<FIELD name="NIR" label="NIR" />
<FIELD name="ID_SALARIE" label="Rattaché au salarié" />
<FIELD name="CODE_ORGANISME_AFFILIATION" label="Code Org affiliation" />
<FIELD name="CODE_OPTION" label="Code Option" />
<FIELD name="NIR_OUVRANT_DROIT" label="NIR ouvrant-droit régime de base maladie" />
<FIELD name="DATE_DEBUT_RATTACHEMENT" label="Date début rattachement" />
<FIELD name="DATE_FIN_RATTACHEMENT" label="Date fin rattachement" />
<FIELD name="DATE_NAISSANCE" label="Date de naissance" />
</TABLE>
 
<TABLE name="BANQUE_POLE_PRODUIT">
<FIELD name="NOM" label="Nom" titlelabel="Nom" />
<FIELD name="NUMERO_RUE" label="Numéro de rue" titlelabel="Numéro de rue" />
362,9 → 389,13
<FIELD name="NOM" label="Référence" titlelabel="Référence" />
<FIELD name="ID_COMMANDE" label="Commande" titlelabel="Commande" />
<FIELD name="ID_DEVISE" label="Devise" titlelabel="Devise" />
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
 
<TABLE name="BON_RECEPTION_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." titlelabel="Qté U.V." />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" titlelabel="Unité de vente" />
<FIELD name="ID_ARTICLE" label="Article" titlelabel="Article" />
426,8 → 457,12
<FIELD name="REMISE_HT" label="Remise HT" />
<FIELD name="ID_TAXE_PORT" label="TVA sur Port" />
<FIELD name="ID_MODELE" label="Modèle" />
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
<TABLE name="BON_DE_LIVRAISON_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille d'article" />
<FIELD name="NB_COLIS" label="Nb Colis" titlelabel="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" titlelabel="Pds Colis" />
546,6 → 581,7
<FIELD name="ID_COMPTE_PCE_SERVICE" label="Compte de service spécifique" titlelabel="Compte de service spécifique" />
<FIELD name="ID_TARIF_MISSION_LIBELLE" label="Tarif" titlelabel="Tarif" />
<FIELD name="ID_TYPE_CLIENT" label="Type de client" />
<FIELD name="REMIND_DATE" label="Date de rappel" />
<FIELD name="ID_GROUPE_CLIENT" label="Groupe" />
<FIELD name="ID_PAYS" label="Pays" titlelabel="Pays" />
<FIELD name="ID_LANGUE" label="Langue" titlelabel="Langue" />
645,6 → 681,8
</TABLE>
 
 
 
 
<TABLE name="CODE_MISSION">
<FIELD name="CONTROLE_TECHNIQUE" label="Mission controle technique" titlelabel="Mission controle technique" />
<FIELD name="CODE" label="Code" titlelabel="Code" />
658,6 → 696,10
<FIELD name="NOTA" label="Nota" titlelabel="Nota" />
</TABLE>
 
<TABLE name="CODE_PENIBILITE_CONTRAT_SALARIE">
<FIELD name="ID_CODE_PENIBILITE" label="Code pénibilité (S21.G00.34.001)" />
</TABLE>
 
<TABLE name="CODE_STATUT_PROF">
<FIELD name="CODE" label="Code" titlelabel="Code" />
<FIELD name="NOM" label="Libellé" titlelabel="Libellé" />
720,6 → 762,49
<FIELD name="N4DS" label="Contact pour la N4DS" titlelabel="Contact pour la N4DS" />
</TABLE>
 
<TABLE name="CONTRAT_PREVOYANCE">
<FIELD name="REFERENCE" label="Référence du contrat de Prévoyance (S21.G00.15.001)" />
<FIELD name="DATE_DEBUT" label="Date début" />
<FIELD name="DATE_FIN" label="Date de fin" />
<FIELD name="CODE_ORGANISME" label="Code organisme (S21.G00.15.002)" />
<FIELD name="CODE_DELEGATAIRE" label="Code délégataire de gestion (S21.G00.15.003)" />
<FIELD name="CODE_UNIQUE" label="Code DSN (S21.G00.15.001)" />
<FIELD name="NOM" label="Nom du contrat" />
<FIELD name="COTISATION_ETABLISSEMENT" label="Cotisation établissement formation, paritarisme, ... (S21.G00.82)" />
</TABLE>
<TABLE name="CONTRAT_PREVOYANCE_AYANT_DROIT">
<FIELD name="ID_AYANT_DROIT" label="Ayant droit" />
<FIELD name="ID_CONTRAT_PREVOYANCE" label="Contrat Prévoyance" />
<FIELD name="DATE_FIN" label="Date de fin" />
<FIELD name="CODE_ORGANISME" label="Code organisme" />
<FIELD name="CODE_DELEGATAIRE" label="Code délégataire de gestion" />
<FIELD name="CODE_UNIQUE" label="Code DSN" titlelabel="Code DSN" />
<FIELD name="NOM" label="Nom du contrat" />
</TABLE>
 
<TABLE name="CONTRAT_PREVOYANCE_RUBRIQUE">
<FIELD name="ID_RUBRIQUE_COTISATION" label="Rubrique de cotisation" />
<FIELD name="ID_CONTRAT_PREVOYANCE" label="Contrat prévoyance" />
</TABLE>
 
<TABLE name="CONTRAT_PREVOYANCE_RUBRIQUE_NET">
<FIELD name="ID_RUBRIQUE_NET" label="Rubrique de net" />
<FIELD name="ID_CONTRAT_PREVOYANCE" label="Contrat prévoyance" />
</TABLE>
 
<TABLE name="CONTRAT_PREVOYANCE_CONTRAT_SALARIE">
<FIELD name="ID_INFOS_SALARIE_PAYE" label="Contrat Salarié" />
<FIELD name="ID_CONTRAT_PREVOYANCE" label="Contrat prévoyance" />
<FIELD name="CODE_OPTION" label="Code option retenue par le salarié" />
<FIELD name="CODE_POPULATION" label="Code population de rattachement" />
<FIELD name="NB_ENFANT_CHARGE" label="Nombre d’enfants à charge" />
<FIELD name="NB_ADULTE_AYANT_DROIT" label="Nombre d'adultes ayants-droit (conjoint, concubin, ...)" />
<FIELD name="NB_AYANT_DROIT" label="Nombre d'ayants-droit" />
<FIELD name="NB_AYANT_DROIT_AUTRE" label="Nombre d'ayants-droit autres (ascendants, collatéraux...)" />
<FIELD name="NB_ENFANT_AYANT_DROIT" label="Nombre d'enfants ayants-droit" />
</TABLE>
 
 
<TABLE name="CONTRAT_SALARIE">
<FIELD name="NATURE" label="Nature de l'emploi (*)" titlelabel="Nature de l'emploi" />
<FIELD name="ID_CODE_EMPLOI" label="Catégorie socioprofessionnelle " titlelabel="Code Catégorie socioprofessionnelle" />
741,7 → 826,10
<FIELD name="NUMERO_RATTACHEMENT_UGRC" label="N° rattachement AGIRC" titlelabel="N° rattachement AGIRC" />
<FIELD name="CODE_IRC_RETRAITE" label="Code IRC prévoyance" titlelabel="Code IRC prévoyance" />
<FIELD name="NUMERO_RATTACHEMENT_RETRAITE" label="N° rattachement prévoyance" titlelabel="N° rattachement prévoyance" />
<FIELD name="DATE_PREV_FIN" label="Date de fin prévisionnelle" />
<FIELD name="DATE_PREV_FIN" label="Date de fin prévisionnelle (S21.G00.40.010)" />
<FIELD name="DATE_DEBUT" label="Date de début de contrat (S21.G00.40.001)" />
<FIELD name="DATE_MODIFICATION" label="Date de modification" />
<FIELD name="NUMERO" label="Numéro" />
</TABLE>
 
<TABLE name="COMMANDE">
769,9 → 857,13
<FIELD name="ID_CLIENT" label="Client" titlelabel="Client" />
<FIELD name="ID_MODELE" label="Modèle" />
<FIELD name="ID_ADRESSE" label="Adresse de livraison spécifique" titlelabel="Adresse de livraison spécifique" />
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
 
<TABLE name="COMMANDE_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="INCOTERM" label="Incoterm" />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." titlelabel="Qté U.V." />
<FIELD name="ID_CODE_FOURNISSEUR" label="Code Fournisseur" titlelabel="Code Fournisseur" />
813,9 → 905,11
</TABLE>
 
<TABLE name="COMMANDE_CLIENT">
<FIELD name="DATE_LIVRAISON_PREV" label="Livraison prévue le" titlelabel="Livraison prévue le" />
<FIELD name="ID_ADRESSE" label="Adresse fact. spéc." titlelabel="Adresse fact. spéc." />
<FIELD name="ID_ADRESSE_LIVRAISON" label="Adresse livr. spéc." titlelabel="Adresse livr. spéc." />
<FIELD name="ID_CLIENT_DEPARTEMENT" label="Service" />
<FIELD name="ACOMPTE_COMMANDE" label="Acompte" />
<FIELD name="ID_CONTACT" label="Contact" titlelabel="Contact" />
<FIELD name="NOM" label="Référence" titlelabel="Référence" />
<FIELD name="NUMERO_EXPEDITION" label="Numéro d'expédition" />
840,9 → 934,13
<FIELD name="TYPE_EXPEDITION" label="Type d'envoi" />
<FIELD name="ID_TARIF" label="Tarif à appliquer" />
<FIELD name="ID_MODELE" label="Modèle" />
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
 
<TABLE name="COMMANDE_CLIENT_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille d'article" />
<FIELD name="NB_COLIS" label="Nb Colis" titlelabel="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" titlelabel="Pds Colis" />
905,6 → 1003,13
<FIELD name="TEL_PERSONEL" label="Numéro de tel personnel" titlelabel="Numéro de tel personnel" />
</TABLE>
 
<TABLE name="COMPTE_CLIENT_TRANSACTION">
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="DATE" label="Date" />
<FIELD name="MONTANT" label="Montant" />
<FIELD name="ID_REGLEMENT" label="Règlement" />
</TABLE>
 
<TABLE name="COMPTE_PCE">
<FIELD name="NUMERO" label="N° de compte" titlelabel="N° de compte" />
<FIELD name="NOM" label="Compte" titlelabel="Compte" />
947,6 → 1052,7
<FIELD name="NET_IMP_C" label="Salaire net imposable cumulé" titlelabel="Salaire net imposable cumulé" />
<FIELD name="NET_A_PAYER_C" label="Salaire net cumulé" titlelabel="Salaire net cumulé" />
<FIELD name="CSG_C" label="Base CSG cumulée" titlelabel="Base CSG cumulée" />
<FIELD name="HEURE_TRAV_C" label="Heures travaillées cumulées" />
</TABLE>
 
<TABLE name="DEPARTEMENT">
1017,9 → 1123,12
<FIELD name="NB_RAPPORT_SAISI" label="Nombre de rapport saisis" />
<FIELD name="DATE_DEMANDE_SAISIE" label="Date de demande en saisie" />
<FIELD name="TYPE_RAPPORT" label="Type de rapport" />
 
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
<TABLE name="DEVIS_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille d'article" />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." titlelabel="Qté U.V." />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" titlelabel="Unité de vente" />
1233,9 → 1342,13
<FIELD name="ID_COMPTE_PCE" label="Compte de charge" titlelabel="Compte de charge" />
<FIELD name="ID_CLIENT" label="Client" titlelabel="Client" />
<FIELD name="ID_ADRESSE" label="Adresse de livraison spécifique" titlelabel="Adresse de livraison spécifique" />
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
 
<TABLE name="FACTURE_FOURNISSEUR_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." titlelabel="Qté U.V." />
<FIELD name="ID_CODE_FOURNISSEUR" label="Code Fournisseur" titlelabel="Code Fournisseur" />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" titlelabel="Unité de vente" />
1398,7 → 1511,7
<FIELD name="INFOS" label="Informations complèmentaires" titlelabel="Informations complèmentaires" />
<FIELD name="MAIL" label="E-Mail" titlelabel="E-Mail" />
<FIELD name="ID_LANGUE" label="Langue" titlelabel="Langue" />
<FIELD name="NOM" label="Nom du fournisseur" titlelabel="Nom" />
<FIELD name="NOM" label="Nom du fournisseur" titlelabel="Fournisseur" />
<FIELD name="CODE" label="Code" titlelabel="Code" />
<FIELD name="UE" label="Fournisseur étranger membre de l'UE" titlelabel="Fournisseur étranger membre de l'UE" />
<FIELD name="ID_ADRESSE" label="Adresse" titlelabel="Adresse" />
1761,6 → 1874,15
<FIELD name="ID_ARTICLE" label="Article" />
</TABLE>
 
<TABLE name="RELIQUAT_BL">
<FIELD name="DATE" label="Date" titlelabel="Date" />
<FIELD name="ID_BON_DE_LIVRAISON_ELEMENT" label="BL élément" />
<FIELD name="ID_BON_DE_LIVRAISON" label="Bon livraison" />
<FIELD name="QTE_UNITAIRE" label="Qté unitaire" />
<FIELD name="QTE" label="Qté" />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" />
<FIELD name="ID_ARTICLE" label="Article" />
</TABLE>
 
<TABLE name="REPARTITION_ANALYTIQUE">
<FIELD name="NOM" label="Libellé" titlelabel="Libellé" />
1825,6 → 1947,7
<FIELD name="CREATION_AUTO" label="Article généré" titlelabel="généré" />
</TABLE>
<TABLE name="SAISIE_VENTE_FACTURE">
<FIELD name="ACOMPTE_COMMANDE" label="Acompte" />
<FIELD name="SOUMIS_TIMBRE_FISCAL" label="Soumis au timbre," />
<FIELD name="TAUX_TIMBRE_FISCAL" label="Taux du timbre" />
<FIELD name="TOTAL_TIMBRE_FISCAL" label="Total timbre" />
1877,9 → 2000,12
<FIELD name="CONTROLE_TECHNIQUE" label="Facture CTC" titlelabel="Facture CTC" />
<FIELD name="COMPTE_SERVICE_AUTO" label="Gestion automatique du compte de service" titlelabel="Gestion automatique du compte de service" />
<FIELD name="ID_TARIF" label="Tarif à appliquer" />
 
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
</TABLE>
<TABLE name="SAISIE_VENTE_FACTURE_ELEMENT">
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille d'article" />
<FIELD name="NB_COLIS" label="Nb Colis" titlelabel="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" titlelabel="Pds Colis" />
2037,6 → 2163,13
<FIELD name="ID_COMPTE_PCE_SERVICE" label="Compte services par défaut (classe 7)" />
</TABLE>
 
<TABLE name="TAXE_COMPLEMENTAIRE">
<FIELD name="NOM" label="Libellé" />
<FIELD name="POURCENT" label="Pourcentage" />
<FIELD name="ID_COMPTE_PCE" label="Compte" />
<FIELD name="ID_COMPTE_PCE_PRODUITS" label="Compte produits" />
</TABLE>
 
<TABLE name="TICKET_CAISSE">
<FIELD name="DATE" label="Date" titlelabel="Date" />
<FIELD name="TOTAL_HT" label="Total HT" titlelabel="Total HT" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/Gestion.java
29,7 → 29,9
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRequestLog;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.sql.request.BaseFillSQLRequest;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
176,11 → 178,11
public boolean implies(ProtectionDomain domain, Permission permission) {
if (domain != null && domain.getClassLoader() == mainLoader) {
return true;
} else {
}
// super caches results (avoid calling expensive isExt())
return super.implies(domain, permission);
 
}
}
});
 
System.setSecurityManager(new SecurityManager());
192,8 → 194,8
 
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
ExceptionHandler.handle("UncaughtException on thread " + t, e);
 
}
});
System.out.println("Java version: " + System.getProperty("java.vendor", "??") + " - " + System.getProperty("java.version", "??"));
202,7 → 204,7
ExceptionHandler.setForumURL("http://www.openconcerto.org/forum");
ExceptionHandler.setSoftwareInformations(SoftwareInfoPanel.FACTORY);
ExceptionHandler.setShowProbably(true);
 
System.setProperty(SQLRowAccessor.ACCESS_DB_IF_NEEDED_PROP, "true");
System.setProperty(PropsConfiguration.REDIRECT_TO_FILE, "true");
// Mac
// only works with Aqua laf
235,12 → 237,19
 
System.setProperty(ITextCombo.SIMPLE_TRAVERSAL, "true");
 
// Disable FOR SHARE lock
BaseFillSQLRequest.setDefaultLockSelect(false);
 
ComboSQLRequest.setDefaultItemsOrder(CompareUtils.<IComboSelectionItem> naturalOrder());
// Initialisation du splashScreen
// ne pas oublier en param -splash:image.png
try {
SplashScreen.getSplashScreen();
} catch (Exception e) {
// Can occur on OpenJDK...
System.out.println("SplashScreen failed... " + e.getMessage());
}
 
 
// must be done before creating UserRightsManager (which is done by
// PropsConfiguration.getRoot())
UserRightsManager.DEFAULT_MACRO_RIGHTS.add(new ComptaTotalUserRight());
250,9 → 259,19
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
 
if (conf == null) {
System.out.println("Unable to create configuration, launching ServerFinderPanel");
ServerFinderPanel.main(new String[0]);
return;
}
// Dump conf directories
try {
System.out.println("Application data folder : " + conf.getBaseDirs().getAppDataFolder().getCanonicalPath());
System.out.println("Application cache folder : " + conf.getBaseDirs().getCacheFolder().getCanonicalPath());
System.out.println("Application preferences folder : " + conf.getBaseDirs().getPreferencesFolder().getCanonicalPath());
} catch (IOException ex2) {
ex2.printStackTrace();
}
System.out.println("Application working directory folder : " + conf.getWD().getAbsolutePath());
if (inWebStart()) {
// needed since our classes aren't loaded by the same loader as the library classes
Helper.setURLStreamHandlerFactory();
262,6 → 281,11
System.setSecurityManager(null);
}
Configuration.setInstance(conf);
try {
Configuration.migrateToNewDir(conf.getOldDataDir(), conf.getDataDir());
} catch (IOException ex) {
throw new IllegalStateException("Couldn't migrate data dir", ex);
}
 
final boolean logRequests = Boolean.valueOf(conf.getProperty("logRequests", "false"));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_pl.xml
344,7 → 344,7
</TABLE>
 
<TABLE name="CHEQUE_A_ENCAISSER">
<FIELD name="ID_CLIENT" label="Customer" />
<FIELD name="ID_CLIENT" label="Klient" />
<FIELD name="ID_MOUVEMENT" label="Mouvement" titlelabel="Mouvement" />
<FIELD name="MONTANT" label="Amount" />
<FIELD name="ENCAISSE" label="Deposit done" />
371,7 → 371,7
</TABLE>
 
<TABLE name="CHEQUE_AVOIR_CLIENT">
<FIELD name="ID_CLIENT" label="Customer" />
<FIELD name="ID_CLIENT" label="Klient" />
<FIELD name="MONTANT" label="Amount" titlelabel="Amount" />
<FIELD name="DECAISSE" label="Décaissé" titlelabel="Décaissé" />
<FIELD name="DATE_AVOIR" label="Avoir du" titlelabel="Avoir du" />
676,6 → 676,13
<FIELD name="TEL_PERSONEL" label="Telefon prywatny" titlelabel="Telefon prywatny" />
</TABLE>
 
<TABLE name="COMPTE_CLIENT_TRANSACTION">
<FIELD name="ID_CLIENT" label="Klient" />
<FIELD name="DATE" label="Date" />
<FIELD name="MONTANT" label="Suma" />
<FIELD name="ID_REGLEMENT" label="Payment" />
</TABLE>
<TABLE name="COMPTE_PCE">
<FIELD name="NUMERO" label="Numer konta" titlelabel="Numer konta" />
<FIELD name="NOM" label="Nazwa" />
864,7 → 871,7
<FIELD name="DATE" label="Date de règlement" titlelabel="Date de règlement" />
<FIELD name="MONTANT" label="Amount" titlelabel="Amount" />
<FIELD name="NOM" label="Libellé encaissement" titlelabel="Libellé encaissement" />
<FIELD name="ID_CLIENT" label="Customer" />
<FIELD name="ID_CLIENT" label="Klient" />
<FIELD name="ID_MODE_REGLEMENT" label="Method of payment" />
<FIELD name="ID_ECHEANCE_CLIENT" label="Echéance client" titlelabel="échéance" />
</TABLE>
949,7 → 956,7
<TABLE name="FICHE_RENDEZ_VOUS">
<FIELD name="DATE" label="Date de création" titlelabel="Date de création" />
<FIELD name="ID_VERIFICATEUR" label="Pilote" titlelabel="Pilote" />
<FIELD name="ID_CLIENT" label="Customer" />
<FIELD name="ID_CLIENT" label="Klient" />
<FIELD name="ID_COMMERCIAL" label="Saleman" />
<FIELD name="ID_CONTACT" label="Correspondant" titlelabel="Correspondant" />
<FIELD name="ID_AFFAIRE" label="Project" titlelabel="Project" />
1271,7 → 1278,7
<TABLE name="RELANCE">
<FIELD name="DATE" label="Date de relance" titlelabel="Date de relance" />
<FIELD name="ID_SAISIE_VENTE_FACTURE" label="Facture" titlelabel="Facture" />
<FIELD name="ID_CLIENT" label="Customer" />
<FIELD name="ID_CLIENT" label="Klient" />
<FIELD name="MONTANT" label="Amount" titlelabel="Amount" />
<FIELD name="ID_TYPE_LETTRE_RELANCE" label="Type de lettre" titlelabel="Type de lettre" />
<FIELD name="INFOS" label="Comments" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/EcoContributionInstallationUtils.java
New file
0,0 → 1,311
/*
* 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.config;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSyntax;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.Inserter;
import org.openconcerto.sql.request.Inserter.Insertion;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ReOrder;
import org.openconcerto.sql.utils.SQLCreateTable;
 
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class EcoContributionInstallationUtils {
 
class EcoContribution {
final private String code, libelle, famille;
final private BigDecimal taux;
 
public EcoContribution(String code, String libelle, String famille, double taux) {
this.code = code;
this.libelle = libelle;
this.famille = famille;
this.taux = new BigDecimal(taux);
}
 
public String getCode() {
return code;
}
 
public String getFamille() {
return famille;
}
 
public String getLibelle() {
return libelle;
}
 
public BigDecimal getTaux() {
return taux;
}
}
 
private void insertUndef(final SQLCreateTable ct) throws SQLException {
// check that we can use insertReturnFirstField()
if (ct.getPrimaryKey().size() != 1)
throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
final Insertion<?> insertion = new Inserter(ct).insertReturnFirstField("(" + SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES(" + ReOrder.MIN_ORDER + ")", false);
assert insertion.getCount() == 1;
if (insertion.getRows().size() != 1)
throw new IllegalStateException("Missing ID " + insertion.getRows());
SQLTable.setUndefID(ct.getRoot().getSchema(), ct.getName(), ((Number) insertion.getRows().get(0)).intValue());
}
 
private void insertValues(List<EcoContribution> values, SQLTable table) throws SQLException {
for (EcoContribution eco : values) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("CODE", eco.getCode());
rowVals.put("NOM", eco.getLibelle());
rowVals.put("ID_FAMILLE_ECO_CONTRIBUTION", getFamille(eco.getFamille(), table));
rowVals.put("TAUX", eco.getTaux());
rowVals.commit();
}
}
 
Map<Object, SQLRowValues> familleMap = new HashMap<Object, SQLRowValues>();
 
private Object getFamille(String famille, SQLTable table) {
if (familleMap.containsKey(famille)) {
return familleMap.get(famille);
} else {
SQLRowValues rowValues = new SQLRowValues(table.getTable("FAMILLE_ECO_CONTRIBUTION"));
rowValues.put("NOM", famille);
familleMap.put(famille, rowValues);
return rowValues;
}
}
 
public void updateEcoCommonTable(final DBRoot root) throws SQLException {
 
if (!root.contains("ECO_CONTRIBUTION")) {
 
final SQLCreateTable createTableFamille = new SQLCreateTable(root, "FAMILLE_ECO_CONTRIBUTION");
createTableFamille.addVarCharColumn("NOM", 512);
 
root.getBase().getDataSource().execute(createTableFamille.asString());
insertUndef(createTableFamille);
root.refetchTable("FAMILLE_ECO_CONTRIBUTION");
root.getSchema().updateVersion();
 
final SQLCreateTable createTableEco = new SQLCreateTable(root, "ECO_CONTRIBUTION");
createTableEco.addVarCharColumn("CODE", 256);
createTableEco.addVarCharColumn("NOM", 512);
createTableEco.addForeignColumn("ID_FAMILLE_ECO_CONTRIBUTION", root.getTable("FAMILLE_ECO_CONTRIBUTION"));
createTableEco.addDecimalColumn("TAUX", 16, 2, BigDecimal.ZERO, false);
 
root.getBase().getDataSource().execute(createTableEco.asString());
insertUndef(createTableEco);
root.refetchTable("ECO_CONTRIBUTION");
root.getSchema().updateVersion();
 
// List<EcoContribution> ecos = new
// ArrayList<EcoContributionInstallationUtils.EcoContribution>();
// ecos.add(new EcoContribution("Ecologic E 1", "Ecrans <= 9kg", "Ecrans", 1));
// ecos.add(new EcoContribution("Ecologic E 2", "Ecrans >= 9.01kg et <=18kg", "Ecrans",
// 2));
// ecos.add(new EcoContribution("Ecologic E 3", "Ecrans >= 18.01kg et <=36kg", "Ecrans",
// 4));
// ecos.add(new EcoContribution("Ecologic E 4", "Ecrans >= 36.01kg ", "Ecrans", 8));
// ecos.add(new EcoContribution("Ecologic F 1", "GEM F <= 40kg", "GEM FROID", 6));
// ecos.add(new EcoContribution("Ecologic F 2", "GEM F >= 40.01kg", "GEM FROID", 12.5));
// ecos.add(new EcoContribution("Ecologic HF 1", "GEM HF <= 6kg", "GEM HORS FROID",
// 0.5));
// ecos.add(new EcoContribution("Ecologic HF 2", "GEM HF >= 6.01kg et <=12kg", "GEM HORS
// FROID", 1));
// ecos.add(new EcoContribution("Ecologic HF 3", "GEM HF >= 12.01kg et <=24kg", "GEM
// HORS FROID", 2));
// ecos.add(new EcoContribution("Ecologic HF 4", "GEM HF >= 24.01kg", "GEM HORS FROID",
// 6));
// ecos.add(new EcoContribution("Ecologic P 1", "PAM <= 0.20kg", "PAM", 0.01));
// ecos.add(new EcoContribution("Ecologic P 2", "PAM >=0.21kg et <=0.50kg", "PAM",
// 0.03));
// ecos.add(new EcoContribution("Ecologic P 3", "PAM >=0.51kg et <=1.00kg", "PAM",
// 0.05));
// ecos.add(new EcoContribution("Ecologic P 4", "PAM >=1.01kg et <=2.50kg", "PAM",
// 0.15));
// ecos.add(new EcoContribution("Ecologic P 5", "PAM >=2.51kg et <=4.00kg", "PAM",
// 0.25));
// ecos.add(new EcoContribution("Ecologic P 6", "PAM >=4.01kg et <=8.00kg", "PAM",
// 0.5));
// ecos.add(new EcoContribution("Ecologic P 7", "PAM >=8.01kg et <=12.00kg", "PAM",
// 0.75));
// ecos.add(new EcoContribution("Ecologic P 8", "PAM >=12.01kg et <=20.00kg", "PAM",
// 1.25));
// ecos.add(new EcoContribution("Ecologic P 9", "PAM >= 20.01", "PAM", 2.25));
// ecos.add(new EcoContribution("Ecosys 1.1", "Gros appareils ménagers 1", "Gros
// appareils ménagers", 13));
// ecos.add(new EcoContribution("Ecosys 1.10", "Gros appareils ménagers 10", "Gros
// appareils ménagers", 0.1));
// ecos.add(new EcoContribution("Ecosys 1.2", "Gros appareils ménagers 2", "Gros
// appareils ménagers", 6));
// ecos.add(new EcoContribution("Ecosys 1.3", "Gros appareils ménagers 3", "Gros
// appareils ménagers", 2));
// ecos.add(new EcoContribution("Ecosys 1.4", "Gros appareils ménagers 4", "Gros
// appareils ménagers", 1));
// ecos.add(new EcoContribution("Ecosys 1.5", "Gros appareils ménagers 5", "Gros
// appareils ménagers", 0.5));
// ecos.add(new EcoContribution("Ecosys 1.6", "Gros appareils ménagers 6", "Gros
// appareils ménagers", 0.1));
// ecos.add(new EcoContribution("Ecosys 1.7", "Gros appareils ménagers 7", "Gros
// appareils ménagers", 4));
// ecos.add(new EcoContribution("Ecosys 1.8", "Gros appareils ménagers 8", "Gros
// appareils ménagers", 1));
// ecos.add(new EcoContribution("Ecosys 1.9", "Gros appareils ménagers 9", "Gros
// appareils ménagers", 0.5));
// ecos.add(new EcoContribution("Ecosys 2.1", "Petits appareils ménagers 1", "Petits
// appareils ménagers", 1));
// ecos.add(new EcoContribution("Ecosys 2.2", "Petits appareils ménagers 2", "Petits
// appareils ménagers", 0.5));
// ecos.add(new EcoContribution("Ecosys 2.3", "Petits appareils ménagers 3", "Petits
// appareils ménagers", 0.1));
// ecos.add(new EcoContribution("Ecosys 3.1", "Equipements informatiques et
// télécommunications 1", "Equipement informat. et de télécom.", 8));
// ecos.add(new EcoContribution("Ecosys 3.2", "Equipements informatiques et
// télécommunications 2", "Equipement informat. et de télécom.", 4));
// ecos.add(new EcoContribution("Ecosys 3.3", "Equipements informatiques et
// télécommunications 3", "Equipement informat. et de télécom.", 1));
// ecos.add(new EcoContribution("Ecosys 3.4", "Equipements informatiques et
// télécommunications 4", "Equipement informat. et de télécom.", 1));
// ecos.add(new EcoContribution("Ecosys 3.5", "Equipements informatiques et
// télécommunications 5", "Equipement informat. et de télécom.", 0.3));
// ecos.add(new EcoContribution("Ecosys 3.6", "Equipements informatiques et
// télécommunications 6", "Equipement informat. et de télécom.", 0.5));
// ecos.add(new EcoContribution("Ecosys 3.7", "Equipements informatiques et
// télécommunications 7", "Equipement informat. et de télécom.", 0.1));
// ecos.add(new EcoContribution("Ecosys 3.8", "Equipements informatiques et
// télécommunications 8", "Equipement informat. et de télécom.", 0.01));
// ecos.add(new EcoContribution("Ecosys 4.1", "Matériel grand public 1", "Matériel grand
// public ", 8));
// ecos.add(new EcoContribution("Ecosys 4.2", "Matériel grand public 2", "Matériel grand
// public ", 4));
// ecos.add(new EcoContribution("Ecosys 4.3", "Matériel grand public 3", "Matériel grand
// public ", 1));
// ecos.add(new EcoContribution("Ecosys 4.4", "Matériel grand public 4", "Matériel grand
// public ", 1));
// ecos.add(new EcoContribution("Ecosys 4.5", "Matériel grand public 5", "Matériel grand
// public ", 0.3));
// ecos.add(new EcoContribution("Ecosys 4.6", "Matériel grand public 6", "Matériel grand
// public ", 0.1));
// ecos.add(new EcoContribution("Ecosys 6.1", "Outils électriques et électroniques 1",
// "Outils électriques et électroniques", 0.2));
// ecos.add(new EcoContribution("Ecosys 6.2", "Outils électriques et électroniques 2",
// "Outils électriques et électroniques", 1.5));
// ecos.add(new EcoContribution("Ecosys 7.1", "Jouets. équipements de loisir et de sport
// 1", "Jouet. équip. de loisir et de sport", 0.05));
// ecos.add(new EcoContribution("Ecosys 7.2", "Jouets. équipements de loisir et de sport
// 2", "Jouet. équip. de loisir et de sport", 0.2));
// ecos.add(new EcoContribution("Ecosys 7.3", "Jouets. équipements de loisir et de sport
// 3", "Jouet. équip. de loisir et de sport", 1.5));
// ecos.add(new EcoContribution("Ecosys 8.1", "Dispositifs médicaux 1", "Dispositifs
// médicaux ", 1));
// ecos.add(new EcoContribution("Ecosys 8.2", "Dispositifs médicaux 2", "Dispositifs
// médicaux ", 0.1));
// ecos.add(new EcoContribution("Ecosys 9.1", "Instruments de contrôle et de
// surveillance 1", "Instrument contrôle et surveillance", 0.1));
// ecos.add(new EcoContribution("Ecosys 9.2", "Instruments de contrôle et de
// surveillance 2", "Instrument contrôle et surveillance", 1));
// ecos.add(new EcoContribution("ERP E 1", "Ecrans < 9kg", "Ecrans", 1));
// ecos.add(new EcoContribution("ERP E 2", "Ecrans >= 9kg et < 15kg", "Ecrans", 2));
// ecos.add(new EcoContribution("ERP E 3", "Ecrans >= 15kg et < 30kg", "Ecrans", 4));
// ecos.add(new EcoContribution("ERP E 4", "Ecrans >= 30kg ", "Ecrans", 8));
// ecos.add(new EcoContribution("ERP GEM F 1", "Froid", "GEM FROID", 13));
// ecos.add(new EcoContribution("ERP GEM HF 1", "GEM < 20 kg", "GEM HORS FROID", 2));
// ecos.add(new EcoContribution("ERP GEM HF 2", "GEM >= 20 kg ", "GEM HORS FROID", 6));
// ecos.add(new EcoContribution("ERP P 1", "PAM < 0.20kg", "PAM", 0.01));
// ecos.add(new EcoContribution("ERP P 10", "PAM >=30 kg", "PAM", 4));
// ecos.add(new EcoContribution("ERP P 2", "PAM >=0.2 kg et < 0.5 kg", "PAM", 0.03));
// ecos.add(new EcoContribution("ERP P 3", "PAM >=0.5kg et < 1.00kg", "PAM", 0.05));
// ecos.add(new EcoContribution("ERP P 4", "PAM >=1 kg et < 2 kg", "PAM", 0.15));
// ecos.add(new EcoContribution("ERP P 5", "PAM >=2 kg et < 4 kg", "PAM", 0.25));
// ecos.add(new EcoContribution("ERP P 6", "PAM >=4 kg et < 8 kg", "PAM", 0.5));
// ecos.add(new EcoContribution("ERP P 7", "PAM >=8 kg et < 15 kg", "PAM", 1));
// ecos.add(new EcoContribution("ERP P 8", "PAM >=15 kg et < 20 kg", "PAM", 1.5));
// ecos.add(new EcoContribution("ERP P 9", "PAM >=20 kg et < 30 kg", "PAM", 2.25));
// ecos.add(new EcoContribution("Récylum 1 ", "Lampes relevant du décret N° 2005-829 du
// 20/07/05", "Lampes", 0.3));
//
// insertValues(ecos, root.getTable("ECO_CONTRIBUTION"));
}
}
 
public void updateEco(final DBRoot root) throws SQLException {
 
List<String> tables = Arrays.asList("AVOIR_CLIENT", "DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE", "COMMANDE", "BON_RECEPTION", "FACTURE_FOURNISSEUR");
 
final SQLTable tableArt = root.getTable("ARTICLE");
 
if (!tableArt.contains("ID_ECO_CONTRIBUTION")) {
AlterTable alter = new AlterTable(tableArt);
alter.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
root.getBase().getDataSource().execute(alter.asString());
root.refetchTable("ARTICLE");
root.getSchema().updateVersion();
 
for (String tableName : tables) {
AlterTable alterTable = new AlterTable(root.getTable(tableName));
alterTable.addLongColumn("T_ECO_CONTRIBUTION", 0L, true);
root.getBase().getDataSource().execute(alterTable.asString());
root.refetchTable(tableName);
root.getSchema().updateVersion();
}
 
for (String tableName : tables) {
AlterTable alterTable = new AlterTable(root.getTable(tableName + "_ELEMENT"));
alterTable.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
alterTable.addDecimalColumn("ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, true);
alterTable.addDecimalColumn("T_ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, true);
root.getBase().getDataSource().execute(alterTable.asString());
root.refetchTable(tableName + "_ELEMENT");
root.getSchema().updateVersion();
}
}
 
// Recheck --> Avoir omis dans 1.5b1
for (String tableName : tables) {
final SQLTable table = root.getTable(tableName);
if (!table.contains("T_ECO_CONTRIBUTION")) {
AlterTable alterTable = new AlterTable(table);
alterTable.addLongColumn("T_ECO_CONTRIBUTION", 0L, true);
root.getBase().getDataSource().execute(alterTable.asString());
root.refetchTable(tableName);
root.getSchema().updateVersion();
}
}
 
for (String tableName : tables) {
final SQLTable table = root.getTable(tableName + "_ELEMENT");
if (!table.contains("T_ECO_CONTRIBUTION")) {
AlterTable alterTable = new AlterTable(table);
alterTable.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
alterTable.addDecimalColumn("ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, true);
alterTable.addDecimalColumn("T_ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, true);
root.getBase().getDataSource().execute(alterTable.asString());
root.refetchTable(tableName + "_ELEMENT");
root.getSchema().updateVersion();
}
}
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/modules/AvailableModulesPanel.java
224,8 → 224,21
JOptionPane.showMessageDialog(panel, "Impossible d'installer le module. Le fichier n'est pas un module.");
return;
}
File dir = new File("Modules");
dir.mkdir();
final File dir = Gestion.MODULES_DIR;
// TODO test symlink in Java 7
if (!dir.isDirectory()) {
if (dir.exists()) {
JOptionPane.showMessageDialog(panel, "Le fichier existe mais n'est pas un dossier : " + dir.getAbsolutePath());
return;
} else {
try {
FileUtils.mkdir_p(dir);
} catch (IOException e) {
JOptionPane.showMessageDialog(panel, "Impossible de créer le dossier des modules : " + dir.getAbsolutePath());
return;
}
}
}
File out = null;
if (dir.canWrite()) {
try {
/trunk/OpenConcerto/src/org/openconcerto/erp/action/AboutAction.java
13,15 → 13,26
package org.openconcerto.erp.action;
 
import org.openconcerto.erp.config.Benchmark;
import org.openconcerto.sql.ui.InfoPanel;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.ReloadPanel;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
 
public final class AboutAction extends AbstractAction {
 
39,8 → 50,13
@Override
public void actionPerformed(final ActionEvent event) {
final JFrame frame = new JFrame((String) this.getValue(Action.NAME));
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
 
final JScrollPane contentPane = new JScrollPane(new InfoPanel());
frame.setContentPane(contentPane);
p.add(contentPane, BorderLayout.CENTER);
p.add(createBenchMarkPanel(), BorderLayout.SOUTH);
frame.setContentPane(p);
frame.pack();
 
final Dimension size = frame.getSize();
62,4 → 78,71
 
frame.setVisible(true);
}
 
private JPanel createBenchMarkPanel() {
final JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.LEFT));
final JLabel lt = new JLabelBold("Test de performance : ");
p.add(lt);
final JLabel l = new JLabel("CLiquez sur démarrer pour lancer le test");
p.add(l);
final JButton b = new JButton("Démarrer");
p.add(b);
final ReloadPanel r = new ReloadPanel();
p.add(r);
b.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
l.setText("Test en cours");
b.setEnabled(false);
r.setMode(ReloadPanel.MODE_ROTATE);
SwingWorker<String, String> s = new SwingWorker<String, String>() {
 
@Override
protected String doInBackground() throws Exception {
Benchmark bench = new Benchmark();
String s = "";
s += "Base de données : " + bench.testDB();
final String s1 = s;
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
l.setText(s1);
 
}
});
s += " - Processeur : " + bench.testCPU();
final String s2 = s;
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
l.setText(s2);
 
}
});
s += " - Disque dur : " + bench.testWriteHD();
return s;
}
 
protected void done() {
b.setEnabled(true);
try {
String result = get();
l.setText(result);
r.setMode(ReloadPanel.MODE_EMPTY);
} catch (Exception e) {
r.setMode(ReloadPanel.MODE_BLINK);
e.printStackTrace();
}
};
};
s.execute();
 
}
});
return p;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/action/NouvelleConnexionAction.java
248,8 → 248,10
// don't close ConnexionPanel until the main frame is shown
showMainFrame.get();
} catch (Throwable e) {
if (e.getMessage() != null && e.getMessage().contains("TR_BON_DE_LIVRAISON not found")) {
JOptionPane.showMessageDialog(new JFrame(), "Votre base de données n'est pas à jour.\nUtilisez l'outil de configuration et pensez à l'achat du manuel!!!");
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"))) {
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;
}
ExceptionHandler.handle("Erreur de connexion", e);
306,6 → 308,7
Ville.init(new NXDatabaseAccessor(comptaConf), prefs.getBoolean(GestionClientPreferencePanel.LOAD_CITIES, true));
 
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("TAXE"), 600);
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("ETAT_DEVIS"), 600);
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("PREFS_COMPTE"), 600);
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("COMPTE_PCE"), 600);
SQLBackgroundTableCache.getInstance().add(baseSociete.getTable("JOURNAL"), 600);
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateListFrameAbstractAction.java
58,7 → 58,7
 
// Create frame
final LightUIFrame frame = new LightUIFrame(elementCode);
frame.setTitle(frameTitle);
frame.createTitlePanel(frameTitle);
 
// Create table
final String tableId = element.getCode() + ".table";
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeBrEltSQLInjector.java
New file
0,0 → 1,27
/*
* 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 CommandeBrEltSQLInjector extends SQLInjector {
public CommandeBrEltSQLInjector(final DBRoot root) {
super(root, "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", false);
createDefaultMap();
if (getDestination().contains("ID_COMMANDE_ELEMENT")) {
map(getSource().getKey(), getDestination().getField("ID_COMMANDE_ELEMENT"));
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/DevisFactureSQLInjector.java
13,6 → 13,7
package org.openconcerto.erp.injector;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRowAccessor;
22,11 → 23,14
import java.math.BigDecimal;
import java.util.Collection;
 
import com.ibm.icu.util.Calendar;
 
public class DevisFactureSQLInjector extends SQLInjector {
public DevisFactureSQLInjector(final DBRoot root) {
super(root, "DEVIS", "SAISIE_VENTE_FACTURE", true);
final SQLTable tableDevis = getSource();
final SQLTable tableFacture = getDestination();
 
map(tableDevis.getField("PORT_HT"), tableFacture.getField("PORT_HT"));
map(tableDevis.getField("REMISE_HT"), tableFacture.getField("REMISE_HT"));
map(tableDevis.getField("ID_CLIENT"), tableFacture.getField("ID_CLIENT"));
61,6 → 65,7
protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
super.merge(srcRow, rowVals);
 
 
// Merge elements
final SQLTable tableElementSource = getSource().getTable("DEVIS_ELEMENT");
final SQLTable tableElementDestination = getSource().getTable("SAISIE_VENTE_FACTURE_ELEMENT");
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/BonFactureSQLInjector.java
40,6 → 40,12
if (getSource().getTable().contains("ID_CLIENT_DEPARTEMENT")) {
map(getSource().getField("ID_CLIENT_DEPARTEMENT"), getDestination().getField("ID_CLIENT_DEPARTEMENT"));
}
if (getSource().getTable().contains("ID_ADRESSE") && getDestination().contains("ID_ADRESSE")) {
map(getSource().getField("ID_ADRESSE"), getDestination().getField("ID_ADRESSE"));
}
if (getSource().getTable().contains("ID_ADRESSE_LIVRAISON")) {
map(getSource().getField("ID_ADRESSE_LIVRAISON"), getDestination().getField("ID_ADRESSE_LIVRAISON"));
}
if (tableBon.contains("ID_TAXE_PORT")) {
map(tableBon.getField("ID_TAXE_PORT"), tableFacture.getField("ID_TAXE_PORT"));
}
52,8 → 58,10
if (getSource().getTable().contains("ID_TARIF") && getDestination().getTable().contains("ID_TARIF")) {
map(getSource().getField("ID_TARIF"), getDestination().getField("ID_TARIF"));
}
 
if (getSource().getTable().contains("ACOMPTE_COMMANDE")) {
map(getSource().getField("ACOMPTE_COMMANDE"), getDestination().getField("ACOMPTE_COMMANDE"));
}
}
 
@Override
protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/DevisBlSQLInjector.java
39,7 → 39,13
if (getSource().getTable().contains("ID_CLIENT_DEPARTEMENT")) {
map(getSource().getField("ID_CLIENT_DEPARTEMENT"), getDestination().getField("ID_CLIENT_DEPARTEMENT"));
}
if (getSource().getTable().contains("ID_ADRESSE") && getDestination().contains("ID_ADRESSE")) {
map(getSource().getField("ID_ADRESSE"), getDestination().getField("ID_ADRESSE"));
}
if (getSource().getTable().contains("ID_ADRESSE_LIVRAISON")) {
map(getSource().getField("ID_ADRESSE_LIVRAISON"), getDestination().getField("ID_ADRESSE_LIVRAISON"));
}
}
 
@Override
protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeFactureClientSQLInjector.java
28,6 → 28,7
final SQLTable tableCommande = getSource();
final SQLTable tableFacture = getDestination();
map(tableCommande.getField("ID_CLIENT"), tableFacture.getField("ID_CLIENT"));
map(tableCommande.getField("ID_COMMERCIAL"), tableFacture.getField("ID_COMMERCIAL"));
if (tableCommande.contains("ID_TAXE_PORT")) {
map(tableCommande.getField("ID_TAXE_PORT"), tableFacture.getField("ID_TAXE_PORT"));
}
34,6 → 35,9
if (tableCommande.contains("PORT_HT")) {
map(tableCommande.getField("PORT_HT"), tableFacture.getField("PORT_HT"));
}
if (tableCommande.contains("ACOMPTE_COMMANDE")) {
map(tableCommande.getField("ACOMPTE_COMMANDE"), tableFacture.getField("ACOMPTE_COMMANDE"));
}
if (tableCommande.contains("REMISE_HT")) {
map(tableCommande.getField("REMISE_HT"), tableFacture.getField("REMISE_HT"));
}
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/BonFactureEltSQLInjector.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.injector;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInjector;
 
public class BonFactureEltSQLInjector extends SQLInjector {
public BonFactureEltSQLInjector(final DBRoot root) {
super(root, "BON_DE_LIVRAISON_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", false);
createDefaultMap();
remove(getSource().getField("QTE"), getDestination().getField("QTE"));
map(getSource().getField("QTE_LIVREE"), getDestination().getField("QTE"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeBlSQLInjector.java
41,6 → 41,9
if (getSource().getTable().contains("ID_TARIF") && getDestination().getTable().contains("ID_TARIF")) {
map(getSource().getField("ID_TARIF"), getDestination().getField("ID_TARIF"));
}
if (tableBl.contains("ACOMPTE_COMMANDE")) {
map(getSource().getField("ACOMPTE_COMMANDE"), getDestination().getField("ACOMPTE_COMMANDE"));
}
if (tableBl.contains("CREATE_VIRTUAL_STOCK")) {
mapDefaultValues(tableBl.getField("CREATE_VIRTUAL_STOCK"), Boolean.FALSE);
}
54,7 → 57,13
if (tableBl.contains("REMISE_HT")) {
map(tableCmd.getField("REMISE_HT"), tableBl.getField("REMISE_HT"));
}
if (getSource().getTable().contains("ID_ADRESSE") && getDestination().contains("ID_ADRESSE")) {
map(getSource().getField("ID_ADRESSE"), getDestination().getField("ID_ADRESSE"));
}
if (getSource().getTable().contains("ID_ADRESSE_LIVRAISON")) {
map(getSource().getField("ID_ADRESSE_LIVRAISON"), getDestination().getField("ID_ADRESSE_LIVRAISON"));
}
}
 
@Override
protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeFactureEltSQLInjector.java
New file
0,0 → 1,27
/*
* 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 CommandeFactureEltSQLInjector extends SQLInjector {
public CommandeFactureEltSQLInjector(final DBRoot root) {
super(root, "COMMANDE_CLIENT_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", false);
createDefaultMap();
if (getDestination().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
map(getSource().getKey(), getDestination().getField("ID_COMMANDE_CLIENT_ELEMENT"));
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeBlEltSQLInjector.java
21,5 → 21,8
super(root, "COMMANDE_CLIENT_ELEMENT", "BON_DE_LIVRAISON_ELEMENT", false);
createDefaultMap();
mapDefaultValues(getDestination().getField("QTE_LIVREE"), Integer.valueOf(0));
if (getDestination().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
map(getSource().getKey(), getDestination().getField("ID_COMMANDE_CLIENT_ELEMENT"));
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLField.java
238,6 → 238,7
String prefix = this.elt.getAttributeValue("prefix");
String suffix = this.elt.getAttributeValue("suffix");
String display = this.elt.getAttributeValue("display");
// FIXME attribut cellSize à mettre sur l'element
String cellSize = this.elt.getAttributeValue("cellSize");
if (prefix != null || suffix != null) {
 
346,8 → 347,19
}
} else if (typeComp.equalsIgnoreCase("cumulPaye")) {
double val = ((Number) result).doubleValue();
double valC = ((Number) this.row.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
double valC;
if (this.row.getTable().getFieldsName().contains("ID_CUMULS_PAYE")) {
valC = ((Number) this.row.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
} else {
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
valC = ((Number) refRow.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
}
return new Double(val + valC);
} else if (typeComp.equalsIgnoreCase("cumulConges")) {
double val = ((Number) result).doubleValue();
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
double valC = ((Number) refRow.getObject("CONGES_ACQUIS")).doubleValue();
return new Double(val + valC);
} else if (typeComp.equalsIgnoreCase("globalAcompte")) {
Long prix = (Long) result;
int pourcent = this.row.getInt("POURCENT_ACOMPTE");
645,25 → 657,15
Nombre n1 = new Nombre(entier.intValue(), langue);
Nombre n2 = new Nombre(decimal.intValue(), langue);
 
// result.append(n1.getText() + " euros");
// 2.51 -> deux euros et cinquante et un centimes
result.append(n1.getText() + " " + deviseName.get0().trim());
 
if (decimal.intValue() > 0)
 
{
// result.append(" et " + n2.getText() + " cents");
result.append(" " + n1.getLocal().getSeparateurLabel() + " " + n2.getText() + deviseName.get1());
if (decimal.intValue() > 0) {
result.append(" " + n1.getSeparateurLabel() + " " + n2.getText() + deviseName.get1());
}
if (result != null && result.length() > 0)
 
{
if (result != null && result.length() > 0) {
return result.toString().replaceFirst(String.valueOf(result.charAt(0)), String.valueOf(result.charAt(0)).toUpperCase());
} else
 
{
return result.toString();
}
 
return "";
}
 
private static BigDecimal calcul(Object o1, Object o2, String op) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/PaiementRemainedProvider.java
19,6 → 19,7
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collection;
 
public class PaiementRemainedProvider implements SpreadSheetCellValueProvider {
54,6 → 55,12
totalEch += row.getLong("MONTANT");
}
}
if (r.getTable().contains("ACOMPTE_COMMANDE") && r.getBigDecimal("ACOMPTE_COMMANDE") != null) {
long totalAcompte = r.getBigDecimal("ACOMPTE_COMMANDE").movePointRight(2).setScale(0, RoundingMode.HALF_UP).longValue();
if (totalEch > totalAcompte) {
totalEch -= totalAcompte;
}
}
 
long total = totalEch;
if (t == Type.DONE) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/DateProvider.java
New file
0,0 → 1,50
/*
* 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.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
 
import java.util.Date;
 
public class DateProvider extends UserInitialsValueProvider {
 
private enum TypeDateProvider {
TODAY, CREATION, MODIFICATION
};
 
private final TypeDateProvider type;
 
public DateProvider(TypeDateProvider t) {
this.type = t;
}
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
 
if (this.type == TypeDateProvider.CREATION) {
return context.getRow().getCreationDate().getTime();
} else if (this.type == TypeDateProvider.MODIFICATION) {
return context.getRow().getModificationDate().getTime();
} else {
return new Date();
}
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("date.today", new DateProvider(TypeDateProvider.TODAY));
SpreadSheetCellValueProviderManager.put("date.creation", new DateProvider(TypeDateProvider.CREATION));
SpreadSheetCellValueProviderManager.put("date.modification", new DateProvider(TypeDateProvider.MODIFICATION));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/RestantAReglerProvider.java
16,14 → 16,34
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.erp.generationDoc.provider.TotalAcompteProvider.TypeTotalAcompteProvider;
import org.openconcerto.erp.generationDoc.provider.TotalCommandeClientProvider.TypeTotalCommandeClientProvider;
 
import java.math.BigDecimal;
 
public class RestantAReglerProvider implements SpreadSheetCellValueProvider {
 
TotalAcompteProvider acompteProv = new TotalAcompteProvider();
TotalCommandeClientProvider cmdProvider = new TotalCommandeClientProvider();
final TotalAcompteProvider acompteProv;
final TotalCommandeClientProvider cmdProvider;
 
private enum TypeRestantAReglerProvider {
HT, TTC;
};
 
private final TypeRestantAReglerProvider type;
 
public RestantAReglerProvider(TypeRestantAReglerProvider t) {
this.type = t;
if (this.type == TypeRestantAReglerProvider.HT) {
acompteProv = new TotalAcompteProvider(TypeTotalAcompteProvider.HT);
cmdProvider = new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.HT);
} else {
acompteProv = new TotalAcompteProvider(TypeTotalAcompteProvider.TTC);
cmdProvider = new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TTC);
}
 
}
 
public Object getValue(SpreadSheetCellValueContext context) {
Object acompte = acompteProv.getValue(context);
Object cmd = cmdProvider.getValue(context);
35,7 → 55,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.due", new RestantAReglerProvider());
SpreadSheetCellValueProviderManager.put("sales.account.due", new RestantAReglerProvider(TypeRestantAReglerProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.due.ttc", new RestantAReglerProvider(TypeRestantAReglerProvider.TTC));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/TotalCommandeClientProvider.java
23,6 → 23,16
 
public class TotalCommandeClientProvider implements SpreadSheetCellValueProvider {
 
public enum TypeTotalCommandeClientProvider {
HT, TTC;
};
 
private final TypeTotalCommandeClientProvider type;
 
public TotalCommandeClientProvider(TypeTotalCommandeClientProvider t) {
this.type = t;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Collection<? extends SQLRowAccessor> rows = row.getReferentRows(row.getTable().getTable("TR_COMMANDE_CLIENT"));
30,7 → 40,7
for (SQLRowAccessor sqlRowAccessor : rows) {
if (!sqlRowAccessor.isForeignEmpty("ID_COMMANDE_CLIENT")) {
SQLRowAccessor rowCmd = sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT");
total += rowCmd.getLong("T_HT");
total += (this.type == TypeTotalCommandeClientProvider.HT ? rowCmd.getLong("T_HT") : rowCmd.getLong("T_TTC"));
}
}
return new BigDecimal(total).movePointLeft(2);
37,7 → 47,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider());
SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.command.total.ttc", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TTC));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/RemiseTotalProvider.java
17,7 → 17,6
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
25,6 → 24,16
 
public class RemiseTotalProvider extends UserInitialsValueProvider {
 
private enum TypeRemiseTotalProvider {
TTC, HT
};
 
private final TypeRemiseTotalProvider type;
 
public RemiseTotalProvider(TypeRemiseTotalProvider t) {
this.type = t;
}
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
34,25 → 43,38
BigDecimal total = BigDecimal.ZERO;
for (SQLRowAccessor sqlRowAccessor : cols) {
 
final BigDecimal montant = sqlRowAccessor.getBigDecimal("MONTANT_REMISE");
BigDecimal remise = (BigDecimal) sqlRowAccessor.getObject("POURCENT_REMISE");
if (!sqlRowAccessor.getTable().contains("NIVEAU") || sqlRowAccessor.getInt("NIVEAU") == 1) {
 
if (montant != null) {
total = total.add(montant.setScale(2, RoundingMode.HALF_UP));
} else if (remise != null && remise.signum() != 0) {
final BigDecimal subtract = BigDecimal.ONE.subtract(remise.movePointLeft(2));
if (subtract.signum() == 0) {
total = total.add(sqlRowAccessor.getBigDecimal("PV_HT").multiply(sqlRowAccessor.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowAccessor.getInt("QTE")))));
} else {
total = total.add((sqlRowAccessor.getBigDecimal("T_PV_HT").divide(subtract, DecimalUtils.HIGH_PRECISION)).subtract(sqlRowAccessor.getBigDecimal("T_PV_HT")).setScale(2,
RoundingMode.HALF_UP));
BigDecimal lineDiscount = BigDecimal.ZERO;
lineDiscount = sqlRowAccessor.getBigDecimal("PV_HT").multiply(sqlRowAccessor.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowAccessor.getInt("QTE"))));
 
if (this.type == TypeRemiseTotalProvider.TTC) {
if (sqlRowAccessor.getForeign("ID_TAXE") != null && !sqlRowAccessor.isForeignEmpty("ID_TAXE")) {
BigDecimal vat = new BigDecimal(sqlRowAccessor.getForeign("ID_TAXE").getFloat("TAUX")).movePointLeft(2).add(BigDecimal.ONE);
lineDiscount = lineDiscount.multiply(vat).setScale(2, RoundingMode.HALF_UP);
}
}
 
total = total.add(lineDiscount);
 
}
return total;
}
 
String prefix = "MONTANT_";
if (row.getTable().contains("T_HT")) {
prefix = "T_";
}
 
if (this.type == TypeRemiseTotalProvider.TTC) {
total = new BigDecimal(row.getLong(prefix + "TTC")).movePointLeft(2).subtract(total);
} else {
total = new BigDecimal(row.getLong(prefix + "HT")).movePointLeft(2).subtract(total);
}
return total.abs();
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.discount.total", new RemiseTotalProvider());
SpreadSheetCellValueProviderManager.put("sales.discount.total", new RemiseTotalProvider(TypeRemiseTotalProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.discount.total.ttc", new RemiseTotalProvider(TypeRemiseTotalProvider.TTC));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/TotalAcompteProvider.java
26,6 → 26,16
 
public class TotalAcompteProvider implements SpreadSheetCellValueProvider {
 
public enum TypeTotalAcompteProvider {
HT, TTC;
};
 
private final TypeTotalAcompteProvider type;
 
public TotalAcompteProvider(TypeTotalAcompteProvider t) {
this.type = t;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Calendar c = row.getDate("DATE");
42,7 → 52,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.total", new TotalAcompteProvider());
SpreadSheetCellValueProviderManager.put("sales.account.total", new TotalAcompteProvider(TypeTotalAcompteProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.total.ttc", new TotalAcompteProvider(TypeTotalAcompteProvider.TTC));
}
 
public long getPreviousAcompte(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded, Calendar c) {
56,7 → 67,7
 
if (rowFact != null && !rowFact.isUndefined() && !alreadyAdded.contains(rowFact) && rowFact.getDate("DATE").before(c)) {
alreadyAdded.add(rowFact);
l += rowFact.getLong("T_HT");
l += this.type == TypeTotalAcompteProvider.HT ? rowFact.getLong("T_HT") : rowFact.getLong("T_TTC");
}
}
return l;
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/SaledTotalNotDiscountedProvider.java
41,7 → 41,7
}
}
if (table.contains("PORT_HT")) {
total.add(new BigDecimal(row.getLong("PORT_HT")).movePointLeft(2));
total = total.add(new BigDecimal(row.getLong("PORT_HT")).movePointLeft(2));
}
return total;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/RecapFactureProvider.java
19,7 → 19,6
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.utils.GestionDevise;
 
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
27,6 → 26,16
 
public class RecapFactureProvider implements SpreadSheetCellValueProvider {
 
private enum TypeRecapFactureProvider {
HT, TTC;
};
 
private final TypeRecapFactureProvider type;
 
public RecapFactureProvider(TypeRecapFactureProvider t) {
this.type = t;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Calendar c = row.getDate("DATE");
46,7 → 55,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.history", new RecapFactureProvider());
SpreadSheetCellValueProviderManager.put("sales.account.history", new RecapFactureProvider(TypeRecapFactureProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.history.ttc", new RecapFactureProvider(TypeRecapFactureProvider.TTC));
}
 
public String getPreviousAcompte(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded, Calendar c) {
60,7 → 70,8
 
if (rowFact != null && !rowFact.isUndefined() && !alreadyAdded.contains(rowFact) && rowFact.getDate("DATE").before(c)) {
alreadyAdded.add(rowFact);
result.append(rowFact.getString("NUMERO") + " (" + GestionDevise.currencyToString(rowFact.getLong("T_HT")) + "€), ");
final String fieldTotal = this.type == TypeRecapFactureProvider.HT ? "T_HT" : "T_TTC";
result.append(rowFact.getString("NUMERO") + " (" + GestionDevise.currencyToString(rowFact.getLong(fieldTotal)) + "€), ");
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/AdresseFullClientValueProvider.java
34,46 → 34,59
if (this.withName) {
result = context.getRow().getForeign("ID_CLIENT").getString("NOM") + "\n";
}
if (r.getString("LIBELLE").trim().length() > 0) {
result = r.getString("LIBELLE") + "\n";
result = getFormattedAddress(r, result);
 
return result;
}
if (r.getString("DEST").trim().length() > 0) {
result = r.getString("DEST") + "\n";
 
public static String getFormattedAddress(final SQLRowAccessor rAddress, String prefix) {
String result = prefix;
if (getStringTrimmed(rAddress, "LIBELLE").length() > 0) {
result = getStringTrimmed(rAddress, "LIBELLE") + "\n";
}
if (r.getString("RUE").trim().length() > 0) {
result += r.getString("RUE") + "\n";
if (getStringTrimmed(rAddress, "DEST").length() > 0) {
result = getStringTrimmed(rAddress, "DEST") + "\n";
}
result += "\n" + r.getString("CODE_POSTAL");
if (getStringTrimmed(rAddress, "RUE").length() > 0) {
result += getStringTrimmed(rAddress, "RUE") + "\n";
}
result += "\n" + getStringTrimmed(rAddress, "CODE_POSTAL");
result += " ";
if (r.getTable().contains("DISTRICT")) {
result += r.getString("DISTRICT") + " ";
if (rAddress.getTable().contains("DISTRICT")) {
result += getStringTrimmed(rAddress, "DISTRICT") + " ";
}
result += r.getString("VILLE");
if (r.getBoolean("HAS_CEDEX")) {
result += getStringTrimmed(rAddress, "VILLE");
if (rAddress.getBoolean("HAS_CEDEX")) {
result += " Cedex";
String cedex = r.getString("CEDEX");
if (cedex != null && cedex.trim().length() > 0) {
String cedex = getStringTrimmed(rAddress, "CEDEX");
if (cedex.length() > 0) {
result += " " + cedex;
}
}
if (r.getTable().contains("PROVINCE")) {
if (rAddress.getTable().contains("PROVINCE")) {
result += "\n";
if (r.getString("PROVINCE").trim().length() > 0) {
result += r.getString("PROVINCE") + " ";
if (getStringTrimmed(rAddress, "PROVINCE").length() > 0) {
result += getStringTrimmed(rAddress, ("PROVINCE")) + " ";
}
 
if (r.getTable().contains("DEPARTEMENT")) {
result += r.getString("DEPARTEMENT");
if (rAddress.getTable().contains("DEPARTEMENT")) {
result += getStringTrimmed(rAddress, "DEPARTEMENT");
}
}
 
if (r.getString("PAYS").trim().length() > 0) {
result += "\n" + r.getString("PAYS");
if (getStringTrimmed(rAddress, "PAYS").length() > 0) {
result += "\n" + getStringTrimmed(rAddress, "PAYS");
}
 
return result;
}
 
public static String getStringTrimmed(SQLRowAccessor r, String field) {
String result = r.getString(field);
if (result == null)
return "";
return result.trim();
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("address.customer.full", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, false));
SpreadSheetCellValueProviderManager.put("address.customer.invoice.full", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, false));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationListeColumnXML.java
200,17 → 200,17
// 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 endPageLine = Integer.valueOf(tableau.getAttributeValue("endPageLine"));
int endLine = Integer.valueOf(tableau.getAttributeValue("endLine"));
 
List listElts = tableau.getChildren("element");
 
Object o = null;
String columnSousTotal = tableau.getAttributeValue("groupSousTotalColumn");
// String columnSousTotal = tableau.getAttributeValue("groupSousTotalColumn");
//
// Map<String, Double> mapSousTotal = new HashMap<String, Double>();
// Map<String, Double> mapTotal = new HashMap<String, Double>();
 
Map<String, Double> mapSousTotal = new HashMap<String, Double>();
Map<String, Double> mapTotal = new HashMap<String, Double>();
 
// on remplit chaque colonnes à partir des rows recuperées
sheet.setColumnCount(liste.size() + 5);
Integer firstCol = Integer.valueOf(tableau.getAttributeValue("firstLine"));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/ReleveChequeSheet.java
32,7 → 32,7
public class ReleveChequeSheet extends AbstractListeSheetXml {
 
private List<Map<String, Object>> listValues;
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
private Date date;
private long total = 0;
private long nb = 0;
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/ReportingEcoContributionSheetXML.java
New file
0,0 → 1,185
/*
* 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.
*/
/*
* Créé le 19 nov. 2012
*/
package org.openconcerto.erp.generationDoc.gestcomm;
 
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.cc.ITransformer;
 
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class ReportingEcoContributionSheetXML extends AbstractListeSheetXml {
 
public static final String TEMPLATE_ID = "ReportingEcoContribution";
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME;
 
private Date dateD, dateF;
 
public ReportingEcoContributionSheetXML(Date debut, Date fin) {
super();
 
this.dateD = debut;
this.dateF = fin;
 
}
 
@Override
public String getStoragePathP() {
return "Autres";
}
 
@Override
public String getDefaultTemplateId() {
return TEMPLATE_ID;
};
 
@Override
public String getName() {
return "ReportingBA";
}
 
@Override
protected void createListeValues() {
 
this.mapAllSheetValues = new HashMap<Integer, Map<String, Object>>();
this.listAllSheetValues = new HashMap<Integer, List<Map<String, Object>>>();
this.styleAllSheetValues = new HashMap<Integer, Map<Integer, String>>();
 
fillSynthese();
 
}
 
private static SQLTable tableVF = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE").getTable();
 
class EcoContribRecap {
private final String code, nom;
private BigDecimal totalEco, qte;
 
public EcoContribRecap(String code, String nom) {
this.code = code;
this.nom = nom;
this.qte = BigDecimal.ZERO;
this.totalEco = BigDecimal.ZERO;
}
 
public void cumul(BigDecimal qte, BigDecimal total) {
this.qte = qte.add(this.qte);
this.totalEco = total.add(this.totalEco);
}
 
public String getCode() {
return code;
}
 
public String getNom() {
return nom;
}
 
public BigDecimal getQte() {
return qte;
}
 
public BigDecimal getTotalEco() {
return totalEco;
}
}
 
private void fillSynthese() {
final SQLTable tableVF = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE");
final SQLTable tableVFElt = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
 
SQLRowValues rowvalsVF = new SQLRowValues(tableVF);
rowvalsVF.put("NUMERO", null);
rowvalsVF.put("DATE", null);
 
SQLRowValues rowvalsVFElt = new SQLRowValues(tableVFElt);
rowvalsVFElt.put("ID_SAISIE_VENTE_FACTURE", rowvalsVF);
rowvalsVFElt.put("T_ECO_CONTRIBUTION", null);
rowvalsVFElt.put("QTE", null);
rowvalsVFElt.put("QTE_UNITAIRE", null);
rowvalsVFElt.putRowValues("ID_ECO_CONTRIBUTION").putNulls("CODE", "NOM");
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowvalsVFElt);
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(input.getAlias(tableVF).getField("DATE"), dateD, dateF);
w = w.and(new Where(tableVFElt.getField("T_ECO_CONTRIBUTION"), ">", BigDecimal.ZERO));
input.setWhere(w);
return input;
}
});
 
Map<Integer, EcoContribRecap> recap = new HashMap<Integer, ReportingEcoContributionSheetXML.EcoContribRecap>();
List<SQLRowValues> results = fetcher.fetch();
for (SQLRowValues sqlRowValues : results) {
EcoContribRecap r;
if (recap.containsKey(sqlRowValues.getForeignID("ID_ECO_CONTRIBUTION"))) {
r = recap.get(sqlRowValues.getForeignID("ID_ECO_CONTRIBUTION"));
} else {
SQLRowAccessor rEco = sqlRowValues.getForeign("ID_ECO_CONTRIBUTION");
r = new EcoContribRecap(rEco.getString("CODE"), rEco.getString("NOM"));
recap.put(sqlRowValues.getForeignID("ID_ECO_CONTRIBUTION"), r);
}
r.cumul(sqlRowValues.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowValues.getInt("QTE"))), sqlRowValues.getBigDecimal("T_ECO_CONTRIBUTION"));
}
 
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
this.listAllSheetValues.put(0, values);
Map<Integer, String> style = new HashMap<Integer, String>();
this.styleAllSheetValues.put(0, style);
 
BigDecimal total = BigDecimal.ZERO;
BigDecimal qteTotal = BigDecimal.ZERO;
 
for (EcoContribRecap item : recap.values()) {
Map<String, Object> vals = new HashMap<String, Object>();
 
vals.put("CODE", item.getCode());
vals.put("NOM", item.getNom());
vals.put("QTE", item.getQte());
vals.put("TOTAL_ECO", item.getTotalEco());
style.put(values.size(), "Normal");
total = total.add(item.getTotalEco());
qteTotal = qteTotal.add(item.getQte());
values.add(vals);
}
 
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Map<String, Object> vals = new HashMap<String, Object>();
vals.put("DATE_DEB", this.dateD);
vals.put("DATE_FIN", this.dateF);
vals.put("PERIODE", "Période du " + format.format(this.dateD) + " au " + format.format(this.dateF));
vals.put("TOTAL", total);
vals.put("TOTAL_QTE", qteTotal);
this.mapAllSheetValues.put(0, vals);
// style.put(values.size(), "Titre 1");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/JournalPaieXmlSheet.java
37,7 → 37,7
*/
public class JournalPaieXmlSheet extends AbstractListeSheetXml {
 
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yy");
private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yy");
 
public static final String TEMPLATE_ID = "JournalPaie";
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/EtatVentesXmlSheet.java
13,6 → 13,8
package org.openconcerto.erp.generationDoc.gestcomm;
 
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.sql.Configuration;
20,6 → 22,8
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.AliasedField;
import org.openconcerto.sql.model.AliasedTable;
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;
32,8 → 36,10
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
152,6 → 158,8
selQte.addSelect(tableFactureElement.getField("T_PA_HT"), "SUM");
selQte.addSelect(tableFactureElement.getField("T_PV_HT"), "SUM");
selQte.addSelect(tableFactureElement.getField("T_PV_TTC"), "SUM");
selQte.addSelect(tableFactureElement.getField("ID_TAXE"));
selQte.addSelect(tableFactureElement.getField("ID_ARTICLE"));
selQte.addJoin("LEFT", tableFactureElement.getField("ID_SAISIE_VENTE_FACTURE")).setWhere(w);
selQte.addJoin("LEFT", tableFactureElement.getField("ID_TICKET_CAISSE"), "ticket").setWhere(w2);
if (this.du != null && this.au != null) {
159,6 → 167,8
}
selQte.addGroupBy(tableFactureElement.getField("NOM"));
selQte.addGroupBy(tableFactureElement.getField("CODE"));
selQte.addGroupBy(tableFactureElement.getField("ID_TAXE"));
selQte.addGroupBy(tableFactureElement.getField("ID_ARTICLE"));
 
List<Object[]> listeQte = (List<Object[]>) Configuration.getInstance().getBase().getDataSource().execute(selQte.asString(), new ArrayListHandler());
 
171,7 → 181,10
Number ha = (Number) sqlRow[3];
Number ht = (Number) sqlRow[4];
Number ttc = (Number) sqlRow[5];
ArticleVendu a = new ArticleVendu(code, nom, qteVendu.intValue(), (BigDecimal) ht, (BigDecimal) ha, (BigDecimal) ttc);
Number tvaID = (Number) sqlRow[6];
Number articleID = (Number) sqlRow[7];
ArticleVendu a = new ArticleVendu(code, nom, qteVendu.intValue(), (BigDecimal) ht, (BigDecimal) ha, (BigDecimal) ttc, tvaID.intValue(),
tableFactureElement.getForeignTable("ID_ARTICLE").getRow(articleID.intValue()));
map.put(code + "##" + nom, a);
}
 
199,6 → 212,8
mValues.put("QTE", a.qte);
mValues.put("T_PA", a.ha);
mValues.put("T_PV_HT", a.ht);
mValues.put("TVA_TAUX", a.tva);
mValues.put("NUMERO_COMPTE", a.numeroCompte);
mValues.put("T_PV_TTC", a.ttc);
mValues.put("NB_CHEQUE", obj[2]);
mValues.put("NB_CB", obj[3]);
372,12 → 387,36
 
}
 
public static SQLRow rowDefaultCptService, rowDefaultCptProduit;
static {
final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
rowDefaultCptService = rowPrefsCompte.getForeign("ID_COMPTE_PCE_VENTE_SERVICE");
if (rowDefaultCptService == null || rowDefaultCptService.isUndefined()) {
try {
rowDefaultCptService = ComptePCESQLElement.getRowComptePceDefault("VentesServices");
} catch (Exception e) {
e.printStackTrace();
}
}
 
rowDefaultCptProduit = rowPrefsCompte.getForeign("ID_COMPTE_PCE_VENTE_PRODUIT");
if (rowDefaultCptProduit == null || rowDefaultCptProduit.isUndefined()) {
try {
rowDefaultCptProduit = ComptePCESQLElement.getRowComptePceDefault("VentesProduits");
} catch (Exception e) {
e.printStackTrace();
}
}
}
 
class ArticleVendu {
public String code, nom;
public int qte;
public BigDecimal ht, ha, ttc;
public int qte, tvaID;
public BigDecimal ht, ha, ttc, tva;
public String numeroCompte;
 
public ArticleVendu(String code, String nom, int qte, BigDecimal ht, BigDecimal ha, BigDecimal ttc) {
public ArticleVendu(String code, String nom, int qte, BigDecimal ht, BigDecimal ha, BigDecimal ttc, int tvaID, SQLRow rowArticle) {
this.code = code;
this.nom = nom;
this.qte = qte;
384,6 → 423,51
this.ht = ht;
this.ha = ha;
this.ttc = ttc;
this.tvaID = tvaID;
this.tva = new BigDecimal(TaxeCache.getCache().getTauxFromId(tvaID));
 
SQLRowAccessor rowTVA = TaxeCache.getCache().getRowFromId(tvaID);
boolean service = rowArticle.getBoolean("SERVICE");
SQLRowAccessor rowCpt;
// Total Service
if (service) {
rowCpt = rowDefaultCptService;
if (rowTVA != null && !rowTVA.isForeignEmpty("ID_COMPTE_PCE_VENTE_SERVICE")) {
rowCpt = rowTVA.getForeign("ID_COMPTE_PCE_VENTE_SERVICE");
}
} else {
rowCpt = rowDefaultCptProduit;
// Compte defini par défaut dans la TVA
if (rowTVA != null && !rowTVA.isForeignEmpty("ID_COMPTE_PCE_VENTE")) {
rowCpt = rowTVA.getForeign("ID_COMPTE_PCE_VENTE");
}
 
}
 
if (rowArticle != null && !rowArticle.isUndefined()) {
SQLRowAccessor compteArticle = rowArticle.getForeign("ID_COMPTE_PCE");
if (compteArticle != null && !compteArticle.isUndefined()) {
rowCpt = compteArticle;
} else {
SQLRowAccessor familleArticle = rowArticle.getForeign("ID_FAMILLE_ARTICLE");
Set<SQLRowAccessor> unique = new HashSet<SQLRowAccessor>();
while (familleArticle != null && !familleArticle.isUndefined() && !unique.contains(familleArticle)) {
 
unique.add(familleArticle);
SQLRowAccessor compteFamilleArticle = familleArticle.getForeign("ID_COMPTE_PCE");
if (compteFamilleArticle != null && !compteFamilleArticle.isUndefined()) {
rowCpt = compteFamilleArticle;
break;
}
 
familleArticle = familleArticle.getForeign("ID_FAMILLE_ARTICLE_PERE");
}
}
}
if (rowCpt != null) {
 
this.numeroCompte = rowCpt.getString("NUMERO");
}
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/FicheRelanceSheet.java
28,7 → 28,7
 
public class FicheRelanceSheet extends AbstractListeSheetXml {
 
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
public static final String TEMPLATE_ID = "FicheRelance";
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationXML.java
16,6 → 16,10
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Log;
import org.openconcerto.erp.core.common.element.StyleSQLElement;
import org.openconcerto.erp.core.common.ui.TotalCalculator;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.openoffice.ODPackage;
import org.openconcerto.openoffice.spreadsheet.MutableCell;
import org.openconcerto.openoffice.spreadsheet.Sheet;
25,10 → 29,11
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.StreamUtils;
import org.openconcerto.utils.Tuple2;
 
import java.awt.Point;
import java.io.File;
37,6 → 42,7
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
122,7 → 128,6
}
}
 
Date d = new Date();
SAXBuilder builder = new SAXBuilder();
try {
 
236,7 → 241,7
Map<String, Map<Integer, String>> mapStyle = searchStyle(sheet, lastColumn, endPageLine);
 
if (tableau.getAttributeValue("table").equalsIgnoreCase("TVA")) {
fillTaxe(tableau, sheet, mapStyle, false);
fillTaxeDocumentMap(tableau, sheet, mapStyle, false);
return;
}
int nbPage = fillTable(tableau, row, sheet, mapStyle, true, rowLanguage);
364,6 → 369,128
 
}
 
private void fillTaxe(Element tableau, List<? extends SQLRowAccessor> rows) {
// getValuesFromElement(boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign,
// BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon,
// SQLRow defaultCompte) {
SQLTable tableElt = Configuration.getInstance().getRoot().findTable(tableau.getAttributeValue("table"));
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);
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean bServiceActive = Boolean.valueOf(val);
 
calc.setServiceActive(bServiceActive != null && bServiceActive);
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()) {
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");
if (!produitCompte.isUndefined()) {
calc.setRowDefaultCptProduit(produitCompte);
}
}
long remise = 0;
BigDecimal totalAvtRemise = BigDecimal.ZERO;
SQLTable tableEchantillon = null;
if (row.getTable().getName().equalsIgnoreCase("SAISIE_VENTE_FACTURE") && row.getTable().getDBRoot().contains("ECHANTILLON_ELEMENT")) {
tableEchantillon = row.getTable().getTable("ECHANTILLON_ELEMENT");
}
if (row.getTable().contains("REMISE_HT")) {
remise = row.getLong("REMISE_HT");
if (remise != 0) {
for (SQLRowAccessor sqlRow : rows) {
calc.addLine(sqlRow, sqlRow.getForeign("ID_ARTICLE"), 1, false);
}
 
if (tableEchantillon != null) {
List<SQLRow> rowsEch = row.getReferentRows(tableEchantillon);
for (SQLRow sqlRow : rowsEch) {
calc.addEchantillon((BigDecimal) sqlRow.getObject("T_PV_HT"), sqlRow.getForeign("ID_TAXE"));
}
}
calc.checkResult();
totalAvtRemise = calc.getTotalHT();
}
}
 
calc.initValues();
long valRemiseHTReel = remise;
if (row.getFields().contains("POURCENT_FACTURABLE") && row.getFields().contains("MONTANT_FACTURABLE")) {
BigDecimal montantFact = row.getBigDecimal("MONTANT_FACTURABLE");
BigDecimal percentFact = row.getBigDecimal("POURCENT_FACTURABLE");
 
if (montantFact != null && montantFact.signum() > 0) {
valRemiseHTReel = 0;
} else if (percentFact != null && percentFact.signum() > 0) {
valRemiseHTReel = percentFact.movePointLeft(2).multiply(new BigDecimal(remise)).setScale(0, RoundingMode.HALF_UP).longValue();
}
 
}
calc.setRemise(valRemiseHTReel, totalAvtRemise);
 
for (int i = 0; i < rows.size(); i++) {
SQLRowAccessor sqlRow = rows.get(i);
calc.addLine(sqlRow, sqlRow.getForeign("ID_ARTICLE"), i, i == rows.size() - 1);
}
 
if (tableEchantillon != null) {
List<SQLRow> rowsEch = row.getReferentRows(tableEchantillon);
for (SQLRow sqlRow : rowsEch) {
calc.addEchantillon((BigDecimal) sqlRow.getObject("T_PV_HT"), sqlRow.getForeign("ID_TAXE"));
}
}
SQLRowAccessor rowTVAPort = null;
if (row.getTable().contains("ID_TAXE_PORT")) {
rowTVAPort = row.getForeign("ID_TAXE_PORT");
}
if (rowTVAPort != null && !rowTVAPort.isUndefined()) {
SQLRowValues rowValsPort = new SQLRowValues(tableElt);
rowValsPort.put("T_PV_HT", BigDecimal.valueOf(row.getLong("PORT_HT")).movePointLeft(2));
rowValsPort.put("QTE", 1);
rowValsPort.put("ID_TAXE", rowTVAPort.getIDNumber());
 
final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
SQLRow rowDefaultCptPort;
if (rowTVAPort.getFloat("TAUX") > 0) {
rowDefaultCptPort = rowPrefsCompte.getForeign("ID_COMPTE_PCE_PORT_SOUMIS");
if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
try {
rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteSoumisTVA");
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
rowDefaultCptPort = rowPrefsCompte.getForeign("ID_COMPTE_PCE_PORT_NON_SOUMIS");
if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
try {
rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteNonSoumisTVA");
} catch (Exception e) {
e.printStackTrace();
}
}
}
rowValsPort.putRowValues("ID_ARTICLE").put("ID_COMPTE_PCE", rowDefaultCptPort.getID());
 
calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
}
calc.checkResult();
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>();
m.put("MONTANT_HT", v.get0());
m.put("MONTANT_TVA", v.get1());
taxe.put(sqlRow, m);
}
}
}
 
private int fillTable(Element tableau, SQLRow row, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test, SQLRow rowLanguage) {
 
if (tableau == null) {
388,52 → 515,11
}
List<Element> listElts = tableau.getChildren("element");
 
if (row.getTable().contains("ID_TAXE_PORT") && row.getTable().contains("PORT_HT")) {
 
SQLRowAccessor rowTaxe = getForeignRow(row, row.getTable().getField("ID_TAXE_PORT"));
BigDecimal ht = BigDecimal.ZERO;
if (row.getTable().getFieldRaw("PORT_HT") != null) {
ht = new BigDecimal((Long) row.getObject("PORT_HT")).movePointLeft(2);
if (ht.signum() != 0) {
if (taxe.get(rowTaxe) != null) {
 
final Object object = taxe.get(rowTaxe).get("MONTANT_HT");
BigDecimal montant = (object == null) ? BigDecimal.ZERO : (BigDecimal) object;
taxe.get(rowTaxe).put("MONTANT_HT", montant.add(ht));
} else {
Map<String, Object> m = new HashMap<String, Object>();
m.put("MONTANT_HT", ht);
taxe.put(rowTaxe, m);
}
}
}
}
 
fillTaxe(tableau, rowsEltCache.get(ref));
// on remplit chaque ligne à partir des rows recuperées
int numeroRef = 0;
for (SQLRowAccessor rowElt : rowsEltCache.get(ref)) {
 
if (!cache && rowElt.getTable().getFieldRaw("ID_TAXE") != null) {
if (!rowElt.getTable().contains("NIVEAU") || rowElt.getInt("NIVEAU") == 1) {
SQLRowAccessor rowTaxe = getForeignRow(rowElt, rowElt.getTable().getField("ID_TAXE"));
BigDecimal ht = BigDecimal.ZERO;
if (rowElt.getTable().getFieldRaw("T_PV_HT") != null) {
ht = (BigDecimal) rowElt.getObject("T_PV_HT");
}
 
if (taxe.get(rowTaxe) != null) {
 
final Object object = taxe.get(rowTaxe).get("MONTANT_HT");
BigDecimal montant = (object == null) ? BigDecimal.ZERO : (BigDecimal) object;
taxe.get(rowTaxe).put("MONTANT_HT", montant.add(ht));
} else {
Map<String, Object> m = new HashMap<String, Object>();
m.put("MONTANT_HT", ht);
taxe.put(rowTaxe, m);
}
}
}
 
final boolean included = isIncluded(tableElement.getFilterId(), tableElement.getForeignTableWhere(), tableElement.getFilterId(), tableElement.getFieldWhere(), rowElt);
String styleName = null;
if (tableElement.getSQLElement().getTable().contains("ID_STYLE")) {
615,7 → 701,7
return nbCellule;
}
 
private void fillTaxe(Element tableau, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test) {
private void fillTaxeDocumentMap(Element tableau, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test) {
 
int line = Integer.valueOf(tableau.getAttributeValue("firstLine"));
List<Element> listElts = tableau.getChildren("element");
638,9 → 724,12
} else if (name.equalsIgnoreCase("MONTANT_TVA")) {
// value = Math.round(((Long) m.get("MONTANT_HT") * rowTaxe.getFloat("TAUX")
// / 100.0));
value = ((BigDecimal) m.get("MONTANT_HT")).multiply(new BigDecimal(rowTaxe.getFloat("TAUX")), DecimalUtils.HIGH_PRECISION).movePointLeft(2);
value = ((BigDecimal) m.get("MONTANT_TVA"));
// value = ((BigDecimal) m.get("MONTANT_HT")).multiply(new
// BigDecimal(rowTaxe.getFloat("TAUX")),
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
} else if (name.equalsIgnoreCase("NOM")) {
value = rowTaxe.getString("NOM");
value = TaxeCache.getCache().getRowFromId(rowTaxe.getID()).getString("NOM");
// TODO prefix et suffix
String prefix = e.getAttributeValue("prefix");
if (prefix != null) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLCache.java
210,7 → 210,7
final SQLTable tableArtElt = root.getTable("ARTICLE_ELEMENT");
SQLRowValues rowVals = new SQLRowValues(tableArtElt);
rowVals.putNulls("QTE", "QTE_UNITAIRE", "ID_UNITE_VENTE", "ID_ARTICLE_PARENT");
rowVals.putRowValues("ID_ARTICLE").putNulls("CODE", "NOM");
rowVals.putRowValues("ID_ARTICLE").setAllToNull();
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
fetch.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/ODTPrinterNX.java
54,7 → 54,7
(float) (paper.getImageableWidth() / POINTS_PER_INCH), (float) (paper.getImageableHeight() / POINTS_PER_INCH), Size2DSyntax.INCH);
attributes.add(printableArea);
 
final PageFormat format = job.getPageFormat(null);
final PageFormat format = printJob.getPageFormat(null);
format.setPaper(paper);
printJob.setPrintable(this, format);
printJob.print(attributes);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieVenteFacture.java
133,12 → 133,26
BigDecimal portHT = BigDecimal.valueOf(saisieRow.getLong("PORT_HT")).movePointLeft(2);
TotalCalculator calc;
if (clientRow.getTable().contains("ID_COMPTE_PCE_PRODUIT") && !clientRow.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
calc = getValuesFromElement(false, "T_PV_HT", saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), tableEchantillon,
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"));
} else {
calc = getValuesFromElement(saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), tableEchantillon);
}
Map<SQLRowAccessor, BigDecimal> compl = calc.getMapHtTaxeCompl();
for (SQLRowAccessor rowCompl : compl.keySet()) {
if (compl.get(rowCompl) != null) {
long taxeC = compl.get(rowCompl).multiply(rowCompl.getBigDecimal("POURCENT").movePointLeft(2)).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE"));
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", Long.valueOf(taxeC));
ajoutEcriture();
 
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE_PRODUITS"));
this.mEcritures.put("DEBIT", Long.valueOf(taxeC));
this.mEcritures.put("CREDIT", Long.valueOf(0));
ajoutEcriture();
}
}
// On génére les ecritures si la facture n'est pas un acompte
long ttcLongValue = calc.getTotalTTC().movePointRight(2).longValue();
if (acompte == null || !acompte) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieVenteComptoir.java
18,6 → 18,7
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;
import org.openconcerto.utils.ExceptionHandler;
116,10 → 117,18
// compte TVA
long tva = prixTTC.calculLongTVA(taxeRow.getFloat("TAUX") / 100.0);
if (tva > 0) {
int idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_VENTE");
int idCompteTVA;
 
SQLRowAccessor rowCptTva = saisieRow.getForeign("ID_TAXE").getForeign("ID_COMPTE_PCE_COLLECTE");
if (rowCptTva == null || rowCptTva.isUndefined()) {
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_VENTE");
if (idCompteTVA <= 1) {
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVACollectee");
}
} else {
idCompteTVA = rowCptTva.getID();
}
 
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVA));
this.mEcritures.put("DEBIT", new Long(0));
this.mEcritures.put("CREDIT", new Long(tva));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtFactureFournisseur.java
95,7 → 95,8
}
}
 
TotalCalculator calc = getValuesFromElement(true, "T_PA_HT", saisieRow, saisieRow.getTable().getTable("FACTURE_FOURNISSEUR_ELEMENT"), BigDecimal.ZERO, null, null, rowCompteAchat);
TotalCalculator calc = getValuesFromElement(rowFournisseur.getBoolean("UE"), true, "T_PA_HT", saisieRow, saisieRow.getTable().getTable("FACTURE_FOURNISSEUR_ELEMENT"), BigDecimal.ZERO, null,
null, rowCompteAchat);
 
long ttcLongValue = calc.getTotalTTC().movePointRight(2).longValue();
long htLongValue = calc.getTotalHT().movePointRight(2).longValue();
120,18 → 121,40
this.mEcritures.put("DEBIT", longValue);
ajoutEcriture();
 
if (rowFournisseur.getBoolean("UE")) {
int idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
if (idCompteTVAIntra <= 1) {
idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
// if (rowFournisseur.getBoolean("UE")) {
// int idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
// if (idCompteTVAIntra <= 1) {
// idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
// }
// this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVAIntra));
// this.mEcritures.put("DEBIT", new Long(0));
// this.mEcritures.put("CREDIT", new Long(longValue));
// ajoutEcriture();
// }
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVAIntra));
this.mEcritures.put("DEBIT", new Long(0));
this.mEcritures.put("CREDIT", new Long(longValue));
}
Map<SQLRowAccessor, BigDecimal> tvaMapIntra = calc.getMapHtTVAIntra();
for (SQLRowAccessor rowAc : tvaMapIntra.keySet()) {
long longValue = tvaMapIntra.get(rowAc).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
if (longValue != 0) {
this.mEcritures.put("ID_COMPTE_PCE", rowAc.getID());
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", longValue);
ajoutEcriture();
 
// if (rowFournisseur.getBoolean("UE")) {
// int idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
// if (idCompteTVAIntra <= 1) {
// idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
// }
// this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVAIntra));
// this.mEcritures.put("DEBIT", new Long(0));
// this.mEcritures.put("CREDIT", new Long(longValue));
// ajoutEcriture();
// }
}
}
}
 
// compte Fournisseurs
int idCompteFourn = rowFournisseur.getInt("ID_COMPTE_PCE");
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtReglementChequeClient.java
68,6 → 68,7
 
// compte Clients
int idCompteClient = -1;
if (chequeRow.getBoolean("SANS_VALEUR_ENCAISSEMENT")) {
if (clientRow != null) {
idCompteClient = clientRow.getInt("ID_COMPTE_PCE");
}
77,6 → 78,12
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
} else {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("ValeurEncaissement");
}
}
 
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteClient));
this.mEcritures.put("DEBIT", new Long(0));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationEcritures.java
33,6 → 33,7
import org.openconcerto.utils.ExceptionHandler;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
365,13 → 366,14
}
 
protected TotalCalculator getValuesFromElement(SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon) {
return getValuesFromElement(false, "T_PV_HT", row, foreign, portHT, rowTVAPort, tableEchantillon, null);
return getValuesFromElement(false, false, "T_PV_HT", row, foreign, portHT, rowTVAPort, tableEchantillon, null);
}
 
protected TotalCalculator getValuesFromElement(boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon,
protected TotalCalculator getValuesFromElement(boolean intra, boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon,
SQLRow defaultCompte) {
 
TotalCalculator calc = new TotalCalculator("T_PA_HT", fieldTotalHT, null, achat, defaultCompte);
calc.setIntraComm(intra);
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean bServiceActive = Boolean.valueOf(val);
 
410,8 → 412,20
}
 
calc.initValues();
calc.setRemise(remise, totalAvtRemise);
long valRemiseHTReel = remise;
if (row.getFields().contains("POURCENT_FACTURABLE") && row.getFields().contains("MONTANT_FACTURABLE")) {
BigDecimal montantFact = row.getBigDecimal("MONTANT_FACTURABLE");
BigDecimal percentFact = row.getBigDecimal("POURCENT_FACTURABLE");
 
if (montantFact != null && montantFact.signum() > 0) {
valRemiseHTReel = 0;
} else if (percentFact != null && percentFact.signum() > 0) {
valRemiseHTReel = percentFact.movePointLeft(2).multiply(new BigDecimal(remise)).setScale(0, RoundingMode.HALF_UP).longValue();
}
 
}
calc.setRemise(valRemiseHTReel, totalAvtRemise);
 
List<SQLRow> rows = row.getReferentRows(foreign);
for (int i = 0; i < rows.size(); i++) {
SQLRow sqlRow = rows.get(i);
452,8 → 466,9
}
}
}
rowValsPort.putRowValues("ID_ARTICLE").put("ID_COMPTE_PCE", rowDefaultCptPort.getID());
 
final SQLRowValues rowValsArt = rowValsPort.putRowValues("ID_ARTICLE");
rowValsArt.put("ID_COMPTE_PCE", rowDefaultCptPort.getID());
rowValsArt.put("ID_TAXE_COMPLEMENTAIRE", null);
calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
}
calc.checkResult();
547,8 → 562,12
* @throws Exception
*/
protected void fillCompteBanqueFromRow(SQLRow sqlRow, String defaultProps, boolean achat) throws Exception {
 
int idPce = base.getTable("TYPE_REGLEMENT").getRow(2).getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
int idPce = -1;
if (sqlRow.getTable().contains("ID_TYPE_REGLEMENT")) {
idPce = sqlRow.getForeign("ID_TYPE_REGLEMENT").getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
} else {
idPce = base.getTable("TYPE_REGLEMENT").getRow(2).getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
}
if (idPce <= 1) {
idPce = ComptePCESQLElement.getIdComptePceDefault(defaultProps);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieAchat.java
20,6 → 20,7
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;
import org.openconcerto.utils.ExceptionHandler;
37,16 → 38,12
private static final SQLTable tableFournisseur = base.getTable("FOURNISSEUR");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
 
public GenerationMvtSaisieAchat(SQLRow row, int idMvt) {
public GenerationMvtSaisieAchat(SQLRow row) {
setRowAnalytiqueSource(row);
this.saisieRow = row;
this.idMvt = idMvt;
this.idMvt = row.getInt("ID_MOUVEMENT");
}
 
public GenerationMvtSaisieAchat(SQLRow row) {
this(row, 1);
}
 
public void genereMouvement() throws Exception {
SQLRow rowFournisseur = tableFournisseur.getRow(this.saisieRow.getInt("ID_FOURNISSEUR"));
 
105,11 → 102,16
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVAImmo");
}
} else {
SQLRowAccessor rowCptTva = this.saisieRow.getForeign("ID_TAXE").getForeign(rowFournisseur.getBoolean("UE") ? "ID_COMPTE_PCE_DED_INTRA" : "ID_COMPTE_PCE_DED");
if (rowCptTva == null || rowCptTva.isUndefined()) {
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_ACHAT");
if (idCompteTVA <= 1) {
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVADeductible");
}
} else {
idCompteTVA = rowCptTva.getID();
}
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVA));
this.mEcritures.put("DEBIT", new Long(prixTVA.getLongValue()));
this.mEcritures.put("CREDIT", new Long(0));
116,10 → 118,17
ajoutEcriture();
 
if (rowFournisseur.getBoolean("UE")) {
int idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
SQLRowAccessor rowCptTva = this.saisieRow.getForeign("ID_TAXE").getForeign("ID_COMPTE_PCE_COLLECTE_INTRA");
int idCompteTVAIntra;
if (rowCptTva == null || rowCptTva.isUndefined()) {
idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
 
if (idCompteTVAIntra <= 1) {
idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
}
} else {
idCompteTVAIntra = rowCptTva.getID();
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVAIntra));
this.mEcritures.put("DEBIT", new Long(0));
this.mEcritures.put("CREDIT", new Long(prixTVA.getLongValue()));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirClient.java
100,11 → 100,27
 
TotalCalculator calc;
if (rowClient.getTable().contains("ID_COMPTE_PCE_PRODUIT") && !rowClient.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
calc = getValuesFromElement(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, null, rowClient.getForeign("ID_COMPTE_PCE_PRODUIT"));
} else {
calc = getValuesFromElement(avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, null);
}
 
Map<SQLRowAccessor, BigDecimal> compl = calc.getMapHtTaxeCompl();
for (SQLRowAccessor rowCompl : compl.keySet()) {
if (compl.get(rowCompl) != null) {
long taxeC = compl.get(rowCompl).multiply(rowCompl.getBigDecimal("POURCENT").movePointLeft(2)).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE"));
this.mEcritures.put("CREDIT", Long.valueOf(0));
this.mEcritures.put("DEBIT", Long.valueOf(taxeC));
ajoutEcriture();
 
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE_PRODUITS"));
this.mEcritures.put("CREDIT", Long.valueOf(taxeC));
this.mEcritures.put("DEBIT", Long.valueOf(0));
ajoutEcriture();
}
}
 
for (SQLRowAccessor row : calc.getMapHt().keySet()) {
long b = calc.getMapHt().get(row).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
if (b != 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementVenteNG.java
56,7 → 56,12
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse) throws Exception {
this(label, rowClient, ttc, d, modeReglement, source, mvtSource, createEncaisse, false);
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance)
throws Exception {
 
SQLRow typeRegRow = modeReglement.getForeignRow("ID_TYPE_REGLEMENT");
setRowAnalytiqueSource(source);
// iniatilisation des valeurs de la map
138,9 → 143,9
 
Calendar c = modeReglement.getDate("DATE_DEPOT");
if (c != null) {
paiementCheque(c.getTime(), source, ttc, rowClient.getID(), modeReglement, mvtSource.getTable().getRow(idMvt));
paiementCheque(c.getTime(), source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance);
} else {
paiementCheque(this.date, source, ttc, rowClient.getID(), modeReglement, mvtSource.getTable().getRow(idMvt));
paiementCheque(this.date, source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance);
}
 
} else {
160,9 → 165,16
this.mEcritures.put("ID_JOURNAL", JournalSQLElement.CAISSES);
}
 
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
if (avance) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("AvanceClients");
}
} else {
 
// compte Clients
 
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
if (idCompteClient <= 1) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
if (idCompteClient <= 1) {
169,10 → 181,11
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
 
}
this.mEcritures.put("ID_COMPTE_PCE", idCompteClient);
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", Long.valueOf(ttc.getLongValue()));
 
this.ecrClient = ajoutEcriture();
 
// compte de reglement, caisse, cheque, ...
300,10 → 313,10
}
}
 
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, int idClient, SQLRow modeRegl, SQLRow mvtSource) throws SQLException {
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, SQLRow rowClient, SQLRow modeRegl, SQLRow mvtSource, boolean avance) throws Exception {
 
SQLRowValues valCheque = new SQLRowValues(base.getTable("CHEQUE_A_ENCAISSER"));
valCheque.put("ID_CLIENT", idClient);
valCheque.put("ID_CLIENT", rowClient.getID());
 
final String foreignBanqueFieldName = "ID_" + BanqueSQLElement.TABLENAME;
if (valCheque.getTable().contains(foreignBanqueFieldName))
326,5 → 339,40
rowVals.update(this.idMvt);
}
 
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
if (avance) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("AvanceClients");
}
} else {
 
// compte Clients
 
if (idCompteClient <= 1) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
}
this.mEcritures.put("ID_JOURNAL", JournalSQLElement.BANQUES);
this.mEcritures.put("ID_COMPTE_PCE", idCompteClient);
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", Long.valueOf(ttc.getLongValue()));
 
this.ecrClient = ajoutEcriture();
 
// compte de reglement, caisse, cheque, ...
int idCompteRegl = rowPrefsCompte.getInt("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT");
if (idCompteRegl <= 1) {
idCompteRegl = ComptePCESQLElement.getIdComptePceDefault("ValeurEncaissement");
}
this.mEcritures.put("ID_COMPTE_PCE", Integer.valueOf(idCompteRegl));
this.mEcritures.put("DEBIT", Long.valueOf(ttc.getLongValue()));
this.mEcritures.put("CREDIT", Long.valueOf(0));
 
ajoutEcriture();
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentSQLElement.java
New file
0,0 → 1,83
/*
* 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.edm;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
public class AttachmentSQLElement extends ComptaSQLConfElement {
 
public final static String DIRECTORY_PREFS = "EDMdirectory";
 
public AttachmentSQLElement() {
super("ATTACHMENT", "un attachement", "attachements");
 
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("SOURCE_TABLE");
l.add("SOURCE_ID");
l.add("NAME");
l.add("MIMETYPE");
l.add("FILENAME");
l.add("STORAGE_PATH");
l.add("THUMBNAIL");
l.add("THUMBNAIL_WIDTH");
l.add("THUMBNAIL_HEIGHT");
l.add("TAG");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NAME");
return l;
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
public void addViews() {
this.setLayout(new GridBagLayout());
 
final GridBagConstraints c = new DefaultGridBagConstraints();
c.anchor = GridBagConstraints.NORTHEAST;
c.gridwidth = 1;
 
// // Numero
// JLabel labelNumero = new JLabel("Numéro ");
// this.add(labelNumero, c);
//
// JTextField textNumero = new JTextField();
// c.gridx++;
// c.weightx = 1;
// this.add(textNumero, c);
 
// this.addRequiredSQLObject(textNumero, "NUMERO");
}
};
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".attachment";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/data-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/data-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/pdf-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/pdf-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentAction.java
New file
0,0 → 1,50
/*
* 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.edm;
 
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.FrameUtil;
 
import java.awt.event.ActionEvent;
 
import javax.swing.AbstractAction;
 
public class AttachmentAction extends PredicateRowAction {
 
public AttachmentAction(final String foreignField) {
super(new AbstractAction("Fichiers liés") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRowAccessor row = IListe.get(e).getSelectedRow();
if (foreignField != null) {
row = row.getForeign(foreignField);
}
AttachmentPanel panel = new AttachmentPanel(row);
// TODO mettre le nom du sqlelement et la ref??? ex : du devis DEV20170101-003
PanelFrame frame = new PanelFrame(panel, "Liste des fichiers liés");
FrameUtil.show(frame);
}
}, true);
 
}
 
public AttachmentAction() {
this(null);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/docx-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/docx-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xlsx-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xlsx-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentPanel.java
New file
0,0 → 1,244
/*
* 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.edm;
 
import org.openconcerto.erp.core.common.ui.ScrollablePanel;
import org.openconcerto.sql.model.SQLRowAccessor;
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.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.SwingThreadUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
 
public class AttachmentPanel extends JPanel {
 
private final SQLRowAccessor rowSource;
private List<ListDataListener> listeners = new ArrayList<ListDataListener>();
 
public AttachmentPanel(SQLRowAccessor rowSource) {
super();
this.rowSource = rowSource;
this.setLayout(new GridBagLayout());
initUI();
setFocusable(true);
}
 
public void addListener(ListDataListener l) {
this.listeners.add(l);
}
 
public void removeListener(ListDataListener l) {
this.listeners.remove(l);
}
 
public void fireDataChanged() {
for (ListDataListener listDataListener : listeners) {
listDataListener.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, 0));
}
}
 
public void initUI() {
this.invalidate();
this.removeAll();
GridBagConstraints c = new DefaultGridBagConstraints();
 
// Recupération de la liste des fichiers
 
// TODO requete dans un SwingWorker
final SQLTable tableAttachment = rowSource.getTable().getTable("ATTACHMENT");
SQLRowValues rowVals = new SQLRowValues(tableAttachment);
rowVals.putNulls(tableAttachment.getFieldsName());
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
Where where = new Where(tableAttachment.getField("SOURCE_TABLE"), "=", this.rowSource.getTable().getName());
where = where.and(new Where(tableAttachment.getField("SOURCE_ID"), "=", this.rowSource.getID()));
// TODO en premier les dossier, puis trier par nom
List<SQLRowValues> attachments = fetcher.fetch(where);
 
// AJout d'un fichier
final JButton addButton = new JButton("Ajouter un fichier");
this.add(addButton, c);
 
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
final JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setValue(100);
progressBar.setStringPainted(true);
progressBar.setVisible(false);
this.add(progressBar, c);
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy++;
 
addButton.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
 
final FileDialog fd = new FileDialog(frame, "Ajouter un fichier", FileDialog.LOAD);
fd.setVisible(true);
final String fileName = fd.getFile();
if (fileName != null) {
File inFile = new File(fd.getDirectory(), fileName);
AttachmentUtils utils = new AttachmentUtils();
utils.uploadFile(inFile, rowSource);
initUI();
}
}
});
 
ScrollablePanel files = new ScrollablePanel() {
@Override
public Dimension getPreferredSize() {
int w = getSize().width;
int nbPerRow = (w - 5) / (FilePanel.WIDTH + 5);
if (nbPerRow < 1) {
nbPerRow = 1;
}
int nbRow = 1 + (getComponentCount() / nbPerRow);
if (nbRow < 1) {
nbRow = 1;
}
return new Dimension(w, 5 + nbRow * (FilePanel.HEIGHT + 5));
}
 
};
files.setOpaque(true);
files.setBackground(Color.WHITE);
files.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT);
files.setScrollableHeight(ScrollablePanel.ScrollableSizeHint.NONE);
files.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
// Liste des fichiers
for (final SQLRowValues sqlRowValues : attachments) {
 
final FilePanel filePanel = new FilePanel(sqlRowValues, this);
filePanel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) {
Thread t = new Thread() {
@Override
public void run() {
AttachmentUtils utils = new AttachmentUtils();
File f = utils.getFile(sqlRowValues);
if (f == null) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Impossible de récupérer le fichier.", "Erreur", JOptionPane.ERROR_MESSAGE);
}
});
System.err.println("Impossible de récupérer le fichier.");
} else {
try {
FileUtils.openFile(f);
} catch (IOException e1) {
ExceptionHandler.handle("Erreur lors de l'ouverture du fichier.", e1);
}
}
}
};
t.start();
}
}
});
files.add(filePanel);
 
}
c.gridwidth = 2;
c.gridx = 0;
c.gridy++;
c.weightx = 1;
c.weighty = 1;
JScrollPane scroll = new JScrollPane(files);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setMinimumSize(new Dimension((int) (400 * 1.618), 400));
scroll.setPreferredSize(new Dimension((int) (400 * 1.618), 400));
scroll.setBackground(Color.WHITE);
scroll.getViewport().setBackground(Color.WHITE);
this.add(scroll, c);
 
this.validate();
this.repaint();
 
DropTarget dt = new DropTarget() {
@Override
public synchronized void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Transferable t = dtde.getTransferable();
try {
 
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
@SuppressWarnings("unchecked")
List<File> fileList = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
// TODO faire en arriere plan, mettre une jauge à droite du bouton ajouter
// et mettre un bouton d'annulation
AttachmentUtils utils = new AttachmentUtils();
boolean cancelledByUser = false;
for (File f : fileList) {
if (cancelledByUser) {
break;
}
utils.uploadFile(f, rowSource);
}
initUI();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
files.setDropTarget(dt);
scroll.getViewport().setDropTarget(dt);
fireDataChanged();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentUtils.java
New file
0,0 → 1,264
/*
* 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.edm;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
import org.openconcerto.erp.storage.StorageEngine;
import org.openconcerto.erp.storage.StorageEngines;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.ExceptionHandler;
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.sql.SQLException;
import java.util.Collection;
import java.util.List;
 
import javax.swing.JOptionPane;
 
import eu.medsea.mimeutil.MimeType;
import eu.medsea.mimeutil.MimeUtil;
 
public class AttachmentUtils {
 
public void uploadFile(File inFile, SQLRowAccessor rowSource) {
try {
 
// Création de la row attachment
SQLRowValues rowValsAttachment = new SQLRowValues(rowSource.getTable().getTable("ATTACHMENT"));
rowValsAttachment.put("SOURCE_TABLE", rowSource.getTable().getName());
rowValsAttachment.put("SOURCE_ID", rowSource.getID());
 
SQLRow rowAttachment = rowValsAttachment.insert();
int id = rowAttachment.getID();
 
String subDir = "EDM" + File.separator + String.valueOf((id / 1000) * 1000);
String fileNameID = String.valueOf(id);
String ext = "";
 
int i = inFile.getName().lastIndexOf('.');
if (i > 0) {
ext = inFile.getName().substring(i + 1);
}
 
final String fileWithIDNAme = fileNameID + "." + ext;
 
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta();
boolean isOnCloud = config.isOnCloud();
 
if (isOnCloud) {
 
String remotePath = subDir;
remotePath = remotePath.replace('\\', '/');
List<StorageEngine> engines = StorageEngines.getInstance().getActiveEngines();
for (StorageEngine storageEngine : engines) {
if (storageEngine.isConfigured() && storageEngine.allowAutoStorage()) {
final String path = remotePath;
try {
storageEngine.connect();
final BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(inFile));
storageEngine.store(inStream, path, fileWithIDNAme, true);
inStream.close();
storageEngine.disconnect();
} catch (IOException e) {
ExceptionHandler.handle("Impossible de sauvegarder le fichier " + inFile.getAbsolutePath() + " vers " + path + "(" + storageEngine + ")", e);
}
// if (storageEngine instanceof CloudStorageEngine) {
// try {
// storageEngine.connect();
// final BufferedInputStream inStream = new BufferedInputStream(new
// FileInputStream(generatedFile));
// storageEngine.store(inStream, path, generatedFile.getName(), true);
// inStream.close();
// storageEngine.disconnect();
// } catch (IOException e) {
// ExceptionHandler.handle("Impossible de sauvegarder le fichier généré " +
// generatedFile.getAbsolutePath() + " vers " + path + "(" + storageEngine +
// ")", e);
// }
// }
}
}
} else {
// Upload File
 
// Get file out
File dirRoot = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(AttachmentSQLElement.DIRECTORY_PREFS);
File storagePathFile = new File(dirRoot, subDir);
storagePathFile.mkdirs();
// TODO CHECK IF FILE EXISTS
FileUtils.copyFile(inFile, new File(storagePathFile, fileWithIDNAme));
 
}
 
// Update rowAttachment
rowValsAttachment = rowAttachment.createEmptyUpdateRow();
 
// Default is without extension
String fileName = inFile.getName();
String name = fileName;
int index = name.lastIndexOf('.');
if (index > 0) {
name = name.substring(0, index);
}
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");
}
rowValsAttachment.put("FILENAME", fileName);
rowValsAttachment.put("FILESIZE", inFile.length());
rowValsAttachment.put("STORAGE_PATH", subDir);
rowValsAttachment.put("STORAGE_FILENAME", fileWithIDNAme);
// TODO THUMBNAIL
// rowVals.put("THUMBNAIL", );
// rowVals.put("THUMBNAIL_WIDTH", );
// rowVals.put("THUMBNAIL_HEIGHT", );
 
// needed for update count
 
rowValsAttachment.commit();
 
updateAttachmentsCountFromAttachment(rowValsAttachment);
} catch (IOException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
 
public File getFile(SQLRowAccessor rowAttachment) {
 
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta();
boolean isOnCloud = config.isOnCloud();
 
String subDir = rowAttachment.getString("STORAGE_PATH");
String fileName = rowAttachment.getString("STORAGE_FILENAME");
 
String remotePath = config.getSocieteID() + File.separator + subDir;
 
File fTemp;
try {
fTemp = File.createTempFile("edm_", "oc");
} catch (IOException e) {
ExceptionHandler.handle("Impossible de créer le fichier temporaire de réception", e);
return null;
}
File f = new File(fTemp.getParent(), fTemp.getName() + "-dir");
f.mkdirs();
fTemp.delete();
 
if (isOnCloud) {
remotePath = remotePath.replace('\\', '/');
final SyncClient client = new SyncClient("https://" + config.getStorageServer());
 
client.setVerifyHost(false);
 
try {
client.retrieveFile(f, remotePath, fileName, config.getToken());
} catch (Exception e) {
ExceptionHandler.handle("Impossible de récupérer le fichier depuis le cloud", e);
return null;
}
 
} else {
 
// 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);
return null;
}
} else {
JOptionPane.showMessageDialog(null, "Le fichier n'existe pas sur le serveur!", "Erreur fichier", JOptionPane.ERROR_MESSAGE);
}
}
final File outFile = new File(f, fileName);
outFile.setReadOnly();
return outFile;
 
}
 
public void deleteFile(SQLRowAccessor rowAttachment) throws SQLException, IllegalStateException {
 
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta();
boolean isOnCloud = config.isOnCloud();
 
// Delete File
String subDir = rowAttachment.getString("STORAGE_PATH");
String fileName = rowAttachment.getString("STORAGE_FILENAME");
 
String remotePath = config.getSocieteID() + File.separator + subDir;
if (isOnCloud) {
remotePath = remotePath.replace('\\', '/');
// final SyncClient client = new SyncClient("https://" + config.getStorageServer());
//
// client.setVerifyHost(false);
 
// TODO DELETE FILE ON CLOUD OR RENAME?
// client.retrieveFile(f, remotePath, fileName, config.getToken());
} else {
 
File dirRoot = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(AttachmentSQLElement.DIRECTORY_PREFS);
File storagePathFile = new File(dirRoot, subDir);
File f = new File(storagePathFile, fileName);
if (f.exists()) {
if (!f.delete()) {
throw new IllegalStateException("Une erreur est survenue lors de la suppression du fichier");
}
}
}
 
// Delete Row
config.getDirectory().getElement(rowAttachment.getTable()).archive(rowAttachment.getID());
updateAttachmentsCountFromAttachment(rowAttachment);
}
 
public void updateAttachmentsCountFromAttachment(SQLRowAccessor rowAttachment) {
SQLTable table = rowAttachment.getTable().getTable(rowAttachment.getString("SOURCE_TABLE"));
SQLRow source = table.getRow(rowAttachment.getInt("SOURCE_ID"));
updateAttachmentsCountFromSource(source);
}
 
public void updateAttachmentsCountFromSource(SQLRow rowSource) {
SQLTable tableSource = rowSource.getTable();
SQLTable tableAtt = rowSource.getTable().getTable("ATTACHMENT");
 
String req = "UPDATE " + tableSource.getSQLName().quote() + " SET " + tableSource.getField("ATTACHMENTS").getQuotedName() + "=(SELECT COUNT(*) FROM " + tableAtt.getSQLName().quote();
req += " WHERE " + tableAtt.getArchiveField().getQuotedName() + "=0 AND " + tableAtt.getField("SOURCE_TABLE").getQuotedName() + "='" + tableSource.getName() + "'";
req += " AND " + tableAtt.getField("SOURCE_ID").getQuotedName() + "=" + rowSource.getID() + ") WHERE " + tableSource.getKey().getQuotedName() + "=" + rowSource.getID();
 
tableSource.getDBSystemRoot().getDataSource().execute(req);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/jpg-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/jpg-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/png-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/png-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/doc-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/doc-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/ods-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/ods-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/FilePanel.java
New file
0,0 → 1,279
/*
* 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.edm;
 
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.JImage;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
 
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
public class FilePanel extends JPanel {
JImage image = null;
 
public static final int WIDTH = 128;
public static final int HEIGHT = 80;
JLabel label;
 
public FilePanel(final SQLRowValues rowAttachment, final AttachmentPanel panelSource) {
final String name = rowAttachment.getString("NAME");
this.setOpaque(true);
this.setLayout(new BorderLayout());
try {
String type = rowAttachment.getString("MIMETYPE");
if (type == null || type.trim().isEmpty() || type.equals("application/octet-stream")) {
image = new JImage(this.getClass().getResource("data-icon.png"));
} else if (type.equals("application/msword")) {
image = new JImage(this.getClass().getResource("doc-icon.png"));
} else if (type.equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) {
image = new JImage(this.getClass().getResource("docx-icon.png"));
} else if (type.equals("application/vnd.oasis.opendocument.text")) {
image = new JImage(this.getClass().getResource("odt-icon.png"));
} else if (type.equals("application/pdf")) {
image = new JImage(this.getClass().getResource("pdf-icon.png"));
} else if (type.equals("image/jpeg")) {
image = new JImage(this.getClass().getResource("jpg-icon.png"));
} else if (type.equals("image/png")) {
image = new JImage(this.getClass().getResource("png-icon.png"));
} else if (type.equals("application/vnd.oasis.opendocument.spreadsheet")) {
image = new JImage(this.getClass().getResource("ods-icon.png"));
} else if (type.equals("application/msexcel") || type.equals("application/vnd.ms-excel") || type.equals("application/xls")) {
image = new JImage(this.getClass().getResource("xls-icon.png"));
} else if (type.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
image = new JImage(this.getClass().getResource("xlsx-icon.png"));
} else {
image = new JImage(this.getClass().getResource("data-icon.png"));
}
image.setOpaque(true);
 
image.setCenterImage(true);
this.add(image, BorderLayout.CENTER);
} catch (Exception e) {
e.printStackTrace();
}
setBackground(Color.WHITE);
label = new JLabel(name, SwingConstants.CENTER);
label.setOpaque(false);
this.add(label, BorderLayout.SOUTH);
 
this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
this.setMinimumSize(new Dimension(WIDTH, HEIGHT));
this.addMouseListener(new MouseAdapter() {
 
@Override
public void mouseExited(MouseEvent e) {
setBackground(Color.WHITE);
}
 
@Override
public void mouseEntered(MouseEvent e) {
setBackground(new Color(230, 240, 255));
}
 
});
final JPopupMenu menu = new JPopupMenu();
final JMenuItem menuItemDelete = new JMenuItem("Supprimer");
menuItemDelete.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
 
int value = JOptionPane.showConfirmDialog(FilePanel.this, "Voulez-vous vraiment supprimer ce fichier ?\n" + rowAttachment.getString("NAME") + "\nFichier orignal : "
+ rowAttachment.getString("FILENAME") + "\nType : " + rowAttachment.getString("MIMETYPE"), "Supprimer le ficher", JOptionPane.YES_NO_OPTION);
 
if (value == JOptionPane.YES_OPTION) {
AttachmentUtils utils = new AttachmentUtils();
try {
utils.deleteFile(rowAttachment);
panelSource.initUI();
} catch (Exception e1) {
ExceptionHandler.handle("Erreur lors de la suppression du fichier!", e1);
}
}
 
}
});
menu.add(menuItemDelete);
final JMenuItem menuItemRename = new JMenuItem("Renommer");
menuItemRename.addActionListener(new ActionListener() {
 
final JTextField text = new JTextField(name);
 
private void stopNameEditing() {
FilePanel.this.invalidate();
FilePanel.this.remove(text);
FilePanel.this.add(label, BorderLayout.SOUTH);
FilePanel.this.validate();
FilePanel.this.repaint();
}
 
public void validText(final SQLRowValues rowAttachment, final String name, final JTextField text) {
try {
String newName = text.getText();
if (newName.trim().isEmpty()) {
newName = name;
}
rowAttachment.put("NAME", newName).commit();
label.setText(newName);
} catch (SQLException e1) {
ExceptionHandler.handle("Erreur lors du renommage du fichier!", e1);
}
}
 
@Override
public void actionPerformed(ActionEvent e) {
final String name = rowAttachment.getString("NAME");
 
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
validText(rowAttachment, name, text);
stopNameEditing();
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
stopNameEditing();
}
}
 
});
text.addFocusListener(new FocusListener() {
 
@Override
public void focusLost(FocusEvent e) {
validText(rowAttachment, name, text);
stopNameEditing();
}
 
@Override
public void focusGained(FocusEvent e) {
}
 
});
text.addMouseListener(new MouseAdapter() {
 
@Override
public void mouseExited(MouseEvent e) {
validText(rowAttachment, name, text);
stopNameEditing();
}
 
});
 
FilePanel.this.invalidate();
FilePanel.this.remove(label);
FilePanel.this.add(text, BorderLayout.SOUTH);
FilePanel.this.validate();
FilePanel.this.repaint();
 
text.grabFocus();
text.setSelectionStart(0);
text.setSelectionEnd(name.length());
}
 
});
menu.add(menuItemRename);
menu.addSeparator();
JMenuItem menuItemProperties = new JMenuItem("Propriétés");
menuItemProperties.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
JFrame f = new JFrame();
f.setTitle("Propriétés de " + rowAttachment.getString("NAME"));
JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
// Name
c.weightx = 0;
p.add(new JLabel("Nom : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getString("NAME")), c);
c.gridy++;
// Type
c.gridx = 0;
c.weightx = 0;
p.add(new JLabel("Type : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getString("MIMETYPE")), c);
c.gridy++;
// FileName
c.gridx = 0;
c.weightx = 0;
p.add(new JLabel("Fichier original : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getString("FILENAME")), c);
c.gridy++;
// Size
c.gridx = 0;
c.weightx = 0;
p.add(new JLabel("Taille : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getInt("FILESIZE") + " octets"), c);
 
// Spacer
c.gridx = 1;
c.gridy++;
c.weightx = 1;
JPanel spacer = new JPanel();
spacer.setPreferredSize(new Dimension(300, 1));
p.add(spacer, c);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 
f.setContentPane(p);
f.pack();
f.setResizable(false);
f.setLocationRelativeTo(FilePanel.this);
f.setVisible(true);
 
}
});
menu.add(menuItemProperties);
setComponentPopupMenu(menu);
}
 
@Override
public void setBackground(Color bg) {
super.setBackground(bg);
if (image != null) {
image.setBackground(bg);
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/odt-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/odt-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xls-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xls-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/ui/EtatDevisRenderer.java
37,7 → 37,7
 
public final static Color couleurRed = new Color(255, 232, 245);
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
 
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/ui/QuoteSQLComponent.java
63,6 → 63,8
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
 
import com.ibm.icu.math.BigDecimal;
 
public class QuoteSQLComponent extends GroupSQLComponent {
 
public static final String ID = "sales.quote";
147,8 → 149,9
final DeviseField totalTVA = (DeviseField) getEditor("T_TVA");
final DeviseField totalRemise = (DeviseField) getEditor("REMISE_HT");
final DeviseField totalPORT = (DeviseField) getEditor("PORT_HT");
final DeviseField totalEco = (DeviseField) getEditor("T_ECO_CONTRIBUTION");
 
return new TotalPanel(items, totalHT, totalTVA, totalTTC, totalRemise, totalPORT, totalService, totalSupply, totalDevise, totalWeight, null);
return new TotalPanel(items, totalEco, totalHT, totalTVA, totalTTC, totalRemise, totalPORT, totalService, totalSupply, totalDevise, totalWeight, null);
} else if (id.startsWith("T_")) {
return new DeviseField();
} else if (id.equals("REMISE_HT") || id.equals("PORT_HT") || id.equals("PREBILAN")) {
420,6 → 423,7
 
}
rowVals.put("DATE", new Date());
rowVals.put("T_ECO_CONTRIBUTION", BigDecimal.ZERO);
rowVals.put("T_HT", Long.valueOf(0));
rowVals.put("T_TVA", Long.valueOf(0));
rowVals.put("T_SERVICE", Long.valueOf(0));
461,6 → 465,7
super.addViews();
 
final DeviseField totalHT = (DeviseField) getEditor("T_HT");
final DeviseField totalEco = (DeviseField) getEditor("T_ECO_CONTRIBUTION");
final DeviseField totalService = (DeviseField) getEditor("T_SERVICE");
final DeviseField totalSupply = (DeviseField) getEditor("T_HA");
final DeviseField totalDevise = (DeviseField) getEditor("T_DEVISE");
475,6 → 480,7
}
 
this.addView(totalPORT, "PORT_HT");
this.addView(totalEco, "T_ECO_CONTRIBUTION");
this.addView(totalRemise, "REMISE_HT");
this.addView(totalTVA, "T_TVA");
this.addView(totalTTC, "T_TTC");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/ui/ListeDesDevisPanel.java
23,27 → 23,34
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.TableRef;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRights;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.ITableModel;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelColumnPath;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.table.PercentTableCellRenderer;
import org.openconcerto.ui.table.TableCellRendererDecorator;
import org.openconcerto.ui.table.TableCellRendererUtils;
import org.openconcerto.ui.table.TimestampTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.SwingWorker2;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.ITransformer;
 
53,11 → 60,12
import java.awt.GridBagLayout;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
86,29 → 94,19
this.map.put(this.tabbedPane.getTabCount(), panelAll);
this.tabbedPane.add("Tous", panelAll);
 
// En cours
ListeAddPanel panelCours = createPanel(EtatDevisSQLElement.EN_COURS);
this.map.put(this.tabbedPane.getTabCount(), panelCours);
List<SQLRow> rowsEtat = SQLBackgroundTableCache.getInstance().getCacheForTable(eltEtatDevis.getTable()).getRows();
 
this.tabbedPane.add(" ", panelCours);
// Date panel
Map<IListe, SQLField> mapDate = new HashMap<IListe, SQLField>();
 
// Attente
ListeAddPanel panelAttente = createPanel(EtatDevisSQLElement.EN_ATTENTE);
this.map.put(this.tabbedPane.getTabCount(), panelAttente);
this.tabbedPane.add(" ", panelAttente);
for (SQLRow sqlRow : rowsEtat) {
ListeAddPanel p = createPanel(sqlRow.getID());
this.map.put(this.tabbedPane.getTabCount(), p);
this.tabbedPane.add(sqlRow.getString("NOM"), p);
mapDate.put(p.getListe(), eltDevis.getTable().getField("DATE"));
}
 
// Accepte
ListeAddPanel panelAccepte = createPanel(EtatDevisSQLElement.ACCEPTE);
this.map.put(this.tabbedPane.getTabCount(), panelAccepte);
this.tabbedPane.add(" ", panelAccepte);
 
// Refuse
ListeAddPanel panelRefuse = createPanel(EtatDevisSQLElement.REFUSE);
this.map.put(this.tabbedPane.getTabCount(), panelRefuse);
this.tabbedPane.add(" ", panelRefuse);
Map<IListe, SQLField> mapDate = new HashMap<IListe, SQLField>();
 
 
this.tabbedPane.setSelectedIndex(1);
 
c.weightx = 1;
120,11 → 118,6
this.add(this.tabbedPane, c);
 
// Date panel
 
mapDate.put(panelAttente.getListe(), eltDevis.getTable().getField("DATE"));
mapDate.put(panelAccepte.getListe(), eltDevis.getTable().getField("DATE"));
mapDate.put(panelRefuse.getListe(), eltDevis.getTable().getField("DATE"));
mapDate.put(panelCours.getListe(), eltDevis.getTable().getField("DATE"));
mapDate.put(panelAll.getListe(), eltDevis.getTable().getField("DATE"));
 
final IListFilterDatePanel datePanel = new IListFilterDatePanel(mapDate, IListFilterDatePanel.getDefaultMap());
133,56 → 126,11
c.weighty = 0;
datePanel.setFilterOnDefault();
this.add(datePanel, c);
initTabTitles();
}
 
 
private void initTabTitles() {
SwingWorker2<List<String>, Object> worker = new SwingWorker2<List<String>, Object>() {
protected void setRenderer(SQLTableModelSourceOnline source) {
 
@Override
protected List<String> doInBackground() throws Exception {
final SQLSelect quoteStates = new SQLSelect();
final SQLTable quoteStatesTable = eltEtatDevis.getTable();
quoteStates.addSelect(quoteStatesTable.getKey());
quoteStates.addSelect(quoteStatesTable.getField("NOM"));
final List<Integer> labelIds = Arrays.asList(EtatDevisSQLElement.EN_COURS, EtatDevisSQLElement.EN_ATTENTE, EtatDevisSQLElement.ACCEPTE, EtatDevisSQLElement.REFUSE);
quoteStates.setWhere(new Where(quoteStatesTable.getKey(), true, labelIds));
@SuppressWarnings("unchecked")
final List<Map<String, Object>> values = quoteStatesTable.getDBSystemRoot().getDataSource().execute(quoteStates.asString());
final List<String> tabNames = new ArrayList<String>();
 
final String keyFieldName = quoteStatesTable.getKey().getName();
for (Integer id : labelIds) {
for (Map<String, Object> m : values) {
if (m.get(keyFieldName).equals(id)) {
tabNames.add(m.get("NOM").toString());
break;
}
}
}
 
return tabNames;
}
 
@Override
protected void done() {
final List<String> tabNames;
try {
tabNames = get();
for (int index = 0; index < tabNames.size(); index++) {
tabbedPane.setTitleAt(index + 1, tabNames.get(index));
}
} catch (Exception e) {
ExceptionHandler.handle("Unable to set tab names", e);
}
}
};
worker.execute();
 
}
 
protected void setRenderer(SQLTableModelSourceOnline source) {
final SQLTableModelColumn column = source.getColumn(this.eltDevis.getTable().getField("DUNNING_DATE"));
if (column != null) {
column.setRenderer(new TimestampTableCellRenderer(false, false) {
284,12 → 232,19
// Filter
final SQLTableModelSourceOnline lAttente = this.eltDevis.getTableSource(true);
final SQLTableModelColumnPath dateEnvoiCol;
if (this.eltDevis.getTable().contains("DATE_REMISE_DOSSIER") && !(idFilter == EtatDevisSQLElement.EN_ATTENTE || idFilter == EtatDevisSQLElement.EN_COURS)) {
// SPADE
SQLTableModelColumn col = lAttente.getColumn(this.eltDevis.getTable().getField("REMIND_DATE"));
if (col != null) {
lAttente.getColumns().remove(col);
}
}
if (idFilter == EtatDevisSQLElement.ACCEPTE) {
if (!this.eltDevis.getTable().contains("DATE_REMISE_DOSSIER")) {
dateEnvoiCol = new SQLTableModelColumnPath(this.eltDevis.getTable().getField("DATE_ENVOI"));
lAttente.getColumns().add(dateEnvoiCol);
dateEnvoiCol.setRenderer(new DateEnvoiRenderer());
dateEnvoiCol.setEditable(true);
 
final BaseSQLTableModelColumn colAvancementCmd = new BaseSQLTableModelColumn("Commande", BigDecimal.class) {
 
@Override
328,7 → 283,11
colAvancement.setRenderer(new PercentTableCellRenderer());
} else {
dateEnvoiCol = null;
 
}
} else {
dateEnvoiCol = null;
}
if (idFilter > 1) {
Where wAttente = new Where(this.eltDevis.getTable().getField("ID_ETAT_DEVIS"), "=", idFilter);
lAttente.getReq().setWhere(wAttente);
356,6 → 315,7
}
 
setRenderer(lAttente);
 
// one config file per idFilter since they haven't the same number of
// columns
final ListeAddPanel pane = new ListeAddPanel(this.eltDevis, new IListe(lAttente), "idFilter" + idFilter);
381,7 → 341,10
return null;
}
}, IListTotalPanel.Type.MOYENNE_MARGE));
total = new IListTotalPanel(pane.getListe(), fields, null, "Total Global");
 
List<Tuple2<SQLField, ?>> filter = new ArrayList<Tuple2<SQLField, ?>>();
filter.add(Tuple2.create(this.eltDevis.getTable().getField("PREBILAN"), Long.valueOf(0)));
total = new IListTotalPanel(pane.getListe(), fields, null, filter, "Total Global (si budget prév. >0)");
} else if (this.eltDevis.getTable().getFieldsName().contains("T_HA") && pane.getListe().getSource().getColumns(this.eltDevis.getTable().getField("T_HA")) != null
&& UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) {
total = new IListTotalPanel(pane.getListe(), Arrays.asList(this.eltDevis.getTable().getField("T_HA"), this.eltDevis.getTable().getField("T_HT")));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/component/DevisSQLComponent.java
14,6 → 14,7
package org.openconcerto.erp.core.sales.quote.component;
 
import static org.openconcerto.utils.CollectionUtils.createSet;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
47,9 → 48,11
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.ui.RadioButtons;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
59,7 → 62,6
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.SwingWorker2;
import org.openconcerto.utils.cc.ITransformer;
import org.openconcerto.utils.checks.ValidState;
import org.openconcerto.utils.text.SimpleDocumentListener;
93,6 → 95,8
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
178,7 → 182,16
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
this.numeroUniqueDevis = new JUniqueTextField(15);
this.numeroUniqueDevis = new JUniqueTextField(15) {
@Override
public String getAutoRefreshNumber() {
if (getMode() == Mode.INSERTION) {
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateDevis.getDate());
} else {
return null;
}
}
};
 
DefaultGridBagConstraints.lockMinimumSize(this.numeroUniqueDevis);
DefaultGridBagConstraints.lockMaximumSize(this.numeroUniqueDevis);
597,6 → 610,7
this.fieldHT = new DeviseField();
final DeviseField fieldTVA = new DeviseField();
final DeviseField fieldTTC = new DeviseField();
final DeviseField fieldEco = new DeviseField();
final DeviseField fieldDevise = new DeviseField();
final DeviseField fieldService = new DeviseField();
this.fieldHT.setEditable(false);
603,7 → 617,9
fieldTVA.setEditable(false);
fieldTTC.setEditable(false);
fieldService.setEditable(false);
fieldEco.setEditable(false);
 
addSQLObject(fieldEco, "T_ECO_CONTRIBUTION");
addRequiredSQLObject(this.fieldHT, "T_HT");
addRequiredSQLObject(fieldTVA, "T_TVA");
addSQLObject(fieldDevise, "T_DEVISE");
622,7 → 638,7
addSQLObject(fieldHA, "T_HA");
}
 
final TotalPanel totalTTC = new TotalPanel(this.table, this.fieldHT, fieldTVA, fieldTTC, textPortHT, this.textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null);
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, this.fieldHT, fieldTVA, fieldTTC, textPortHT, this.textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null);
 
cBottom.gridy = 0;
cBottom.gridx += 2;
768,54 → 784,92
cTabSite.fill = GridBagConstraints.HORIZONTAL;
cTabSite.weightx = 0;
 
// Coche
cTabSite.gridx = 0;
cTabSite.gridwidth = 2;
cTabSite.weightx = 0;
JCheckBox boxAsaisir = new JCheckBox("Rapport à saisir");
tabSite.add(boxAsaisir, cTabSite);
 
// Type Rapport
JLabel labelRapport = new JLabel(getLabelFor("TYPE_RAPPORT"));
cTabSite.gridx = 2;
tabSite.add(labelRapport, cTabSite);
SQLTextCombo comboType = new SQLTextCombo();
cTabSite.gridwidth = GridBagConstraints.REMAINDER;
cTabSite.gridx++;
cTabSite.weightx = 1;
tabSite.add(comboType, cTabSite);
cTabSite.gridwidth = 1;
 
// Date
// Nb Rapport
cTabSite.gridx = 0;
cTabSite.gridy++;
cTabSite.weightx = 0;
tabSite.add(new JLabel(getLabelFor("NB_RAPPORT_A_SAISIR")), cTabSite);
cTabSite.gridx++;
cTabSite.weightx = 1;
JTextField fieldNbRapportASaisir = new JTextField(5);
tabSite.add(fieldNbRapportASaisir, cTabSite);
 
// Date
cTabSite.gridx++;
cTabSite.weightx = 0;
tabSite.add(new JLabel(getLabelFor("DATE_DEMANDE_SAISIE")), cTabSite);
cTabSite.gridx++;
cTabSite.weightx = 0;
JDate dateDmdSaisie = new JDate();
tabSite.add(dateDmdSaisie, cTabSite);
 
cTabSite.gridx++;
tabSite.add(new JLabel(getLabelFor("DATE_SAISIE")), cTabSite);
cTabSite.gridx++;
JDate dateSaisie = new JDate();
tabSite.add(dateSaisie, cTabSite);
 
// Coche
cTabSite.gridx = 0;
cTabSite.gridy++;
cTabSite.gridwidth = 2;
JCheckBox boxAsaisir = new JCheckBox("Rapport à saisir");
tabSite.add(boxAsaisir, cTabSite);
 
cTabSite.gridx += 2;
cTabSite.weightx = 0;
JCheckBox boxAcceptSaisie = new JCheckBox("Accepté en saisie");
tabSite.add(boxAcceptSaisie, cTabSite);
cTabSite.gridwidth = 1;
 
// Nb Rapport
cTabSite.gridy++;
cTabSite.gridx = 0;
cTabSite.weightx = 0;
tabSite.add(new JLabel(getLabelFor("NB_RAPPORT_SAISI")), cTabSite);
cTabSite.gridx++;
cTabSite.weightx = 1;
JTextField fieldNbRapportSaisi = new JTextField(5);
tabSite.add(fieldNbRapportSaisi, cTabSite);
 
cTabSite.gridx++;
cTabSite.weightx = 0;
tabSite.add(new JLabel(getLabelFor("DATE_SAISIE")), cTabSite);
cTabSite.gridx++;
cTabSite.weightx = 0;
JDate dateSaisie = new JDate();
tabSite.add(dateSaisie, cTabSite);
if (!UserRightsManager.getCurrentUserRights().haveRight("VOIR_DEVIS_4_SEMAINES")) {
cTabSite.gridx++;
cTabSite.weightx = 0;
tabSite.add(new JLabel(getLabelFor("DATE_SAISIE_REELLE")), cTabSite);
cTabSite.gridx++;
cTabSite.weightx = 0;
JDate dateSaisieR = new JDate();
tabSite.add(dateSaisieR, cTabSite);
this.addView(dateSaisieR, "DATE_SAISIE_REELLE");
}
cTabSite.gridy++;
tabSite.add(new JLabel(getLabelFor("NB_RAPPORT_A_SAISIR")), cTabSite);
cTabSite.weightx = 0;
cTabSite.gridx = 0;
tabSite.add(new JLabel(getLabelFor("TEMPS_SAISIE")), cTabSite);
cTabSite.gridx++;
JTextField fieldNbRapportASaisir = new JTextField();
tabSite.add(fieldNbRapportASaisir, cTabSite);
cTabSite.weightx = 1;
JTextField fieldTpsSaisi = new JTextField(5);
tabSite.add(fieldTpsSaisi, cTabSite);
 
cTabSite.gridx++;
tabSite.add(new JLabel(getLabelFor("NB_RAPPORT_SAISI")), cTabSite);
cTabSite.weightx = 0;
tabSite.add(new JLabel(getLabelFor("ID_USER_COMMON_SAISIE")), cTabSite);
cTabSite.gridx++;
JTextField fieldNbRapportSaisi = new JTextField();
tabSite.add(fieldNbRapportSaisi, cTabSite);
cTabSite.weightx = 1;
SQLRequestComboBox boxUserSaisi = new SQLRequestComboBox();
tabSite.add(boxUserSaisi, cTabSite);
 
// Date de demande
// Nb rapport a saisie
829,6 → 883,8
this.addView(dateSaisie, "DATE_SAISIE");
this.addView(boxAcceptSaisie, "ACCEPTE_EN_SAISIE");
this.addView(boxAsaisir, "RAPPORT_A_SAISIR");
this.addView(boxUserSaisi, "ID_USER_COMMON_SAISIE");
this.addView(fieldTpsSaisi, "TEMPS_SAISIE");
}
return tabSite;
}
1086,7 → 1142,7
if (getTable().getFieldsName().contains("DATE_VALIDITE")) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, 1);
rowVals.put("DATE_VALIDITE", cal.getTime());
rowVals.put("DATE_VALIDITE", new java.sql.Date(cal.getTimeInMillis()));
}
return rowVals;
}
1117,8 → 1173,34
public int insert(final SQLRow order) {
 
final int idDevis;
int attempt = 0;
// on verifie qu'un devis du meme numero n'a pas été inséré entre temps
if (this.numeroUniqueDevis.checkValidation()) {
if (!this.numeroUniqueDevis.checkValidation(false)) {
while (attempt < JUniqueTextField.RETRY_COUNT) {
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateDevis.getDate());
this.numeroUniqueDevis.setText(num);
attempt++;
if (this.numeroUniqueDevis.checkValidation(false)) {
System.err.println("ATEMPT " + attempt + " SUCCESS WITH NUMERO " + num);
break;
}
try {
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
final String num = this.numeroUniqueDevis.getText();
if (attempt == JUniqueTextField.RETRY_COUNT) {
idDevis = getSelectedID();
ExceptionHandler.handle("Impossible d'ajouter, numéro de devis existant.");
final Object root = SwingUtilities.getRoot(this);
if (root instanceof EditFrame) {
final EditFrame frame = (EditFrame) root;
frame.getPanel().setAlwaysVisible(true);
}
} else {
 
idDevis = super.insert(order);
this.table.updateField("ID_DEVIS", idDevis);
1146,15 → 1228,14
e.printStackTrace();
}
}
} else {
idDevis = getSelectedID();
ExceptionHandler.handle("Impossible d'ajouter, numéro de devis existant.");
final Object root = SwingUtilities.getRoot(this);
if (root instanceof EditFrame) {
final EditFrame frame = (EditFrame) root;
frame.getPanel().setAlwaysVisible(true);
if (attempt > 0) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
}
});
}
}
 
return idDevis;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisItemSQLElement.java
28,7 → 28,6
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.SQLTableModelSourceOnline;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
 
79,14 → 78,6
return l;
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
 
SQLTableModelSourceOnline table = super.createTableSource();
 
return table;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("CODE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisSQLElement.java
46,7 → 46,6
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBoxUtils;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
58,7 → 57,7
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.light.ActivationOnSelectionControler;
import org.openconcerto.ui.light.ColumnSpec;
import org.openconcerto.ui.light.ColumnsSpec;
546,9 → 545,8
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline table = super.createTableSource();
 
protected synchronized void _initTableSource(final SQLTableModelSource table) {
super._initTableSource(table);
final BaseSQLTableModelColumn colAdrLiv = new BaseSQLTableModelColumn("Adresse de livraison", String.class) {
 
@Override
588,8 → 586,6
};
table.getColumns().add(3, colAdrLiv);
 
 
return table;
}
 
@Override
646,8 → 642,9
}
 
@Override
protected Map<String, CustomEditorProvider> getDefaultCustomEditorProvider(final Configuration configuration, final SQLRowValues sqlRow, long userId) throws IllegalArgumentException {
final Map<String, CustomEditorProvider> map = super.getDefaultCustomEditorProvider(configuration, sqlRow, userId);
protected Map<String, CustomEditorProvider> _getDefaultCustomEditorProvider(final Configuration configuration, final SQLRowAccessor sqlRow, final String sessionSecurityToken)
throws IllegalArgumentException {
final Map<String, CustomEditorProvider> map = super._getDefaultCustomEditorProvider(configuration, sqlRow, sessionSecurityToken);
map.put("sales.quote.items.list", new CustomEditorProvider() {
 
@Override
687,6 → 684,9
if (w3cDoc != null) {
columnsPrefs = in.build(w3cDoc);
}
if (columnsPrefs == null) {
throw new IllegalStateException("Columns Prefs is null");
}
} catch (Exception ex) {
throw new IllegalArgumentException(
"DevisSQLElement getItemsCustomEditorProvider - Failed to get ColumnPrefs for descriptor " + lId + " and for user " + userId + "\n" + ex.getMessage());
747,21 → 747,22
 
if (sqlRow != null) {
// send: id,value
final SQLTable table = configuration.getDirectory().getElement("DEVIS_ELEMENT").getTable();
final List<SQLField> fieldsToFetch = new ArrayList<SQLField>();
final SQLElement elem = configuration.getDirectory().getElement("DEVIS_ELEMENT");
final SQLTable table = elem.getTable();
final List<String> fieldsToFetch = new ArrayList<String>();
for (ColumnSpec cs : columnsSpec) {
String colId = cs.getId();
SQLField f = configuration.getFieldMapper().getSQLFieldForItem(colId);
if (f != null) {
fieldsToFetch.add(f);
fieldsToFetch.add(f.getName());
} else {
throw new IllegalStateException("No field in " + table + " for column id " + colId);
}
}
 
final Where where = new Where(table.getKey(), "=", sqlRow.getID());
final SQLRowValues graph = ElementComboBoxUtils.getGraphToFetch(configuration, table, fieldsToFetch);
List<SQLRowValues> fetchedRows = ElementComboBoxUtils.fetchRows(graph, where);
final Where where = new Where(table.getField("ID_DEVIS"), "=", sqlRow.getID());
final ListSQLRequest req = elem.createListRequest(fieldsToFetch, where, configuration.getShowAs());
List<SQLRowValues> fetchedRows = req.getValues();
 
List<Row> rows = new ArrayList<Row>();
for (final SQLRowValues vals : fetchedRows) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/FamilleEcoContributionSQLElement.java
New file
0,0 → 1,76
/*
* 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.sales.product.element;
 
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
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.JTextField;
 
public class FamilleEcoContributionSQLElement extends ConfSQLElement {
 
public FamilleEcoContributionSQLElement() {
super("FAMILLE_ECO_CONTRIBUTION");
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(2);
list.add("NOM");
return list;
}
 
protected List<String> getComboFields() {
final List<String> list = new ArrayList<String>(2);
list.add("NOM");
return list;
}
 
@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) {
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// 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);
 
this.addRequiredSQLObject(textNom, "NOM");
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReferenceArticleSQLElement.java
16,6 → 16,7
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.product.action.InventairePanel;
import org.openconcerto.erp.core.sales.product.component.ReferenceArticleSQLComponent;
36,7 → 37,6
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
44,9 → 44,8
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ListMap;
55,7 → 54,6
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
111,11 → 109,15
}, true, false);
clone.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(clone);
 
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline source = super.createTableSource();
protected synchronized void _initTableSource(final SQLTableModelSource source) {
super._initTableSource(source);
source.init();
final SQLTableModelColumn pvHA1Col = source.getColumn(getTable().getField("PRIX_METRIQUE_HA_1"));
if (pvHA1Col != null) {
164,7 → 166,6
}
});
}
return source;
}
 
protected List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/EcoContributionSQLElement.java
New file
0,0 → 1,115
/*
* 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.sales.product.element;
 
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
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.JTextField;
 
public class EcoContributionSQLElement extends ConfSQLElement {
 
public EcoContributionSQLElement() {
super("ECO_CONTRIBUTION");
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(2);
list.add("ID_FAMILLE_ECO_CONTRIBUTION");
list.add("CODE");
list.add("NOM");
list.add("TAUX");
return list;
}
 
protected List<String> getComboFields() {
final List<String> list = new ArrayList<String>(2);
list.add("CODE");
list.add("NOM");
list.add("TAUX");
return list;
}
 
@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);
 
// Famille
c.gridy++;
c.gridx = 0;
c.weightx = 0;
final JLabel labelFamille = new JLabel(getLabelFor("ID_FAMILLE_ECO_CONTRIBUTION"));
this.add(labelFamille, c);
c.gridx++;
c.weightx = 1;
ElementComboBox combo = new ElementComboBox();
this.add(combo, c);
 
// Taux
c.gridx++;
c.weightx = 0;
final JLabel labelTaux = new JLabel(getLabelFor("TAUX"));
this.add(labelTaux, c);
c.gridx++;
c.weightx = 1;
final JTextField textTaux = new JTextField();
this.add(textTaux, c);
 
this.addRequiredSQLObject(textTaux, "TAUX");
this.addSQLObject(combo, "ID_FAMILLE_ECO_CONTRIBUTION");
this.addRequiredSQLObject(textNom, "NOM");
this.addRequiredSQLObject(textCode, "CODE");
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReliquatSQLElement.java
13,16 → 13,6
package org.openconcerto.erp.core.sales.product.element;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JLabel;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.sales.invoice.ui.FactureAffacturerTable;
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
37,6 → 27,16
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JLabel;
 
public class ReliquatSQLElement extends ComptaSQLConfElement {
 
private final String tableBonName;
73,7 → 73,7
for (SQLRowValues rowVals : rows) {
try {
SQLRowValues upRowVals = rowVals.createEmptyUpdateRow();
upRowVals.put("ID_BON_RECEPTION", id);
upRowVals.put("ID_" + tableBonName, id);
upRowVals.update();
} catch (SQLException exn) {
exn.printStackTrace();
91,8 → 91,13
}
});
 
BonReceptionSQLComponent comp = (BonReceptionSQLComponent) frame.getSQLComponent();
comp.loadFromReliquat(rows);
SQLComponent comp = (SQLComponent) frame.getSQLComponent();
if (comp instanceof BonReceptionSQLComponent) {
((BonReceptionSQLComponent) comp).loadFromReliquat(rows);
} else {
// ((BonDeLivraisonSQLComponent) comp).loadFromReliquat(rows);
 
}
frame.setVisible(true);
 
}
107,7 → 112,6
 
@Override
protected String getParentFFName() {
 
return "ID_" + this.tableBonName;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/ListeDesArticlesAction.java
81,8 → 81,7
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(this.sqlTableArticle);
final FamilleArticlePanel panelFam = new FamilleArticlePanel(elt.getForeignElement("ID_FAMILLE_ARTICLE"));
 
final SQLTableModelSourceOnline createTableSource = elt.initTableSource(elt.getTableSource(true));
createTableSource.init();
final SQLTableModelSourceOnline createTableSource = elt.createTableSource();
 
SQLTableModelColumn colStock;
if (elt.getTable().getDBRoot().contains("ARTICLE_PRIX_REVIENT")) {
139,7 → 138,7
c.gridx++;
panel.add(buttonSuppr, c);
 
final JFrame frame = new PanelFrame(panel, "Suppression d'ecritures");
final JFrame frame = new PanelFrame(panel, "Suppression d'article");
buttonObs.addActionListener(new ActionListener() {
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/ListeEcoContributionAction.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.sales.product.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 ListeEcoContributionAction extends CreateFrameAbstractAction {
 
public ListeEcoContributionAction() {
super();
this.putValue(Action.NAME, "Barème éco-contribution");
}
 
public JFrame createFrame() {
return new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("ECO_CONTRIBUTION")));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/QtyToDeliverRowValuesRenderer.java
New file
0,0 → 1,73
/*
* 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.sales.product.ui;
 
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.table.AlternateTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
 
import java.awt.Color;
import java.awt.Component;
 
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
 
public class QtyToDeliverRowValuesRenderer extends DeviseNiceTableCellRenderer {
 
// Red
public static final Color red = new Color(255, 31, 52);
public static final Color redLightGrey = new Color(240, 65, 85);
 
// Orange
public final static Color orange = new Color(243, 125, 75);
public final static Color orangeGrey = new Color(222, 107, 47);
 
// Blue
public final static Color light = new Color(232, 238, 250);
public final static Color lightGrey = new Color(211, 220, 222);
 
// Black
public final static Color lightBlack = new Color(192, 192, 192);
public final static Color lightBlackGrey = new Color(155, 155, 155);
 
public QtyToDeliverRowValuesRenderer() {
AlternateTableCellRenderer.setBGColorMap(this, CollectionUtils.createMap(lightBlack, lightBlackGrey, red, redLightGrey, orange, orangeGrey));
}
 
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
 
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
 
if (table instanceof RowValuesTable) {
 
((JLabel) comp).setHorizontalAlignment(SwingConstants.RIGHT);
RowValuesTableModel model = ((RowValuesTable) table).getRowValuesTableModel();
SQLRowValues rowVals = model.getRowValuesAt(row);
 
Number qte = (Number) rowVals.getObject("QTE");
Number qteL = (Number) rowVals.getObject("QTE_LIVREE");
if (qte != null && qteL != null) {
if (qte.intValue() <= 0) {
comp.setBackground(red);
}
}
}
return comp;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/DeliveredQtyRowValuesRenderer.java
New file
0,0 → 1,77
/*
* 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.sales.product.ui;
 
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.table.AlternateTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
 
import java.awt.Color;
import java.awt.Component;
 
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
 
public class DeliveredQtyRowValuesRenderer extends DeviseNiceTableCellRenderer {
 
// Red
public static final Color red = new Color(255, 31, 52);
public static final Color redLightGrey = new Color(240, 65, 85);
 
// Orange
public final static Color orange = new Color(243, 125, 75);
public final static Color orangeGrey = new Color(222, 107, 47);
 
// Blue
public final static Color light = new Color(232, 238, 250);
public final static Color lightGrey = new Color(211, 220, 222);
 
// Black
public final static Color lightBlack = new Color(192, 192, 192);
public final static Color lightBlackGrey = new Color(155, 155, 155);
 
public DeliveredQtyRowValuesRenderer() {
AlternateTableCellRenderer.setBGColorMap(this, CollectionUtils.createMap(lightBlack, lightBlackGrey, red, redLightGrey, orange, orangeGrey));
}
 
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
 
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
 
if (table instanceof RowValuesTable) {
 
((JLabel) comp).setHorizontalAlignment(SwingConstants.RIGHT);
RowValuesTableModel model = ((RowValuesTable) table).getRowValuesTableModel();
SQLRowValues rowVals = model.getRowValuesAt(row);
 
Number qte = (Number) rowVals.getObject("QTE");
Number qteL = (Number) rowVals.getObject("QTE_LIVREE");
if (qte != null && qteL != null) {
if (qte.intValue() < qteL.intValue()) {
comp.setBackground(red);
} else if (qteL.intValue() <= 0) {
comp.setBackground(lightBlack);
} else if (qteL.intValue() != qte.intValue()) {
comp.setBackground(orange);
}
}
}
return comp;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ProductItemListTable.java
59,7 → 59,7
 
final List<SQLTableElement> list = new Vector<SQLTableElement>();
 
SQLTableElement product = new SQLTableElement(productItemTable.getField("ID_ARTICLE"));
final SQLTableElement product = new SQLTableElement(productItemTable.getField("ID_ARTICLE"));
list.add(product);
// Quantité
final SQLTableElement q = new SQLTableElement(productItemTable.getField("QTE"), Integer.class);
75,6 → 75,8
 
@Override
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
if (source.equals(product)) {
 
final Object object = row.getObject("ID_ARTICLE");
if (object == null) {
return null;
81,7 → 83,10
}
SQLRowAccessor r = row.getForeign("ID_ARTICLE");
return r.getForeignIDNumber("ID_UNITE_VENTE");
} else {
return row.getObject("ID_UNITE_VENTE");
}
}
 
});
product.addModificationListener(unit);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ProductQtyPriceListTable.java
121,7 → 121,8
 
// Prix de vente HT de la métrique 1
final SQLField field = e.getTable().getField("PRIX_METRIQUE_VT_1");
final DeviseNumericHTConvertorCellEditor editorPVHT = new DeviseNumericHTConvertorCellEditor(field);
// final DeviseNumericHTConvertorCellEditor editorPVHT = new
// DeviseNumericHTConvertorCellEditor(field);
this.tableElementVenteHT = new SQLTableElement(field, BigDecimal.class);
list.add(tableElementVenteHT);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductHelper.java
137,16 → 137,21
public Map<Long, BigDecimal> getUnitCost(Map<Long, Integer> productQties, TypePrice type) {
final Map<Long, BigDecimal> result = new HashMap<Long, BigDecimal>();
 
String fieldPrice = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR ? "PRIX_ACHAT_DEVISE_F" : "PRIX");
String fieldDate = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR ? "DATE_PRIX" : "DATE");
String fieldPrice = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR || type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP ? "PRIX_ACHAT_DEVISE_F" : "PRIX");
String fieldDate = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR || type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP ? "DATE_PRIX" : "DATE");
 
// get all costs
final SQLTable costTable = root.getTable(type.name());
final SQLTable costTable = root.getTable(type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP ? "ARTICLE_TARIF_FOURNISSEUR" : type.name());
final SQLSelect sel = new SQLSelect();
sel.addSelect(costTable.getKey());
sel.addSelect(costTable.getField("ID_ARTICLE"));
sel.addSelect(costTable.getField("QTE"));
sel.addSelect(costTable.getField(fieldPrice));
if (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP) {
for (SupplierPriceField f : SupplierPriceField.values()) {
sel.addSelect(costTable.getField(f.name()));
}
}
sel.addSelect(costTable.getField(fieldDate));
sel.setWhere(new Where(costTable.getField("ID_ARTICLE"), true, productQties.keySet()));
sel.addFieldOrder(costTable.getField("QTE"));
158,6 → 163,9
System.out.println(sqlRow.getID() + ":" + sqlRow.getAllValues());
}
final int size = l.size();
if (size == 0 && type == TypePrice.ARTICLE_PRIX_REVIENT) {
return getUnitCost(productQties, TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP);
} else {
for (Long id : productQties.keySet()) {
BigDecimal cost = BigDecimal.ZERO;
final int qty = productQties.get(id);
167,11 → 175,19
// stop when the max qty is found
if (row.getLong("QTE") > qty) {
if (cost == null) {
if (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP) {
cost = getEnumPrice(row, SupplierPriceField.COEF_TRANSPORT_SIEGE);
} else {
cost = row.getBigDecimal(fieldPrice);
}
}
break;
}
if (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP) {
cost = getEnumPrice(row, SupplierPriceField.COEF_TRANSPORT_SIEGE);
} else {
cost = row.getBigDecimal(fieldPrice);
}
 
}
}
183,6 → 199,7
}
return result;
}
}
 
/**
*
210,8 → 227,12
final Map<Integer, BigDecimal> qtyParent = new HashMap<Integer, BigDecimal>();
for (ProductComponent p : items) {
parentsArticleIDs.add(p.getProduct().getID());
qtyParent.put(p.getProduct().getID(), p.getQty());
BigDecimal qty = BigDecimal.ZERO;
if (qtyParent.get(p.getProduct().getID()) != null) {
qty = qtyParent.get(p.getProduct().getID());
}
qtyParent.put(p.getProduct().getID(), qty.add(p.getQty()));
}
 
// get all childs
final SQLTable costTable = root.getTable("ARTICLE_ELEMENT");
240,8 → 261,9
if (childs.size() > 0) {
 
for (SQLRowValues childRowValues : childs) {
final SQLRowAccessor foreignArticleParent = childRowValues.getForeign("ID_ARTICLE_PARENT");
 
final SQLRowAccessor foreignArticleParent = childRowValues.getForeign("ID_ARTICLE_PARENT");
if (!childRowValues.isForeignEmpty("ID_ARTICLE") && childRowValues.getForeign("ID_ARTICLE") != null) {
ProductComponent childComponent = ProductComponent.createFrom(childRowValues);
// Test pour éviter les boucles dans les boms
if (!ancestors.contains(childComponent.getProduct().getID())) {
260,6 → 282,7
}
}
}
}
 
// Recherche si un kit est présent parmis les articles
final List<ProductComponent> bomFromChilds = getChildWithQtyFrom(new ArrayList(result), ancestors);
334,7 → 357,7
}
 
public enum TypePrice {
ARTICLE_PRIX_REVIENT, ARTICLE_PRIX_MIN_VENTE, ARTICLE_PRIX_PUBLIC, ARTICLE_TARIF_FOURNISSEUR
ARTICLE_PRIX_REVIENT, ARTICLE_PRIX_MIN_VENTE, ARTICLE_PRIX_PUBLIC, ARTICLE_TARIF_FOURNISSEUR, ARTICLE_TARIF_FOURNISSEUR_DDP
};
 
public BigDecimal getBomPriceForQuantity(int qty, Collection<? extends SQLRowAccessor> rowValuesProductItems, TypePrice type) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ReferenceArticleSQLComponent.java
42,6 → 42,7
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.DecimalUtils;
399,7 → 400,32
panel.setOpaque(false);
GridBagConstraints c = new DefaultGridBagConstraints();
 
c.weightx = 0;
JLabel labelEco = new JLabel(getLabelFor("ID_ECO_CONTRIBUTION"));
c.fill = GridBagConstraints.BOTH;
panel.add(labelEco, c);
c.weightx = 1;
c.gridx++;
ElementComboBox box = new ElementComboBox();
panel.add(box, c);
 
c.weightx = 0;
c.gridy++;
c.gridx = 0;
JLabel labelTaxeCompl = new JLabel(getLabelFor("ID_TAXE_COMPLEMENTAIRE"));
c.fill = GridBagConstraints.BOTH;
panel.add(labelTaxeCompl, c);
c.weightx = 1;
c.gridx++;
ElementComboBox boxTaxeCompl = new ElementComboBox();
panel.add(boxTaxeCompl, c);
 
c.gridy++;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
TitledSeparator sep = new TitledSeparator(getLabelFor("INFOS"));
panel.add(sep, c);
c.gridy++;
c.weighty = 1;
ITextArea infos = new ITextArea();
c.fill = GridBagConstraints.BOTH;
406,7 → 432,8
panel.add(infos, c);
 
this.addSQLObject(infos, "INFOS");
 
this.addSQLObject(box, "ID_ECO_CONTRIBUTION");
this.addSQLObject(boxTaxeCompl, "ID_TAXE_COMPLEMENTAIRE");
return panel;
}
 
537,7 → 564,7
panel.setOpaque(false);
GridBagConstraints c = new DefaultGridBagConstraints();
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
boolean gestionStockMin = prefs.getBoolean("ArticleStockMin", true);
boolean gestionStockMin = prefs.getBoolean(GestionArticleGlobalPreferencePanel.WARNING_STOCK_MIN, true);
c.gridx = 0;
c.gridy++;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/calculator_selected.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar_retour.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar_menu.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/especes.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar_list.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/cheque.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/cb.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/calculator.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/search.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/StatusBar.java
18,37 → 18,18
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
 
import javax.swing.ImageIcon;
import javax.swing.JPanel;
 
public class StatusBar extends JPanel {
private Image bg;
private Image bg_retour;
 
private String title = "";
 
private boolean previous;
private int offsetX = 110;
 
StatusBar() {
this("toolbar.png", "toolbar_retour.png");
}
 
StatusBar(String fileBg, String fileFg) {
bg = new ImageIcon(TicketPanel.class.getResource(fileBg)).getImage();
bg_retour = new ImageIcon(TicketPanel.class.getResource(fileFg)).getImage();
public StatusBar() {
setFont(new Font("Arial", Font.BOLD, 24));
}
 
public void setPrevious(boolean b) {
if (b != previous) {
this.previous = b;
repaint();
}
}
 
public void setTitle(String t) {
if (this.title == null || !this.title.equals(t)) {
this.title = t;
56,24 → 37,14
}
}
 
void setTitleLocation(int x) {
offsetX = x;
}
 
@Override
protected void paintComponent(Graphics g) {
final int w = this.getWidth();
int imWidth = bg.getWidth(null);
for (int x = imWidth - 1; x <= w; x += imWidth) {
g.drawImage(bg, x, 0, null);
}
if (previous)
g.drawImage(bg_retour, 0, 0, null);
else
g.drawImage(bg, 0, 0, null);
g.setColor(CaissePanel.LIGHT_BLUE);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int w = (int) g.getFontMetrics().getStringBounds(title, g).getWidth();
g.setColor(new Color(250, 250, 250));
g.drawString(title, offsetX, 30);
g.drawString(title, (this.getWidth() - w) / 2, 30);
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/SoldePaiementPanel.java
New file
0,0 → 1,244
/*
* 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.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.model.Paiement;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.ParseException;
import java.util.Locale;
 
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.text.NumberFormatter;
 
public class SoldePaiementPanel extends JPanel {
 
private JFormattedTextField textField;
private JRadioButton bCB;
private JRadioButton bCheque;
private JRadioButton bEspece;
 
public SoldePaiementPanel() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Label
c.insets = new Insets(14, 5, 5, 5);
this.add(new POSLabel("Montant"), c);
 
// Textfield
final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("##0.00", new DecimalFormatSymbols(Locale.ENGLISH)));
formatter.setAllowsInvalid(false);
textField = new JFormattedTextField(formatter);
textField.setHorizontalAlignment(JTextField.RIGHT);
textField.setFont(textField.getFont().deriveFont(20f));
textField.setMargin(new Insets(5, 5, 5, 5));
textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height));
c.gridx++;
c.insets = new Insets(14, 5, 5, 0);
this.add(textField, c);
// Reset
c.gridx++;
c.insets = new Insets(14, 0, 5, 5);
final JButton b = new JButton("C");
b.setBackground(CaissePanel.LIGHT_BLUE);
b.setForeground(Color.WHITE);
b.setFont(b.getFont().deriveFont(18f));
b.setFocusPainted(false);
b.setPreferredSize(new Dimension(64, 40));
b.setFocusable(false);
b.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
textField.setValue(null);
 
}
});
this.add(b, c);
 
c.gridx++;
//
c.gridwidth = 3;
c.gridx = 1;
c.gridy++;
c.weighty = 1;
bCB = createRadioButton("CB");
bCB.setFocusable(false);
bCB.setSelected(true);
this.add(bCB, c);
c.gridy++;
bCheque = createRadioButton("Chèque");
bCheque.setFocusable(false);
this.add(bCheque, c);
c.gridy++;
bEspece = createRadioButton("Espèce");
bEspece.setFocusable(false);
this.add(bEspece, c);
ButtonGroup g = new ButtonGroup();
g.add(bCB);
g.add(bCheque);
g.add(bEspece);
// Calculator
c.gridx = 4;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 4;
c.insets = new Insets(0, 0, 0, 0);
this.add(createCalculatorPanel(), c);
this.setBackground(Color.WHITE);
}
 
private JRadioButton createRadioButton(String string) {
JRadioButton b = new JRadioButton(string);
b.setFont(b.getFont().deriveFont(20f));
b.setOpaque(false);
b.setFocusable(false);
return b;
}
 
JPanel createCalculatorPanel() {
JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
JButton b7 = createButton("7");
p.add(b7, c);
c.gridx++;
JButton b8 = createButton("8");
p.add(b8, c);
c.gridx++;
JButton b9 = createButton("9");
p.add(b9, c);
//
c.gridx = 0;
c.gridy++;
JButton b4 = createButton("4");
p.add(b4, c);
c.gridx++;
JButton b5 = createButton("5");
p.add(b5, c);
c.gridx++;
JButton b6 = createButton("6");
p.add(b6, c);
 
//
c.gridx = 0;
c.gridy++;
JButton b1 = createButton("1");
p.add(b1, c);
c.gridx++;
JButton b2 = createButton("2");
p.add(b2, c);
c.gridx++;
JButton b3 = createButton("3");
p.add(b3, c);
//
c.gridx = 0;
c.gridy++;
JButton b0 = createButton("0");
c.gridwidth = 2;
p.add(b0, c);
c.gridx += 2;
c.gridwidth = 1;
JButton bPoint = createButton(".");
 
p.add(bPoint, c);
p.setBackground(CaissePanel.LIGHT_BLUE);
p.setFocusable(false);
return p;
}
 
private JButton createButton(final String string) {
final JButton b = new JButton(string);
b.setBackground(CaissePanel.DARK_BLUE);
b.setForeground(Color.WHITE);
b.setFont(b.getFont().deriveFont(20f));
b.setBorderPainted(false);
// b.setContentAreaFilled(false);
b.setFocusPainted(false);
b.setPreferredSize(new Dimension(64, 64));
b.setFocusable(false);
b.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final char c = string.charAt(0);
textField.grabFocus();
textField.dispatchEvent(new KeyEvent(textField, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, c));
 
}
});
return b;
}
 
public BigDecimal getAmount() {
try {
this.textField.commitEdit();
BigDecimal m = new BigDecimal(((Number) this.textField.getValue()).doubleValue());
return m;
} catch (ParseException e) {
e.printStackTrace();
return null;
}
 
}
 
public int getPaymentType() {
if (bCB.isSelected()) {
return Paiement.CB;
}
if (bCheque.isSelected()) {
return Paiement.CHEQUE;
}
if (bEspece.isSelected()) {
return Paiement.ESPECES;
}
throw new IllegalStateException("Unable to compute payment type");
}
 
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
final JFrame jFrame = new JFrame();
jFrame.setUndecorated(true);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setContentPane(new SoldePaiementPanel());
jFrame.pack();
 
jFrame.setVisible(true);
}
});
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/POSRadioButton.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.sales.pos.ui;
 
import java.awt.Font;
 
import javax.swing.Icon;
import javax.swing.JRadioButton;
 
public class POSRadioButton extends JRadioButton {
public POSRadioButton(String text, Icon icon, boolean selected) {
super(text, icon, selected);
customize();
}
 
public POSRadioButton(String text) {
super(text);
customize();
}
 
public void customize() {
final Font f = getFont().deriveFont(20f);
this.setFont(f);
this.setOpaque(false);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ConfigCaissePanel.java
39,6 → 39,8
import java.util.List;
import java.util.Vector;
 
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
55,6 → 57,7
 
public class ConfigCaissePanel extends JPanel {
 
private final POSConfiguration configuration = POSConfiguration.getInstance();
private int userId;
private int societeId;
private int caisseId;
70,7 → 73,8
private final TicketPrinterConfigPanel ticketPanel1;
private final TicketPrinterConfigPanel ticketPanel2;
// LCD
private JTextField textLCDSerialPort;
private JComboBox comboLCDType;
private JTextField textLCDPort;
private JTextField textLCDLine1;
private JTextField textLCDLine2;
 
89,8 → 93,8
c.gridwidth = 3;
c.weightx = 1;
JTextField textConfigurationFile = new JTextField("");
if (POSConfiguration.getConfigFile() != null) {
textConfigurationFile.setText(POSConfiguration.getConfigFile().getAbsolutePath());
if (this.configuration.getConfigFile() != null) {
textConfigurationFile.setText(this.configuration.getConfigFile().getAbsolutePath());
}
textConfigurationFile.setEditable(false);
this.add(textConfigurationFile, c);
252,13 → 256,25
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
c.fill = GridBagConstraints.NONE;
p.add(new JLabel("Port série", SwingConstants.RIGHT), c);
p.add(new JLabel("Type", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
comboLCDType = new JComboBox(new String[] { "Port série", "Emulation imprimante" });
 
p.add(comboLCDType, c);
c.gridy++;
c.gridx = 0;
c.anchor = GridBagConstraints.EAST;
final JLabel labelType = new JLabel("Port", SwingConstants.RIGHT);
p.add(labelType, c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
 
this.textLCDSerialPort = new JTextField(20);
p.add(this.textLCDSerialPort, c);
this.textLCDPort = new JTextField(20);
p.add(this.textLCDPort, c);
c.weightx = 0;
c.gridx++;
final JButton selectPortButton = new JButton("Sélectionner");
269,22 → 285,33
List<String> choices = new ArrayList<String>();
final String title;
final String message;
 
if (comboLCDType.getSelectedIndex() == 1) {
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
for (PrintService printer : printServices) {
choices.add(printer.getName());
}
title = "Afficheur LCD";
message = "Choisissez l'imprimante correspondante à l'afficheur LCD";
} else if (comboLCDType.getSelectedIndex() == 0) {
choices.addAll(ESCSerialPrinter.getSerialPortNames());
title = "Port série";
message = "Choisissez le port série lié à l'afficheur";
message = "Choisissez le port série lié à l'afficheur LCD";
} else {
return;
}
if (choices.isEmpty()) {
return;
}
String s = (String) JOptionPane.showInputDialog(p, message, title, JOptionPane.PLAIN_MESSAGE, null, choices.toArray(), choices.get(0));
 
// If a string was returned
if ((s != null) && (s.length() > 0)) {
textLCDSerialPort.setText(s);
textLCDPort.setText(s);
}
 
}
});
p.add(selectPortButton, c);
//
 
c.gridx = 0;
c.gridy++;
429,11 → 456,18
 
public void loadConfiguration() {
 
final POSConfiguration configuration = POSConfiguration.getInstance();
final POSConfiguration configuration = this.configuration;
// Terminal CB
this.textTerminalCB.setText(configuration.getCreditCardPort());
// Afficheur LCD
this.textLCDSerialPort.setText(configuration.getLCDSerialPort());
final String lcdType = configuration.getLCDType();
if (lcdType.equals("serial")) {
this.comboLCDType.setSelectedIndex(0);
} else {
this.comboLCDType.setSelectedIndex(1);
}
 
this.textLCDPort.setText(configuration.getLCDPort());
this.textLCDLine1.setText(configuration.getLCDLine1());
this.textLCDLine2.setText(configuration.getLCDLine2());
 
562,7 → 596,7
}
 
public void saveConfiguration() {
POSConfiguration configuration = POSConfiguration.getInstance();
final POSConfiguration configuration = this.configuration;
this.ticketPanel1.commitValues();
this.ticketPanel2.commitValues();
configuration.setUserID(this.userId);
573,7 → 607,13
// Terminal CB
configuration.setCreditCardPort(this.textTerminalCB.getText());
// LCD
configuration.setLCDSerialPort(this.textLCDSerialPort.getText());
final int selectedIndex = this.comboLCDType.getSelectedIndex();
if (selectedIndex == 0) {
configuration.setLCDType("serial");
} else {
configuration.setLCDType("printer");
}
configuration.setLCDPort(this.textLCDPort.getText());
configuration.setLCDLine1(this.textLCDLine1.getText());
configuration.setLCDLine2(this.textLCDLine2.getText());
// Save
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ListeDesClientsPanel.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.sales.pos.ui;
 
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.RoundingMode;
import java.util.Vector;
 
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.model.Client;
import org.openconcerto.ui.DefaultListModel;
import org.openconcerto.ui.touch.ScrollableList;
 
public class ListeDesClientsPanel extends JPanel {
 
private ScrollableList clientList;
private DefaultListModel ticketLlistModel;
 
ListeDesClientsPanel(final CaisseFrame caisseFrame) {
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 1;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
 
final StatusBar p = new StatusBar();
p.setTitle("Liste des clients");
p.setLayout(new FlowLayout(FlowLayout.RIGHT));
final POSButton bBack = new POSButton("Fermer");
p.add(bBack);
this.add(p, c);
 
// Liste des clients
c.gridy++;
c.gridwidth = 1;
c.weighty = 1;
c.gridheight = 2;
 
ticketLlistModel = new DefaultListModel();
ticketLlistModel.addAll(new Vector<Client>(POSConfiguration.getInstance().allClients()));
final Font f = new Font("Arial", Font.PLAIN, 24);
clientList = new ScrollableList(ticketLlistModel) {
@Override
public void paintCell(Graphics g, Object object, int index, boolean isSelected, int posY) {
g.setFont(f);
 
if (isSelected) {
g.setColor(new Color(232, 242, 254));
} else {
g.setColor(Color.WHITE);
}
g.fillRect(0, posY, getWidth(), getCellHeight());
 
//
g.setColor(Color.GRAY);
g.drawLine(0, posY + this.getCellHeight() - 1, this.getWidth(), posY + this.getCellHeight() - 1);
 
if (isSelected) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Client client = (Client) object;
String label = client.getFullName();
final int soldeInCents = client.getSolde().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
String euro = TicketCellRenderer.centsToString(soldeInCents) + "€";
 
int wEuro = (int) g.getFontMetrics().getStringBounds(euro, g).getWidth();
g.drawString(label, 10, posY + 24);
g.drawString(euro, getWidth() - 5 - wEuro, posY + 24);
 
final String addr = client.getAddr();
if (addr != null) {
g.drawString(addr, 10, posY + 48);
}
}
};
this.add(clientList, c);
 
// Detail
c.fill = GridBagConstraints.BOTH;
c.gridx++;
c.gridheight = 1;
c.weighty = 1;
c.insets = new Insets(10, 10, 10, 10);
 
final DetailClientPanel detailClientPanel = new DetailClientPanel(caisseFrame);
this.add(detailClientPanel, c);
 
clientList.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
Client selectedValue = (Client) clientList.getSelectedValue();
detailClientPanel.setSelectedClient(selectedValue);
}
});
 
bBack.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.showCaisse();
 
}
});
 
}
 
public void setSelectedClient(Object selectedValue) {
clientList.setSelectedValue(selectedValue, true);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/DetailClientPanel.java
New file
0,0 → 1,245
/*
* 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.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.TicketPrinterConfiguration;
import org.openconcerto.erp.core.sales.pos.io.TicketPrinter;
import org.openconcerto.erp.core.sales.pos.model.Client;
import org.openconcerto.erp.core.sales.pos.model.Transaction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.DefaultListModel;
import org.openconcerto.ui.touch.ScrollableList;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
import com.ibm.icu.text.DateFormat;
 
public class DetailClientPanel extends JPanel {
private CaisseFrame caisseFrame;
 
DetailClientPanel(CaisseFrame f) {
this.caisseFrame = f;
this.setOpaque(false);
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
final JPanel filler = new JPanel();
filler.setOpaque(false);
this.add(filler, c);
}
 
public void setSelectedClient(final Client client) {
 
this.removeAll();
this.invalidate();
final Font f = new Font("Arial", Font.PLAIN, 24);
GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0;
final JLabel label = new JLabel(client.getFullName());
label.setFont(f);
this.add(label, c);
c.gridy++;
final JLabel labelTransaction = new JLabel("Transactions");
labelTransaction.setFont(f);
this.add(labelTransaction, c);
c.gridy++;
//
c.weighty = 1;
this.add(createTransactionList(client), c);
//
 
c.fill = GridBagConstraints.NONE;
c.weighty = 0;
c.gridy++;
final JButton bCredit = new POSButton("Créditer le compte");
this.add(bCredit, c);
 
//
c.gridy++;
c.anchor = GridBagConstraints.EAST;
c.insets = new Insets(20, 20, 5, 2);
final JButton bSelect = new POSButton("Sélectionner ce client");
this.add(bSelect, c);
 
this.validate();
this.repaint();
 
// Listeners
bCredit.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
TransparentPanel tP = new TransparentPanel(caisseFrame);
//
JPanel p = new JPanel();
p.setBackground(Color.WHITE);
p.setLayout(new GridBagLayout());
GridBagConstraints constraints = new DefaultGridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
constraints.insets = new Insets(20, 20, 20, 20);
constraints.gridwidth = 2;
constraints.weightx = 1;
POSLabel label = new POSLabel(client.getFullName());
p.add(label, constraints);
constraints.gridy++;
 
final SoldePaiementPanel soldePanel = new SoldePaiementPanel();
p.add(soldePanel, constraints);
constraints.gridwidth = 1;
constraints.gridy++;
constraints.gridx = 0;
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.EAST;
POSButton bC = new POSButton("Créditer");
p.add(bC, constraints);
bC.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
try {
final BigDecimal amount = soldePanel.getAmount();
final int paymentType = soldePanel.getPaymentType();
client.credit(amount, paymentType);
final BigDecimal nouveauSolde = client.getSolde();
final Thread t = new Thread(new Runnable() {
 
@Override
public void run() {
final TicketPrinterConfiguration conf1 = POSConfiguration.getInstance().getTicketPrinterConfiguration1();
if (conf1.isValid()) {
final TicketPrinter prt = conf1.createTicketPrinter();
final int ticketWidth = conf1.getTicketWidth();
client.printCredit(prt, ticketWidth, amount, paymentType, nouveauSolde);
}
 
}
});
t.setDaemon(true);
t.start();
caisseFrame.showClients();
} catch (Exception e1) {
ExceptionHandler.handle("Erreur lors du crédit", e1);
}
 
}
});
constraints.gridx++;
constraints.weightx = 0;
POSButton bClose = new POSButton("Fermer");
p.add(bClose, constraints);
bClose.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.showClients();
}
});
//
tP.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = 1;
c.gridheight = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
tP.add(p, c);
caisseFrame.invalidate();
caisseFrame.setContentPane(tP);
caisseFrame.validate();
caisseFrame.repaint();
 
}
});
bSelect.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.setClient(client);
caisseFrame.showCaisse();
}
});
}
 
private Component createTransactionList(Client client) {
final DefaultListModel ticketLlistModel = new DefaultListModel();
final List<Transaction> transactions = client.getTransactions();
final Font f = new Font("Arial", Font.PLAIN, 24);
if (transactions.isEmpty()) {
final JPanel p = new JPanel();
p.setBackground(Color.WHITE);
p.setLayout(new BorderLayout());
final JLabel label = new JLabel("Aucune transaction pour le moment");
label.setFont(f);
label.setForeground(Color.GRAY);
p.add(label, BorderLayout.NORTH);
return p;
}
 
ticketLlistModel.addAll(transactions);
 
final ScrollableList clientList = new ScrollableList(ticketLlistModel) {
@Override
public void paintCell(Graphics g, Object object, int index, boolean isSelected, int posY) {
g.setFont(f);
g.setColor(Color.WHITE);
g.fillRect(0, posY, getWidth(), getCellHeight());
 
//
g.setColor(Color.GRAY);
g.drawLine(0, posY + this.getCellHeight() - 1, this.getWidth(), posY + this.getCellHeight() - 1);
 
if (isSelected) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Transaction client = (Transaction) object;
String label = DateFormat.getDateTimeInstance().format(client.getDate());
final int soldeInCents = client.getAmount().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
String euro = TicketCellRenderer.centsToString(soldeInCents) + "€";
 
int wEuro = (int) g.getFontMetrics().getStringBounds(euro, g).getWidth();
g.drawString(label, 10, posY + 24);
g.drawString(euro, getWidth() - 5 - wEuro, posY + 24);
 
}
};
return clientList;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TransparentPanel.java
New file
0,0 → 1,53
/*
* 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.sales.pos.ui;
 
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Robot;
import java.awt.image.BufferedImage;
 
import javax.swing.JPanel;
 
public class TransparentPanel extends JPanel {
private BufferedImage screenShot;
 
public TransparentPanel(Frame frame) {
try {
final Robot robot = new Robot();
screenShot = robot.createScreenCapture(frame.getBounds());
final Graphics2D graphics = screenShot.createGraphics();
// sets a 65% translucent composite
final AlphaComposite alpha = AlphaComposite.SrcOver.derive(0.65f);
graphics.setComposite(alpha);
// fills the background
graphics.setColor(Color.BLACK);
graphics.fillRect(0, 0, screenShot.getWidth(), screenShot.getHeight());
graphics.dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
 
@Override
protected void paintComponent(Graphics g) {
if (screenShot != null) {
g.drawImage(screenShot, 0, 0, null);
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PriceEditorPanel.java
New file
0,0 → 1,247
/*
* 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.sales.pos.ui;
 
import org.openconcerto.erp.core.common.ui.NumericTextField;
import org.openconcerto.erp.core.sales.pos.model.Article;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
 
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
public class PriceEditorPanel extends JPanel {
CaisseFrame frame;
private POSLabel labelPrice;
private Article article;
final POSRadioButton rHT, rTTC, rDiscountPercent, rDiscount;
private NumericTextField htTextField;
private NumericTextField ttcTextField;
private NumericTextField discountPercentTextField;
private NumericTextField discountTextField;
 
public PriceEditorPanel(final CaisseFrame caisseFrame, final Article article) {
this.article = article;
this.frame = caisseFrame;
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.EAST;
c.weightx = 0;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.insets = new Insets(20, 20, 30, 20);
// Line 1
c.gridwidth = 2;
POSLabel title = new POSLabel("Modification du prix de vente");
this.add(title, c);
// Line 2
c.gridy++;
c.gridwidth = 1;
rHT = new POSRadioButton("prix HT");
rHT.setSelected(true);
c.weightx = 0;
this.add(rHT, c);
htTextField = new NumericTextField();
htTextField.setValue(article.getPriceWithoutTax());
htTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(htTextField, c);
// Line 3
c.gridy++;
rTTC = new POSRadioButton("prix TTC");
htTextField.setValue(article.getPriceWithTax());
c.gridx = 0;
c.weightx = 0;
this.add(rTTC, c);
ttcTextField = new NumericTextField();
ttcTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(ttcTextField, c);
// Line 4
c.gridy++;
rDiscountPercent = new POSRadioButton("remise en %");
c.gridx = 0;
c.weightx = 0;
this.add(rDiscountPercent, c);
discountPercentTextField = new NumericTextField();
discountPercentTextField.setValue(BigDecimal.ZERO);
discountPercentTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(discountPercentTextField, c);
// Line 5
rDiscount = new POSRadioButton("remise HT");
c.gridx = 0;
c.weightx = 0;
c.gridy++;
this.add(rDiscount, c);
discountTextField = new NumericTextField();
discountTextField.setValue(BigDecimal.ZERO);
discountTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(discountTextField, c);
 
final ButtonGroup group = new ButtonGroup();
group.add(rHT);
group.add(rTTC);
group.add(rDiscountPercent);
group.add(rDiscount);
//
//
c.gridy++;
c.gridx = 0;
c.gridwidth = 2;
final POSLabel labelPriceOld = new POSLabel("Ancien Prix : ");
final BigDecimal ttc = Article.computePriceWithTax(this.article.getPriceWithoutTax(), this.article.getIdTaxe());
ttcTextField.setValue(ttc);
labelPriceOld.setText("Ancien Prix : " + TicketCellRenderer.toString(this.article.getPriceWithoutTax()) + " HT, " + TicketCellRenderer.toString(ttc));
this.add(labelPriceOld, c);
 
c.gridy++;
c.gridx = 0;
labelPrice = new POSLabel("Nouveau Prix : ");
this.add(labelPrice, c);
 
c.gridy++;
c.gridx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.SOUTHEAST;
 
final JPanel buttons = new JPanel();
buttons.setOpaque(false);
POSButton bApply = new POSButton("Appliquer");
buttons.add(bApply, c);
POSButton bCancel = new POSButton("Annuler");
buttons.add(bCancel, c);
bApply.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.getControler().setArticleHT(article, getHTFromUI());
caisseFrame.showCaisse();
}
});
bCancel.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.showCaisse();
}
});
 
this.add(buttons, c);
updatePrice(article.getPriceWithoutTax());
updateTextFields();
//
final ActionListener listenerRadio = new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
updatePrice(getHTFromUI());
 
updateTextFields();
 
}
};
this.rDiscount.addActionListener(listenerRadio);
this.rDiscountPercent.addActionListener(listenerRadio);
this.rHT.addActionListener(listenerRadio);
this.rTTC.addActionListener(listenerRadio);
 
final DocumentListener docListener = new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void changedUpdate(DocumentEvent e) {
updatePrice(getHTFromUI());
}
};
this.ttcTextField.getDocument().addDocumentListener(docListener);
this.htTextField.getDocument().addDocumentListener(docListener);
this.discountPercentTextField.getDocument().addDocumentListener(docListener);
this.discountTextField.getDocument().addDocumentListener(docListener);
}
 
protected BigDecimal getHTFromUI() {
BigDecimal r = null;
try {
if (this.rHT.isSelected()) {
r = this.htTextField.getValue();
} else if (this.rTTC.isSelected()) {
r = Article.computePriceWithoutTax(this.ttcTextField.getValue(), this.article.getIdTaxe());
} else if (this.rDiscountPercent.isSelected()) {
r = this.article.getPriceWithoutTax().subtract(this.article.getPriceWithoutTax().multiply(this.discountPercentTextField.getValue().divide(new BigDecimal(100))));
} else if (this.rDiscount.isSelected()) {
r = this.article.getPriceWithoutTax().subtract(this.discountTextField.getValue());
}
} catch (Exception e) {
e.printStackTrace();
}
if (r == null) {
// fallback if something wrong
r = this.article.getPriceWithoutTax();
}
return r;
}
 
void updatePrice(BigDecimal ht) {
BigDecimal ttc = Article.computePriceWithTax(ht, this.article.getIdTaxe());
labelPrice.setText("Nouveau Prix : " + TicketCellRenderer.toString(ht) + " HT, " + TicketCellRenderer.toString(ttc));
}
 
public void updateTextFields() {
this.invalidate();
htTextField.setVisible(false);
ttcTextField.setVisible(false);
discountPercentTextField.setVisible(false);
discountTextField.setVisible(false);
if (rHT.isSelected()) {
htTextField.setVisible(true);
} else if (rTTC.isSelected()) {
ttcTextField.setVisible(true);
} else if (rDiscountPercent.isSelected()) {
discountPercentTextField.setVisible(true);
} else if (rDiscount.isSelected()) {
discountTextField.setVisible(true);
}
this.validate();
repaint();
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ArticleSearchPanel.java
18,6 → 18,7
import org.openconcerto.ui.touch.ScrollableList;
 
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
25,14 → 26,16
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
 
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
55,11 → 58,12
final FilteredListModel model = new FilteredListModel();
final Font f1 = new Font("Arial", Font.PLAIN, 24);
final Font f2 = new Font("Arial", Font.PLAIN, 16);
setBackground(CaissePanel.LIGHT_BLUE);
list = new ScrollableList(model) {
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.GRAY);
g.setColor(CaissePanel.LIGHT_BLUE);
g.drawLine(0, 0, 0, this.getHeight());
}
 
80,14 → 84,21
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
StatusBar bar = new StatusBar("toolbar.png", "toolbar_list.png");
bar.addMouseListener(new MouseAdapter() {
final StatusBar bar = new StatusBar();
final POSButton bSwitch = new POSButton("-");
bSwitch.setForeground(Color.WHITE);
bSwitch.setBackground(CaissePanel.DARK_BLUE);
bar.setLayout(new FlowLayout(FlowLayout.LEFT));
bar.add(bSwitch);
bSwitch.addActionListener(new ActionListener() {
 
@Override
public void mousePressed(MouseEvent e) {
public void actionPerformed(ActionEvent e) {
controler.switchListMode();
 
}
});
bar.setPrevious(true);
 
bar.setTitle("Articles");
c.fill = GridBagConstraints.BOTH;
c.gridwidth = 2;
111,6 → 122,7
c.weightx = 0;
this.add(label, c);
final JTextField textField = new JTextField();
textField.setBorder(BorderFactory.createLineBorder(CaissePanel.DARK_BLUE, 1));
textField.setFont(f1);
c.weightx = 1;
c.gridx++;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseControler.java
19,11 → 19,13
import org.openconcerto.erp.core.sales.pos.io.ESCSerialDisplay;
import org.openconcerto.erp.core.sales.pos.io.TicketPrinter;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.Client;
import org.openconcerto.erp.core.sales.pos.model.Paiement;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.utils.Pair;
 
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
38,6 → 40,7
private Article articleSelected;
private Paiement paiementSelected;
private Ticket t;
private Client client = Client.NONE;
private List<CaisseListener> listeners = new ArrayList<CaisseListener>();
 
private final BarcodeReader r;
45,7 → 48,7
private Paiement p2 = new Paiement(Paiement.CB);
private Paiement p3 = new Paiement(Paiement.CHEQUE);
private final CaisseFrame caisseFrame;
private final ESCSerialDisplay lcd;
private final POSDisplay lcd;
 
public CaisseControler(CaisseFrame caisseFrame) {
this.caisseFrame = caisseFrame;
58,7 → 61,11
this.r = new BarcodeReader(POSConfiguration.getInstance().getScanDelay());
this.r.start();
this.r.addBarcodeListener(this);
lcd = new ESCSerialDisplay(POSConfiguration.getInstance().getLCDSerialPort());
if (POSConfiguration.getInstance().getLCDType().equals("serial")) {
lcd = new ESCSerialDisplay(POSConfiguration.getInstance().getLCDPort());
} else {
lcd = new PrinterPOSDisplay(POSConfiguration.getInstance().getLCDPort());
}
this.setLCDDefaultDisplay(0);
}
 
96,6 → 103,24
this.listeners.add(l);
}
 
// Customer
public void setClient(Client client) {
if (client == null) {
throw new IllegalArgumentException("Customer cannot be null");
}
this.client = client;
this.t.setClient(client);
fire();
}
 
public boolean isClientDefined() {
return this.client != Client.NONE;
}
 
public Client getClient() {
return client;
}
 
// Articles
void addArticle(Article a) {
this.t.addArticle(a);
136,6 → 161,12
}
 
public void setPaiementValue(Paiement p, int v) {
if (p.getType() == Paiement.SOLDE) {
int soldeInCents = getClient().getSolde().movePointRight(2).intValue();
if (v > soldeInCents) {
v = soldeInCents;
}
}
p.setMontantInCents(v);
fire();
this.setLCD("Paiement " + p.getTypeAsString().replace('è', 'e').replace('é', 'e'), TicketCellRenderer.centsToString(p.getMontantInCents()), 0);
173,6 → 204,7
 
@Override
public void barcodeRead(String code) {
System.err.println("CaisseControler.barcodeRead() " + code);
if (code.equalsIgnoreCase("especes")) {
autoFillPaiement(this.p1);
 
216,8 → 248,14
}
 
void autoFillPaiement(Paiement p) {
int montant = p.getMontantInCents();
p.setMontantInCents(getTotal() - getPaidTotal() + montant);
int nouveauMontant = getTotal() - getPaidTotal() + p.getMontantInCents();
if (p.getType() == Paiement.SOLDE) {
int soldeInCents = getClient().getSolde().movePointRight(2).intValue();
if (nouveauMontant > soldeInCents) {
nouveauMontant = soldeInCents;
}
}
p.setMontantInCents(nouveauMontant);
setPaiementSelected(p);
this.setLCD("Paiement " + p.getTypeAsString(), TicketCellRenderer.centsToString(p.getMontantInCents()), 0);
this.setLCDDefaultDisplay(3);
274,7 → 312,7
this.t.addPaiement(this.p3);
this.setPaiementSelected(null);
this.setArticleSelected(null);
 
client = Client.NONE;
}
}
}
306,7 → 344,7
}
 
public void switchListMode() {
caisseFrame.t.switchListMode();
caisseFrame.mainPanel.switchListMode();
 
}
 
373,4 → 411,34
}
 
}
 
public void setArticleHT(Article article, BigDecimal ht) {
Article existingArticle = null;
final List<Pair<Article, Integer>> articles = t.getArticles();
for (Pair<Article, Integer> pair : articles) {
final Article a = pair.getFirst();
if (a.getId() == article.getId()) {
if (article.getPriceWithoutTax().doubleValue() == a.getPriceWithoutTax().doubleValue()) {
existingArticle = a;
break;
}
}
}
if (existingArticle != null) {
existingArticle.updatePriceWithoutTax(ht);
fire();
}
}
 
public void openPriceEditor(Article article) {
caisseFrame.showPriceEditor(article, this);
}
 
public void enableBarcodeReader() {
this.r.setEnabled(true);
}
 
public void disableBarcodeReader() {
this.r.setEnabled(false);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TicketCellRenderer.java
26,6 → 26,7
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.math.BigDecimal;
import java.math.RoundingMode;
 
import javax.swing.JLabel;
38,6 → 39,7
 
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
@SuppressWarnings("unchecked")
Pair<Article, Integer> item = (Pair<Article, Integer>) value;
JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
57,7 → 59,8
c.gridx++;
c.weightx = 0;
 
final JLabel l3 = new JLabel(centsToString(article.getPriceWithTax().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()), SwingConstants.RIGHT);
final BigDecimal priceWithTax = article.getPriceWithTax();
final JLabel l3 = new JLabel(toString(priceWithTax), SwingConstants.RIGHT);
p.add(l3, c);
 
//
116,8 → 119,10
if (c < 10) {
sc = "0" + sc;
}
 
return cents / 100 + "." + sc;
}
 
public static String toString(final BigDecimal p) {
return centsToString(p.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseMenuPanel.java
13,36 → 13,25
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;
 
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
public class CaisseMenuPanel extends JPanel implements ListSelectionListener {
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.JImage;
 
private JList l;
public class CaisseMenuPanel extends JPanel {
 
private CaisseFrame frame;
private Image bg;
 
CaisseMenuPanel(CaisseFrame caisseFrame) {
this.frame = caisseFrame;
49,66 → 38,61
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.NONE;
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 1;
c.weighty = 1;
c.weightx = 0;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
final Font font = new Font("Arial", Font.PLAIN, 46);
l = new JList(new String[] { "Retour", "", "Liste des tickets", "Clôturer", "", "Fermer le logiciel", "" });
l.setCellRenderer(new ListCellRenderer() {
c.insets = new Insets(20, 20, 30, 20);
final JImage image = new JImage(ComptaBasePropsConfiguration.class.getResource("logo.png"));
this.add(image, c);
c.gridx++;
 
final POSButton bTickets = new POSButton("Liste des tickets");
this.add(bTickets, c);
c.gridy++;
final POSButton bCloture = new POSButton("Clôturer");
this.add(bCloture, c);
c.gridy++;
c.insets = new Insets(20, 20, 20, 20);
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
final POSButton bQuit = new POSButton("Quitter");
bQuit.setBackground(Color.decode("#AD1457"));
this.add(bQuit, c);
// Listeners
bTickets.addActionListener(new ActionListener() {
 
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel l = new JLabel(value.toString()) {
@Override
public void paint(Graphics g) {
 
super.paint(g);
 
g.setColor(Color.LIGHT_GRAY);
g.drawLine(0, 0, this.getWidth(), 0);
public void actionPerformed(ActionEvent e) {
try {
frame.showTickets(null);
} catch (Exception ex) {
ExceptionHandler.handle("Erreur", ex);
}
};
l.setFont(font);
return l;
}
 
});
l.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
l.getSelectionModel().addListSelectionListener(this);
bCloture.addActionListener(new ActionListener() {
 
l.setFixedCellHeight(80);
this.add(l, c);
bg = new ImageIcon(TicketPanel.class.getResource("toolbar.png")).getImage();
setFont(new Font("Arial", Font.BOLD, 24));
}
 
@Override
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting()) {
return;
}
public void actionPerformed(ActionEvent e) {
try {
final int selectedIndex = l.getSelectedIndex();
switch (selectedIndex) {
case 0:
// Retour
frame.showCaisse();
break;
case 2:
// Liste des tickets
frame.showTickets(null);
break;
case 3:
// Clôture
 
frame.getControler().setLCD("Cloture", "En cours...", 0);
POSConfiguration.getInstance().commitAll(POSConfiguration.getInstance().allTickets());
frame.getControler().setLCD("Cloture", "Terminee", 0);
break;
case 5:
} catch (Exception ex) {
ExceptionHandler.handle("Erreur", ex);
}
}
});
bQuit.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
try {
// Fermeture
frame.getControler().setLCD(" CAISSE FERMEE ", "", 0);
frame.dispose();
123,30 → 107,12
System.err.println(thread.getName() + " " + thread.getId() + " not daemon");
}
}
break;
default:
break;
}
} catch (Exception ex) {
ExceptionHandler.handle("Erreur", ex);
}
}
});
 
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
final int w = this.getWidth();
int imWidth = bg.getWidth(null);
for (int x = 0; x <= w; x += imWidth) {
g.drawImage(bg, x, 0, null);
}
 
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(new Color(250, 250, 250));
String str = "Menu Principal";
 
Rectangle2D r = g.getFontMetrics().getStringBounds(str, g);
int x = (int) (this.getWidth() - r.getWidth()) / 2;
g.drawString(str, x, 30);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PaiementPanel.java
13,7 → 13,6
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.io.ConcertProtocol;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.Paiement;
 
22,24 → 21,25
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;
import java.util.List;
 
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
 
public class PaiementPanel extends JPanel implements CaisseListener, MouseListener, BarcodeListener {
private static final int OFFSETY = 50;
private static final int LINE_HEIGHT = 64;
private Image bg, bg2, bgCB, bgCHEQUE, bgESPECES;
private static final int PAYMENT_POS_Y = 50;
private static final int PAYMENT_LINE_HEIGHT = 60;
 
private CaisseControler controller;
private String calculatorValue = "";
 
int calcHeight = 5 * 68;
int calcWidth = 4 * 69;
int BUTTON_SIZE = 64;
/**
* Mode '+' ajout d'une quantité '*' multiplication '-' soustraction ' ' remplacement
*/
51,11 → 51,7
this.controller.addCaisseListener(this);
this.controller.addBarcodeListener(this);
this.setOpaque(false);
bg = new ImageIcon(TicketPanel.class.getResource("calculator.png")).getImage();
bg2 = new ImageIcon(TicketPanel.class.getResource("calculator_selected.png")).getImage();
bgCB = new ImageIcon(TicketPanel.class.getResource("cb.png")).getImage();
bgCHEQUE = new ImageIcon(TicketPanel.class.getResource("cheque.png")).getImage();
bgESPECES = new ImageIcon(TicketPanel.class.getResource("especes.png")).getImage();
 
this.addMouseListener(this);
 
this.setLayout(null);
70,51 → 66,85
 
@Override
public void paint(Graphics g) {
g.setColor(Color.BLACK);
Graphics2D g2 = (Graphics2D) g;
g.setColor(new Color(250, 250, 250));
g.fillRect(0, 0, this.getWidth(), this.getHeight());
int y = this.getHeight() - this.bg.getHeight(null);
if (controller.getArticleSelected() != null || controller.getPaiementSelected() != null) {
g.drawImage(bg2, 0, y, null);
} else {
g.drawImage(bg, 0, y, null);
}
 
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawLine(0, 0, 0, this.getHeight());
y = OFFSETY;
int y = PAYMENT_POS_Y;
for (Paiement p : controller.getPaiements()) {
if (p.getType() == Paiement.CB) {
g.drawImage(bgCB, 0, y, null);
drawMontant(g, p, 242, y);
drawMontant(g, "CB", p, 242 - 15, y, true);
} else if (p.getType() == Paiement.CHEQUE) {
g.drawImage(bgCHEQUE, 0, y, null);
drawMontant(g, p, 242, y);
drawMontant(g, "Chèque", p, 242 - 15, y, true);
} else if (p.getType() == Paiement.ESPECES) {
g.drawImage(bgESPECES, 0, y, null);
drawMontant(g, p, 300, y);
drawMontant(g, "Espèces", p, 300 - 45, y, false);
} else if (p.getType() == Paiement.SOLDE) {
drawMontant(g, "Solde", p, 300 - 45, y, false);
}
y += LINE_HEIGHT;
y += PAYMENT_LINE_HEIGHT;
}
 
drawKey(g2, "0", 0, 0, 2, 1, CaissePanel.DARK_BLUE);
drawKey(g2, ".", 2, 0, 1, 1, CaissePanel.DARK_BLUE);
 
drawKey(g2, "1", 0, 1, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "2", 1, 1, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "3", 2, 1, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "=", 3, 1, 1, 2, CaissePanel.DARK_BLUE);
 
drawKey(g2, "4", 0, 2, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "5", 1, 2, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "6", 2, 2, 1, 1, CaissePanel.DARK_BLUE);
 
drawKey(g2, "7", 0, 3, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "8", 1, 3, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "9", 2, 3, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "+", 3, 3, 1, 2, CaissePanel.DARK_BLUE);
 
drawKey(g2, "C", 0, 4, 2, 1, CaissePanel.LIGHT_BLUE);
drawKey(g2, "x", 2, 4, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "-", 3, 4, 1, 1, CaissePanel.DARK_BLUE);
 
drawCalculator(g);
if (Boolean.getBoolean("sales.pos.debug")) {
drawGrid(g);
}
super.paint(g);
}
 
private void drawGrid(Graphics g) {
g.setColor(Color.RED);
for (int x = 0; x < 320; x += 80) {
for (int y = 28; y < 900; y += 72) {
g.drawLine(x, y, x + 2, y + 2);
private void drawKey(Graphics2D g2, String string, int col, int row, int w, int h, Color color) {
// background
g2.setColor(color);
g2.fillRect(3 + col * 69, this.getHeight() - (68 * (row + 1)) + 2, 69 * w - 5, 68 * h - 4);
// label
g2.setColor(Color.WHITE);
g2.setFont(g2.getFont().deriveFont(32f));
final int width2 = (int) g2.getFontMetrics().getStringBounds(string, g2).getWidth();
int x = -width2 / 2 + (69) / 2 + col * 69;
int y = this.getHeight() - (row * 68 + 20);
 
g2.drawString(string, x, y);
}
 
public int getLCDY() {
return this.getHeight() - this.calcHeight - 66;
}
 
public int getLCDHeight() {
return 64;
}
 
private void drawCalculator(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
int y = this.getHeight() - this.bg.getHeight(null);
 
// LCD
if (controller.getArticleSelected() != null || controller.getPaiementSelected() != null) {
g.setColor(new Color(232, 242, 254));
} else {
g.setColor(new Color(240, 240, 240));
}
g.fillRect(3, getLCDY(), this.getWidth() - 5, getLCDHeight());
//
int y = this.getHeight() - this.calcHeight - 10;
g.setFont(new Font("Arial", Font.PLAIN, 32));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final Article article = controller.getArticleSelected();
123,7 → 153,7
String string = calculatorValue;
g.setFont(g.getFont().deriveFont(52f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(string, g2);
g.drawString(string, (int) (260 - r1.getWidth()), 500 + y);
g.drawString(string, (int) (260 - r1.getWidth()), y);
g.setFont(g.getFont().deriveFont(14f));
g.drawString("Quantité", 10, 460 + y);
 
133,7 → 163,7
String string = calculatorValue;
g.setFont(g.getFont().deriveFont(52f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(string, g2);
g.drawString(string, (int) (300 - r1.getWidth()), 500 + y);
g.drawString(string, (int) (260 - r1.getWidth()), y);
g.setFont(g.getFont().deriveFont(14f));
String str = "Paiement ";
if (paiement.getType() == Paiement.CB) {
142,17 → 172,19
str += " en espèces";
} else if (paiement.getType() == Paiement.CHEQUE) {
str += " par chèque";
} else if (paiement.getType() == Paiement.SOLDE) {
str += " depuis solde";
}
g.drawString(str, 10, 460 + y);
g.drawString(str, 10, y - 40);
}
}
g.setFont(g.getFont().deriveFont(14f));
g.drawString("" + mode, 10, 480 + y);
g.drawString("" + mode, 10, y - 20);
}
 
private char getToucheFrom(int x, int y) {
int yy = (this.getHeight() - y) / 72;
int xx = x / 80;
int yy = (this.getHeight() - y) / 68;
int xx = x / 69;
switch (yy) {
case 0:
if (xx == 0) {
219,13 → 251,36
return '?';
}
 
private void drawMontant(Graphics g, Paiement p, int x, int y) {
private void drawMontant(Graphics g, String label, Paiement p, int x, int y, boolean showAdd) {
y = y + 36;
Graphics2D g2 = (Graphics2D) g;
g.setColor(Color.GRAY);
 
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int cents = p.getMontantInCents() % 100;
int euros = p.getMontantInCents() / 100;
// Background
g.setColor(new Color(240, 240, 240));
g.fillRect(3, y - 36, this.getWidth() - 5, 44);
 
g.setColor(CaissePanel.DARK_BLUE);
 
g.fillRect(3, y - 36, 95, 44);
 
if (showAdd) {
g.setColor(CaissePanel.DARK_BLUE);
g.fillRect(this.getWidth() - 46, y - 36, 44, 44);
}
// Label
g.setFont(g.getFont().deriveFont(20f));
g.setFont(g.getFont().deriveFont(Font.BOLD));
 
g.setColor(Color.WHITE);
g.drawString(label, 10, y - 8);
if (showAdd) {
g.drawString("+", this.getWidth() - 32, y - 8);
}
// Cents
g.setColor(Color.GRAY);
String sCents = String.valueOf(cents);
if (sCents.length() < 2) {
sCents = "0" + sCents;
233,10 → 288,10
g.setFont(getFont().deriveFont(18f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(sCents, g2);
g.drawString(sCents, (int) (x - r1.getWidth()), y);
//
// Euros
g.setFont(g.getFont().deriveFont(36f));
g.setFont(g.getFont().deriveFont(Font.BOLD));
g.setColor(Color.WHITE);
g.setColor(Color.BLACK);
String sEuros = String.valueOf(euros) + ".";
Rectangle2D r2 = g.getFontMetrics().getStringBounds(sEuros, g2);
g.drawString(sEuros, (int) (x - r1.getWidth() - r2.getWidth()), y);
244,13 → 299,11
 
@Override
public Dimension getPreferredSize() {
 
return new Dimension(320, 900);
return new Dimension(calcWidth, 768);
}
 
public Dimension getMinimumSize() {
 
return new Dimension(320, 900);
return new Dimension(calcWidth, 768);
}
 
@Override
260,7 → 313,33
} else if (controller.getPaiementSelected() != null) {
initCaissePaiement();