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/.classpath
38,5 → 38,7
<classpathentry kind="lib" path="lib/json-smart-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/icu4j-56_1-module_format+calendar.jar"/>
<classpathentry kind="lib" path="lib/icu4j-56-data-western_europe.jar"/>
<classpathentry kind="lib" path="lib/DS_Desktop_Notify.jar"/>
<classpathentry kind="lib" path="lib/mime_util.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/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/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/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/jOpenCalendar.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/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/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/utils/CollectionUtils.java
373,7 → 373,7
}
 
static public <C extends Collection<?>> boolean containsAny(final C coll1, final C coll2) {
return org.apache.commons.collections.CollectionUtils.containsAny(coll1, coll2);
return !Collections.disjoint(coll1, coll2);
}
 
static public final <T> boolean identityContains(final Collection<T> coll, final T item) {
403,6 → 403,63
}
 
/**
* Cast list
*
* @param <E> type of result list
* @param list the list to convert
* @param c the class of the result list
* @return a new ArrayList create from <code>list</code> or null if <code>list</code> is null
* @throws ClassCastException if some item of <code>list</code> is not a <code>E</code>.
*/
public static <E> List<E> castList(final List<?> list, Class<E> c) throws ClassCastException {
if (list == null) {
return null;
}
 
final List<E> result = new ArrayList<E>();
for (int i = 0; i < list.size(); i++) {
result.add(c.cast(list.get(i)));
}
return result;
}
 
/**
* Cast Map
*
* @param <E> type of key
* @param <F> type of value
* @param map the map to convert
* @param cKey the class of key
* @param cValue the class of value
* @return a new HashMap create from the <code>map</code> or null if <code>map</code> is null
* @throws ClassCastException if some item of <code>map</code> have a key which the type is not
* a <code>E</code> or a value which the type is not a <code>F</code>.
*/
public static <E, F> Map<E, F> castMap(final Map<?, ?> map, Class<E> cKey, Class<F> cValue) throws ClassCastException {
if (map == null) {
return null;
}
 
final Map<E, F> result = new HashMap<E, F>();
for (final Entry<?, ?> mapEntry : map.entrySet()) {
final E key;
try {
key = cKey.cast(mapEntry.getKey());
} catch (final ClassCastException ex) {
throw new ClassCastException("Key " + mapEntry.getKey().toString() + " is not valid: " + ex.getMessage());
}
final F value;
try {
value = cValue.cast(mapEntry.getValue());
} catch (final ClassCastException ex) {
throw new ClassCastException("Value " + mapEntry.getKey().toString() + " is not valid: " + ex.getMessage());
}
result.put(key, value);
}
return result;
}
 
