OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 89 → Rev 90

/trunk/OpenConcerto/.classpath
35,5 → 35,6
<classpathentry exported="true" kind="lib" path="lib/jOpenDocument-1.4rc2.jar"/>
<classpathentry kind="lib" path="lib/jsch-0.1.51.jar"/>
<classpathentry kind="lib" path="lib/msv-20090415.jar"/>
<classpathentry kind="lib" path="lib/jOpenCalendar.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/OpenConcerto/lib/jOpenCalendar.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/jOpenCalendar.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/ui/TimeStampTableCellEditor.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/ui/JDate.java
16,6 → 16,7
import org.openconcerto.ui.component.text.TextComponent;
import org.openconcerto.ui.valuewrapper.ValueWrapper;
import org.openconcerto.utils.FormatGroup;
import org.openconcerto.utils.TimeUtils;
import org.openconcerto.utils.checks.ValidListener;
import org.openconcerto.utils.checks.ValidState;
import org.openconcerto.utils.i18n.TM.MissingMode;
78,7 → 79,7
 
private static boolean CommitEachValidEditDefault = false;
 
public static void setCommitEachValidEditDefault(boolean commitEachValidEditDefault) {
public static void setCommitEachValidEditDefault(final boolean commitEachValidEditDefault) {
CommitEachValidEditDefault = commitEachValidEditDefault;
}
 
88,6 → 89,7
 
private final boolean fillWithCurrentDate;
private final boolean commitEachValidEdit;
private final Calendar cal;
 
/**
* Créé un composant d'édition de date, vide.
103,7 → 105,7
* d'aujourd'hui, sinon vide.
* @see #getCommitEachValidEditDefault()
*/
public JDate(boolean fillWithCurrentDate) {
public JDate(final boolean fillWithCurrentDate) {
this(fillWithCurrentDate, getCommitEachValidEditDefault());
}
 
117,7 → 119,7
* leaving or hitting enter).
* @see DefaultFormatter#setCommitsOnValidEdit(boolean)
*/
public JDate(boolean fillWithCurrentDate, boolean commitEachValidEdit) {
public JDate(final boolean fillWithCurrentDate, final boolean commitEachValidEdit) {
super();
this.fillWithCurrentDate = fillWithCurrentDate;
this.commitEachValidEdit = commitEachValidEdit;
128,11 → 130,11
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK), "monthToFuture");
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK), "monthToPast");
final ActionMap actionMap = this.getEditor().getActionMap();
final Calendar cal = Calendar.getInstance(this.getMonthView().getLocale());
actionMap.put("dayToPast", createChangeDateAction(cal, Calendar.DAY_OF_YEAR, -1));
actionMap.put("dayToFuture", createChangeDateAction(cal, Calendar.DAY_OF_YEAR, 1));
actionMap.put("monthToPast", createChangeDateAction(cal, Calendar.MONTH, -1));
actionMap.put("monthToFuture", createChangeDateAction(cal, Calendar.MONTH, 1));
this.cal = Calendar.getInstance(this.getMonthView().getLocale());
actionMap.put("dayToPast", createChangeDateAction(Calendar.DAY_OF_YEAR, -1));
actionMap.put("dayToFuture", createChangeDateAction(Calendar.DAY_OF_YEAR, 1));
actionMap.put("monthToPast", createChangeDateAction(Calendar.MONTH, -1));
actionMap.put("monthToFuture", createChangeDateAction(Calendar.MONTH, 1));
 
this.resetValue();
}
141,17 → 143,21
return this.fillWithCurrentDate;
}
 
protected AbstractAction createChangeDateAction(final Calendar cal, final int field, final int amount) {
protected final Calendar getCal() {
return this.cal;
}
 
protected AbstractAction createChangeDateAction(final int field, final int amount) {
return new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(final ActionEvent e) {
Date currentVal = getDate();
if (currentVal == null && fillsWithCurrentDate())
currentVal = new Date();
if (currentVal != null) {
cal.setTime(currentVal);
cal.add(field, amount);
setDate(cal.getTime());
getCal().setTime(currentVal);
getCal().add(field, amount);
setValue(getCal().getTime());
}
}
};
158,10 → 164,10
}
 
