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/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/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/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/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/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/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/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/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/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/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/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);
 
}