/**
* The number of equals item between a and b, starting from the end.
*
* @param <T> type of items.
776,6 → 833,20
}
}
 
public static <T> List<T> createList(T item1, T item2) {
final List<T> res = new ArrayList<T>();
res.add(item1);
res.add(item2);
return res;
}
 
// workaround for lack of @SafeVarargs in Java 6, TODO use Arrays.asList() in Java 7
public static <T> List<T> createList(T item1, T item2, T item3) {
final List<T> res = createList(item1, item2);
res.add(item3);
return res;
}
 
public static <T> Set<T> createSet(T... items) {
return new HashSet<T>(Arrays.asList(items));
}
/trunk/OpenConcerto/src/org/openconcerto/utils/Nombre.java
13,293 → 13,62
package org.openconcerto.utils;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
 
import com.ibm.icu.text.MessageFormat;
import com.ibm.icu.text.RuleBasedNumberFormat;
 
/**
* @author ilm
*
* @deprecated use {@link RuleBasedNumberFormat#SPELLOUT} or {@link MessageFormat} with
* <code>"{1,spellout}"</code>. To write currency amount :
* https://www.thebalance.com/write-numbers-using-words-4083198
* http://icu-project.org/docs/papers/a_rule_based_approach_to_number_spellout/
* http://icu-project.org/apiref/icu4j/com/ibm/icu/text/RuleBasedNumberFormat.html
*/
public class Nombre {
private int nb;
 
static int[] puissanceMille = { 0, 1000, 1000000, 1000000000 };
public static int FR = 0;
public static int EN = 1;
public static int ES = 2;
public static int PL = 3;
private final NombreLocal local;
static private final Locale[] LOCALES = { Locale.FRENCH, Locale.ENGLISH, new Locale("es"), new Locale("pl") };
@Deprecated
static private final Map<Locale, String> DECIMAL_SEP;
 
static {
DECIMAL_SEP = new HashMap<Locale, String>();
DECIMAL_SEP.put(Locale.FRENCH, "et");
DECIMAL_SEP.put(Locale.ENGLISH, "and");
DECIMAL_SEP.put(LOCALES[2], "y");
DECIMAL_SEP.put(LOCALES[3], "i");
}
 
private int nb;
private final Locale locale;
private final RuleBasedNumberFormat format;
 
public Nombre(int i) {
this(i, FR);
}
 
public Nombre(int i, int language) {
this.nb = i;
if (language == EN) {
this.local = new NombreLocalEN();
} else if (language == PL) {
this.local = new NombreLocalPL();
} else if (language == ES) {
this.local = new NombreLocalES();
} else {
this.local = new NombreLocalFR();
this(i, LOCALES[language]);
}
}
 
public Nombre(int i, NombreLocal local) {
public Nombre(int i, Locale l) {
this.nb = i;
this.local = local;
this.locale = l;
this.format = new RuleBasedNumberFormat(l, RuleBasedNumberFormat.SPELLOUT);
}
 
public String getText() {
StringBuffer result = new StringBuffer();
if (this.nb < 0)
result.append(this.local.negatifLabel);
 
if (this.local.getNombrePredefini(this.nb) != null) {
result.append(this.local.getNombrePredefini(this.nb));
} else if (this.nb < 100) {
 
int decimal = this.nb / 10;
int unit = this.nb % 10;
 
result.append(this.local.getDizaine(decimal));
 
if (unit > 0) { // trente, quarante..
if (this.local.separateurDizaineLabel != null && this.local.separateurDizaineLabel.length() > 0) {
result.append(" " + this.local.separateurDizaineLabel);
return this.format.format(this.nb);
}
result.append(" " + this.local.getNombrePredefini(unit));
}
 
} else {
 
if (this.nb < 1000) {
 
int cent = this.nb / 100;
 
if (this.local.getNombrePredefini(cent * 100) != null) {
result.append(this.local.getNombrePredefini(cent * 100));
} else {
result.append(this.local.getNombrePredefini(cent) + " " + this.local.getDizaine(10));
public final String getSeparateurLabel() {
return DECIMAL_SEP.get(this.locale);
}
int reste = this.nb - (cent * 100);
if (reste > 0) {
Nombre d = new Nombre(reste, this.local);
if (this.local.separateurDizaineLabel != null && this.local.separateurDizaineLabel.length() > 0) {
result.append(" " + this.local.separateurDizaineLabel);
}
result.append(" " + d.getText());
}
} else {
 
int longueur = new Double(Math.ceil((String.valueOf(this.nb)).length() / 3.0)).intValue();
 
int cumul = 0;
for (int i = longueur - 1; i > 0; i--) {
int puissancei = puissanceMille[i];
int val = (this.nb - cumul) / puissancei;
if (val > 0) {
if (val > 1 && (i - 1) > 0) {
 
result.append(new Nombre(val, this.local).getText() + " " + this.local.getMult(i - 1) + "s ");
} else {
result.append(new Nombre(val, this.local).getText() + " " + this.local.getMult(i - 1) + " ");
}
}
cumul += val * puissancei;
}
 
int val = this.nb % 1000;
if (val > 0) {
result.append(new Nombre(val, this.local).getText());
}
}
}
 
System.err.println(result.toString().trim());
return result.toString().trim();
}
 
String getText(String r) {
 
return String.valueOf(r);
}
 
public NombreLocal getLocal() {
return local;
}
 
public class NombreLocal {
protected final Map<Integer, String> nombrePredefini = new HashMap<Integer, String>();
protected final List<String> dizaine = new ArrayList<String>();
protected final List<String> mult = new ArrayList<String>();
protected final String separateurLabel, separateurDizaineLabel, negatifLabel;
 
public NombreLocal(String sep, String sepDizaine, String neg) {
this.negatifLabel = neg;
this.separateurLabel = sep;
this.separateurDizaineLabel = sepDizaine;
}
 
public String getDizaine(int index) {
return dizaine.get(index);
}
 
public String getMult(int index) {
return mult.get(index);
}
 
public String getNombrePredefini(int value) {
return nombrePredefini.get(value);
}
 
public String getSeparateurLabel() {
return separateurLabel;
}
 
}
 
private class NombreLocalFR extends NombreLocal {
final String[] ref0 = { "zéro", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", "dix huit",
"dix neuf", "vingt" };
final String[] ref10 = { "zéro", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "soixante", "quatre vingt", "quatre vingt", "cent" };
final String[] refmult = { "mille", "million", "milliard", "billion", "trillion" };// 3,6,9,12,15
 
public NombreLocalFR() {
super("et", "", "moins");
for (int i = 0; i < ref0.length; i++) {
nombrePredefini.put(i, ref0[i]);
}
for (int i = 0; i < ref10.length; i++) {
dizaine.add(ref10[i]);
}
for (int i = 0; i < refmult.length; i++) {
mult.add(refmult[i]);
}
 
nombrePredefini.put(21, "vingt et un");
nombrePredefini.put(31, "trente et un");
nombrePredefini.put(41, "quarante et un");
nombrePredefini.put(51, "cinquante et un");
nombrePredefini.put(61, "soixante et un");
 
nombrePredefini.put(70, "soixante dix");
nombrePredefini.put(71, "soixante et onze");
nombrePredefini.put(72, "soixante douze");
nombrePredefini.put(73, "soixante treize");
nombrePredefini.put(74, "soixante quatorze");
nombrePredefini.put(75, "soixante quinze");
nombrePredefini.put(76, "soixante seize");
nombrePredefini.put(77, "soixante dix sept");
nombrePredefini.put(78, "soixante dix huit");
nombrePredefini.put(79, "soixante dix neuf");
 
nombrePredefini.put(90, "quatre vingt dix");
nombrePredefini.put(91, "quatre vingt onze");
nombrePredefini.put(92, "quatre vingt douze");
nombrePredefini.put(93, "quatre vingt treize");
nombrePredefini.put(94, "quatre vingt quatorze");
nombrePredefini.put(95, "quatre vingt quinze");
nombrePredefini.put(96, "quatre vingt seize");
nombrePredefini.put(97, "quatre vingt dix sept");
nombrePredefini.put(98, "quatre vingt dix huit");
nombrePredefini.put(99, "quatre vingt dix neuf");
 
nombrePredefini.put(100, "cent");
}
}
 
private class NombreLocalEN extends NombreLocal {
final String[] ref0 = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
"eighteen", "nineteen", "twenty" };
final String[] ref10 = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety", "hundred" };
 
final String[] refmult = { "thousand", "million", "billion", "billion", "trillion" };// 3,6,9,12,15
 
public NombreLocalEN() {
super("and", "", "moins");
for (int i = 0; i < ref0.length; i++) {
nombrePredefini.put(i, ref0[i]);
}
for (int i = 0; i < ref10.length; i++) {
dizaine.add(ref10[i]);
}
for (int i = 0; i < refmult.length; i++) {
mult.add(refmult[i]);
}
nombrePredefini.put(100, "one hundred");
}
}
 
private class NombreLocalPL extends NombreLocal {
final String[] ref0 = { "zero", "jeden", "dwa", "trzy", "cztery", "pięć", "sześć", "siedem", "osiem", "dziewięć", "diesięć", "jedenaście", "dwanaście", "trzynaście", "czternaście",
"piętnaście", "szesnaście", "siedemnaście", "osiemnaście", "dziewiętnaście", "dwadzieścia" };
final String[] ref10 = { "zero", "dziesięć", "dwadzieścia", "trzydzieści", "czterdzieści", "pięćdziesiąt", "sześćdziesiąt", "siedemdziesiąt", "osiemdziesiąt", "dziewięćdziesiąt", "sto" };
final String[] refmult = { "tysiąć", "milion", "miliard", "bilion", "trilion" };
 
public NombreLocalPL() {
super("i", "", "moins");
for (int i = 0; i < ref0.length; i++) {
nombrePredefini.put(i, ref0[i]);
}
for (int i = 0; i < ref10.length; i++) {
dizaine.add(ref10[i]);
}
for (int i = 0; i < refmult.length; i++) {
mult.add(refmult[i]);
}
nombrePredefini.put(100, "sto");
nombrePredefini.put(200, "dwiescie");
nombrePredefini.put(300, "trysta");
nombrePredefini.put(400, "czterysta");
nombrePredefini.put(500, "pięćdziesiąt");
nombrePredefini.put(600, "sześćdziesiąt");
nombrePredefini.put(700, "siedemdziesiąt");
nombrePredefini.put(800, "osiemdziesiąt");
nombrePredefini.put(900, "dziewięćdziesiąt");
}
}
 
private class NombreLocalES extends NombreLocal {
 
final String[] ref0 = { "cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", "trece", "catorce", "quince", "dieciseis", "diecisiete",
"dieciocho", "diecinueve", "veinte" };
final String[] ref10 = { "cero", "diez", "veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa", "cien" };
final String[] refmult = { "mil", "millón", "millar", "billón", "trillón" };
 
public NombreLocalES() {
super("y", "y", "moins");
for (int i = 0; i < ref0.length; i++) {
nombrePredefini.put(i, ref0[i]);
}
for (int i = 0; i < ref10.length; i++) {
dizaine.add(ref10[i]);
}
for (int i = 0; i < refmult.length; i++) {
mult.add(refmult[i]);
}
nombrePredefini.put(100, "cien");
nombrePredefini.put(21, "veintiuno");
nombrePredefini.put(22, "veintidos");
nombrePredefini.put(23, "veintitrés");
nombrePredefini.put(24, "veinticuatro");
nombrePredefini.put(25, "veinticinco");
nombrePredefini.put(26, "veintiséis");
nombrePredefini.put(27, "veintisiete");
nombrePredefini.put(28, "veintiocho");
nombrePredefini.put(29, "veintinueve");
nombrePredefini.put(200, "doscientos");
nombrePredefini.put(300, "trescientos");
nombrePredefini.put(400, "cuatrocientos");
nombrePredefini.put(500, "quinientos");
nombrePredefini.put(600, "seiscientos");
nombrePredefini.put(700, "setecientos");
nombrePredefini.put(800, "ochocientos");
nombrePredefini.put(900, "novecientos");
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/Zip.java
16,6 → 16,7
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
23,9 → 24,12
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.Enumeration;
import java.util.Set;
import java.util.zip.CRC32;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipOutputStream;
38,6 → 42,44
*/
public class Zip {
 
static public byte[] deflate(final String s) throws IOException {
return deflate(s.getBytes(StringUtils.UTF8));
}
 
static public byte[] deflate(final byte[] b) throws IOException {
final ByteArrayOutputStream bOut = new ByteArrayOutputStream();
final DeflaterOutputStream out = new DeflaterOutputStream(bOut);
out.write(b);
out.close();
return bOut.toByteArray();
}
 
static public ByteBuffer deflateToBuffer(final String s) throws IOException {
return ByteBuffer.wrap(deflate(s));
}
 
static public String inflateToString(final ByteBuffer payload) throws IOException {
return inflateToString(payload, payload.remaining());
}
 
static public String inflateToString(final ByteBuffer payload, final int length) throws IOException {
final byte[] b = new byte[length];
payload.get(b);
return inflateToString(b);
}
 
static public String inflateToString(final byte[] b) throws IOException {
return new String(inflate(b), StringUtils.UTF8);
}
 
static public byte[] inflate(final byte[] b) throws IOException {
final InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(b));
final ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamUtils.copy(in, out);
out.close();
return out.toByteArray();
}
 
/**
* Copie de from dans to seulement les entrées dont le nom n'est pas dans
* <code>excludedEntries</code>.
50,12 → 92,12
* @throws ZipException
* @throws IOException
*/
static public Zip createFrom(File from, File to, Set excludedEntries) throws ZipException, IOException {
static public Zip createFrom(File from, File to, Set<String> excludedEntries) throws ZipException, IOException {
Unzip unz = new Unzip(from);
Zip res = new Zip(to);
final Enumeration en = unz.entries();
final Enumeration<? extends ZipEntry> en = unz.entries();
while (en.hasMoreElements()) {
ZipEntry entry = (ZipEntry) en.nextElement();
final ZipEntry entry = en.nextElement();
if (!excludedEntries.contains(entry.getName())) {
res.zip(entry.getName(), unz.getInputStream(entry));
}
73,7 → 115,7
* @throws ZipException
* @throws IOException
*/
static public void delete(File src, Set entriesName, File dest) throws ZipException, IOException {
static public void delete(File src, Set<String> entriesName, File dest) throws ZipException, IOException {
if (dest.exists())
dest.delete();
createFrom(src, dest, entriesName).close();
/trunk/OpenConcerto/src/org/openconcerto/utils/Unzip.java
67,9 → 67,9
destDir = new File("");
destDir.mkdirs();
 
final Enumeration en = this.entries();
final Enumeration<? extends ZipEntry> en = this.entries();
while (en.hasMoreElements()) {
ZipEntry target = (ZipEntry) en.nextElement();
final ZipEntry target = en.nextElement();
unzip(destDir, target);
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/checks/ValidState.java
18,10 → 18,15
import java.util.LinkedHashMap;
import java.util.Map;
 
import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.Immutable;
 
@Immutable
public class ValidState {
 
static private final ValidState TRUE = new ValidState(true, null);
static private final ValidState FALSE = new ValidState(false, null);
@GuardedBy("cache")
static private final Map<String, ValidState> cache = new LinkedHashMap<String, ValidState>(32, 0.75f, true) {
@Override
protected boolean removeEldestEntry(java.util.Map.Entry<String, ValidState> eldest) {
74,6 → 79,7
} else if (reason == null) {
return FALSE;
} else if (cacheNonValid) {
synchronized (cache) {
ValidState res = cache.get(reason);
if (res == null) {
res = new ValidState(valid, reason);
80,6 → 86,7
cache.put(reason, res);
}
return res;
}
} else {
return new ValidState(valid, reason);
}
/trunk/OpenConcerto/src/org/openconcerto/utils/checks/EmptyObjFromVO.java
39,7 → 39,8
}
 
private static final IPredicate<Object> DEFAULT_PREDICATE = new IPredicate<Object>() {
public boolean evaluateChecked(Object object) {
@Override
public boolean evaluateChecked(final Object object) {
if (object instanceof String)
return ((String) object).length() == 0;
else
51,7 → 52,7
private final IPredicate<V> testEmptiness;
private final EmptyChangeSupport supp;
 
public EmptyObjFromVO(ValueObject<V> vo, IPredicate<V> testEmptiness) {
public EmptyObjFromVO(final ValueObject<V> vo, final IPredicate<V> testEmptiness) {
super();
 
this.vo = vo;
62,7 → 63,8
this.supp = new EmptyChangeSupport(this, this.isEmpty());
// ecoute les changements de notre cible pour décider si elle devient vide ou non
this.vo.addValueListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
valueChanged();
}
});
74,12 → 76,12
}
 
@Override
public void addEmptyListener(EmptyListener l) {
public void addEmptyListener(final EmptyListener l) {
this.supp.addEmptyListener(l);
}
 
@Override
public void removeEmptyListener(EmptyListener l) {
public void removeEmptyListener(final EmptyListener l) {
this.supp.removeEmptyListener(l);
}
 
/trunk/OpenConcerto/src/org/openconcerto/utils/model/ISearchable.java
26,7 → 26,8
* Change search.
*
* @param s the new search.
* @param r will be invoked after the search has been carried out.
* @param r will be invoked in the EDT after the search has been carried out, can be
* <code>null</code>.
* @return <code>true</code> if the search has changed, i.e. <code>s</code> has changed and
* {@link #isSearchable()} is <code>true</code>.
*/
/trunk/OpenConcerto/src/org/openconcerto/utils/StringUtils.java
355,10 → 355,15
static private final Pattern slashPatrn = Pattern.compile("(\\\\+)");
 
static public String doubleQuote(String s) {
return doubleQuote(s, true);
}
 
static public String doubleQuote(String s, final boolean escapeEscapeChar) {
// http://developer.apple.com/library/mac/#documentation/applescript/conceptual/applescriptlangguide/reference/ASLR_classes.html#//apple_ref/doc/uid/TP40000983-CH1g-SW6
// http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.5
// https://developer.mozilla.org/en/JavaScript/Guide/Values%2C_Variables%2C_and_Literals#Escaping_characters
if (s.length() > 0) {
if (escapeEscapeChar)
s = slashPatrn.matcher(s).replaceAll("$1$1");
s = quotePatrn.matcher(s).replaceAll("\\\\\"");
}
739,4 → 744,47
}
return new String(hexChars);
}
 
/**
* Whether the parameter is empty.
*
* @param s the string to test.
* @return <code>true</code> if <code>null</code> or {@link String#isEmpty() empty}.
*/
public static boolean isEmpty(final String s) {
return isEmpty(s, false);
}
 
public static boolean isEmpty(final String s, final boolean trim) {
return s == null || (trim ? s.trim() : s).isEmpty();
}
 
/**
* Return the first parameter that is non-empty.
*
* @param s1 the string to test.
* @param s2 the alternate value.
* @return <code>s1</code> if not <code>null</code> and not {@link String#isEmpty() empty},
* <code>s2</code> otherwise.
*/
public static String coalesce(String s1, String s2) {
return isEmpty(s1) ? s2 : s1;
}
 
/**
* Return the first value that is non-empty.
*
* @param values values to test for emptiness.
* @return the first value that is neither <code>null</code> nor {@link String#isEmpty() empty}.
*/
public static String coalesce(String... values) {
return coalesce(false, values);
}
 
public static String coalesce(final boolean trim, String... values) {
for (final String s : values)
if (!isEmpty(s, trim))
return s;
return null;
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/sync/SyncClient.java
554,7 → 554,7
 
/**
* @return true if the file exists and is retrieved :)
* */
*/
public void retrieveFile(File dir, String remotePath, String remoteName, String token) throws Exception {
 
// If the file exists or not, get the hashValues to compare the hash
616,7 → 616,17
 
if (needToResync) {
if (localFile.length() > HashWriter.BLOCK_SIZE) {
try {
retrieveFileWithDelta(localFile, remotePath, remoteName, token);
} catch (Exception e) {
System.err.println("SyncClient.retrieveFile() failed for " + remotePath + " " + remoteName);
System.err.println("SyncClient.retrieveFile() fallback to plain download");
downloadFile(localFile, remotePath, remoteName, fileSize, token);
byte[] fileLocalHash = HashWriter.getHash(localFile);
if (!HashWriter.compareHash(fileHash, fileLocalHash)) {
throw new IllegalStateException("Full download failed. Hash error");
}
}
} else {
downloadFile(localFile, remotePath, remoteName, fileSize, token);
byte[] fileLocalHash = HashWriter.getHash(localFile);
632,7 → 642,7
/**
* @param fileHash2
* @return true if the file exists and is retrieved :)
* */
*/
private void retrieveFileWithDelta(File localFile, String remotePath, String remoteName, String token) throws Exception {
 
// Construct data
/trunk/OpenConcerto/src/org/openconcerto/utils/DesktopEnvironment.java
18,13 → 18,20
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
import javax.swing.filechooser.FileSystemView;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
 
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
 
/**
* A desktop environment like Gnome or MacOS.
*
35,13 → 42,39
 
static public final class Gnome extends DesktopEnvironment {
 
static private final String getTextContent(final Element parentElem, final String childName) {
final NodeList children = parentElem.getElementsByTagName(childName);
if (children.getLength() != 1)
throw new IllegalStateException("Not one child " + childName + " in " + parentElem);
return children.item(0).getTextContent();
}
 
private final String name;
 
public Gnome(final String name) {
this.name = name;
}
 
@Override
protected String findVersion() {
try {
if (this.name.equals("gnome")) {
// e.g. GNOME gnome-about 2.24.1
final String line = cmdSubstitution(Runtime.getRuntime().exec(new String[] { "gnome-about", "--version" }));
final String[] words = line.split(" ");
return words[words.length - 1];
} else if (this.name.equals("gnome3")) {
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// <gnome-version>
// <platform>3</platform>
// <minor>18</minor>
// <micro>2</micro>
// </gnome-version>
final Element root = builder.parse(new File("/usr/share/gnome/gnome-version.xml")).getDocumentElement();
return getTextContent(root, "platform") + '.' + getTextContent(root, "minor") + '.' + getTextContent(root, "micro");
} else {
throw new IllegalStateException("unknown name : " + this.name);
}
} catch (Exception e) {
e.printStackTrace();
return null;
49,6 → 82,22
}
}
 
static public final class MATE extends DesktopEnvironment {
 
@Override
protected String findVersion() {
try {
// e.g. GNOME gnome-about 2.24.1
final String line = cmdSubstitution(Runtime.getRuntime().exec(new String[] { "mate-about", "--version" }));
final String[] words = line.split(" ");
return words[words.length - 1];
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
 
static public final class KDE extends DesktopEnvironment {
 
private static final Pattern versionPattern = Pattern.compile("^KDE: (.*)$", Pattern.MULTILINE);
71,13 → 120,23
}
 
static public final class XFCE extends DesktopEnvironment {
// xfce4-about 4.11.1 (Xfce 4.10)
// Copyright (c) 2008-2011
private static final Pattern versionPattern = Pattern.compile("^xfce4-about.+\\(\\p{Alnum}+\\p{Blank}+(.+)\\)$", Pattern.MULTILINE);
 
@Override
protected String findVersion() {
// TODO
return "";
try {
final String line = cmdSubstitution(Runtime.getRuntime().exec(new String[] { "xfce4-about", "--version" }));
final Matcher matcher = versionPattern.matcher(line);
matcher.find();
return matcher.group(1);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
 
static public final class Unknown extends DesktopEnvironment {
@Override
199,8 → 258,8
public File getAppDir(final String bundleID) throws IOException {
// we used to ask for the URL of the application file but since 10.7 it returns a
// file reference URL like "file:///.file/id=6723689.35865"
final ProcessBuilder processBuilder = new ProcessBuilder("osascript", "-e", "tell application id \"com.apple.Finder\" to POSIX path of (application file id \"" + bundleID
+ "\" as string)");
final ProcessBuilder processBuilder = new ProcessBuilder("osascript", "-e",
"tell application id \"com.apple.Finder\" to POSIX path of (application file id \"" + bundleID + "\" as string)");
// if not found prints nothing to out and a cryptic error to the standard error stream
final String dir = cmdSubstitution(processBuilder.start()).trim();
return dir.length() == 0 ? null : new File(dir);
238,6 → 297,33
return encoding == null ? out.toString() : out.toString(encoding.name());
}
 
private static final String detectXDG() {
String res = null;
InputStream scriptIns = null;
try {
scriptIns = DesktopEnvironment.class.getResourceAsStream("DesktopEnvironmentXDG.sh");
final Process ps = new ProcessBuilder("sh").start();
ps.getErrorStream().close();
StreamUtils.copy(scriptIns, ps.getOutputStream());
ps.getOutputStream().close();
res = FileUtils.readUTF8(ps.getInputStream()).trim();
ps.getInputStream().close();
if (ps.waitFor() != 0)
throw new IllegalStateException("Not OK : " + ps.exitValue());
} catch (Exception e) {
Log.get().fine(e.getLocalizedMessage());
} finally {
if (scriptIns != null) {
try {
scriptIns.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return res;
}
 
private static final DesktopEnvironment detectDE() {
final OSFamily os = OSFamily.getInstance();
if (os == OSFamily.Windows) {
245,24 → 331,16
} else if (os == OSFamily.Mac) {
return new Mac();
} else if (os instanceof Unix) {
// from redhat xdg-utils 1.0.2-14.20091016cvs
if ("true".equalsIgnoreCase(System.getenv("KDE_FULL_SESSION")))
final String de = detectXDG();
if (de.equals("xfce"))
return new XFCE();
else if (de.equals("mate"))
return new MATE();
else if (de.equals("kde"))
return new KDE();
else if (System.getenv("GNOME_DESKTOP_SESSION_ID") != null)
return new Gnome();
// the above variable is deprecated, the line below only works for newer gnome
else if (test("dbus-send", "--print-reply", "--dest=org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus.GetNameOwner", "string:org.gnome.SessionManager"))
return new Gnome();
else {
try {
final String saveMode = cmdSubstitution(Runtime.getRuntime().exec(new String[] { "xprop", "-root", "_DT_SAVE_MODE" }));
if (saveMode.endsWith(" = \"xfce4\""))
return new XFCE();
} catch (IOException e) {
Log.get().fine(e.getLocalizedMessage());
else if (de.startsWith("gnome"))
return new Gnome(de);
}
}
}
return new Unknown();
}
 
293,10 → 371,18
return this.version;
}
 
// where to write user-visible files (e.g. spreadsheets, exports)
public File getDocumentsFolder() {
return FileSystemView.getFileSystemView().getDefaultDirectory();
}
 
/**
* Where the configuration files are stored.
*
* @param appName the name of application.
* @return the preferences folder.
* @deprecated kept around to migrate existing files, but otherwise use {@link BaseDirs}.
*/
public File getPreferencesFolder(final String appName) {
return new File(System.getProperty("user.home"), "." + appName);
}
312,6 → 398,12
}
 
public static void main(String[] args) {
System.out.println(getDE() + " version " + getDE().getVersion());
// removes default
LogUtils.rmRootHandlers();
// add console handler
LogUtils.setUpConsoleHandler();
Log.get().setLevel(Level.FINE);
final DesktopEnvironment de = getDE();
System.out.println(de + " version " + de.getVersion());
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/convertor/ValueConvertorFactory.java
42,6 → 42,7
static {
convs = new ArrayList<ValueConvertor<?, ?>>();
convs.add(new DateTSConvertor());
convs.add(new DateToSQLConvertor());
convs.add(new DateToTimeConvertor());
convs.add(StringClobConvertor.INSTANCE);
convs.add(NumberConvertor.INT_TO_LONG);
/trunk/OpenConcerto/src/org/openconcerto/utils/convertor/DateToSQLConvertor.java
New file
0,0 → 1,29
/*
* 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.utils.convertor;
 
import java.util.Date;
 
public class DateToSQLConvertor extends NullIsNullConvertor<Date, java.sql.Date> {
 
@Override
protected java.sql.Date convertNonNull(Date o) {
return new java.sql.Date(o.getTime());
}
 
@Override
protected Date unconvertNonNull(java.sql.Date o) {
return o;
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/PEMImporter.java
New file
0,0 → 1,132
/*
* 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.utils;
 
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPrivateKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.ArrayList;
import java.util.List;
 
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLServerSocketFactory;
import javax.xml.bind.DatatypeConverter;
 
public class PEMImporter {
 
public static SSLServerSocketFactory createSSLFactory(File privateKeyPem, File certificatePem, String password) throws Exception {
final SSLContext context = SSLContext.getInstance("TLS");
final KeyStore keystore = createKeyStore(privateKeyPem, certificatePem, password);
final KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keystore, password.toCharArray());
final KeyManager[] km = kmf.getKeyManagers();
context.init(km, null, null);
return context.getServerSocketFactory();
}
 
/**
* Create a KeyStore from standard PEM files
*
* @param privateKeyPem the private key PEM file
* @param certificatePem the certificate(s) PEM file
* @param the password to set to protect the private key
*/
public static KeyStore createKeyStore(File privateKeyPem, File certificatePem, final String password)
throws Exception, KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
final X509Certificate[] cert = createCertificates(certificatePem);
final KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(null);
// Import private key
final PrivateKey key = createPrivateKey(privateKeyPem);
keystore.setKeyEntry(privateKeyPem.getName(), key, password.toCharArray(), cert);
return keystore;
}
 
private static PrivateKey createPrivateKey(File privateKeyPem) throws Exception {
final BufferedReader r = new BufferedReader(new FileReader(privateKeyPem));
String s = r.readLine();
if (s == null || !s.contains("BEGIN PRIVATE KEY")) {
r.close();
throw new IllegalArgumentException("No PRIVATE KEY found");
}
final StringBuffer b = new StringBuffer();
s = "";
while (s != null) {
if (s.contains("END PRIVATE KEY")) {
break;
}
b.append(s);
s = r.readLine();
}
r.close();
final String hexString = b.toString();
final byte[] bytes = DatatypeConverter.parseBase64Binary(hexString);
return generatePrivateKeyFromDER(bytes);
}
 
private static X509Certificate[] createCertificates(File certificatePem) throws Exception {
final List<X509Certificate> result = new ArrayList<X509Certificate>();
final BufferedReader r = new BufferedReader(new FileReader(certificatePem));
String s = r.readLine();
if (s == null || !s.contains("BEGIN CERTIFICATE")) {
r.close();
throw new IllegalArgumentException("No CERTIFICATE found");
}
StringBuffer b = new StringBuffer();
while (s != null) {
if (s.contains("END CERTIFICATE")) {
String hexString = b.toString();
final byte[] bytes = DatatypeConverter.parseBase64Binary(hexString);
X509Certificate cert = generateCertificateFromDER(bytes);
result.add(cert);
b = new StringBuffer();
} else {
if (!s.startsWith("----")) {
b.append(s);
}
}
s = r.readLine();
}
r.close();
 
return result.toArray(new X509Certificate[result.size()]);
}
 
private static RSAPrivateKey generatePrivateKeyFromDER(byte[] keyBytes) throws InvalidKeySpecException, NoSuchAlgorithmException {
final PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
final KeyFactory factory = KeyFactory.getInstance("RSA");
return (RSAPrivateKey) factory.generatePrivate(spec);
}
 
private static X509Certificate generateCertificateFromDER(byte[] certBytes) throws CertificateException {
final CertificateFactory factory = CertificateFactory.getInstance("X.509");
return (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(certBytes));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/utils/NumberUtils.java
277,9 → 277,10
return res;
}
 
public static int ensureInt(long l) {
// TODO use Math.toIntExact() in Java8
public static int ensureInt(long l) throws ArithmeticException {
if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
throw new IllegalArgumentException("long value " + String.valueOf(l) + " cannot be cast to int without changing its value.");
throw new ArithmeticException("long value " + String.valueOf(l) + " cannot be cast to int without changing its value.");
}
return (int) l;
}
/trunk/OpenConcerto/src/org/openconcerto/utils/io/JSONConverter.java
14,18 → 14,15
package org.openconcerto.utils.io;
 
import org.openconcerto.utils.NumberUtils;
import org.openconcerto.utils.XMLDateFormat;
 
import java.awt.Color;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.Format;
import java.util.Calendar;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Date;
 
import javax.xml.bind.DatatypeConverter;
 
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;
32,8 → 29,21
import net.minidev.json.parser.ParseException;
 
public class JSONConverter {
final static Pattern pattern = Pattern.compile("d{4}-[01]d-[0-3]dT[0-2]d:[0-5]d:[0-5]d.d+([+-][0-2]d:[0-5]d|Z)");
 
static private final Format DF = new XMLDateFormat();
 
static synchronized private final String format(final Date d) {
return DF.format(d);
}
 
public synchronized static String formatCalendar(final Calendar calendar) {
return DF.format(calendar);
}
 
static synchronized private final Date parse(final String s) throws java.text.ParseException {
return (Date) DF.parseObject(s);
}
 
public static Object getJSON(Object param) {
Object result = null;
 
42,12 → 52,10
result = ((HTMLable) param).getHTML();
} else if (param instanceof JSONAble) {
result = ((JSONAble) param).toJSON();
} else if (param instanceof Timestamp) {
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
result = df.format((Timestamp) param);
} else if (param instanceof Date) {
result = format((Date) param);
} else if (param instanceof Calendar) {
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
result = df.format(((Calendar) param).getTime());
result = formatCalendar(((Calendar) param));
} else if (param instanceof Class<?>) {
result = ((Class<?>) param).getName();
} else if (param instanceof Iterable) {
66,6 → 74,8
jsonColor.put("b", paramColor.getBlue());
result = jsonColor;
}
} else if (param instanceof BigDecimal) {
result = ((BigDecimal) param).doubleValue();
} else {
result = param;
}
74,90 → 84,61
return result;
}
 
public static <T extends Object> T getObjectFromJSON(final Object o, final Class<T> type) {
return getObjectFromJSON(o, type, null);
}
 
public static <T extends Object> T getObjectFromJSON(final Object o, final Class<T> type, final Object defaultValue) {
Object result = defaultValue;
 
public static <T> T getObjectFromJSON(final Object o, final Class<T> type) {
final T result;
if (o != null && !o.equals("null")) {
if (type.equals(Integer.class)) {
if (!o.getClass().isAssignableFrom(Long.class)) {
if (type.isInstance(o)) {
result = type.cast(o);
} else if (type.equals(Integer.class)) {
final int intVal;
if (o instanceof BigDecimal) {
intVal = ((BigDecimal) o).intValueExact();
} else if (o instanceof BigInteger) {
// TODO use intValueExact() in Java 8
final BigInteger bigInt = (BigInteger) o;
if (bigInt.compareTo(BigInteger.valueOf(Integer.MIN_VALUE)) < 0 || bigInt.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0)
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "'");
intVal = bigInt.intValue();
} else {
try {
result = NumberUtils.ensureInt((Long) o);
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "', " + ex.getMessage());
intVal = NumberUtils.ensureInt((Long) o);
} catch (ArithmeticException ex) {
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "'", ex);
}
}
result = type.cast(intVal);
} else if (type.equals(Date.class)) {
if (!o.getClass().isAssignableFrom(String.class)) {
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "'");
}
final String sparam = (String) o;
final Matcher matcher = pattern.matcher(sparam);
if (matcher.find()) {
final Calendar c = DatatypeConverter.parseDateTime(sparam);
result = c.getTime();
} else {
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "', the format is not valid");
try {
final Date c = parse(sparam);
result = type.cast(c);
} catch (java.text.ParseException e) {
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "', the format is not valid", e);
}
} else if (type.equals(Color.class)) {
final JSONObject jsonColor = (JSONObject) o;
final int r = JSONConverter.getParameterFromJSON(jsonColor, "r", Integer.class);
final int g = JSONConverter.getParameterFromJSON(jsonColor, "g", Integer.class);
final int b = JSONConverter.getParameterFromJSON(jsonColor, "b", Integer.class);
result = type.cast(new Color(r, g, b));
} else {
if (!o.getClass().isAssignableFrom(type)) {
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "'");
result = type.cast(o);
}
result = o;
}
} else {
result = null;
}
 
return (T) result;
return result;
}
 
public static <T extends Object> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type) {
public static <T> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type) {
return getParameterFromJSON(json, key, type, null);
}
 
public static <T extends Object> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type, Object defaultValue) {
Object o = defaultValue;
if (json.containsKey(key)) {
o = json.get(key);
if (o == null || o.equals("null")) {
o = null;
} else {
if (type.equals(Integer.class)) {
if (!o.getClass().isAssignableFrom(Long.class)) {
throw new IllegalArgumentException("value " + o + " for '" + key + "' is invalid");
} else {
try {
o = NumberUtils.ensureInt((Long) o);
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("value " + o + " for '" + key + "' is invalid, " + ex.getMessage());
public static <T> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type, T defaultValue) {
return json.containsKey(key) ? getObjectFromJSON(json.get(key), type) : defaultValue;
}
}
} else if (type.equals(Color.class)) {
if (!(o instanceof JSONObject)) {
throw new IllegalArgumentException("value " + o + " for '" + key + "' is invalid");
}
 
final JSONObject jsonColor = (JSONObject) o;
final int r = (Integer) JSONConverter.getParameterFromJSON(jsonColor, "r", Integer.class);
final int g = (Integer) JSONConverter.getParameterFromJSON(jsonColor, "g", Integer.class);
final int b = (Integer) JSONConverter.getParameterFromJSON(jsonColor, "b", Integer.class);
o = new Color(r, g, b);
} else {
if (!o.getClass().isAssignableFrom(type)) {
throw new IllegalArgumentException("value " + o + " for '" + key + "' is invalid");
}
}
}
}
return (T) o;
}
 
public static JSONObject convertStringToJsonObject(final String jsonString) {
final JSONParser parser = new JSONParser(JSONParser.USE_HI_PRECISION_FLOAT);
final JSONObject json;
179,20 → 160,4
}
return json;
}
 
// TODO move to another class
public static boolean listInstanceOf(Object object, Class<?> c) {
if (object instanceof List<?>) {
final List<?> list = (List<?>) object;
final int listSize = list.size();
for (int i = 0; i < listSize; i++) {
if (!c.isInstance(list.get(i))) {
return false;
}
}
} else {
return false;
}
return true;
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/FileUtils.java
930,8 → 930,8
}
 
/**
* Try to guess the media type of the passed file name (see <a
* href="http://www.iana.org/assignments/media-types">iana</a>).
* Try to guess the media type of the passed file name (see
* <a href="http://www.iana.org/assignments/media-types">iana</a>).
*
* @param fname a file name.
* @return its mime type.
973,8 → 973,9
*/
public static final Escaper FILENAME_ESCAPER = new StringUtils.Escaper('\'', 'Q');
 
static private final Pattern CONTROL_PATTERN = Pattern.compile("[\\p{IsCc}\\p{IsCf}]+");
static private final Pattern WS_PATTERN = Pattern.compile("\\p{javaWhitespace}+");
static private final String WS = "\\p{javaWhitespace}";
static private final Pattern WS_PATTERN = Pattern.compile(WS + "+");
static private final Pattern CONTROL_PATTERN = Pattern.compile("[\\p{IsCc}\\p{IsCf}&&[^" + WS + "]]+");
static private final Pattern INVALID_CHARS_PATTERN;
 
static {
995,9 → 996,10
* @return a name suitable for any file system.
*/
static public final String sanitize(String name) {
// remove all control and format characters
// remove control and format characters (except white spaces)
name = CONTROL_PATTERN.matcher(name).replaceAll("");
// only use spaces
// only use one regular space (must be done after removing control characters as if they are
// between spaces we want only one space to remain)
name = WS_PATTERN.matcher(name).replaceAll(" ");
// leading and trailing spaces are hard to see (and illegal in Explorer)
name = name.trim();
/trunk/OpenConcerto/src/org/openconcerto/utils/text/DocumentFilterList.java
199,10 → 199,11
@Override
public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
if (this.nextFilter == null) {
final String str = this.orig.getDocument().getText(offset, length);
if (!str.equals(text)) {
// don't try to optimise by comparing the replacing text to the replaced text as
// replace() does more than replace document content : it also change selection.
// E.g. if the text is "fo*o*bar" and "o" is input then the document content doesn't
// change but the selection should be cleared.
this.orig.replace(offset, length, text, attrs);
}
} else {
this.nextFilter.replace(this.next, offset, length, text, attrs);
}
/trunk/OpenConcerto/src/org/openconcerto/utils/text/SimpleDocumentFilter.java
31,33 → 31,36
INSERT, REMOVE, REPLACE
}
 
static public final String subString(Document doc, int offset) throws BadLocationException {
static public final String subString(final Document doc, final int offset) throws BadLocationException {
return doc.getText(offset, doc.getLength() - offset);
}
 
public static String computeInsertString(FilterBypass fb, int offset, String text) throws BadLocationException {
public static String computeInsertString(final FilterBypass fb, final int offset, final String text) throws BadLocationException {
return fb.getDocument().getText(0, offset) + text + subString(fb.getDocument(), offset);
}
 
public static String computeRemove(FilterBypass fb, int offset, int length) throws BadLocationException {
public static String computeRemove(final FilterBypass fb, final int offset, final int length) throws BadLocationException {
return fb.getDocument().getText(0, offset) + subString(fb.getDocument(), offset + length);
}
 
public static String computeReplace(FilterBypass fb, int offset, int length, String text) throws BadLocationException {
public static String computeReplace(final FilterBypass fb, final int offset, final int length, final String text) throws BadLocationException {
return fb.getDocument().getText(0, offset) + text + subString(fb.getDocument(), offset + length);
}
 
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
@Override
public void remove(final FilterBypass fb, final int offset, final int length) throws BadLocationException {
if (this.change(fb, computeRemove(fb, offset, length), Mode.REMOVE))
super.remove(fb, offset, length);
}
 
public void insertString(FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException {
@Override
public void insertString(final FilterBypass fb, final int offset, final String text, final AttributeSet attr) throws BadLocationException {
if (this.change(fb, computeInsertString(fb, offset, text), Mode.INSERT))
super.insertString(fb, offset, text, attr);
}
 
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
@Override
public void replace(final FilterBypass fb, final int offset, final int length, final String text, final AttributeSet attrs) throws BadLocationException {
if (this.change(fb, computeReplace(fb, offset, length, text), Mode.REPLACE))
super.replace(fb, offset, length, text, attrs);
}
/trunk/OpenConcerto/src/org/openconcerto/utils/DesktopEnvironmentXDG.sh
New file
0,0 → 1,94
#!/bin/sh
# From https://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-utils-common.in
 
#--------------------------------------
# Checks for known desktop environments
# set variable DE to the desktop environments name, lowercase
 
detectDE()
{
# see https://bugs.freedesktop.org/show_bug.cgi?id=34164
unset GREP_OPTIONS
 
if [ -n "${XDG_CURRENT_DESKTOP}" ]; then
case "${XDG_CURRENT_DESKTOP}" in
# only recently added to menu-spec, pre-spec X- still in use
Cinnamon|X-Cinnamon)
DE=cinnamon;
;;
ENLIGHTENMENT)
DE=enlightenment;
;;
# GNOME, GNOME-Classic:GNOME, or GNOME-Flashback:GNOME
GNOME*)
DE=gnome;
;;
KDE)
DE=kde;
;;
LXDE)
DE=lxde;
;;
MATE)
DE=mate;
;;
XFCE)
DE=xfce
;;
X-Generic)
DE=generic
;;
esac
fi
 
if [ x"$DE" = x"" ]; then
# classic fallbacks
if [ x"$KDE_FULL_SESSION" != x"" ]; then DE=kde;
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE=mate;
elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE=xfce
elif echo $DESKTOP | grep -q '^Enlightenment'; then DE=enlightenment;
fi
fi
 
if [ x"$DE" = x"" ]; then
# fallback to checking $DESKTOP_SESSION
case "$DESKTOP_SESSION" in
gnome)
DE=gnome;
;;
LXDE|Lubuntu)
DE=lxde;
;;
MATE)
DE=mate;
;;
xfce|xfce4|'Xfce Session')
DE=xfce;
;;
esac
fi
 
if [ x"$DE" = x"" ]; then
# fallback to uname output for other platforms
case "$(uname 2>/dev/null)" in
CYGWIN*)
DE=cygwin;
;;
Darwin)
DE=darwin;
;;
esac
fi
 
if [ x"$DE" = x"gnome" ]; then
# gnome-default-applications-properties is only available in GNOME 2.x
# but not in GNOME 3.x
which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3"
fi
}
 
detectDE
echo "$DE"
/trunk/OpenConcerto/src/org/openconcerto/utils/ProductInfo.java
26,7 → 26,10
public class ProductInfo {
 
public static final String PROPERTIES_NAME = "/product.properties";
public static final String ORGANIZATION_NAME = "ORGANIZATION_NAME";
public static final String ORGANIZATION_ID = "ORGANIZATION_ID";
public static final String NAME = "NAME";
public static final String ID = "ID";
public static final String VERSION = "VERSION";
 
private static ProductInfo INSTANCE;
40,7 → 43,7
public synchronized static final ProductInfo getInstance() {
if (INSTANCE == null) {
try {
INSTANCE = createDefault();
setInstance(createDefault());
} catch (IOException e) {
throw new IllegalStateException("unable to load default product properties", e);
}
68,12 → 71,24
return p == null ? null : new ProductInfo(p);
}
 
static private final String sanitizeDomain(final String s) {
return FileUtils.sanitize(s).replace(' ', '_');
}
 
static private final String sanitizeDomainPart(final String s) {
return sanitizeDomain(s).replace('.', '_');
}
 
private final Properties props;
 
public ProductInfo(final String name) {
this(Collections.singletonMap(NAME, name));
this(name, "ILM Informatique", "fr.ilm-informatique");
}
 
public ProductInfo(final String name, final String orgName, final String orgID) {
this(CollectionUtils.createMap(NAME, name, ORGANIZATION_NAME, orgName, ORGANIZATION_ID, orgID));
}
 
public ProductInfo(final Map<String, String> map) {
this(PropertiesUtils.createFromMap(map));
}
100,13 → 115,41
}
 
public final String getProperty(String name, String def) {
return this.getProps().getProperty(name, def);
final String res = this.getProperty(name);
return StringUtils.isEmpty(res, true) ? def : res;
}
 
public final String getOrganizationName() {
return this.getProperty(ORGANIZATION_NAME);
}
 
// com.acme
public final String getOrganizationID() {
final String res = this.getProperty(ORGANIZATION_ID);
if (res != null)
return sanitizeDomain(res);
final String name = this.getOrganizationName();
if (name != null)
return "com." + sanitizeDomainPart(this.getOrganizationName());
return null;
}
 
// my app
public final String getName() {
return this.getProperty(NAME, "unnamed product");
}
 
// my_app
public final String getID() {
return sanitizeDomainPart(this.getProperty(ID, this.getName()));
}
 
// com.acme.my_app
public final String getFullID() {
final String orgID = this.getOrganizationID();
return orgID == null ? null : orgID + '.' + this.getID();
}
 
public final String getVersion() {
return this.getProperty(VERSION);
}
/trunk/OpenConcerto/src/org/openconcerto/utils/BaseDirs.java
New file
0,0 → 1,280
/*
* 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.utils;
 
import java.io.File;
import java.io.IOException;
 
/**
* A set of base directories.
*
* @author Sylvain CUAZ
*/
public abstract class BaseDirs {
 
static private final String DATA = "Data";
static private final String PREFERENCES = "Preferences";
static private final String CACHES = "Caches";
 
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
static public final class XDG extends BaseDirs {
protected XDG(final ProductInfo info, final String subdir) {
super(info, subdir);
}
 
@Override
protected File _getAppDataFolder() {
/*
* $XDG_DATA_HOME defines the base directory relative to which user specific data files
* should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to
* $HOME/.local/share should be used.
*/
return new File(StringUtils.coalesce(System.getenv("XDG_DATA_HOME"), System.getenv("HOME") + "/.local/share"), this.getAppID());
}
 
@Override
protected File _getPreferencesFolder() {
/*
* $XDG_CONFIG_HOME defines the base directory relative to which user specific
* configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty,
* a default equal to $HOME/.config should be used.
*/
return new File(StringUtils.coalesce(System.getenv("XDG_CONFIG_HOME"), System.getenv("HOME") + "/.config"), this.getAppID());
}
 
@Override
protected File _getCacheFolder() {
/*
* $XDG_CACHE_HOME defines the base directory relative to which user specific
* non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or
* empty, a default equal to $HOME/.cache should be used.
*/
return new File(StringUtils.coalesce(System.getenv("XDG_CACHE_HOME"), System.getenv("HOME") + "/.cache"), this.getAppID());
}
}
 
static public final class Unknown extends BaseDirs {
 
protected Unknown(final ProductInfo info, final String subdir) {
super(info, subdir);
}
 
}
 
static public final class Windows extends BaseDirs {
private final String path;
 
protected Windows(final ProductInfo info, final String subdir) {
super(info, subdir);
final String orgID = info.getOrganizationName() == null ? null : FileUtils.sanitize(info.getOrganizationName());
final String appID = this.getAppName();
// handle missing org and avoid OpenConcerto/OpenConcerto
this.path = orgID == null || orgID.equals(appID) ? appID : orgID + File.separatorChar + appID;
// ProductInfo test emptiness
assert this.path.charAt(0) != File.separatorChar && this.path.charAt(this.path.length() - 1) != File.separatorChar : "Separator not in between : " + this.path;
}
 
protected final String getPath() {
return this.path;
}
 
@Override
protected File _getAppDataFolder() {
// do not use LOCALAPPDATA as the user needs its data synchronised
return new File(System.getenv("APPDATA"), this.getPath() + File.separatorChar + DATA);
}
 
@Override
protected File _getPreferencesFolder() {
// do not use LOCALAPPDATA as configuration should be small enough to be synchronised on
// the network
return new File(System.getenv("APPDATA"), this.getPath() + File.separatorChar + PREFERENCES);
}
 
@Override
protected File _getCacheFolder() {
// use LOCALAPPDATA as caches can be quite big and don't need to be synchronised
return new File(System.getenv("LOCALAPPDATA"), this.getPath() + File.separatorChar + CACHES);
}
}
 
// https://developer.apple.com/library/mac/qa/qa1170/_index.html
static public final class Mac extends BaseDirs {
 
protected Mac(final ProductInfo info, final String subdir) {
super(info, subdir);
}
 
@Override
protected File _getAppDataFolder() {
// NOTE : "Application Support" directory is reserved for non-essential application
// resources
return new File(System.getProperty("user.home") + "/Library/" + this.getAppName());
}
 
@Override
protected File _getPreferencesFolder() {
return new File(System.getProperty("user.home") + "/Library/Preferences/" + this.getAppFullID());
}
 
@Override
protected File _getCacheFolder() {
return new File(System.getProperty("user.home") + "/Library/Caches/" + this.getAppFullID());
}
}
 
static public final class Portable extends BaseDirs {
 
private final File rootDir;
 
protected Portable(final File rootDir, final ProductInfo info, final String subdir) {
super(info, subdir);
this.rootDir = rootDir;
}
 
public final File getRootDir() {
return this.rootDir;
}
 
@Override
protected File _getAppDataFolder() {
return new File(this.getRootDir(), DATA);
}
 
@Override
protected File _getPreferencesFolder() {
return new File(this.getRootDir(), PREFERENCES);
}
 
@Override
protected File _getCacheFolder() {
return new File(this.getRootDir(), CACHES);
}
}
 
public static final BaseDirs createPortable(final File rootDir, final ProductInfo info, final String subdir) {
return new Portable(rootDir, info, subdir);
}
 
public static final BaseDirs create(final ProductInfo info) {
return create(info, null);
}
 
public static final BaseDirs create(final ProductInfo info, final String subdir) {
final OSFamily os = OSFamily.getInstance();
if (os == OSFamily.Windows)
return new Windows(info, subdir);
else if (os == OSFamily.Mac)
return new Mac(info, subdir);
else if (os instanceof OSFamily.Unix)
return new XDG(info, subdir);
else
return new Unknown(info, subdir);
}
 
private final ProductInfo info;
private final String subdir;
 
protected BaseDirs(final ProductInfo info, final String subdir) {
this.info = info;
this.subdir = subdir == null ? null : FileUtils.sanitize(subdir);
}
 
// should use other methods to avoid invalid characters
private final ProductInfo getInfo() {
return this.info;
}
 
protected final String getAppName() {
return FileUtils.sanitize(this.getInfo().getName());
}
 
protected final String getAppID() {
return this.getInfo().getID();
}
 
protected final String getAppFullID() {
final String res = this.getInfo().getFullID();
return res != null ? res : this.getAppID();
}
 
protected File getFolderToWrite(final File dir) throws IOException {
if (dir.isDirectory() && dir.canWrite())
return dir;
if (dir.exists())
throw new IOException((dir.isDirectory() ? "Not writable: " : "Not a directory: ") + dir);
// TODO create with 0700 mode in Java 7 (from § Referencing this specification)
FileUtils.mkdir_p(dir);
return dir;
}
 
protected final File getSubDir(final File dir) {
return this.subdir == null ? dir : new File(dir, this.subdir);
}
 
protected File _getAppDataFolder() {
return new File(System.getProperty("user.home"), "." + this.getAppFullID());
}
 
// where to write user-hidden data files (e.g. mbox files, DB files)
public final File getAppDataFolder() {
return getSubDir(_getAppDataFolder());
}
 
public final File getAppDataFolderToWrite() throws IOException {
return getFolderToWrite(this.getAppDataFolder());
}
 
protected File _getPreferencesFolder() {
return this.getAppDataFolder();
}
 
// where to write configuration
public final File getPreferencesFolder() {
return getSubDir(_getPreferencesFolder());
}
 
public final File getPreferencesFolderToWrite() throws IOException {
return getFolderToWrite(this.getPreferencesFolder());
}
 
protected File _getCacheFolder() {
return new File(System.getProperty("java.io.tmpdir"), this.getAppFullID());
}
 
// where to write data that can be re-created
public final File getCacheFolder() {
return getSubDir(_getCacheFolder());
}
 
public final File getCacheFolderToWrite() throws IOException {
return getFolderToWrite(this.getCacheFolder());
}
 
@Override
public String toString() {
return BaseDirs.class.getSimpleName() + " " + this.getClass().getSimpleName();
}
 
public static void main(String[] args) {
final String appName = args.length > 0 ? args[0] : "fooApp";
final String companyName = args.length > 1 ? args[1] : "acme";
final String subdir = System.getProperty("subdir");
final BaseDirs instance = create(new ProductInfo(CollectionUtils.createMap(ProductInfo.ORGANIZATION_NAME, companyName, ProductInfo.NAME, appName)), subdir);
System.out.println(instance);
System.out.println("app data : " + instance.getAppDataFolder());
System.out.println("preferences : " + instance.getPreferencesFolder());
System.out.println("cache : " + instance.getCacheFolder());
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/ImageUtils.java
126,7 → 126,7
throw new IllegalArgumentException("null argument");
}
 
final BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
final BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bufferedImage.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
/trunk/OpenConcerto/src/org/openconcerto/xml/XMLCodecUtils.java
160,7 → 160,7
}
 
private static final void createElemEscaped(final String elemName, final Object o, final StringBuilder sb) {
createElem(elemName, JDOMUtils.OUTPUTTER.escapeElementEntities(o.toString()), sb);
createElem(elemName, JDOM2Utils.OUTPUTTER.escapeElementEntities(o.toString()), sb);
}
 
private static final void createElem(final String elemName, final Object o, final StringBuilder sb) {
369,52 → 369,17
}
}
 
private static final Object eval(Element elem, Stack<Object> context, final Map<String, Object> ids) throws ClassNotFoundException, InstantiationException, IllegalAccessException,
InvocationTargetException {
private static final Object eval(Element elem, Stack<Object> context, final Map<String, Object> ids)
throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException {
final String n = elem.getName();
if (n.equals("null")) {
return null;
} else if (n.equals("boolean")) {
return Boolean.valueOf(elem.getText());
} else if (n.equals("byte")) {
return Byte.valueOf(elem.getText());
} else if (n.equals("char")) {
return Character.valueOf(elem.getText().charAt(0));
} else if (n.equals("string")) {
// Ordered from real world scenario
// string : 80k
// void : 53k
// int : 18k
// object : 9k
// null : 6k
if (n.equals("string")) {
return elem.getText();
} else if (n.equals("short")) {
return Short.valueOf(elem.getText());
} else if (n.equals("int")) {
return Integer.valueOf(elem.getText());
} else if (n.equals("long")) {
return Long.valueOf(elem.getText());
} else if (n.equals("float")) {
return Float.valueOf(elem.getText());
} else if (n.equals("double")) {
return Double.valueOf(elem.getText());
} else if (n.equals("array")) {
final String classAttr = elem.getAttributeValue("class");
final String lengthAttr = elem.getAttributeValue("length");
 
final Class<?> componentClass = parseClassName(classAttr);
if (lengthAttr != null) {
context.push(Array.newInstance(componentClass, Integer.parseInt(lengthAttr)));
for (final Object child : elem.getChildren()) {
eval((Element) child, context, ids);
}
return context.pop();
} else {
return evalContainer(elem, context, ids, new ExnTransformer<List<Object>, Object, RuntimeException>() {
@Override
public Object transformChecked(List<Object> args) {
final Object res = Array.newInstance(componentClass, args.size());
for (int j = 0; j < args.size(); j++) {
Array.set(res, j, args.get(j));
}
return res;
}
});
}
} else if (n.equals("void") || n.equals("object")) {
final String idref = elem.getAttributeValue("idref");
if (idref != null) {
467,6 → 432,47
if (id != null)
ids.put(id, res);
return res;
} else if (n.equals("int")) {
return Integer.valueOf(elem.getText());
} else if (n.equals("null")) {
return null;
} else if (n.equals("boolean")) {
return Boolean.valueOf(elem.getText());
} else if (n.equals("byte")) {
return Byte.valueOf(elem.getText());
} else if (n.equals("char")) {
return Character.valueOf(elem.getText().charAt(0));
} else if (n.equals("short")) {
return Short.valueOf(elem.getText());
} else if (n.equals("long")) {
return Long.valueOf(elem.getText());
} else if (n.equals("float")) {
return Float.valueOf(elem.getText());
} else if (n.equals("double")) {
return Double.valueOf(elem.getText());
} else if (n.equals("array")) {
final String classAttr = elem.getAttributeValue("class");
final String lengthAttr = elem.getAttributeValue("length");
 
final Class<?> componentClass = parseClassName(classAttr);
if (lengthAttr != null) {
context.push(Array.newInstance(componentClass, Integer.parseInt(lengthAttr)));
for (final Object child : elem.getChildren()) {
eval((Element) child, context, ids);
}
return context.pop();
} else {
return evalContainer(elem, context, ids, new ExnTransformer<List<Object>, Object, RuntimeException>() {
@Override
public Object transformChecked(List<Object> args) {
final Object res = Array.newInstance(componentClass, args.size());
for (int j = 0; j < args.size(); j++) {
Array.set(res, j, args.get(j));
}
return res;
}
});
}
} else if (n.equals("class")) {
return Class.forName(elem.getText());
} else
479,7 → 485,8
final List<?> children = parent.getChildren();
int i = 0;
boolean noVoid = true;
while (i < children.size() && noVoid) {
final int size = children.size();
while (i < size && noVoid) {
final Element child = (Element) children.get(i);
if (child.getName().equals("void"))
noVoid = false;
/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/core/customerrelationship/customer/element/ClientNormalSQLElement.java
16,6 → 16,7
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.ql.LabelCreator;
import org.openconcerto.ql.QLPrinter;
23,6 → 24,7
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
49,25 → 51,8
@Override
public void actionPerformed(ActionEvent e) {
final SQLRowAccessor row = IListe.get(e).fetchSelectedRow();
final LabelCreator c = new LabelCreator(720);
c.setLeftMargin(10);
c.setTopMargin(10);
c.setDefaultFont(new Font("Verdana", Font.PLAIN, 50));
c.addLineBold(row.getString("NOM"));
final SQLRowAccessor foreignRow = row.getForeign("ID_ADRESSE");
final String string = foreignRow.getString("RUE");
String[] s = string.split("\n");
for (String string2 : s) {
c.addLineNormal(string2);
printLabel(row, property);
}
c.addLineNormal(foreignRow.getString("CODE_POSTAL") + " " + foreignRow.getString("VILLE"));
final QLPrinter prt = new QLPrinter(property);
try {
prt.print(c.getImage());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}, false, "customerrelationship.customer.label.print");
actionPrintLabel.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionPrintLabel);
98,6 → 83,33
getRowActions().add(action);
}
 
public void printLabel(SQLRowAccessor row, String qlPrinterProperty) {
final LabelCreator c = new LabelCreator(720);
c.setLeftMargin(10);
c.setTopMargin(10);
c.setDefaultFont(new Font("Verdana", Font.PLAIN, 50));
c.addLineBold(row.getString("NOM"));
final SQLRowAccessor foreignRow = row.asRow().getForeign("ID_ADRESSE");
final String string = foreignRow.getString("RUE");
String[] s = string.split("\n");
for (String string2 : s) {
c.addLineNormal(string2);
}
c.addLineNormal(foreignRow.getString("CODE_POSTAL") + " " + foreignRow.getString("VILLE"));
 
final String pays = foreignRow.getString("PAYS");
if (pays != null && pays.trim().length() > 0 && !pays.equalsIgnoreCase(ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeignRow("ID_ADRESSE_COMMON").getString("PAYS"))) {
c.addLineNormal(pays);
}
 
final QLPrinter prt = new QLPrinter(qlPrinterProperty);
try {
prt.print(c.getImage());
} catch (Exception ex) {
ex.printStackTrace();
}
}
 
protected void sendMail(List<SQLRowValues> l) {
 
String mail = "";
155,6 → 167,10
} else {
l.add("CODE");
}
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
if (prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_PCE, false)) {
l.add("ID_COMPTE_PCE");
}
return l;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CompteClientTransactionSQLELement.java
New file
0,0 → 1,48
/*
* 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.customerrelationship.customer.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
 
import java.util.ArrayList;
import java.util.List;
 
public class CompteClientTransactionSQLELement extends ComptaSQLConfElement {
 
public CompteClientTransactionSQLELement() {
super("COMPTE_CLIENT_TRANSACTION");
}
 
@Override
protected List<String> getListFields() {
final List<String> fields = new ArrayList<String>();
fields.add("ID_CLIENT");
fields.add("DATE");
fields.add("MONTANT");
fields.add("ID_MODE_REGLEMENT");
return fields;
}
 
@Override
protected SQLComponent createComponent() {
return new GroupSQLComponent(this, new CompteClientTransactionGroup());
}
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".account.transaction";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLElement.java
13,9 → 13,12
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
 
import java.util.List;
 
26,6 → 29,11
final CustomerGroup group = new CustomerGroup();
GlobalMapper.getInstance().map(CustomerGroup.ID, group);
setDefaultGroup(group);
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
 
}
 
@Override
38,6 → 46,11
@Override
protected List<String> getListFields() {
final List<String> fields = super.getListFields();
if (getTable().contains("GROUPE")) {
fields.add("GROUPE");
}
fields.add("SOLDE_COMPTE");
fields.add("REMIND_DATE");
fields.add("OBSOLETE");
return fields;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLComponent.java
16,7 → 16,6
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
28,7 → 27,6
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenu;
45,6 → 43,7
import org.openconcerto.ui.component.ComboLockedMode;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Component;
import java.awt.Dimension;
53,7 → 52,6
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
 
62,9 → 60,11
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
75,7 → 75,16
private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
private final JUniqueTextField code = new JUniqueTextField(20);
private final JUniqueTextField code = new JUniqueTextField(20) {
@Override
public String getAutoRefreshNumber() {
if (getMode() == Mode.INSERTION) {
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
} else {
return null;
}
}
};
 
private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
private JCheckBox checkAdrLivraison, checkAdrFacturation;
243,10 → 252,40
 
@Override
public int insert(SQLRow order) {
int id = super.insert(order);
int id;
 
int attempt = 0;
// on verifie qu'un client du meme numero n'a pas été inséré entre temps
if (!this.code.checkValidation(false)) {
while (attempt < JUniqueTextField.RETRY_COUNT) {
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
this.code.setText(num);
attempt++;
if (this.code.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.code.getText();
if (attempt == JUniqueTextField.RETRY_COUNT) {
id = getSelectedID();
ExceptionHandler.handle("Impossible d'ajouter, numéro de client existant.");
final Object root = SwingUtilities.getRoot(this);
if (root instanceof EditFrame) {
final EditFrame frame = (EditFrame) root;
frame.getPanel().setAlwaysVisible(true);
}
} else {
id = super.insert(order);
this.table.updateField("ID_CLIENT", id);
this.adresseTable.updateField("ID_CLIENT", id);
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.code.getText().trim())) {
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
final SQLRow rowNumAuto = this.tableNum.getRow(2);
if (rowNumAuto.getObject("CLIENT_START") != null) {
261,7 → 300,14
}
}
}
 
if (attempt > 0) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
}
});
}
}
return id;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CompteClientTransactionGroup.java
New file
0,0 → 1,29
/*
* 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.customerrelationship.customer.element;
 
import org.openconcerto.ui.group.Group;
 
public class CompteClientTransactionGroup extends Group {
public final static String ID = "customerrelationship.customer.account.default";
 
public CompteClientTransactionGroup() {
super(ID);
this.addItem("ID_CLIENT");
this.addItem("DATE");
this.addItem("MONTANT");
this.addItem("ID_REGLEMENT");
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerGroup.java
82,6 → 82,7
 
this.add(gState);
final Group gInfo = new Group("customerrelationship.customer.info", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gInfo.addItem("REMIND_DATE");
gInfo.addItem("INFOS", new LayoutHints(true, true, true, true, true, true, true, true));
gInfo.addItem("COMMENTAIRES", new LayoutHints(true, true, true, true, true, true, true, true));
gInfo.addItem("OBSOLETE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ContactSQLElementBase.java
47,6 → 47,9
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
if (getTable().contains("ID_TITRE_PERSONNEL")) {
l.add("ID_TITRE_PERSONNEL");
}
l.add("NOM");
l.add("PRENOM");
l.add("FONCTION");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AssociationAnalytiqueSQLElement.java
14,15 → 14,13
package org.openconcerto.erp.core.finance.accounting.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.map.model.Ville;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.utils.CollectionUtils;
 
import java.math.BigDecimal;
76,8 → 74,8
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline table = super.createTableSource();
protected synchronized void _initTableSource(final SQLTableModelSource table) {
super._initTableSource(table);
BaseSQLTableModelColumn debit = new BaseSQLTableModelColumn("Débit", BigDecimal.class) {
 
@Override
121,7 → 119,5
};
 
table.getColumns().add(credit);
 
return table;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ComptePCESQLElement.java
24,13 → 24,18
import org.openconcerto.sql.model.SQLBackgroundTableCacheItem;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.utils.ExceptionHandler;
39,11 → 44,13
 
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 java.util.regex.Pattern;
 
import javax.swing.AbstractAction;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
55,13 → 62,33
 
public ComptePCESQLElement() {
super("COMPTE_PCE", "un compte", "comptes");
 
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Consulter le compte") {
 
public void actionPerformed(ActionEvent e) {
final SQLRowAccessor row = IListe.get(e).getSelectedRow();
((EcritureSQLElement) getDirectory().getElement("ECRITURE")).consultationCompte(row);
// ConsultationCompteFrame f = new ConsultationCompteFrame(table.getValueAt(row,
// 0).toString());
 
}
}, true);
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(action);
}
 
@Override
protected void _initComboRequest(ComboSQLRequest req) {
super._initComboRequest(req);
req.setWhere(new Where(getTable().getField("OBSOLETE"), "=", Boolean.FALSE));
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(3);
list.add("NUMERO");
list.add("NOM");
list.add("INFOS");
list.add("OBSOLETE");
return list;
}
 
141,6 → 168,12
JCheckBox checkRacine = new JCheckBox("Racine");
this.add(checkRacine, c);
 
c.gridy++;
c.gridx++;
c.weightx = 0;
JCheckBox checkObs = new JCheckBox("Obsolète");
this.add(checkObs, c);
 
// Infos
JLabel labelInfos = new JLabel(getLabelFor("INFOS"));
c.gridy++;
161,6 → 194,7
this.addRequiredSQLObject(textNom, "NOM");
this.addSQLObject(textInfos, "INFOS");
this.addSQLObject(checkRacine, "RACINE");
this.addSQLObject(checkObs, "OBSOLETE");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java
17,8 → 17,11
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.accounting.ui.ConsultationCompteFrame;
import org.openconcerto.erp.core.finance.accounting.ui.LettrageRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.ListEcritureRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.ListeDesEcrituresPanel;
import org.openconcerto.erp.core.finance.accounting.ui.PointageRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel;
import org.openconcerto.sql.Configuration;
43,7 → 46,10
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
50,11 → 56,17
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.convertor.ValueConvertor;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
62,9 → 74,11
import java.util.List;
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
 
74,6 → 88,9
 
public EcritureSQLElement() {
super("ECRITURE", "une écriture", "écritures");
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction("ID_MOUVEMENT").getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
}
 
@Override
87,8 → 104,6
 
public List<String> getListFields() {
final List<String> l = new ArrayList<String>();
 
l.add("ID");
l.add("VALIDE");
l.add("ID_MOUVEMENT");
if (getTable().contains("NOM_PIECE")) {
125,9 → 140,100
req.addToGraphToFetch("VALIDE");
}
 
public void consultationCompte(SQLRowAccessor rowCpt) {
final ConsultationCompteFrame f = new ConsultationCompteFrame(new ListeDesEcrituresPanel(), "Consultation compte n°" + rowCpt.getString("NUMERO") + " " + rowCpt.getString("NOM"));
 
f.getPanel().getListe().getJTable().addMouseListener(new MouseAdapter() {
 
public void mousePressed(final MouseEvent mE) {
 
if (mE.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Voir les ecritures du journal") {
 
public void actionPerformed(ActionEvent e) {
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
// int id = f.getPanel().getListe().getSelectedId();
 
SQLTable ecrTable = getTable().getTable("ECRITURE");
 
System.err.println("Ecritures ID ::: " + id);
SQLRow rowEcr = ecrTable.getRow(id);
 
System.err.println("Ecritures ID ::: " + id + " --> ID_JOURNAL = " + rowEcr.getInt("ID_JOURNAL"));
 
ConsultationCompteFrame f2 = new ConsultationCompteFrame(new ListeDesEcrituresPanel(),
"Consultation du journal " + getTable().getTable("JOURNAL").getRow(rowEcr.getInt("ID_JOURNAL")).getString("NOM"));
 
Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", rowEcr.getInt("ID_JOURNAL"));
 
f2.getPanel().getListe().getRequest().setWhere(w);
f2.getPanel().getListe().setSQLEditable(false);
f2.pack();
f2.setVisible(true);
}
});
 
menuDroit.add(new AbstractAction("Voir la source") {
 
public void actionPerformed(ActionEvent e) {
 
// int id = f.getPanel().getListe().getSelectedId();
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
System.err.println("ID COMPTE SELECTED " + id);
SQLRow rowEcr = getTable().getTable("ECRITURE").getRow(id);
 
System.out.println("MOUVEMENT VALIDE ------------->>>>>>>>>>>>>> " + MouvementSQLElement.isEditable(rowEcr.getInt("ID_MOUVEMENT")));
 
MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
 
System.out.println("Mouvement Numero : " + rowEcr.getInt("ID_MOUVEMENT"));
}
});
 
menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
}
}
});
 
SQLTable ecrTable = getTable().getTable("ECRITURE");
 
Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", rowCpt.getID());
f.getPanel().getListe().getRequest().setWhere(w);
 
f.getPanel().getListe().setSQLEditable(false);
f.pack();
f.setVisible(true);
}
 
@Override
protected void _initTableSource(SQLTableModelSourceOnline res) {
protected void _initTableSource(SQLTableModelSource res) {
super._initTableSource(res);
BaseSQLTableModelColumn analytique = new BaseSQLTableModelColumn("Poste analytique", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> assocs = r.getReferentRows(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
StringBuffer res = new StringBuffer();
 
for (SQLRowAccessor sqlRowAccessor : assocs) {
res.append(sqlRowAccessor.getForeign("ID_POSTE_ANALYTIQUE").getString("NOM"));
res.append(", ");
}
 
return res.toString();
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
p = p.add(p.getLast().getForeignTable("ID_POSTE_ANALYTIQUE"));
return CollectionUtils.createSet(new FieldPath(p, "NOM"));
}
};
res.getColumns().add(analytique);
for (SQLTableModelColumn col : res.getColumns()) {
col.setRenderer(ListEcritureRenderer.UTILS.getRenderer(col.getRenderer()));
}
142,13 → 248,35
listEcriture.add("DATE");
listEcriture.add("DEBIT");
listEcriture.add("CREDIT");
final SQLTableModelSourceOnline res = this.initTableSource(new SQLTableModelSourceOnline(this.createListRequest(listEcriture)));
for (SQLTableModelColumn column : res.getColumns()) {
column.setRenderer(PointageRenderer.UTILS.getRenderer(column.getRenderer()));
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
for (SQLTableModelColumn col : res.getColumns()) {
if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
col.setConverter(new ValueConvertor<Number, BigDecimal>() {
@Override
public BigDecimal convert(Number o) {
if (o == null) {
return BigDecimal.ZERO;
}
return res;
return new BigDecimal(o.longValue()).movePointLeft(2);
}
 
@Override
public Number unconvert(BigDecimal o) {
 
if (o == null) {
return 0;
}
return o.movePointRight(2);
}
}, BigDecimal.class);
col.setRenderer(CURRENCY_RENDERER);
}
 
col.setRenderer(PointageRenderer.UTILS.getRenderer(col.getRenderer()));
}
return this.initTableSource(res, true);
}
 
public final SQLTableModelSourceOnline createLettrageTableSource() {
final List<String> listEcriture = new ArrayList<String>();
listEcriture.add("LETTRAGE");
162,44 → 290,33
listEcriture.add("DATE");
listEcriture.add("DEBIT");
listEcriture.add("CREDIT");
final SQLTableModelSourceOnline res = this.initTableSource(new SQLTableModelSourceOnline(this.createListRequest(listEcriture)));
for (SQLTableModelColumn column : res.getColumns()) {
column.setRenderer(LettrageRenderer.UTILS.getRenderer(column.getRenderer()));
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
for (SQLTableModelColumn col : res.getColumns()) {
if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
col.setConverter(new ValueConvertor<Number, BigDecimal>() {
@Override
public BigDecimal convert(Number o) {
if (o == null) {
return BigDecimal.ZERO;
}
return res;
return new BigDecimal(o.longValue()).movePointLeft(2);
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline source = super.createTableSource();
public Number unconvert(BigDecimal o) {
 
BaseSQLTableModelColumn analytique = new BaseSQLTableModelColumn("Poste analytique", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> assocs = r.getReferentRows(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
StringBuffer res = new StringBuffer();
 
for (SQLRowAccessor sqlRowAccessor : assocs) {
res.append(sqlRowAccessor.getForeign("ID_POSTE_ANALYTIQUE").getString("NOM"));
res.append(", ");
if (o == null) {
return 0;
}
 
return res.toString();
return o.movePointRight(2);
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
p = p.add(p.getLast().getForeignTable("ID_POSTE_ANALYTIQUE"));
return CollectionUtils.createSet(new FieldPath(p, "NOM"));
}, BigDecimal.class);
col.setRenderer(CURRENCY_RENDERER);
}
};
source.getColumns().add(analytique);
 
return source;
col.setRenderer(LettrageRenderer.UTILS.getRenderer(col.getRenderer()));
}
return this.initTableSource(res, true);
}
 
/*
* (non-Javadoc)
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/RepartitionAnalytiqueSheetXML.java
41,8 → 41,8
protected final static SQLTable tablePoste = base.getTable("POSTE_ANALYTIQUE");
private final static SQLTable tableEcriture = base.getTable("ECRITURE");
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
 
private Date dateDu, dateAu;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceSheet.java
40,8 → 40,8
private final static SQLTable tableEcriture = base.getTable("ECRITURE");
private final static SQLTable tableCompte = base.getTable("COMPTE_PCE");
private boolean centralClient, centralFourn, centralFournImmo;
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
public static String TEMPLATE_ID = "Balance";
public static String TEMPLATE_PROPERTY_NAME = "LocationBalance";
private Date dateAu, dateDu;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator.java
51,7 → 51,7
 
public static void main(String[] args) {
new PdfGenerator_2033B().generateFrom(null);
HashMap h = new HashMap();
// HashMap h = new HashMap();
// h.put("NOM","Front Software");
// new PdfGenerator_2033A().generateFrom(h);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceAgeeListeSheetXML.java
94,10 → 94,11
sel.addSelect(ecr.getTable().getField("LETTRAGE"));
Where w = new Where(ecr.getTable().getField("LETTRAGE"), "IS NOT", (Object) null);
w = w.and(new Where(ecr.getTable().getField("LETTRAGE"), "!=", ""));
if (this.fin == null) {
this.fin = new Date();
}
 
if (fin != null) {
w = w.and(new Where(ecr.getTable().getField("DATE"), "<=", fin));
}
sel.setWhere(w);
 
final List<String> lettrageList = (List<String>) Configuration.getInstance().getBase().getDataSource().executeCol(sel.asString());
110,9 → 111,9
if (deb != null) {
w2 = w2.and(new Where(ecr.getTable().getField("DATE"), ">=", deb));
}
if (fin != null) {
 
w2 = w2.and(new Where(ecr.getTable().getField("DATE"), "<=", fin));
}
 
sel2.addGroupBy(ecr.getTable().getField("LETTRAGE"));
sel2.setHaving(Where.createRaw("SUM(\"DEBIT\") != SUM(\"CREDIT\")", Arrays.asList(ecr.getTable().getField("DEBIT"), ecr.getTable().getField("CREDIT"))));
sel2.setWhere(w2);
135,9 → 136,8
if (deb != null) {
w = w.and(new Where(tableEcriture.getField("DATE"), ">=", deb));
}
if (fin != null) {
w = w.and(new Where(tableEcriture.getField("DATE"), "<=", fin));
}
 
// w = w.and(new Where(cpt.getTable().getField("NOM"), "LIKE", "%RIBEIRO%"));
// w = w.and(new Where(ecr.getTable().getField("ID_COMPTE_PCE"), "=",
// cpt.getTable().getKey()));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/JournauxAnalytiqueSheetXML.java
47,8 → 47,8
public final static int MODELETTREE = 2;
public final static int MODENONLETTREE = 3;
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
protected Date dateDu, dateAu;
private SQLRow rowPoste;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map3310.java
39,7 → 39,7
public class Map3310 extends Thread {
 
private Map<String, Object> m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private JProgressBar bar;
private Date dateDebut, dateFin;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java
37,11 → 37,17
public class Map2033A extends Thread {
 
private Map<String, Object> m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private JProgressBar bar;
private Date dateDebut, dateFin;
SommeCompte sommeCompte;
 
// Debugger un bilan non réparti
// Faire le bilan mois par mois pour retrouver à partir de quel date le bilan est déséquilibré,
// puis comparer les balances J J-1 pour trouver les différences ( ou le grand livre)
// --> Utiliser Check Bilan ACtion pour retrouver les mouvements qui ne sont pas bien réparti
// entre actif et passif
 
// TODO if value = 0.0 ne pas mettre -0.0
 
public void run() {
114,7 → 120,7
// Racine = "109, 201, 203, 205, 208, 237"
// S014=201...205+208+237+232
// Fix Abaque 208 - 2087
long v014 = this.sommeCompte.sommeCompteFils("109", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("201", this.dateDebut, this.dateFin)
long v014 = this.sommeCompte.soldeCompteDebiteur(109, 109, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("201", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("203", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("232", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("205", this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompte(208, 208, true, this.dateDebut, this.dateFin)
- this.sommeCompte.soldeCompte(2087, 2087, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin);
501,8 → 507,9
// 120 -SommeSolde( 100, 103* )-SommeSolde( 108, 109* )
// Racine = "101, 104, 108"
// S120=-10...101-108-104
long v120 = -this.sommeCompte.sommeCompteFils("101", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("108", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("104", this.dateDebut, this.dateFin);
long v120 = -this.sommeCompte.sommeCompteFils("101", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("103", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("108", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("104", this.dateDebut, this.dateFin)
+ this.sommeCompte.soldeCompteCrediteur(109, 109, true, this.dateDebut, this.dateFin);
this.m.put("PASSIF3.15", GestionDevise.currencyToString(v120, false));
 
// 121
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033B.java
34,7 → 34,7
 
public class Map2033B extends Thread {
private Map<String, String> m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private JProgressBar bar;
private Date dateDeb, dateFin;
SommeCompte sommeCompte;
431,6 → 431,7
******************************************************************************************/
// 312
// 374 SommeSoldeDebit( 4457, 4457* )
// TODO répartir les comptes crediteurs
long v374 = this.sommeCompte.soldeCompteDebiteur(4457, 4457, true, this.dateDeb, this.dateFin);
this.m.put("T1.41", GestionDevise.currencyToString(v374, false));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033E.java
28,7 → 28,7
// TODO finir de remplir la Map
public class Map2033E {
private Map m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
SommeCompte sommeCompte;
 
public Map2033E() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/VentilationAnalytiqueSheetXML.java
50,8 → 50,8
private final static SQLTable tableMvt = base.getTable("MOUVEMENT");
private final static SQLTable tableCompte = base.getTable("COMPTE_PCE");
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
 
private Date dateDu, dateAu;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesEcrituresAction.java
18,6 → 18,7
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.accounting.ui.AssociationAnalytiquePanel;
27,6 → 28,7
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
53,7 → 55,6
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
 
144,7 → 145,12
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Consultation du compte") {
public void actionPerformed(ActionEvent event) {
SQLRowAccessor row = frame.getPanel().getListe().getSelectedRow();
((EcritureSQLElement) element).consultationCompte(ComptePCESQLElement.getRow(row.getString("COMPTE_NUMERO"), row.getString("COMPTE_NOM")));
}
});
menuDroit.add(new AbstractAction("Contrepassation") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.contrePassationPiece(frame.getPanel().getListe().getSelectedId());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesComptesAction.java
21,11 → 21,10
import javax.swing.Action;
import javax.swing.JFrame;
 
 
public class ListeDesComptesAction extends CreateFrameAbstractAction {
public ListeDesComptesAction() {
super();
this.putValue(Action.NAME, "Liste des comptes");
this.putValue(Action.NAME, "Liste des comptes du plan comptable");
}
 
public JFrame createFrame() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptaPrefTreeNode.java
20,6 → 20,7
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleManager;
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
import org.openconcerto.erp.preferences.AttachmentPreferencePanel;
import org.openconcerto.erp.preferences.GenerationDeclarationDocPreferencePanel;
import org.openconcerto.erp.preferences.GenerationDocGlobalPreferencePanel;
import org.openconcerto.erp.preferences.GenerationDocumentComptaPreferencePanel;
142,8 → 143,10
final PrefTreeNode nDestGestComm = new PrefTreeNode(GenerationDocumentGestCommPreferencePanel.class, "Gestion commerciale", new String[] { "destination" });
final PrefTreeNode nDestPaye = new PrefTreeNode(GenerationDocumentPayePreferencePanel.class, "Paye", new String[] { "destination" });
final PrefTreeNode nDestEtat = new PrefTreeNode(GenerationDeclarationDocPreferencePanel.class, "Déclaration", new String[] { "Déclaration", "destination" });
final PrefTreeNode nGED = new PrefTreeNode(AttachmentPreferencePanel.class, "GED", new String[] { "GED", "EDM" });
 
nDest.add(nDestCompta);
nDest.add(nGED);
nDest.add(nDestGestComm);
nDest.add(nDestPaye);
nDest.add(nDestEtat);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ListeGestCommEltPanel.java
15,6 → 15,8
 
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
32,7 → 34,7
 
public class ListeGestCommEltPanel extends ListeAddPanel {
 
private EditFrame editModifyFrame, editReadOnlyFrame;
private EditFrame editReadOnlyFrame;
 
private ListeGestCommEltPanel(SQLElement elem, boolean showAdd, Where w, String variant) {
// TODO verifier que l'element contient la clef etrangere ID_MOUVEMENT
61,21 → 63,21
return null;
}
});
this.btnMngr.setAdditional(this.buttonModifier, new ITransformer<JButton, String>() {
 
@Override
public String transformChecked(JButton input) {
 
SQLRowAccessor row = getListe().fetchSelectedRow();
 
if (row.getBoolean("PARTIAL") || row.getBoolean("SOLDE")) {
return "Vous ne pouvez pas modifier une facture intermédiaire.";
// this.btnMngr.setAdditional(this.buttonModifier, new ITransformer<JButton, String>() {
//
// @Override
// public String transformChecked(JButton input) {
//
// SQLRowAccessor row = getListe().fetchSelectedRow();
//
// if (row.getBoolean("PARTIAL") || row.getBoolean("SOLDE")) {
// return "Vous ne pouvez pas modifier une facture intermédiaire.";
// }
// return null;
// }
// });
}
return null;
}
});
}
}
 
public boolean isLastPartialInvoice(SQLRowAccessor sqlRowAccessor) {
Collection<? extends SQLRowAccessor> rows = sqlRowAccessor.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
139,12 → 141,17
} else {
if (source == this.buttonModifier) {
 
if (mvt == null || mvt.isUndefined() | MouvementSQLElement.isEditable(mvt.getID())) {
if (this.editModifyFrame == null) {
this.editModifyFrame = new EditFrame(this.element, EditPanel.MODIFICATION);
if (mvt == null || mvt.isUndefined() || MouvementSQLElement.isEditable(mvt.getID())) {
EditFrame editModifyFrame;
if (this.element.getTable().getName().equals("SAISIE_VENTE_FACTURE") && row.getBoolean("PARTIAL")) {
editModifyFrame = new EditFrame(this.element.createComponent(VenteFactureSituationSQLComponent.ID), EditPanel.MODIFICATION);
} else if (this.element.getTable().getName().equals("SAISIE_VENTE_FACTURE") && row.getBoolean("SOLDE")) {
editModifyFrame = new EditFrame(this.element.createComponent(VenteFactureSoldeSQLComponent.ID), EditPanel.MODIFICATION);
} else {
editModifyFrame = new EditFrame(this.element, EditPanel.MODIFICATION);
}
this.editModifyFrame.selectionId(this.getListe().getSelectedId());
this.editModifyFrame.setVisible(true);
editModifyFrame.selectionId(this.getListe().getSelectedId());
editModifyFrame.setVisible(true);
} else {
if (this.editReadOnlyFrame == null) {
this.editReadOnlyFrame = new EditFrame(this.element, EditPanel.READONLY);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ClotureManuellePanel.java
53,7 → 53,7
private final SQLRow rowExercice = this.exercice.getRow(this.rowSociete.getInt("ID_EXERCICE_COMMON"));
private JButton valider = new JButton("Valider");
private JButton annul = new JButton("Annuler");
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
 
public ClotureManuellePanel() {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieKmItemTable.java
93,12 → 93,6
final SQLTableElement tableElementNomEcriture = new SQLTableElement(tableElement.getField("NOM_ECRITURE"));
list.add(tableElementNomEcriture);
 
if (!DefaultNXProps.getInstance().getBooleanValue("HideAnalytique")) {
final AnalytiqueItemTable analytiqueAssocTable = new AnalytiqueItemTable(true);
SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class, new MultiLineTableCellEditor(
(RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable));
list.add(eltPourcentAnalytique);
}
//
 
this.debit = new SQLTableElement(tableElement.getField("DEBIT"), Long.class, this.deviseCellEditor);
105,6 → 99,12
list.add(this.debit);
this.credit = new SQLTableElement(tableElement.getField("CREDIT"), Long.class, this.deviseCellEditor);
list.add(this.credit);
if (!DefaultNXProps.getInstance().getBooleanValue("HideAnalytique")) {
final AnalytiqueItemTable analytiqueAssocTable = new AnalytiqueItemTable(true);
SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class,
new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable));
list.add(eltPourcentAnalytique);
}
 
final RowValuesTableModel model = new RowValuesTableModel(elt, list, tableElement.getField("NUMERO"), false, defaultRowVals) {
@Override
131,8 → 131,9
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
 
// Autocompletion
final AutoCompletionManager m = new AutoCompletionManager(this.tableElementNumeroCompte, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField(
"COMPTE_PCE.NUMERO"), this.table, this.table.getRowValuesTableModel(), ITextWithCompletion.MODE_STARTWITH, true, false, new ValidStateChecker() {
final AutoCompletionManager m = new AutoCompletionManager(this.tableElementNumeroCompte,
((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("COMPTE_PCE.NUMERO"), this.table, this.table.getRowValuesTableModel(),
ITextWithCompletion.MODE_STARTWITH, true, false, new ValidStateChecker() {
 
ComptePCESQLElement elt = Configuration.getInstance().getDirectory().getElement(ComptePCESQLElement.class);
 
146,6 → 147,8
});
m.fill("NOM", "NOM");
m.setFillWithField("NUMERO");
final Where w = new Where(elt.getTable().getTable("COMPTE_PCE").getField("OBSOLETE"), "=", Boolean.FALSE);
m.setWhere(w);
 
// FIXME erreur fill numero
final AutoCompletionManager m2 = new AutoCompletionManager(tableElementNomCompte, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("COMPTE_PCE.NOM"),
152,6 → 155,7
this.table, this.table.getRowValuesTableModel(), ITextWithCompletion.MODE_CONTAINS, true);
m2.fill("NUMERO", "NUMERO");
m2.setFillWithField("NOM");
m2.setWhere(w);
 
TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ClotureMensuellePayePanel.java
131,6 → 131,7
selFiche.andWhere(new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText())));
selFiche.andWhere(new Where(tableSalarie.getField("ID"), "=", tableFiche.getField("ID_SALARIE")));
selFiche.andWhere(new Where(tableInfosSal.getField("ID"), "=", tableSalarie.getField("ID_INFOS_SALARIE_PAYE")));
selFiche.andWhere(new Where(tableSalarie.getField("ID_FICHE_PAYE"), "!=", tableFiche.getKey()));
 
// FIXME ne pas valider les fiches d'un employé renvoyé
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/EcritureGrandLivreRenderer.java
31,7 → 31,7
public class EcritureGrandLivreRenderer extends DefaultTableCellRenderer {
 
private TableSorter model;
private static final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRENCH);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRENCH);
private final static Color couleurEcritureValide = new Color(253, 243, 204);
private final static Color couleurEcritureToDay = new Color(225, 254, 207);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PlanComptableEPanel.java
14,7 → 14,7
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.accounting.model.PlanComptableEModel;
import org.openconcerto.erp.element.objet.ClasseCompte;
import org.openconcerto.erp.element.objet.Compte;
22,8 → 22,6
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.ui.DefaultGridBagConstraints;
255,75 → 253,9
 
public void actionPerformed(ActionEvent e) {
int row = table.rowAtPoint(mE.getPoint());
 
// ConsultationCompteFrame f = new ConsultationCompteFrame(table.getValueAt(row,
// 0).toString());
final ConsultationCompteFrame f = new ConsultationCompteFrame(new ListeDesEcrituresPanel(), "Consultation compte n°" + table.getValueAt(row, 0).toString() + " "
+ table.getValueAt(row, 1).toString());
 
f.getPanel().getListe().getJTable().addMouseListener(new MouseAdapter() {
 
public void mousePressed(final MouseEvent mE) {
 
if (mE.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Voir les ecritures du journal") {
 
public void actionPerformed(ActionEvent e) {
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
// int id = f.getPanel().getListe().getSelectedId();
 
SQLTable ecrTable = base.getTable("ECRITURE");
 
System.err.println("Ecritures ID ::: " + id);
SQLRow rowEcr = ecrTable.getRow(id);
 
System.err.println("Ecritures ID ::: " + id + " --> ID_JOURNAL = " + rowEcr.getInt("ID_JOURNAL"));
 
ConsultationCompteFrame f2 = new ConsultationCompteFrame(new ListeDesEcrituresPanel(), "Consultation du journal "
+ base.getTable("JOURNAL").getRow(rowEcr.getInt("ID_JOURNAL")).getString("NOM"));
 
Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", rowEcr.getInt("ID_JOURNAL"));
 
f2.getPanel().getListe().getRequest().setWhere(w);
f2.getPanel().getListe().setSQLEditable(false);
f2.pack();
f2.setVisible(true);
}
});
 
menuDroit.add(new AbstractAction("Voir la source") {
 
public void actionPerformed(ActionEvent e) {
 
// int id = f.getPanel().getListe().getSelectedId();
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
System.err.println("ID COMPTE SELECTED " + id);
SQLRow rowEcr = base.getTable("ECRITURE").getRow(id);
 
System.out.println("MOUVEMENT VALIDE ------------->>>>>>>>>>>>>> " + MouvementSQLElement.isEditable(rowEcr.getInt("ID_MOUVEMENT")));
 
MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
 
System.out.println("Mouvement Numero : " + rowEcr.getInt("ID_MOUVEMENT"));
}
});
 
menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
}
}
});
 
SQLTable ecrTable = base.getTable("ECRITURE");
SQLRow rowCompte = base.getTable("COMPTE_PCE").getRow(((PlanComptableEModel) (table.getModel())).getId(row));
 
Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", rowCompte.getID());
f.getPanel().getListe().getRequest().setWhere(w);
 
f.getPanel().getListe().setSQLEditable(false);
f.pack();
f.setVisible(true);
((EcritureSQLElement) ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement("ECRITURE")).consultationCompte(rowCompte);
}
});
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CloturePanel.java
28,6 → 28,7
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
72,7 → 73,7
private final Map<Object, Long> mRAN = new HashMap<Object, Long>();
private JButton valider = new JButton("Valider");
private JButton annul = new JButton("Annuler");
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private JLabel opEnCours = new JLabel("Etat: en attente de validation");
private JCheckBox boxValid = new JCheckBox("Je confirme avoir effectué toutes les opérations nécessaires.");
 
182,16 → 183,31
this.valider.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
 
valider.setEnabled(false);
dateFerm.setEnabled(false);
dateOuv.setEnabled(false);
 
new Thread(new Runnable() {
public void run() {
try {
clotureExercice();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// show OK works fine
Component comp = SwingUtilities.getRoot(CloturePanel.this);
JOptionPane.showMessageDialog(CloturePanel.this, "Exercice clôturé", "Fin de la clôture", JOptionPane.INFORMATION_MESSAGE);
if (comp != null) {
((JFrame) comp).dispose();
}
}
});
} catch (Exception ex) {
ExceptionHandler.handle("Erreur lors de la clôture", ex);
}
}
}).start();
 
}
});
 
this.valider.setEnabled(isDateValid());
222,15 → 238,19
 
private void clotureExercice() throws SQLException {
 
SQLRow rowPrefCompte = this.tablePrefCompte.getRow(2);
int id_Compte_Bilan_Ouverture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O");
if (id_Compte_Bilan_Ouverture <= 1) {
final SQLRow rowPrefCompte = this.tablePrefCompte.getRow(2);
final int id_Compte_Bilan_Ouverture;
if (rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O") <= 1) {
id_Compte_Bilan_Ouverture = ComptePCESQLElement.getId("890");
} else {
id_Compte_Bilan_Ouverture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O");
}
 
int id_Compte_Bilan_Cloture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F");
if (id_Compte_Bilan_Cloture <= 1) {
final int id_Compte_Bilan_Cloture;
if (rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F") <= 1) {
id_Compte_Bilan_Cloture = ComptePCESQLElement.getId("891");
} else {
id_Compte_Bilan_Cloture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F");
}
 
/*******************************************************************************************
237,10 → 257,19
* Validation des écritures
******************************************************************************************/
EcritureSQLElement.validationEcrituresBefore((Date) this.rowExercice.getObject("DATE_FIN"), true);
 
SQLUtils.executeAtomic(this.tablePrefCompte.getDBSystemRoot().getDataSource(), new SQLUtils.SQLFactory<Object>() {
@Override
public Object create() throws SQLException {
 
/*******************************************************************************************
* Solde des comptes de gestion 6* et 7* (génération du résultat)
******************************************************************************************/
this.opEnCours.setText("En cours: solde des comptes 6 et 7");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: solde des comptes 6 et 7");
}
});
long time = new Date().getTime();
System.err.println("Start :: " + time);
soldeCompte(false);
248,8 → 277,12
/*******************************************************************************************
* Solde des autres comptes (comptes de bilan)
******************************************************************************************/
this.opEnCours.setText("En cours: solde des comptes autres que 6 et 7");
this.bar.setValue(1);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: solde des comptes autres que 6 et 7");
CloturePanel.this.bar.setValue(1);
}
});
soldeCompte(true);
 
long time2 = new Date().getTime();
259,12 → 292,16
/*******************************************************************************************
* Reouverture des comptes de bilan
******************************************************************************************/
this.opEnCours.setText("En cours: report des à nouveaux");
this.bar.setValue(2);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: report des à nouveaux");
CloturePanel.this.bar.setValue(2);
}
});
// transfert du compte bilan fermeture vers le compte bilan ouverture
SQLTable ecritureTable = this.base.getTable("ECRITURE");
SQLTable compteTable = this.base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(this.base);
SQLTable ecritureTable = CloturePanel.this.base.getTable("ECRITURE");
SQLTable compteTable = CloturePanel.this.base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(CloturePanel.this.base);
 