@Override
public void setFormats(DateFormat[] formats) {
public void setFormats(final DateFormat[] formats) {
final InternationalFormatter formatter = new InternationalFormatter(new FormatGroup(formats)) {
@Override
public Object stringToValue(String text) throws ParseException {
public Object stringToValue(final String text) throws ParseException {
// JXDatePickerFormatter used to handle null date ; InternationalFormatter only use
// the formats which obviously fail to parse "" and so revert the empty value.
if (text == null || text.isEmpty())
175,9 → 181,9
 
@Override
public DateFormat[] getFormats() {
AbstractFormatterFactory factory = this.getEditor().getFormatterFactory();
final AbstractFormatterFactory factory = this.getEditor().getFormatterFactory();
if (factory != null) {
AbstractFormatter formatter = factory.getFormatter(this.getEditor());
final AbstractFormatter formatter = factory.getFormatter(this.getEditor());
if (formatter instanceof JXDatePickerFormatter) {
return ((JXDatePickerFormatter) formatter).getFormats();
} else if (formatter instanceof InternationalFormatter) {
213,6 → 219,11
}
}
 
/**
* Reset the component as if it has just been created. If {@link #fillsWithCurrentDate()} then
* the date at the time this method is called will be used (not the date of creation).
*/
@Override
public final void resetValue() {
if (this.fillsWithCurrentDate()) {
this.setValue(new Date());
221,10 → 232,25
}
}
 
public final void setValue(Date date) {
this.setDate(date);
/**
* Set the value after clearing the time part.
*
* @param date the new value.
*/
@Override
public final void setValue(final Date date) {
final Date timeless;
if (date == null) {
timeless = null;
} else {
getCal().setTime(date);
TimeUtils.clearTime(getCal());
timeless = getCal().getTime();
}
this.setDate(timeless);
}
 
@Override
public final Date getValue() {
return this.getDate();
}
233,14 → 259,17
return this.getValue() == null;
}
 
public final void addValueListener(PropertyChangeListener l) {
@Override
public final void addValueListener(final PropertyChangeListener l) {
this.getEditor().addPropertyChangeListener("value", l);
}
 
public void rmValueListener(PropertyChangeListener l) {
@Override
public void rmValueListener(final PropertyChangeListener l) {
this.getEditor().removePropertyChangeListener("value", l);
}
 
@Override
public JComponent getComp() {
return this;
}
250,15 → 279,17
return ValidState.getTrueInstance();
}
 
public void addValidListener(ValidListener l) {
@Override
public void addValidListener(final ValidListener l) {
// nothing to do
}
 
@Override
public void removeValidListener(ValidListener l) {
public void removeValidListener(final ValidListener l) {
// nothing to do
}
 
@Override
public JTextComponent getTextComp() {
return getEditor();
}
/trunk/OpenConcerto/src/org/openconcerto/ui/JLabelBold.java
22,4 → 22,9
super(s);
this.setFont(getFont().deriveFont(Font.BOLD));
}
 
@Override
public String toString() {
return super.toString() + " text:" + this.getText();
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/touch/ScrollableList.java
209,10 → 209,8
}
 
public void setSelectedIndex(int index, boolean scroll) {
System.err.println("ScrollableList.setSelectedIndex()! " + index);
if (index != selectedIndex) {
this.selectedIndex = index;
System.err.println("ScrollableList.setSelectedIndex():" + index);
if (scroll) {
scrollToSelectedIndex();
}
/trunk/OpenConcerto/src/org/openconcerto/ui/translation/messages_en.properties
20,4 → 20,8
prefs.reset=Reset settings
prefs.main=Main application preferences
 
day.spelloutRule=%spellout-ordinal
day.spellout.beforeLast=second to last
day.spellout.last=last
 
email.fallback=Wrong settings for email, using basic settings.
/trunk/OpenConcerto/src/org/openconcerto/ui/translation/messages_fr.properties
23,5 → 23,8
# maximum 3 newline delimited formats
jdate.formats=dd/MM/yy\n\
d MMMM yyyy
day.spelloutRule=%spellout-ordinal-masculine
day.spellout.beforeLast=avant-dernier
day.spellout.last=dernier
 
email.fallback=Mauvais réglages de courriel, utilisation du système basique.
/trunk/OpenConcerto/src/org/openconcerto/ui/translation/messages_pl.properties
New file
0,0 → 1,2
# maximum 3 newline delimited formats
jdate.formats=dd.MM.yyyy
/trunk/OpenConcerto/src/org/openconcerto/ui/list/CheckListRenderer.java
New file
0,0 → 1,56
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.ui.list;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
 
import javax.swing.JCheckBox;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
 
public class CheckListRenderer extends JCheckBox implements ListCellRenderer {
private Color color;
 
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus) {
setEnabled(list.isEnabled());
setSelected(((CheckListItem) value).isSelected());
setColorIndicator(((CheckListItem) value).getColor());
setFont(list.getFont());
setBackground(list.getBackground());
setForeground(list.getForeground());
setText(value.toString());
return this;
}
 
private void setColorIndicator(Color c) {
this.color = c;
}
 
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (color != null) {
final int marginV = 4;
final int marginH = 3;
final int y = marginV;
final int s = this.getHeight() - 2 * marginV;
g.setColor(color);
final int x = this.getWidth() - s - marginH;
g.fillRect(x, y, s, s);
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/list/CheckListItem.java
New file
0,0 → 1,55
/*
* 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.ui.list;
 
import java.awt.Color;
 
public class CheckListItem {
private final Object object;
private boolean isSelected = false;
private Color color;
 
public CheckListItem(Object object) {
this.object = object;
}
 
public CheckListItem(Object object, boolean selected) {
this.object = object;
this.isSelected = selected;
}
 
public Object getObject() {
return object;
}
 
public boolean isSelected() {
return isSelected;
}
 
public void setSelected(boolean isSelected) {
this.isSelected = isSelected;
}
 
public Color getColor() {
return color;
}
 
public void setColor(Color color) {
this.color = color;
}
 
public String toString() {
return object.toString();
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DayOfWeek.java
New file
0,0 → 1,72
/*
* 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.ui.date;
 
import java.util.Calendar;
import java.util.EnumSet;
 
enum DayOfWeek {
SUNDAY(Calendar.SUNDAY), MONDAY(Calendar.MONDAY), TUESDAY(Calendar.TUESDAY), WEDNESDAY(Calendar.WEDNESDAY), THURSDAY(Calendar.THURSDAY), FRIDAY(Calendar.FRIDAY), SATURDAY(Calendar.SATURDAY);
 
public static final EnumSet<DayOfWeek> WORKING_DAYS = EnumSet.complementOf(EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY));
 
private final int calendarField;
 
private DayOfWeek(int field) {
this.calendarField = field;
}
 
public final int getCalendarField() {
return this.calendarField;
}
 
/**
* Return the instance from a Calendar constant.
*
* @param field a {@link Calendar#DAY_OF_WEEK Calendar constant}, e.g. {@link Calendar#SUNDAY}.
* @return the instance for the passed parameter.
*/
static public DayOfWeek fromCalendarField(final int field) {
for (final DayOfWeek d : values()) {
if (d.getCalendarField() == field)
return d;
}
throw new IllegalArgumentException("Unknown field : " + field);
}
 
static public DayOfWeek fromCalendar(final Calendar c) {
return fromCalendarField(c.get(Calendar.DAY_OF_WEEK));
}
 
static public DayOfWeek[] valuesStartingAt(final DayOfWeek d) {
final DayOfWeek[] all = values();
if (d.ordinal() == 0)
return all;
 
final DayOfWeek[] res = new DayOfWeek[all.length];
System.arraycopy(all, d.ordinal(), res, 0, all.length - d.ordinal());
System.arraycopy(all, 0, res, all.length - d.ordinal(), d.ordinal());
return res;
}
 
/**
* The ordered days of a week.
*
* @param c a calendar.
* @return all days beginning by {@link Calendar#getFirstDayOfWeek()}.
*/
static public DayOfWeek[] getWeek(final Calendar c) {
return valuesStartingAt(fromCalendarField(c.getFirstDayOfWeek()));
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/EventProviders.java
New file
0,0 → 1,204
/*
* 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.ui.date;
 
import java.util.Calendar;
import java.util.Set;
 
public class EventProviders {
 
private EventProviders() {
}
 
static final class Daily implements EventProvider {
 
private final int dayIncrement;
 
protected Daily(int dayIncrement) {
super();
this.dayIncrement = dayIncrement;
}
 
@Override
public final void next(final Calendar c, final boolean initialValue) {
// if initial value, any day is fine
if (!initialValue) {
c.add(Period.DAY.getCalendarField(), this.dayIncrement);
}
}
}
 
static final class Weekly implements EventProvider {
 
private final int increment;
private final Set<DayOfWeek> days;
 
protected Weekly(final int increment, final Set<DayOfWeek> days) {
super();
this.increment = increment;
if (days.isEmpty())
throw new IllegalArgumentException("no days");
this.days = days;
}
 
@Override
public final void next(final Calendar c, final boolean initialValue) {
final int currentWeekNumber = c.get(Calendar.WEEK_OF_YEAR);
if (!initialValue) {
// we want a different day
c.add(Calendar.DAY_OF_WEEK, 1);
}
while (c.get(Calendar.WEEK_OF_YEAR) == currentWeekNumber) {
if (this.days.contains(DayOfWeek.fromCalendar(c))) {
return;
}
c.add(Calendar.DAY_OF_WEEK, 1);
}
// come back to the (last day of) starting week
c.add(Calendar.DAY_OF_WEEK, -1);
assert c.get(Calendar.WEEK_OF_YEAR) == currentWeekNumber;
 
c.add(Period.WEEK.getCalendarField(), this.increment);
c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek());
// we allow the passed day
this.next(c, true);
}
}
 
static private abstract class ConstantPeriodEventProvider implements EventProvider {
 
private final Period period;
private final int increment;
 
protected ConstantPeriodEventProvider(final Period period, final int increment) {
super();
this.period = period;
if (increment == 0)
throw new IllegalArgumentException("Empty increment");
this.increment = increment;
}
 
@Override
public final void next(final Calendar c, final boolean initialValue) {
if (!initialValue || currentPeriodBefore(c)) {
// GregorianCalendar calls pinDayOfMonth() so that January the 31st + 1 month stays
// in February
c.add(this.period.getCalendarField(), this.increment);
}
setDate(c);
}
 
protected boolean currentPeriodBefore(final Calendar c) {
final Calendar clone = (Calendar) c.clone();
setDate(clone);
return clone.compareTo(c) < 0;
}
 
protected abstract void setDate(final Calendar c);
}
 
static final class Monthly extends ConstantPeriodEventProvider {
 
private final int dayOfMonth;
 
protected Monthly(final int dayOfMonth, final int increment) {
super(Period.MONTH, increment);
this.dayOfMonth = dayOfMonth;
}
 
@Override
protected boolean currentPeriodBefore(Calendar c) {
return this.dayOfMonth < c.get(Calendar.DAY_OF_MONTH);
}
 
@Override
protected void setDate(Calendar c) {
if (c.get(Calendar.DAY_OF_MONTH) != this.dayOfMonth) {
setDayOfMonth(c, this.dayOfMonth);
}
}
 
}
 
// set the day without changing month
static protected void setDayOfMonth(final Calendar c, final int dayOfMonth) {
c.set(Calendar.DAY_OF_MONTH, Math.min(c.getActualMaximum(Calendar.DAY_OF_MONTH), dayOfMonth));
}
 
static final class Yearly extends ConstantPeriodEventProvider {
 
private final int dayOfMonth;
private final int month;
 
protected Yearly(final int dayOfMonth, final int month, final int increment) {
super(Period.YEAR, increment);
this.dayOfMonth = dayOfMonth;
this.month = month;
}
 
@Override
protected void setDate(Calendar c) {
c.set(Calendar.MONTH, this.month);
setDayOfMonth(c, this.dayOfMonth);
}
}
 
static private abstract class WeekInMonth extends ConstantPeriodEventProvider {
private final int ordinal;
private final DayOfWeek day;
 
protected WeekInMonth(final Period period, final int increment, final int ordinal, final DayOfWeek day) {
super(period, increment);
if (period.compareTo(Period.MONTH) < 0)
throw new IllegalArgumentException("Period too short : " + period);
this.ordinal = ordinal;
this.day = day;
}
 
@Override
protected void setDate(Calendar c) {
// clear any fields that might interfere with time resolution
c.clear(Calendar.DAY_OF_MONTH);
c.clear(Calendar.DAY_OF_YEAR);
c.clear(Calendar.WEEK_OF_YEAR);
c.clear(Calendar.WEEK_OF_MONTH);
 
c.set(Calendar.DAY_OF_WEEK_IN_MONTH, this.ordinal);
c.set(Calendar.DAY_OF_WEEK, this.day.getCalendarField());
}
}
 
static final class MonthlyDayOfWeek extends WeekInMonth {
protected MonthlyDayOfWeek(final int ordinal, final DayOfWeek day, final int increment) {
super(Period.MONTH, increment, ordinal, day);
}
}
 
static final class YearlyDayOfWeekEventProvider extends WeekInMonth {
 
private final int month;
 
protected YearlyDayOfWeekEventProvider(final int ordinal, final DayOfWeek day, final int month, final int increment) {
super(Period.YEAR, increment, ordinal, day);
this.month = month;
}
 
@Override
protected void setDate(final Calendar c) {
super.setDate(c);
c.set(Calendar.MONTH, this.month);
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DateRangeTable.java
New file
0,0 → 1,213
/*
* 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.ui.date;
 
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.StringUtils;
 
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
 
public class DateRangeTable extends JPanel {
private static final long serialVersionUID = 351767837995219468L;
public JButton bAdd = new JButton("Ajouter une plage horaire");
public JButton bRemove = new JButton("Supprimer");
public JTable rangeTable;
final DateFormat dateTimeInstance = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT);
final DateFormat timeInstance = DateFormat.getTimeInstance(DateFormat.SHORT);
private boolean nonEmpty;
 
public DateRangeTable(final boolean nonEmpty) {
this.nonEmpty = nonEmpty;
final DateRangeTableModel model = new DateRangeTableModel();
this.rangeTable = new JTable(model);
this.rangeTable.setRowHeight((int) (new JLabel("A").getPreferredSize().height * 1.8));
 
// Start
final TableColumn columnStart = this.rangeTable.getColumnModel().getColumn(0);
columnStart.setIdentifier("start");
columnStart.setCellRenderer(new DefaultTableCellRenderer() {
 
private static final long serialVersionUID = -5791552871303767817L;
 
@Override
protected void setValue(final Object value) {
if (value != null && value instanceof Date) {
super.setValue(" " + StringUtils.firstUp(DateRangeTable.this.dateTimeInstance.format(value)));
} else {
super.setValue(value);
}
}
});
columnStart.setCellEditor(new DateTimeCellEditor());
// End
TableColumn columnEnd = this.rangeTable.getColumnModel().getColumn(1);
columnEnd.setCellRenderer(new DefaultTableCellRenderer() {
 
private static final long serialVersionUID = -4281193780380371423L;
 
@Override
public Component getTableCellRendererComponent(final JTable table, Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
if (value != null && value instanceof Date) {
final Date endDate = (Date) value;
final Calendar cEnd = Calendar.getInstance();
cEnd.setTime(endDate);
final int col = table.getColumn("start").getModelIndex();
final Object startDate = table.getValueAt(row, col);
if (startDate != null) {
final Calendar cStart = Calendar.getInstance();
cStart.setTime((Date) startDate);
if (cStart.get(Calendar.YEAR) == cEnd.get(Calendar.YEAR) && cStart.get(Calendar.DAY_OF_YEAR) == cEnd.get(Calendar.DAY_OF_YEAR)) {
final Calendar c = Calendar.getInstance();
c.clear();
c.add(Calendar.MINUTE, cEnd.get(Calendar.HOUR_OF_DAY) * 60 + cEnd.get(Calendar.MINUTE));
c.add(Calendar.MINUTE, -(cStart.get(Calendar.HOUR_OF_DAY) * 60 + cStart.get(Calendar.MINUTE)));
String m = String.valueOf(c.get(Calendar.MINUTE));
if (m.length() < 2) {
m = "0" + m;
}
value = " " + DateRangeTable.this.timeInstance.format(value) + " (durée :" + c.get(Calendar.HOUR_OF_DAY) + ":" + m + ")";
} else {
value = " " + StringUtils.firstUp(DateRangeTable.this.dateTimeInstance.format(value));
}
 
} else {
value = " " + StringUtils.firstUp(DateRangeTable.this.dateTimeInstance.format(value));
}
}
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
 
});
columnEnd.setCellEditor(new DateTimeCellEditor());
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.NONE;
this.add(this.bAdd, c);
c.gridx++;
this.bRemove.setEnabled(false);
this.add(this.bRemove, c);
c.gridx = 0;
c.gridy++;
c.gridwidth = 2;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
if (nonEmpty) {
model.addNewLine();
}
this.add(new JScrollPane(this.rangeTable), c);
this.bAdd.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(final ActionEvent e) {
model.addNewLine();
 
}
});
this.bRemove.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(final ActionEvent e) {
final int[] selection = DateRangeTable.this.rangeTable.getSelectedRows();
model.remove(selection);
}
});
this.rangeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(final ListSelectionEvent event) {
if (DateRangeTable.this.rangeTable.getSelectedRowCount() > 0) {
DateRangeTable.this.bRemove.setEnabled(!nonEmpty || (nonEmpty && DateRangeTable.this.rangeTable.getRowCount() > 1));
} else {
DateRangeTable.this.bRemove.setEnabled(false);
}
}
});
}
 
public void fillFrom(final List<DateRange> list) {
assert SwingUtilities.isEventDispatchThread();
getDateRangeTableModel().fillFrom(list);
if (list.isEmpty() && this.nonEmpty) {
getDateRangeTableModel().addNewLine();
}
}
 
/**
* @param args
*/
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (final Exception e) {
e.printStackTrace();
}
 
final JFrame f = new JFrame();
f.setContentPane(new DateRangeTable(true));
f.setSize(400, 300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
 
}
});
 
}
 
@SuppressWarnings("unchecked")
public void clear() {
fillFrom(Collections.EMPTY_LIST);
}
 
public List<DateRange> getRanges() {
List<DateRange> result = new ArrayList<DateRange>();
DateRangeTableModel model = getDateRangeTableModel();
for (int i = 0; i < model.getRowCount(); i++) {
result.add(model.getRange(i));
}
return result;
 
}
 
private DateRangeTableModel getDateRangeTableModel() {
return (DateRangeTableModel) this.rangeTable.getModel();
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/Period.java
New file
0,0 → 1,30
/*
* 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.ui.date;
 
import java.util.Calendar;
 
enum Period {
DAY(Calendar.DAY_OF_YEAR), WEEK(Calendar.WEEK_OF_YEAR), MONTH(Calendar.MONTH), YEAR(Calendar.YEAR);
 
private final int calendar;
 
private Period(int calendar) {
this.calendar = calendar;
}
 
public final int getCalendarField() {
return this.calendar;
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DateRangeTableModel.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.ui.date;
 
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
 
import javax.swing.table.AbstractTableModel;
 
public class DateRangeTableModel extends AbstractTableModel {
private static final long serialVersionUID = 5076344567233395335L;
private final List<DateRange> ranges = new ArrayList<DateRange>();
 
@Override
public int getRowCount() {
return this.ranges.size();
}
 
@Override
public int getColumnCount() {
return 2;
}
 
public DateRange getRange(int index) {
return this.ranges.get(index);
}
 
@Override
public Object getValueAt(final int rowIndex, final int columnIndex) {
final Calendar c = Calendar.getInstance();
if (columnIndex == 0) {
c.setTimeInMillis(this.ranges.get(rowIndex).getStart());
} else {
c.setTimeInMillis(this.ranges.get(rowIndex).getStop());
}
return c.getTime();
}
 
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if (aValue == null || !(aValue instanceof Date)) {
throw new IllegalArgumentException("Cannot set " + aValue + " at " + rowIndex + ":" + columnIndex);
}
long time = ((Date) aValue).getTime();
 
if (columnIndex == 0) {
this.ranges.get(rowIndex).setStart(time);
} else {
this.ranges.get(rowIndex).setStop(time);
}
}
 
public void addNewLine() {
long start = System.currentTimeMillis();
for (final DateRange r : this.ranges) {
if (r.getStart() + 3600 * 1000 > start) {
start = r.getStart() + 24 * 3600 * 1000;
}
}
this.ranges.add(new DateRange(start));
fireTableDataChanged();
}
 
public void fillFrom(final List<DateRange> list) {
this.ranges.clear();
this.ranges.addAll(list);
Collections.sort(this.ranges);
fireTableDataChanged();
}
 
@Override
public String getColumnName(final int column) {
if (column == 0) {
return "Début";
} else {
return "Fin";
}
}
 
public void remove(final int[] selection) {
for (int i = selection.length - 1; i >= 0; i--) {
this.ranges.remove(selection[i]);
}
fireTableDataChanged();
}
 
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DateTimeCellEditor.java
New file
0,0 → 1,49
/*
* 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 30 janv. 2015
*/
package org.openconcerto.ui.date;
 
import org.openconcerto.ui.JDateTime;
 
import java.awt.Component;
import java.util.Calendar;
import java.util.Date;
 
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
 
public class DateTimeCellEditor extends AbstractCellEditor implements TableCellEditor {
 
private static final long serialVersionUID = -658886621619885412L;
private final JDateTime datetime = new JDateTime(false);
 
@Override
public Object getCellEditorValue() {
Date result = this.datetime.getValue();
if (result == null) {
result = Calendar.getInstance().getTime();
}
return result;
}
 
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
this.datetime.setValue((Date) value);
return this.datetime;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DateRange.java
New file
0,0 → 1,60
/*
* 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.ui.date;
 
import java.text.DateFormat;
import java.util.Date;
 
public class DateRange implements Comparable<DateRange> {
private static final int MS_PER_HOUR = 3600 * 1000;
private long start;
private long stop;
 
public DateRange() {
this.start = System.currentTimeMillis();
this.stop = System.currentTimeMillis() + MS_PER_HOUR;
}
 
public DateRange(final long start) {
this.start = start;
this.stop = start + MS_PER_HOUR;
}
 
public long getStart() {
return this.start;
}
 
public long getStop() {
return this.stop;
}
 
public void setStart(final long start) {
this.start = start;
}
 
public void setStop(final long stop) {
this.stop = stop;
}
 
@Override
public int compareTo(final DateRange o) {
return (int) (this.start - o.start);
}
 
@Override
public String toString() {
DateFormat f = DateFormat.getDateTimeInstance();
return f.format(new Date(start)) + " -> " + f.format(new Date(stop));
}
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DateRangePlannerPanel.java
New file
0,0 → 1,781
/*
* 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.ui.date;
 
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.JTime;
import org.openconcerto.ui.TM;
import org.openconcerto.ui.component.JRadioButtons;
import org.openconcerto.ui.date.EventProviders.Daily;
import org.openconcerto.ui.date.EventProviders.Monthly;
import org.openconcerto.ui.date.EventProviders.MonthlyDayOfWeek;
import org.openconcerto.ui.date.EventProviders.Weekly;
import org.openconcerto.ui.date.EventProviders.Yearly;
import org.openconcerto.ui.date.EventProviders.YearlyDayOfWeekEventProvider;
import org.openconcerto.utils.TimeUtils;
import org.openconcerto.utils.i18n.TM.MissingMode;
 
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.ButtonGroup;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
 
import com.ibm.icu.text.RuleBasedNumberFormat;
 
@SuppressWarnings("unqualified-field-access")
public class DateRangePlannerPanel extends JPanel {
 
private static final long serialVersionUID = 1006612828847678846L;
 
private JTime timeStart;
private JTime timeEnd;
private Component currentPanel;
private JRadioButtons<Period> radioPeriod;
private Map<Period, Component> panels;
 
// Date range
private JRadioButton radioEndAt;
private JDate dateStart;
private JDate dateEnd;
private JSpinner spinDateRangeCount;
private JRadioButton dayRadio;
private JSpinner dayEveryDay;
private JSpinner weekIncrementSpinner;
private Set<DayOfWeek> weekDays;
 
// monthly
private int monthIncrement = -1;
private JSpinner dayOfMonth;
private JComboBox comboWeekOfMonth;
private JComboBox comboWeekDayOfMonth;
 
// yearly
private int yearlyMonth = -1;
private JSpinner yearlyDayOfMonth;
private JComboBox yearlyComboWeekOfMonth;
private JComboBox yearlyComboWeekDayOfMonth;
 
public DateRangePlannerPanel() {
this.weekDays = new HashSet<DayOfWeek>();
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
final JLabelBold timeLabel = new JLabelBold("Horaires");
this.add(timeLabel, c);
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 1;
c.gridy++;
// Time
 
this.add(createTimePanel(), c);
c.gridy++;
// Period
final JLabelBold periodLabel = new JLabelBold("Périodicité");
this.add(periodLabel, c);
c.gridy++;
this.add(createPerdiodPanel(), c);
c.gridy++;
// Range
final JLabel rangeLabel = new JLabel("Plage de périodicité");
this.add(rangeLabel, c);
c.gridy++;
c.weighty = 1;
this.add(createRangePanel(), c);
 
}
 
private Component createTimePanel() {
final JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.LEFT));
p.add(new JLabel("Heure de début"));
timeStart = new JTime(true, false);
 
p.add(timeStart);
p.add(new JLabel(" Fin"));
timeEnd = new JTime(true, false);
timeEnd.setTimeInMillis(Math.min(86400000 - 1, timeStart.getTimeInMillis() + 3600 * 1000));
p.add(timeEnd);
 
timeStart.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
long delta = timeEnd.getTimeInMillis() - timeStart.getTimeInMillis();
if (delta < 60 * 1000) {
timeEnd.setTimeInMillis(timeStart.getTimeInMillis() + 60 * 1000);
}
}
});
 
timeEnd.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
long delta = timeEnd.getTimeInMillis() - timeStart.getTimeInMillis();
if (delta < 60 * 1000) {
timeStart.setTimeInMillis(timeEnd.getTimeInMillis() - 60 * 1000);
}
}
});
return p;
}
 
private Component createPerdiodPanel() {
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
final Map<Period, String> choices = new LinkedHashMap<Period, String>();
choices.put(Period.DAY, "Quotidienne");
choices.put(Period.WEEK, "Hebdomadaire");
choices.put(Period.MONTH, "Mensuelle");
choices.put(Period.YEAR, "Annuelle");
 
radioPeriod = new JRadioButtons<Period>(false, choices);
radioPeriod.setValue(Period.WEEK);
p.add(radioPeriod, c);
c.gridx++;
c.fill = GridBagConstraints.VERTICAL;
p.add(new JSeparator(JSeparator.VERTICAL), c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.BOTH;
this.panels = new HashMap<Period, Component>();
this.panels.put(Period.DAY, createDayPanel());
this.panels.put(Period.WEEK, createWeekPanel());
this.panels.put(Period.MONTH, createMonthPanel());
this.panels.put(Period.YEAR, createYearPanel());
this.currentPanel = this.panels.get(Period.WEEK);
p.add(currentPanel, c);
this.currentPanel.setPreferredSize(new Dimension(currentPanel.getPreferredSize().width + 80, currentPanel.getPreferredSize().height));
 
radioPeriod.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getNewValue() != null) {
final Period id = (Period) evt.getNewValue();
p.remove(currentPanel);
currentPanel = panels.get(id);
p.add(currentPanel, c);
p.revalidate();
p.repaint();
}
}
});
 
return p;
}
 
private Component createRangePanel() {
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
p.add(new JLabel("Début"), c);
c.fill = GridBagConstraints.NONE;
c.gridx++;
dateStart = new JDate(true, true);
p.add(dateStart, c);
c.gridx++;
radioEndAt = new JRadioButton("Fin le");
radioEndAt.setSelected(true);
p.add(radioEndAt, c);
c.gridx++;
dateEnd = new JDate(false, true);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 7);
dateEnd.setValue(cal.getTime());
c.gridwidth = 2;
p.add(dateEnd, c);
//
c.gridy++;
c.gridwidth = 1;
c.gridx = 2;
final JRadioButton radioRepeat = new JRadioButton("Fin après");
p.add(radioRepeat, c);
c.gridx++;
spinDateRangeCount = new JSpinner(new SpinnerNumberModel(1, 1, 365 * 100, 1));
spinDateRangeCount.setEnabled(false);
p.add(spinDateRangeCount, c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel("occurences"), c);
ButtonGroup group = new ButtonGroup();
group.add(radioEndAt);
group.add(radioRepeat);
 
radioEndAt.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
spinDateRangeCount.setEnabled(radioRepeat.isSelected());
dateEnd.setEnabled(!radioRepeat.isSelected());
}
});
radioRepeat.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
spinDateRangeCount.setEnabled(radioRepeat.isSelected());
dateEnd.setEnabled(!radioRepeat.isSelected());
}
});
return p;
}
 
// DAY
private Component createDayPanel() {
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(0, 0, 0, 2);
//
final JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 0));
dayRadio = new JRadioButton("Tous les ");
dayRadio.setSelected(true);
dayEveryDay = new JSpinner(new SpinnerNumberModel(1, 1, 365, 1));
final JLabel labelEvery = new JLabel("jour");
dayEveryDay.addChangeListener(new ChangeListener() {
 
@Override
public void stateChanged(ChangeEvent e) {
if (dayEveryDay.getValue().toString().equals("1")) {
labelEvery.setText("jour");
} else {
labelEvery.setText("jours");
}
 
}
});
p1.add(dayRadio);
p1.add(dayEveryDay);
p1.add(labelEvery);
//
final JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
final JRadioButton b2 = new JRadioButton("Tous les jours ouvrables");
p2.add(b2);
//
dayRadio.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
dayEveryDay.setEnabled(dayRadio.isSelected());
}
});
b2.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
dayEveryDay.setEnabled(dayRadio.isSelected());
}
});
 
//
ButtonGroup g = new ButtonGroup();
g.add(dayRadio);
g.add(b2);
p1.setOpaque(false);
p2.setOpaque(false);
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
p.add(p1, c);
c.gridy++;
c.weighty = 1;
 
p.add(p2, c);
return p;
 
}
 
// WEEK
 
private Component createWeekPanel() {
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(0, 4, 0, 4);
c.anchor = GridBagConstraints.NORTHWEST;
//
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 0));
p1.add(new JLabel("Toutes les"));
weekIncrementSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 365, 1));
final JLabel labelEvery = new JLabel("semaine, le :");
weekIncrementSpinner.addChangeListener(new ChangeListener() {
 
@Override
public void stateChanged(ChangeEvent e) {
if (weekIncrementSpinner.getValue().toString().equals("1")) {
labelEvery.setText("semaine, le :");
} else {
labelEvery.setText("semaines, le :");
}
 
}
});
p1.add(weekIncrementSpinner);
p1.add(labelEvery);
c.gridwidth = 4;
p.add(p1, c);
//
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
 
final String[] namesOfDays = DateFormatSymbols.getInstance().getWeekdays();
final DayOfWeek[] week = DayOfWeek.getWeek(Calendar.getInstance());
final int weekLength = week.length;
final int midWeek = weekLength / 2;
for (int i = 0; i < weekLength; i++) {
final DayOfWeek d = week[i];
if (i == midWeek) {
c.weightx = 1;
} else {
c.weightx = 0;
}
final JCheckBox cb = new JCheckBox(namesOfDays[d.getCalendarField()]);
cb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
weekDays.add(d);
} else {
weekDays.remove(d);
}
}
});
p.add(cb, c);
if (i == midWeek) {
c.gridx = 0;
c.gridy++;
c.weighty = 1;
} else {
c.gridx++;
}
}
 
return p;
}
 
protected final void setMonthIncrement(Object src) {
this.monthIncrement = (Integer) ((JSpinner) src).getValue();
}
 
// MONTH
private Component createMonthPanel() {
final Calendar cal = Calendar.getInstance();
 
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(0, 4, 0, 4);
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 1;
//
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 0));
final JRadioButton radio1 = new JRadioButton("Le");
radio1.setSelected(true);
p1.add(radio1);
this.dayOfMonth = createDayOfMonthSpinner(cal);
p1.add(this.dayOfMonth);
p1.add(new JLabel("tous les"));
final JSpinner spin2 = new JSpinner(new SpinnerNumberModel(1, 1, 96, 1));
final ChangeListener setMonthIncrementCL = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
setMonthIncrement(e.getSource());
}
};
spin2.addChangeListener(setMonthIncrementCL);
p1.add(spin2);
p1.add(new JLabel("mois"));
p.add(p1, c);
//
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 0));
final JRadioButton radio2 = new JRadioButton("Le");
p2.add(radio2);
this.comboWeekOfMonth = createWeekOfMonthCombo();
p2.add(comboWeekOfMonth);
 
this.comboWeekDayOfMonth = createWeekDayOfMonthCombo(cal);
p2.add(comboWeekDayOfMonth);
p2.add(new JLabel("tous les"));
final JSpinner spin3 = new JSpinner(new SpinnerNumberModel(1, 1, 96, 1));
p2.add(spin3);
p2.add(new JLabel("mois"));
spin3.addChangeListener(setMonthIncrementCL);
 
c.gridy++;
c.weighty = 1;
p.add(p2, c);
ButtonGroup g = new ButtonGroup();
g.add(radio1);
g.add(radio2);
 
final ActionListener listener = new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final boolean selected = radio1.isSelected();
dayOfMonth.setEnabled(selected);
spin2.setEnabled(selected);
 
comboWeekOfMonth.setEnabled(!selected);
comboWeekDayOfMonth.setEnabled(!selected);
spin3.setEnabled(!selected);
 
setMonthIncrement(selected ? spin2 : spin3);
}
};
radio1.addActionListener(listener);
radio2.addActionListener(listener);
// initialize
listener.actionPerformed(null);
return p;
}
 
protected JSpinner createDayOfMonthSpinner(final Calendar cal) {
final int minDayOfMonth = cal.getMinimum(Calendar.DAY_OF_MONTH);
final int maxDayOfMonth = cal.getMaximum(Calendar.DAY_OF_MONTH);
return new JSpinner(new SpinnerNumberModel(minDayOfMonth, minDayOfMonth, maxDayOfMonth, 1));
}
 
protected JComboBox createWeekOfMonthCombo() {
final JComboBox res = new JComboBox(new Object[] { 1, 2, 3, 4, -2, -1 });
final RuleBasedNumberFormat f = new RuleBasedNumberFormat(RuleBasedNumberFormat.SPELLOUT);
final String rule = TM.getInstance().translate(MissingMode.NULL, "day.spelloutRule");
if (rule != null)
f.setDefaultRuleSet(rule);
res.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final String v;
final long weekIndex = ((Number) value).longValue();
if (weekIndex == -2)
v = TM.getInstance().translate("day.spellout.beforeLast");
else if (weekIndex == -1)
v = TM.getInstance().translate("day.spellout.last");
else
v = f.format(weekIndex);
return super.getListCellRendererComponent(list, v, index, isSelected, cellHasFocus);
}
});
return res;
}
 
protected JComboBox createWeekDayOfMonthCombo(final Calendar cal) {
final String[] namesOfDays = DateFormatSymbols.getInstance().getWeekdays();
final DayOfWeek[] week = DayOfWeek.getWeek(cal);
final JComboBox res = new JComboBox(week);
res.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
return super.getListCellRendererComponent(list, namesOfDays[((DayOfWeek) value).getCalendarField()], index, isSelected, cellHasFocus);
}
});
return res;
}
 
protected JComboBox createMonthCombo() {
final String[] namesOfMonths = DateFormatSymbols.getInstance().getMonths();
final Object[] monthsIndex = new Object[namesOfMonths.length];
for (int i = 0; i < namesOfMonths.length; i++) {
// from Calendar.MONTH : starts at 0
monthsIndex[i] = i;
}
final JComboBox res = new JComboBox(monthsIndex);
res.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
return super.getListCellRendererComponent(list, namesOfMonths[((Number) value).intValue()], index, isSelected, cellHasFocus);
}
});
return res;
}
 
// YEAR
private Component createYearPanel() {
final Calendar cal = Calendar.getInstance();
 
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(0, 4, 0, 4);
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 1;
//
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 0));
final JRadioButton radio1 = new JRadioButton("Chaque");
radio1.setSelected(true);
p1.add(radio1);
this.yearlyDayOfMonth = this.createDayOfMonthSpinner(cal);
p1.add(this.yearlyDayOfMonth);
 
final JComboBox combo0 = createMonthCombo();
p1.add(combo0);
p.add(p1, c);
//
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 0));
final JRadioButton radio2 = new JRadioButton("Le");
p2.add(radio2);
this.yearlyComboWeekOfMonth = this.createWeekOfMonthCombo();
p2.add(this.yearlyComboWeekOfMonth);
 
yearlyComboWeekDayOfMonth = this.createWeekDayOfMonthCombo(cal);
p2.add(yearlyComboWeekDayOfMonth);
p2.add(new JLabel("de"));
final JComboBox combo3 = createMonthCombo();
p2.add(combo3);
 
c.gridy++;
c.weighty = 1;
p.add(p2, c);
ButtonGroup g = new ButtonGroup();
g.add(radio1);
g.add(radio2);
 
final ActionListener listener = new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final boolean selected = radio1.isSelected();
yearlyDayOfMonth.setEnabled(selected);
combo0.setEnabled(selected);
 
yearlyComboWeekOfMonth.setEnabled(!selected);
yearlyComboWeekDayOfMonth.setEnabled(!selected);
combo3.setEnabled(!selected);
 
setYearlyMonth(selected ? combo0 : combo3);
}
};
radio1.addActionListener(listener);
radio2.addActionListener(listener);
final ItemListener monthL = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
setYearlyMonth(e.getSource());
}
}
};
combo0.addItemListener(monthL);
combo3.addItemListener(monthL);
// initialize
listener.actionPerformed(null);
return p;
}
 
protected final void setYearlyMonth(final Object comp) {
this.yearlyMonth = (Integer) ((JComboBox) comp).getSelectedItem();
}
 
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (final Exception e) {
e.printStackTrace();
}
 
final JFrame f = new JFrame();
JPanel p = new JPanel();
 
final DateRangePlannerPanel planner = new DateRangePlannerPanel();
p.setLayout(new BorderLayout());
 
p.add(planner, BorderLayout.CENTER);
final JButton b = new JButton("Print ranges");
p.add(b, BorderLayout.SOUTH);
b.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
List<DateRange> ranges = planner.getRanges();
System.out.println("---- " + ranges.size() + " ranges :");
for (DateRange dateRange : ranges) {
System.out.println(dateRange);
}
}
});
f.setContentPane(p);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
 
}
});
}
 
public List<DateRange> getRanges() {
final Period type = radioPeriod.getValue();
final Date startDate = this.dateStart.getValue();
final int timeStartInMS = this.timeStart.getTimeInMillis().intValue();
final int timeEndInMS = this.timeEnd.getTimeInMillis().intValue();
 
final boolean endAfterDate = this.radioEndAt.isSelected();
final Date endDate;
final int eventCount;
if (endAfterDate) {
endDate = this.dateEnd.getValue();
if (endDate.compareTo(startDate) < 0)
throw new IllegalArgumentException("End before start");
eventCount = -1;
} else {
endDate = null;
eventCount = ((Number) this.spinDateRangeCount.getValue()).intValue();
if (eventCount <= 0)
throw new IllegalArgumentException("Negative event count : " + eventCount);
}
 
final Calendar c = Calendar.getInstance();
c.setTime(startDate);
 
final EventProvider prov;
if (type == Period.DAY) {
if (dayRadio.isSelected()) {
final int incr = ((Number) dayEveryDay.getValue()).intValue();
prov = new Daily(incr);
} else {
prov = new Weekly(1, DayOfWeek.WORKING_DAYS);
}
} else if (type == Period.WEEK) {
if (this.weekDays.isEmpty()) {
prov = null;
} else {
final int incr = ((Number) this.weekIncrementSpinner.getValue()).intValue();
prov = new Weekly(incr, this.weekDays);
}
} else if (type == Period.MONTH) {
if (this.dayOfMonth.isEnabled()) {
prov = new Monthly((Integer) this.dayOfMonth.getValue(), this.monthIncrement);
} else {
prov = new MonthlyDayOfWeek((Integer) this.comboWeekOfMonth.getSelectedItem(), (DayOfWeek) this.comboWeekDayOfMonth.getSelectedItem(), this.monthIncrement);
}
} else if (type == Period.YEAR) {
if (this.yearlyDayOfMonth.isEnabled()) {
prov = new Yearly((Integer) this.yearlyDayOfMonth.getValue(), this.yearlyMonth, 1);
} else {
prov = new YearlyDayOfWeekEventProvider((Integer) this.yearlyComboWeekOfMonth.getSelectedItem(), (DayOfWeek) this.yearlyComboWeekDayOfMonth.getSelectedItem(), this.yearlyMonth, 1);
}
} else {
throw new IllegalStateException("invalid type: " + type);
}
if (prov == null)
return Collections.emptyList();
 
prov.next(c, true);
final List<DateRange> result = new ArrayList<DateRange>();
// use a different calendar since setStartAndStop() might change the day
final Calendar startStopCal = (Calendar) c.clone();
while (before(c, endDate) && lessThan(result.size(), eventCount)) {
final DateRange r = new DateRange();
final Date currentTime = c.getTime();
startStopCal.setTime(currentTime);
setStartAndStop(r, startStopCal, timeStartInMS, timeEndInMS);
result.add(r);
prov.next(c, false);
// prevent infinite loop
if (currentTime.compareTo(c.getTime()) >= 0)
throw new IllegalStateException("Provider hasn't moved time forward");
}
return result;
}
 
private boolean before(Calendar c, Date endDate) {
if (endDate == null)
return true;
return c.getTime().compareTo(endDate) <= 0;
}
 
private boolean lessThan(int currentEventCount, int eventCount) {
if (eventCount < 0)
return true;
return currentEventCount < eventCount;
}
 
protected void setStartAndStop(DateRange r, final Calendar c, final int timeStartInMS, final int timeEndInMS) {
final int day = c.get(Calendar.DAY_OF_YEAR);
TimeUtils.clearTime(c);
c.add(Calendar.MILLISECOND, timeStartInMS);
if (c.get(Calendar.DAY_OF_YEAR) != day)
throw new IllegalArgumentException("More than a day : " + timeStartInMS);
r.setStart(c.getTimeInMillis());
 
if (timeEndInMS < timeStartInMS) {
// pass midnight
TimeUtils.clearTime(c);
c.add(Calendar.DAY_OF_YEAR, 1);
c.add(Calendar.MILLISECOND, timeEndInMS);
// timeEndInMS < timeStartInMS && timeStartInMS < dayLength thus timeEndInMS < dayLength
assert c.get(Calendar.DAY_OF_YEAR) == day + 1;
} else {
c.add(Calendar.MILLISECOND, timeEndInMS - timeStartInMS);
if (c.get(Calendar.DAY_OF_YEAR) != day)
throw new IllegalArgumentException("More than a day : " + timeEndInMS);
}
r.setStop(c.getTimeInMillis());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/ui/date/EventProvider.java
New file
0,0 → 1,21
/*
* 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.ui.date;
 
import java.util.Calendar;
 
interface EventProvider {
// pass false if c must be modified
public abstract void next(final Calendar c, final boolean initialValue);
}
/trunk/OpenConcerto/src/org/openconcerto/ui/JDateTime.java
22,6 → 22,7
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.ParseException;
import java.util.Date;
 
import javax.swing.JComponent;
133,6 → 134,11
this.supp.removePropertyChangeListener("value", l);
}
 
public void commitEdit() throws ParseException {
this.date.commitEdit();
this.time.commitEdit();
}
 
@Override
public JComponent getComp() {
return this;
/trunk/OpenConcerto/src/org/openconcerto/ui/JTime.java
22,6 → 22,7
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
170,6 → 171,12
this.getEditor().removePropertyChangeListener("value", l);
}
 
// useful since by default this commits on focus lost, as is a table cell editor. So sometimes
// the table cell editor is called back before the commit and thus takes the original value.
public void commitEdit() throws ParseException {
this.text.commitEdit();
}
 
@Override
public JComponent getComp() {
return this;
/trunk/OpenConcerto/src/org/openconcerto/ui/group/LayoutHints.java
22,6 → 22,8
private final boolean largeHeight;
 
private final boolean showLabel;
// true if the layouted element (group or label+editor) is visually separated from the others
// elements
private final boolean separated;
private final boolean fillWidth;
private final boolean fillHeight;
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLField.java
394,6 → 394,21
return this.getTable();
}
 
/**
* Return this field in the passed table.
*
* @param table a table, e.g OBSERVATION obs.
* @return a field in the passed table, e.g. if this is OBSERVATION.DESIGNATION then
* obs.DESIGNATION.
* @throws IllegalArgumentException if this field is not in the same table as the argument.
* @see {@link TableRef#getField(String)}
*/
public final FieldRef getFieldRef(TableRef table) throws IllegalArgumentException {
if (table.getTable() != this.getTable())
throw new IllegalArgumentException("Table mismatch for " + table + " and " + this);
return table.getField(this.getName());
}
 
public synchronized String toXML() {
if (this.xml == null) {
final StringBuilder sb = new StringBuilder(2048);
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLRowValuesCluster.java
178,8 → 178,12
newCluster.getListeners().put(key, this.listeners.remove(key));
}
}
assert !this.items.isEmpty() && !newCluster.items.isEmpty() && !CollectionUtils.containsAny(this.items, newCluster.items) : "Empty or shared items while removing " + f + " -> " + dest
+ " from " + src;
// http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6612102
// resolved in 7b25 : iterator.remove() might decrement the size twice : e.g. size is 0
// and thus isEmpty() is true, while there's still elements in this.items
assert !this.items.isEmpty() : "Empty items while removing " + f + " -> " + dest + " from " + src;
assert !newCluster.items.isEmpty() : "New graph is empty while removing " + f + " -> " + dest + " from " + src;
assert !CollectionUtils.containsAny(this.items, newCluster.items) : "Shared items while removing " + f + " -> " + dest + " from " + src;
 
for (final SQLRowValues vals : newCluster.getItems())
vals.setGraph(newCluster);
/trunk/OpenConcerto/src/org/openconcerto/sql/utils/SQLUtils.java
94,7 → 94,7
* @throws X if <code>h</code> throw it.
*/
public static <T, X extends Exception> T executeAtomic(final SQLDataSource ds, final ConnectionHandlerNoSetup<T, X> h) throws SQLException, X {
return executeAtomic(ds, h, true);
return executeAtomic(ds, h, false);
}
 
/**
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/RowValuesTableModel.java
23,6 → 23,7
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.CompareUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.OrderedSet;
 
532,10 → 533,19
}
});
}
 
}
 
public void insertFrom(final SQLRowAccessor rowVals) {
insertFrom(rowVals, null);
}
 
public void insertFrom(final SQLRowAccessor rowVals, final SQLField referentField) {
insertFrom(rowVals, referentField, null, null);
}
 
// Remplit la table à partir de la SQLRow parente
public void insertFrom(final SQLRowAccessor rowVals) {
public void insertFrom(final SQLRowAccessor rowVals, final SQLField referentField, final SQLField fieldWhere, final Object value) {
if (!SwingUtilities.isEventDispatchThread()) {
Thread.dumpStack();
}
551,15 → 561,22
List<SQLRow> rowSet = row.getReferentRows(RowValuesTableModel.this.element.getTable());
 
for (SQLRow row2 : rowSet) {
if (fieldWhere == null || CompareUtils.equals(row2.getObject(fieldWhere.getName()), value)) {
SQLRowValues rowVals2 = new SQLRowValues(RowValuesTableModel.this.element.getTable());
rowVals2.loadAbsolutelyAll(row2);
newRows.add(rowVals2);
}
}
 
} else {
Collection<? extends SQLRowAccessor> colRows = rowVals.getReferentRows();
final Collection<? extends SQLRowAccessor> colRows;
if (referentField == null) {
colRows = rowVals.getReferentRows(RowValuesTableModel.this.element.getTable());
} else {
colRows = rowVals.getReferentRows(referentField);
}
for (SQLRowAccessor rowValues : colRows) {
if (rowValues.getTable().getName().equalsIgnoreCase(RowValuesTableModel.this.element.getTable().getName())) {
if (fieldWhere == null || CompareUtils.equals(rowValues.getObject(fieldWhere.getName()), value)) {
newRows.add(rowValues.asRowValues());
}
}
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/SQLTableElement.java
24,7 → 24,7
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.ui.TextAreaRenderer;
import org.openconcerto.ui.TextAreaTableCellEditor;
import org.openconcerto.ui.TimeStampTableCellEditor;
import org.openconcerto.ui.table.TimestampTableCellEditor;
import org.openconcerto.utils.CompareUtils;
 
import java.awt.event.ActionEvent;
202,7 → 202,7
textEditor.setLimitedSize(this.field.getType().getSize());
return textEditor;
} else if (this.field.getType().getJavaType() == Timestamp.class) {
final TimeStampTableCellEditor textEditor = new TimeStampTableCellEditor();
final TimestampTableCellEditor textEditor = new TimestampTableCellEditor(false);
return textEditor;
}
}
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/RowValuesTable.java
341,8 → 341,13
}
 
public SQLRowValues getSelectedRowValues() {
try {
return this.model.getRowValuesAt(this.getSelectedRow());
} catch (Exception e) {
// can happen when no selected row
return null;
}
}
 
public XTableColumnModel getColumnModel() {
return (XTableColumnModel) super.getColumnModel();
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/itemview/VWRowItemView.java
13,8 → 13,11
package org.openconcerto.sql.sqlobject.itemview;
 
import org.openconcerto.sql.element.RIVPanel;
import org.openconcerto.sql.element.SQLComponentItem;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.request.SQLRowItemView;
import org.openconcerto.ui.valuewrapper.ValueWrapper;
import org.openconcerto.utils.cc.IPredicate;
import org.openconcerto.utils.checks.ChainValidListener;
34,7 → 37,7
* @author Sylvain CUAZ
* @param <T> type of value
*/
public abstract class VWRowItemView<T> extends BaseRowItemView {
public abstract class VWRowItemView<T> extends BaseRowItemView implements SQLComponentItem {
 
private final ValueWrapper<T> wrapper;
private EmptyObjHelper helper;
52,6 → 55,15
this.helper = this.createHelper();
}
 
@Override
public void added(RIVPanel comp, SQLRowItemView v) {
// re-use SQLComponentItem even though the second parameter is useless
assert v == this;
if (getWrapper() instanceof SQLComponentItem) {
((SQLComponentItem) getWrapper()).added(comp, v);
}
}
 
private final EmptyObjHelper createHelper() {
final EmptyObj eo;
if (this.getWrapper() instanceof EmptyObj)
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/IComboModel.java
117,8 → 117,14
this.running = false;
 
this.setSelectOnAdd(false);
// we always change the selection after changing the items
this.setOnRemovingOrReplacingSelection(NewSelection.NO);
// we always change the selection after changing the items so don't make an extra fire
// (replace takes place in reloadComboItem() and doUpdateAll())
this.setOnReplacingSelection(NewSelection.NO);
// if an item was removed, we obviously can't keep referring to it. E.g. we're creating a
// new client and have selected an address that gets deleted. We can't just keep pointing to
// the deleted address, the insertion will fail, better to let the user know right ahead.
// (remove takes place in reloadComboItem())
this.setOnRemovingSelection(NewSelection.NONE);
 
this.uiInit();
}
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/JUniqueTextField.java
13,6 → 13,9
package org.openconcerto.sql.sqlobject;
 
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.RIVPanel;
import org.openconcerto.sql.element.SQLComponentItem;
import org.openconcerto.sql.model.IResultSetHandler;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLField;
43,6 → 46,7
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
import java.util.Vector;
63,7 → 67,7
* @author Administrateur
*
*/
public class JUniqueTextField extends JPanel implements ValueWrapper<String>, Documented, TextComponent, RowItemViewComponent, MouseListener {
public class JUniqueTextField extends JPanel implements ValueWrapper<String>, Documented, TextComponent, RowItemViewComponent, SQLComponentItem, MouseListener {
 
private JTextField textField;
private JLabelWarning labelWarning;
303,6 → 307,17
return this.field;
}
 
@Override
public void added(RIVPanel comp, SQLRowItemView v) {
((BaseSQLComponent) comp.getSQLComponent()).addSelectionListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
setIdSelected(((Number) evt.getNewValue()).intValue());
}
});
// MAYBE add removed() callback
}
 
public void setValue(String val) {
if (!this.textField.getText().equals(val))
this.textField.setText(val);
/trunk/OpenConcerto/src/org/openconcerto/sql/element/TreesOfSQLRows.java
31,7 → 31,7
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.SetMap;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.Tuple3;
import org.openconcerto.utils.cc.ITransformer;
 
import java.sql.SQLException;
75,6 → 75,7
 
private final SQLElement elem;
private final Map<SQLRow, SQLRowValues> trees;
private final Set<SQLRow> mainRows;
private SetMap<SQLField, SQLRow> externReferences;
 
public TreesOfSQLRows(final SQLElement elem, SQLRow row) {
85,10 → 86,12
super();
this.elem = elem;
this.trees = new HashMap<SQLRow, SQLRowValues>(rows.size());
// check each row and remove duplicates (i.e. this.trees might be smaller than rows)
for (final SQLRowAccessor r : rows) {
this.elem.check(r);
this.trees.put(r.asRow(), null);
}
this.mainRows = new HashSet<SQLRow>();
this.externReferences = null;
}
 
102,10 → 105,12
 
public final Map<SQLRow, SQLRowValues> getTrees() throws SQLException {
if (this.externReferences == null) {
final Tuple2<Map<SQLRow, SQLRowValues>, SetMap<SQLField, SQLRow>> expand = this.expand();
assert expand.get0().keySet().equals(this.trees.keySet());
this.trees.putAll(expand.get0());
this.externReferences = expand.get1();
final Tuple3<Rows, Rows, SetMap<SQLField, SQLRow>> expand = this.expand();
assert expand.get0().vals.keySet().equals(this.trees.keySet());
// replace nulls by actual SQLRowValues
this.trees.putAll(expand.get0().vals);
this.mainRows.addAll(expand.get1().vals.keySet());
this.externReferences = expand.get2();
}
return Collections.unmodifiableMap(this.trees);
}
119,9 → 124,9
return res;
}
 
private final Tuple2<Map<SQLRow, SQLRowValues>, SetMap<SQLField, SQLRow>> expand() throws SQLException {
private final Tuple3<Rows, Rows, SetMap<SQLField, SQLRow>> expand() throws SQLException {
final Map<Integer, SQLRowValues> valsMap = new HashMap<Integer, SQLRowValues>();
final Map<SQLRow, SQLRowValues> hasBeen = new HashMap<SQLRow, SQLRowValues>();
final Rows hasBeen = new Rows();
final SetMap<SQLField, SQLRow> toCut = new SetMap<SQLField, SQLRow>();
 
// fetch privates of root rows
152,7 → 157,7
privates = null;
}
 
final Map<SQLRow, SQLRowValues> res = new HashMap<SQLRow, SQLRowValues>();
final Rows res = new Rows();
for (final SQLRow r : this.getRows()) {
SQLRowValues vals = valsMap.get(r.getID());
// when there's no private to fetch
167,7 → 172,7
expand(getElem().getTable(), valsMap, hasBeen, toCut, false);
if (privates != null)
privates.expand();
return Tuple2.create(res, toCut);
return Tuple3.create(res, hasBeen, toCut);
}
 
// NOTE using a collection of vals changed the time it took to archive a site (736 01) from 225s
177,14 → 182,14
*
* @param t the table, eg /LOCAL/.
* @param valsMap the values to expand, eg {3=>LOCAL(3)->BAT(4), 12=>LOCAL(12)->BAT(4)}.
* @param hasBeen the rows alredy expanded, eg {BAT[4], LOCAL[3], LOCAL[12]}.
* @param hasBeen the rows already expanded, eg {BAT[4], LOCAL[3], LOCAL[12]}.
* @param toCut the links to cut, eg {|BAT.ID_PRECEDENT|=> [BAT[2]]}.
* @param ignorePrivateParentRF <code>true</code> if
* {@link SQLElement#getPrivateParentReferentFields() private links} should be ignored.
* @throws SQLException if a link is {@link ReferenceAction#RESTRICT}.
*/
private final void expand(final SQLTable t, final Map<Integer, SQLRowValues> valsMap, final Map<SQLRow, SQLRowValues> hasBeen, final SetMap<SQLField, SQLRow> toCut,
final boolean ignorePrivateParentRF) throws SQLException {
private final void expand(final SQLTable t, final Map<Integer, SQLRowValues> valsMap, final Rows hasBeen, final SetMap<SQLField, SQLRow> toCut, final boolean ignorePrivateParentRF)
throws SQLException {
if (valsMap.size() == 0)
return;
 
223,7 → 228,7
});
for (final SQLRowValues newVals : fetcher.fetch()) {
final SQLRow r = newVals.asRow();
final boolean already = hasBeen.containsKey(r);
final boolean already = hasBeen.contains(r);
switch (action) {
case RESTRICT:
throw new SQLException(createRestrictDesc(refElem, newVals, link));
245,7 → 250,7
}
// if already expanded just link and do not add to next
if (already) {
hasBeen.get(r).put(ffName, valsMap.get(newVals.getInt(ffName)));
hasBeen.getValues(r).put(ffName, valsMap.get(newVals.getInt(ffName)));
}
}
 
260,12 → 265,12
final Iterator<SQLRow> iter2 = e.getValue().iterator();
while (iter2.hasNext()) {
final SQLRow rowToCut = iter2.next();
final SQLRowValues inGraphRowToCut = hasBeen.get(rowToCut);
final SQLRowValues inGraphRowToCut = hasBeen.getValues(rowToCut);
if (inGraphRowToCut != null) {
// remove from toCut
iter2.remove();
// add link
final SQLRowValues dest = hasBeen.get(rowToCut.getForeignRow(fieldName, SQLRowMode.NO_CHECK));
final SQLRowValues dest = hasBeen.getValues(rowToCut.getForeignRow(fieldName, SQLRowMode.NO_CHECK));
if (dest == null)
throw new IllegalStateException("destination of link to cut " + fieldName + " not found for " + rowToCut);
inGraphRowToCut.put(fieldName, dest);
277,21 → 282,22
}
 
private final class Privates {
private final Map<SQLRow, SQLRowValues> hasBeen;
private final Rows hasBeen;
private final SetMap<SQLField, SQLRow> toCut;
private final Map<SQLTable, Map<Integer, SQLRowValues>> privateRows;
 
public Privates(final Map<SQLRow, SQLRowValues> hasBeen, final SetMap<SQLField, SQLRow> toCut) {
public Privates(final Rows hasBeen, final SetMap<SQLField, SQLRow> toCut) {
this.hasBeen = hasBeen;
this.toCut = toCut;
this.privateRows = new HashMap<SQLTable, Map<Integer, SQLRowValues>>();
}
 
// main row linked to its private graph
private void collect(final SQLRowValues mainRow) {
for (final SQLRowValues privateVals : mainRow.getGraph().getItems()) {
if (privateVals != mainRow) {
// since newVals isn't in, its privates can't
assert !this.hasBeen.containsKey(privateVals.asRow());
assert !this.hasBeen.contains(privateVals.asRow());
Map<Integer, SQLRowValues> map = this.privateRows.get(privateVals.getTable());
if (map == null) {
map = new HashMap<Integer, SQLRowValues>();
309,10 → 315,34
}
}
 
// unique SQLRowValues indexed by SQLRow
static private final class Rows {
 
private final Map<SQLRow, SQLRowValues> vals;
 
private Rows() {
this.vals = new HashMap<SQLRow, SQLRowValues>();
}
 
private boolean contains(final SQLRow r) {
return this.vals.containsKey(r);
}
 
private SQLRowValues getValues(final SQLRow r) {
return this.vals.get(r);
}
 
private void put(final SQLRow r, final SQLRowValues newVals) {
assert newVals.asRow().equals(r);
if (this.vals.put(r, newVals) != null)
throw new IllegalStateException("Row already in : " + newVals);
}
}
 
// ***
 
/**
* Put all the rows of the trees (except the roots) in a map by table.
* Put all the main (i.e. non private) rows of the trees (except the roots) in a map by table.
*
* @return the descendants by table.
* @throws SQLException if the trees could not be fetched.
322,7 → 352,8
final Set<SQLRow> roots = this.getRows();
for (final SQLRowValuesCluster c : this.getClusters()) {
for (final SQLRowValues v : c.getItems()) {
if (!roots.contains(v.asRow()))
final SQLRow r = v.asRow();
if (!roots.contains(r) && this.mainRows.contains(r))
res.add(v.getTable(), v);
}
}
/trunk/OpenConcerto/src/org/openconcerto/sql/element/SQLElement.java
1490,15 → 1490,17
*
* @param row the row to copy, can be <code>null</code>.
* @param parent the parent the copy will be in, <code>null</code> meaning the same as
* <code>row</code>.
* <code>row</code>. If it's an {@link SQLRowValues} it will be used directly, otherwise
* {@link SQLRowAccessor#getIDNumber()} will be used (i.e. if the copy isn't to be linked
* to its parent, pass a {@link SQLRowAccessor#asRow() row}).
* @return a copy ready to be inserted, or <code>null</code> if <code>row</code> cannot be
* copied.
*/
public SQLRowValues createCopy(SQLRowAccessor row, SQLRow parent) {
public SQLRowValues createCopy(SQLRowAccessor row, SQLRowAccessor parent) {
return createCopy(row, false, parent);
}
 
public SQLRowValues createCopy(SQLRowAccessor row, final boolean full, SQLRow parent) {
public SQLRowValues createCopy(SQLRowAccessor row, final boolean full, SQLRowAccessor parent) {
// do NOT copy the undefined
if (row == null || row.isUndefined())
return null;
1522,7 → 1524,7
final SQLTable foreignTable = this.getParentForeignField().getForeignTable();
if (!parent.getTable().equals(foreignTable))
throw new IllegalArgumentException(parent + " is not a parent of " + row);
copy.put(this.getParentForeignFieldName(), parent.getID());
copy.put(this.getParentForeignFieldName(), parent instanceof SQLRowValues ? parent : parent.getIDNumber());
}
 
return copy;
2010,6 → 2012,8
if (!UserRightsManager.getCurrentUserRights().canDelete(getTable()))
throw new SQLException("forbidden");
final TreesOfSQLRows trees = TreesOfSQLRows.createFromIDs(this, ids);
// only display main rows since the user might not be aware of the private ones (the UI
// might hide the fact that one panel is in fact multiple rows)
final Map<SQLTable, List<SQLRowAccessor>> descs = trees.getDescendantsByTable();
final SortedMap<SQLField, Integer> externRefs = trees.getExternReferencesCount();
final String confirmDelete = getTM().trA("sqlElement.confirmDelete");
/trunk/OpenConcerto/src/org/openconcerto/sql/element/BaseSQLComponent.java
391,6 → 391,9
}
this.getRequest().add(v);
 
if (v instanceof SQLComponentItem) {
((SQLComponentItem) v).added(this, v);
}
if (v.getComp() instanceof SQLComponentItem) {
((SQLComponentItem) v.getComp()).added(this, v);
}
497,6 → 500,23
return this.getRequest().getView(comp);
}
 
/**
* Return each view that has at least one of {@link SQLRowItemView#getFields() its fields} in
* the passed set.
*
* @param fields the fields to search for.
* @return all views that contains <code>fields</code>.
*/
public final List<SQLRowItemView> getViews(final Set<SQLField> fields) {
final List<SQLRowItemView> res = new ArrayList<SQLRowItemView>();
for (final SQLRowItemView v : this.getRequest().getViews()) {
if (!Collections.disjoint(fields, v.getFields())) {
res.add(v);
}
}
return res;
}
 
protected final SQLForeignRowItemView getForeignView(SQLRowItemView v) {
if (v instanceof SQLForeignRowItemView)
return (SQLForeignRowItemView) v;
/trunk/OpenConcerto/src/org/openconcerto/sql/element/GroupSQLComponent.java
98,7 → 98,7
return;
}
 
if (size.isSeparated()) {
if (size.isSeparated() || size.isSplit()) {
x = 0;
c.gridx = 0;
c.gridy++;
151,7 → 151,7
c.weightx = 0;
c.weighty = 0;
// Label
if (size.isSeparated()) {
if (size.isSplit()) {
c.gridwidth = 4;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
159,7 → 159,7
c.fill = GridBagConstraints.HORIZONTAL;
}
panel.add(getLabel(id), c);
if (size.isSeparated()) {
if (size.isSplit()) {
c.gridy++;
c.gridx = 0;
} else {
185,13 → 185,13
c.weighty = 0;
}
if (size.largeWidth()) {
if (size.isSeparated()) {
if (size.isSplit()) {
c.gridwidth = this.columns * 2;
} else {
c.gridwidth = this.columns * 2 - 1;
}
} else {
if (size.showLabel() && !size.isSeparated()) {
if (size.showLabel() && !size.isSplit()) {
c.gridwidth = 1;
} else {
c.gridwidth = 2;
215,7 → 215,7
}
 
if (size.largeWidth()) {
if (size.isSeparated()) {
if (size.isSplit()) {
c.gridx += 4;
} else {
c.gridx += 3;
224,7 → 224,7
c.gridx++;
}
 
if (c.gridx >= this.columns * 2) {
if (c.gridx >= this.columns * 2 || size.isSeparated()) {
c.gridx = 0;
c.gridy++;
x = 0;
365,7 → 365,6
protected JComponent createLabel(final String id) {
final JLabel jLabel = new JLabel();
jLabel.setHorizontalAlignment(SwingConstants.RIGHT);
registerPopupMenu(jLabel, id);
return jLabel;
}
 
379,8 → 378,8
final JPopupMenu popMenu = new JPopupMenu();
final JMenu menuItemInfo = new JMenu("Information");
menuItemInfo.add(new JMenuItem("id: " + id));
menuItemInfo.add(new JMenuItem("label: " + getLabel(id).getClass().getName()));
menuItemInfo.add(new JMenuItem("editor: " + getEditor(id).getClass().getName()));
menuItemInfo.add(new JMenuItem("label: " + getLabel(id).getClass().getName() + ":" + getLabel(id)));
menuItemInfo.add(new JMenuItem("editor: " + getEditor(id).getClass().getName() + ":" + getEditor(id)));
popMenu.add(menuItemInfo);
final JMenuItem menuItemDoc = new JMenuItem("Modifier la documentation");
menuItemDoc.addActionListener(new ActionListener() {
413,7 → 412,7
if (label == null) {
label = createLabel(id);
this.labels.put(id, label);
 
registerPopupMenu(label, id);
final RowItemDesc rivDesc = getRIVDescForId(id);
updateUI(id, rivDesc);
}
/trunk/OpenConcerto/src/org/openconcerto/utils/FileUtils.java
34,6 → 34,7
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.net.URI;
import java.net.URL;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
55,34 → 56,34
// all static
}
 
public static void browseFile(File f) {
public static void browseFile(final File f) {
try {
if (Desktop.isDesktopSupported()) {
Desktop d = Desktop.getDesktop();
if (d.isSupported(Desktop.Action.BROWSE)) {
 
try {
d.browse(f.getCanonicalFile().toURI());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} else {
openNative(f);
}
} else {
try {
openNative(f);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ExceptionHandler.handle("Impossible de trouver le dossier " + f.getAbsolutePath(), e);
}
}
 
public static void browse(URI uri) throws Exception {
final boolean windows = System.getProperty("os.name").startsWith("Windows");
if (windows) {
Desktop.getDesktop().browse(uri);
} else {
try {
openNative(f);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
String[] cmdarray = new String[] { "xdg-open", uri.toString() };
final int res = Runtime.getRuntime().exec(cmdarray).waitFor();
if (res != 0)
throw new IOException("error (" + res + ") executing " + Arrays.asList(cmdarray));
}
}
}
 
public static void openFile(File f) throws IOException {
if (Desktop.isDesktopSupported()) {
589,7 → 590,6
}
 
public static void write(String s, File f, String charset, boolean append) throws IOException {
@SuppressWarnings("resource")
final FileOutputStream fileStream = new FileOutputStream(f, append);
final OutputStreamWriter out = charset == null ? new OutputStreamWriter(fileStream) : new OutputStreamWriter(fileStream, charset);
final BufferedWriter w = new BufferedWriter(out);
/trunk/OpenConcerto/src/org/openconcerto/utils/ExceptionHandler.java
428,13 → 428,9
al.actionPerformed(null);
}
});
try {
 
f.setVisible(true);
} catch (Exception e) {
// Catch to avoid infinite loop
e.printStackTrace();
}
}
 
private String getTrace() {
return ExceptionUtils.getStackTrace(this);
/trunk/OpenConcerto/src/org/openconcerto/utils/i18n/TM.java
18,6 → 18,7
import org.openconcerto.utils.PropertiesUtils;
import org.openconcerto.utils.Tuple2;
 
import java.beans.Introspector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
40,7 → 41,7
* Translation manager. The translations are provided by {@link Translator} instances, they are
* created either from a class ending in a language tag that implements it, or by properties files
* that must contain values that will be passed to {@link MessageFormat}. In the latter case,
* messages can reference {@link #createValue(Map, String) virtual named arguments}.
* messages can reference {@link #createValue(Map, Object[], String) virtual named arguments}.
*
* @author Sylvain
* @see LocalizedInstances
51,6 → 52,11
EXCEPTION, NULL, STRING
}
 
static public final String NOUN_CLASS_PROP = "nounClass";
static {
assert NOUN_CLASS_PROP.equals(Introspector.decapitalize(NounClass.class.getSimpleName()));
}
 
static private final MissingMode DEFAULT_MISSING_MODE = MissingMode.STRING;
 
static private final TM INSTANCE = new TM();
233,10 → 239,12
/**
* Try to create a value for a missing key. The syntax of keys must be phraseName(__name)+ and
* if you need to have __ in a name it must be doubled (i.e. ____). <code>phraseName</code>, as
* its name implies, must reference an existing phrase in <code>map</code>. Then this phrase and
* the list of <code>name</code> are passed to {@link Grammar#eval(Phrase, Number, List)}. The
* count is <code>phraseNameCount</code> if it exists and is a {@link Number}, then
* <code>count</code> else <code>null</code>.
* its name implies, must reference an existing phrase in <code>map</code>. If this phrase is
* suffixed by {@value #NOUN_CLASS_PROP} then the {@link NounClass#getName() name} of the noun
* class of the phrase is returned. Else this phrase and the list of <code>name</code> are
* passed to {@link Grammar#eval(Phrase, Number, List)}. The count is
* <code>phraseNameCount</code> if it exists and is a {@link Number}, then <code>count</code>
* else <code>null</code>.
*
* @param map the current map.
* @param objects the original map as an array.
282,7 → 290,14
assert first != null;
final Object firstObj = handleGet(map, first);
final Phrase phrase = firstObj instanceof Phrase ? (Phrase) firstObj : null;
if (phrase != null && phrase.getGrammar() != null) {
if (phrase != null && l.size() == 2 && NOUN_CLASS_PROP.equals(l.get(1))) {
if (phrase.getNounClass() == null) {
Log.get().warning("No noun class for " + phrase);
return phrase.getBase();
} else {
return phrase.getNounClass().getName();
}
} else if (phrase != null && phrase.getGrammar() != null) {
Object countObj = handleGet(map, first + "Count");
if (!(countObj instanceof Number))
countObj = handleGet(map, "count");
/trunk/OpenConcerto/src/org/openconcerto/utils/i18n/DefaultVariantKey.java
93,4 → 93,9
public final String getVariant() {
return this.variant;
}
 
@Override
public String toString() {
return this.getClass().getSimpleName() + " '" + this.getID() + "'";
}
}
/trunk/OpenConcerto/src/org/openconcerto/utils/i18n/Grammar.java
164,7 → 164,7
final String last = l.get(size - 1);
final VariantKey key = this.getVariantKey(last);
if (key == null) {
Log.get().warning("Unknown key ID " + last + " for " + phrase);
Log.get().warning("Unknown key ID '" + last + "' for " + phrase + "\nknown keys : " + getVariantKeys());
return phrase;
}
final String inflection = count == null ? phrase.getVariant(key) : phrase.getNumeralVariant(count.intValue(), key);
/trunk/OpenConcerto/src/org/openconcerto/utils/TimeUtils.java
359,4 → 359,13
return DSTChange.NO;
}
}
 
static public final Calendar clearTime(final Calendar cal) {
// reset doesn't work, see javadoc
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
return cal;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationXML.java
26,6 → 26,7
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.StreamUtils;
 
36,7 → 37,6
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
595,7 → 595,7
} 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")), MathContext.DECIMAL128).movePointLeft(2);
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");
// TODO prefix et suffix
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SheetXml.java
291,8 → 291,7
* */
public String getTemplateId() {
if (this.row != null && this.row.getTable().getFieldsName().contains("ID_MODELE")) {
SQLRow rowModele = this.row.getForeignRow("ID_MODELE");
if (rowModele.isUndefined()) {
if (row.isForeignEmpty("ID_MODELE")) {
TypeModeleSQLElement typeModele = Configuration.getInstance().getDirectory().getElement(TypeModeleSQLElement.class);
String modele = typeModele.getTemplateMapping().get(this.row.getTable().getName());
if (modele == null) {
303,6 → 302,7
return modele;
}
} else {
SQLRow rowModele = this.row.getForeignRow("ID_MODELE");
return rowModele.getString("NOM");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLField.java
25,6 → 25,7
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.Nombre;
import org.openconcerto.utils.StringUtils;
31,7 → 32,6
import org.openconcerto.utils.Tuple2;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
213,7 → 213,13
Object o = getSpecialValue(typeComp);
 
String stringValue;
String scale = this.elt.getAttributeValue("decimalScale");
if (o != null) {
 
if (o != null && scale != null && scale.trim().length() > 0) {
 
o = ((BigDecimal) o).setScale(Integer.valueOf(scale));
}
if (this.elt.getAttributeValue("upperCase") != null) {
o = o.toString().toUpperCase();
}
221,6 → 227,11
} else {
Object o2 = this.row.getObject(field);
 
if (o2 != null && scale != null && scale.trim().length() > 0) {
 
o2 = ((BigDecimal) o2).setScale(Integer.valueOf(scale));
}
 
stringValue = (o2 == null) ? "" : o2.toString();
}
 
326,6 → 337,13
if (result instanceof Long) {
return new Double(GestionDevise.currencyToString(prix.longValue(), false));
} else {
String scale = this.elt.getAttributeValue("decimalScale");
 
if (result != null && scale != null && scale.trim().length() > 0) {
 
return ((BigDecimal) result).setScale(Integer.valueOf(scale));
}
 
return result;
}
} else if (typeComp.equalsIgnoreCase("globalAcompte")) {
363,8 → 381,16
} else if (typeComp.equalsIgnoreCase("Traduction")) {
return getTraduction();
} else if (typeComp.equalsIgnoreCase("VilleCP")) {
if (this.row.getTable().contains("CODE_POSTAL")) {
// Code postal de la ville
return this.row.getString("CODE_POSTAL");
} else {
Ville v = Ville.getVilleFromVilleEtCode(this.row.getString(field));
if (v != null) {
return v.getCodepostal();
}
return null;
}
} else if (typeComp.equalsIgnoreCase("DateEcheance")) {
// Retourne la date d'échéance
int idModeReglement = this.row.getInt("ID_MODE_REGLEMENT");
501,8 → 527,8
BigDecimal d;
double coeff = ((double) lN) / ((double) l0);
 
d = new BigDecimal(0.15).add(new BigDecimal(0.85).multiply(new BigDecimal(coeff), MathContext.DECIMAL128));
p = d.multiply(p0, MathContext.DECIMAL128);
d = new BigDecimal(0.15).add(new BigDecimal(0.85).multiply(new BigDecimal(coeff), DecimalUtils.HIGH_PRECISION));
p = d.multiply(p0, DecimalUtils.HIGH_PRECISION);
} else {
p = p0;
}
510,7 → 536,7
// p = Math.round(p * (lA / 100.0));
// }
if (lremise.signum() != 0 && lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(cent) < 100) {
p = p.multiply(cent.subtract(lremise).movePointLeft(2), MathContext.DECIMAL128);
p = p.multiply(cent.subtract(lremise).movePointLeft(2), DecimalUtils.HIGH_PRECISION);
}
cumul += p.setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
}
590,16 → 616,16
}
 
if (op.equalsIgnoreCase("+")) {
return d1.add(d2);
return d1.add(d2, DecimalUtils.HIGH_PRECISION);
} else {
if (op.equalsIgnoreCase("-")) {
return d1.subtract(d2);
return d1.subtract(d2, DecimalUtils.HIGH_PRECISION);
} else {
if (op.equalsIgnoreCase("*")) {
return d1.multiply(d2);
return d1.multiply(d2, DecimalUtils.HIGH_PRECISION);
} else {
if (op.equalsIgnoreCase("/") && d2.compareTo(BigDecimal.ZERO) != 0) {
return d1.divide(d2);
return d1.divide(d2, DecimalUtils.HIGH_PRECISION);
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLTableField.java
23,6 → 23,7
import org.openconcerto.utils.Nombre;
 
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/PrixUnitaireRemiseProvider.java
16,9 → 16,9
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
 
public class PrixUnitaireRemiseProvider extends UserInitialsValueProvider {
35,7 → 35,7
if (row.getTable().contains("POURCENT_ACOMPTE") && row.getObject("POURCENT_ACOMPTE") != null) {
acompte = ((BigDecimal) row.getObject("POURCENT_ACOMPTE")).movePointLeft(2);
}
BigDecimal result = BigDecimal.ONE.subtract(remise.movePointLeft(2)).multiply(pv, MathContext.DECIMAL128).multiply(acompte, MathContext.DECIMAL128);
BigDecimal result = BigDecimal.ONE.subtract(remise.movePointLeft(2)).multiply(pv, DecimalUtils.HIGH_PRECISION).multiply(acompte, DecimalUtils.HIGH_PRECISION);
 
return result.setScale(2, RoundingMode.HALF_UP);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/AdresseFullClientValueProvider.java
29,7 → 29,12
public Object getValue(SpreadSheetCellValueContext context) {
final SQLRowAccessor r = getAdresse(context.getRow(), this.type);
 
String result = r.getString("RUE");
String result = r.getString("LIBELLE");
if (result.trim().length() == 0) {
result = r.getString("RUE");
} else {
result += "\n" + r.getString("RUE");
}
result += "\n" + r.getString("CODE_POSTAL");
result += " ";
result += r.getString("VILLE");
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/RemiseProvider.java
New file
0,0 → 1,62
/*
* 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.core.common.ui.Acompte;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.utils.GestionDevise;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
 
public class RemiseProvider extends UserInitialsValueProvider {
 
public enum TypeAffichage {
GLOBAL, LIGNE, NORMAL
};
 
public final TypeAffichage type;
 
public RemiseProvider(TypeAffichage t) {
this.type = t;
}
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
 
final BigDecimal montant = row.getBigDecimal("MONTANT_REMISE");
BigDecimal remise = (BigDecimal) row.getObject("POURCENT_REMISE");
 
Acompte a = new Acompte(remise, montant);
 
if (a == null) {
return null;
} else if (a.getPercent() != null) {
return a.getPercent().setScale(2, RoundingMode.HALF_UP).toString() + "%";
} else if (montant != null) {
return GestionDevise.currencyToString(montant);
} else {
return "";
}
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("remise.global", new RemiseProvider(TypeAffichage.GLOBAL));
SpreadSheetCellValueProviderManager.put("remise.line", new RemiseProvider(TypeAffichage.LIGNE));
SpreadSheetCellValueProviderManager.put("remise", new RemiseProvider(TypeAffichage.NORMAL));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/RelanceSheet.java
78,7 → 78,9
final SQLRow clientRowNX = this.rowRelance.getForeignRow("ID_CLIENT");
rowClient = clientRowNX;
SQLRow rowAdresse = rowClient.getForeignRow("ID_ADRESSE");
 
if (!clientRowNX.isForeignEmpty("ID_ADRESSE_F")) {
rowAdresse = clientRowNX.getForeign("ID_ADRESSE_F");
}
// Client compte
SQLRow rowCompteClient = clientRowNX.getForeignRow("ID_COMPTE_PCE");
String numero = rowCompteClient.getString("NUMERO");
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationEcritures.java
25,6 → 25,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
330,7 → 331,14
TotalCalculator calc = new TotalCalculator("T_PA_HT", fieldTotalHT, null, achat, defaultCompte);
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);
}
}
long remise = 0;
BigDecimal totalAvtRemise = BigDecimal.ZERO;
if (row.getTable().contains("REMISE_HT")) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirClient.java
62,6 → 62,10
SQLRow rowClient;
rowClient = avoirRow.getForeignRow("ID_CLIENT");
 
if (ecritureTable.contains("CODE_CLIENT")) {
this.mEcritures.put("CODE_CLIENT", rowClient.getString("CODE"));
}
 
// iniatilisation des valeurs de la map
this.date = (Date) avoirRow.getObject("DATE");
this.nom = avoirRow.getObject("NOM").toString();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CourrierClientSQLElement.java
25,7 → 25,6
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
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;
321,14 → 320,6
}
 
@Override
public void select(SQLRowAccessor r) {
if (r != null) {
this.textNumero.setIdSelected(r.getID());
}
super.select(r);
}
 
@Override
public void update() {
 
if (!this.textNumero.checkValidation()) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/RelanceSQLElement.java
234,9 → 234,6
 
@Override
public void select(SQLRowAccessor r) {
if (r != null) {
this.textNumero.setIdSelected(r.getID());
}
super.select(r);
 
// numero de facture et client figé
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientNormalSQLComponent.java
11,13 → 11,9
* When distributing the software, include this License Header Notice in each file.
*/
/*
* Créé le 12 déc. 2011
*/
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
34,6 → 30,7
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
49,7 → 46,6
import org.openconcerto.sql.sqlobject.itemview.VWRowItemView;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.JComponentUtils;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.component.ComboLockedMode;
67,7 → 63,14
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.ButtonGroup;
import javax.swing.Icon;
85,29 → 88,30
// Client without CTech link (i.e. there's one and only table in the DB)
public class ClientNormalSQLComponent extends BaseSQLComponent {
 
int idDefaultCompteClient = 1;
JCheckBox checkAdrLivraison, checkAdrFacturation;
private int idDefaultCompteClient = 1;
private JCheckBox checkAdrLivraison, checkAdrFacturation;
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
private ElementComboBox boxPays = null;
final ElementComboBox boxTarif = new ElementComboBox();
private final ElementComboBox boxTarif = new ElementComboBox();
 
protected boolean showMdr = true;
 
ElementSQLObject componentPrincipale, componentLivraison, componentFacturation;
AdresseClientItemTable adresseTable = new AdresseClientItemTable();
JCheckBox boxGestionAutoCompte;
private ElementSQLObject componentPrincipale, componentLivraison, componentFacturation;
private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
private JCheckBox boxGestionAutoCompte;
private Map<SQLField, JCheckBox> mapCheckLivraison = new HashMap<SQLField, JCheckBox>();
 
private JCheckBox boxAffacturage, boxComptant;
private DeviseField fieldMontantFactMax;
ISQLCompteSelector compteSel;
private ISQLCompteSelector compteSel;
private SQLRowItemView textNom;
// ITextWithCompletion textNom;
final ElementComboBox comboPole = new ElementComboBox();
DecimalFormat format = new DecimalFormat("000");
private final ElementComboBox comboPole = new ElementComboBox();
private final DecimalFormat format = new DecimalFormat("000");
 
private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
private final SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
private ContactItemTable table;
private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
private final SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
private SQLRowItemView eltModeRegl;
private JUniqueTextField textCode;
private JLabel labelCpt;
198,7 → 202,7
c.weightx = 0;
this.add(labelIntraComm, c);
 
JTextField textNumIntracomm = new JTextField(20);
final JTextField textNumIntracomm = new JTextField(20);
c.gridx++;
c.weightx = 0.5;
DefaultGridBagConstraints.lockMinimumSize(textNumIntracomm);
220,7 → 224,7
// Responsable
final JLabel responsable = new JLabel(this.getLabelFor("RESPONSABLE"));
responsable.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textResp = new JTextField();
final JTextField textResp = new JTextField();
c.gridx = 0;
c.gridy++;
c.weightx = 0;
232,7 → 236,7
DefaultGridBagConstraints.lockMinimumSize(textResp);
this.add(textResp, c);
 
JLabel labelRIB = new JLabel(getLabelFor("RIB"));
final JLabel labelRIB = new JLabel(getLabelFor("RIB"));
labelRIB.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx++;
c.gridwidth = 1;
239,7 → 243,7
c.weightx = 0;
this.add(labelRIB, c);
 
JTextField textRib = new JTextField();
final JTextField textRib = new JTextField();
c.gridx++;
c.weightx = 0.5;
DefaultGridBagConstraints.lockMinimumSize(textRib);
282,7 → 286,7
c.weightx = 0;
this.add(labelMail, c);
 
JTextField textMail = new JTextField();
final JTextField textMail = new JTextField();
c.gridx++;
c.weightx = 0.5;
DefaultGridBagConstraints.lockMinimumSize(textMail);
296,7 → 300,7
c.weightx = 0;
this.add(labelPortable, c);
 
JTextField textPortable = new JTextField();
final JTextField textPortable = new JTextField();
c.gridx++;
c.weightx = 0.5;
DefaultGridBagConstraints.lockMinimumSize(textPortable);
337,7 → 341,7
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
this.add(addP, c);
 
c.gridy++;
350,6 → 354,7
if (showMdr) {
tabs.addTab("Mode de règlement", pReglement);
}
 
tabs.addTab("Comptabilité", createComptabiliteComponent());
 
tabs.setMinimumSize(new Dimension(tabs.getPreferredSize().width, tabs.getPreferredSize().height));
507,6 → 512,7
this.addView("ID_ADRESSE_F", DEC + ";" + SEP);
this.componentFacturation = (ElementSQLObject) this.getView("ID_ADRESSE_F");
this.componentFacturation.setOpaque(false);
this.componentFacturation.setCreatedUIVisible(false);
panelFacturation.add(this.componentFacturation, cPanelF);
this.checkAdrFacturation = new JCheckBox("Adresse de facturation identique à la principale");
this.checkAdrFacturation.setOpaque(false);
513,23 → 519,53
cPanelF.gridy++;
panelFacturation.add(this.checkAdrFacturation, cPanelF);
tabbedAdresse.add(getLabelFor("ID_ADRESSE_F"), panelFacturation);
Set<SQLField> fieldsAdr = getTable().getForeignKeys("ADRESSE");
List<SQLField> fieldsAdrOrder = new ArrayList<SQLField>(fieldsAdr);
Collections.sort(fieldsAdrOrder, new Comparator<SQLField>() {
@Override
public int compare(SQLField o1, SQLField o2) {
 
return o1.getName().compareTo(o2.getName());
}
});
int val = 1;
for (SQLField sqlField : fieldsAdrOrder) {
 
final String fieldName = sqlField.getName();
if (fieldName.startsWith("ID_ADRESSE_L")) {
// Adr livraison
JPanel panelLivraison = new JPanel(new GridBagLayout());
panelLivraison.setOpaque(false);
GridBagConstraints cPanelL = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 1, 2, 1), 0, 0);
 
this.addView("ID_ADRESSE_L", DEC + ";" + SEP);
this.componentLivraison = (ElementSQLObject) this.getView("ID_ADRESSE_L");
((AdresseSQLComponent) this.componentLivraison.getSQLChild()).setDestinataireVisible(true);
this.addView(fieldName, DEC + ";" + SEP);
this.componentLivraison = (ElementSQLObject) this.getView(fieldName);
this.componentLivraison.setOpaque(false);
this.componentLivraison.setCreatedUIVisible(false);
 
panelLivraison.add(this.componentLivraison, cPanelL);
 
this.checkAdrLivraison = new JCheckBox("Adresse de livraison identique à l'adresse principale");
this.checkAdrLivraison.setOpaque(false);
checkAdrLivraison = new JCheckBox("Adresse de livraison identique à l'adresse principale");
checkAdrLivraison.setOpaque(false);
cPanelL.gridy++;
panelLivraison.add(this.checkAdrLivraison, cPanelL);
tabbedAdresse.add(getLabelFor("ID_ADRESSE_L"), panelLivraison);
panelLivraison.add(checkAdrLivraison, cPanelL);
tabbedAdresse.add(getLabelFor(fieldName) + (val == 1 ? "" : " " + val), panelLivraison);
val++;
 
checkAdrLivraison.addActionListener(new ActionListener() {
 
public void actionPerformed(java.awt.event.ActionEvent e) {
boolean b = checkAdrLivraison.isSelected();
 
componentLivraison.setEditable(!b);
componentLivraison.setCreated(!b);
}
});
checkAdrLivraison.setSelected(true);
this.mapCheckLivraison.put(sqlField, checkAdrLivraison);
}
}
 
String labelAdrSuppl = "Adresses supplémentaires";
tabbedAdresse.add(labelAdrSuppl, this.adresseTable);
 
667,14 → 703,16
 
super.select(r);
 
this.checkAdrLivraison.setSelected(r == null || r.isForeignEmpty("ID_ADRESSE_L"));
this.checkAdrFacturation.setSelected(r == null || r.isForeignEmpty("ID_ADRESSE_F"));
for (SQLField f : this.mapCheckLivraison.keySet()) {
this.mapCheckLivraison.get(f).setSelected(r == null || !r.getFields().contains(f.getName()) || r.isForeignEmpty(f.getName()));
}
this.checkAdrFacturation.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_F") || r.isForeignEmpty("ID_ADRESSE_F"));
 
if (r != null) {
this.table.insertFrom("ID_CLIENT", r.asRowValues());
this.adresseTable.insertFrom("ID_CLIENT", r.getID());
this.defaultContactRowVals.put("TEL_DIRECT", r.getString("TEL"));
this.defaultContactRowVals.put("FAX", r.getString("FAX"));
this.textCode.setIdSelected(r.getID());
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ComptePCESQLElement.java
23,7 → 23,6
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;
164,14 → 163,6
}
 
@Override
public void select(SQLRowAccessor r) {
super.select(r);
if (r != null) {
this.textNumero.setIdSelected(r.getID());
}
}
 
@Override
public synchronized ValidState getValidState() {
return super.getValidState().and(this.compteNumeroValidState);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/AnalytiqueItemTable.java
25,11 → 25,11
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.DecimalUtils;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.List;
import java.util.Vector;
79,7 → 79,7
 
long total = row.getForeign("ID_ECRITURE").getLong("DEBIT") - row.getForeign("ID_ECRITURE").getLong("CREDIT");
 
BigDecimal pourcent = new BigDecimal(montant).divide(new BigDecimal(total), MathContext.DECIMAL128).abs().movePointRight(2)
BigDecimal pourcent = new BigDecimal(montant).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).abs().movePointRight(2)
.setScale(tableElementPourcent.getDecimalDigits(), RoundingMode.HALF_UP);
return pourcent;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/AssociationAnalytiqueItemModel.java
16,27 → 16,18
import org.openconcerto.erp.core.common.ui.DeviseCellEditor;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.view.list.CellDynamicModifier;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.DecimalUtils;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.List;
import java.util.Vector;
 
import javax.swing.JScrollPane;
import javax.swing.ToolTipManager;
 
public class AssociationAnalytiqueItemModel {
 
private final DeviseKmRowValuesRenderer deviseRenderer = new DeviseKmRowValuesRenderer();
70,7 → 61,7
 
long total = row.getForeign("ID_ECRITURE").getLong("DEBIT") - row.getForeign("ID_ECRITURE").getLong("CREDIT");
 
BigDecimal pourcent = new BigDecimal(montant).divide(new BigDecimal(total), MathContext.DECIMAL128).abs().movePointRight(2)
BigDecimal pourcent = new BigDecimal(montant).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).abs().movePointRight(2)
.setScale(tableElementPourcent.getDecimalDigits(), RoundingMode.HALF_UP);
return pourcent;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/report/N4DS.java
106,7 → 106,11
 
private void writeS80(PrintStream stream, SQLRow rowSociete) throws IOException {
 
final String nic = StringUtils.limitLength(rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 9);
// final String nic =
// StringUtils.limitLength(rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 9);
final String siret = rowSociete.getString("NUM_SIRET").replaceAll(" ", "");
String siren = StringUtils.limitLength(siret, 9);
String nic = siret.substring(siren.length(), siret.length());
 
// // SIREN
// write("S80.G01.00.001.001", siren);
147,7 → 151,7
write("S80.G01.00.003.010", rowAdr.getString("CODE_POSTAL"));
 
// Localité
write("S80.G01.00.003.012", rowAdr.getString("VILLE").toUpperCase());
write("S80.G01.00.003.012", normalizeString2(rowAdr.getString("VILLE")));
 
// Code Pays, ne doit pas être renseigné pour une adresse en France
// TODO support des autres pays
244,8 → 248,9
 
// Siren
 
String siren = StringUtils.limitLength(rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 9);
String nic = StringUtils.limitLength(rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 9);
final String siret = rowSociete.getString("NUM_SIRET").replaceAll(" ", "");
String siren = StringUtils.limitLength(siret, 9);
String nic = siret.substring(siren.length(), siret.length());
write("S20.G01.00.001", siren);
 
// Raison sociale
252,10 → 257,10
write("S20.G01.00.002", rowSociete.getString("NOM"));
 
// FIXME Debut periode
write("S20.G01.00.003.001", "01012013");
write("S20.G01.00.003.001", "01012014");
 
// FIXME Fin periode
write("S20.G01.00.003.002", "31122013");
write("S20.G01.00.003.002", "31122014");
 
// Code nature
write("S20.G01.00.004.001", "01");
305,7 → 310,7
write("S20.G01.00.009.010", rowAdr.getString("CODE_POSTAL"));
 
// Localité
write("S20.G01.00.009.012", rowAdr.getString("VILLE").toUpperCase());
write("S20.G01.00.009.012", normalizeString2(rowAdr.getString("VILLE")));
 
write("S20.G01.00.013.002", "1");
 
325,8 → 330,9
 
// Siren
 
String siren = StringUtils.limitLength(rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 9);
String nic = StringUtils.limitLength(rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 9);
final String siret = rowSociete.getString("NUM_SIRET").replaceAll(" ", "");
String siren = StringUtils.limitLength(siret, 9);
String nic = siret.substring(siren.length(), siret.length());
write("S10.G01.00.001.001", siren);
 
// NIC
362,13 → 368,13
// stream.write("S10.G01.00.003.007",voie);
 
// TODO: Service de distribution
write("S10.G01.00.003.009", rowAdr.getString("VILLE"));
write("S10.G01.00.003.009", normalizeString2(rowAdr.getString("VILLE")));
 
// Code postal
write("S10.G01.00.003.010", rowAdr.getString("CODE_POSTAL"));
 
// Localité
write("S10.G01.00.003.012", rowAdr.getString("VILLE").toUpperCase());
write("S10.G01.00.003.012", normalizeString2(rowAdr.getString("VILLE")));
 
// Code Pays, ne doit pas être renseigné pour une adresse en France
// TODO support des autres pays
394,7 → 400,7
write("S10.G01.00.010", "02");
 
// Norme utilisée
write("S10.G01.00.011", "V01X08");
write("S10.G01.00.011", "V01X09");
 
// Code table char
write("S10.G01.00.012", "01");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/report/N4DSSalarie.java
43,8 → 43,8
private ComptaPropsConfiguration conf = ((ComptaPropsConfiguration) Configuration.getInstance());
private N4DS n4ds;
 
Date d = new Date(113, 0, 1);
Date d2 = new Date(113, 11, 31);
Date d = new Date(114, 0, 1);
Date d2 = new Date(114, 11, 31);
 
DecimalFormat decimalFormat = new DecimalFormat("0.00");
 
222,7 → 222,9
n4ds.write("S40.G01.00.004.001", "098");
 
// Nic de l'établissment du d'affectation du salarié
String nic = StringUtils.limitLength(rowSociete.getString("NUM_SIRET").replaceAll(" ", ""), 9);
final String siret = rowSociete.getString("NUM_SIRET").replaceAll(" ", "");
String siren = StringUtils.limitLength(siret, 9);
String nic = siret.substring(siren.length(), siret.length());
n4ds.write("S40.G01.00.005", nic);
 
/**
384,13 → 386,14
n4ds.write("S40.G30.04.002", decimalFormat.format(getCSG(rowSalarie)));
 
// final double baseBrute = getBaseBrute(rowSalarie);
if ((baseBrute) < (2.5 * 9.43 * 12 * 151.6667)) {
final double smicMensuel = 9.53;
if ((baseBrute) < (2.5 * smicMensuel * 12 * 151.6667)) {
 
n4ds.write("S40.G30.40.001", String.valueOf("17162.64"));
n4ds.write("S40.G30.40.001", String.valueOf("17344.60"));
n4ds.write("S40.G30.40.002", decimalFormat.format(baseBrute));
}
if ((baseBrute / 12.0 / 151.6667) < (1.6 * 9.43)) {
double COEFF_FILLON = (0.281 / 0.6) * ((1.6 * 9.43 * 12 * 151.6667 / (rowSalarie.getForeign("ID_INFOS_SALARIE_PAYE").getFloat("SALAIRE_MOIS") * 12.0)) - 1.0);
if ((baseBrute / 12.0 / 151.6667) < (1.6 * smicMensuel)) {
double COEFF_FILLON = (0.281 / 0.6) * ((1.6 * smicMensuel * 12 * 151.6667 / (rowSalarie.getForeign("ID_INFOS_SALARIE_PAYE").getFloat("SALAIRE_MOIS") * 12.0)) - 1.0);
n4ds.write("S40.G30.40.003", decimalFormat.format(baseBrute * COEFF_FILLON));
} else {
n4ds.write("S40.G30.40.003", String.valueOf("0.00"));
397,6 → 400,10
}
 
n4ds.write("S40.G30.40.004", String.valueOf("0.00"));
if ((baseBrute) < (2.5 * smicMensuel * 12 * 151.6667)) {
n4ds.write("S40.G30.40.005", String.valueOf("17344.60"));
n4ds.write("S40.G30.40.006", decimalFormat.format(baseBrute));
}
 
// FIXME base brute fiscale
n4ds.write("S40.G40.00.035.001", decimalFormat.format(baseBrute));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/project/element/CalendarItemSQLElement.java
New file
0,0 → 1,46
/*
* 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.project.element;
 
import java.util.Arrays;
import java.util.List;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
 
public class CalendarItemSQLElement extends ComptaSQLConfElement {
 
public CalendarItemSQLElement() {
super("CALENDAR_ITEM");
}
 
@Override
protected List<String> getListFields() {
return Arrays.asList("SUMMARY", "START", "END", "STATUS");
}
 
@Override
protected SQLComponent createComponent() {
return null;
}
 
protected String createCode() {
return "calendaritem";
};
 
@Override
protected String getParentFFName() {
return "ID_CALENDAR_ITEM_GROUP";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/project/element/CalendarItemGroupSQLElement.java
New file
0,0 → 1,41
/*
* 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.project.element;
 
import java.util.Arrays;
import java.util.List;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
 
public class CalendarItemGroupSQLElement extends ComptaSQLConfElement {
 
public CalendarItemGroupSQLElement() {
super("CALENDAR_ITEM_GROUP");
}
 
@Override
protected List<String> getListFields() {
return Arrays.asList("NAME");
}
 
@Override
protected SQLComponent createComponent() {
return null;
}
 
protected String createCode() {
return "calendaritemgroup";
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/component/BonDeLivraisonSQLComponent.java
97,7 → 97,7
 
@Override
protected SQLRowValues createDefaults() {
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(BonDeLivraisonSQLElement.class));
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
this.tableBonItem.getModel().clearRows();
return super.createDefaults();
}
451,9 → 451,6
 
@Override
public void select(SQLRowAccessor r) {
if (r != null) {
this.textNumeroUnique.setIdSelected(r.getID());
}
if (r == null || r.getIDNumber() == null)
super.select(r);
else {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/element/BonDeLivraisonSQLElement.java
20,6 → 20,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.Where;
39,8 → 40,12
// TODO afficher uniquement les factures non livrees dans la combo
// MAYBE mettre un niceCellRenderer dans les rowValuesTable
 
public BonDeLivraisonSQLElement(String single, String plural) {
super("BON_DE_LIVRAISON", single, plural);
}
 
public BonDeLivraisonSQLElement() {
super("BON_DE_LIVRAISON", "un bon de livraison", "Bons de livraison");
this("un bon de livraison", "Bons de livraison");
}
 
protected List<String> getListFields() {
82,9 → 87,11
return new BonDeLivraisonSQLComponent();
}
 
protected void archive(SQLRow row, boolean cutLinks) throws SQLException {
super.archive(row, cutLinks);
@Override
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
 
for (SQLRow row : trees.getRows()) {
 
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
 
106,4 → 113,6
}
}
}
super.archive(trees, cutLinks);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/ui/BonDeLivraisonItemTable.java
42,9 → 42,9
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.ui.table.XTableColumnModel;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
280,7 → 280,7
if (o2 != null && o3 != null) {
BigDecimal poids = (BigDecimal) o2;
int nb = (Integer) o3;
return poids.multiply(new BigDecimal(nb), MathContext.DECIMAL128).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
return poids.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
} else {
return row.getObject("T_POIDS_COLIS_NET");
}
420,7 → 420,7
BigDecimal f = (BigDecimal) row.getObject("PV_HT");
System.out.println("Qte:" + qte + " et PV_HT:" + f);
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), MathContext.DECIMAL128).setScale(totalHT.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), DecimalUtils.HIGH_PRECISION).setScale(totalHT.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
return r;
}
 
443,7 → 443,7
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
// Long r = new Long(pHT.calculLongTTC(taux / 100f));
editorPVHT.setTaxe(taux);
BigDecimal r = f.multiply(BigDecimal.ONE.add(BigDecimal.valueOf(taux).movePointLeft(2)), MathContext.DECIMAL128).setScale(6, BigDecimal.ROUND_HALF_UP);
BigDecimal r = f.multiply(BigDecimal.ONE.add(BigDecimal.valueOf(taux).movePointLeft(2)), DecimalUtils.HIGH_PRECISION).setScale(6, BigDecimal.ROUND_HALF_UP);
 
return r.setScale(tableElementTotalTTC.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/credit/component/AvoirClientSQLComponent.java
726,11 → 726,7
@Override
public void select(SQLRowAccessor r) {
if (r != null) {
this.textNumero.setIdSelected(r.getID());
}
 
if (r != null) {
 
// Les contacts sont filtrés en fonction du client (ID_AFFAIRE.ID_CLIENT), donc si
// l'ID_CONTACT est changé avant ID_AFFAIRE le contact ne sera pas présent dans la combo
// => charge en deux fois les valeurs
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/action/ListeDesCommandesClientAction.java
27,7 → 27,6
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.graph.Path;
39,6 → 38,7
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
45,7 → 45,9
import org.openconcerto.ui.state.WindowStateManager;
import org.openconcerto.ui.table.PercentTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.NumberUtils;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.GridBagConstraints;
53,7 → 55,6
import java.awt.event.ActionEvent;
import java.io.File;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
73,6 → 74,8
this.putValue(Action.NAME, "Liste des commandes clients");
}
 
private BaseSQLTableModelColumn colAvancement;
 
public JFrame createFrame() {
final JFrame frame = new JFrame("Commandes clients");
// Actions
182,7 → 185,7
allowedActions.add(soldeAction);
allowedActions.add(cmdAction);
 
final BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) {
this.colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
196,8 → 199,8
return CollectionUtils.createSet(new FieldPath(p, "T_HT"));
}
};
tableSource.getColumns().add(colAvancement);
colAvancement.setRenderer(new PercentTableCellRenderer());
tableSource.getColumns().add(this.colAvancement);
this.colAvancement.setRenderer(new PercentTableCellRenderer());
final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions);
return panel;
}
214,7 → 217,7
}
}
if (total > 0) {
return new BigDecimal(totalFact).divide(new BigDecimal(total), MathContext.DECIMAL128).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
} else {
return BigDecimal.ONE.movePointRight(2);
}
258,9 → 261,10
}
};
 
final List<SQLField> fields = new ArrayList<SQLField>(2);
fields.add(eltCmd.getTable().getField("T_HT"));
final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, "Total des commandes de la liste");
final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
fields.add(Tuple2.create(panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")), IListTotalPanel.Type.SOMME));
fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, null, "Total des commandes de la liste");
 
final GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/component/CommandeClientSQLComponent.java
20,10 → 20,8
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.sales.order.element.CommandeClientSQLElement;
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
import org.openconcerto.erp.core.sales.order.ui.CommandeClientItemTable;
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.Type;
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
36,9 → 34,7
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
60,7 → 56,6
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JOptionPane;
74,8 → 69,6
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
public class CommandeClientSQLComponent extends TransfertBaseSQLComponent {
 
private CommandeClientItemTable table;
394,7 → 387,7
addSQLObject(this.infos, "INFOS");
addSQLObject(this.comboDevis, "ID_DEVIS");
 
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
 
this.table.getModel().addTableModelListener(new TableModelListener() {
 
436,7 → 429,7
}
 
// incrémentation du numéro auto
if (NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
int val = this.tableNum.getRow(2).getInt("COMMANDE_CLIENT_START");
val++;
463,10 → 456,6
 
@Override
public void select(SQLRowAccessor r) {
 
if (r != null) {
this.numeroUniqueCommande.setIdSelected(r.getID());
}
if (r == null || r.getIDNumber() == null)
super.select(r);
else {
545,7 → 534,7
 
public void setDefaults() {
this.resetValue();
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
this.table.getModel().clearRows();
}
 
577,7 → 566,7
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("T_POIDS", 0.0F);
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
// User
// SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/CommandeClientSQLElement.java
20,6 → 20,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
28,10 → 29,10
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ListMap;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
90,8 → 91,10
}
 
@Override
protected void archive(SQLRow row, boolean cutLinks) throws SQLException {
super.archive(row, cutLinks);
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
 
for (SQLRow row : trees.getRows()) {
 
// Mise à jour des stocks
SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
SQLSelect sel = new SQLSelect();
109,6 → 112,8
}
}
}
super.archive(trees, cutLinks);
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
163,9 → 168,9
rowValsElt.put("ID_STYLE", sqlRow.getObject("ID_STYLE"));
rowValsElt.put("QTE", sqlRow.getObject("QTE"));
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), MathContext.DECIMAL128));
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
rowValsElt.put("T_PA_TTC",
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), MathContext.DECIMAL128));
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), DecimalUtils.HIGH_PRECISION));
 
map.add(rowArticleFind.getForeignRow("ID_FOURNISSEUR"), rowValsElt);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/SaisieVenteFactureSQLElement.java
67,6 → 67,7
import org.openconcerto.ui.table.PercentTableCellRenderer;
import org.openconcerto.utils.CollectionMap;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.Tuple2;
78,7 → 79,6
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.ArrayList;
85,8 → 85,10
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.AbstractAction;
276,7 → 278,7
 
final BigDecimal totalAregler = new BigDecimal(r.getLong("T_TTC")).subtract(avoirTTC);
if (totalAregler.signum() > 0 && totalEch > 0) {
return totalAregler.subtract(new BigDecimal(totalEch)).divide(totalAregler, MathContext.DECIMAL128).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
return totalAregler.subtract(new BigDecimal(totalEch)).divide(totalAregler, DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
} else {
return BigDecimal.ONE.movePointRight(2);
}
466,22 → 468,22
if (rowDeviseF != null && !rowDeviseF.isUndefined()) {
if (rowDeviseF.getID() == rowDeviseHA.getID()) {
rowValsElt.put("PA_DEVISE", rowArticleFind.getObject("PA_DEVISE"));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowArticleFind.getObject("PA_DEVISE")).multiply(qte, MathContext.DECIMAL128));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowArticleFind.getObject("PA_DEVISE")).multiply(qte, DecimalUtils.HIGH_PRECISION));
rowValsElt.put("ID_DEVISE", rowDeviseF.getID());
} else {
BigDecimal taux = (BigDecimal) rowDeviseF.getObject("TAUX");
rowValsElt.put("PA_DEVISE", taux.multiply((BigDecimal) rowValsElt.getObject("PA_HT")));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowValsElt.getObject("PA_DEVISE")).multiply(qte, MathContext.DECIMAL128));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowValsElt.getObject("PA_DEVISE")).multiply(qte, DecimalUtils.HIGH_PRECISION));
rowValsElt.put("ID_DEVISE", rowDeviseF.getID());
}
}
 
BigDecimal prixHA = (BigDecimal) rowValsElt.getObject("PA_HT");
rowValsElt.put("T_PA_HT", prixHA.multiply(qte, MathContext.DECIMAL128));
rowValsElt.put("T_PA_HT", prixHA.multiply(qte, DecimalUtils.HIGH_PRECISION));
 
rowValsElt.put("T_PA_HT", prixHA.multiply(qte, MathContext.DECIMAL128));
rowValsElt.put("T_PA_HT", prixHA.multiply(qte, DecimalUtils.HIGH_PRECISION));
rowValsElt.put("T_PA_TTC",
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal(rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0), MathContext.DECIMAL128));
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal(rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0), DecimalUtils.HIGH_PRECISION));
 
map.add(rowArticleFind.getForeignRow("ID_FOURNISSEUR"), rowValsElt);
 
493,4 → 495,19
});
 
}
 
public interface DoWithRow {
public void process(SQLRow row);
}
 
Map<String, DoWithRow> specialAction = new HashMap<String, DoWithRow>();
 
public DoWithRow getSpecialAction(String key) {
return specialAction.get(key);
}
 
public void putSpecialAction(String key, DoWithRow action) {
specialAction.put(key, action);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/EcheanceClientSQLElement.java
45,6 → 45,7
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.CollectionMap;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.GestionDevise;
 
import java.awt.GridBagConstraints;
52,7 → 53,6
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
209,7 → 209,7
SQLRow rowDevise = rowTarif.getForeign("ID_DEVISE");
BigDecimal t = (BigDecimal) rowDevise.getObject("TAUX");
BigDecimal bigDecimal = new BigDecimal(lRestantDevise);
lRestantDevise = t.signum() == 0 ? lRestantDevise : bigDecimal.multiply(t, MathContext.DECIMAL128).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
lRestantDevise = t.signum() == 0 ? lRestantDevise : bigDecimal.multiply(t, DecimalUtils.HIGH_PRECISION).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
if (rowDevise.getString("CODE").trim().length() > 0) {
devise = rowDevise.getString("CODE");
} else {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/NouveauSaisieVenteFactureAcompteAction.java
New file
0,0 → 1,36
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class NouveauSaisieVenteFactureAcompteAction extends CreateFrameAbstractAction {
 
public NouveauSaisieVenteFactureAcompteAction() {
super();
this.putValue(Action.NAME, "Facture");
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE").createComponent(VenteFactureSituationSQLComponent.ID), EditMode.CREATION);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListPanelEcheancesClients.java
18,6 → 18,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
34,6 → 35,7
 
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.table.TableColumn;
 
public class ListPanelEcheancesClients extends ListeAddPanel {
 
102,9 → 104,24
}
getListe().getRequest().setWhere(wNotRegle);
 
final ListEcheanceClientRenderer rend = new ListEcheanceClientRenderer();
final ListEcheanceClientRenderer rend = new ListEcheanceClientRenderer(false);
final ListEcheanceClientRenderer rendDate = new ListEcheanceClientRenderer(true);
//
SQLTableModelColumn colDate = ListPanelEcheancesClients.this.getListe().getSource().getColumn(elementEchT.getField("DATE"));
int indexColDate = ListPanelEcheancesClients.this.getListe().getSource().getColumns().indexOf(colDate);
for (int i = 0; i < ListPanelEcheancesClients.this.getListe().getJTable().getColumnCount(); i++) {
if (ListPanelEcheancesClients.this.getListe().getJTable().getColumnClass(i) != Boolean.class) {
 
getListe().getSource().getColumn(elementEchT.getField("DATE")).setRenderer(rend);
TableColumn col = ListPanelEcheancesClients.this.getListe().getJTable().getColumnModel().getColumn(i);
if (col.getModelIndex() == indexColDate) {
col.setCellRenderer(rendDate);
} else {
col.setCellRenderer(rend);
}
}
}
 
getListe().getSource().getColumn(elementEchT.getField("DATE")).setRenderer(rendDate);
ListPanelEcheancesClients.this.buttonAjouter.setVisible(false);
ListPanelEcheancesClients.this.buttonEffacer.setVisible(false);
ListPanelEcheancesClients.this.buttonModifier.setVisible(false);
113,11 → 130,17
 
ListPanelEcheancesClients.this.getListe().setSQLEditable(true);
 
SQLField fieldDateEch = elementEchT.getField("DATE");
for (SQLTableModelColumn column : src.getColumns()) {
if (column.getClass().isAssignableFrom(SQLTableModelColumnPath.class)) {
((SQLTableModelColumnPath) column).setEditable(false);
}
if (column.getFields().contains(fieldDateEch)) {
column.setRenderer(rendDate);
} else {
column.setRenderer(rend);
}
}
 
((SQLTableModelColumnPath) src.getColumns(getElement().getTable().getField("INFOS")).iterator().next()).setEditable(true);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListEcheanceClientRenderer.java
48,8 → 48,11
// Rouge
private final static Color couleurRegCompta = new Color(255, 202, 255);
 
public ListEcheanceClientRenderer() {
private final boolean date;
 
public ListEcheanceClientRenderer(boolean date) {
super();
this.date = date;
}
 
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
59,7 → 62,7
if (!isSelected) {
 
setForeground(Color.BLACK);
if (value instanceof Date) {
if (this.date) {
if (!((Date) value).after(new Date())) {
setForeground(couleurEcheance);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/component/SaisieVenteFactureSQLComponent.java
27,6 → 27,7
import org.openconcerto.erp.core.finance.payment.component.ModeDeReglementSQLComponent;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement.DoWithRow;
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
import org.openconcerto.erp.core.sales.invoice.ui.SaisieVenteFactureItemTable;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
76,6 → 77,7
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
112,7 → 114,8
private ISQLCompteSelector compteSel;
private final SQLTable tableNum = this.factureElt.getTable().getBase().getTable("NUMEROTATION_AUTO");
private JCheckBox checkCompteServiceAuto, checkPrevisionnelle, checkComplement, checkAcompte, checkCT;
private PanelOOSQLComponent panelOO;
 
protected PanelOOSQLComponent panelOO;
private ElementComboBox selAvoir, selAffaire;
private ElementSQLObject eltModeRegl;
private static final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
169,7 → 172,6
private ElementComboBox comboVerificateur = new ElementComboBox();;
private SQLTable tableBanque = getTable().getTable(BanqueSQLElement.TABLENAME);
 
 
public SaisieVenteFactureSQLComponent() {
super(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE"));
 
694,7 → 696,6
if (SaisieVenteFactureSQLComponent.this.comboClient.getValue() != null) {
final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow();
final int id = row == null ? SQLRow.NONEXISTANT_ID : row.getID();
 
SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row);
if (row != null) {
if (SaisieVenteFactureSQLComponent.this.contact != null) {
715,6 → 716,7
 
SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(w);
}
 
} else {
if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) {
SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(null);
897,6 → 899,8
@Override
public void select(SQLRowAccessor r) {
 
this.panelOO.getCheckAbo().setSelected(false);
 
boolean isPartial = false;
if (r != null && r.getBoolean("PARTIAL") != null) {
isPartial = r.getBoolean("PARTIAL").booleanValue();
918,10 → 922,9
if (this.comboClient != null)
this.comboClient.rmValueListener(this.listenerModeReglDefaut);
}
 
this.rowSelected = r;
if (r != null) {
this.textNumeroUnique.setIdSelected(r.getID());
 
// FIXME Mettre un droit pour autoriser la modification d'une facture lettrée ou pointée
if (!r.isUndefined() && r.getObject("ID_MOUVEMENT") != null && !r.isForeignEmpty("ID_MOUVEMENT")) {
SQLTable tableEcr = getTable().getTable("ECRITURE");
985,6 → 988,7
setAcompte(false);
}
}
 
if (this.comboClient != null) {
if (getMode() != Mode.INSERTION) {
this.comboClient.addValueListener(this.listenerModeReglDefaut);
1078,7 → 1082,9
// Mise à jour des tables liées
this.tableFacture.updateField("ID_SAISIE_VENTE_FACTURE", idSaisieVF);
 
this.tableFacture.createArticle(idSaisieVF, this.getElement());
 
 
createDocument(rowFacture);
 
int idMvt = -1;
1159,7 → 1165,14
}
 
 
if (getTable().getDBRoot().contains("ABONNEMENT") && panelOO.isCheckAboSelected()) {
DoWithRow doWithRow = ((SaisieVenteFactureSQLElement) getElement()).getSpecialAction("subscription.autocreate");
if (doWithRow != null) {
doWithRow.process(rowFacture);
}
}
 
}
} catch (Exception e) {
ExceptionHandler.handle("", e);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisSQLElement.java
24,10 → 24,13
import org.openconcerto.erp.core.sales.quote.ui.QuoteEditGroup;
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.erp.utils.KDUtils;
import org.openconcerto.erp.utils.KDUtils.Folder;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
37,6 → 40,7
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBoxUtils;
import org.openconcerto.sql.ui.StringWithId;
43,16 → 47,19
import org.openconcerto.sql.ui.light.GroupToLightUIConvertor;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.EditPanelListener;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.light.ActivationOnSelectionControler;
import org.openconcerto.ui.light.ColumnSpec;
import org.openconcerto.ui.light.ColumnsSpec;
import org.openconcerto.ui.light.CustomEditorProvider;
import org.openconcerto.ui.light.LightControler;
import org.openconcerto.ui.light.LightUIButton;
import org.openconcerto.ui.light.LightUIButtonUnmanaged;
import org.openconcerto.ui.light.LightUIButtonWithContext;
import org.openconcerto.ui.light.LightUIComboElement;
import org.openconcerto.ui.light.LightUIDescriptor;
import org.openconcerto.ui.light.LightUIElement;
59,20 → 66,25
import org.openconcerto.ui.light.LightUILine;
import org.openconcerto.ui.light.LightUITextField;
import org.openconcerto.ui.light.Row;
import org.openconcerto.ui.light.RowSpec;
import org.openconcerto.ui.light.TableContent;
import org.openconcerto.ui.light.TableSpec;
import org.openconcerto.ui.table.TimestampTableCellRenderer;
import org.openconcerto.utils.CollectionMap;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.event.ActionEvent;
import java.io.File;
import java.math.BigDecimal;
import java.math.MathContext;
import java.nio.channels.IllegalSelectorException;
import java.net.URI;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
87,6 → 99,32
 
public static final String TABLENAME = "DEVIS";
 
public static enum Month {
 
JANVIER("01", "Janvier"), FEVRIER("02", "Février"), MARS("03", "Mars"), AVRIL("04", "Avril"), MAI("05", "Mai"), JUIN("06", "Juin"), JUILLET("07", "Juillet"), AOUT("08", "Août"), SEPTEMBRE(
"09", "Septembre"), OCTOBRE("10", "Octobre"), NOVEMBRE("11", "Novembre"), DECEMBRE("12", "Décembre");
 
private String number;
private String name;
 
Month(String number, String name) {
this.number = number;
this.name = name;
}
 
public String getName() {
return this.name;
}
 
public String getNumber() {
return this.number;
}
 
public String getPath() {
return this.getNumber() + "-" + this.getName();
}
};
 
public DevisSQLElement() {
this("un devis", "devis");
}
97,6 → 135,7
setDefaultGroup(new QuoteEditGroup());
}
 
 
private List<RowAction> getDevisRowActions() {
 
List<RowAction> rowsActions = new ArrayList<RowAction>();
107,6 → 146,22
 
rowsActions.add(factureAction);
 
PredicateRowAction actionClient = new PredicateRowAction(new AbstractAction("Détails client") {
EditFrame edit;
private SQLElement eltClient = Configuration.getInstance().getDirectory().getElement(((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CLIENT"));
 
public void actionPerformed(ActionEvent e) {
if (edit == null) {
edit = new EditFrame(eltClient, EditMode.MODIFICATION);
}
edit.selectionId(IListe.get(e).getSelectedRow().getForeignID("ID_CLIENT"));
edit.setVisible(true);
}
}, false);
actionClient.setPredicate(IListeEvent.getSingleSelectionPredicate());
rowsActions.add(actionClient);
 
 
// Voir le document
RowAction actionTransfertCmd = getDevis2CmdFournAction();
rowsActions.add(actionTransfertCmd);
205,7 → 260,8
}, false, "sales.quote.accept") {
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowAccessor> selection) {
if (selection != null && selection.size() == 1) {
if (selection.get(0).getInt("ID_ETAT_DEVIS") == EtatDevisSQLElement.EN_ATTENTE) {
final int int1 = selection.get(0).getInt("ID_ETAT_DEVIS");
if (int1 != EtatDevisSQLElement.REFUSE && int1 != EtatDevisSQLElement.ACCEPTE) {
return true;
}
}
218,15 → 274,16
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).copySelectedRows(), "SAISIE_VENTE_FACTURE");
 
}
}, true, "sales.quote.create.invoice") {
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowAccessor> selection) {
if (selection != null && selection.size() == 1) {
if (selection.get(0).getInt("ID_ETAT_DEVIS") == EtatDevisSQLElement.ACCEPTE) {
return true;
boolean b = selection.size() > 0;
for (SQLRowAccessor sqlRowAccessor : selection) {
b &= sqlRowAccessor.getInt("ID_ETAT_DEVIS") == EtatDevisSQLElement.ACCEPTE;
}
}
return false;
 
return b;
};
};
}
411,9 → 468,9
rowValsElt.put("ID_STYLE", sqlRow.getObject("ID_STYLE"));
rowValsElt.put("QTE", sqlRow.getObject("QTE"));
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE"), MathContext.DECIMAL128)));
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE"), DecimalUtils.HIGH_PRECISION)));
rowValsElt.put("T_PA_TTC",
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal(rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0), MathContext.DECIMAL128));
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal(rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0), DecimalUtils.HIGH_PRECISION));
 
// gestion de la devise
rowDeviseF = sqlRow.getForeignRow("ID_DEVISE");
422,12 → 479,12
if (rowDeviseF != null && !rowDeviseF.isUndefined()) {
if (rowDeviseF.getID() == rowDeviseHA.getID()) {
rowValsElt.put("PA_DEVISE", rowArticleFind.getObject("PA_DEVISE"));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowArticleFind.getObject("PA_DEVISE")).multiply(qte, MathContext.DECIMAL128));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowArticleFind.getObject("PA_DEVISE")).multiply(qte, DecimalUtils.HIGH_PRECISION));
rowValsElt.put("ID_DEVISE", rowDeviseF.getID());
} else {
BigDecimal taux = (BigDecimal) rowDeviseF.getObject("TAUX");
rowValsElt.put("PA_DEVISE", taux.multiply((BigDecimal) rowValsElt.getObject("PA_HT")));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowValsElt.getObject("PA_DEVISE")).multiply(qte, MathContext.DECIMAL128));
rowValsElt.put("PA_DEVISE_T", ((BigDecimal) rowValsElt.getObject("PA_DEVISE")).multiply(qte, DecimalUtils.HIGH_PRECISION));
rowValsElt.put("ID_DEVISE", rowDeviseF.getID());
}
}
448,6 → 505,7
l.add("ID_CLIENT");
l.add("OBJET");
l.add("ID_COMMERCIAL");
l.add("T_HA");
l.add("T_HT");
l.add("T_TTC");
l.add("INFOS");
454,6 → 512,7
return l;
}
 
 
@Override
public CollectionMap<String, String> getShowAs() {
 
501,7 → 560,7
*
* @param devisID
*/
public void transfertFacture(int devisID) {
public void transfertFacture(final int devisID) {
 
SQLElement elt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
EditFrame editFactureFrame = new EditFrame(elt);
512,6 → 571,7
comp.setDefaults();
comp.loadDevis(devisID);
 
 
editFactureFrame.pack();
editFactureFrame.setState(JFrame.NORMAL);
editFactureFrame.setVisible(true);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/ui/ListeDesDevisPanel.java
38,6 → 38,7
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.table.PercentTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.SwingWorker2;
import org.openconcerto.utils.Tuple2;
46,7 → 47,6
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
179,19 → 179,73
 
}
 
private BigDecimal getAvancement(SQLRowAccessor r) {
private BigDecimal getAvancementCommande(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_DEVIS"));
long totalFact = 0;
long total = r.getLong("T_HT");
 
for (SQLRowAccessor row : rows) {
if (!row.isForeignEmpty("ID_COMMANDE_CLIENT")) {
SQLRowAccessor rowFact = row.getForeign("ID_COMMANDE_CLIENT");
Long l = rowFact.getLong("T_HT");
totalFact += l;
}
}
 
if (total > 0) {
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
} else {
return BigDecimal.ONE.movePointRight(2);
}
}
 
private BigDecimal getAvancementFacture(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_DEVIS"));
long totalFact = 0;
long total = r.getLong("T_HT");
 
List<SQLRowAccessor> rowsCmd = new ArrayList<SQLRowAccessor>();
for (SQLRowAccessor row : rows) {
if (!row.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) {
SQLRowAccessor rowFact = row.getForeign("ID_SAISIE_VENTE_FACTURE");
Long l = rowFact.getLong("T_HT");
totalFact += l;
}
if (!row.isForeignEmpty("ID_COMMANDE_CLIENT")) {
rowsCmd.add(row.getForeign("ID_COMMANDE_CLIENT"));
}
}
 
List<SQLRowAccessor> rowsBL = new ArrayList<SQLRowAccessor>();
for (SQLRowAccessor row : rowsCmd) {
Collection<? extends SQLRowAccessor> rowsTrCmd = row.getReferentRows(r.getTable().getTable("TR_COMMANDE_CLIENT"));
for (SQLRowAccessor sqlRowAccessor : rowsTrCmd) {
 
if (!sqlRowAccessor.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) {
SQLRowAccessor rowFact = sqlRowAccessor.getForeign("ID_SAISIE_VENTE_FACTURE");
Long l = rowFact.getLong("T_HT");
totalFact += l;
}
if (!sqlRowAccessor.isForeignEmpty("ID_BON_DE_LIVRAISON")) {
rowsBL.add(sqlRowAccessor.getForeign("ID_BON_DE_LIVRAISON"));
}
}
}
 
for (SQLRowAccessor row : rowsBL) {
Collection<? extends SQLRowAccessor> rowsTrBL = row.getReferentRows(r.getTable().getTable("TR_COMMANDE_CLIENT"));
for (SQLRowAccessor sqlRowAccessor : rowsTrBL) {
 
if (!sqlRowAccessor.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) {
SQLRowAccessor rowFact = sqlRowAccessor.getForeign("ID_SAISIE_VENTE_FACTURE");
Long l = rowFact.getLong("T_HT");
totalFact += l;
}
}
}
 
if (total > 0) {
return new BigDecimal(totalFact).divide(new BigDecimal(total), MathContext.DECIMAL128).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
} else {
return BigDecimal.ONE.movePointRight(2);
}
207,20 → 261,40
dateEnvoiCol.setRenderer(new DateEnvoiRenderer());
dateEnvoiCol.setEditable(true);
 
final BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) {
final BaseSQLTableModelColumn colAvancementCmd = new BaseSQLTableModelColumn("Commande", BigDecimal.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
return getAvancement(r);
return getAvancementCommande(r);
}
 
@Override
public Set<FieldPath> getPaths() {
final Path p = new PathBuilder(eltDevis.getTable()).addTable("TR_DEVIS").addTable("SAISIE_VENTE_FACTURE").build();
final Path p = new PathBuilder(eltDevis.getTable()).addTable("TR_DEVIS").addTable("COMMANDE_CLIENT").build();
return CollectionUtils.createSet(new FieldPath(p, "T_HT"));
}
};
lAttente.getColumns().add(colAvancementCmd);
colAvancementCmd.setRenderer(new PercentTableCellRenderer());
 
final BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Facturation", BigDecimal.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
return getAvancementFacture(r);
}
 
@Override
public Set<FieldPath> getPaths() {
final Path p = new PathBuilder(eltDevis.getTable()).addTable("TR_DEVIS").addTable("SAISIE_VENTE_FACTURE").build();
final Path p2 = new PathBuilder(eltDevis.getTable()).addTable("TR_DEVIS").addTable("COMMANDE_CLIENT").addTable("TR_COMMANDE_CLIENT").addTable("SAISIE_VENTE_FACTURE").build();
final Path p3 = new PathBuilder(eltDevis.getTable()).addTable("TR_DEVIS").addTable("COMMANDE_CLIENT").addTable("TR_COMMANDE_CLIENT").addTable("BON_DE_LIVRAISON")
.addTable("TR_BON_DE_LIVRAISON").addTable("SAISIE_VENTE_FACTURE").build();
return CollectionUtils.createSet(new FieldPath(p, "T_HT"), new FieldPath(p2, "T_HT"), new FieldPath(p3, "T_HT"));
}
};
lAttente.getColumns().add(colAvancement);
colAvancement.setRenderer(new PercentTableCellRenderer());
} else {
262,7 → 336,7
// asList = Arrays.asList(this.eltDevis.getTable().getField("PREBILAN"),
// this.eltDevis.getTable().getField("T_HT"));
List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
fields.add(Tuple2.create(pane.getListe().getSource().getColumn(this.eltDevis.getTable().getField("T_HT")), IListTotalPanel.Type.SOMME));
fields.add(Tuple2.create(pane.getListe().getSource().getColumn(11), IListTotalPanel.Type.SOMME));
fields.add(Tuple2.create(pane.getListe().getSource().getColumn(this.eltDevis.getTable().getField("PREBILAN")), IListTotalPanel.Type.SOMME));
fields.add(Tuple2.create(new BaseSQLTableModelColumn("%MB", String.class) {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/component/DevisSQLComponent.java
37,6 → 37,7
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.model.Where;
53,7 → 54,10
import org.openconcerto.ui.VFlowLayout;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.SwingWorker2;
import org.openconcerto.utils.cc.ITransformer;
import org.openconcerto.utils.checks.ValidState;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.Color;
63,11 → 67,15
import java.awt.Insets;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
128,6 → 136,14
}
 
@Override
public Set<String> getPartialResetNames() {
Set<String> s = new HashSet<String>();
s.add("OBJET");
s.add("NUMERO");
return s;
}
 
@Override
public void addViews() {
setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
152,6 → 168,7
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
this.numeroUniqueDevis = new JUniqueTextField(15);
 
DefaultGridBagConstraints.lockMinimumSize(this.numeroUniqueDevis);
DefaultGridBagConstraints.lockMaximumSize(this.numeroUniqueDevis);
this.add(this.numeroUniqueDevis, c);
620,6 → 637,14
}
}
 
private ValidState validStateContact = ValidState.getTrueInstance();
 
@Override
public synchronized ValidState getValidState() {
assert SwingUtilities.isEventDispatchThread();
return super.getValidState().and(this.validStateContact);
}
 
private JPanel createPanelDiff(final Type_Diff type) {
 
GridBagConstraints cTabSite = new DefaultGridBagConstraints();
813,6 → 838,8
this.contactSite.setEditable(b);
this.faxSite.setEditable(b);
} else {
b = false;
 
this.sirenDonneur.setEditable(b);
this.desDonneur.setEditable(b);
this.adrDonneur.setEditable(b);
834,7 → 861,7
 
// Numero incremental auto
final SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
 
// User
// final SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
852,6 → 879,7
if (rowsComm != null) {
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
}
 
if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) {
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.EN_ATTENTE);
} else {
919,11 → 947,11
}
 
// incrémentation du numéro auto
if (NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class).equalsIgnoreCase(this.numeroUniqueDevis.getText().trim())) {
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.numeroUniqueDevis.getText().trim())) {
final SQLRowValues rowVals = new SQLRowValues(this.tableNum);
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class));
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()));
val++;
rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class), new Integer(val));
rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()), new Integer(val));
try {
rowVals.update(2);
} catch (final SQLException e) {
945,10 → 973,6
 
@Override
public void select(final SQLRowAccessor r) {
if (r != null) {
this.numeroUniqueDevis.setIdSelected(r.getID());
}
 
if (r == null || r.getIDNumber() == null)
super.select(r);
else {
1021,7 → 1045,7
final SQLRow row = devis.getTable().getRow(idDevis);
final SQLRowValues rowVals = new SQLRowValues(devis.getTable());
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT"));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
 
 
this.select(rowVals);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ReferenceArticleSQLComponent.java
40,6 → 40,7
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
52,7 → 53,6
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.List;
148,12 → 148,12
 
if (DefaultNXProps.getInstance().getBooleanValue(TotalPanel.MARGE_MARQUE, false)) {
if (vt.compareTo(BigDecimal.ZERO) > 0) {
value = margeHT.divide(vt, MathContext.DECIMAL128).multiply(BigDecimal.valueOf(100), MathContext.DECIMAL128);
value = margeHT.divide(vt, DecimalUtils.HIGH_PRECISION).multiply(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION);
} else {
value = BigDecimal.ZERO;
}
} else {
value = margeHT.divide(ha, MathContext.DECIMAL128).multiply(BigDecimal.valueOf(100), MathContext.DECIMAL128);
value = margeHT.divide(ha, DecimalUtils.HIGH_PRECISION).multiply(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION);
}
 
if (value.compareTo(BigDecimal.ZERO) > 0) {
185,14 → 185,14
 
BigDecimal d = StringUtils.getBigDecimalFromUserText(this.textMarge.getText());
if (DefaultNXProps.getInstance().getBooleanValue(TotalPanel.MARGE_MARQUE, false)) {
final BigDecimal e = BigDecimal.ONE.subtract(d.divide(BigDecimal.valueOf(100), MathContext.DECIMAL128));
final BigDecimal e = BigDecimal.ONE.subtract(d.divide(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION));
if (e.signum() == 0) {
this.textPVHT.setText("0");
} else {
this.textPVHT.setText(ha.divide(e, MathContext.DECIMAL128).setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
this.textPVHT.setText(ha.divide(e, DecimalUtils.HIGH_PRECISION).setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
} else {
BigDecimal result = ha.multiply(d.divide(BigDecimal.valueOf(100), MathContext.DECIMAL128).add(BigDecimal.ONE));
BigDecimal result = ha.multiply(d.divide(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION).add(BigDecimal.ONE));
this.textPVHT.setText(result.setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
}
828,7 → 828,7
ha = BigDecimal.ZERO;
}
final BigDecimal taux = (BigDecimal) boxDevise.getSelectedRow().getObject("TAUX");
textPAHT.setText(taux.multiply(ha, MathContext.DECIMAL128).setScale(getTable().getField("PA_DEVISE").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
textPAHT.setText(taux.multiply(ha, DecimalUtils.HIGH_PRECISION).setScale(getTable().getField("PA_DEVISE").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
 
}
}
1212,7 → 1212,7
if (id > 1) {
Float resultTaux = TaxeCache.getCache().getTauxFromId(id);
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue() / 100.0F;
this.textPVHT.setText(ttc.divide(BigDecimal.valueOf(taux).add(BigDecimal.ONE), MathContext.DECIMAL128)
this.textPVHT.setText(ttc.divide(BigDecimal.valueOf(taux).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION)
.setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
}
1227,7 → 1227,7
if (id > 1) {
final Float resultTaux = TaxeCache.getCache().getTauxFromId(id);
final float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue() / 100.0F;
this.textPVTTC.setText(ht.multiply(BigDecimal.valueOf(taux).add(BigDecimal.ONE), MathContext.DECIMAL128)
this.textPVTTC.setText(ht.multiply(BigDecimal.valueOf(taux).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION)
.setScale(getTable().getField("PV_TTC").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReferenceArticleSQLElement.java
31,16 → 31,26
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.utils.CollectionMap;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ListMap;
 
import java.awt.event.ActionEvent;
import java.math.BigDecimal;
import java.math.MathContext;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
public class ReferenceArticleSQLElement extends ComptaSQLConfElement {
56,9 → 66,26
super("ARTICLE", "un article", "articles");
 
getRowActions().addAll(new MouseSheetXmlListeListener(FicheArticleXmlSheet.class).getRowActions());
PredicateRowAction clone = new PredicateRowAction(new AbstractAction("Dupliquer") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
SQLRowValues rowVals = ReferenceArticleSQLElement.this.createCopy(IListe.get(e).getSelectedId());
ListMap<SQLTable, SQLRow> children = ReferenceArticleSQLElement.this.getChildrenRows(IListe.get(e).getSelectedRow().asRow());
for (SQLRow child : children.allValues()) {
Configuration.getInstance().getDirectory().getElement(child.getTable()).createCopy(child, false, rowVals);
}
EditFrame f = new EditFrame(createComponent(), EditMode.CREATION);
f.getSQLComponent().select(rowVals);
FrameUtil.show(f);
 
}
}, true, false);
clone.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(clone);
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline source = super.createTableSource();
227,23 → 254,23
if (mode == AU_METRE_CARRE) {
float surface = valMetrique1 * valMetrique2;
if (value == PRIX_HA) {
return metrique1HA.multiply(BigDecimal.valueOf(surface), MathContext.DECIMAL128);
return metrique1HA.multiply(BigDecimal.valueOf(surface), DecimalUtils.HIGH_PRECISION);
}
return metrique1VT.multiply(BigDecimal.valueOf(surface), MathContext.DECIMAL128);
return metrique1VT.multiply(BigDecimal.valueOf(surface), DecimalUtils.HIGH_PRECISION);
}
// Mode de vente au metre, largeur
if (mode == AU_METRE_LARGEUR) {
if (value == PRIX_HA) {
return metrique1HA.multiply(BigDecimal.valueOf(valMetrique2), MathContext.DECIMAL128);
return metrique1HA.multiply(BigDecimal.valueOf(valMetrique2), DecimalUtils.HIGH_PRECISION);
}
return metrique1VT.multiply(BigDecimal.valueOf(valMetrique2), MathContext.DECIMAL128);
return metrique1VT.multiply(BigDecimal.valueOf(valMetrique2), DecimalUtils.HIGH_PRECISION);
}
// Mode de vente au metre, longueur
if (mode == AU_METRE_LONGUEUR) {
if (value == PRIX_HA) {
return metrique1HA.multiply(BigDecimal.valueOf(valMetrique1), MathContext.DECIMAL128);
return metrique1HA.multiply(BigDecimal.valueOf(valMetrique1), DecimalUtils.HIGH_PRECISION);
}
return metrique1VT.multiply(BigDecimal.valueOf(valMetrique1), MathContext.DECIMAL128);
return metrique1VT.multiply(BigDecimal.valueOf(valMetrique1), DecimalUtils.HIGH_PRECISION);
}
// Mode de vente au poids / m2
if (mode == AU_POID_METRECARRE) {
250,9 → 277,9
float surface = valMetrique1 * valMetrique2;
float p = surface * valMetrique3;
if (value == PRIX_HA) {
return metrique1HA.multiply(BigDecimal.valueOf(p), MathContext.DECIMAL128);
return metrique1HA.multiply(BigDecimal.valueOf(p), DecimalUtils.HIGH_PRECISION);
}
return metrique1VT.multiply(BigDecimal.valueOf(p), MathContext.DECIMAL128);
return metrique1VT.multiply(BigDecimal.valueOf(p), DecimalUtils.HIGH_PRECISION);
}
throw new IllegalStateException("Unknown mode:" + mode);
 
317,6 → 344,7
SQLRowValues rowVals = l.get(0).asRowValues();
vals.put("ID_FOURNISSEUR", rowVals.getObject("ID_FOURNISSEUR"));
vals.put("CODE_BARRE", rowVals.getObject("CODE_BARRE"));
vals.put("QTE_ACHAT", rowVals.getObject("QTE_ACHAT"));
rowNew = vals.insert();
rowVals.put("ID_ARTICLE", rowNew.getID());
rowVals.commit();
369,7 → 397,7
SQLSelect sel = new SQLSelect(eltArticle.getTable().getBase());
sel.addSelect(eltArticle.getTable().getField("ID"));
 
Where w = new Where(eltArticle.getTable().getField("CODE"), "=", row.getString("CODE"));
Where w = new Where(eltArticle.getTable().getField("CODE"), "=", row.getString("CODE").trim());
if (includeMetrique) {
 
float value1 = ((Number) row.getObject("VALEUR_METRIQUE_1")).floatValue();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ArticleDesignationSQLElement.java
49,6 → 49,11
return l;
}
 
@Override
protected String getParentFFName() {
return "ID_ARTICLE";
}
 
/*
* (non-Javadoc)
*
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ArticleTarifSQLElement.java
44,6 → 44,11
return l;
}
 
@Override
protected String getParentFFName() {
return "ID_ARTICLE";
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/ListeDesArticlesAction.java
35,6 → 35,7
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.Tuple2;
 
import java.awt.GridBagConstraints;
45,7 → 46,6
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
90,7 → 90,7
float qte = stock.getFloat("QTE_REEL");
BigDecimal ha = r.getBigDecimal("PA_HT");
 
BigDecimal total = ha.multiply(new BigDecimal(qte), MathContext.DECIMAL128);
BigDecimal total = ha.multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION);
if (total.signum() == 1) {
return total;
} else {
174,6 → 174,7
if (panel.getListe().getModel().isSearching())
title += ", recherche en cours";
 
if (this.panelFrame != null)
this.panelFrame.setTitle(title);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ArticleTarifTable.java
29,9 → 29,9
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTablePanel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.List;
import java.util.Vector;
 
166,7 → 166,7
 
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
editorPVHT.setTaxe(taux);
BigDecimal r = pHT.multiply(BigDecimal.valueOf(taux).divide(BigDecimal.valueOf(100)).add(BigDecimal.ONE), MathContext.DECIMAL128);
BigDecimal r = pHT.multiply(BigDecimal.valueOf(taux).divide(BigDecimal.valueOf(100)).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION);
return r.setScale(tableElement_PrixVente_TTC.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/Caisse.java
48,6 → 48,7
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.DesktopEnvironment;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Pair;
57,7 → 58,6
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.ArrayList;
186,10 → 186,10
Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
 
final BigDecimal valueHT = article.getPriceHTInCents().multiply(new BigDecimal(nb), MathContext.DECIMAL128);
final BigDecimal valueHT = article.getPriceHTInCents().multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION);
 
rowValsElt.put("T_PV_HT", valueHT);
rowValsElt.put("T_PV_TTC", valueHT.multiply(tauxTVA, MathContext.DECIMAL128));
rowValsElt.put("T_PV_TTC", valueHT.multiply(tauxTVA, DecimalUtils.HIGH_PRECISION));
rowValsElt.put("ID_TAXE", article.getIdTaxe());
rowValsElt.put("CODE", article.getCode());
rowValsElt.put("NOM", article.getName());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TextAreaTicketPanel.java
24,6 → 24,7
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.DecimalUtils;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
30,7 → 31,6
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.List;
 
import javax.swing.JButton;
111,7 → 111,7
a.setPriceHTInCents(ht);
int idTaxe = row2.getInt("ID_TAXE");
float tva = TaxeCache.getCache().getTauxFromId(idTaxe);
a.setPriceInCents(ht.multiply(new BigDecimal(1.0 + (tva / 100.0D)), MathContext.DECIMAL128));
a.setPriceInCents(ht.multiply(new BigDecimal(1.0 + (tva / 100.0D)), DecimalUtils.HIGH_PRECISION));
a.setIdTaxe(idTaxe);
t.addArticle(a);
t.setArticleCount(a, row2.getInt("QTE"));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TicketCellRenderer.java
16,6 → 16,7
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.ui.touch.ScrollableList;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.Pair;
 
import java.awt.Color;
28,7 → 29,6
import java.awt.Insets;
import java.awt.RenderingHints;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
 
import javax.swing.JLabel;
63,7 → 63,7
Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
 
BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(item.getSecond()), MathContext.DECIMAL128).multiply(tauxTVA, MathContext.DECIMAL128);
BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(item.getSecond()), DecimalUtils.HIGH_PRECISION).multiply(tauxTVA, DecimalUtils.HIGH_PRECISION);
final JLabel l3 = new JLabel(centsToString(multiply.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()), SwingConstants.RIGHT);
p.add(l3, c);
 
115,7 → 115,7
Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
 
BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(item.getSecond()), MathContext.DECIMAL128).multiply(tauxTVA, MathContext.DECIMAL128);
BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(item.getSecond()), DecimalUtils.HIGH_PRECISION).multiply(tauxTVA, DecimalUtils.HIGH_PRECISION);
final String s3 = centsToString(multiply.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue());
final int width3 = (int) g.getFontMetrics().getStringBounds(s3, g).getWidth() + inset * 2;
g.drawString(s3, list.getWidth() - width3, height);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/Ticket.java
24,6 → 24,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.Pair;
 
import java.io.File;
30,7 → 31,6
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
273,7 → 273,7
final Integer nb = item.getSecond();
Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(nb), MathContext.DECIMAL128).multiply(tauxTVA, MathContext.DECIMAL128);
BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION).multiply(tauxTVA, DecimalUtils.HIGH_PRECISION);
 
if (article.getCode() != null && !article.getCode().isEmpty()) {
// 2 lines
306,11 → 306,9
int totalTTCInCents = calc.getTotalTTC().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
int totalTVHAInCents = calc.getTotalTVA().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
 
 
prt.addToBuffer(
DefaultTicketPrinter.formatRight(maxWidth - MAX_PRICE_WIDTH, "MONTANT TOTAL TTC (Euros) : ")
+ DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(totalTTCInCents)),
DefaultTicketPrinter.BOLD);
+ DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(totalTTCInCents)), DefaultTicketPrinter.BOLD);
prt.addToBuffer(
DefaultTicketPrinter.formatRight(maxWidth - MAX_PRICE_WIDTH, "Dont TVA : ") + DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(totalTVHAInCents)),
DefaultTicketPrinter.NORMAL);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/NumerotationAutoSQLElement.java
31,6 → 31,8
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.IResultSetHandler;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
65,10 → 67,13
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
 
import org.apache.commons.dbutils.ResultSetHandler;
 
// FIXME bug JTextField for input bigInt
 
public class NumerotationAutoSQLElement extends ComptaSQLConfElement {
209,6 → 214,7
 
private void updateLabel(JTextField textStart, JTextField textFormat, JLabel label) {
if (textStart.getText().trim().length() > 0) {
try {
String numProposition = getNextNumero(textFormat.getText(), Integer.parseInt(textStart.getText()), new Date());
 
if (numProposition != null) {
218,6 → 224,9
label.setIcon(this.iconWarning);
label.setText("");
}
} catch (IllegalArgumentException e) {
JOptionPane.showMessageDialog(null, "Le format " + textFormat.getText() + " n'est pas valide!");
}
} else {
label.setIcon(this.iconWarning);
label.setText("");
237,12 → 246,21
 
public final static String AUTO_MONTH = "_AUTO_MONTH";
 
public static final String getNextNumero(Class<? extends SQLElement> clazz) {
/*
*
*
* @throws IllegalArgumentException pattern incorrect
*/
public static final String getNextNumero(Class<? extends SQLElement> clazz) throws IllegalArgumentException {
return getNextNumero(clazz, new Date());
}
 
// Format du type 'Fact'yyyy-MM-dd0000
public static final String getNextNumero(Class<? extends SQLElement> clazz, Date d) {
/*
* Format du type 'Fact'yyyy-MM-dd0000
*
* @throws IllegalArgumentException pattern incorrect
*/
public static final String getNextNumero(Class<? extends SQLElement> clazz, Date d) throws IllegalArgumentException {
SQLRow rowNum = TABLE_NUM.getRow(2);
String s = map.get(clazz);
 
287,7 → 305,10
return Tuple2.create(prefix, suffix);
}
 
protected static final String getNextNumero(String format, Integer start, Date d) {
/*
* @throws IllegalArgumentException pattern incorrect
*/
protected static final String getNextNumero(String format, Integer start, Date d) throws IllegalArgumentException {
if (start != null && start < 0) {
return null;
}
394,13 → 415,18
final String prefix = prefixSuffix.get0();
final String suffix = prefixSuffix.get1();
 
Where w = new Where(table.getField("NUMERO"), "LIKE", "%" + prefix + "%");
final SQLSelect sel = new SQLSelect();
sel.addSelect(table.getField("NUMERO"));
sel.addSelect(table.getKey());
 
sel.setWhere(new Where(table.getField("NUMERO"), "LIKE", "%" + prefix + "%"));
final List<SQLRow> l = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
sel.setWhere(w);
SQLDataSource source = Configuration.getInstance().getBase().getDataSource();
 
final ResultSetHandler createFromSelect = SQLRowListRSH.createFromSelect(sel);
 
final List<SQLRow> l = (List<SQLRow>) source.execute(sel.asString(), new IResultSetHandler(createFromSelect, false));
 
final String decimalPattern = "'" + prefix + "'" + suffix;
final DecimalFormat format = new DecimalFormat(decimalPattern);
int value = 0;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/StyleSQLElement.java
61,7 → 61,7
String s = (o == null) ? null : o.toString();
m.put(s, null);
}
 
m.put("BlankStyle", null);
return m;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculator.java
21,9 → 21,9
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.HashSet;
66,6 → 66,10
this(fieldHA, fieldHT, fieldDeviseTotal, false, null);
}
 
public void setRowDefaultCptService(SQLRowAccessor rowDefaultCptService) {
this.rowDefaultCptService = rowDefaultCptService;
}
 
public TotalCalculator(String fieldHA, String fieldHT, String fieldDeviseTotal, boolean achat, SQLRowAccessor defaultCompte) {
 
this.achat = achat;
230,7 → 234,7
totalTVA = BigDecimal.ZERO;
} else {
BigDecimal tauxTVA = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(tva.getID())).movePointLeft(2);
ttc = tauxTVA.add(BigDecimal.ONE).multiply(ht, MathContext.DECIMAL128);
ttc = tauxTVA.add(BigDecimal.ONE).multiply(ht, DecimalUtils.HIGH_PRECISION);
totalTVA = ttc.subtract(ht);
}
 
320,9 → 324,9
totalLineHT = totalLineHT.subtract(new BigDecimal(this.remiseRestante).movePointLeft(2));
this.remiseRestante = 0;
} else {
BigDecimal percent = totalLineHT.divide(this.totalHTAvantRemise, MathContext.DECIMAL128);
BigDecimal percent = totalLineHT.divide(this.totalHTAvantRemise, DecimalUtils.HIGH_PRECISION);
 
BigDecimal remiseApply = percent.multiply(new BigDecimal(this.remiseHT), MathContext.DECIMAL128).setScale(0, RoundingMode.HALF_UP);
BigDecimal remiseApply = percent.multiply(new BigDecimal(this.remiseHT), DecimalUtils.HIGH_PRECISION).setScale(0, RoundingMode.HALF_UP);
totalLineHT = totalLineHT.subtract(remiseApply.movePointLeft(2));
this.remiseRestante -= remiseApply.longValue();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractAchatArticleItemTable.java
36,9 → 36,9
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashMap;
360,7 → 360,7
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal f = (row.getObject("PA_HT") == null) ? BigDecimal.ZERO : (BigDecimal) row.getObject("PA_HT");
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), MathContext.DECIMAL128).setScale(totalHT.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), DecimalUtils.HIGH_PRECISION).setScale(totalHT.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
 
if (row.getTable().contains("POURCENT_REMISE")) {
final Object o2 = row.getObject("POURCENT_REMISE");
388,7 → 388,7
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal f = (BigDecimal) row.getObject("PA_DEVISE");
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), MathContext.DECIMAL128).setScale(tableElementTotalDevise.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), DecimalUtils.HIGH_PRECISION).setScale(tableElementTotalDevise.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
 
if (row.getTable().contains("POURCENT_REMISE")) {
final Object o2 = row.getObject("POURCENT_REMISE");
420,7 → 420,7
Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
 
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), MathContext.DECIMAL128), MathContext.DECIMAL128).setScale(tableElementTotalTTC.getDecimalDigits(),
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION).setScale(tableElementTotalTTC.getDecimalDigits(),
BigDecimal.ROUND_HALF_UP);
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalPanel.java
25,6 → 25,7
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.SwingWorker2;
36,7 → 37,6
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
396,6 → 396,7
}
 
private static String CLEAR = "";
private SwingWorker2<TotalCalculator, Object> worker;
 
private void clearTextField() {
 
486,13 → 487,14
}
 
final Boolean isServiceActive = bServiceActive;
if (worker != null) {
worker.cancel(true);
}
worker = new SwingWorker2<TotalCalculator, Object>() {
 
// Calcul des totaux
SwingWorker2<TotalCalculator, Object> worker = new SwingWorker2<TotalCalculator, Object>() {
 
@Override
protected TotalCalculator doInBackground() throws Exception {
 
Thread.sleep(100);
params.fetchArticle();
 
SQLTableElement tableElementTotalDevise = articleTable.getTableElementTotalDevise();
535,7 → 537,11
calc.setSelectedRows(selectedRows);
calc.setRemise(valRemiseHT, totalHTAvtremise);
 
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedException();
}
 
 
// Total des elements
int rowCount = size;
for (int i = 0; i < rowCount; i++) {
552,11 → 558,17
 
// Verification du resultat ht +tva = ttc
calc.checkResult();
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedException();
}
return calc;
}
 
@Override
protected void done() {
if (isCancelled()) {
return;
}
TotalCalculator calc;
try {
calc = get();
589,9 → 601,9
if (totalHA.signum() != 0) {
d = totalHT.subtract(totalHA);
if (DefaultNXProps.getInstance().getBooleanValue(MARGE_MARQUE, false) && totalHT.signum() != 0) {
m = d.divide(totalHT, MathContext.DECIMAL128).movePointRight(2);
m = d.divide(totalHT, DecimalUtils.HIGH_PRECISION).movePointRight(2);
} else {
m = d.divide(totalHA, MathContext.DECIMAL128).movePointRight(2);
m = d.divide(totalHA, DecimalUtils.HIGH_PRECISION).movePointRight(2);
}
}
if (d.compareTo(BigDecimal.ZERO) <= 0) {
611,9 → 623,9
if (totalHASel.signum() != 0) {
e = totalHTSel.subtract(totalHASel);
if (DefaultNXProps.getInstance().getBooleanValue(MARGE_MARQUE, false) && totalHTSel.signum() != 0) {
m2 = e.divide(totalHTSel, MathContext.DECIMAL128).movePointRight(2);
m2 = e.divide(totalHTSel, DecimalUtils.HIGH_PRECISION).movePointRight(2);
} else {
m2 = e.divide(totalHASel, MathContext.DECIMAL128).movePointRight(2);
m2 = e.divide(totalHASel, DecimalUtils.HIGH_PRECISION).movePointRight(2);
}
}
margeSel.setText("(" + m2.setScale(2, RoundingMode.HALF_UP) + "%) " + GestionDevise.currencyToString(e.setScale(2, RoundingMode.HALF_UP)));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCommandePanel.java
New file
0,0 → 1,168
/*
* 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 27 oct. 2014
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
 
public class TotalCommandePanel extends JPanel {
 
DeviseField textTotalHT, textTotalTVA, textTotalTTC, textPortHT, textRemiseHT, textService, textTotalHA, textTotalDevise, marge;
 
public TotalCommandePanel() {
 
super(new GridBagLayout());
textTotalHT = new DeviseField();
textTotalTVA = new DeviseField();
textTotalTTC = new DeviseField();
textPortHT = new DeviseField();
textRemiseHT = new DeviseField();
textService = new DeviseField();
textTotalHA = new DeviseField();
textTotalDevise = new DeviseField();
marge = new DeviseField();
GridBagConstraints c = new DefaultGridBagConstraints();
 
c.gridheight = 1;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
 
// Global
c.gridx = 3;
c.gridy = 0;
c.gridheight = GridBagConstraints.REMAINDER;
c.weighty = 1;
c.fill = GridBagConstraints.VERTICAL;
c.weightx = 0;
this.add(createSeparator(), c);
 
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.weighty = 0;
c.gridx++;
this.add(new JLabelBold("Global"), c);
c.gridy++;
c.gridx = 4;
c.gridwidth = 2;
c.weightx = 1;
this.add(createSeparator(), c);
this.marge = new DeviseField();
c.gridwidth = 1;
c.weightx = 0;
 
// Total HA HT
c.gridy++;
this.add(new JLabel("Total achat HT"), c);
 
c.gridx++;
c.weightx = 1;
this.add(this.textTotalHA, c);
 
// Marge
c.gridy++;
c.gridx = 4;
c.weightx = 0;
this.add(new JLabel("Marge"), c);
 
c.gridx++;
c.weightx = 1;
this.add(this.marge, c);
 
c.gridy++;
c.gridx = 4;
c.gridwidth = 2;
c.weightx = 1;
this.add(createSeparator(), c);
 
c.gridwidth = 1;
c.weightx = 0;
 
// Total HT
c.gridy++;
c.gridx = 4;
c.weightx = 0;
this.add(new JLabelBold("Total HT"), c);
 
c.gridx++;
c.weightx = 1;
this.add(textTotalHT, c);
 
if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SERVICE, false)) {
// Service
c.gridx = 4;
c.gridy++;
c.weightx = 0;
this.add(new JLabelBold("Service HT inclus "), c);
c.gridx++;
c.weightx = 1;
this.add(this.textService, c);
}
// TVA
c.gridx = 4;
c.gridy++;
c.weightx = 0;
this.add(new JLabelBold("Total TVA"), c);
c.gridx++;
c.weightx = 1;
this.add(textTotalTVA, c);
 
// Sep
c.gridwidth = 2;
c.gridx = 4;
c.gridy++;
c.weightx = 1;
c.fill = GridBagConstraints.BOTH;
this.add(createSeparator(), c);
 
// TTC
c.gridwidth = 1;
c.gridx = 4;
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabelBold("Total TTC"), c);
c.gridx++;
c.weightx = 1;
textTotalTTC.setFont(textTotalHT.getFont());
this.add(textTotalTTC, c);
 
}
 
private final JSeparator createSeparator() {
final JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
DefaultGridBagConstraints.lockMinimumSize(sep);
return sep;
}
 
public void loadFromCmd(SQLRowAccessor rowCmd) {
this.textTotalHT.setValue(rowCmd.getLong("T_HT"));
this.textTotalTVA.setValue(rowCmd.getLong("T_TVA"));
this.textTotalTTC.setValue(rowCmd.getLong("T_TTC"));
this.textTotalHA.setValue(rowCmd.getLong("T_HA"));
this.marge.setValue(rowCmd.getLong("T_HT") - rowCmd.getLong("T_HA"));
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListTotalPanel.java
52,7 → 52,9
SOMME,
// Marge en pourcentage requiert dans la liste la colonne achat en premier et vente en
// deuxieme
MOYENNE_MARGE;
MOYENNE_MARGE,
// Requiert le field TTC
AVANCEMENT_TTC;
};
 
DecimalFormat decimalFormat = new DecimalFormat("##,##0.00");
116,7 → 118,7
c.weightx = 1;
this.add(textField, c);
c.weightx = 0;
if (field2.get1() == Type.SOMME || field2.get1() == Type.MOYENNE_DEVISE) {
if (field2.get1() == Type.SOMME || field2.get1() == Type.MOYENNE_DEVISE || field2.get1() == Type.AVANCEMENT_TTC) {
this.add(new JLabelBold("€"), c);
} else if (field2.get1() == Type.MOYENNE_POURCENT || field2.get1() == Type.MOYENNE_MARGE) {
this.add(new JLabelBold("%"), c);
164,6 → 166,39
}
 
}
} else if (field.get1() == Type.AVANCEMENT_TTC) {
 
BigDecimal n = mapTotal.get(field.get0());
final SQLTableModelColumn columnTTC = list.getSource().getColumn(list.getSource().getPrimaryTable().getField("T_TTC"));
BigDecimal ttc = BigDecimal.valueOf(((Number) list.getModel().getValueAt(i, list.getSource().getColumns().indexOf(columnTTC))).doubleValue());
 
BigDecimal av = BigDecimal.valueOf(((Number) list.getModel().getValueAt(i, list.getSource().getColumns().indexOf(field.get0()))).doubleValue());
// if
// (list.getSource().getPrimaryTable().getName().equalsIgnoreCase(field.get0().getFields()))
// {
// n2 = (Long) rowAt.getObject(field.getName());
// } else {
// SQLField fk = (SQLField)
// rowAt.getTable().getForeignKeys(field.getTable()).toArray()[0];
// n2 = (Long)
// rowAt.getForeign(fk.getName()).getObject(field.getName());
// }
 
boolean in = true;
 
if (filters != null) {
for (Tuple2<SQLField, ?> tuple2 : filters) {
in = in && rowAt.getObject(tuple2.get0().getName()).equals(tuple2.get1());
}
}
 
if (in) {
if (n == null) {
mapTotal.put(field.get0(), ttc.multiply(av).movePointLeft(2));
} else {
mapTotal.put(field.get0(), n.add(ttc.multiply(av).movePointLeft(2)));
}
}
} else if (field.get1() != Type.MOYENNE_MARGE) {
BigDecimal n = mapTotal.get(field.get0());
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListFilterDatePanel.java
218,6 → 218,7
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridx = GridBagConstraints.RELATIVE;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
 
// Période pédéfini
if (map != null && map.keySet().size() > 0) {
242,8 → 243,11
}
// Filtre
this.add(new JLabel("Du"), c);
c.weightx = 1;
this.add(this.dateDu, c);
c.weightx = 0;
this.add(new JLabel("Au"), c);
c.weightx = 1;
this.add(this.dateAu, c);
this.dateAu.addValueListener(this.listener);
this.dateDu.addValueListener(this.listener);
451,13 → 455,18
 
String name = null;
for (IListe l : mapList.keySet()) {
String confName = l.getConfigFile().getName();
final File configFile = l.getConfigFile();
if (configFile != null) {
String confName = configFile.getName();
if (name == null) {
name = confName;
} else if (name.compareTo(confName) > 0) {
name = confName;
}
} else {
name = l.getSource().getPrimaryTable().getName();
}
}
return new File(conf.getConfDir(), "DateRanges" + File.separator + name);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseNumericRemiseCellEditor.java
14,6 → 14,7
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.StringUtils;
 
import java.awt.event.ActionEvent;
20,7 → 21,6
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
 
import javax.swing.AbstractAction;
51,7 → 51,7
public void actionPerformed(ActionEvent e) {
final BigDecimal prixHTRemise = StringUtils.getBigDecimalFromUserText(textField.getText());
if (prixHTRemise != null) {
BigDecimal divide = prixHTRemise.divide(ht, MathContext.DECIMAL128).movePointRight(2);
BigDecimal divide = prixHTRemise.divide(ht, DecimalUtils.HIGH_PRECISION).movePointRight(2);
divide = divide.setScale(precision, RoundingMode.HALF_UP);
textField.setText(divide.toString());
}
65,7 → 65,7
public void actionPerformed(ActionEvent e) {
final BigDecimal prixTTCRemise = StringUtils.getBigDecimalFromUserText(textField.getText());
if (prixTTCRemise != null) {
BigDecimal divide = prixTTCRemise.divide(ttc, MathContext.DECIMAL128).movePointRight(2);
BigDecimal divide = prixTTCRemise.divide(ttc, DecimalUtils.HIGH_PRECISION).movePointRight(2);
divide = divide.setScale(precision, RoundingMode.HALF_UP);
textField.setText(divide.toString());
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/Remise.java
13,8 → 13,9
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
 
public class Remise extends Acompte {
 
25,7 → 26,7
public BigDecimal getResultFrom(BigDecimal montant) {
 
if (this.percent != null) {
return montant.subtract(montant.multiply(percent.movePointLeft(2), MathContext.DECIMAL128));
return montant.subtract(montant.multiply(percent.movePointLeft(2), DecimalUtils.HIGH_PRECISION));
} else if (this.getMontant() == null) {
return montant;
} else {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/Acompte.java
13,10 → 13,10
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.StringUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.text.DecimalFormat;
 
public class Acompte {
42,10 → 42,10
 
public String toPlainString() {
if (percent != null) {
DecimalFormat format = new DecimalFormat("###.00");
DecimalFormat format = new DecimalFormat("##0.00");
return format.format(percent) + "%";
} else if (montant != null) {
DecimalFormat format = new DecimalFormat("###,###.00");
DecimalFormat format = new DecimalFormat("###,##0.00");
return format.format(montant);
} else {
return "";
66,7 → 66,7
public BigDecimal getResultFrom(BigDecimal montant) {
 
if (this.percent != null) {
return montant.multiply(percent.movePointLeft(2), MathContext.DECIMAL128);
return montant.multiply(percent.movePointLeft(2), DecimalUtils.HIGH_PRECISION);
} else if (this.getMontant() == null) {
return montant;
} else {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractArticleItemTable.java
190,7 → 190,11
if (poidsTColIndex >= 0) {
for (int i = 0; i < this.table.getRowCount(); i++) {
final Number tmp = (Number) this.model.getValueAt(i, poidsTColIndex);
if (tmp != null && this.model.getRowValuesAt(i).getInt("NIVEAU") == 1) {
int level = 1;
if (this.model.getRowValuesAt(i).getObject("NIVEAU") != null) {
level = this.model.getRowValuesAt(i).getInt("NIVEAU");
}
if (tmp != null && level == 1) {
poids += tmp.floatValue();
}
}
274,7 → 278,10
 
int rowCount = this.model.getRowCount();
SQLRowValues rowValsSource = this.getRowValuesTable().getRowValuesTableModel().getRowValuesAt(index);
int niveauSource = rowValsSource.getInt("NIVEAU");
int niveauSource = 1;
if (rowValsSource.getObject("NIVEAU") != null) {
niveauSource = rowValsSource.getInt("NIVEAU");
}
if (niveauSource > 1) {
int startFrom = index;
for (int i = index + 1; i < rowCount; i++) {
288,15 → 295,24
 
if (startFrom == index) {
 
// index à mettre à jour (de niveau n-1)
int indexToUpdate = index;
BigDecimal prixUnitHT = BigDecimal.ZERO;
BigDecimal prixUnitHA = BigDecimal.ZERO;
 
// Test pour éviter aucun niveau n-1 dans le tableau (ex : que des niveaux 2)
boolean update = false;
 
// Calcul du sous total
for (int i = index; i >= 0; i--) {
indexToUpdate = i;
SQLRowValues rowVals = this.getRowValuesTable().getRowValuesTableModel().getRowValuesAt(i);
final int niveauCourant = rowVals.getInt("NIVEAU");
int niveauCourant = 1;
if (rowVals.getObject("NIVEAU") != null) {
niveauCourant = rowVals.getInt("NIVEAU");
}
if (niveauCourant < niveauSource) {
 
update = true;
break;
} else if (niveauCourant == niveauSource) {
// Cumul des valeurs
304,7 → 320,7
prixUnitHA = prixUnitHA.add(rowVals.getBigDecimal("PA_HT").multiply(new BigDecimal(rowVals.getInt("QTE"))).multiply(rowVals.getBigDecimal("QTE_UNITAIRE")));
}
}
 
if (update) {
this.model.putValue(prixUnitHA, indexToUpdate, "PRIX_METRIQUE_HA_1");
// this.model.putValue(prixUnitHA, indexToUpdate, "PA_HT");
this.model.putValue(ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeignID("ID_DEVISE"), indexToUpdate, "ID_DEVISE");
314,6 → 330,7
// if (indexToUpdate < rowCount) {
// calculTarifNomenclature(indexToUpdate);
// }
}
} else {
calculTarifNomenclature(startFrom);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractVenteArticleItemTable.java
39,10 → 39,10
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.utils.DecimalUtils;
 
import java.awt.Component;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
138,7 → 138,7
BigDecimal qteU = rowVals.getBigDecimal("QTE_UNITAIRE");
BigDecimal pU = rowVals.getBigDecimal("PV_HT");
 
BigDecimal totalLine = pU.multiply(qteU, MathContext.DECIMAL128).multiply(new BigDecimal(qte), MathContext.DECIMAL128).setScale(2, RoundingMode.HALF_UP);
BigDecimal totalLine = pU.multiply(qteU, DecimalUtils.HIGH_PRECISION).multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).setScale(2, RoundingMode.HALF_UP);
 
// BigDecimal lremise = (type == TypeCalcul.CALCUL_FACTURABLE ?
// rowVals.getBigDecimal("POURCENT_REMISE") : BigDecimal.ZERO);
147,7 → 147,7
// lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
// totalLine =
// totalLine.multiply(BigDecimal.valueOf(100).subtract(lremise),
// MathContext.DECIMAL128).movePointLeft(2);
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
// }
if (type == TypeCalcul.CALCUL_FACTURABLE) {
if (rowVals.getTable().getFieldsName().contains("MONTANT_REMISE")) {
171,7 → 171,7
BigDecimal qteU = rowVals.getBigDecimal("QTE_UNITAIRE");
BigDecimal pU = rowVals.getBigDecimal("PV_HT");
 
BigDecimal totalLine = pU.multiply(qteU, MathContext.DECIMAL128).multiply(new BigDecimal(qte), MathContext.DECIMAL128).setScale(2, RoundingMode.HALF_UP);
BigDecimal totalLine = pU.multiply(qteU, DecimalUtils.HIGH_PRECISION).multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).setScale(2, RoundingMode.HALF_UP);
 
// BigDecimal lremise = (type == TypeCalcul.CALCUL_FACTURABLE ?
// rowVals.getBigDecimal("POURCENT_REMISE") : BigDecimal.ZERO);
180,7 → 180,7
// lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
// totalLine =
// totalLine.multiply(BigDecimal.valueOf(100).subtract(lremise),
// MathContext.DECIMAL128).movePointLeft(2);
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
// }
if (rowVals.getTable().getFieldsName().contains("MONTANT_REMISE")) {
final BigDecimal acomptePercent = rowVals.getBigDecimal("POURCENT_REMISE");
189,9 → 189,9
totalLine = remise.getResultFrom(totalLine);
}
 
BigDecimal percent = (totalHT.signum() != 0 ? totalLine.divide(totalHT, MathContext.DECIMAL128) : BigDecimal.ZERO);
BigDecimal percent = (totalHT.signum() != 0 ? totalLine.divide(totalHT, DecimalUtils.HIGH_PRECISION) : BigDecimal.ZERO);
 
model.putValue(a.getMontant().multiply(percent, MathContext.DECIMAL128).setScale(6, RoundingMode.HALF_UP), i, type.getFieldMontant());
model.putValue(a.getMontant().multiply(percent, DecimalUtils.HIGH_PRECISION).setScale(6, RoundingMode.HALF_UP), i, type.getFieldMontant());
tableElement.fireModification(model.getRowValuesAt(i));
}
}
332,7 → 332,18
// Prébilan
 
if (e.getTable().getFieldsName().contains("PREBILAN")) {
prebilan = new SQLTableElement(e.getTable().getField("PREBILAN"), BigDecimal.class);
prebilan = new SQLTableElement(e.getTable().getField("PREBILAN"), BigDecimal.class) {
protected Object getDefaultNullValue() {
return BigDecimal.ZERO;
}
 
@Override
public boolean isCellEditable(SQLRowValues vals) {
return isCellNiveauEditable(vals);
}
 
};
prebilan.setRenderer(new DeviseTableCellRenderer());
list.add(prebilan);
}
 
529,7 → 540,7
if (o2 != null && o3 != null) {
BigDecimal poids = (BigDecimal) o2;
int nb = (Integer) o3;
return poids.multiply(new BigDecimal(nb), MathContext.DECIMAL128).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
return poids.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
} else {
return row.getObject("T_POIDS_COLIS_NET");
}
614,7 → 625,7
BigDecimal percent = rowVals.getBigDecimal("POURCENT_REMISE");
BigDecimal amount = rowVals.getBigDecimal("MONTANT_REMISE");
Remise a = new Remise(percent, amount);
label.setText(a.toString());
label.setText(a.toPlainString());
return label;
}
});
653,7 → 664,17
// Marge HT
if (e.getTable().getFieldsName().contains("MARGE_HT")) {
 
final SQLTableElement marge = new SQLTableElement(e.getTable().getField("MARGE_HT"), BigDecimal.class);
final SQLTableElement marge = new SQLTableElement(e.getTable().getField("MARGE_HT"), BigDecimal.class) {
protected Object getDefaultNullValue() {
return BigDecimal.ZERO;
}
 
@Override
public boolean isCellEditable(SQLRowValues vals) {
return isCellNiveauEditable(vals);
}
 
};
marge.setRenderer(new DeviseTableCellRenderer());
marge.setEditable(false);
list.add(marge);
682,8 → 703,12
 
if (e.getTable().getFieldsName().contains("MARGE_PREBILAN_HT")) {
 
final SQLTableElement marge = new SQLTableElement(e.getTable().getField("MARGE_PREBILAN_HT"), Long.class, new DeviseCellEditor());
marge.setRenderer(new MargeTableCellRenderer());
final SQLTableElement marge = new SQLTableElement(e.getTable().getField("MARGE_PREBILAN_HT"), BigDecimal.class) {
protected Object getDefaultNullValue() {
return BigDecimal.ZERO;
}
};
marge.setRenderer(new DeviseTableCellRenderer());
marge.setEditable(false);
list.add(marge);
this.totalHT.addModificationListener(marge);
880,9 → 905,9
int qte = (row.getObject("QTE") == null) ? 0 : Integer.parseInt(row.getObject("QTE").toString());
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal f = (BigDecimal) row.getObject("PV_HT");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), MathContext.DECIMAL128), MathContext.DECIMAL128);
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION);
if (lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
r = r.multiply(BigDecimal.valueOf(100).subtract(lremise), MathContext.DECIMAL128).movePointLeft(2);
r = r.multiply(BigDecimal.valueOf(100).subtract(lremise), DecimalUtils.HIGH_PRECISION).movePointLeft(2);
}
 
if (row.getTable().getFieldsName().contains("MONTANT_REMISE")) {
908,7 → 933,7
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal f = (BigDecimal) row.getObject("PA_HT");
BigDecimal r = b.multiply(new BigDecimal(qte), MathContext.DECIMAL128).multiply(f, MathContext.DECIMAL128).setScale(6, BigDecimal.ROUND_HALF_UP);
BigDecimal r = b.multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).multiply(f, DecimalUtils.HIGH_PRECISION).setScale(6, BigDecimal.ROUND_HALF_UP);
return r.setScale(totalHA.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
}
 
932,7 → 957,7
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal f = (BigDecimal) row.getObject("PV_U_DEVISE");
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), MathContext.DECIMAL128);
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), DecimalUtils.HIGH_PRECISION);
 
if (row.getTable().getFieldsName().contains("MONTANT_REMISE")) {
final BigDecimal acomptePercent = row.getBigDecimal("POURCENT_REMISE");
944,7 → 969,7
// if (lremise.compareTo(BigDecimal.ZERO) > 0 &&
// lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
// r = r.multiply(BigDecimal.valueOf(100).subtract(lremise),
// MathContext.DECIMAL128).movePointLeft(2);
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
// }
return r.setScale(tableElementTotalDevise.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
}
972,7 → 997,7
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
editorPVHT.setTaxe(taux);
 
BigDecimal r = ht.multiply(BigDecimal.valueOf(taux).movePointLeft(2).add(BigDecimal.ONE), MathContext.DECIMAL128);
BigDecimal r = ht.multiply(BigDecimal.valueOf(taux).movePointLeft(2).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION);
final BigDecimal resultTTC = r.setScale(tableElementTotalTTC.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
 
return resultTTC;
1036,8 → 1061,8
BigDecimal t = (BigDecimal) row.getForeign("ID_DEVISE").getObject("TAUX");
BigDecimal bigDecimal = (BigDecimal) row.getObject("PV_U_DEVISE");
 
BigDecimal result = (t.equals(BigDecimal.ZERO) ? row.getBigDecimal("PRIX_METRIQUE_VT_1") : bigDecimal.divide(t));
result = tauxConversionLocale.multiply(result, MathContext.DECIMAL128);
BigDecimal result = (t.equals(BigDecimal.ZERO) ? row.getBigDecimal("PRIX_METRIQUE_VT_1") : bigDecimal.divide(t, DecimalUtils.HIGH_PRECISION));
result = tauxConversionLocale.multiply(result, DecimalUtils.HIGH_PRECISION);
return result;
}
return row.getObject("PRIX_METRIQUE_VT_1");
1157,7 → 1182,7
} else if ((field.equalsIgnoreCase("PV_U_DEVISE"))) {
BigDecimal t = (BigDecimal) getTarif().getForeign("ID_DEVISE").getObject("TAUX");
 
BigDecimal result = row.getBigDecimal("PRIX_METRIQUE_VT_1").divide(tauxConversionLocale, MathContext.DECIMAL128);
BigDecimal result = row.getBigDecimal("PRIX_METRIQUE_VT_1").divide(tauxConversionLocale, DecimalUtils.HIGH_PRECISION);
result = result.multiply(t);
return result.setScale(row.getTable().getField(field).getType().getDecimalDigits(), RoundingMode.HALF_UP);
 
1170,7 → 1195,7
return rowTarif.getObject(field);
else {
BigDecimal t = (BigDecimal) rowTarif.getForeign("ID_DEVISE").getObject("TAUX");
BigDecimal result = rowTarif.getBigDecimal(field).divide(t, MathContext.DECIMAL128);
BigDecimal result = rowTarif.getBigDecimal(field).divide(t, DecimalUtils.HIGH_PRECISION);
result = result.multiply(tauxConversionLocale);
return result.setScale(row.getTable().getField(field).getType().getDecimalDigits(), RoundingMode.HALF_UP);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseNumericHTConvertorCellEditor.java
15,6 → 15,7
 
import org.openconcerto.erp.config.Log;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.StringUtils;
 
import java.awt.event.ActionEvent;
21,7 → 22,6
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
 
import javax.swing.AbstractAction;
50,7 → 50,7
if (prixTTC != null) {
try {
BigDecimal taux = new BigDecimal(taxe).movePointLeft(2).add(BigDecimal.ONE);
BigDecimal divide = prixTTC.divide(taux, MathContext.DECIMAL128);
BigDecimal divide = prixTTC.divide(taux, DecimalUtils.HIGH_PRECISION);
divide = divide.setScale(precision, RoundingMode.HALF_UP);
textField.setText(divide.toString());
} catch (Exception ex) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/HistoriqueClientBilanPanel.java
43,10 → 43,12
private final JLabel labelEcheances = new JLabel();
private final JLabel labelRelances = new JLabel();
private final JLabel labelTotalVente = new JLabel();
private final JLabel labelTotalVentesArticle = new JLabel();
private long nbVentesCompoir;
private long totalVentesCompoir;
private long nbVentesFacture;
private long totalVentesFacture;
private long totalVentesArticle;
private long nbTotalCheques;
private long totalCheques;
private long nbChequesNonEncaisses;
81,6 → 83,8
add(this.labelRelances);
// Total vente
add(this.labelTotalVente);
// Toal article vente
add(this.labelTotalVentesArticle);
}
 
public synchronized void updateRelance(final List<Integer> listId) {
91,64 → 95,6
}
}
 
public synchronized void updateTotalVente(final int idClient) {
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
public void run() {
 
final SQLBase base = ((ComptaPropsConfiguration) ComptaPropsConfiguration.getInstance()).getSQLBaseSociete();
 
final SQLTable tableVF = base.getTable("SAISIE_VENTE_FACTURE");
final SQLTable tableVC = base.getTable("SAISIE_VENTE_COMPTOIR");
 
// Total VF
final SQLSelect selVF = new SQLSelect();
selVF.addSelect(tableVF.getField("T_HT"), "SUM");
 
if (idClient > 1) {
selVF.setWhere(tableVF.getField("ID_CLIENT"), "=", idClient);
}
final String req = selVF.asString();
// System.err.println(req);
final Object o = base.getDataSource().executeScalar(req);
final long totalVF = o == null ? 0 : ((Number) o).longValue();
 
// Total VC
final SQLSelect selVC = new SQLSelect();
selVC.addSelect(tableVC.getField("MONTANT_HT"), "SUM");
 
if (idClient > 1) {
selVC.setWhere(tableVC.getField("ID_CLIENT"), "=", idClient);
}
final String reqVC = selVC.asString();
// System.err.println(reqVC);
final Object oVC = base.getDataSource().executeScalar(reqVC);
final long totalVC = oVC == null ? 0 : ((Number) oVC).longValue();
 
final SQLSelect selAllVF = new SQLSelect();
selAllVF.addSelect(tableVF.getField("T_HT"), "SUM");
final Object o2 = base.getDataSource().executeScalar(selAllVF.asString());
final long totalAllVF = o2 == null ? 0 : ((Number) o2).longValue();
 
final SQLSelect selAllVC = new SQLSelect();
selAllVC.addSelect(tableVC.getField("MONTANT_HT"), "SUM");
final Object oVCA = base.getDataSource().executeScalar(selAllVC.asString());
final long totalAllVC = oVCA == null ? 0 : ((Number) oVCA).longValue();
 
if (totalAllVC + totalAllVF == 0) {
setPoucentageVentes(0);
} else {
final double pourCentage = (totalVF + totalVC) / (double) (totalAllVC + totalAllVF) * 100.0;
setPoucentageVentes((int) Math.round(pourCentage * 100.0) / 100);
}
updateLabels();
 
}
});
 
}
 
public synchronized void updateEcheance(final List<Integer> listId) {
 
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
291,6 → 237,31
});
}
 
public synchronized void updateVFArticleData(final List<Integer> listId, final int idClient) {
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
public void run() {
final SQLBase base = ((ComptaPropsConfiguration) ComptaPropsConfiguration.getInstance()).getSQLBaseSociete();
 
double valueTotal = 0;
if (listId != null && listId.size() > 0) {
final SQLSelect select = new SQLSelect();
final SQLTable tableElt = base.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
select.addSelect(tableElt.getField("T_PV_HT"), "SUM");
select.setWhere(new Where(tableElt.getKey(), listId));
final Number n = (Number) base.getDBSystemRoot().getDataSource().executeScalar(select.asString());
if (n != null) {
valueTotal = n.doubleValue();
}
}
 
setTotalVentesArticle(Math.round(valueTotal * 100.0D));
updateLabels();
}
});
}
 
private void addDatesToMap(final SQLBase base, final SQLSelect selDateFacture, final Map mapDateFact) {
final List<Object[]> lDateFact = (List<Object[]>) base.getDataSource().execute(selDateFacture.asString(), new ArrayListHandler());
 
382,6 → 353,10
this.totalVentesFacture = totalInCents;
}
 
public void setTotalVentesArticle(long totalVentesArticle) {
this.totalVentesArticle = totalVentesArticle;
}
 
// Cheques
public void setNbTotalCheques(final long nb) {
this.nbTotalCheques = nb;
522,7 → 497,16
} else {
HistoriqueClientBilanPanel.this.labelTotalVente.setText(" ventes de " + total + " € HT, soit " + HistoriqueClientBilanPanel.this.poucentageVentes + "% des ventes totales");
}
 
// % des ventes
 
total = GestionDevise.currencyToString(HistoriqueClientBilanPanel.this.totalVentesArticle, true);
if (HistoriqueClientBilanPanel.this.totalVentesArticle == 0) {
HistoriqueClientBilanPanel.this.labelTotalVentesArticle.setText(" Aucun article vendu");
} else {
HistoriqueClientBilanPanel.this.labelTotalVentesArticle.setText(total + "€ HT d'articles facturés");
}
}
});
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/HistoriqueClientFrame.java
99,10 → 99,18
SQLRowAccessor rowSel = HistoriqueClientFrame.this.listPanel.getSelectedRow();
int id = (rowSel == null) ? -1 : rowSel.getID();
bilanPanel.updateVFData(HistoriqueClientFrame.this.listPanel.getListId("SAISIE_VENTE_FACTURE"), id);
bilanPanel.updateTotalVente(id);
}
}, "SAISIE_VENTE_FACTURE");
 
this.listPanel.addListenerTable(new TableModelListener() {
public void tableChanged(TableModelEvent arg0) {
 
SQLRowAccessor rowSel = HistoriqueClientFrame.this.listPanel.getSelectedRow();
int id = (rowSel == null) ? -1 : rowSel.getID();
bilanPanel.updateVFArticleData(HistoriqueClientFrame.this.listPanel.getListId("SAISIE_VENTE_FACTURE_ELEMENT"), id);
}
}, "SAISIE_VENTE_FACTURE_ELEMENT");
 
this.panelFrame = new PanelFrame(this.listPanel, "Historique client");
this.panelFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/ListeHistoriquePanel.java
489,7 → 489,7
IListe liste = getIListeFromTableName(tableName);
int index = getIndexFromTableName(tableName);
if (liste != null) {
liste.getTableModel().addTableModelListener(listener);
liste.addListener(listener);
List<TableModelListener> l = this.mapListener.get(liste);
if (l == null) {
l = new ArrayList<TableModelListener>();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/stat/action/EvolutionCAAction.java
31,7 → 31,7
}
 
public JFrame createFrame() {
final PanelFrame panelFrame = new PanelFrame(new GraphCAPanel(), TITLE);
final PanelFrame panelFrame = new PanelFrame(new GraphCAPanel(false), TITLE);
panelFrame.setResizable(false);
return panelFrame;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/stat/action/EvolutionCmdAction.java
New file
0,0 → 1,38
/*
* 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.reports.stat.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.graph.GraphCmdPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class EvolutionCmdAction extends CreateFrameAbstractAction {
 
private static final String TITLE = "Evolution des commandes clients";
 
public EvolutionCmdAction() {
super();
this.putValue(Action.NAME, TITLE);
this.mustLoadState = false;
}
 
public JFrame createFrame() {
final PanelFrame panelFrame = new PanelFrame(new GraphCmdPanel(false), TITLE);
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/stat/action/EvolutionCACumulAction.java
New file
0,0 → 1,38
/*
* 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.reports.stat.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.graph.GraphCAPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class EvolutionCACumulAction extends CreateFrameAbstractAction {
 
private static final String TITLE = "Evolution du chiffre d'affaires cumulés";
 
public EvolutionCACumulAction() {
super();
this.putValue(Action.NAME, TITLE);
this.mustLoadState = false;
}
 
public JFrame createFrame() {
final PanelFrame panelFrame = new PanelFrame(new GraphCAPanel(true), TITLE);
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/stat/action/EvolutionCmdCumulAction.java
New file
0,0 → 1,38
/*
* 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.reports.stat.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.graph.GraphCmdPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class EvolutionCmdCumulAction extends CreateFrameAbstractAction {
 
private static final String TITLE = "Evolution des commandes clients cumulés";
 
public EvolutionCmdCumulAction() {
super();
this.putValue(Action.NAME, TITLE);
this.mustLoadState = false;
}
 
public JFrame createFrame() {
final PanelFrame panelFrame = new PanelFrame(new GraphCmdPanel(true), TITLE);
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/stat/action/VenteArticleFamilleGraphAction.java
New file
0,0 → 1,39
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.reports.stat.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.graph.ChoiceGraphFamillePanel;
import org.openconcerto.erp.graph.GraphArticleMargePanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class VenteArticleFamilleGraphAction extends CreateFrameAbstractAction {
 
private static final String TITLE = "CA par famille d'article";
 
public VenteArticleFamilleGraphAction() {
super();
this.putValue(Action.NAME, TITLE);
this.mustLoadState = false;
}
 
public JFrame createFrame() {
final PanelFrame panelFrame = new PanelFrame(new ChoiceGraphFamillePanel(), TITLE);
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/credit/component/AvoirFournisseurSQLComponent.java
130,7 → 130,7
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
this.add(addP, c);
 
c.gridy++;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/CommandeSQLComponent.java
21,7 → 21,6
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.supplychain.order.element.CommandeSQLElement;
import org.openconcerto.erp.core.supplychain.order.ui.CommandeItemTable;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.Type;
91,6 → 90,7
final JCheckBox boxLivrClient = new JCheckBox("Livrer directement le client");
private DefaultElementSQLObject compAdr;
final JPanel panelAdrSpec = new JPanel(new GridBagLayout());
protected ElementComboBox boxAdr;
 
public CommandeSQLComponent() {
super(Configuration.getInstance().getDirectory().getElement("COMMANDE"));
194,6 → 194,19
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
 
this.boxAdr = new ElementComboBox();
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
boxAdr.init(adrElement);
c.gridwidth = 1;
final JLabel labelAdrLiv = new JLabel("Adresse de livraison existante");
this.add(labelAdrLiv, c);
c.gridx++;
c.gridwidth = 2;
this.add(boxAdr, c);
 
c.gridx = 0;
c.gridy++;
this.add(new JLabel(getLabelFor("ID_ADRESSE")), c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
201,7 → 214,6
this.addView("ID_ADRESSE");
final DefaultElementSQLObject comp = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();
 
if (getTable().getFieldsName().contains("LIVRAISON_F")) {
final JCheckBox boxLivr = new JCheckBox("Livré par le fournisseur");
this.add(boxLivr, c);
this.addSQLObject(boxLivr, "LIVRAISON_F");
213,11 → 225,32
comp.setCreated(true);
if (CommandeSQLComponent.this.getTable().contains("ID_AFFAIRE")) {
 
SQLRowValues rowVals = getLivraisonAdr(((ElementComboBox) CommandeSQLComponent.this.getView("ID_AFFAIRE").getComp()).getSelectedRow());
final SQLRow selectedRow = ((ElementComboBox) CommandeSQLComponent.this.getView("ID_AFFAIRE").getComp()).getSelectedRow();
SQLRowValues rowVals = getLivraisonAdr(selectedRow);
 
comp.setValue(rowVals);
 
if (selectedRow != null && !selectedRow.isUndefined()) {
final SQLRow clientRow = selectedRow.getForeign("ID_CLIENT");
Where w = new Where(boxAdr.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", clientRow.getID());
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE")));
// w = w.or(new
// Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
// clientRow.getInt("ID_ADRESSE_F")));
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE_L")));
if (clientRow.getTable().contains("ID_ADRESSE_L_2")) {
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE_L_2")));
}
if (clientRow.getTable().contains("ID_ADRESSE_L_3")) {
w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=", clientRow.getInt("ID_ADRESSE_L_3")));
}
boxAdr.getRequest().setWhere(w);
} else {
boxAdr.getRequest().setWhere(null);
}
 
}
 
} else {
if (!boxLivr.isSelected()) {
comp.setCreated(false);
225,11 → 258,35
}
}
});
}
 
c.gridy++;
this.add(comp, c);
this.add(this.getView("ID_ADRESSE").getComp(), c);
 
comp.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
boxAdr.setVisible(comp.isCreated());
labelAdrLiv.setVisible(comp.isCreated());
}
});
 
boxAdr.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
final SQLRow selectedRow = boxAdr.getSelectedRow();
if (selectedRow != null && !selectedRow.isUndefined()) {
SQLRowValues rowVals = selectedRow.asRowValues();
rowVals.clearPrimaryKeys();
comp.setValue(rowVals);
}
}
});
boxAdr.setVisible(false);
labelAdrLiv.setVisible(false);
 
} else {
 
c.gridy++;
438,7 → 495,7
addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
addSQLObject(this.infos, "INFOS");
 
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
 
// radioEtat.setValue(EtatDevisSQLElement.EN_ATTENTE);
// this.numeroUniqueDevis.addLabelWarningMouseListener(new MouseAdapter() {
668,11 → 725,11
sheet.showPrintAndExportAsynchronous(this.checkVisu.isSelected(), this.checkImpression.isSelected(), true);
 
// incrémentation du numéro auto
if (NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(CommandeSQLElement.class));
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()));
val++;
rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(CommandeSQLElement.class), new Integer(val));
rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()), new Integer(val));
 
try {
rowVals.update(2);
694,9 → 751,6
 
@Override
public void select(SQLRowAccessor r) {
if (r != null) {
this.numeroUniqueCommande.setIdSelected(r.getID());
}
if (!getTable().contains("LIVRAISON_F") && r != null && !r.isUndefined()) {
 
SQLRowAccessor adr = r.getForeign("ID_ADRESSE");
784,7 → 838,7
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
return getLibelleStock(rowOrigin, rowElt);
}
}, row, row.getReferentRows(getTable().getTable("COMMANDE_ELEMENT")), Type.REAL_RECEPT);
}, row, row.getReferentRows(getTable().getTable("COMMANDE_ELEMENT")), Type.VIRTUAL_RECEPT);
 
stockUpdater.update();
}
791,7 → 845,7
 
public void setDefaults() {
this.resetValue();
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
this.table.getModel().clearRows();
}
 
821,7 → 875,7
rowVals.put("T_DEVISE", Long.valueOf(0));
rowVals.put("T_TVA", Long.valueOf(0));
rowVals.put("T_TTC", Long.valueOf(0));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
 
if (getTable().contains("ID_TAXE_PORT")) {
rowVals.put("ID_TAXE_PORT", TaxeCache.getCache().getFirstTaxe().getID());
830,6 → 884,10
return rowVals;
}
 
public CommandeItemTable getRowValuesTablePanel() {
return this.table;
}
 
@Override
public RowValuesTable getRowValuesTable() {
return this.table.getRowValuesTable();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/CommandeSQLElement.java
128,9 → 128,10
}
 
@Override
protected void archive(SQLRow row, boolean cutLinks) throws SQLException {
// TODO Auto-generated method stub
super.archive(row, cutLinks);
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
 
for (SQLRow row : trees.getRows()) {
 
// Mise à jour des stocks
SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
SQLSelect sel = new SQLSelect();
148,5 → 149,7
}
}
}
super.archive(trees, cutLinks);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/component/BonReceptionSQLComponent.java
45,6 → 45,7
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
 
55,7 → 56,6
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.List;
422,14 → 422,6
}
 
@Override
public void select(SQLRowAccessor r) {
if (r != null) {
this.textNumeroUnique.setIdSelected(r.getID());
}
super.select(r);
}
 
@Override
public void update() {
 
if (!this.textNumeroUnique.checkValidation()) {
537,10 → 529,10
BigDecimal qteRecue = new BigDecimal(rowEltBon.getInt("QTE"));
BigDecimal prixHACmd = (BigDecimal) rowEltBon.getObject("PRIX_METRIQUE_HA_1");
if (qteRecue.compareTo(BigDecimal.ZERO) > 0 && prixHACmd != null) {
BigDecimal totalHARecue = qteRecue.multiply(prixHACmd, MathContext.DECIMAL128);
BigDecimal totalHAStock = qteStock.multiply(prixHA, MathContext.DECIMAL128);
BigDecimal totalHARecue = qteRecue.multiply(prixHACmd, DecimalUtils.HIGH_PRECISION);
BigDecimal totalHAStock = qteStock.multiply(prixHA, DecimalUtils.HIGH_PRECISION);
BigDecimal totalQte = qteRecue.add(qteStock);
BigDecimal prixHaPond = totalHARecue.add(totalHAStock).divide(totalQte, MathContext.DECIMAL128);
BigDecimal prixHaPond = totalHARecue.add(totalHAStock).divide(totalQte, DecimalUtils.HIGH_PRECISION);
SQLRowValues rowValsArticle = rowArticle.createEmptyUpdateRow();
rowValsArticle.put("PRIX_METRIQUE_HA_1", prixHaPond);
rowValsArticle.commit();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/element/BonReceptionSQLElement.java
20,6 → 20,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.Where;
36,7 → 37,6
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
 
public class BonReceptionSQLElement extends ComptaSQLConfElement {
 
public BonReceptionSQLElement() {
96,9 → 96,10
}
 
@Override
protected void archive(SQLRow row, boolean cutLinks) throws SQLException {
super.archive(row, cutLinks);
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
 
for (SQLRow row : trees.getRows()) {
 
// Mise à jour des stocks
SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
SQLSelect sel = new SQLSelect(eltMvtStock.getTable().getBase());
115,4 → 116,6
}
}
}
super.archive(trees, cutLinks);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/product/component/ArticleFournisseurSQLComponent.java
38,6 → 38,7
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
50,7 → 51,6
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.List;
143,12 → 143,12
 
if (DefaultNXProps.getInstance().getBooleanValue(TotalPanel.MARGE_MARQUE, false)) {
if (vt.compareTo(BigDecimal.ZERO) > 0) {
value = margeHT.divide(vt, MathContext.DECIMAL128).multiply(BigDecimal.valueOf(100), MathContext.DECIMAL128);
value = margeHT.divide(vt, DecimalUtils.HIGH_PRECISION).multiply(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION);
} else {
value = BigDecimal.ZERO;
}
} else {
value = margeHT.divide(ha, MathContext.DECIMAL128).multiply(BigDecimal.valueOf(100), MathContext.DECIMAL128);
value = margeHT.divide(ha, DecimalUtils.HIGH_PRECISION).multiply(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION);
}
 
if (value.compareTo(BigDecimal.ZERO) > 0) {
180,14 → 180,14
 
BigDecimal d = StringUtils.getBigDecimalFromUserText(this.textMarge.getText());
if (DefaultNXProps.getInstance().getBooleanValue(TotalPanel.MARGE_MARQUE, false)) {
final BigDecimal e = BigDecimal.ONE.subtract(d.divide(BigDecimal.valueOf(100), MathContext.DECIMAL128));
final BigDecimal e = BigDecimal.ONE.subtract(d.divide(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION));
if (e.signum() == 0) {
this.textPVHT.setText("0");
} else {
this.textPVHT.setText(ha.divide(e, MathContext.DECIMAL128).setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
this.textPVHT.setText(ha.divide(e, DecimalUtils.HIGH_PRECISION).setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
} else {
BigDecimal result = ha.multiply(d.divide(BigDecimal.valueOf(100), MathContext.DECIMAL128).add(BigDecimal.ONE));
BigDecimal result = ha.multiply(d.divide(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION).add(BigDecimal.ONE));
this.textPVHT.setText(result.setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
}
713,7 → 713,7
ha = BigDecimal.ZERO;
}
final BigDecimal taux = (BigDecimal) boxDevise.getSelectedRow().getObject("TAUX");
textPAHT.setText(taux.multiply(ha, MathContext.DECIMAL128).setScale(getTable().getField("PA_DEVISE").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
textPAHT.setText(taux.multiply(ha, DecimalUtils.HIGH_PRECISION).setScale(getTable().getField("PA_DEVISE").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
 
}
}
1091,7 → 1091,7
if (id > 1) {
Float resultTaux = TaxeCache.getCache().getTauxFromId(id);
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue() / 100.0F;
this.textPVHT.setText(ttc.divide(BigDecimal.valueOf(taux).add(BigDecimal.ONE), MathContext.DECIMAL128)
this.textPVHT.setText(ttc.divide(BigDecimal.valueOf(taux).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION)
.setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
}
1106,7 → 1106,7
if (id > 1) {
final Float resultTaux = TaxeCache.getCache().getTauxFromId(id);
final float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue() / 100.0F;
this.textPVTTC.setText(ht.multiply(BigDecimal.valueOf(taux).add(BigDecimal.ONE), MathContext.DECIMAL128)
this.textPVTTC.setText(ht.multiply(BigDecimal.valueOf(taux).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION)
.setScale(getTable().getField("PV_TTC").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/StockItem.java
13,11 → 13,18
package org.openconcerto.erp.core.supplychain.stock.element;
 
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.model.SQLInjector;
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.sql.model.Where;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.ListMap;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
 
82,6 → 89,37
this.virtualQty = virtual;
}
 
public void fillCommandeFournisseur(ListMap<SQLRow, SQLRowValues> cmd) {
 
DefaultProps props = DefaultNXProps.getInstance();
String stockMin = props.getStringProperty("ArticleStockMin");
Boolean bStockMin = !stockMin.equalsIgnoreCase("false");
boolean gestionStockMin = (bStockMin == null || bStockMin.booleanValue());
if (article.getTable().getFieldsName().contains("QTE_MIN") && gestionStockMin && article.getObject("QTE_MIN") != null && getRealQty() < article.getInt("QTE_MIN")) {
// final float qteShow = qteNvlle;
SQLInjector inj = SQLInjector.getInjector(article.getTable(), article.getTable().getTable("COMMANDE_ELEMENT"));
final SQLRow asRow = article.asRow();
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(asRow));
rowValsElt.put("ID_STYLE", 2);
final SQLRowAccessor unite = article.getForeign("ID_UNITE_VENTE");
final double qteElt = article.getInt("QTE_MIN") - getRealQty();
if (unite.isUndefined() || unite.getBoolean("A_LA_PIECE")) {
rowValsElt.put("QTE", Math.round(qteElt));
rowValsElt.put("QTE_UNITAIRE", BigDecimal.ONE);
} else {
rowValsElt.put("QTE", 1);
rowValsElt.put("QTE_UNITAIRE", new BigDecimal(qteElt));
}
rowValsElt.put("ID_TAXE", rowValsElt.getObject("ID_TAXE"));
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * qteElt);
rowValsElt.put("T_PA_HT", rowValsElt.getLong("PA_HT") * qteElt);
rowValsElt.put("T_PA_TTC", rowValsElt.getLong("T_PA_HT") * (rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0));
 
cmd.add(asRow.getForeignRow("ID_FOURNISSEUR"), rowValsElt);
}
 
}
 
/**
* Mise à jour des quantités de stocks. Stock Reel : inc/dec QTE_REEL, inc/dec
* QTE_LIV_ATTENTE/inc/dec QTE_RECEPT_ATTENTE Stock Th : inc/dec QTE_TH, inc/dec
119,6 → 157,7
this.realQty = qteNvlle;
 
} else {
// THEORIQUE
final double qteNvlle;
final double qteOrigin = this.virtualQty;
if (archive) {
165,6 → 204,13
return !this.article.isForeignEmpty("ID_STOCK");
}
 
public void clearStockValues() {
this.realQty = 0;
this.deliverQty = 0;
this.receiptQty = 0;
this.virtualQty = 0;
}
 
public String getUpdateRequest() {
final SQLTable stockTable = this.article.getTable().getForeignTable("ID_STOCK");
UpdateBuilder update = new UpdateBuilder(stockTable);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/StockItemsUpdater.java
14,6 → 14,7
package org.openconcerto.erp.core.supplychain.stock.element;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
21,16 → 22,20
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.RTInterruptedException;
import org.openconcerto.utils.cc.ITransformer;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
 
import org.apache.commons.dbutils.ResultSetHandler;
 
public class StockItemsUpdater {
85,6 → 90,8
// Mise à jour des stocks des articles non composés
List<StockItem> stockItems = fetch();
 
final ListMap<SQLRow, SQLRowValues> cmd = new ListMap<SQLRow, SQLRowValues>();
 
for (StockItem stockItem : stockItems) {
if (stockItem.isStockInit()) {
requests.add(stockItem.getUpdateRequest());
98,6 → 105,7
rowValsArt.put("ID_STOCK", rowVals);
rowValsArt.commit();
}
stockItem.fillCommandeFournisseur(cmd);
}
 
List<? extends ResultSetHandler> handlers = new ArrayList<ResultSetHandler>(requests.size());
113,8 → 121,26
comp.update();
}
 
// FIXME Créer une interface de saisie de commande article en dessous du seuil mini de stock
if (cmd.size() > 0) {
String msg = "Les articles suivants sont inférieurs au stock minimum : \n";
for (SQLRow row : cmd.keySet()) {
for (SQLRowValues rowVals : cmd.get(row)) {
msg += rowVals.getString("CODE") + " " + rowVals.getString("NOM") + "\n";
}
}
final String msgFinal = msg;
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
JOptionPane.showMessageDialog(null, msgFinal, "Alerte de stock minimum", JOptionPane.WARNING_MESSAGE);
}
});
}
 
}
 
/**
* Suppression des anciens mouvements
*
195,7 → 221,7
 
final int qte = item.getInt("QTE");
final BigDecimal qteUV = item.getBigDecimal("QTE_UNITAIRE");
double qteFinal = qteUV.multiply(new BigDecimal(qte), MathContext.DECIMAL128).doubleValue();
double qteFinal = qteUV.multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).doubleValue();
if (!this.type.isEntry()) {
qteFinal = -qteFinal;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/MouvementStockSQLElement.java
42,14 → 42,13
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
175,7 → 174,7
 
final int qte = rowElt.getInt("QTE");
final BigDecimal qteUV = rowElt.getBigDecimal("QTE_UNITAIRE");
double qteFinal = qteUV.multiply(new BigDecimal(qte), MathContext.DECIMAL128).doubleValue();
double qteFinal = qteUV.multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).doubleValue();
 
if (entry) {
rowVals.put("QTE", qteFinal);
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/PanelOOSQLComponent.java
40,6 → 40,7
 
private final JCheckBox checkImpression = new JCheckBox("Imprimer");
private final JCheckBox checkVisu = new JCheckBox("Visualiser");
private final JCheckBox checkAbo = new JCheckBox("Créer l'abonnement associé");
 
public PanelOOSQLComponent(final BaseSQLComponent comp) {
super(new GridBagLayout());
46,10 → 47,16
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridx = GridBagConstraints.RELATIVE;
this.setOpaque(false);
 
final SQLTable tableComp = comp.getElement().getTable();
if (tableComp.getName().equals("SAISIE_VENTE_FACTURE") && tableComp.getDBRoot().contains("ABONNEMENT")) {
this.add(this.checkAbo, c);
}
 
SQLPreferences prefs = SQLPreferences.getMemCached(((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete());
if (prefs.getBoolean(GenerationDocGlobalPreferencePanel.MULTIMOD, false)) {
 
if (comp.getElement().getTable().getFieldsName().contains("ID_MODELE")) {
if (tableComp.getFieldsName().contains("ID_MODELE")) {
String labelFor = comp.getLabelFor("ID_MODELE");
if (labelFor == null || labelFor.trim().length() == 0) {
labelFor = "Modéles";
64,7 → 71,7
@Override
public SQLSelect transformChecked(SQLSelect input) {
SQLTable table = Configuration.getInstance().getDirectory().getElement("TYPE_MODELE").getTable();
Where w = new Where(input.getAlias(table.getField("TABLE")), "=", comp.getElement().getTable().getName());
Where w = new Where(input.getAlias(table.getField("TABLE")), "=", tableComp.getName());
input.setWhere(w);
return input;
}
73,7 → 80,7
DefaultGridBagConstraints.lockMinimumSize(boxModele);
this.add(boxModele, c);
} else {
System.err.println("Impossible d'ajouter la combo pour le choix des modèles car le champ ID_MODELE n'est pas présent dans la table " + comp.getElement().getTable().getName());
System.err.println("Impossible d'ajouter la combo pour le choix des modèles car le champ ID_MODELE n'est pas présent dans la table " + tableComp.getName());
Thread.dumpStack();
}
}
81,6 → 88,10
this.add(this.checkVisu, c);
}
 
public JCheckBox getCheckAbo() {
return checkAbo;
}
 
public boolean isVisualisationSelected() {
return this.checkVisu.isSelected();
}
89,4 → 100,8
return this.checkImpression.isSelected();
}
 
public boolean isCheckAboSelected() {
return this.checkAbo.isSelected();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportPanel.java
21,8 → 21,10
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.ISpinnerIntegerModel;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Tuple2;
 
31,6 → 33,8
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.io.FileNotFoundException;
 
43,8 → 47,11
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeListener;
 
public class ExportPanel extends JPanel {
static enum ExportType {
92,6 → 99,9
private final JTextField textDestination = new JTextField();
private final ElementComboBox boxJournal = new ElementComboBox(true);
private final JCheckBox boxExport = new JCheckBox("Seulement les nouvelles ecritures");
private final JCheckBox boxReplaceLib = new JCheckBox("Remplacer le libellé par le nom du client");
private JSpinner spinNbChar = new JSpinner(new ISpinnerIntegerModel(0, 20, 0));
private JSpinner spinNbCharLimit = new JSpinner(new ISpinnerIntegerModel(0, 20, 0));
 
public ExportPanel() {
super(new GridBagLayout());
201,8 → 211,47
comboType.setSelectedIndex(0);
this.add(comboType, c);
 
final JPanel p = new JPanel(new GridBagLayout());
GridBagConstraints c2 = new DefaultGridBagConstraints();
c2.gridx = 0;
c2.weightx = 1;
c2.gridwidth = GridBagConstraints.REMAINDER;
c2.fill = GridBagConstraints.HORIZONTAL;
p.add(new TitledSeparator("Option export relation expert", true), c2);
 
c2.gridy++;
c2.gridx = 0;
c2.weightx = 0;
c2.gridwidth = 3;
c2.fill = GridBagConstraints.HORIZONTAL;
p.add(new JLabel("Formater les numéros de compte suivant le nombre de caractères suivants", SwingUtilities.RIGHT), c2);
c2.gridx += 3;
c2.weightx = 1;
c2.gridwidth = 1;
 
p.add(this.spinNbChar, c2);
 
c2.gridy++;
c2.gridx = 0;
c2.weightx = 0;
c2.gridwidth = 3;
c2.fill = GridBagConstraints.HORIZONTAL;
p.add(new JLabel("Limiter le nombre de caractéres des numéros compte à", SwingUtilities.RIGHT), c2);
c2.gridx += 3;
c2.weightx = 1;
c2.gridwidth = 1;
p.add(this.spinNbCharLimit, c2);
 
c.gridy++;
c.gridx = 0;
c.weightx = 1;
c.weighty = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(p, c);
 
c.gridy++;
c.weightx = 1;
c.gridx = 0;
c.gridwidth = 1;
final JPanel panelButton = new JPanel();
219,12 → 268,24
export((ExportType) comboType.getSelectedItem());
}
});
p.setVisible(false);
comboType.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
p.setVisible((ExportType) comboType.getSelectedItem() == ExportType.RelationExpert);
 
}
});
}
 
protected final void export(ExportType type) {
try {
final Tuple2<File, Number> res = type.createExport(ComptaPropsConfiguration.getInstanceCompta().getRootSociete()).export(this.fileChooser.getSelectedFile(), this.du.getDate(),
this.au.getDate(), this.boxJournal.getSelectedRow(), this.boxExport.isSelected());
final AbstractExport createExport = type.createExport(ComptaPropsConfiguration.getInstanceCompta().getRootSociete());
createExport.setNbCharCpt((Integer) this.spinNbChar.getValue());
createExport.setNbCharLimitCpt((Integer) this.spinNbCharLimit.getValue());
final Tuple2<File, Number> res = createExport.export(this.fileChooser.getSelectedFile(), this.du.getDate(), this.au.getDate(), this.boxJournal.getSelectedRow(),
this.boxExport.isSelected());
if (res.get1().intValue() == 0) {
JOptionPane.showMessageDialog(this, "Aucune écriture trouvée. La période est-elle correcte ?");
} else {
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/AbstractExport.java
32,7 → 32,7
import java.text.SimpleDateFormat;
import java.util.Date;
 
abstract class AbstractExport {
public abstract class AbstractExport {
 
static private final DateFormat FILE_DF = new SimpleDateFormat("yyyyMMdd");
static private final DateFormat UNIQUE_DF = new SimpleDateFormat("yyyyMMdd_HHmmss");
40,6 → 40,8
private final String type;
private final String extension;
private boolean used;
private int nbCharCpt = 0;
private int nbCharLimitCpt = 0;
 
protected AbstractExport(final DBRoot rootSociete, final String type, final String extension) {
this.rootSociete = rootSociete;
48,6 → 50,46
this.used = false;
}
 
public String getFormattedCompte(String s) {
String result = s;
if (s != null) {
 
if (this.nbCharCpt > 0 && s.trim().length() > 0) {
 
StringBuffer res = new StringBuffer(this.nbCharCpt);
 
for (int i = 0; i < Math.max(this.nbCharCpt, s.length()); i++) {
if (i < s.length()) {
res.append(s.charAt(i));
} else {
res.append("0");
}
}
result = res.toString();
}
if (this.nbCharLimitCpt > 0 && result.length() > this.nbCharLimitCpt) {
result = result.substring(0, this.nbCharLimitCpt);
}
}
return result;
}
 
public void setNbCharCpt(int nbCharCpt) {
this.nbCharCpt = nbCharCpt;
}
 
public void setNbCharLimitCpt(int nbCharLimitCpt) {
this.nbCharLimitCpt = nbCharLimitCpt;
}
 
public int getNbCharCpt() {
return nbCharCpt;
}
 
public int getNbCharLimitCpt() {
return nbCharLimitCpt;
}
 
protected final DBRoot getRootSociete() {
return this.rootSociete;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportRelationExpertPanel.java
91,7 → 91,7
line.append('\t');
// N° Cpt
final String cpt = tmp[2].toString().trim();
line.append(cpt);
line.append(getFormattedCompte(cpt));
line.append('\t');
 
// ?
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportFEC.java
166,9 → 166,9
line.add("");
}
// Montantdevise
addEmptyField(line);
addAmountField(line, ((Number) array[8]).longValue() + ((Number) array[9]).longValue());
// Idevise
addEmptyField(line);
line.add("EUR");
 
assert line.size() == fieldsCount;
for (int i = 0; i < fieldsCount; i++) {
/trunk/OpenConcerto/src/org/openconcerto/erp/model/MouseSheetXmlListeListener.java
367,13 → 367,19
if (this.generateIsVisible) {
l.add(new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent ev) {
List<SQLRowAccessor> l = IListe.get(ev).getSelectedRows();
 
if (l.size() == 1) {
createDocument(ev);
} else {
createDocuments(l);
}
}
}, this.generateHeader, "document.create") {
 
@Override
public boolean enabledFor(List<SQLRowAccessor> selection) {
return selection != null && selection.size() == 1;
return selection != null && selection.size() > 0;
}
 
});
382,6 → 388,17
return l;
}
 
private void createDocuments(List<SQLRowAccessor> selection) {
int a = JOptionPane.showConfirmDialog(null, "Voulez vous recréer l'ensemble des documents sélectionnés?", "Génération de documents", JOptionPane.YES_NO_OPTION);
if (a == JOptionPane.YES_OPTION) {
for (SQLRowAccessor sqlRowAccessor : selection) {
final AbstractSheetXml sheet = createAbstractSheet(sqlRowAccessor.getTable().getRow(sqlRowAccessor.getID()));
sheet.createDocumentAsynchronous();
sheet.showPrintAndExportAsynchronous(false, false, true);
}
}
}
 
private void createDocument(ActionEvent ev) {
final AbstractSheetXml sheet = createAbstractSheet(IListe.get(ev).fetchSelectedRow());
if (sheet.getGeneratedFile().exists()) {
/trunk/OpenConcerto/src/org/openconcerto/erp/utils/ConvertDevise.java
13,8 → 13,9
package org.openconcerto.erp.utils;
 
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
 
public class ConvertDevise {
34,7 → 35,7
int scale) {
 
BigDecimal tauxB = taxe.movePointLeft(2).add(BigDecimal.ONE);
BigDecimal result = ht.multiply(tauxB, MathContext.DECIMAL128)
BigDecimal result = ht.multiply(tauxB, DecimalUtils.HIGH_PRECISION)
.setScale(scale, RoundingMode.HALF_UP);
return result;
 
58,7 → 59,7
}
 
BigDecimal tauxB = taxe.movePointLeft(2).add(BigDecimal.ONE);
BigDecimal result = ttc.divide(tauxB, MathContext.DECIMAL128).setScale(
BigDecimal result = ttc.divide(tauxB, DecimalUtils.HIGH_PRECISION).setScale(
scale, RoundingMode.HALF_UP);
return result;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/CADataModel.java
33,8 → 33,9
private int year;
private int total;
 
public CADataModel(final VerticalBarChart chart, final int year) {
loadYear(year);
public CADataModel(final VerticalBarChart chart, final int year, boolean cumul) {
 
loadYear(year, cumul);
}
 
@Override
42,7 → 43,7
return 12;
}
 
public synchronized void loadYear(Object value) {
public synchronized void loadYear(Object value, final boolean cumul) {
if (!(value instanceof Number)) {
return;
}
100,7 → 101,7
final int value = Math.round(vCA / 100);
total += value;
if (((int) value) != 0) {
CADataModel.this.setValueAt(i, value);
CADataModel.this.setValueAt(i, cumul ? total : value);
fireDataModelChanged();
Thread.sleep(20);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/CmdDataModel.java
New file
0,0 → 1,125
/*
* 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.graph;
 
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.RTInterruptedException;
 
import java.util.Calendar;
import java.util.Date;
 
import org.jopenchart.DataModel1D;
import org.jopenchart.barchart.VerticalBarChart;
 
public class CmdDataModel extends DataModel1D {
 
private Thread thread;
private int year;
private int total;
 
public CmdDataModel(final VerticalBarChart chart, final int year, boolean cumul) {
 
loadYear(year, cumul);
}
 
@Override
public int getSize() {
return 12;
}
 
public synchronized void loadYear(Object value, final boolean cumul) {
if (!(value instanceof Number)) {
return;
}
if (thread != null) {
thread.interrupt();
}
year = ((Number) value).intValue();
 
thread = new Thread() {
 
@Override
public void run() {
setState(LOADING);
// Clear
CmdDataModel.this.clear();
fireDataModelChanged();
SommeCompte sommeCompte = new SommeCompte();
total = 0;
try {
for (int i = 0; i < 12; i++) {
if (isInterrupted()) {
break;
}
Calendar c = Calendar.getInstance();
c.set(year, i, 1);
Date d1 = new Date(c.getTimeInMillis());
c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
Date d2 = new Date(c.getTimeInMillis());
Thread.yield();
double vCA = 0;
 
final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
SQLTable tableEcr = directory.getElement("COMMANDE_CLIENT").getTable();
SQLSelect sel = new SQLSelect();
sel.addSelect(tableEcr.getField("T_HT"), "SUM");
Where w = new Where(tableEcr.getField("DATE"), d1, d2);
sel.setWhere(w);
 
Object[] o = tableEcr.getBase().getDataSource().executeA1(sel.asString());
if (o != null && o[0] != null && (Long.valueOf(o[0].toString()) != 0)) {
long deb = Long.valueOf(o[0].toString());
vCA = deb;
}
 
final long value = Math.round(vCA / 100.0D);
total += value;
if (((int) value) != 0) {
CmdDataModel.this.setValueAt(i, cumul ? total : value);
fireDataModelChanged();
Thread.sleep(20);
}
 
}
if (!isInterrupted()) {
setState(LOADED);
fireDataModelChanged();
}
} catch (InterruptedException e) {
// Thread stopped because of year changed
} catch (RTInterruptedException e) {
// Thread stopped because of year changed
}
 
}
};
 
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
 
}
 
public int getYear() {
return year;
}
 
public int getTotal() {
return total;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/CAYearDataModel.java
New file
0,0 → 1,125
/*
* 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.graph;
 
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.RTInterruptedException;
 
import java.util.Calendar;
import java.util.Date;
 
import org.jopenchart.DataModel1D;
import org.jopenchart.barchart.VerticalBarChart;
 
public class CAYearDataModel extends DataModel1D {
 
private Thread thread;
private int year;
 
public CAYearDataModel(final int year) {
loadYear(year);
}
 
@Override
public int getSize() {
return 1;
}
 
public synchronized void loadYear(Object value) {
if (!(value instanceof Number)) {
return;
}
if (thread != null) {
thread.interrupt();
}
year = ((Number) value).intValue();
 
thread = new Thread() {
@Override
public void run() {
setState(LOADING);
// Clear
CAYearDataModel.this.clear();
fireDataModelChanged();
SommeCompte sommeCompte = new SommeCompte();
try {
 
Calendar c = Calendar.getInstance();
c.set(year, Calendar.JANUARY, 1);
Date d1 = new Date(c.getTimeInMillis());
c.set(Calendar.MONTH, Calendar.DECEMBER);
c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
Date d2 = new Date(c.getTimeInMillis());
Thread.yield();
float vCA = 0;
 
final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
SQLTable tableEcr = directory.getElement("ECRITURE").getTable();
SQLTable tableCpt = directory.getElement("COMPTE_PCE").getTable();
SQLSelect sel = new SQLSelect();
sel.addSelect(tableEcr.getField("DEBIT"), "SUM");
sel.addSelect(tableEcr.getField("CREDIT"), "SUM");
Where w = new Where(tableEcr.getField("DATE"), d1, d2);
Where w2 = new Where(tableEcr.getField("ID_COMPTE_PCE"), "=", tableCpt.getKey());
Where w3 = new Where(tableCpt.getField("NUMERO"), "LIKE", "70%");
Where w4 = new Where(tableEcr.getField("NOM"), "LIKE", "Fermeture%");
sel.setWhere(w.and(w2).and(w3).and(w4));
 
Object[] o = tableEcr.getBase().getDataSource().executeA1(sel.asString());
if (o != null && o[0] != null && o[1] != null && (Long.valueOf(o[0].toString()) != 0 || Long.valueOf(o[1].toString()) != 0)) {
long deb = Long.valueOf(o[0].toString());
long cred = Long.valueOf(o[1].toString());
long tot = deb - cred;
vCA = sommeCompte.soldeCompteDebiteur(700, 708, true, d1, d2) - sommeCompte.soldeCompteDebiteur(709, 709, true, d1, d2);
vCA = tot - vCA;
} else {
vCA = sommeCompte.soldeCompteCrediteur(700, 708, true, d1, d2) - sommeCompte.soldeCompteCrediteur(709, 709, true, d1, d2);
}
 
final float value = vCA / 100;
 
if (((int) value) != 0) {
CAYearDataModel.this.setValueAt(0, value);
fireDataModelChanged();
Thread.sleep(20);
}
 
if (!isInterrupted()) {
setState(LOADED);
fireDataModelChanged();
}
} catch (InterruptedException e) {
// Thread stopped because of year changed
} catch (RTInterruptedException e) {
// Thread stopped because of year changed
}
 
}
};
 
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
 
}
 
public int getYear() {
return year;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/CmdYearDataModel.java
New file
0,0 → 1,115
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.graph;
 
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.RTInterruptedException;
 
import java.util.Calendar;
import java.util.Date;
 
import org.jopenchart.DataModel1D;
import org.jopenchart.barchart.VerticalBarChart;
 
public class CmdYearDataModel extends DataModel1D {
 
private Thread thread;
private int year;
 
public CmdYearDataModel(final int year) {
loadYear(year);
}
 
@Override
public int getSize() {
return 1;
}
 
public synchronized void loadYear(Object value) {
if (!(value instanceof Number)) {
return;
}
if (thread != null) {
thread.interrupt();
}
year = ((Number) value).intValue();
 
thread = new Thread() {
@Override
public void run() {
setState(LOADING);
// Clear
CmdYearDataModel.this.clear();
fireDataModelChanged();
SommeCompte sommeCompte = new SommeCompte();
try {
 
Calendar c = Calendar.getInstance();
c.set(year, Calendar.JANUARY, 1);
Date d1 = new Date(c.getTimeInMillis());
c.set(Calendar.MONTH, Calendar.DECEMBER);
c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
Date d2 = new Date(c.getTimeInMillis());
Thread.yield();
double vCA = 0;
 
final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
SQLTable tableEcr = directory.getElement("COMMANDE_CLIENT").getTable();
SQLSelect sel = new SQLSelect();
sel.addSelect(tableEcr.getField("T_HT"), "SUM");
Where w = new Where(tableEcr.getField("DATE"), d1, d2);
sel.setWhere(w);
 
Object[] o = tableEcr.getBase().getDataSource().executeA1(sel.asString());
if (o != null && o[0] != null && (Long.valueOf(o[0].toString()) != 0)) {
long deb = Long.valueOf(o[0].toString());
 
vCA = deb;
}
final double value = vCA / 100.0D;
 
if (((int) value) != 0) {
CmdYearDataModel.this.setValueAt(0, value);
fireDataModelChanged();
Thread.sleep(20);
}
 
if (!isInterrupted()) {
setState(LOADED);
fireDataModelChanged();
}
} catch (InterruptedException e) {
// Thread stopped because of year changed
} catch (RTInterruptedException e) {
// Thread stopped because of year changed
}
 
}
};
 
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
 
}
 
public int getYear() {
return year;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/GraphFamilleArticlePanel.java
New file
0,0 → 1,170
/*
* 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.graph;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.DecimalUtils;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JPanel;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
import org.jopenchart.ChartPanel;
import org.jopenchart.Label;
import org.jopenchart.piechart.PieChart;
 
public class GraphFamilleArticlePanel extends JPanel {
 
private Date d1, d2;
public DecimalFormat decFormat = new DecimalFormat("##,##0.00#");
 
public GraphFamilleArticlePanel(Date d1, Date d2) {
this.d1 = d1;
this.d2 = d2;
List<String> labels = new ArrayList<String>();
List<Number> values = new ArrayList<Number>();
BigDecimal total = updateDataset(labels, values);
PieChart chart = new PieChart();
chart.setDimension(new Dimension(800, 360));
chart.setData(values);
for (String label : labels) {
chart.addLabel(new Label(label));
}
 
ChartPanel p = new ChartPanel(chart);
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(4, 6, 4, 4);
p.setOpaque(false);
this.setBackground(Color.WHITE);
this.add(p, c);
 
final JPanel p1 = new JPanel();
p1.setOpaque(false);
p1.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yy");
p1.add(new JLabelBold("Répartition du chiffre d'affaire du " + format.format(d1) + " au " + format.format(d2) + " pour un total de "
+ decFormat.format(total.setScale(2, RoundingMode.HALF_UP).doubleValue()) + "€"));
 
c.gridy++;
c.weighty = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(p1, c);
}
 
private Component createColorPanel(final Color color) {
final JPanel p = new JPanel();
p.setBorder(BorderFactory.createLineBorder(Color.WHITE));
p.setMinimumSize(new Dimension(40, 16));
p.setPreferredSize(new Dimension(40, 16));
p.setOpaque(true);
p.setBackground(color);
return p;
}
 
protected BigDecimal updateDataset(List<String> labels, List<Number> values) {
 
final SQLTable tableVFElement = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT").getTable();
final SQLTable tableVF = tableVFElement.getTable("SAISIE_VENTE_FACTURE");
final SQLTable tableArticle = tableVFElement.getTable("ARTICLE");
 
final SQLSelect sel = new SQLSelect();
final String field = "ID_FAMILLE_ARTICLE";
 
sel.addSelect(tableArticle.getField(field));
 
sel.addSelect(tableVFElement.getField("T_PA_HT"), "SUM");
sel.addSelect(tableVFElement.getField("T_PV_HT"), "SUM");
sel.addSelect(tableVFElement.getField("QTE"), "SUM");
 
Where w = new Where(tableVF.getKey(), "=", tableVFElement.getField("ID_SAISIE_VENTE_FACTURE"));
w = w.and(new Where(tableVF.getField("DATE"), this.d1, this.d2));
w = w.and(new Where(tableArticle.getKey(), "=", tableVFElement.getField("ID_ARTICLE")));
sel.setWhere(w);
 
final List<Object[]> rowsArticle = (List<Object[]>) Configuration.getInstance().getBase().getDataSource()
.execute(sel.asString() + " GROUP BY \"ARTICLE\".\"" + field + "\"", new ArrayListHandler());
 
Collections.sort(rowsArticle, new Comparator<Object[]>() {
@Override
public int compare(Object[] o1, Object[] o2) {
 
BigDecimal pa1 = (BigDecimal) o1[1];
BigDecimal pv1 = (BigDecimal) o1[2];
BigDecimal qte1 = new BigDecimal(o1[3].toString());
 
BigDecimal pa2 = (BigDecimal) o2[1];
BigDecimal pv2 = (BigDecimal) o2[2];
BigDecimal qte2 = new BigDecimal(o2[3].toString());
 
BigDecimal marge1 = pv1.subtract(pa1).multiply(qte1, DecimalUtils.HIGH_PRECISION);
BigDecimal marge2 = pv2.subtract(pa2).multiply(qte2, DecimalUtils.HIGH_PRECISION);
return pv1.compareTo(pv2);
}
});
 
SQLTable tableFamille = tableVFElement.getTable("FAMILLE_ARTICLE");
 
BigDecimal total = BigDecimal.ZERO;
for (int i = 0; i < rowsArticle.size(); i++) {
Object[] o = rowsArticle.get(i);
 
BigDecimal pv2 = (BigDecimal) o[2];
total = total.add(pv2);
}
if (total.signum() > 0) {
 
for (int i = 0; i < 12 && i < rowsArticle.size(); i++) {
Object[] o = rowsArticle.get(i);
BigDecimal pa2 = (BigDecimal) o[1];
BigDecimal pv2 = (BigDecimal) o[2];
BigDecimal qte2 = new BigDecimal(o[3].toString());
BigDecimal marge2 = pv2.subtract(pa2).multiply(qte2, DecimalUtils.HIGH_PRECISION);
 
String s = "Indéfini";
if (o[0] != null) {
int id = ((Number) o[0]).intValue();
s = tableFamille.getRow(id).getString("NOM");
}
values.add(pv2);
labels.add(s + "(" + decFormat.format(pv2.setScale(2, RoundingMode.HALF_UP).doubleValue()) + "€ soit "
+ pv2.divide(total, DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP) + "%)");
}
}
return total;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/GraphArticleMargePanel.java
16,9 → 16,9
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
61,8 → 61,8
BigDecimal pv2 = (BigDecimal) o2[2];
BigDecimal qte2 = new BigDecimal(o2[3].toString());
 
BigDecimal marge1 = pv1.subtract(pa1).multiply(qte1, MathContext.DECIMAL128);
BigDecimal marge2 = pv2.subtract(pa2).multiply(qte2, MathContext.DECIMAL128);
BigDecimal marge1 = pv1.subtract(pa1).multiply(qte1, DecimalUtils.HIGH_PRECISION);
BigDecimal marge2 = pv2.subtract(pa2).multiply(qte2, DecimalUtils.HIGH_PRECISION);
return marge1.compareTo(marge2);
}
});
72,7 → 72,7
BigDecimal pa2 = (BigDecimal) o[1];
BigDecimal pv2 = (BigDecimal) o[2];
BigDecimal qte2 = new BigDecimal(o[3].toString());
BigDecimal marge2 = pv2.subtract(pa2).multiply(qte2, MathContext.DECIMAL128);
BigDecimal marge2 = pv2.subtract(pa2).multiply(qte2, DecimalUtils.HIGH_PRECISION);
 
final String string = o[0].toString();
values.add(marge2);
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/MargeDayDataModel.java
18,11 → 18,11
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.NumberUtils;
import org.openconcerto.utils.RTInterruptedException;
 
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Calendar;
import java.util.Date;
106,7 → 106,7
chart.getLeftAxis().getLabels().get(2).setLabel(total.setScale(0, RoundingMode.HALF_UP).toString() + " €");
// currencyToString = GestionDevise.currencyToString(euros * 100 / 2,
// true);
chart.getLeftAxis().getLabels().get(1).setLabel(total.divide(new BigDecimal(2), MathContext.DECIMAL128).setScale(0, RoundingMode.HALF_UP) + " €");
chart.getLeftAxis().getLabels().get(1).setLabel(total.divide(new BigDecimal(2), DecimalUtils.HIGH_PRECISION).setScale(0, RoundingMode.HALF_UP) + " €");
chart.setHigherRange(total);
}
if (total.compareTo(BigDecimal.ZERO) != 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/GraphCAPanel.java
50,15 → 50,20
private CADataModel model1;
private CADataModel model2;
private CADataModel model3;
 
private CAYearDataModel modelYear1;
private CAYearDataModel modelYear2;
private CAYearDataModel modelYear3;
private final VerticalGroupBarChart chart = new VerticalGroupBarChart();
private JLabel title = new JLabelBold("-");
private final boolean cumul;
 
/**
* Chiffres d'affaires, affichés en barres
*/
public GraphCAPanel() {
public GraphCAPanel(boolean cumul) {
final int year = Calendar.getInstance().get(Calendar.YEAR);
 
this.cumul = cumul;
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(4, 6, 4, 4);
99,11 → 104,11
chart.setColors(colors);
chart.setDimension(new Dimension(800, 400));
// Models
model1 = new CADataModel(chart, year - 2);
model1 = new CADataModel(chart, year - 2, cumul);
chart.addModel(model1);
model2 = new CADataModel(chart, year - 1);
model2 = new CADataModel(chart, year - 1, cumul);
chart.addModel(model2);
model3 = new CADataModel(chart, year);
model3 = new CADataModel(chart, year, cumul);
chart.addModel(model3);
// Range
chart.setLowerRange(0);
126,7 → 131,12
};
panel.setBackground(Color.WHITE);
this.add(panel, c);
 
if (!this.cumul) {
c.gridx++;
this.add(createYearChartPanel(year), c);
}
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.weightx = 1;
c.weighty = 0;
164,11 → 174,75
updateTitle();
}
 
private ChartPanel createYearChartPanel(int year) {
List<Color> colors = new ArrayList<Color>();
colors.add(Color.decode("#4A79A5"));
colors.add(Color.decode("#639ACE"));
colors.add(Color.decode("#94BAE7"));
 
final Axis axisY = new Axis("y");
axisY.addLabel(new AxisLabel("0"));
axisY.addLabel(new AxisLabel("500 €"));
axisY.addLabel(new AxisLabel("1000 €"));
 
final Axis axisX = new Axis("x");
axisX.addLabel(new AxisLabel("Total", 1));
 
final VerticalGroupBarChart chartYear = new VerticalGroupBarChart();
chartYear.setBottomAxis(axisX);
chartYear.setLeftAxis(axisY);
chartYear.setBarWidth(14);
chartYear.setColors(colors);
chartYear.setDimension(new Dimension(150, 400));
// Models
modelYear1 = new CAYearDataModel(year - 2);
chartYear.addModel(modelYear1);
modelYear2 = new CAYearDataModel(year - 1);
chartYear.addModel(modelYear2);
modelYear3 = new CAYearDataModel(year);
chartYear.addModel(modelYear3);
// Range
chartYear.setLowerRange(0);
chartYear.setHigherRange(1000);
 
modelYear1.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(chartYear, modelYear1.getMaxValue().floatValue());
}
});
modelYear2.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(chartYear, modelYear2.getMaxValue().floatValue());
}
});
modelYear3.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(chartYear, modelYear3.getMaxValue().floatValue());
}
});
 
final ChartPanel panel = new ChartPanel(chartYear) {
@Override
public String getToolTipTextFrom(Number n) {
if (n == null) {
return null;
}
CAYearDataModel m = (CAYearDataModel) chartYear.getHighlight().getModel();
return axisX.getLabels().get(chartYear.getHighlight().getIndexOnModel()).getLabel() + " " + m.getYear() + ": " + n.longValue() + " €";
}
};
panel.setOpaque(false);
return panel;
}
 
private void addLeftAxisUpdater(final CADataModel model) {
model.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(model.getMaxValue().floatValue());
updateLeftAxis(chart, model.getMaxValue().floatValue());
}
});
}
194,11 → 268,17
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == s1) {
model1.loadYear(s1.getValue());
model1.loadYear(s1.getValue(), this.cumul);
if (!this.cumul)
modelYear1.loadYear(s1.getValue());
} else if (e.getSource() == s2) {
model2.loadYear(s2.getValue());
model2.loadYear(s2.getValue(), this.cumul);
if (!this.cumul)
modelYear2.loadYear(s2.getValue());
} else if (e.getSource() == s3) {
model3.loadYear(s3.getValue());
model3.loadYear(s3.getValue(), this.cumul);
if (!this.cumul)
modelYear3.loadYear(s3.getValue());
}
 
}
210,7 → 290,7
return h;
}
 
public void updateLeftAxis(final float maxValue) {
public void updateLeftAxis(final VerticalGroupBarChart chartGroup, final float maxValue) {
if (maxValue >= getHigherValue()) {
SwingUtilities.invokeLater(new Runnable() {
 
217,12 → 297,12
@Override
public void run() {
long euros = (long) maxValue;
chart.getLeftAxis().removeAllLabels();
chartGroup.getLeftAxis().removeAllLabels();
String currencyToString = GestionDevise.currencyToString(euros * 100, true);
chart.getLeftAxis().addLabel(new AxisLabel(currencyToString.substring(0, currencyToString.length() - 3) + " €", euros));
chartGroup.getLeftAxis().addLabel(new AxisLabel(currencyToString.substring(0, currencyToString.length() - 3) + " €", euros));
currencyToString = GestionDevise.currencyToString(euros * 100 / 2, true);
chart.getLeftAxis().addLabel(new AxisLabel(currencyToString.substring(0, currencyToString.length() - 3) + " €", euros / 2));
chart.setHigherRange(maxValue);
chartGroup.getLeftAxis().addLabel(new AxisLabel(currencyToString.substring(0, currencyToString.length() - 3) + " €", euros / 2));
chartGroup.setHigherRange(maxValue);
}
});
 
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/GraphCmdPanel.java
New file
0,0 → 1,332
/*
* 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.graph;
 
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.GestionDevise;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
 
import org.jopenchart.Axis;
import org.jopenchart.AxisLabel;
import org.jopenchart.ChartPanel;
import org.jopenchart.DataModelListener;
import org.jopenchart.barchart.VerticalGroupBarChart;
 
public class GraphCmdPanel extends JPanel implements ChangeListener, DataModelListener {
private final JSpinner s1 = new JSpinner();
private final JSpinner s2 = new JSpinner();
private final JSpinner s3 = new JSpinner();
private CmdDataModel model1;
private CmdDataModel model2;
private CmdDataModel model3;
 
private CmdYearDataModel modelYear1;
private CmdYearDataModel modelYear2;
private CmdYearDataModel modelYear3;
private final VerticalGroupBarChart chart = new VerticalGroupBarChart();
private JLabel title = new JLabelBold("-");
private final boolean cumul;
 
/**
* Chiffres d'affaires, affichés en barres
*/
public GraphCmdPanel(boolean cumul) {
final int year = Calendar.getInstance().get(Calendar.YEAR);
this.cumul = cumul;
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(4, 6, 4, 4);
this.setBackground(Color.WHITE);
title.setOpaque(false);
this.add(title, c);
c.gridy++;
 
c.insets = new Insets(0, 0, 0, 0);
 
List<Color> colors = new ArrayList<Color>();
colors.add(Color.decode("#4A79A5"));
colors.add(Color.decode("#639ACE"));
colors.add(Color.decode("#94BAE7"));
 
final Axis axisY = new Axis("y");
axisY.addLabel(new AxisLabel("0"));
axisY.addLabel(new AxisLabel("500 €"));
axisY.addLabel(new AxisLabel("1000 €"));
 
final Axis axisX = new Axis("x");
axisX.addLabel(new AxisLabel("Janvier", 1));
axisX.addLabel(new AxisLabel("Février", 2));
axisX.addLabel(new AxisLabel("Mars", 3));
axisX.addLabel(new AxisLabel("Avril", 4));
axisX.addLabel(new AxisLabel("Mai", 5));
axisX.addLabel(new AxisLabel("Juin", 6));
axisX.addLabel(new AxisLabel("Juillet", 7));
axisX.addLabel(new AxisLabel("Août", 8));
axisX.addLabel(new AxisLabel("Septembre", 9));
axisX.addLabel(new AxisLabel("Octobre", 10));
axisX.addLabel(new AxisLabel("Novembre", 11));
axisX.addLabel(new AxisLabel("Décembre", 12));
 
chart.setBottomAxis(axisX);
chart.setLeftAxis(axisY);
chart.setBarWidth(14);
chart.setColors(colors);
chart.setDimension(new Dimension(800, 400));
// Models
model1 = new CmdDataModel(chart, year - 2, cumul);
chart.addModel(model1);
model2 = new CmdDataModel(chart, year - 1, cumul);
chart.addModel(model2);
model3 = new CmdDataModel(chart, year, cumul);
chart.addModel(model3);
// Range
chart.setLowerRange(0);
chart.setHigherRange(1000);
c.gridy++;
 
addLeftAxisUpdater(model1);
addLeftAxisUpdater(model2);
addLeftAxisUpdater(model3);
 
final ChartPanel panel = new ChartPanel(chart) {
@Override
public String getToolTipTextFrom(Number n) {
if (n == null) {
return null;
}
CmdDataModel m = (CmdDataModel) chart.getHighlight().getModel();
return axisX.getLabels().get(chart.getHighlight().getIndexOnModel()).getLabel() + " " + m.getYear() + ": " + n.longValue() + " €";
}
};
panel.setBackground(Color.WHITE);
this.add(panel, c);
if (!this.cumul) {
c.gridx++;
this.add(createYearChartPanel(year), c);
}
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.BOTH;
this.add(new JSeparator(JSeparator.HORIZONTAL), c);
 
// Spinners
s1.setValue(year - 2);
s2.setValue(year - 1);
s3.setValue(year);
 
final JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
p1.add(new JLabel("Années: "));
p1.add(createColorPanel(colors.get(0)));
p1.add(s1);
p1.add(createSpacer());
p1.add(createColorPanel(colors.get(1)));
p1.add(s2);
p1.add(createSpacer());
p1.add(createColorPanel(colors.get(2)));
p1.add(s3);
c.gridy++;
c.weighty = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(p1, c);
s1.addChangeListener(this);
s2.addChangeListener(this);
s3.addChangeListener(this);
 
model1.addDataModelListener(this);
model2.addDataModelListener(this);
model3.addDataModelListener(this);
updateTitle();
}
 
private ChartPanel createYearChartPanel(int year) {
List<Color> colors = new ArrayList<Color>();
colors.add(Color.decode("#4A79A5"));
colors.add(Color.decode("#639ACE"));
colors.add(Color.decode("#94BAE7"));
 
final Axis axisY = new Axis("y");
axisY.addLabel(new AxisLabel("0"));
axisY.addLabel(new AxisLabel("500 €"));
axisY.addLabel(new AxisLabel("1000 €"));
 
final Axis axisX = new Axis("x");
axisX.addLabel(new AxisLabel("Total", 1));
 
final VerticalGroupBarChart chartYear = new VerticalGroupBarChart();
chartYear.setBottomAxis(axisX);
chartYear.setLeftAxis(axisY);
chartYear.setBarWidth(14);
chartYear.setColors(colors);
chartYear.setDimension(new Dimension(150, 400));
// Models
modelYear1 = new CmdYearDataModel(year - 2);
chartYear.addModel(modelYear1);
modelYear2 = new CmdYearDataModel(year - 1);
chartYear.addModel(modelYear2);
modelYear3 = new CmdYearDataModel(year);
chartYear.addModel(modelYear3);
// Range
chartYear.setLowerRange(0);
chartYear.setHigherRange(1000);
 
modelYear1.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(chartYear, modelYear1.getMaxValue().floatValue());
}
});
modelYear2.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(chartYear, modelYear2.getMaxValue().floatValue());
}
});
modelYear3.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(chartYear, modelYear3.getMaxValue().floatValue());
}
});
 
final ChartPanel panel = new ChartPanel(chartYear) {
@Override
public String getToolTipTextFrom(Number n) {
if (n == null) {
return null;
}
CmdYearDataModel m = (CmdYearDataModel) chartYear.getHighlight().getModel();
return axisX.getLabels().get(chartYear.getHighlight().getIndexOnModel()).getLabel() + " " + m.getYear() + ": " + n.longValue() + " €";
}
};
panel.setOpaque(false);
return panel;
}
 
private void addLeftAxisUpdater(final CmdDataModel model) {
model.addDataModelListener(new DataModelListener() {
@Override
public void dataChanged() {
updateLeftAxis(chart, model.getMaxValue().floatValue());
}
});
}
 
private Component createColorPanel(final Color color) {
final JPanel p = new JPanel();
p.setBorder(BorderFactory.createLineBorder(Color.WHITE));
p.setMinimumSize(new Dimension(40, 16));
p.setPreferredSize(new Dimension(40, 16));
p.setOpaque(true);
p.setBackground(color);
return p;
}
 
private Component createSpacer() {
final JPanel p = new JPanel();
p.setMinimumSize(new Dimension(16, 16));
p.setPreferredSize(new Dimension(16, 16));
p.setOpaque(false);
return p;
}
 
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == s1) {
model1.loadYear(s1.getValue(), this.cumul);
if (!this.cumul)
modelYear1.loadYear(s1.getValue());
} else if (e.getSource() == s2) {
model2.loadYear(s2.getValue(), this.cumul);
if (!this.cumul)
modelYear2.loadYear(s2.getValue());
} else if (e.getSource() == s3) {
model3.loadYear(s3.getValue(), this.cumul);
if (!this.cumul)
modelYear3.loadYear(s3.getValue());
}
 
}
 
public float getHigherValue() {
float h = model1.getMaxValue().floatValue();
h = Math.max(h, model2.getMaxValue().floatValue());
h = Math.max(h, model3.getMaxValue().floatValue());
return h;
}
 
public void updateLeftAxis(final VerticalGroupBarChart chartGroup, final float maxValue) {
if (maxValue >= getHigherValue()) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
long euros = (long) maxValue;
chartGroup.getLeftAxis().removeAllLabels();
String currencyToString = GestionDevise.currencyToString(euros * 100, true);
chartGroup.getLeftAxis().addLabel(new AxisLabel(currencyToString.substring(0, currencyToString.length() - 3) + " €", euros));
currencyToString = GestionDevise.currencyToString(euros * 100 / 2, true);
chartGroup.getLeftAxis().addLabel(new AxisLabel(currencyToString.substring(0, currencyToString.length() - 3) + " €", euros / 2));
chartGroup.setHigherRange(maxValue);
}
});
 
}
}
 
@Override
public void dataChanged() {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
updateTitle();
 
}
});
 
}
 
protected void updateTitle() {
String s = " ";
s += this.s1.getValue().toString() + " : " + this.model1.getTotal() + " € ";
s += this.s2.getValue().toString() + " : " + this.model2.getTotal() + " € ";
s += this.s3.getValue().toString() + " : " + this.model3.getTotal() + " €";
this.title.setText(s);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/ChoiceGraphFamillePanel.java
New file
0,0 → 1,90
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
/*
* Créé le 23 avr. 2012
*/
package org.openconcerto.erp.graph;
 
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
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.concurrent.ExecutionException;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
public class ChoiceGraphFamillePanel extends JPanel {
 
public ChoiceGraphFamillePanel() {
super(new GridBagLayout());
 
JLabel labelCom = new JLabel("Afficher le graphique pour la période du");
GridBagConstraints c = new DefaultGridBagConstraints();
this.add(labelCom, c);
c.gridx++;
final JDate d1 = new JDate();
this.add(d1, c);
c.gridx++;
JLabel labelYear = new JLabel("au");
final JDate date2 = new JDate();
 
this.add(labelYear, c);
c.gridx++;
this.add(date2, c);
 
final JButton buttonValid = new JButton(new AbstractAction("Valider") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
GraphFamilleArticlePanel p = new GraphFamilleArticlePanel(d1.getDate(), date2.getDate());
FrameUtil.show(new PanelFrame(p, "Répartition du CA par famille"));
 
}
 
});
c.gridx++;
this.add(buttonValid, c);
 
buttonValid.setEnabled(false);
d1.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonValid.setEnabled(d1.getDate() != null && date2.getDate() != null);
}
});
date2.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonValid.setEnabled(d1.getDate() != null && date2.getDate() != null);
}
});
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/graph/MargeDataModel.java
104,7 → 104,7
// true);
chart.getLeftAxis().getLabels().get(2).setLabel(total.setScale(0, RoundingMode.HALF_UP).toString() + " €");
 
chart.getLeftAxis().getLabels().get(1).setLabel(total.divide(new BigDecimal(2), MathContext.DECIMAL128).setScale(0, RoundingMode.HALF_UP) + " €");
chart.getLeftAxis().getLabels().get(1).setLabel(total.divide(new BigDecimal(2), DecimalUtils.HIGH_PRECISION).setScale(0, RoundingMode.HALF_UP) + " €");
chart.setHigherRange(value);
}
if (((int) value) != 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/config/fieldmapping.xml
25,6 → 25,10
<field id="sales.quote.address.alternative" name="ID_ADRESSE" />
<field id="sales.quote.info.general" name="INFOS" />
<field id="sales.quote.state" name="ID_ETAT_DEVIS"/>
<field id="sales.quote.validity" name="DATE_VALIDITE" />
<field id="sales.quote.customer.contact" name="ID_CONTACT" />
<field id="sales.quote.customer.tarif" name="ID_TARIF" />
<field id="sales.quote.customer.discount" name="MONTANT_REMISE,POURCENT_REMISE" />
</table>
<table id="sales.quote.item" name="DEVIS_ELEMENT">
<field id="sales.quote.item.quote" name="ID_DEVIS"/>
/trunk/OpenConcerto/src/org/openconcerto/erp/config/ComptaPropsConfiguration.java
100,6 → 100,8
import org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.VariableSalarieSQLElement;
import org.openconcerto.erp.core.humanresources.timesheet.element.PointageSQLElement;
import org.openconcerto.erp.core.project.element.CalendarItemGroupSQLElement;
import org.openconcerto.erp.core.project.element.CalendarItemSQLElement;
import org.openconcerto.erp.core.sales.credit.element.AvoirClientElementSQLElement;
import org.openconcerto.erp.core.sales.credit.element.AvoirClientSQLElement;
import org.openconcerto.erp.core.sales.invoice.element.EcheanceClientSQLElement;
164,6 → 166,7
import org.openconcerto.erp.generationDoc.provider.PrixUnitaireRemiseProvider;
import org.openconcerto.erp.generationDoc.provider.QteTotalProvider;
import org.openconcerto.erp.generationDoc.provider.RefClientValueProvider;
import org.openconcerto.erp.generationDoc.provider.RemiseProvider;
import org.openconcerto.erp.generationDoc.provider.TotalAcompteProvider;
import org.openconcerto.erp.generationDoc.provider.TotalCommandeClientProvider;
import org.openconcerto.erp.generationDoc.provider.UserCreateInitialsValueProvider;
466,6 → 469,7
FormatedGlobalQtyTotalProvider.register();
MergedGlobalQtyTotalProvider.register();
PaiementRemainedProvider.register();
RemiseProvider.register();
}
 
@Override
836,6 → 840,9
dir.addSQLElement(new VariableSalarieSQLElement());
dir.addSQLElement(UniteVenteArticleSQLElement.class);
 
dir.addSQLElement(CalendarItemSQLElement.class);
dir.addSQLElement(CalendarItemGroupSQLElement.class);
 
// check that all codes are unique
Collection<SQLElement> elements = dir.getElements();
String s = "";
/trunk/OpenConcerto/src/org/openconcerto/erp/config/DefaultMenuConfiguration.java
72,7 → 72,11
import org.openconcerto.erp.core.humanresources.payroll.action.NouvelHistoriqueFichePayeAction;
import org.openconcerto.erp.core.humanresources.payroll.action.NouvelleSaisieKmAction;
import org.openconcerto.erp.core.reports.stat.action.EvolutionCAAction;
import org.openconcerto.erp.core.reports.stat.action.EvolutionCACumulAction;
import org.openconcerto.erp.core.reports.stat.action.EvolutionCmdAction;
import org.openconcerto.erp.core.reports.stat.action.EvolutionCmdCumulAction;
import org.openconcerto.erp.core.reports.stat.action.EvolutionMargeAction;
import org.openconcerto.erp.core.reports.stat.action.VenteArticleFamilleGraphAction;
import org.openconcerto.erp.core.reports.stat.action.VenteArticleGraphAction;
import org.openconcerto.erp.core.reports.stat.action.VenteArticleMargeGraphAction;
import org.openconcerto.erp.core.sales.credit.action.ListeDesAvoirsClientsAction;
178,7 → 182,7
 
}
 
void registerMenuActions(final MenuAndActions ma) {
public void registerMenuActions(final MenuAndActions ma) {
registerFilesMenuActions(ma);
registerCreationMenuActions(ma);
registerListMenuActions(ma);
308,7 → 312,7
return group;
}
 
private Group createPaymentMenuGroup() {
public Group createPaymentMenuGroup() {
final Group group = new Group(MainFrame.PAYMENT_MENU);
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
 
340,11 → 344,14
return group;
}
 
private Group createStatsMenuGroup() {
public Group createStatsMenuGroup() {
final Group group = new Group(MainFrame.STATS_MENU);
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
 
group.addItem("sales.graph");
group.addItem("sales.graph.cumulate");
group.addItem("sales.graph.cmd");
group.addItem("sales.graph.cmd.cumulate");
 
group.addItem("sales.margin.graph");
 
351,11 → 358,12
group.addItem("sales.list.report");
group.addItem("sales.product.graph");
group.addItem("sales.product.margin.graph");
group.addItem("sales.product.family.graph");
group.addItem("sales.list.graph");
return group;
}
 
private Group createStatsDocumentsGroup() {
public Group createStatsDocumentsGroup() {
final Group group = new Group(MainFrame.DECLARATION_MENU);
// group.addItem("accounting.vat.report");
group.addItem("accounting.costs.report");
364,7 → 372,7
return group;
}
 
private Group createAccountingMenuGroup() {
public Group createAccountingMenuGroup() {
final Group group = new Group(MainFrame.STATE_MENU);
group.addItem("accounting.balance");
group.addItem("accounting.client.balance");
548,7 → 556,7
 
}
 
private void registerAccountingMenuActions(final MenuAndActions mManager) {
public void registerAccountingMenuActions(final MenuAndActions mManager) {
mManager.registerAction("accounting.balance", new EtatBalanceAction());
mManager.registerAction("accounting.client.balance", new BalanceAgeeAction());
mManager.registerAction("accounting.analytical.ledger", new ImpressionJournauxAnalytiqueAction());
561,7 → 569,7
mManager.registerAction("accounting.closing", new NouveauClotureAction());
}
 
private void registerStatsDocumentsActions(final MenuAndActions mManager) {
public void registerStatsDocumentsActions(final MenuAndActions mManager) {
// mManager.registerAction("accounting.vat.report", new DeclarationTVAAction());
mManager.registerAction("accounting.costs.report", new EtatChargeAction());
mManager.registerAction("accounting.balance.report", new CompteResultatBilanAction());
568,21 → 576,26
mManager.registerAction("employe.social.report", new N4DSAction());
}
 
private void registerStatsMenuActions(final MenuAndActions mManager) {
public void registerStatsMenuActions(final MenuAndActions mManager) {
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
 
mManager.registerAction("sales.graph", new EvolutionCAAction());
mManager.registerAction("sales.graph.cumulate", new EvolutionCACumulAction());
 
mManager.registerAction("sales.graph.cmd", new EvolutionCmdAction());
mManager.registerAction("sales.graph.cmd.cumulate", new EvolutionCmdCumulAction());
 
mManager.registerAction("sales.margin.graph", new EvolutionMargeAction());
 
mManager.registerAction("sales.list.report", new GenListeVenteAction());
mManager.registerAction("sales.product.graph", new VenteArticleGraphAction());
mManager.registerAction("sales.product.margin.graph", new VenteArticleMargeGraphAction());
mManager.registerAction("sales.product.family.graph", new VenteArticleFamilleGraphAction());
mManager.registerAction("sales.list.graph", new EtatVenteAction());
 
}
 
private void registerPaymentMenuActions(final MenuAndActions mManager) {
public void registerPaymentMenuActions(final MenuAndActions mManager) {
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
 
if (rights.haveRight(ComptaUserRight.MENU) || rights.haveRight(ComptaUserRight.POINTAGE_LETTRAGE)) {
622,7 → 635,7
 
}
 
private void registerOrganizationMenuActions(final MenuAndActions mManager) {
public void registerOrganizationMenuActions(final MenuAndActions mManager) {
final UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
final ComptaPropsConfiguration configuration = ComptaPropsConfiguration.getInstanceCompta();
if (rights.haveRight(ComptaUserRight.MENU)) {
/trunk/OpenConcerto/src/org/openconcerto/erp/config/InstallationPanel.java
1487,11 → 1487,22
addContact(root);
 
final SQLTable tableDevis = root.getTable("DEVIS");
AlterTable tDevis = new AlterTable(tableDevis);
boolean updateDevis = false;
if (!tableDevis.contains("POURCENT_REMISE")) {
updateDevis = true;
tDevis.addColumn("POURCENT_REMISE", "numeric (12,8)");
}
if (!tableDevis.contains("MONTANT_REMISE")) {
AlterTable t = new AlterTable(tableDevis);
t.addColumn("POURCENT_REMISE", "numeric (12,8)");
t.addColumn("MONTANT_REMISE", "numeric (16,8)");
tableDevis.getBase().getDataSource().execute(t.asString());
updateDevis = true;
tDevis.addColumn("MONTANT_REMISE", "numeric (16,8)");
}
if (!tableDevis.contains("T_HA")) {
updateDevis = true;
tDevis.addColumn("T_HA", "bigint", "0", false);
}
if (updateDevis) {
tableDevis.getBase().getDataSource().execute(tDevis.asString());
tableDevis.getSchema().updateVersion();
tableDevis.fetchFields();
}
1507,15 → 1518,31
}
 
final SQLTable tableAdresse = root.getTable("ADRESSE");
if (tableAdresse != null && !tableAdresse.contains("PROVINCE")) {
if (tableAdresse != null) {
AlterTable t = new AlterTable(tableAdresse);
boolean updateADr = false;
if (!tableAdresse.contains("PROVINCE")) {
t.addVarCharColumn("PROVINCE", 256);
updateADr = true;
}
if (!tableAdresse.contains("LIBELLE")) {
t.addVarCharColumn("LIBELLE", 256);
updateADr = true;
}
if (!tableAdresse.contains("TYPE")) {
t.addVarCharColumn("TYPE", 256);
updateADr = true;
}
if (!tableAdresse.contains("EMAIL_CONTACT")) {
t.addVarCharColumn("EMAIL_CONTACT", 256);
updateADr = true;
}
if (updateADr) {
tableAdresse.getBase().getDataSource().execute(t.asString());
tableAdresse.getSchema().updateVersion();
tableAdresse.fetchFields();
}
}
final SQLTable tableClient = root.getTable("CLIENT");
if (tableClient != null && !tableClient.contains("BLOQUE_LIVRAISON")) {
AlterTable t = new AlterTable(tableClient);
1535,7 → 1562,33
tableAssoc.getSchema().updateVersion();
tableAssoc.fetchFields();
}
if (!root.contains("CALENDAR_ITEM")) {
final SQLCreateTable createTaskGroupTable = new SQLCreateTable(root, "CALENDAR_ITEM_GROUP");
createTaskGroupTable.addVarCharColumn("NAME", 1024);
createTaskGroupTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
 
final SQLCreateTable createTaskTable = new SQLCreateTable(root, "CALENDAR_ITEM");
createTaskTable.addDateAndTimeColumn("START");
createTaskTable.addDateAndTimeColumn("END");
createTaskTable.addLongColumn("DURATION_S", 0L, false);
createTaskTable.addVarCharColumn("SUMMARY", 1024);
createTaskTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
createTaskTable.addVarCharColumn("FLAGS", 1024);
createTaskTable.addVarCharColumn("STATUS", 128);
createTaskTable.addForeignColumn(createTaskGroupTable);
createTaskTable.addLongColumn("SOURCE_ID", null, true);
createTaskTable.addVarCharColumn("SOURCE_TABLE", 256);
try {
root.getDBSystemRoot().getDataSource().execute(createTaskGroupTable.asString());
insertUndef(createTaskGroupTable);
root.getDBSystemRoot().getDataSource().execute(createTaskTable.asString());
insertUndef(createTaskTable);
tableDevis.getSchema().updateVersion();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
}
 
}
addArticleFournisseur(root);
}
 
1968,6 → 2021,10
 
SQLTable tableCmdFournElt = root.getTable("COMMANDE_ELEMENT");
addHAElementField(tableCmdFournElt, root);
if (root.contains("DEMANDE_PRIX_ELEMENT")) {
SQLTable tableDmdFournElt = root.getTable("DEMANDE_PRIX_ELEMENT");
addHAElementField(tableDmdFournElt, root);
}
 
SQLTable tableBonRecptElt = root.getTable("BON_RECEPTION_ELEMENT");
addHAElementField(tableBonRecptElt, root);
2340,7 → 2397,7
 
List<String> cols = Arrays.asList("PV_HT", "PA_DEVISE_T", "T_PV_HT", "T_PA_TTC", "T_PA_HT", "PA_HT", "T_PV_TTC", "PRIX_METRIQUE_HA_2", "PRIX_METRIQUE_HA_1", "PRIX_METRIQUE_HA_3",
"PRIX_METRIQUE_VT_2", "PRIX_METRIQUE_VT_1", "MONTANT_HT", "MONTANT_INITIAL", "PRIX_METRIQUE_VT_3", "MARGE_HT", "PA_DEVISE", "PV_U_DEVISE", "PV_T_DEVISE", "PV_TTC", "TARIF_Q18_HT",
"T_PRIX_FINAL_TTC", "PRIX_FINAL_TTC", "PV_UNIT_HT");
"T_PRIX_FINAL_TTC", "PRIX_FINAL_TTC", "PV_UNIT_HT", "PREBILAN", "MARGE_PREBILAN_HT");
 
if ((table.contains("PV_HT") && table.getField("PV_HT").getType().getDecimalDigits() == 0) || (table.contains("PV_UNIT_HT") && table.getField("PV_UNIT_HT").getType().getDecimalDigits() == 0)) {
AlterTable t = new AlterTable(table);
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_fr.xml
868,7 → 868,6
</TABLE>
 
<TABLE name="DEVIS">
 
<FIELD name="CONTACT_MAIL_RAPPORT" label="Email dest. suppl." />
<FIELD name="SITE_DIFF" label="Site d'intervention différent du donneur d'ordre" titlelabel="Site d'intervention différent du donneur d'ordre" />
<FIELD name="DESIGNATION_SITE" label="Désignation du site" />
879,7 → 878,6
<FIELD name="FAX_SITE" label="Fax du site" />
<FIELD name="MAIL_SITE" label="Email du site" />
<FIELD name="CONTACT_SITE" label="Contact du site" />
 
<FIELD name="DONNEUR_DIFF" label="Donneur d'ordre différent du client" />
<FIELD name="DESIGNATION_DONNEUR" label="Désignation du donneur d'ordre" />
<FIELD name="ADRESSE_DONNEUR" label="Adresse du donneur d'ordre" />
890,9 → 888,7
<FIELD name="MAIL_DONNEUR" label="Email du donneur d'ordre" />
<FIELD name="CONTACT_DONNEUR" label="Contact du donneur d'ordre" />
<FIELD name="SIREN_DONNEUR" label="Siren du donneur d'ordre" />
 
<FIELD name="DATE_DEMANDE" label="Date demande client" titlelabel="Date demande client" />
 
<FIELD name="MONTANT_REMISE" label="Remise globale" />
<FIELD name="ID_MODELE" label="Modèle" titlelabel="Modèle" />
<FIELD name="PROBABILITE" label="Probabilité" titlelabel="Probabilité" />
902,6 → 898,7
<FIELD name="OBJET" label="Référence" titlelabel="Référence" />
<FIELD name="ID_COMMERCIAL" label="Commercial" titlelabel="Commercial" />
<FIELD name="ID_CLIENT" label="Client" titlelabel="Client" />
<FIELD name="T_HA" label="Total achat HT" titlelabel="Total achat HT" />
<FIELD name="T_HT" label="Total HT" titlelabel="Total HT" />
<FIELD name="T_TVA" label="Total TVA" titlelabel="Total TVA" />
<FIELD name="T_TTC" label="Total TTC" titlelabel="Total TTC" />
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_cs.properties
New file
0,0 → 1,8
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Dnes je {0,date, d. MMMM yyyy}
JXDatePicker.longFormat=EEE d.MM.yyyy
#czech grammar vs application admits more variants to use
JXDatePicker.mediumFormat=d.M.yyyy
JXDatePicker.shortFormat=d.M.
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_pl_PL.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Dzisiaj jest {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE dd.MM.yyyy
JXDatePicker.mediumFormat=dd.MM.yy
JXDatePicker.shortFormat=MM/dd
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_pt_BR.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Hoje \u00E9 {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE dd/MM/yyyy
JXDatePicker.mediumFormat=dd/MM/yyyy
JXDatePicker.shortFormat=dd/MM
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_es.properties
New file
0,0 → 1,4
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Hoy es {0,date, dd MMMM yyyy}
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_fr.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Aujourd''hui, nous sommes le {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE dd/MM/yyyy
JXDatePicker.mediumFormat=dd/MM/yyyy
JXDatePicker.shortFormat=dd/MM
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_en_US.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Today is {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE MM/dd/yyyy
JXDatePicker.mediumFormat=MM/dd/yy
JXDatePicker.shortFormat=MM/dd
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_nl.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Vandaag is het {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE yyyy-MM-dd
JXDatePicker.mediumFormat=yyyy-MM-dd
JXDatePicker.shortFormat=yyyy-MM-dd
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_en_GB.properties
New file
0,0 → 1,10
#
# Text, formatting for JXDatePicker
#
#
 
JXDatePicker.linkFormat=Today is {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE dd/MM/yyyy
JXDatePicker.mediumFormat=dd/MM/yyyy
JXDatePicker.shortFormat=dd/MM
 
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_it.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Oggi \u00E8 il {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE dd/MM/yyyy
JXDatePicker.mediumFormat=dd/MM/yyyy
JXDatePicker.shortFormat=dd/MM
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker.properties
New file
0,0 → 1,13
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Today is {0,date}
# Issue #945-swingx: force a default fallback here not the right thing to
# for locales which do not have a properties file. In that case the
# language defaults provide a better fit
#JXDatePicker.longFormat=EEE MM/dd/yyyy
#JXDatePicker.mediumFormat=MM/dd/yy
#JXDatePicker.shortFormat=MM/dd
# Cannot work since AbstractComponentAddon.addResource() use ResourceBundle which only supports String
# and thus UIDefaults.getInt() returns 0
#JXDatePicker.numColumns=10
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_da.properties
New file
0,0 → 1,11
#
# Text, formatting for JXDatePicker
#
# Note: Danish official date formating allows for both a traditional
# and the ISO version. Since de-facto is to use the traditional
# that's what JXDatePicker will use default.
#
JXDatePicker.linkFormat=Dags dato {0,date, dd MMMM yyyy}
JXDatePicker.longFormat=EEE dd-MM-yyyy
JXDatePicker.mediumFormat=dd-MM-yyyy
JXDatePicker.shortFormat=dd/MM
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_sv.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Idag \u00E4r {0,date, yyyy MMMM dd}
JXDatePicker.longFormat=EEE yyyy/MM/dd
JXDatePicker.mediumFormat=yyyy/MM/dd
JXDatePicker.shortFormat=MM/dd
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_de.properties
New file
0,0 → 1,7
#
# Text, formatting for JXDatePicker
#
JXDatePicker.linkFormat=Heute ist der{0,date, dd. MMMM yyyy}
JXDatePicker.longFormat=dd.MM.yyyy
JXDatePicker.mediumFormat=dd.MM.yyyy
JXDatePicker.shortFormat=dd.MM
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/resources/DatePicker_en.properties
--- src/org/jdesktop/swingx/plaf/JXDatePickerAddon.java (revision 89)
+++ src/org/jdesktop/swingx/plaf/JXDatePickerAddon.java (revision 90)
@@ -18,14 +18,16 @@
*/
package org.jdesktop.swingx.plaf;
-import org.jdesktop.swingx.JXDatePicker;
+import java.util.Arrays;
+import java.util.List;
-import javax.swing.*;
+import javax.swing.BorderFactory;
+import javax.swing.border.LineBorder;
import javax.swing.plaf.BorderUIResource;
-import javax.swing.border.LineBorder;
-import java.util.List;
-import java.util.Arrays;
+import org.jdesktop.swingx.JXDatePicker;
+import org.jdesktop.swingx.plaf.basic.BasicDatePickerUI;
+
/**
* @author Joshua Outwater
*/
@@ -37,8 +39,8 @@
protected void addBasicDefaults(LookAndFeelAddons addon, List/*<Object>*/ defaults) {
defaults.addAll(Arrays.asList(new Object[] {
- new Boolean(defaults.add(JXDatePicker.uiClassID)),
- new Boolean(defaults.add("org.jdesktop.swingx.plaf.basic.BasicDatePickerUI")),
+ JXDatePicker.uiClassID,
+ BasicDatePickerUI.class.getName(),
"JXDatePicker.linkFormat",
"Nous sommes le {0,date, dd MMMM yyyy}",
"JXDatePicker.longFormat",
@@ -54,5 +56,6 @@
"JXDatePicker.numColumns",
new Integer(10)
}));
+ addResource(defaults, "org.jdesktop.swingx.plaf.basic.resources.DatePicker");
}
}
/trunk/OpenConcerto/src/product.properties
1,2 → 1,2
NAME=OpenConcerto
VERSION=1.4b1
VERSION=1.4b2