sel.addSelect(compteTable.getKey());
sel.addSelect(compteTable.getField("NUMERO"));
279,13 → 316,13
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\", \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
System.out.println(req);
 
Object ob = this.base.getDataSource().execute(req, new ArrayListHandler());
Object ob = CloturePanel.this.base.getDataSource().execute(req, new ArrayListHandler());
 
List myList = (List) ob;
 
if (myList.size() != 0) {
GenerationMvtVirement gen = new GenerationMvtVirement(1, id_Compte_Bilan_Cloture, 0, 0, "Fermeture du compte ", this.rowExercice.getDate("DATE_FIN").getTime(), JournalSQLElement.OD,
"Fermeture des comptes");
GenerationMvtVirement gen = new GenerationMvtVirement(1, id_Compte_Bilan_Cloture, 0, 0, "Fermeture du compte ", CloturePanel.this.rowExercice.getDate("DATE_FIN").getTime(),
JournalSQLElement.OD, "Fermeture des comptes");
for (int i = 0; i < myList.size(); i++) {
 
Object[] objTmp = (Object[]) myList.get(i);
296,12 → 333,12
 
if (solde != 0) {
if (solde > 0) {
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, 0, Math.abs(solde), "Fermeture du compte " + cptTmp.getNumero(), this.rowExercice.getDate("DATE_FIN").getTime(),
JournalSQLElement.OD, false);
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, 0, Math.abs(solde), "Fermeture du compte " + cptTmp.getNumero(),
CloturePanel.this.rowExercice.getDate("DATE_FIN").getTime(), JournalSQLElement.OD, false);
 
} else {
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, Math.abs(solde), 0, "Fermeture du compte " + cptTmp.getNumero(), this.rowExercice.getDate("DATE_FIN").getTime(),
JournalSQLElement.OD, false);
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, Math.abs(solde), 0, "Fermeture du compte " + cptTmp.getNumero(),
CloturePanel.this.rowExercice.getDate("DATE_FIN").getTime(), JournalSQLElement.OD, false);
}
gen.genereMouvement();
}
310,24 → 347,29
/*******************************************************************************************
* Validation des écritures de clotures
******************************************************************************************/
this.opEnCours.setText("En cours: validation des écritures de l'exercice");
this.bar.setValue(3);
EcritureSQLElement.validationEcrituresBefore((Date) this.rowExercice.getObject("DATE_FIN"), true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: validation des écritures de l'exercice");
CloturePanel.this.bar.setValue(3);
}
});
EcritureSQLElement.validationEcrituresBefore((Date) CloturePanel.this.rowExercice.getObject("DATE_FIN"), true);
 
// A nouveaux
Object[] compteAnouveau = this.mRAN.keySet().toArray();
GenerationMvtVirement genAnouveaux = new GenerationMvtVirement(id_Compte_Bilan_Ouverture, 1, 0, 0, "A nouveaux", this.dateOuv.getValue(), JournalSQLElement.OD, "A nouveaux");
for (int i = 0; i < this.mRAN.keySet().size(); i++) {
Object[] compteAnouveau = CloturePanel.this.mRAN.keySet().toArray();
GenerationMvtVirement genAnouveaux = new GenerationMvtVirement(id_Compte_Bilan_Ouverture, 1, 0, 0, "A nouveaux", CloturePanel.this.dateOuv.getValue(), JournalSQLElement.OD,
"A nouveaux");
for (int i = 0; i < CloturePanel.this.mRAN.keySet().size(); i++) {
 
long solde = this.mRAN.get(compteAnouveau[i]).longValue();
long solde = CloturePanel.this.mRAN.get(compteAnouveau[i]).longValue();
 
// if (solde != 0) {
if (solde > 0) {
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), 0, Math.abs(solde), "A nouveaux", this.dateOuv.getValue(), JournalSQLElement.OD,
false);
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), 0, Math.abs(solde), "A nouveaux", CloturePanel.this.dateOuv.getValue(),
JournalSQLElement.OD, false);
} else {
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), Math.abs(solde), 0, "A nouveaux", this.dateOuv.getValue(), JournalSQLElement.OD,
false);
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), Math.abs(solde), 0, "A nouveaux", CloturePanel.this.dateOuv.getValue(),
JournalSQLElement.OD, false);
}
genAnouveaux.genereMouvement();
// }
334,35 → 376,33
}
 
// Fixé la nouvel date de l'exercice
SQLRowValues valsExercice = new SQLRowValues(this.exercice);
SQLRowValues valsExercice = new SQLRowValues(CloturePanel.this.exercice);
valsExercice.put("CLOTURE", Boolean.TRUE);
try {
valsExercice.update(this.rowExercice.getID());
} catch (SQLException e) {
valsExercice.update(CloturePanel.this.rowExercice.getID());
 
e.printStackTrace();
}
 
// Creation d'un nouvel exercice
valsExercice.put("CLOTURE", Boolean.FALSE);
valsExercice.put("DATE_DEB", new java.sql.Date(this.dateOuv.getValue().getTime()));
valsExercice.put("DATE_FIN", new java.sql.Date(this.dateFerm.getValue().getTime()));
valsExercice.put("ID_SOCIETE_COMMON", this.rowSociete.getID());
try {
valsExercice.put("DATE_DEB", new java.sql.Date(CloturePanel.this.dateOuv.getValue().getTime()));
valsExercice.put("DATE_FIN", new java.sql.Date(CloturePanel.this.dateFerm.getValue().getTime()));
valsExercice.put("ID_SOCIETE_COMMON", CloturePanel.this.rowSociete.getID());
SQLRow rowNewEx = valsExercice.insert();
 
// mise a jour de l'exercice de la societe
SQLRowValues rowValsSociete = new SQLRowValues(this.societe);
SQLRowValues rowValsSociete = new SQLRowValues(CloturePanel.this.societe);
rowValsSociete.put("ID_EXERCICE_COMMON", rowNewEx.getID());
rowValsSociete.update(this.rowSociete.getID());
rowValsSociete.update(CloturePanel.this.rowSociete.getID());
// Recharge les informations de la societe pour pointer sur le nouvel exercice
ComptaPropsConfiguration.getInstanceCompta().getRowSociete().fetchValues();
} catch (SQLException e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.bar.setValue(4);
CloturePanel.this.opEnCours.setText("Etat: clôture terminée");
}
});
 
e.printStackTrace();
return null;
}
this.bar.setValue(4);
this.opEnCours.setText("Etat: clôture terminée");
});
}
 
private void soldeCompte(boolean compteBilan) throws SQLException {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteGestCommPreferencePanel.java
40,8 → 40,8
 
public class CompteGestCommPreferencePanel extends DefaultPreferencePanel {
 
private ISQLCompteSelector selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteClient, selCompteVenteProduits, selCompteVenteService, selCompteTVACol, selCompteTVADed,
selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis;
private ISQLCompteSelector selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteValeurEncaissement, selCompteAvanceClient, selCompteClient, selCompteVenteProduits,
selCompteVenteService, selCompteTVACol, selCompteTVADed, selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis;
private ElementComboBox selJrnlFactor;
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
145,6 → 145,28
this.selCompteClient.init();
this.add(this.selCompteClient, c);
 
// Avance Compte client
c.gridy++;
c.weightx = 0;
this.add(new JLabel("Compte Avance Client"), c);
c.weightx = 1;
c.gridx++;
 
this.selCompteAvanceClient = new ISQLCompteSelector();
this.selCompteAvanceClient.init();
this.add(this.selCompteAvanceClient, c);
 
// Valeur à l'encaissement
c.gridy++;
c.weightx = 0;
this.add(new JLabel("Compte dépôt chèque"), c);
c.weightx = 1;
c.gridx++;
 
this.selCompteValeurEncaissement = new ISQLCompteSelector();
this.selCompteValeurEncaissement.init();
this.add(this.selCompteValeurEncaissement, c);
 
// Compte vente produits
c.gridy++;
c.weightx = 0;
298,6 → 320,8
this.rowPrefCompteVals.put("ID_JOURNAL_FACTOR", (selectedId > 1) ? selectedId : 1);
this.rowPrefCompteVals.put("ID_COMPTE_PCE_FOURNISSEUR", this.selCompteFourn.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_CLIENT", this.selCompteClient.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_AVANCE_CLIENT", this.selCompteAvanceClient.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", this.selCompteValeurEncaissement.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_ACHAT", this.selCompteTVADed.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_VENTE", this.selCompteTVACol.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_INTRA", this.selCompteTVAIntraComm.getValue());
358,6 → 382,14
value = ComptePCESQLElement.getId(compte);
this.selCompteClient.setValue(value);
 
// AvanceClient
compte = ComptePCESQLElement.getComptePceDefault("AvanceClients");
value = ComptePCESQLElement.getId(compte);
this.selCompteAvanceClient.setValue(value);
 
compte = ComptePCESQLElement.getComptePceDefault("ValeurEncaissement");
value = ComptePCESQLElement.getId(compte);
this.selCompteValeurEncaissement.setValue(value);
// Port
compte = ComptePCESQLElement.getComptePceDefault("PortVenteSoumisTVA");
value = ComptePCESQLElement.getId(compte);
416,6 → 448,8
 
setComboValues(selCompteFourn, "ID_COMPTE_PCE_FOURNISSEUR", "Fournisseurs");
setComboValues(selCompteClient, "ID_COMPTE_PCE_CLIENT", "Clients");
setComboValues(selCompteAvanceClient, "ID_COMPTE_PCE_AVANCE_CLIENT", "AvanceClients");
setComboValues(selCompteValeurEncaissement, "ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", "ValeurEncaissement");
setComboValues(selComptePortSoumis, "ID_COMPTE_PCE_PORT_SOUMIS", "PortVenteSoumisTVA");
setComboValues(selComptePortNonSoumis, "ID_COMPTE_PCE_PORT_NON_SOUMIS", "PortVenteNonSoumisTVA");
setComboValues(selCompteTVACol, "ID_COMPTE_PCE_TVA_VENTE", "TVACollectee");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/Currency.java
17,13 → 17,24
import java.util.Map;
 
public class Currency {
 
private String code;
 
public Currency(String code) {
this.code = code;
}
 
public String getCode() {
return code;
}
 
public static String[] ISO_CODES = { "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTN",
"BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL",
"GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR",
"KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN",
"NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP",
"SLL", "SOS", "SPL", "SRD", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TVD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VND", "VUV",
"WST", "XAF", "XCD", "XDR", "XOF", "XPF", "YER", "ZAR", "ZMW", "ZWD" };
"BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP",
"GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW",
"KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO",
"NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SPL", "SRD",
"STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TVD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XCD", "XDR", "XOF",
"XPF", "YER", "ZAR", "ZMW", "ZWD" };
 
private static final Map<String, String> mapSymbol;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/CurrencyConverter.java
48,7 → 48,7
}
 
public CurrencyConverter() {
this(ComptaPropsConfiguration.getInstanceCompta().getRootSociete(), ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeign("ID_DEVISE").getString("CODE"), "EUR");
this(ComptaPropsConfiguration.getInstanceCompta().getRootSociete(), ComptaPropsConfiguration.getInstanceCompta().getCurrency().getCode(), "EUR");
}
 
public String getCompanyCurrencyCode() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/PlanComptableGModel.java
92,6 → 92,9
if (w2 != null) {
w1 = w1.and(w2);
}
if (compteTable.getName().equals("COMPTE_PCE")) {
w1 = w1.and(new Where(compteTable.getField("OBSOLETE"), "=", Boolean.FALSE));
}
selCompte.setWhere(w1);
 
selCompte.addRawOrder("\"" + table + "\".\"NUMERO\"");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/TaxeSQLElement.java
142,8 → 142,6
ISQLCompteSelector compteCol = new ISQLCompteSelector();
this.add(compteCol, c);
 
 
 
JLabel labelCompteDed = new JLabel(getLabelFor("ID_COMPTE_PCE_DED"), SwingConstants.RIGHT);
c.gridx = 0;
c.gridy++;
158,7 → 156,6
ISQLCompteSelector compteDed = new ISQLCompteSelector();
this.add(compteDed, c);
 
JLabel labelCompteVente = new JLabel(getLabelFor("ID_COMPTE_PCE_VENTE"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
185,6 → 182,31
ISQLCompteSelector compteVenteS = new ISQLCompteSelector();
this.add(compteVenteS, c);
JLabel labelCompteColIntra = new JLabel(getLabelFor("ID_COMPTE_PCE_COLLECTE_INTRA"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy++;
this.add(labelCompteColIntra, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteColIntra = new ISQLCompteSelector();
this.add(compteColIntra, c);
 
JLabel labelCompteDedIntra = new JLabel(getLabelFor("ID_COMPTE_PCE_DED_INTRA"), SwingConstants.RIGHT);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(labelCompteDedIntra, c);
c.gridx++;
c.weightx = 1;
 
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteDedIntra = new ISQLCompteSelector();
this.add(compteDedIntra, c);
 
// Spacer
c.gridy++;
c.weighty = 1;
195,8 → 217,9
this.addSQLObject(compteDed, "ID_COMPTE_PCE_DED");
this.addSQLObject(compteVente, "ID_COMPTE_PCE_VENTE");
this.addSQLObject(compteVenteS, "ID_COMPTE_PCE_VENTE_SERVICE");
this.addSQLObject(compteColIntra, "ID_COMPTE_PCE_COLLECTE_INTRA");
this.addSQLObject(compteDedIntra, "ID_COMPTE_PCE_DED_INTRA");
 
 
this.addRequiredSQLObject(fieldNom, "NOM");
this.addRequiredSQLObject(fieldTaux, "TAUX");
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/TaxeComplementaireSQLElement.java
New file
0,0 → 1,126
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.finance.tax.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.model.ISQLCompteSelector;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
public class TaxeComplementaireSQLElement extends ComptaSQLConfElement {
 
public TaxeComplementaireSQLElement() {
super("TAXE_COMPLEMENTAIRE", "une taxe complémentaire", "taxes complémentaires");
 
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
l.add("POURCENT");
l.add("ID_COMPTE_PCE");
l.add("ID_COMPTE_PCE_PRODUITS");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
@Override
protected void addViews() {
 
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
JLabel labelNom = new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT);
 
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
JTextField fieldNom = new JTextField(40);
DefaultGridBagConstraints.lockMinimumSize(fieldNom);
this.add(fieldNom, c);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
JLabel labelTaux = new JLabel(getLabelFor("POURCENT"), SwingConstants.RIGHT);
this.add(labelTaux, c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
JTextField fieldTaux = new JTextField(6);
DefaultGridBagConstraints.lockMinimumSize(fieldTaux);
this.add(fieldTaux, c);
 
JLabel labelCompteCol = new JLabel(getLabelFor("ID_COMPTE_PCE"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy++;
this.add(labelCompteCol, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compte = new ISQLCompteSelector();
this.add(compte, c);
 
JLabel labelCompteDed = new JLabel(getLabelFor("ID_COMPTE_PCE_PRODUITS"), SwingConstants.RIGHT);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(labelCompteDed, c);
c.gridx++;
c.weightx = 1;
 
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteProduits = new ISQLCompteSelector();
this.add(compteProduits, c);
 
// Spacer
c.gridy++;
c.weighty = 1;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(new JPanel(), c);
 
this.addRequiredSQLObject(compte, "ID_COMPTE_PCE");
this.addRequiredSQLObject(compteProduits, "ID_COMPTE_PCE_PRODUITS");
this.addRequiredSQLObject(fieldNom, "NOM");
this.addRequiredSQLObject(fieldTaux, "POURCENT");
}
};
}
 
@Override
protected String createCode() {
return "finance.tax.complement";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/action/ReportingEcoContributionPanel.java
New file
0,0 → 1,106
/*
* 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 23 avr. 2012
*/
package org.openconcerto.erp.core.finance.tax.action;
 
import org.openconcerto.erp.generationDoc.gestcomm.ReportingEcoContributionSheetXML;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Calendar;
import java.util.concurrent.ExecutionException;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
public class ReportingEcoContributionPanel extends JPanel {
 
public ReportingEcoContributionPanel() {
super(new GridBagLayout());
 
JLabel labelCom = new JLabel("Période du ");
 
GridBagConstraints c = new DefaultGridBagConstraints();
this.add(labelCom, c);
c.gridx++;
final JDate dateDeb = new JDate();
this.add(dateDeb, c);
c.gridx++;
JLabel labelYear = new JLabel("au");
final JDate dateFin = new JDate();
 
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH, 1);
dateDeb.setValue(cal.getTime());
 
this.add(labelYear, c);
c.gridx++;
this.add(dateFin, c);
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DAY_OF_MONTH, 31);
dateFin.setValue(cal.getTime());
 
final JButton buttonValid = new JButton(new AbstractAction("Valider") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
new Thread() {
public void run() {
ReportingEcoContributionSheetXML sheet = new ReportingEcoContributionSheetXML(dateDeb.getValue(), dateFin.getValue());
try {
sheet.createDocument();
} catch (InterruptedException exn) {
exn.printStackTrace();
} catch (ExecutionException exn) {
exn.printStackTrace();
}
sheet.showPrintAndExport(true, false, false);
 
};
}.start();
 
}
 
});
c.gridx++;
// buttonValid.setEnabled(false);
this.add(buttonValid, c);
dateDeb.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null);
}
});
dateFin.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null);
}
});
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/model/TaxeCache.java
73,6 → 73,17
return this.mapTaux.get(Integer.valueOf(idTaux));
}
 
public SQLRowAccessor getRowFromId(final int idTaux) {
Set<SQLRowAccessor> s = mapRowTaux.keySet();
for (SQLRowAccessor r : s) {
if (r.getID() == idTaux) {
return r;
}
}
return null;
 
}
 
public SQLRow getFirstTaxe() {
if (this.firstIdTaxe == null) {
final SQLSelect sel = getSel();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/ListeDesReferencesAction.java
91,7 → 91,7
}
};
 
final IListe list = new IListe(elementArticle.initTableSource(new SQLTableModelSourceOnline(req)));
final IListe list = new IListe(elementArticle.createTableSourceOnline(req));
 
IListFrame frame = new IListFrame(new ListeAddPanel(elementArticle, list) {
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/ui/GestionChequesRenderer.java
24,7 → 24,7
public class GestionChequesRenderer extends DefaultTableCellRenderer {
 
private final static Color couleurChequeValide = new Color(255, 128, 64);
private static final 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/finance/payment/element/ChequeSQLElement.java
15,9 → 15,7
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.finance.payment.ui.GestionChequesRenderer;
import org.openconcerto.sql.FieldExpander;
import org.openconcerto.sql.ShowAs;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
31,21 → 29,9
}
 
protected final SQLTableModelSourceOnline createDepositTableSource(final List<String> fields, final ShowAs showAs, final Where w) {
final ListSQLRequest req = new ListSQLRequest(getTable(), fields) {
@Override
protected void customizeToFetch(SQLRowValues graphToFetch) {
super.customizeToFetch(graphToFetch);
graphToFetch.putNulls(getDoneFieldName());
}
 
@Override
protected FieldExpander getShowAs() {
return showAs;
}
};
req.setWhere(new Where(this.getTable().getField(this.getDoneFieldName()), "=", Boolean.FALSE).and(w));
 
final SQLTableModelSourceOnline res = new SQLTableModelSourceOnline(req);
final ListSQLRequest req = this.createListRequest(fields, new Where(this.getTable().getField(this.getDoneFieldName()), "=", Boolean.FALSE).and(w), showAs);
req.addToGraphToFetch(getDoneFieldName());
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(req);
res.init();
res.getColumn(getTable().getField(getMinDateFieldName())).setRenderer(new GestionChequesRenderer());