Dépôt officiel du code source de l'ERP OpenConcerto
/trunk/OpenConcerto/src/org/jopendocument/link/OOConnexion.java |
---|
14,8 → 14,6 |
package org.jopendocument.link; |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.tools.SimpleURLClassLoader; |
import org.openconcerto.utils.tools.SimpleURLClassLoader.URLCollector; |
import java.io.File; |
import java.io.FileNotFoundException; |
55,20 → 53,27 |
static private final URL[] getURLs(final OOInstallation ooInstall) { |
final List<URL> res = ooInstall.getURLs(CollectionUtils.createSet("ridl.jar", "jurt.jar", "juh.jar", "unoil.jar")); |
return res.toArray(new URL[res.size()]); |
} |
static private final URL getFwkURL(final OOInstallation ooInstall) { |
final String jarName = "OO" + OO_VERSION + "-link.jar"; |
final URL resource = OOConnexion.class.getResource(jarName); |
if (resource == null) |
// Did you run ant in the OO3Link project (or in ours) ? |
throw new IllegalStateException("Missing " + jarName); |
res.add(org.openconcerto.utils.protocol.Helper.toJarJar(resource)); |
return resource; |
return res.toArray(new URL[res.size()]); |
} |
static private final PermissionCollection addPermissions(final PermissionCollection perms, final OOInstallation ooInstall) { |
static private final ClassLoader getLoader(final OOInstallation ooInstall) { |
ClassLoader res = loaders.get(ooInstall); |
if (res == null) { |
// pass our classloader otherwise the system class loader will be used. This won't work |
// in webstart since the classpath is loaded by JNLPClassLoader, thus a class loaded by |
// res couldn't refer to the classpath (e.g. this class) but only to the java library. |
res = new URLClassLoader(getURLs(ooInstall), OOConnexion.class.getClassLoader()) { |
@Override |
protected PermissionCollection getPermissions(CodeSource codesource) { |
final PermissionCollection perms = super.getPermissions(codesource); |
perms.add(new FilePermission(ooInstall.getExecutable().getAbsolutePath(), "execute")); |
perms.add(new SocketPermission("localhost:" + PORT + "-" + PORT_MAX, "connect")); |
// needed by OO jars |
92,29 → 97,9 |
perms.add(new RuntimePermission("getenv.*")); |
// needed by OOConnexion.convertToUrl() |
perms.add(new FilePermission("/usr/bin/gvfs-info", "execute")); |
return perms; |
} |
static synchronized private final ClassLoader getLoader(final OOInstallation ooInstall) { |
ClassLoader res = loaders.get(ooInstall); |
if (res == null) { |
// pass our classloader otherwise the system class loader will be used. This won't work |
// in webstart since the classpath is loaded by JNLPClassLoader, thus a class loaded by |
// res couldn't refer to the classpath (e.g. this class) but only to the java library. |
final URLClassLoader officeLoader = new URLClassLoader(getURLs(ooInstall), OOConnexion.class.getClassLoader()) { |
@Override |
protected PermissionCollection getPermissions(CodeSource codesource) { |
return addPermissions(super.getPermissions(codesource), ooInstall); |
} |
}; |
// only use SimpleURLClassLoader when really needed since it is less optimized |
res = new SimpleURLClassLoader(new URLCollector().addJar(getFwkURL(ooInstall)), officeLoader) { |
@Override |
protected PermissionCollection getPermissions(CodeSource codesource) { |
return addPermissions(super.getPermissions(codesource), ooInstall); |
} |
}; |
loaders.put(ooInstall, res); |
} |
return res; |
/trunk/OpenConcerto/src/org/jopendocument/link/OOInstallation.java |
---|
264,17 → 264,8 |
} |
public final List<URL> getURLs(final Set<String> jars) { |
final List<File> foundJars = findJarFiles(jars); |
final List<URL> res = new ArrayList<>(foundJars.size()); |
for (final File foundJar : foundJars) { |
res.add(toURL(foundJar)); |
} |
return res; |
} |
public final List<File> findJarFiles(final Set<String> jars) { |
final int stop = this.getClasspath().size(); |
final List<File> res = new ArrayList<>(); |
final List<URL> res = new ArrayList<URL>(); |
for (int i = 0; i < stop; i++) { |
final File[] foundJars = this.getClasspath().get(i).listFiles(new FileFilter() { |
@Override |
283,7 → 274,7 |
} |
}); |
for (final File foundJar : foundJars) { |
res.add(foundJar); |
res.add(toURL(foundJar)); |
} |
} |
return res; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/HistoriqueClientFrame.java |
---|
56,7 → 56,6 |
mapList.put("Echéances", Arrays.asList("ECHEANCE_CLIENT")); |
mapList.put("Relances", Arrays.asList("RELANCE")); |
mapList.put("Devis", Arrays.asList("DEVIS")); |
mapList.put("Commandes", Arrays.asList("COMMANDE_CLIENT")); |
mapList.put("Avoirs", Arrays.asList("AVOIR_CLIENT")); |
mapList.put("Articles facturés", Arrays.asList("SAISIE_VENTE_FACTURE_ELEMENT")); |
mapList.put("Articles proposés", Arrays.asList("DEVIS_ELEMENT")); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/stat/action/ReportingCommercialFournisseurAction.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/ComposedItemStockUpdater.java |
---|
21,8 → 21,6 |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLSelectJoin; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.SQLTableEvent; |
import org.openconcerto.sql.model.SQLTableEvent.Mode; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.request.UpdateBuilder; |
import org.openconcerto.sql.utils.SQLUtils; |
116,9 → 114,8 |
for (String s : requests) { |
handlers.add(null); |
} |
// FIXME FIRE TABLE CHANGED TO UPDATE ILISTE ?? |
SQLUtils.executeMultiple(stockTable.getDBSystemRoot(), requests, handlers); |
stockTable.fire(new SQLTableEvent(stockTable, SQLRow.NONEXISTANT_ID, Mode.ROW_UPDATED)); |
} |
/** |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/InventaireFromEtatStockImporter.java |
---|
385,7 → 385,7 |
} else { |
boolean contains = false; |
for (SQLRowValues sqlRowValues2 : referentRows) { |
if (sqlRowValues2.getForeign("ID_ARTICLE") != null && !sqlRowValues2.isForeignEmpty("ID_ARTICLE") && sqlRowValues2.getForeign("ID_ARTICLE").getString("CODE") != null) { |
if (!sqlRowValues2.isForeignEmpty("ID_ARTICLE") && sqlRowValues2.getForeign("ID_ARTICLE") != null && sqlRowValues2.getForeign("ID_ARTICLE").getString("CODE") != null) { |
if (codeKits.contains(sqlRowValues2.getForeign("ID_ARTICLE").getString("CODE"))) { |
contains = true; |
break; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/StockItem.java |
---|
96,13 → 96,13 |
} |
StockItemComponent comp = components.get(0); |
double real = comp.getItem().getRealQty() == 0 ? 0 : Math.floor(comp.getItem().getRealQty() / (comp.getQty() * comp.getQtyUnit().doubleValue())); |
double virtual = comp.getItem().getVirtualQty() == 0 ? 0 : Math.floor(comp.getItem().getVirtualQty() / (comp.getQty() * comp.getQtyUnit().doubleValue())); |
double real = comp.getItem().getRealQty() == 0 ? 0 : Math.ceil(comp.getItem().getRealQty() / (comp.getQty() * comp.getQtyUnit().doubleValue())); |
double virtual = comp.getItem().getVirtualQty() == 0 ? 0 : Math.ceil(comp.getItem().getVirtualQty() / (comp.getQty() * comp.getQtyUnit().doubleValue())); |
for (StockItemComponent stockItemComponent : components) { |
real = Math.min(real, stockItemComponent.getItem().getRealQty() == 0 ? 0 |
: Math.floor(stockItemComponent.getItem().getRealQty() / (stockItemComponent.getQty() * stockItemComponent.getQtyUnit().doubleValue()))); |
: Math.ceil(stockItemComponent.getItem().getRealQty() / (stockItemComponent.getQty() * stockItemComponent.getQtyUnit().doubleValue()))); |
virtual = Math.min(virtual, stockItemComponent.getItem().getVirtualQty() == 0 ? 0 |
: Math.floor(stockItemComponent.getItem().getVirtualQty() / (stockItemComponent.getQty() * stockItemComponent.getQtyUnit().doubleValue()))); |
: Math.ceil(stockItemComponent.getItem().getVirtualQty() / (stockItemComponent.getQty() * stockItemComponent.getQtyUnit().doubleValue()))); |
} |
// La quantité du kit ne peut être négative |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/supplier/action/NouvelHistoriqueListeFournAction.java |
---|
45,11 → 45,7 |
// l.add("SAISIE_ACHAT"); |
// l.add("CHEQUE_FOURNISSEUR"); |
Map<String, List<String>> mapList = new HashMap<String, List<String>>(); |
mapList.put("Commandes", Arrays.asList("COMMANDE")); |
mapList.put("Bons de réception", Arrays.asList("BON_RECEPTION")); |
mapList.put("Factures", Arrays.asList("FACTURE_FOURNISSEUR")); |
mapList.put("Achats", Arrays.asList("SAISIE_ACHAT")); |
mapList.put("Avoirs", Arrays.asList("AVOIR_FOURNISSEUR")); |
mapList.put("Chèques émis", Arrays.asList("CHEQUE_FOURNISSEUR")); |
final HistoriqueFournBilanPanel panelBilan = new HistoriqueFournBilanPanel(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/supplier/component/FournisseurSQLComponent.java |
---|
378,7 → 378,7 |
// BIC |
JLabel labelBIC = new JLabel("BIC", SwingConstants.RIGHT); |
JTextField textBIC = new JTextField(20); |
JTextField textBIC = new JTextField(12); |
c2.gridx = 0; |
c2.gridy++; |
c2.weightx = 0; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/purchase/importer/FacturXExporter.java |
---|
13,25 → 13,16 |
package org.openconcerto.erp.core.supplychain.purchase.importer; |
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement; |
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; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import java.math.BigDecimal; |
import java.text.DecimalFormat; |
import java.text.DecimalFormatSymbols; |
import java.text.SimpleDateFormat; |
import java.util.Collection; |
import java.util.ArrayList; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Locale; |
import java.util.Map; |
import org.jdom2.Document; |
import org.jdom2.Element; |
43,27 → 34,18 |
* FacturX export (EN 16931 format) |
*/ |
public class FacturXExporter { |
private class Tax { |
// Taux, ex pour 20% : 20.00 |
final BigDecimal rate; |
BigDecimal rate; |
// Montant de la TVA |
BigDecimal amount = BigDecimal.ZERO; |
BigDecimal amount; |
// montant HT sur lequel s'applique la TVA |
BigDecimal basisAmount = BigDecimal.ZERO; |
BigDecimal basisAmount; |
public Tax(BigDecimal rate) { |
this.rate = rate; |
} |
public void add(BigDecimal taxAmount, |
BigDecimal basisAmount) { |
this.amount = this.amount.add(taxAmount); |
this.basisAmount = this.basisAmount.add(basisAmount); |
} |
} |
public static Namespace QDT_NS = Namespace.getNamespace("qdt", "urn:un:unece:uncefact:data:standard:QualifiedDataType:100"); |
public static Namespace RAM_NS = Namespace.getNamespace("ram", "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"); |
public static Namespace RSM_NS = Namespace.getNamespace("rsm", "urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"); |
74,55 → 56,26 |
FacturXExporter ex = new FacturXExporter(); |
System.err.println("FacturXExporter.main() " + ex.checkEAN13("5987854125989")); |
// String xml = ex.createXMLFrom(null, 1); |
// System.out.println(xml); |
String xml = ex.createXMLFrom(null, 1); |
System.out.println(xml); |
} |
DecimalFormat formatAmount = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); |
public String createXMLFrom(DBRoot row, int invoiceId) { |
private boolean useCommonClient = false; |
List<Tax> taxes = new ArrayList<>(); |
Tax t1 = new Tax(); |
t1.rate = new BigDecimal("20.0"); |
t1.amount = new BigDecimal("40.0"); |
t1.basisAmount = new BigDecimal("200.0"); |
taxes.add(t1); |
public String createXMLFrom(DBRoot dbRoot, int invoiceId, SQLRow societeRow) { |
SQLTable factureTable = dbRoot.getTable("SAISIE_VENTE_FACTURE"); |
SQLRowValues rowValsToFetch = new SQLRowValues(factureTable); |
rowValsToFetch.putNulls("NUMERO", "DATE", "NOM", "T_TVA", "T_HT", "T_TTC", "NET_A_PAYER"); |
rowValsToFetch.putRowValues("ID_MODE_REGLEMENT").putNulls("COMPTANT", "AJOURS", "LENJOUR", "DATE_FACTURE", "FIN_MOIS").putRowValues("ID_TYPE_REGLEMENT").putNulls("NOM"); |
SQLRowValues putRowValuesClient = rowValsToFetch.putRowValues("ID_CLIENT"); |
putRowValuesClient.putNulls("NOM", "RESPONSABLE", "SIRET", "NUMERO_TVA", "MAIL", "TEL"); |
if (putRowValuesClient.getTable().contains("ID_CLIENT")) { |
this.useCommonClient = true; |
putRowValuesClient.putRowValues("ID_CLIENT").putNulls("NOM", "RESPONSABLE", "SIRET", "NUMERO_TVA", "MAIL", "TEL").putRowValues("ID_ADRESSE").putNulls("RUE", "VILLE", "CODE_POSTAL", |
"PAYS"); |
} |
putRowValuesClient.putRowValues("ID_ADRESSE").putNulls("RUE", "VILLE", "CODE_POSTAL", "PAYS"); |
putRowValuesClient.putRowValues("ID_ADRESSE_F").putNulls("RUE", "VILLE", "CODE_POSTAL", "PAYS"); |
rowValsToFetch.putRowValues("ID_ADRESSE").putNulls("RUE", "VILLE", "CODE_POSTAL", "PAYS"); |
SQLTable factureItemtable = dbRoot.getTable("SAISIE_VENTE_FACTURE_ELEMENT"); |
SQLRowValues rowValsItemsToFetch = new SQLRowValues(factureItemtable); |
rowValsItemsToFetch.putNulls("NIVEAU", "CODE", "NOM", "QTE", "QTE_UNITAIRE", "PV_HT", "T_PV_HT", "T_PV_TTC").putRowValues("ID_TAXE").put("TAUX", null); |
rowValsItemsToFetch.put("ID_SAISIE_VENTE_FACTURE", rowValsToFetch); |
List<SQLRowValues> factures = SQLRowValuesListFetcher.create(rowValsToFetch).fetch(new Where(factureTable.getKey(), "=", invoiceId)); |
SQLRowValues facture = factures.get(0); |
Collection<? extends SQLRowAccessor> factureItems = facture.getReferentRows(factureItemtable.getField("ID_SAISIE_VENTE_FACTURE")); |
Map<Integer, Tax> taxes = new HashMap<>(); |
// Tax t1 = new Tax(); |
// t1.rate = new BigDecimal("20.0"); |
// t1.amount = new BigDecimal("40.0"); |
// t1.basisAmount = new BigDecimal("200.0"); |
// taxes.add(t1); |
DecimalFormat format = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); |
DecimalFormat fQty = new DecimalFormat("#0.########", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); |
String invoiceNumber = facture.getString("NUMERO"); |
Date invoiceDate = facture.getDate("DATE").getTime(); |
String regNote = societeRow.getString("TYPE") + " au capital de " + societeRow.getObject("CAPITAL") + " €"; |
String legNote = societeRow.getString("RCS"); |
int nbLines = factureItems.size(); |
String invoiceNumber = "-"; |
Date invoiceDate = new Date(); |
String regNote = "SARL au capital de 50 000 EUR"; |
String legNote = "RCS MAVILLE 123 456 789"; |
int nbLines = 4; |
final Document doc = new Document(); |
Element root = new Element("CrossIndustryInvoice", RSM_NS); |
179,40 → 132,21 |
// SupplyChainTradeTransaction |
Element eSupplyChainTradeTransaction = new Element("SupplyChainTradeTransaction", RSM_NS); |
int lineID = 1; |
for (SQLRowAccessor rowItem : factureItems) { |
String productCode = rowItem.getString("CODE"); |
String productName = rowItem.getString("NOM").trim().length() == 0 ? "Ligne" : rowItem.getString("NOM"); |
for (int i = 0; i < nbLines; i++) { |
String productCode = "a"; |
String productName = "b"; |
final BigDecimal pHT, pTTC, totalHTLigne, totalTTCLigne; |
SQLRowAccessor taxeItem = rowItem.getForeign("ID_TAXE"); |
BigDecimal taxValue = new BigDecimal(taxeItem.getFloat("TAUX")).setScale(2); |
if (rowItem.getInt("NIVEAU") != 1) { |
pHT = BigDecimal.ZERO; |
pTTC = BigDecimal.ZERO; |
totalHTLigne = BigDecimal.ZERO; |
totalTTCLigne = BigDecimal.ZERO; |
} else { |
pHT = rowItem.getBigDecimal("PV_HT"); |
pTTC = pHT.multiply(taxValue.add(BigDecimal.ONE)); |
totalHTLigne = rowItem.getBigDecimal("T_PV_HT"); |
totalTTCLigne = rowItem.getBigDecimal("T_PV_TTC"); |
} |
BigDecimal pHT = new BigDecimal("12.46"); |
BigDecimal tax = new BigDecimal("0.20"); |
BigDecimal pTTC = new BigDecimal("14.95"); |
BigDecimal qte = new BigDecimal("10.0"); |
BigDecimal totalHTLigne = new BigDecimal("124.60"); |
int idTaxe = taxeItem.getID(); |
if (!taxes.containsKey(idTaxe)) { |
Tax t = new Tax(taxValue); |
taxes.put(idTaxe, t); |
} |
taxes.get(idTaxe).add(totalTTCLigne.subtract(totalHTLigne), totalHTLigne); |
BigDecimal qte = new BigDecimal(rowItem.getInt("QTE")).multiply(rowItem.getBigDecimal("QTE_UNITAIRE")); |
Element eLineItem = new Element("IncludedSupplyChainTradeLineItem", RAM_NS); |
// AssociatedDocumentLineDocument |
Element eAssociatedDocumentLineDocument = new Element("AssociatedDocumentLineDocument", RAM_NS); |
Element eLineID = new Element("LineID", RAM_NS); |
eLineID.setText(String.valueOf(lineID++)); |
eLineID.setText(String.valueOf(i + 1)); |
eAssociatedDocumentLineDocument.addContent(eLineID); |
eLineItem.addContent(eAssociatedDocumentLineDocument); |
// SpecifiedTradeProduct |
242,11 → 176,11 |
// Prix unitaire TTC |
Element eGrossPriceProductTradePrice = new Element("GrossPriceProductTradePrice", RAM_NS); |
Element eChargeAmount = new Element("ChargeAmount", RAM_NS); |
eChargeAmount.setText(formatAmount.format(pTTC)); |
eChargeAmount.setText(format.format(pTTC)); |
eGrossPriceProductTradePrice.addContent(eChargeAmount); |
Element eAppliedTradeAllowanceCharge = new Element("AppliedTradeAllowanceCharge", RAM_NS); |
Element eChargeIndicator = new Element("ChargeIndicator", RAM_NS); |
Element eIndicator = new Element("Indicator", UDT_NS); |
Element eIndicator = new Element("ChargeIndicator", UDT_NS); |
// pas de remise |
eIndicator.setText("false"); |
eChargeIndicator.addContent(eIndicator); |
254,17 → 188,17 |
Element eActualAmount = new Element("ActualAmount", RAM_NS); |
// Montant de TVA (unitaire) |
eActualAmount.setText(formatAmount.format(pTTC.subtract(pHT))); |
eActualAmount.setText(format.format(pTTC.subtract(pHT))); |
eAppliedTradeAllowanceCharge.addContent(eActualAmount); |
// eGrossPriceProductTradePrice.addContent(eAppliedTradeAllowanceCharge); |
eGrossPriceProductTradePrice.addContent(eAppliedTradeAllowanceCharge); |
eSpecifiedLineTradeAgreement.addContent(eGrossPriceProductTradePrice); |
// Prix unitaire HT |
Element eNetPriceProductTradePrice = new Element("NetPriceProductTradePrice", RAM_NS); |
Element eChargeAmountHT = new Element("ChargeAmount", RAM_NS); |
eChargeAmountHT.setText(formatAmount.format(pHT)); |
eChargeAmountHT.setText(format.format(pHT)); |
eNetPriceProductTradePrice.addContent(eChargeAmountHT); |
eSpecifiedLineTradeAgreement.addContent(eNetPriceProductTradePrice); |
306,7 → 240,7 |
Element eRateApplicablePercent = new Element("RateApplicablePercent", RAM_NS); |
// 20% -> 20.0 |
eRateApplicablePercent.setText(formatAmount.format(taxValue)); |
eRateApplicablePercent.setText(format.format(tax.multiply(new BigDecimal(100)))); |
eApplicableTradeTaxt.addContent(eRateApplicablePercent); |
eSpecifiedLineTradeSettlement.addContent(eApplicableTradeTaxt); |
314,7 → 248,7 |
Element eSpecifiedTradeSettlementLineMonetarySummation = new Element("SpecifiedTradeSettlementLineMonetarySummation", RAM_NS); |
// Total HT |
Element eLineTotalAmount = new Element("LineTotalAmount", RAM_NS); |
eLineTotalAmount.setText(formatAmount.format(totalHTLigne)); |
eLineTotalAmount.setText(format.format(totalHTLigne)); |
eSpecifiedTradeSettlementLineMonetarySummation.addContent(eLineTotalAmount); |
eSpecifiedLineTradeSettlement.addContent(eSpecifiedTradeSettlementLineMonetarySummation); |
323,11 → 257,12 |
eSupplyChainTradeTransaction.addContent(eLineItem); |
} |
addApplicableHeader(eSupplyChainTradeTransaction, taxes); |
ed.addContent(eSupplyChainTradeTransaction); |
root.addContent(ed); |
addApplicableHeader(societeRow, facture, eSupplyChainTradeTransaction, taxes.values()); |
root.addContent(eSupplyChainTradeTransaction); |
final XMLOutputter xmlOutput = new XMLOutputter(); |
xmlOutput.setFormat(Format.getPrettyFormat()); |
return xmlOutput.outputString(doc); |
338,25 → 273,22 |
parent.addContent(element); |
} |
private void addApplicableHeader(SQLRowAccessor rowSociete, SQLRowAccessor rowFacture, Element eSupplyChainTradeTransaction, Collection<Tax> taxes) { |
private void addApplicableHeader(Element eSupplyChainTradeTransaction, List<Tax> taxes) { |
// |
// ApplicableHeaderTradeAgreement |
// |
final Element eApplicableHeaderTradeAgreement = new Element("ApplicableHeaderTradeAgreement", RAM_NS); |
addSupplierInfo(eApplicableHeaderTradeAgreement, rowSociete); |
addBuyerInfo(eApplicableHeaderTradeAgreement, rowFacture); |
addSupplierInfo(eApplicableHeaderTradeAgreement); |
addBuyerInfo(eApplicableHeaderTradeAgreement); |
String orderRef = ""; |
String contractRef = ""; |
// Date de livraison, facultative |
Date effectiveDeliveryDate = rowFacture.getDate("DATE").getTime(); |
String invoiceNumber = rowFacture.getString("NUMERO"); |
Date effectiveDeliveryDate = new Date(65454654); |
String invoiceNumber = "FA-2017-0010"; |
String currencyCode = "EUR"; |
SQLRowAccessor foreignMdr = rowFacture.getForeign("ID_MODE_REGLEMENT"); |
int ajours = foreignMdr.getInt("AJOURS"); |
int lenjour = foreignMdr.getInt("LENJOUR"); |
String dueDescription = (ajours > 0 ? "A " + ajours : "") + (lenjour > 0 ? " le " + lenjour : ""); |
Date dueDate = ModeDeReglementSQLElement.calculDate(foreignMdr, rowFacture.getDate("DATE").getTime()); |
String dueDescription = "30% d'acompte, solde à 30 j"; |
Date dueDate = new Date(65455654); |
final Element eBuyerOrderReferencedDocument = new Element("BuyerOrderReferencedDocument", RAM_NS); |
addValue(eBuyerOrderReferencedDocument, new Element("IssuerAssignedID", RAM_NS), orderRef); |
398,7 → 330,6 |
addValue(eApplicableHeaderTradeSettlement, new Element("PaymentReference", RAM_NS), invoiceNumber); |
addValue(eApplicableHeaderTradeSettlement, new Element("InvoiceCurrencyCode", RAM_NS), currencyCode); |
final Element aSpecifiedTradeSettlementPaymentMeans = new Element("SpecifiedTradeSettlementPaymentMeans", RAM_NS); |
addValue(aSpecifiedTradeSettlementPaymentMeans, new Element("TypeCode", RAM_NS), "57"); |
// <ram:TypeCode>30</ram:TypeCode> |
// <ram:Information>Virement sur compte Banque Fiducial</ram:Information> |
449,38 → 380,7 |
eApplicableHeaderTradeSettlement.addContent(eSpecifiedTradePaymentTerms); |
final Element eSpecifiedTradeSettlementHeaderMonetarySummation = new Element("SpecifiedTradeSettlementHeaderMonetarySummation", RAM_NS); |
final Element eTotalHT = new Element("LineTotalAmount", RAM_NS); |
eTotalHT.setText(this.formatAmount.format(new BigDecimal(rowFacture.getLong("T_HT")).movePointLeft(2))); |
eSpecifiedTradeSettlementHeaderMonetarySummation.addContent(eTotalHT); |
final Element eTotalBaseTVA = new Element("TaxBasisTotalAmount", RAM_NS); |
BigDecimal totalBaseTVA = BigDecimal.ZERO; |
for (Tax tax : taxes) { |
totalBaseTVA = totalBaseTVA.add(tax.basisAmount); |
} |
eTotalBaseTVA.setText(this.formatAmount.format(totalBaseTVA)); |
eSpecifiedTradeSettlementHeaderMonetarySummation.addContent(eTotalBaseTVA); |
final Element eTotalTVA = new Element("TaxTotalAmount", RAM_NS); |
eTotalTVA.setAttribute("currencyID", "EUR"); |
eTotalTVA.setText(this.formatAmount.format(new BigDecimal(rowFacture.getLong("T_TVA")).movePointLeft(2))); |
eSpecifiedTradeSettlementHeaderMonetarySummation.addContent(eTotalTVA); |
final Element eTotalTTC = new Element("GrandTotalAmount", RAM_NS); |
BigDecimal totalTTC = new BigDecimal(rowFacture.getLong("T_TTC")).movePointLeft(2); |
eTotalTTC.setText(this.formatAmount.format(totalTTC)); |
eSpecifiedTradeSettlementHeaderMonetarySummation.addContent(eTotalTTC); |
final Element eTotalPrepaid = new Element("TotalPrepaidAmount", RAM_NS); |
BigDecimal netApayer = new BigDecimal(rowFacture.getLong("NET_A_PAYER")).movePointLeft(2); |
eTotalPrepaid.setText(this.formatAmount.format(totalTTC.subtract(netApayer))); |
eSpecifiedTradeSettlementHeaderMonetarySummation.addContent(eTotalPrepaid); |
final Element eTotalDue = new Element("DuePayableAmount", RAM_NS); |
eTotalDue.setText(this.formatAmount.format(netApayer)); |
eSpecifiedTradeSettlementHeaderMonetarySummation.addContent(eTotalDue); |
// Total HT |
// <ram:LineTotalAmount>624.90</ram:LineTotalAmount> |
// Total HT sur leque est appliqué la TVA |
500,35 → 400,20 |
} |
private void addBuyerInfo(final Element eApplicableHeaderTradeAgreement, final SQLRowAccessor rowFacture) { |
SQLRowAccessor client = rowFacture.getForeign("ID_CLIENT"); |
SQLRowAccessor clientGestion = client; |
if (this.useCommonClient) { |
client = client.getForeign("ID_CLIENT"); |
} |
final SQLRowAccessor adr; |
if (!rowFacture.isForeignEmpty("ID_ADRESSE")) { |
adr = rowFacture.getForeign("ID_ADRESSE"); |
} else if (!clientGestion.isForeignEmpty("ID_ADRESSE_F")) { |
adr = clientGestion.getForeign("ID_ADRESSE_F"); |
} else { |
adr = client.getForeign("ID_ADRESSE"); |
} |
private void addBuyerInfo(final Element eApplicableHeaderTradeAgreement) { |
// Acheteur |
String buyerName = client.getString("NOM"); |
String buyerSIRET = client.getString("SIRET"); |
String buyerVAT = client.getString("NUMERO_TVA"); |
String buyerContactName = client.getString("RESPONSABLE"); |
String buyerPhone = client.getString("TEL"); |
String buyerEmail = client.getString("MAIL"); |
String buyerAddrL1 = adr.getString("RUE"); |
String buyerName = "Ma jolie boutique"; |
String buyerSIRET = "78787878400035"; |
String buyerVAT = "FR19787878784"; |
String buyerContactName = "Alexandre Payet"; |
String buyerPhone = "+33 4 72 07 08 67"; |
String buyerEmail = "alexandre.payet@majolieboutique.net"; |
String buyerAddrL1 = "35 rue de la République"; |
String buyerAddrL2 = ""; |
String buyerAddrL3 = ""; |
String buyerPostalCode = adr.getString("CODE_POSTAL"); |
String buyerCity = adr.getString("VILLE"); |
String buyerCountryCode = resolveCountryCode(adr.getString("PAYS")); |
String buyerPostalCode = "69001"; |
String buyerCity = "Lyon"; |
String buyerCountryCode = "FR"; |
final Element eBuyerTradeParty = new Element("BuyerTradeParty", RAM_NS); |
this.addValue(eBuyerTradeParty, new Element("Name", RAM_NS), buyerName); |
554,20 → 439,19 |
eBuyerTradeParty.addContent(eDefinedTradeContact); |
// Adresse postale |
final Element ePostalTradeAddress = new Element("PostalTradeAddress", RAM_NS); |
addValue(ePostalTradeAddress, new Element("PostcodeCode", RAM_NS), buyerPostalCode); |
addValue(ePostalTradeAddress, new Element("LineOne", RAM_NS), buyerAddrL1); |
addValue(ePostalTradeAddress, new Element("LineOne>", RAM_NS), buyerAddrL1); |
if (buyerAddrL2 != null && !buyerAddrL2.trim().isEmpty()) { |
addValue(ePostalTradeAddress, new Element("LineTwo", RAM_NS), buyerAddrL2); |
addValue(ePostalTradeAddress, new Element("LineTwo>", RAM_NS), buyerAddrL2); |
} |
if (buyerAddrL3 != null && !buyerAddrL3.trim().isEmpty()) { |
addValue(ePostalTradeAddress, new Element("LineThree", RAM_NS), buyerAddrL3); |
addValue(ePostalTradeAddress, new Element("LineThree>", RAM_NS), buyerAddrL3); |
} |
addValue(ePostalTradeAddress, new Element("CityName", RAM_NS), buyerCity); |
addValue(ePostalTradeAddress, new Element("CountryID", RAM_NS), buyerCountryCode); |
addValue(ePostalTradeAddress, new Element("PostcodeCode>", RAM_NS), buyerPostalCode); |
addValue(ePostalTradeAddress, new Element("CityName>", RAM_NS), buyerCity); |
addValue(ePostalTradeAddress, new Element("CountryID>", RAM_NS), buyerCountryCode); |
eBuyerTradeParty.addContent(ePostalTradeAddress); |
if (buyerVAT != null && buyerVAT.trim().length() > 0) { |
// TVA |
final Element eSpecifiedTaxRegistration = new Element("SpecifiedTaxRegistration", RAM_NS); |
final Element eSpecifiedTaxRegistrationId = new Element("ID", RAM_NS); |
575,24 → 459,23 |
eSpecifiedTaxRegistrationId.setText(buyerVAT); |
eSpecifiedTaxRegistration.addContent(eSpecifiedTaxRegistrationId); |
eBuyerTradeParty.addContent(eSpecifiedTaxRegistration); |
} |
eApplicableHeaderTradeAgreement.addContent(eBuyerTradeParty); |
} |
private void addSupplierInfo(final Element eApplicableHeaderTradeAgreement, SQLRowAccessor rowSociete) { |
String supplierName = rowSociete.getString("NOM"); |
String supplierSIRET = rowSociete.getString("NUM_SIRET"); |
String supplierContactName = ""; |
String supplierContactPhone = rowSociete.getString("NUM_TEL"); |
String supplierContactEmail = rowSociete.getString("MAIL"); |
SQLRowAccessor adr = rowSociete.getForeign("ID_ADRESSE_COMMON"); |
String supplierAddrL1 = adr.getString("RUE"); |
private void addSupplierInfo(final Element eApplicableHeaderTradeAgreement) { |
String supplierName = "Au bon moulin"; |
String supplierSIRET = "121321321321"; |
String supplierContactName = "Tony Dubois"; |
String supplierContactPhone = "+33 4 72 07 08 56"; |
String supplierContactEmail = "tony.dubois@aubonmoulin.fr"; |
String supplierAddrL1 = "3 rue du pont"; |
String supplierAddrL2 = ""; |
String supplierAddrL3 = ""; |
String supplierAddrPostalCode = adr.getString("CODE_POSTAL"); |
String supplierAddrCityName = adr.getString("VILLE"); |
String supplierAddrCountryID = resolveCountryCode(adr.getString("PAYS")); |
String supplierNumTVA = rowSociete.getString("NUM_NII"); |
String supplierAddrPostalCode = "80100"; |
String supplierAddrCityName = "Abbeville"; |
String supplierAddrCountryID = "FR"; |
String supplierNumTVA = "FR121321321321"; |
// Vendeur |
final Element eSellerTradeParty = new Element("SellerTradeParty", RAM_NS); |
addValue(eSellerTradeParty, new Element("Name", RAM_NS), supplierName); |
624,7 → 507,6 |
eSellerTradeParty.addContent(eDefinedTradeContact); |
final Element ePostalTradeAddress = new Element("PostalTradeAddress", RAM_NS); |
addValue(ePostalTradeAddress, new Element("PostcodeCode", RAM_NS), supplierAddrPostalCode); |
addValue(ePostalTradeAddress, new Element("LineOne", RAM_NS), supplierAddrL1); |
if (supplierAddrL2 != null && !supplierAddrL2.trim().isEmpty()) { |
addValue(ePostalTradeAddress, new Element("LineTwo", RAM_NS), supplierAddrL2); |
632,6 → 514,7 |
if (supplierAddrL3 != null && !supplierAddrL3.trim().isEmpty()) { |
addValue(ePostalTradeAddress, new Element("LineThree", RAM_NS), supplierAddrL3); |
} |
addValue(ePostalTradeAddress, new Element("PostcodeCode", RAM_NS), supplierAddrPostalCode); |
addValue(ePostalTradeAddress, new Element("CityName", RAM_NS), supplierAddrCityName); |
addValue(ePostalTradeAddress, new Element("CountryID", RAM_NS), supplierAddrCountryID); |
685,56 → 568,4 |
} |
return Integer.valueOf(code.substring(12, 13)).intValue() == checkdigit; |
} |
private String resolveCountryCode(String pays) { |
if (pays == null || pays.trim().length() == 0) { |
return "FR"; |
} else if (pays.toLowerCase().equals("france")) { |
return "FR"; |
} else if (pays.toLowerCase().equals("fr")) { |
return "FR"; |
} else if (pays.toLowerCase().equals("polska")) { |
return "PL"; |
} else if (pays.toLowerCase().equals("pologne")) { |
return "PL"; |
} else if (pays.toLowerCase().equals("pl")) { |
return "PL"; |
} else if (pays.toLowerCase().equals("allemagne")) { |
return "DE"; |
} else if (pays.toLowerCase().equals("de")) { |
return "DE"; |
} else if (pays.toLowerCase().equals("deutschland")) { |
return "DE"; |
} else if (pays.toLowerCase().equals("italie")) { |
return "IT"; |
} else if (pays.toLowerCase().equals("italy")) { |
return "IT"; |
} else if (pays.toLowerCase().equals("italia")) { |
return "IT"; |
} else if (pays.toLowerCase().equals("it")) { |
return "IT"; |
} else if (pays.toLowerCase().equals("espagne")) { |
return "SP"; |
} else if (pays.toLowerCase().equals("spain")) { |
return "SP"; |
} else if (pays.toLowerCase().equals("sp")) { |
return "SP"; |
} else if (pays.toLowerCase().equals("luxembourg")) { |
return "LU"; |
} else if (pays.toLowerCase().equals("lu")) { |
return "LU"; |
} else if (pays.toLowerCase().equals("portugal")) { |
return "PT"; |
} else if (pays.toLowerCase().equals("pt")) { |
return "PT"; |
} else if (pays.toLowerCase().equals("belgique")) { |
return "BE"; |
} else if (pays.toLowerCase().equals("belgium")) { |
return "BE"; |
} else if (pays.toLowerCase().equals("be")) { |
return "BE"; |
} else { |
return ""; |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/table/ChiffrageCommandeTable.java |
---|
28,7 → 28,6 |
import org.openconcerto.sql.view.list.RowValuesTableRenderer; |
import org.openconcerto.sql.view.list.SQLTableElement; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.table.XTableColumnModel; |
import org.openconcerto.utils.DecimalUtils; |
import java.awt.GridBagConstraints; |
37,9 → 36,7 |
import java.math.BigDecimal; |
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
import java.util.Vector; |
import javax.swing.AbstractAction; |
83,9 → 80,7 |
final SQLField fieldHA = e.getTable().getField("PA_HT"); |
final DeviseNumericCellEditor editorPAHT = new DeviseNumericCellEditor(fieldHA); |
final SQLTableElement pa = new SQLTableElement(fieldHA, BigDecimal.class, editorPAHT); |
DeviseTableCellRenderer renderer = new DeviseTableCellRenderer(); |
renderer.setHideZeroValue(true); |
pa.setRenderer(renderer); |
pa.setRenderer(new DeviseTableCellRenderer()); |
if (e.getTable().contains("ID_CATEGORIE_HEURE")) { |
pa.setEditable(false); |
} |
94,7 → 89,7 |
final SQLField fieldPV = e.getTable().getField("PV_HT"); |
final DeviseNumericCellEditor editorPVHT = new DeviseNumericCellEditor(fieldPV); |
final SQLTableElement pv = new SQLTableElement(fieldPV, BigDecimal.class, editorPVHT); |
pv.setRenderer(renderer); |
pv.setRenderer(new DeviseTableCellRenderer()); |
list.add(pv); |
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE"), BigDecimal.class) { |
103,7 → 98,7 |
return BigDecimal.ZERO; |
} |
}; |
qteU.setRenderer(renderer); |
qteU.setRenderer(new DeviseTableCellRenderer()); |
list.add(qteU); |
if (e.getTable().contains("ANT")) { |
113,7 → 108,7 |
return BigDecimal.ZERO; |
} |
}; |
ant.setRenderer(renderer); |
ant.setRenderer(new DeviseTableCellRenderer()); |
list.add(ant); |
} |
124,7 → 119,7 |
return BigDecimal.ZERO; |
} |
}; |
restant.setRenderer(renderer); |
restant.setRenderer(new DeviseTableCellRenderer()); |
list.add(restant); |
} |
134,7 → 129,7 |
final SQLField fieldTotalHA = e.getTable().getField("T_PA_HT"); |
final DeviseNumericCellEditor editorTotalPAHT = new DeviseNumericCellEditor(fieldTotalHA); |
final SQLTableElement totalpa = new SQLTableElement(fieldTotalHA, BigDecimal.class, editorTotalPAHT); |
totalpa.setRenderer(renderer); |
totalpa.setRenderer(new DeviseTableCellRenderer()); |
totalpa.setEditable(false); |
list.add(totalpa); |
142,7 → 137,7 |
final DeviseNumericCellEditor editorTotalPVHT = new DeviseNumericCellEditor(fieldTotalPV); |
final SQLTableElement totalpv = new SQLTableElement(fieldTotalPV, BigDecimal.class, editorTotalPVHT); |
totalpv.setEditable(false); |
totalpv.setRenderer(renderer); |
totalpv.setRenderer(new DeviseTableCellRenderer()); |
list.add(totalpv); |
final SQLField fieldMarge = e.getTable().getField("MARGE"); |
149,7 → 144,7 |
final DeviseNumericCellEditor editorMarge = new DeviseNumericCellEditor(fieldMarge); |
final SQLTableElement marge = new SQLTableElement(fieldMarge, BigDecimal.class, editorMarge); |
marge.setEditable(false); |
marge.setRenderer(renderer); |
marge.setRenderer(new DeviseTableCellRenderer()); |
list.add(marge); |
SQLRowValues defautRow = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable())); |
159,17 → 154,6 |
ToolTipManager.sharedInstance().unregisterComponent(this.table); |
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader()); |
this.table.readState(); |
Map<String, Boolean> mapCustom = getCustomVisibilityMap(); |
if (mapCustom != null) { |
for (String string : mapCustom.keySet()) { |
setColumnVisible(model.getColumnForField(string), mapCustom.get(string)); |
} |
} |
this.table.writeState(); |
// Autocompletion |
// AutoCompletionManager m = new AutoCompletionManager(tableElementNom, |
// ((ComptaPropsConfiguration) |
230,19 → 214,6 |
}); |
} |
protected void setColumnVisible(int col, boolean visible) { |
if (col >= 0) { |
XTableColumnModel columnModel = this.table.getColumnModel(); |
columnModel.setColumnVisible(columnModel.getColumnByModelIndex(col), visible); |
} |
} |
public static Map<String, Boolean> map = new HashMap<String, Boolean>(); |
protected Map<String, Boolean> getCustomVisibilityMap() { |
return map; |
} |
/** |
* |
*/ |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/table/FacturationCommandeTable.java |
---|
20,7 → 20,6 |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.UndefinedRowValuesCache; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.request.ComboSQLRequest; |
33,7 → 32,6 |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.table.PercentTableCellRenderer; |
import org.openconcerto.ui.table.TimestampTableCellEditor; |
import org.openconcerto.ui.table.XTableColumnModel; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
42,9 → 40,7 |
import java.math.BigDecimal; |
import java.sql.Date; |
import java.sql.Timestamp; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
import java.util.Vector; |
import javax.swing.JButton; |
59,12 → 55,6 |
private RowValuesTableModel model; |
private SQLComponent comp; |
public static Map<String, Boolean> map = new HashMap<String, Boolean>(); |
protected Map<String, Boolean> getCustomVisibilityMap() { |
return map; |
} |
public FacturationCommandeTable(SQLComponent comp) { |
this.comp = comp; |
init(); |
99,7 → 89,6 |
final SQLTableElement comptant = new SQLTableElement(e.getTable().getField("COMPTANT")); |
list.add(comptant); |
// TODO fix return value of timestamp if not show hour return date object |
final SQLTableElement date = new SQLTableElement(e.getTable().getField("DATE_PREVISIONNELLE"), Date.class, new TimestampTableCellEditor(false) { |
@Override |
public Object getCellEditorValue() { |
121,21 → 110,30 |
ToolTipManager.sharedInstance().unregisterComponent(this.table); |
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader()); |
Map<String, Boolean> mapCustom = getCustomVisibilityMap(); |
if (mapCustom != null) { |
for (String string : mapCustom.keySet()) { |
setColumnVisible(model.getColumnForField(string), mapCustom.get(string)); |
} |
} |
// Autocompletion |
// AutoCompletionManager m = new AutoCompletionManager(tableElementNom, |
// ((ComptaPropsConfiguration) |
// Configuration.getInstance()).getSQLBaseSociete().getField("ECHANTILLON.NOM"), this.table, |
// this.table.getRowValuesTableModel()); |
// m.fill("NOM", "NOM"); |
// m.fill("PV_HT", "PV_HT"); |
} |
// // Calcul automatique du total HT |
// qteElement.addModificationListener(this.totalHT); |
// this.pvHT.addModificationListener(this.totalHT); |
// this.totalHT.setModifier(new CellDynamicModifier() { |
// public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) { |
// System.out.println("Compute totalHT"); |
// |
// int qte = Integer.parseInt(row.getObject("QTE").toString()); |
// BigDecimal f = row.getBigDecimal("PV_HT"); |
// BigDecimal r = f.multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION); |
// return r; |
// } |
// |
// }); |
protected void setColumnVisible(int col, boolean visible) { |
if (col >= 0) { |
XTableColumnModel columnModel = this.table.getColumnModel(); |
columnModel.setColumnVisible(columnModel.getColumnByModelIndex(col), visible); |
} |
} |
/** |
* |
154,7 → 152,7 |
this.add(new JLabel("Ajouter un terme"), c); |
final ElementComboBox boxCat = new ElementComboBox(); |
final SQLElement element = getSQLElement(); |
final SQLElement element = Configuration.getInstance().getDirectory().getElement("FACTURATION_COMMANDE_CLIENT"); |
ComboSQLRequest req = element.getComboRequest(true); |
req.setWhere(new Where(element.getTable().getField("CHOICE"), "=", Boolean.TRUE)); |
boxCat.init(element, req); |
180,13 → 178,10 |
return; |
} |
final SQLTable table2 = getSQLElement().getTable(); |
SQLRowValues rowVals = new SQLRowValues(table2); |
if (table2.getName().equals("FACTURATION_COMMANDE_CLIENT")) { |
if (comp != null && comp.getSelectedID() > 1) { |
SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("FACTURATION_COMMANDE_CLIENT")); |
if (comp.getSelectedID() > 1) { |
rowVals.put("ID_COMMANDE_CLIENT", comp.getSelectedID()); |
} |
} |
rowVals.put("NOM", rowCat.getObject("NOM")); |
rowVals.put("ID_TYPE_REGLEMENT", rowCat.getObject("ID_TYPE_REGLEMENT")); |
rowVals.put("AJOURS", rowCat.getObject("AJOURS")); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/CommandeSQLElement.java |
---|
16,7 → 16,6 |
import org.openconcerto.erp.config.Gestion; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.edm.AttachmentAction; |
import org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent; |
import org.openconcerto.erp.core.supplychain.order.component.SaisieAchatSQLComponent; |
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent; |
63,12 → 62,6 |
public CommandeSQLElement() { |
super("COMMANDE", "une commande fournisseur", "commandes fournisseur"); |
if (getTable().contains("ATTACHMENTS")) { |
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true); |
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
getRowActions().add(actionAttachment); |
} |
getRowActions().addAll(new MouseSheetXmlListeListener(CommandeXmlSheet.class).getRowActions()); |
// Transfert vers BR |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/FactureFournisseurSQLElement.java |
---|
14,7 → 14,6 |
package org.openconcerto.erp.core.supplychain.order.element; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement; |
import org.openconcerto.erp.core.edm.AttachmentAction; |
import org.openconcerto.erp.core.supplychain.order.component.FactureFournisseurSQLComponent; |
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet; |
22,7 → 21,6 |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.model.FieldPath; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.graph.Path; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanel; |
76,12 → 74,7 |
} |
}; |
getRowActions().add(actionClone); |
final SQLTable tableNum = getTable().getTable("NUMEROTATION_AUTO"); |
// incrémentation du numéro auto |
if (tableNum.contains("FACTURE_FOURNISSEUR_START")) { |
NumerotationAutoSQLElement.addClass(this.getClass(), "FACTURE_FOURNISSEUR"); |
} |
} |
@Override |
public Set<String> getReadOnlyFields() { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/FactureFournisseurSQLComponent.java |
---|
16,7 → 16,6 |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement; |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.core.common.ui.TotalPanel; |
30,6 → 29,7 |
import org.openconcerto.erp.panel.PanelOOSQLComponent; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.DefaultElementSQLObject; |
import org.openconcerto.sql.element.ElementSQLObject; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLBackgroundTableCache; |
41,19 → 41,16 |
import org.openconcerto.sql.preferences.SQLPreferences; |
import org.openconcerto.sql.request.ComboSQLRequest; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.sql.sqlobject.JUniqueTextField; |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox; |
import org.openconcerto.sql.users.UserManager; |
import org.openconcerto.sql.view.list.RowValuesTable; |
import org.openconcerto.sql.view.list.RowValuesTableModel; |
import org.openconcerto.ui.AutoHideListener; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.FormLayouter; |
import org.openconcerto.ui.JDate; |
import org.openconcerto.ui.TitledSeparator; |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.ui.preferences.DefaultProps; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.checks.ValidState; |
import org.openconcerto.utils.text.SimpleDocumentListener; |
import java.awt.Color; |
63,8 → 60,6 |
import java.beans.PropertyChangeListener; |
import java.math.BigDecimal; |
import java.sql.SQLException; |
import java.util.Arrays; |
import java.util.Date; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
73,7 → 68,6 |
import javax.swing.JOptionPane; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.JTabbedPane; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
import javax.swing.SwingUtilities; |
89,8 → 83,7 |
private ElementComboBox fourn = new ElementComboBox(); |
private ElementComboBox comptePCE = new ElementComboBox(); |
private ElementComboBox avoirFourn = new ElementComboBox(); |
private ElementComboBox avoirFourn2 = new ElementComboBox(); |
private DefaultElementSQLObject compAdr; |
private PanelOOSQLComponent panelOO; |
final JPanel panelAdrSpec = new JPanel(new GridBagLayout()); |
private JDate dateCommande = new JDate(); |
104,9 → 97,15 |
public void propertyChange(PropertyChangeEvent evt) { |
final SQLRow rowFourn = FactureFournisseurSQLComponent.this.fourn.getRequest().getPrimaryTable().getRow(FactureFournisseurSQLComponent.this.fourn.getWantedID()); |
if ((getMode() == Mode.INSERTION || !isFilling()) && rowFourn != null && !rowFourn.isUndefined()) { |
SQLRow rowFourn = fourn.getRequest().getPrimaryTable().getRow(fourn.getWantedID()); |
if (!isFilling() && rowFourn != null && !rowFourn.isUndefined()) { |
// SQLRow rowCharge = rowFourn.getForeign("ID_COMPTE_PCE_CHARGE"); |
// if (rowCharge != null && !rowCharge.isUndefined()) { |
// compteSel.setValue(rowCharge); |
// } |
int idModeRegl = rowFourn.getInt("ID_MODE_REGLEMENT"); |
if (idModeRegl > 1 && FactureFournisseurSQLComponent.this.eltModeRegl != null && getMode() == Mode.INSERTION) { |
SQLElement sqlEltModeRegl = getElement().getDirectory().getElement("MODE_REGLEMENT"); |
114,8 → 113,9 |
SQLRowValues rowVals = rowModeRegl.createUpdateRow(); |
rowVals.clearPrimaryKeys(); |
FactureFournisseurSQLComponent.this.eltModeRegl.setValue(rowVals); |
System.err.println("Select Mode regl " + idModeRegl); |
} |
// } |
} |
} |
139,79 → 139,21 |
return s; |
} |
@Override |
public synchronized ValidState getValidState() { |
if (getTable().contains("ID_COMPTE_PCE") && getTable().contains("ID_TYPE_CMD") && getTable().getTable("FACTURE_FOURNISSEUR_ELEMENT").contains("ID_COMPTE_PCE")) { |
SQLRequestComboBox boxCpt = (SQLRequestComboBox) getView("ID_COMPTE_PCE").getComp(); |
final SQLRow selectedCpt = boxCpt.getSelectedRow(); |
if (selectedCpt == null || selectedCpt.isUndefined()) { |
RowValuesTableModel tableRow = this.table.getRowValuesTable().getRowValuesTableModel(); |
for (int i = 0; i < tableRow.getRowCount(); i++) { |
SQLRowValues rowVals = tableRow.getRowValuesAt(i); |
if (rowVals.getInt("QTE") != 0 && (rowVals.getObject("ID_COMPTE_PCE") == null || rowVals.isForeignEmpty("ID_COMPTE_PCE"))) { |
return ValidState.create(false, "Aucun compte global sélectionné et une ligne avec une quantité > 0 n'est pas affectée à un compte!"); |
} |
} |
} |
} |
return super.getValidState(); |
} |
private JUniqueTextField numero; |
public void addViews() { |
this.setLayout(new GridBagLayout()); |
final GridBagConstraints c = new DefaultGridBagConstraints(); |
if (getTable().getTable("NUMEROTATION_AUTO").contains("FACTURE_FOURNISSEUR_START")) { |
this.numero = new JUniqueTextField(35) { |
@Override |
public String getAutoRefreshNumber() { |
if (getMode() == Mode.INSERTION) { |
final Date date = FactureFournisseurSQLComponent.this.dateCommande.getDate(); |
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), date == null ? new Date() : date); |
} else { |
return null; |
} |
} |
}; |
this.dateCommande.addValueListener(new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
if (!isFilling() && FactureFournisseurSQLComponent.this.dateCommande.getValue() != null) { |
final String nextNumero = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), FactureFournisseurSQLComponent.this.dateCommande.getValue()); |
if (FactureFournisseurSQLComponent.this.numero.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(FactureFournisseurSQLComponent.this.numero.getText())) { |
int answer = JOptionPane.showConfirmDialog(FactureFournisseurSQLComponent.this, "Voulez vous actualiser le numéro de la facture?", "Changement du numéro de facture", |
JOptionPane.YES_NO_OPTION); |
if (answer == JOptionPane.NO_OPTION) { |
return; |
} |
} |
FactureFournisseurSQLComponent.this.numero.setText(nextNumero); |
} |
} |
}); |
} else { |
this.numero = new JUniqueTextField(35); |
} |
// Numero du commande |
c.gridx = 0; |
c.weightx = 0; |
this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c); |
JTextField numero = new JTextField(25); |
c.gridx++; |
c.weightx = 1; |
c.fill = GridBagConstraints.NONE; |
DefaultGridBagConstraints.lockMinimumSize(this.numero); |
this.add(this.numero, c); |
DefaultGridBagConstraints.lockMinimumSize(numero); |
this.add(numero, c); |
// Date |
JLabel labelDate = new JLabel(getLabelFor("DATE")); |
223,14 → 165,14 |
c.gridx++; |
c.fill = GridBagConstraints.NONE; |
this.add(this.dateCommande, c); |
this.add(dateCommande, c); |
this.dateCommande.addValueListener(new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
if (!isFilling() && FactureFournisseurSQLComponent.this.dateCommande.getValue() != null) { |
FactureFournisseurSQLComponent.this.table.setDateDevise(FactureFournisseurSQLComponent.this.dateCommande.getValue()); |
if (!isFilling() && dateCommande.getValue() != null) { |
table.setDateDevise(dateCommande.getValue()); |
updateLabelTauxConversion(); |
} |
} |
251,23 → 193,23 |
this.add(this.fourn, c); |
addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR"); |
this.fourn.addModelListener("wantedID", new PropertyChangeListener() { |
fourn.addModelListener("wantedID", new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
int wantedID = FactureFournisseurSQLComponent.this.fourn.getWantedID(); |
int wantedID = fourn.getWantedID(); |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) { |
final SQLRow rowF = getTable().getForeignTable("ID_FOURNISSEUR").getRow(wantedID); |
if (rowF.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowF.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) { |
FactureFournisseurSQLComponent.this.table.setRowCatComptable(rowF.getForeign("ID_CATEGORIE_COMPTABLE")); |
table.setRowCatComptable(rowF.getForeign("ID_CATEGORIE_COMPTABLE")); |
} else { |
FactureFournisseurSQLComponent.this.table.setRowCatComptable(null); |
table.setRowCatComptable(null); |
} |
} else { |
FactureFournisseurSQLComponent.this.table.setRowCatComptable(null); |
table.setRowCatComptable(null); |
} |
} |
}); |
308,8 → 250,8 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
FactureFournisseurSQLComponent.this.table.setFournisseur(FactureFournisseurSQLComponent.this.fourn.getSelectedRow()); |
SQLRow row = FactureFournisseurSQLComponent.this.fourn.getSelectedRow(); |
table.setFournisseur(fourn.getSelectedRow()); |
SQLRow row = fourn.getSelectedRow(); |
if (!isFilling()) { |
if (row != null && !row.isUndefined() && !row.isForeignEmpty("ID_DEVISE")) { |
boxDevise.setValue(row.getForeignID("ID_DEVISE")); |
317,10 → 259,9 |
} |
if (row != null && !row.isUndefined()) { |
FactureFournisseurSQLComponent.this.avoirFourn.getRequest() |
.setWhere(new Where(FactureFournisseurSQLComponent.this.avoirFourn.getRequest().getPrimaryTable().getField("ID_FOURNISSEUR"), "=", row.getID())); |
avoirFourn.getRequest().setWhere(new Where(avoirFourn.getRequest().getPrimaryTable().getField("ID_FOURNISSEUR"), "=", row.getID())); |
} else { |
FactureFournisseurSQLComponent.this.avoirFourn.getRequest().setWhere(null); |
avoirFourn.getRequest().setWhere(null); |
} |
} |
}); |
414,21 → 355,21 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
FactureFournisseurSQLComponent.this.table.setDevise(boxDevise.getSelectedRow()); |
table.setDevise(boxDevise.getSelectedRow()); |
updateLabelTauxConversion(); |
} |
}); |
this.fieldTaux.getDocument().addDocumentListener(new SimpleDocumentListener() { |
fieldTaux.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
BigDecimal tauxConversion = null; |
if (FactureFournisseurSQLComponent.this.fieldTaux.getText().trim().length() > 0) { |
tauxConversion = new BigDecimal(FactureFournisseurSQLComponent.this.fieldTaux.getText()); |
if (fieldTaux.getText().trim().length() > 0) { |
tauxConversion = new BigDecimal(fieldTaux.getText()); |
} |
FactureFournisseurSQLComponent.this.table.setTauxConversion(tauxConversion); |
table.setTauxConversion(tauxConversion); |
updateLabelTauxConversion(); |
} |
}); |
438,13 → 379,13 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
FactureFournisseurSQLComponent.this.table.setFournisseur(FactureFournisseurSQLComponent.this.fourn.getSelectedRow()); |
table.setFournisseur(fourn.getSelectedRow()); |
if (!isFilling()) { |
SQLRow row = FactureFournisseurSQLComponent.this.fourn.getSelectedRow(); |
SQLRow row = fourn.getSelectedRow(); |
if (row != null && !row.isUndefined()) { |
row.fetchValues(); |
if (!row.isForeignEmpty("ID_COMPTE_PCE_CHARGE")) { |
FactureFournisseurSQLComponent.this.comptePCE.setValue(row.getForeign("ID_COMPTE_PCE_CHARGE")); |
comptePCE.setValue(row.getForeign("ID_COMPTE_PCE_CHARGE")); |
} |
} |
} |
454,13 → 395,18 |
c.gridy++; |
c.weighty = 0; |
this.add(getBottomPanel(), c); |
ModeDeReglementSQLComponent modeReglComp; |
ModeDeReglementSQLComponent modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild(); |
modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild(); |
modeReglComp.addDateCompListener(this.dateCommande); |
// Modèle, visualiser, imprimer.. |
c.gridx = 0; |
c.gridy++; |
c.fill = GridBagConstraints.HORIZONTAL; |
c.anchor = GridBagConstraints.WEST; |
c.gridx = 0; |
c.gridy++; |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.SOUTHEAST; |
c.gridwidth = GridBagConstraints.REMAINDER; |
469,8 → 415,8 |
this.add(this.panelOO, c); |
addSQLObject(textNom, "NOM"); |
addRequiredSQLObject(this.dateCommande, "DATE"); |
addRequiredSQLObject(this.numero, "NUMERO"); |
addRequiredSQLObject(dateCommande, "DATE"); |
addRequiredSQLObject(numero, "NUMERO"); |
addSQLObject(this.infos, "INFOS"); |
DefaultGridBagConstraints.lockMinimumSize(this.fourn); |
493,80 → 439,60 |
final JPanel panel = new JPanel(new GridBagLayout()); |
final GridBagConstraints c = new DefaultGridBagConstraints(); |
JTabbedPane tabs = new JTabbedPane(); |
JPanel mainBottomPanel = new JPanel(); |
mainBottomPanel.setOpaque(false); |
tabs.add(mainBottomPanel, "Règlements et caractéristiques"); |
final JScrollPane scrollPane = new JScrollPane(this.infos); |
scrollPane.setBorder(null); |
tabs.add(scrollPane, getLabelFor("INFOS")); |
// Colonne 1 : Infos |
c.gridx = 0; |
c.weightx = 1; |
c.anchor = GridBagConstraints.WEST; |
c.fill = GridBagConstraints.BOTH; |
panel.add(tabs, c); |
c.fill = GridBagConstraints.HORIZONTAL; |
mainBottomPanel.setLayout(new GridBagLayout()); |
GridBagConstraints cMainBottomPanel = new DefaultGridBagConstraints(); |
panel.add(new TitledSeparator(getLabelFor("INFOS")), c); |
// Colonne 1 : Infos |
c.gridy++; |
c.weighty = 0; |
c.weightx = 1; |
c.fill = GridBagConstraints.BOTH; |
final JScrollPane scrollPane = new JScrollPane(this.infos); |
scrollPane.setBorder(null); |
panel.add(scrollPane, c); |
cMainBottomPanel.weighty = 0; |
cMainBottomPanel.weightx = 0; |
cMainBottomPanel.fill = GridBagConstraints.BOTH; |
this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP); |
this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT"); |
c.gridx++; |
c.fill = GridBagConstraints.NONE; |
c.weightx = 1; |
c.weighty = 1; |
this.eltModeRegl.setOpaque(false); |
mainBottomPanel.add(this.eltModeRegl, cMainBottomPanel); |
eltModeRegl.setOpaque(false); |
panel.add(eltModeRegl, c); |
// Colonne 2 : Poids & autres |
JPanel column2 = new JPanel(); |
column2.setOpaque(false); |
cMainBottomPanel.gridx++; |
cMainBottomPanel.weightx = 0; |
mainBottomPanel.add(column2, cMainBottomPanel); |
DefaultProps props = DefaultNXProps.getInstance(); |
Boolean b = props.getBooleanValue("ArticleShowPoids"); |
final JTextField textPoidsTotal = new JTextField(8); |
JTextField poids = new JTextField(); |
if (b) { |
final JPanel panelPoids = new JPanel(); |
column2.setLayout(new GridBagLayout()); |
GridBagConstraints c2 = new DefaultGridBagConstraints(); |
panelPoids.add(new JLabel(getLabelFor("T_POIDS")), c); |
c2.weightx = 0; |
c2.weighty = 0; |
c2.gridwidth = 1; |
c2.gridheight = 1; |
c2.fill = GridBagConstraints.HORIZONTAL; |
c2.anchor = GridBagConstraints.NORTHEAST; |
// Poids |
DefaultProps props = DefaultNXProps.getInstance(); |
Boolean poidsVisible = props.getBooleanValue("ArticleShowPoids"); |
if (poidsVisible) { |
column2.add(new JLabel(getLabelFor("T_POIDS"), SwingConstants.RIGHT), c2); |
final JTextField textPoidsTotal = new JTextField(8); |
textPoidsTotal.setEnabled(false); |
textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT); |
textPoidsTotal.setDisabledTextColor(Color.BLACK); |
c2.weightx = 1; |
c2.gridx++; |
column2.add(textPoidsTotal, c2); |
DefaultGridBagConstraints.lockMinimumSize(textPoidsTotal); |
addSQLObject(textPoidsTotal, "T_POIDS"); |
this.table.getModel().addTableModelListener(new TableModelListener() { |
panelPoids.add(textPoidsTotal, c); |
public void tableChanged(TableModelEvent e) { |
textPoidsTotal.setText(String.valueOf(FactureFournisseurSQLComponent.this.table.getPoidsTotal())); |
} |
}); |
c.gridx++; |
c.gridy = 0; |
c.weightx = 0; |
c.weighty = 0; |
c.gridwidth = 1; |
c.gridheight = 2; |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.NORTHEAST; |
panel.add(panelPoids, c); |
DefaultGridBagConstraints.lockMinimumSize(panelPoids); |
addSQLObject(textPoidsTotal, "T_POIDS"); |
} else { |
addSQLObject(new JTextField(), "T_POIDS"); |
addSQLObject(poids, "T_POIDS"); |
} |
DeviseField textPortHT = new DeviseField(); |
573,75 → 499,52 |
ElementComboBox comboTaxePort = new ElementComboBox(); |
DeviseField textRemiseHT = new DeviseField(); |
final JPanel panelPoids = new JPanel(new GridBagLayout()); |
GridBagConstraints cPort = new DefaultGridBagConstraints(); |
if (getTable().contains("PORT_HT")) { |
// Port HT |
addSQLObject(textPortHT, "PORT_HT"); |
c2.gridx = 0; |
c2.gridy++; |
c2.weightx = 0; |
column2.add(new JLabel(getLabelFor("PORT_HT"), SwingConstants.RIGHT), c2); |
cPort.gridx = 0; |
cPort.weightx = 0; |
panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort); |
textPortHT.setHorizontalAlignment(JTextField.RIGHT); |
c2.gridx++; |
c2.weightx = 1; |
column2.add(textPortHT, c2); |
// TVA sur port |
c2.gridy++; |
c2.gridx = 0; |
c2.weightx = 0; |
cPort.gridx++; |
cPort.weightx = 1; |
panelPoids.add(textPortHT, cPort); |
cPort.gridy++; |
cPort.gridx = 0; |
cPort.weightx = 0; |
addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT"); |
column2.add(new JLabel(getLabelFor("ID_TAXE_PORT"), SwingConstants.RIGHT), c2); |
c2.gridx++; |
c2.weightx = 0; |
column2.add(comboTaxePort, c2); |
// Remise HT |
panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT")), cPort); |
cPort.gridx++; |
cPort.weightx = 0; |
panelPoids.add(comboTaxePort, cPort); |
c.gridx++; |
c.gridy = 0; |
c.weightx = 0; |
c.weighty = 0; |
c.gridwidth = 1; |
c.gridheight = 2; |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.NORTHEAST; |
panel.add(panelPoids, c); |
DefaultGridBagConstraints.lockMinimumSize(panelPoids); |
addSQLObject(textRemiseHT, "REMISE_HT"); |
c2.gridx = 0; |
c2.gridy++; |
c2.weightx = 0; |
column2.add(new JLabel(getLabelFor("REMISE_HT"), SwingConstants.RIGHT), c2); |
cPort.gridy++; |
cPort.gridx = 0; |
cPort.fill = GridBagConstraints.NONE; |
cPort.weightx = 0; |
panelPoids.add(new JLabel(getLabelFor("REMISE_HT")), cPort); |
textRemiseHT.setHorizontalAlignment(JTextField.RIGHT); |
c2.gridx++; |
c2.weightx = 1; |
column2.add(textRemiseHT, c2); |
cPort.gridx++; |
cPort.weightx = 1; |
panelPoids.add(textRemiseHT, cPort); |
} |
final JTextField textTvaAdujs; |
if (getTable().contains("TVA_ADJUSTMENT")) { |
textTvaAdujs = new JTextField(15); |
final JLabel labelTvaAdujst = new JLabel(getLabelFor("TVA_ADJUSTMENT"), SwingConstants.RIGHT); |
c2.gridx = 0; |
c2.gridy++; |
c2.weightx = 0; |
column2.add(labelTvaAdujst, c2); |
c2.gridx++; |
c2.weightx = 1; |
column2.add(textTvaAdujs, c2); |
addView(textTvaAdujs, "TVA_ADJUSTMENT"); |
// Total |
DefaultGridBagConstraints.lockMinimumSize(textTvaAdujs); |
} else { |
textTvaAdujs = null; |
} |
c2.gridy++; |
c2.gridx = 0; |
column2.add(new JLabel("Avoirs", SwingConstants.RIGHT), c2); |
c2.gridx++; |
c2.fill = GridBagConstraints.NONE; |
c2.anchor = GridBagConstraints.EAST; |
column2.add(createPanelAvoir(), c2); |
c2.gridy++; |
column2.add(getModuleTotalPanel(), c2); |
c2.gridy++; |
JPanel filler = new JPanel(); |
filler.setOpaque(false); |
c2.weighty = 1; |
column2.add(filler, c2); |
// Colonne 4 Total |
DeviseField fieldHT = new DeviseField(); |
DeviseField fieldEco = new DeviseField(); |
DeviseField fieldTVA = new DeviseField(); |
649,7 → 552,7 |
DeviseField fieldService = new DeviseField(); |
fieldHT.setOpaque(false); |
fieldTVA.setOpaque(false); |
this.fieldTTC.setOpaque(false); |
fieldTTC.setOpaque(false); |
fieldService.setOpaque(false); |
addRequiredSQLObject(fieldDevise, "T_DEVISE"); |
addRequiredSQLObject(fieldEco, "T_ECO_CONTRIBUTION"); |
656,10 → 559,10 |
addRequiredSQLObject(fieldHT, "T_HT"); |
addRequiredSQLObject(fieldTVA, "T_TVA"); |
addRequiredSQLObject(this.fieldTTC, "T_TTC"); |
addRequiredSQLObject(fieldTTC, "T_TTC"); |
addRequiredSQLObject(fieldService, "T_SERVICE"); |
this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() { |
fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
refreshText(); |
675,9 → 578,21 |
this.allowEditable("T_SERVICE", false); |
this.allowEditable("T_POIDS", false); |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, this.fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null, |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null, |
(getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null), null); |
if (textTvaAdujs != null) { |
if (getTable().contains("TVA_ADJUSTMENT")) { |
final JTextField textTvaAdujs = new JTextField(15); |
JLabel labelTvaAdujst = new JLabel(getLabelFor("TVA_ADJUSTMENT")); |
labelTvaAdujst.setHorizontalAlignment(SwingConstants.RIGHT); |
cPort.gridx = 0; |
cPort.gridy++; |
panelPoids.add(labelTvaAdujst, cPort); |
cPort.gridx++; |
panelPoids.add(textTvaAdujs, cPort); |
addView(textTvaAdujs, "TVA_ADJUSTMENT"); |
totalTTC.setTextFixTVA(textTvaAdujs); |
textTvaAdujs.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
706,23 → 621,44 |
totalTTC.updateTotal(); |
} |
}); |
DefaultGridBagConstraints.lockMinimumSize(textTvaAdujs); |
} |
c.gridx++; |
c.gridy = 0; |
c.gridwidth = 1; |
c.gridheight = 1; |
c.gridy--; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.gridheight = 2; |
c.anchor = GridBagConstraints.NORTHEAST; |
c.fill = GridBagConstraints.HORIZONTAL; |
c.fill = GridBagConstraints.BOTH; |
c.weighty = 0; |
DefaultGridBagConstraints.lockMinimumSize(totalTTC); |
panel.add(totalTTC, c); |
c.gridy += 3; |
c.gridheight = 1; |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.EAST; |
panel.add(createPanelAvoir(), c); |
c.gridy += 4; |
c.gridheight = 2; |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.EAST; |
panel.add(getModuleTotalPanel(), c); |
table.getModel().addTableModelListener(new TableModelListener() { |
public void tableChanged(TableModelEvent e) { |
textPoidsTotal.setText(String.valueOf(table.getPoidsTotal())); |
} |
}); |
this.fourn.addModelListener("wantedID", new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
final SQLRow selectedRow2 = FactureFournisseurSQLComponent.this.fourn.getSelectedRow(); |
final SQLRow selectedRow2 = fourn.getSelectedRow(); |
if (selectedRow2 != null && !selectedRow2.isUndefined()) { |
totalTTC.setIntraComm(selectedRow2.getBoolean("UE")); |
} else { |
750,6 → 686,7 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
// TODO Raccord de méthode auto-généré |
totalTTC.updateTotal(); |
} |
}); |
780,24 → 717,6 |
public int insert(SQLRow order) { |
final SQLTable tableNum = getTable().getTable("NUMEROTATION_AUTO"); |
// incrémentation du numéro auto |
if (tableNum.contains("FACTURE_FOURNISSEUR_START") && NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.numero.getText().trim())) { |
SQLRowValues rowVals = new SQLRowValues(tableNum); |
final SQLRow rowNumAuto = tableNum.getRow(2); |
if (rowNumAuto.getObject("FACTURE_FOURNISSEUR_START") != null) { |
int val = rowNumAuto.getInt("FACTURE_FOURNISSEUR_START"); |
val++; |
rowVals.put("FACTURE_FOURNISSEUR_START", new Integer(val)); |
try { |
rowVals.update(2); |
} catch (SQLException e) { |
e.printStackTrace(); |
} |
} |
} |
int idFacture = getSelectedID(); |
idFacture = super.insert(order); |
this.table.updateField("ID_FACTURE_FOURNISSEUR", idFacture); |
855,16 → 774,12 |
} |
public void commitAvoir(SQLRow rowFactureOld, SQLRow rowFacture) { |
try { |
List<String> fieldsAvoir = Arrays.asList("ID_AVOIR_FOURNISSEUR", "ID_AVOIR_FOURNISSEUR_2"); |
for (String field : fieldsAvoir) { |
if (rowFactureOld != null && rowFactureOld.getObject("ID_AVOIR_FOURNISSEUR") != null && !rowFactureOld.isForeignEmpty("ID_AVOIR_FOURNISSEUR") |
&& (rowFacture.getObject("ID_AVOIR_FOURNISSEUR") == null || rowFacture.isForeignEmpty("ID_AVOIR_FOURNISSEUR"))) { |
if (rowFactureOld != null && rowFactureOld.getObject(field) != null && !rowFactureOld.isForeignEmpty(field) |
&& (rowFacture.getObject(field) == null || rowFacture.isForeignEmpty(field))) { |
SQLRow rowAvoir = rowFactureOld.getForeignRow("ID_AVOIR_FOURNISSEUR"); |
SQLRow rowAvoir = rowFactureOld.getForeignRow(field); |
SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow(); |
// Soldé |
875,9 → 790,9 |
} |
// on solde l'avoir |
if (rowFacture.getObject(field) != null && !rowFacture.isForeignEmpty(field)) { |
if (rowFacture.getObject("ID_AVOIR_FOURNISSEUR") != null && !rowFacture.isForeignEmpty("ID_AVOIR_FOURNISSEUR")) { |
SQLRow rowAvoir = rowFacture.getForeignRow(field); |
SQLRow rowAvoir = rowFacture.getForeignRow("ID_AVOIR_FOURNISSEUR"); |
SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow(); |
rowVals.put("SOLDE", Boolean.TRUE); |
885,7 → 800,6 |
rowVals.update(); |
} |
} |
} catch (SQLException e) { |
ExceptionHandler.handle("Erreur lors la mise à jour de l'avoir associée!", e); |
} |
915,11 → 829,6 |
if (rowsComm != null) { |
rowVals.put("ID_COMMERCIAL", rowsComm.getID()); |
} |
if (getTable().getTable("NUMEROTATION_AUTO").contains("FACTURE_FOURNISSEUR_START")) { |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date())); |
} |
rowVals.put("T_HT", Long.valueOf(0)); |
rowVals.put("T_SERVICE", Long.valueOf(0)); |
rowVals.put("T_DEVISE", Long.valueOf(0)); |
962,43 → 871,19 |
cA.gridx++; |
cA.weightx = 0; |
panelAvoir.add(this.textNetAPayer, cA); |
addView(this.textNetAPayer, "NET_A_PAYER"); |
addView(textNetAPayer, "NET_A_PAYER"); |
this.textNetAPayer.setHorizontalAlignment(SwingConstants.RIGHT); |
JLabel labelAvoir2 = new JLabel(getLabelFor("ID_AVOIR_FOURNISSEUR_2")); |
labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT); |
cA.gridx = 0; |
cA.gridy++; |
cA.weightx = 1; |
labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT); |
panelAvoir.add(labelAvoir2, cA); |
cA.weightx = 0; |
cA.gridx++; |
this.avoirFourn2 = new ElementComboBox(); |
this.avoirFourn2.setAddIconVisible(false); |
panelAvoir.add(this.avoirFourn2, cA); |
addView(this.avoirFourn2, "ID_AVOIR_FOURNISSEUR_2"); |
addView(this.avoirFourn, "ID_AVOIR_FOURNISSEUR"); |
addView(this.avoirTTC, "AVOIR_TTC"); |
this.avoirFourn.addModelListener("wantedID", new PropertyChangeListener() { |
addView(avoirTTC, "AVOIR_TTC"); |
this.avoirFourn.addValueListener(new PropertyChangeListener() { |
public void propertyChange(PropertyChangeEvent evt) { |
if (!isFilling()) { |
refreshText(); |
} |
} |
}); |
this.avoirFourn2.addModelListener("wantedID", new PropertyChangeListener() { |
public void propertyChange(PropertyChangeEvent evt) { |
if (!isFilling()) { |
refreshText(); |
} |
} |
}); |
return panelAvoir; |
} |
1006,16 → 891,16 |
Number n = this.fieldTTC.getValue(); |
long totalAvoirTTC = 0; |
long netAPayer = 0; |
long ttc = 0; |
if (n != null) { |
netAPayer = n.longValue(); |
ttc = n.longValue(); |
} |
List<ElementComboBox> boxAvoir = Arrays.asList(this.avoirFourn, this.avoirFourn2); |
for (ElementComboBox elementComboBox : boxAvoir) { |
if (elementComboBox.getWantedID() > 1) { |
if (this.avoirFourn.getSelectedId() > 1) { |
SQLTable tableAvoir = getTable().getForeignTable("ID_AVOIR_FOURNISSEUR"); |
if (n != null) { |
SQLRow rowAvoir = tableAvoir.getRow(elementComboBox.getWantedID()); |
SQLRow rowAvoir = tableAvoir.getRow(this.avoirFourn.getSelectedId()); |
long totalAvoir = ((Number) rowAvoir.getObject("MONTANT_TTC")).longValue(); |
if (getSelectedID() > 1) { |
SQLRow row = getTable().getRow(getSelectedID()); |
1025,10 → 910,10 |
} |
} |
long l = netAPayer - totalAvoir; |
long l = ttc - totalAvoir; |
if (l < 0) { |
l = 0; |
totalAvoirTTC = netAPayer; |
totalAvoirTTC = ttc; |
} else { |
totalAvoirTTC = totalAvoir; |
} |
1035,7 → 920,6 |
netAPayer = l; |
} |
} |
} |
this.textNetAPayer.setValue(netAPayer); |
this.avoirTTC.setValue(totalAvoirTTC); |
1063,7 → 947,15 |
if (!row.isForeignEmpty("ID_COMPTE_PCE")) { |
rowVals.put("ID_COMPTE_PCE", row.getForeignID("ID_COMPTE_PCE")); |
} |
// if (getTable().contains("ID_NUMEROTATION_AUTO")) { |
// rowVals.put("NUMERO", |
// NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new |
// Date(), row.getForeign("ID_NUMEROTATION_AUTO"))); |
// } else { |
// rowVals.put("NUMERO", |
// NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new |
// Date())); |
// } |
rowVals.put("NOM", row.getObject("NOM")); |
this.select(rowVals); |
} |
1078,12 → 970,6 |
SQLRowValues rowVals = rowElt.createUpdateRow(); |
rowVals.clearPrimaryKeys(); |
if (rowVals.getTable().contains("ID_COMMANDE_ELEMENT")) { |
rowVals.putEmptyLink("ID_COMMANDE_ELEMENT"); |
} |
if (rowVals.getTable().contains("ID_BON_RECEPTION_ELEMENT")) { |
rowVals.putEmptyLink("ID_BON_RECEPTION_ELEMENT"); |
} |
this.table.getModel().addRow(rowVals); |
int rowIndex = this.table.getModel().getRowCount() - 1; |
this.table.getModel().fireTableModelModified(rowIndex); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/SaisieAchatSQLComponent.java |
---|
340,7 → 340,7 |
} |
}); |
this.comboAvoir.addModelListener("wantedID", new PropertyChangeListener() { |
this.comboAvoir.addValueListener(new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
refreshText(); |
534,11 → 534,11 |
private void refreshText() { |
Number n = this.montant.getMontantTTC().getValue(); |
if (this.comboAvoir.getWantedID() > 1) { |
if (this.comboAvoir.getSelectedId() > 1) { |
SQLTable tableAvoir = Configuration.getInstance().getDirectory().getElement("AVOIR_FOURNISSEUR").getTable(); |
if (n != null) { |
long ttc = n.longValue(); |
SQLRow rowAvoir = tableAvoir.getRow(this.comboAvoir.getWantedID()); |
SQLRow rowAvoir = tableAvoir.getRow(this.comboAvoir.getSelectedId()); |
long totalAvoir = ((Number) rowAvoir.getObject("MONTANT_TTC")).longValue(); |
this.fieldMontantRegle.setValue(ttc - totalAvoir); |
} else { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/CommandeSQLComponent.java |
---|
95,19 → 95,19 |
public class CommandeSQLComponent extends TransfertBaseSQLComponent { |
protected CommandeItemTable table = new CommandeItemTable(); |
protected PanelOOSQLComponent panelOO; |
private CommandeItemTable table = new CommandeItemTable(); |
private PanelOOSQLComponent panelOO; |
protected JUniqueTextField numeroUniqueCommande; |
protected final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO"); |
protected final ITextArea infos = new ITextArea(3, 3); |
protected ElementComboBox fourn = new ElementComboBox(); |
protected final JCheckBox boxLivrClient = new JCheckBox("Livrer directement le client"); |
protected DefaultElementSQLObject compAdr; |
protected final JPanel panelAdrSpec = new JPanel(new GridBagLayout()); |
private JUniqueTextField numeroUniqueCommande; |
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO"); |
private final ITextArea infos = new ITextArea(3, 3); |
private ElementComboBox fourn = new ElementComboBox(); |
private final JCheckBox boxLivrClient = new JCheckBox("Livrer directement le client"); |
private DefaultElementSQLObject compAdr; |
final JPanel panelAdrSpec = new JPanel(new GridBagLayout()); |
protected ElementComboBox boxAdr; |
protected JDate dateCommande = new JDate(true); |
protected ElementSQLObject componentPrincipaleAdr; |
private JDate dateCommande = new JDate(true); |
private ElementSQLObject componentPrincipaleAdr; |
public CommandeSQLComponent() { |
super(Configuration.getInstance().getDirectory().getElement("COMMANDE")); |
571,7 → 571,7 |
c.anchor = GridBagConstraints.EAST; |
this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c); |
final SQLTextCombo textNom = new SQLTextCombo(); |
final JTextField textNom = new JTextField(); |
c.gridx++; |
c.weightx = 1; |
this.add(textNom, c); |
653,7 → 653,6 |
DefaultGridBagConstraints.lockMinimumSize(this.fourn); |
DefaultGridBagConstraints.lockMinimumSize(commSel); |
this.addView(this.table.getRowValuesTable(), ""); |
} |
protected SQLRowValues getLivraisonAdr(SQLRow rowAffaire) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/AgenceGroup.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/AgenceSQLElement.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLElement.java |
---|
15,12 → 15,10 |
import org.openconcerto.erp.core.edm.AttachmentAction; |
import org.openconcerto.erp.core.reports.history.ui.HistoriqueClientFrame; |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel; |
import org.openconcerto.sql.element.GlobalMapper; |
import org.openconcerto.sql.element.GroupSQLComponent; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.preferences.SQLPreferences; |
import org.openconcerto.sql.request.SQLFieldTranslator; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
75,11 → 73,6 |
if (getTable().contains("GROUPE")) { |
fields.add("GROUPE"); |
} |
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot()); |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) { |
fields.add("ID_CATEGORIE_COMPTABLE"); |
} |
fields.add("SOLDE_COMPTE"); |
fields.add("REMIND_DATE"); |
fields.add("OBSOLETE"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/RelanceSQLElement.java |
---|
15,14 → 15,7 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement; |
import org.openconcerto.erp.config.Log; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement; |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet; |
import org.openconcerto.erp.generationDoc.A4; |
import org.openconcerto.erp.generationDoc.ProgressPrintingFrame; |
import org.openconcerto.erp.generationDoc.gestcomm.FicheRelanceSheet; |
import org.openconcerto.erp.generationDoc.gestcomm.RelanceSheet; |
import org.openconcerto.erp.preferences.PrinterNXProps; |
import org.openconcerto.sql.element.BaseSQLComponent; |
36,8 → 29,6 |
import org.openconcerto.sql.sqlobject.JUniqueTextField; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.RowAction; |
import org.openconcerto.ui.JDate; |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.ui.component.InteractionMode; |
45,160 → 36,23 |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.Window; |
import java.awt.event.ActionEvent; |
import java.awt.print.Paper; |
import java.awt.print.PrinterException; |
import java.awt.print.PrinterJob; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.Calendar; |
import java.util.List; |
import java.util.logging.Level; |
import javax.print.PrintService; |
import javax.print.attribute.Attribute; |
import javax.print.attribute.HashPrintRequestAttributeSet; |
import javax.print.attribute.Size2DSyntax; |
import javax.print.attribute.standard.Copies; |
import javax.print.attribute.standard.MediaPrintableArea; |
import javax.print.attribute.standard.MediaSizeName; |
import javax.swing.AbstractAction; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JSeparator; |
import javax.swing.SwingUtilities; |
import javax.swing.JOptionPane; |
import javax.swing.SwingUtilities; |
public class RelanceSQLElement extends ComptaSQLConfElement { |
public static final String ITEM_TYPE = "type.id"; |
public static final String ITEM_DATE = "date"; |
public static final String ITEM_NUMBER = "number"; |
public static final String ITEM_CUSTOMER = "customer.id"; |
public static final String ITEM_SALES_INVOICE_INPUT = "sales.invoice.input.id"; |
public static final String ITEM_AMOUNT = "amount"; |
public static final String ITEM_INFORMATIONS = "informations"; |
public static final String ITEM_VISUALIZATION = "visualization"; |
public static final String ITEM_PRINT = "impression"; |
private static final double POINTS_PER_INCH = 72.0; |
public RelanceSQLElement() { |
super("RELANCE", "une relance client", "relances clients"); |
RowAction actionShowDoc = new RowAction(new AbstractAction("Voir le document") { |
public void actionPerformed(ActionEvent e) { |
final RelanceSheet s = new RelanceSheet(IListe.get(e).getSelectedRow().asRow().fetchNew(false)); |
s.generate(false, false, ""); |
s.showDocument(); |
} |
}, false) { |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.size() == 1) { |
SQLRowValues rowRelance = selection.get(0); |
boolean isNotMail = !(rowRelance.getForeign("ID_TYPE_LETTRE_RELANCE") == null || rowRelance.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")); |
return isNotMail; |
} |
return false; |
} |
}; |
getRowActions().add(actionShowDoc); |
RowAction actionPrintDoc = new RowAction(new AbstractAction("Imprimer") { |
public void actionPerformed(ActionEvent e) { |
print(e, false); |
} |
}, false) { |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.size() >= 1) { |
boolean isNotMail = true; |
for (SQLRowValues rowRelance : selection) { |
isNotMail &= !(rowRelance.getForeign("ID_TYPE_LETTRE_RELANCE") == null || rowRelance.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")); |
} |
return isNotMail; |
} |
return false; |
} |
}; |
getRowActions().add(actionPrintDoc); |
// Impression |
RowAction actionPrintDocFact = new RowAction(new AbstractAction("Imprimer avec la facture") { |
public void actionPerformed(ActionEvent e) { |
print(e, true); |
} |
}, false) { |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.size() >= 1) { |
boolean isNotMail = true; |
for (SQLRowValues rowRelance : selection) { |
isNotMail &= !(rowRelance.getForeign("ID_TYPE_LETTRE_RELANCE") == null || rowRelance.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")); |
} |
return isNotMail; |
} |
return false; |
} |
}; |
getRowActions().add(actionPrintDocFact); |
// Générer |
RowAction actionGen = new RowAction(new AbstractAction("Générer le document") { |
public void actionPerformed(ActionEvent e) { |
for (SQLRowValues rowVals : IListe.get(e).getSelectedRows()) { |
final RelanceSheet s = new RelanceSheet(rowVals.asRow().fetchNew(false)); |
String printer = PrinterNXProps.getInstance().getStringProperty("RelancePrinter"); |
s.generate(false, true, printer, true); |
s.showDocument(); |
} |
} |
}, false) { |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.size() >= 1) { |
SQLRowValues rowRelance = selection.get(0); |
boolean isNotMail = !(rowRelance.getForeign("ID_TYPE_LETTRE_RELANCE") == null || rowRelance.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")); |
return isNotMail; |
} |
return false; |
} |
}; |
getRowActions().add(actionGen); |
RowAction actionFiche = new RowAction(new AbstractAction("Créer la fiche de relance") { |
public void actionPerformed(ActionEvent e) { |
try { |
FicheRelanceSheet sheet = new FicheRelanceSheet(IListe.get(e).getSelectedRow().asRow().fetchNew(false)); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(true, false, true); |
} catch (Exception ex) { |
ExceptionHandler.handle("Impression impossible", ex); |
} |
} |
}, false) { |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
return (selection.size() == 1); |
} |
}; |
getRowActions().add(actionFiche); |
} |
protected List<String> getListFields() { |
final List<String> l = new ArrayList<String>(); |
l.add("NUMERO"); |
448,103 → 302,4 |
protected String createCode() { |
return this.createCodeOfPackage() + ".chaseletter"; |
} |
public void print(final ActionEvent ev, boolean withInvoice) { |
// |
final IListe ilist = IListe.get(ev); |
String printerName = PrinterNXProps.getInstance().getStringProperty("RelancePrinter"); |
// Printer configuration |
final PrinterJob printJob = PrinterJob.getPrinterJob(); |
// Set the printer |
PrintService myService = null; |
if (printerName != null && printerName.trim().length() > 0) { |
final PrintService[] services = PrinterJob.lookupPrintServices(); |
for (int i = 0; i < services.length; i++) { |
if (services[i].getName().equals(printerName)) { |
myService = services[i]; |
break; |
} |
} |
if (myService != null) { |
try { |
printJob.setPrintService(myService); |
} catch (PrinterException e) { |
Log.get().log(Level.SEVERE, "cannot print", e); |
JOptionPane.showMessageDialog(null, "Imprimante non compatible"); |
return; |
} |
} |
} |
final HashPrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); |
// L'impression est forcée en A4, sur OpenSuse le format est en |
// Letter par défaut alors que l'imprimante est en A4 dans le système |
final MediaSizeName media = MediaSizeName.ISO_A4; |
attributes.add(media); |
Paper paper = new A4(0, 0); |
final MediaPrintableArea printableArea = new MediaPrintableArea((float) (paper.getImageableX() / POINTS_PER_INCH), (float) (paper.getImageableY() / POINTS_PER_INCH), |
(float) (paper.getImageableWidth() / POINTS_PER_INCH), (float) (paper.getImageableHeight() / POINTS_PER_INCH), Size2DSyntax.INCH); |
attributes.add(printableArea); |
attributes.add(new Copies(1)); |
boolean okToPrint = printJob.printDialog(attributes); |
final Attribute attribute = attributes.get(Copies.class); |
if (attribute != null) { |
final Copies attributeCopies = (Copies) attribute; |
final int value = attributeCopies.getValue(); |
printJob.setCopies(value); |
} else { |
printJob.setCopies(1); |
} |
if (okToPrint) { |
Window w = SwingUtilities.getWindowAncestor(ilist); |
final ProgressPrintingFrame pFrame = new ProgressPrintingFrame(w, printJob, "Impression", "Impression en cours", 300); |
// Génération + impression |
final List<SQLRowValues> rows = IListe.get(ev).getSelectedRows(); |
final Thread thread = new Thread() { |
@Override |
public void run() { |
final int size = rows.size(); |
for (int i = 0; i < size; i++) { |
final int index = i; |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
pFrame.setMessage("Document " + (index + 1) + "/" + size); |
pFrame.setProgress((100 * (index + 1)) / size); |
} |
}); |
if (!pFrame.isCancelled()) { |
SQLRowValues r = rows.get(i); |
SQLRow rowRelance = r.asRow().fetchNew(false); |
RelanceSheet s = new RelanceSheet(rowRelance); |
s.printDocument(printJob); |
if (withInvoice) { |
SaisieVenteFactureSQLElement element = getDirectory().getElement(SaisieVenteFactureSQLElement.class); |
final VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(rowRelance.getForeignRow("ID_SAISIE_VENTE_FACTURE")); |
try { |
sheet.getOrCreateDocumentFile(); |
sheet.printDocument(printJob); |
} catch (Exception e) { |
ExceptionHandler.handle("Erreur lors de la création de la facture", e); |
} |
} |
} |
} |
} |
}; |
thread.setPriority(Thread.MIN_PRIORITY); |
thread.setDaemon(true); |
pFrame.setLocationRelativeTo(ilist); |
pFrame.setVisible(true); |
thread.start(); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLComponent.java |
---|
18,7 → 18,6 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable; |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable; |
import org.openconcerto.erp.core.sales.product.ui.CustomerProductFamilyQtyPriceListTable; |
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable; |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel; |
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel; |
43,10 → 42,7 |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanel.EditMode; |
import org.openconcerto.sql.view.IListFrame; |
import org.openconcerto.sql.view.IListPanel; |
import org.openconcerto.sql.view.ListeAddPanel; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.SQLTableModelSource; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.FrameUtil; |
import org.openconcerto.ui.JDate; |
69,7 → 65,6 |
import javax.swing.AbstractAction; |
import javax.swing.Icon; |
import javax.swing.JButton; |
import javax.swing.JCheckBox; |
import javax.swing.JComponent; |
import javax.swing.JLabel; |
100,10 → 95,8 |
}; |
private CustomerProductQtyPriceListTable clienTarifTable = new CustomerProductQtyPriceListTable(); |
private CustomerProductFamilyQtyPriceListTable clienFamilleTarifTable = new CustomerProductFamilyQtyPriceListTable(); |
private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable)); |
private JCheckBox checkAdrLivraison, checkAdrFacturation; |
private IListPanel agencePanel; |
public CustomerSQLComponent(SQLElement element) { |
super(element); |
179,34 → 172,10 |
return new JDate(true); |
} else if (id.equals("customerrelationship.customer.contacts")) { |
return this.table; |
} else if (id.equals("customerrelationship.customer.agencies")) { |
SQLElement elementAgence = getElement().getDirectory().getElement("AGENCE"); |
SQLTableModelSource source = elementAgence.createTableSource(Where.FALSE); |
this.agencePanel = new ListeAddPanel(elementAgence, new IListe(source)) { |
@Override |
protected void handleAction(JButton source, ActionEvent evt) { |
if (source == this.buttonAjouter) { |
if (getMode() == Mode.MODIFICATION && getSelectedID() != SQLRow.NONEXISTANT_ID) { |
SQLRowValues rowValsAgency = new SQLRowValues(elementAgence.getTable()); |
rowValsAgency.put("ID_CLIENT", getSelectedID()); |
this.getCreateFrame().getSQLComponent().select(rowValsAgency); |
} |
FrameUtil.show(this.getCreateFrame()); |
} else { |
super.handleAction(source, evt); |
} |
} |
}; |
if (getMode() == Mode.INSERTION || getMode() == Mode.READ_ONLY) { |
this.agencePanel.getButtonAdd().setEnabled(false); |
} |
return this.agencePanel; |
} else if (id.equals("customerrelationship.customer.customproduct")) { |
return this.tableCustomProduct; |
} else if (id.equals("customerrelationship.customer.customtarif")) { |
return this.clienTarifTable; |
} else if (id.equals("customerrelationship.customer.customfamilytarif")) { |
return this.clienFamilleTarifTable; |
} else if (id.equals("customerrelationship.customer.addresses")) { |
return createAdressesComponent(); |
} else if (id.equals("NOM")) { |
284,7 → 253,6 |
final int selectedID = getSelectedID(); |
this.table.updateField("ID_CLIENT", selectedID); |
this.clienTarifTable.updateField("ID_CLIENT", selectedID); |
this.clienFamilleTarifTable.updateField("ID_CLIENT", selectedID); |
this.tableCustomProduct.updateField("ID_CLIENT", selectedID); |
this.adresseTable.updateField("ID_CLIENT", selectedID); |
} |
297,16 → 265,10 |
if (r != null) { |
this.table.insertFrom("ID_CLIENT", r.asRowValues()); |
this.clienTarifTable.insertFrom("ID_CLIENT", r.asRowValues()); |
this.clienFamilleTarifTable.insertFrom("ID_CLIENT", r.asRowValues()); |
this.tableCustomProduct.insertFrom("ID_CLIENT", r.asRowValues()); |
this.adresseTable.insertFrom("ID_CLIENT", r.asRowValues()); |
} |
if (r != null && r.hasID()) { |
this.agencePanel.getListe().getRequest().setWhere(new Where(this.agencePanel.getListe().getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", r.getID())); |
} else { |
this.agencePanel.getListe().getRequest().setWhere(Where.FALSE); |
} |
} |
@Override |
public int insert(SQLRow order) { |
342,8 → 304,6 |
} else { |
id = super.insert(order); |
this.table.updateField("ID_CLIENT", id); |
this.clienTarifTable.updateField("ID_CLIENT", id); |
this.clienFamilleTarifTable.updateField("ID_CLIENT", id); |
this.tableCustomProduct.updateField("ID_CLIENT", id); |
this.clienTarifTable.updateField("ID_CLIENT", id); |
this.adresseTable.updateField("ID_CLIENT", id); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerGroup.java |
---|
57,10 → 57,6 |
this.add(gAddress); |
final Group gAgency = new Group("customerrelationship.customer.agency"); |
gAgency.addItem("customerrelationship.customer.agencies", new LayoutHints(true, true, true, true, true, true, true, true)); |
this.add(gAgency); |
final Group gContact = new Group("customerrelationship.customer.contact", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS); |
gContact.addItem("customerrelationship.customer.contacts", new LayoutHints(true, true, true, true, true, true, true, true)); |
this.add(gContact); |
99,10 → 95,8 |
final Group gCustomProduct = new Group("customerrelationship.customer.customproduct", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS); |
gCustomProduct.addItem("customerrelationship.customer.customproduct", new LayoutHints(true, true, true, true, true, true, true, true)); |
this.add(gCustomProduct); |
final Group gCustomRemiseProduct = new Group("customerrelationship.customer.customtarif", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS); |
gCustomRemiseProduct.addItem("customerrelationship.customer.customtarif", new LayoutHints(true, true, true, true, true, true, true, true)); |
gCustomRemiseProduct.addItem("customerrelationship.customer.customfamilytarif", new LayoutHints(true, true, true, true, true, true, true, true)); |
this.add(gCustomRemiseProduct); |
this.add(gState); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/report/ReportingCommercialFournisseurCreator.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/report/ReportingCommercialFournisseurPanel.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/model/TaxeCache.java |
---|
40,12 → 40,10 |
SQLRowValues rowVals = new SQLRowValues(table); |
rowVals.putNulls("TAUX", "CODE", "NOM", "ID_TAXE", "DEFAULT", "DEFAULT_ACHAT"); |
List<String> compteFields = Arrays.asList("ID_COMPTE_PCE_COLLECTE", "ID_COMPTE_PCE_DED", "ID_COMPTE_PCE", "ID_COMPTE_PCE_VENTE", "ID_COMPTE_PCE_VENTE_SERVICE", "ID_COMPTE_PCE_COLLECTE_INTRA", |
"ID_COMPTE_PCE_DED_INTRA", "ID_COMPTE_PCE_COLLECTE_ENCAISSEMENT"); |
"ID_COMPTE_PCE_DED_INTRA"); |
for (String foreignFieldName : compteFields) { |
if (table.contains(foreignFieldName)) { |
rowVals.putRowValues(foreignFieldName).putNulls("NUMERO", "NOM"); |
} |
} |
return SQLRowValuesListFetcher.create(rowVals); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/EncaisserMontantSQLElement.java |
---|
121,29 → 121,7 |
return Collections.singleton("ID_CLIENT"); |
} |
@Override |
protected synchronized void _initTableSource(final SQLTableModelSource table) { |
super._initTableSource(table); |
final BaseSQLTableModelColumn racCol = new BaseSQLTableModelColumn("Report échéance", Boolean.class) { |
@Override |
protected Object show_(SQLRowAccessor r) { |
return !r.getForeign("ID_MODE_REGLEMENT").getBoolean("COMPTANT"); |
} |
@Override |
public Set<FieldPath> getPaths() { |
Path p = new Path(getTable()); |
Path p2 = p.add(p.getLast().getField("ID_MODE_REGLEMENT")); |
return CollectionUtils.createSet(new FieldPath(p2, "COMPTANT")); |
} |
}; |
table.getColumns().add(racCol); |
} |
/* |
* (non-Javadoc) |
* |
194,64 → 172,21 |
super.archive(trees, cutLinks); |
} |
public void regleFacture(SQLRow rowAfter, SQLRowValues rowBefore, boolean update) throws Exception { |
public void regleFacture(SQLRow row) throws Exception { |
if (update && rowBefore == null) { |
throw new IllegalArgumentException(); |
} else if (update) { |
// Recalcul des échéances |
for (SQLRowAccessor rowEncaisse : rowBefore.getReferentRows(getTable().getTable("ENCAISSER_MONTANT_ELEMENT"))) { |
SQLRowAccessor rowEch = rowEncaisse.getForeign("ID_ECHEANCE_CLIENT"); |
// SI une echeance est associée (paiement non comptant) |
if (rowEch.getID() > 1) { |
SQLRowValues rowVals = rowEch.createEmptyUpdateRow(); |
rowVals.put("REGLE", Boolean.FALSE); |
if (rowEch.getBoolean("REGLE")) { |
rowVals.put("MONTANT", rowEncaisse.getLong("MONTANT_REGLE")); |
} else { |
rowVals.put("MONTANT", rowEch.getLong("MONTANT") + rowEncaisse.getLong("MONTANT_REGLE")); |
} |
rowVals.update(); |
} |
// TODO si pas une echeance, echeance à creer |
} |
// On supprime les mouvements |
SQLSelect sel = new SQLSelect(getTable().getBase()); |
SQLTable tableMvt = getTable().getTable("MOUVEMENT"); |
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement(tableMvt.getTable("ECRITURE")); |
sel.addSelectStar(tableMvt); |
Where w = new Where(tableMvt.getField("SOURCE"), "=", getTable().getName()); |
w = w.and(new Where(tableMvt.getField("IDSOURCE"), "=", rowBefore.getID())); |
sel.setWhere(w); |
List<SQLRow> list = (List<SQLRow>) getTable().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel, tableMvt)); |
for (SQLRow sqlRow : list) { |
eltEcr.archiveMouvementProfondeur(sqlRow.getID(), false); |
} |
// On supprime si une prochaine échéance a été créé (ex: prélévement) |
final SQLRowAccessor nonEmptyForeignMvt = rowBefore.getNonEmptyForeign("ID_MOUVEMENT"); |
if (nonEmptyForeignMvt != null && nonEmptyForeignMvt.getString("SOURCE").equals("ECHEANCE_CLIENT")) { |
eltEcr.archiveMouvementProfondeur(nonEmptyForeignMvt.getID(), true); |
} |
} |
System.out.println("Génération des ecritures du reglement"); |
String s = rowAfter.getString("NOM"); |
SQLRow rowModeRegl = rowAfter.getForeignRow("ID_MODE_REGLEMENT"); |
String s = row.getString("NOM"); |
SQLRow rowModeRegl = row.getForeignRow("ID_MODE_REGLEMENT"); |
SQLRow rowTypeRegl = rowModeRegl.getForeignRow("ID_TYPE_REGLEMENT"); |
// Compte Client |
SQLRow clientRow = rowAfter.getForeignRow("ID_CLIENT"); |
SQLRow clientRow = row.getForeignRow("ID_CLIENT"); |
String label = "Règlement vente " + ((s == null) ? "" : s) + " (" + rowTypeRegl.getString("NOM") + ") " + StringUtils.limitLength(clientRow.getString("NOM"), 20); |
long montant = rowAfter.getLong("MONTANT"); |
long montant = row.getLong("MONTANT"); |
PrixTTC ttc = new PrixTTC(montant); |
List<SQLRow> l = rowAfter.getReferentRows(rowAfter.getTable().getTable("ENCAISSER_MONTANT_ELEMENT")); |
List<SQLRow> l = row.getReferentRows(row.getTable().getTable("ENCAISSER_MONTANT_ELEMENT")); |
if (l.isEmpty()) { |
SwingUtilities.invokeLater(new Runnable() { |
260,17 → 195,17 |
JOptionPane.showMessageDialog(null, "Un problème a été rencontré lors de l'encaissement! \n Les écritures comptables non pu être générer!"); |
} |
}); |
System.err.println("Liste des échéances vides pour l'encaissement ID " + rowAfter.getID()); |
System.err.println("Liste des échéances vides pour l'encaissement ID " + row.getID()); |
Thread.dumpStack(); |
return; |
} |
new GenerationReglementVenteNG(label, clientRow, ttc, rowAfter.getDate("DATE").getTime(), rowModeRegl, rowAfter, l.get(0).getForeignRow("ID_MOUVEMENT_ECHEANCE"), false, false, |
rowAfter.getString("TIERS"), rowAfter.getForeign("ID_COMPTE_PCE_TIERS")); |
new GenerationReglementVenteNG(label, clientRow, ttc, row.getDate("DATE").getTime(), rowModeRegl, row, l.get(0).getForeignRow("ID_MOUVEMENT_ECHEANCE"), false, false, row.getString("TIERS"), |
row.getForeign("ID_COMPTE_PCE_TIERS")); |
// Mise a jour du montant de l'echeance |
boolean supplement = false; |
if (!rowAfter.getBoolean("ACOMPTE")) { |
if (!row.getBoolean("ACOMPTE")) { |
// On marque les echeances comme reglees |
for (SQLRow sqlRow : l) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeFournisseurSQLElement.java |
---|
34,7 → 34,6 |
import java.util.List; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.SwingConstants; |
public class ChequeFournisseurSQLElement extends ChequeSQLElement { |
130,7 → 129,7 |
final GridBagConstraints c = new DefaultGridBagConstraints(); |
// Montant |
JLabel labelMontant = new JLabel("Montant", SwingConstants.RIGHT); |
JLabel labelMontant = new JLabel("Montant "); |
this.add(labelMontant, c); |
c.gridx++; |
138,7 → 137,7 |
this.add(this.textMontant, c); |
// Date |
JLabel labelDate = new JLabel("Date", SwingConstants.RIGHT); |
JLabel labelDate = new JLabel("Date "); |
c.weightx = 0; |
c.gridx++; |
labelDate.setHorizontalAlignment(SwingConstants.RIGHT); |
146,24 → 145,19 |
JDate dateAchat = new JDate(true); |
c.gridx++; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(dateAchat, c); |
c.gridy++; |
c.gridx = 0; |
JLabel labelFournisseurNom = new JLabel("Fournisseur", SwingConstants.RIGHT); |
JLabel labelFournisseurNom = new JLabel("Fournisseur "); |
this.add(labelFournisseurNom, c); |
final ElementComboBox nomFournisseur = new ElementComboBox(); |
c.gridx++; |
c.gridwidth = 3; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(nomFournisseur, c); |
JPanel spacer = new JPanel(); |
spacer.setOpaque(false); |
c.weighty = 1; |
c.gridy++; |
this.add(spacer, c); |
this.addRequiredSQLObject(nomFournisseur, "ID_FOURNISSEUR"); |
this.addRequiredSQLObject(this.textMontant, "MONTANT"); |
this.addRequiredSQLObject(dateAchat, "DATE_ACHAT"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/SDDMessageSQLElement.java |
---|
207,7 → 207,7 |
final File directDebitDir = new File(newPath); |
try { |
for (final SQLRowAccessor messageRow : messages) { |
FileUtils.writeUTF8(messageRow.getString("XML"), new File(directDebitDir, messageRow.getString("MessageIdentification") + ".xml")); |
FileUtils.write(messageRow.getString("XML"), new File(directDebitDir, messageRow.getString("MessageIdentification") + ".xml"), StringUtils.UTF8, false); |
} |
} catch (IOException exn) { |
ExceptionHandler.handle(comp, "Impossible d'exporter", exn); |
422,7 → 422,7 |
} |
public SQLTable getTable() { |
return this.table; |
return table; |
} |
@Override |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ReglerMontantSQLElement.java |
---|
23,7 → 23,6 |
import org.openconcerto.utils.CollectionUtils; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.List; |
import java.util.Set; |
52,38 → 51,6 |
@Override |
protected void _initTableSource(SQLTableModelSource res) { |
super._initTableSource(res); |
final BaseSQLTableModelColumn racColFact = new BaseSQLTableModelColumn("Factures associées", String.class) { |
@Override |
protected Object show_(SQLRowAccessor r) { |
Collection<? extends SQLRowAccessor> l = r.getReferentRows(r.getTable().getTable("REGLER_MONTANT_ELEMENT")); |
String s = ""; |
for (SQLRowAccessor sqlRowAccessor : l) { |
if (!sqlRowAccessor.isForeignEmpty("ID_MOUVEMENT_ECHEANCE")) { |
SQLRowAccessor rMvt = sqlRowAccessor.getForeign("ID_MOUVEMENT_ECHEANCE"); |
if (!rMvt.isForeignEmpty("ID_PIECE")) { |
SQLRowAccessor rP = rMvt.getForeign("ID_PIECE"); |
s += (s.trim().length() > 0 ? ", " : "") + rP.getString("NOM"); |
} |
} |
} |
return s; |
} |
@Override |
public Set<FieldPath> getPaths() { |
Path p = new Path(getTable()); |
Path p2 = p.add(p.getLast().getTable("REGLER_MONTANT_ELEMENT")); |
Path p3 = p2.add(p2.getLast().getField("ID_MOUVEMENT_ECHEANCE")); |
Path p4 = p3.add(p3.getLast().getField("ID_PIECE")); |
return CollectionUtils.createSet(new FieldPath(p4, "NOM")); |
} |
}; |
res.getColumns().add(racColFact); |
final BaseSQLTableModelColumn racCol = new BaseSQLTableModelColumn("Report échéance", Boolean.class) { |
@Override |
protected Object show_(SQLRowAccessor r) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ReglerMontantSQLComponent.java |
---|
59,7 → 59,7 |
public class ReglerMontantSQLComponent extends BaseSQLComponent { |
private RegleMontantTable table = new RegleMontantTable(); |
private DeviseField montant = new DeviseField(15); |
private DeviseField montant = new DeviseField(10); |
private JDate date; |
private JLabel labelWarning = new JLabelWarning(); |
private JLabel labelWarningText = new JLabel("Le montant n'est pas valide!"); |
68,14 → 68,6 |
super(elt); |
} |
@Override |
public void select(SQLRowAccessor r) { |
super.select(r); |
if (r != null) { |
this.table.getRowValuesTable().insertFrom(r); |
} |
} |
public void addViews() { |
this.setLayout(new GridBagLayout()); |
final GridBagConstraints c = new DefaultGridBagConstraints(); |
123,10 → 115,9 |
c.weightx = 0; |
this.add(new JLabel("Montant réglé", SwingConstants.RIGHT), c); |
c.gridx++; |
c.weightx = 1; |
c.weightx = 0; |
c.gridwidth = 1; |
c.fill = GridBagConstraints.NONE; |
DefaultGridBagConstraints.lockMinimumSize(this.montant); |
this.add(this.montant, c); |
// Warning |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/ListeDesEncaissementsAction.java |
---|
16,12 → 16,10 |
import org.openconcerto.erp.action.CreateFrameAbstractAction; |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel; |
import org.openconcerto.erp.core.common.ui.IListTotalPanel; |
import org.openconcerto.erp.core.common.ui.ListeViewPanel; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.view.IListFrame; |
import org.openconcerto.sql.view.ListeAddPanel; |
import org.openconcerto.sql.view.list.IListe; |
28,15 → 26,11 |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import java.awt.GridBagConstraints; |
import java.awt.event.ActionEvent; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.List; |
import javax.swing.Action; |
import javax.swing.JButton; |
import javax.swing.JFrame; |
import javax.swing.JOptionPane; |
public class ListeDesEncaissementsAction extends CreateFrameAbstractAction { |
49,55 → 43,12 |
final SQLElement elementEchClient = Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT"); |
ListeAddPanel panel = new ListeAddPanel(elementEchClient, new IListe(elementEchClient.getTableSource(true))) { |
// FIXME faire les checks en plus dans l'element |
@Override |
protected void handleAction(JButton source, ActionEvent evt) { |
if (source == this.buttonEffacer) { |
List<SQLRowValues> rowValsSel = this.getListe().getSelectedRows(); |
// FIXME Cacher les encaissements de reports (créer à partir d'une échéance pour la reporter |
// ????) |
if (isEncaissementEditable(rowValsSel, "effacer")) { |
super.handleAction(source, evt); |
} |
} else if (source == this.buttonModifier) { |
List<SQLRowValues> rowValsSel = this.getListe().getSelectedRows(); |
if (isEncaissementEditable(rowValsSel, "supprimer")) { |
super.handleAction(source, evt); |
} |
} else { |
super.handleAction(source, evt); |
} |
} |
private boolean isEncaissementEditable(List<SQLRowValues> rowValsSel, String action) { |
for (SQLRowValues sqlRowValues : rowValsSel) { |
final SQLRow asRow = sqlRowValues.asRow(); |
Collection<? extends SQLRowAccessor> rowItems = asRow.getReferentRows(sqlRowValues.getTable().getTable("ENCAISSER_MONTANT_ELEMENT")); |
for (SQLRowAccessor sqlRowValues2 : rowItems) { |
if (sqlRowValues2.isForeignEmpty("ID_ECHEANCE_CLIENT")) { |
JOptionPane.showMessageDialog(null, "Impossible de " + action + " un encaissement qui ne vient pas d'une échéance"); |
return false; |
} |
} |
SQLRowAccessor rowAcMvt = asRow.getNonEmptyForeign("ID_MOUVEMENT"); |
if (rowAcMvt != null) { |
Collection<? extends SQLRowAccessor> rowItemsEcr = rowAcMvt.getReferentRows(rowAcMvt.getTable().getTable("ECRITURE").getField("ID_MOUVEMENT")); |
for (SQLRowAccessor sqlRowValues2 : rowItemsEcr) { |
if (sqlRowValues2.getBoolean("VALIDE")) { |
JOptionPane.showMessageDialog(null, "Impossible de " + action + " un encaissement dont les écritures sont validées."); |
return false; |
} |
} |
} |
} |
return true; |
} |
}; |
ListeViewPanel panel = new ListeViewPanel(elementEchClient, new IListe(elementEchClient.getTableSource(true))); |
panel.setAddVisible(false); |
// panel.setDeleteVisible(false); |
panel.setDeleteVisible(false); |
IListFrame frame = new IListFrame(panel); |
List<SQLField> fields = new ArrayList<SQLField>(2); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/ListeDesRelancesAction.java |
---|
14,9 → 14,16 |
package org.openconcerto.erp.core.finance.payment.action; |
import org.openconcerto.erp.action.CreateFrameAbstractAction; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel; |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet; |
import org.openconcerto.erp.generationDoc.gestcomm.FicheRelanceSheet; |
import org.openconcerto.erp.generationDoc.gestcomm.RelanceSheet; |
import org.openconcerto.erp.preferences.PrinterNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.view.IListFrame; |
import org.openconcerto.sql.view.ListeAddPanel; |
24,15 → 31,22 |
import org.openconcerto.sql.view.list.SQLTableModelColumnPath; |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.cc.ITransformer; |
import java.awt.GridBagConstraints; |
import java.awt.event.ActionEvent; |
import java.awt.event.MouseEvent; |
import java.awt.event.MouseListener; |
import java.util.List; |
import javax.swing.AbstractAction; |
import javax.swing.Action; |
import javax.swing.JButton; |
import javax.swing.JFrame; |
import javax.swing.JPopupMenu; |
public class ListeDesRelancesAction extends CreateFrameAbstractAction { |
public class ListeDesRelancesAction extends CreateFrameAbstractAction implements MouseListener { |
private IListFrame frame; |
53,9 → 67,9 |
@Override |
public String transformChecked(JButton input) { |
SQLRowValues row = getListe().getSelectedRow(); |
SQLRowAccessor row = getListe().fetchSelectedRow(); |
if (row.getObject("ID_TYPE_LETTRE_RELANCE") == null || row.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")) { |
if (row.getForeign("ID_TYPE_LETTRE_RELANCE") == null || row.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")) { |
return "Vous ne pouvez pas modifier une relance envoyée par mail!"; |
} |
return null; |
76,6 → 90,7 |
((SQLTableModelColumnPath) src.getColumns(elt.getTable().getField("INFOS")).iterator().next()).setEditable(true); |
this.frame.getPanel().getListe().getJTable().addMouseListener(this); |
this.frame.getPanel().setAddVisible(false); |
// Date panel |
94,4 → 109,124 |
return this.frame; |
} |
public void mouseClicked(MouseEvent e) { |
} |
public void mousePressed(MouseEvent e) { |
int selectedId = this.frame.getPanel().getListe().getSelectedId(); |
if (selectedId > 1 && e.getButton() == MouseEvent.BUTTON3) { |
// String locationRelance = |
// TemplateNXProps.getInstance().getStringProperty("LocationRelanceOO"); |
final SQLRow rowRelance = this.frame.getPanel().getListe().fetchSelectedRow(); |
boolean isNotMail = !(rowRelance.getForeign("ID_TYPE_LETTRE_RELANCE") == null || rowRelance.isForeignEmpty("ID_TYPE_LETTRE_RELANCE")); |
// final String fileName = "Relance_" + rowRelance.getString("NUMERO"); |
// final File fileOutOO = new File(locationRelance, fileName + ".odt"); |
JPopupMenu menu = new JPopupMenu(); |
final RelanceSheet s = new RelanceSheet(rowRelance); |
// Voir le document |
AbstractAction actionOpen = new AbstractAction("Voir le document") { |
public void actionPerformed(ActionEvent e) { |
s.generate(false, false, ""); |
s.showDocument(); |
} |
}; |
actionOpen.setEnabled(isNotMail); |
menu.add(actionOpen); |
// Impression |
AbstractAction actionPrint = new AbstractAction("Imprimer") { |
public void actionPerformed(ActionEvent e) { |
s.fastPrintDocument(); |
} |
}; |
actionPrint.setEnabled(isNotMail); |
menu.add(actionPrint); |
// Impression |
AbstractAction actionPrintFact = new AbstractAction("Imprimer la facture") { |
public void actionPerformed(ActionEvent e) { |
final Thread t = new Thread(new Runnable() { |
@Override |
public void run() { |
try { |
printInvoice(rowRelance); |
} catch (Exception e) { |
ExceptionHandler.handle("Impression impossible", e); |
} |
} |
}); |
t.start(); |
} |
}; |
actionPrintFact.setEnabled(isNotMail); |
menu.add(actionPrintFact); |
// Impression |
AbstractAction actionPrintBoth = new AbstractAction("Imprimer la facture et la relance") { |
public void actionPerformed(ActionEvent e) { |
final Thread t = new Thread(new Runnable() { |
@Override |
public void run() { |
try { |
s.fastPrintDocument(); |
printInvoice(rowRelance); |
} catch (Exception e) { |
ExceptionHandler.handle("Impression impossible", e); |
} |
} |
}); |
t.start(); |
} |
}; |
actionPrintBoth.setEnabled(isNotMail); |
menu.add(actionPrintBoth); |
// Générer |
final AbstractAction actionGenerate = new AbstractAction("Générer") { |
public void actionPerformed(ActionEvent e) { |
String printer = PrinterNXProps.getInstance().getStringProperty("RelancePrinter"); |
s.generate(false, true, printer, true); |
} |
}; |
actionGenerate.setEnabled(isNotMail); |
menu.add(actionGenerate); |
// Créer la fiche de relance |
menu.add(new AbstractAction("Créer la fiche de relance") { |
public void actionPerformed(ActionEvent e) { |
try { |
FicheRelanceSheet sheet = new FicheRelanceSheet(rowRelance); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(true, false, true); |
} catch (Exception ex) { |
ExceptionHandler.handle("Impression impossible", ex); |
} |
} |
}); |
menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); |
} |
} |
public void mouseReleased(MouseEvent e) { |
} |
public void mouseEntered(MouseEvent e) { |
} |
public void mouseExited(MouseEvent e) { |
} |
private void printInvoice(final SQLRow rowRelance) throws Exception { |
final VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(rowRelance.getForeignRow("ID_SAISIE_VENTE_FACTURE")); |
sheet.getOrCreateDocumentFile(); |
sheet.showPrintAndExport(false, true, true); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/EncaisserMontantSQLComponent.java |
---|
28,9 → 28,7 |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLRowValuesListFetcher; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.sql.view.list.RowValuesTableModel; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
315,36 → 313,14 |
System.out.println("Génération des ecritures du reglement"); |
SQLRow row = getTable().getRow(id); |
try { |
((EncaisserMontantSQLElement) getElement()).regleFacture(row, null, false); |
} catch (Exception e) { |
ExceptionHandler.handle("Erreur de génération des écritures", e); |
} |
return id; |
} |
@Override |
public void update() { |
int id = getSelectedID(); |
SQLRowValues rowValsFetcValues = new SQLRowValues(getTable()); |
rowValsFetcValues.putRowValues("ID_MOUVEMENT").putNulls("ID","SOURCE","IDSOURCE"); |
SQLRowValues rowValsFetcValuesItem = new SQLRowValues(getTable().getTable("ENCAISSER_MONTANT_ELEMENT")); |
rowValsFetcValuesItem.put("ID_ENCAISSER_MONTANT", rowValsFetcValues).putNulls("MONTANT_REGLE"); |
rowValsFetcValuesItem.putRowValues("ID_ECHEANCE_CLIENT").putNulls("MONTANT", "REGLE"); |
List<SQLRowValues> oldEch = SQLRowValuesListFetcher.create(rowValsFetcValues).fetch(new Where(getTable().getKey(), "=", id)); |
super.update(); |
this.table.updateField("ID_ENCAISSER_MONTANT", id); |
System.out.println("Génération des ecritures du reglement"); |
SQLRow row = getTable().getRow(id); |
try { |
((EncaisserMontantSQLElement) getElement()).regleFacture(row, oldEch.get(0), true); |
((EncaisserMontantSQLElement) getElement()).regleFacture(row); |
} catch (Exception e) { |
ExceptionHandler.handle("Erreur de génération des écritures", e); |
} |
return id; |
} |
@Override |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/SaisieKmSQLElement.java |
---|
16,28 → 16,20 |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.finance.accounting.ui.AnalytiqueItemTable; |
import org.openconcerto.erp.core.finance.accounting.ui.ComptabiliteWorkflowPreferencePanel; |
import org.openconcerto.erp.core.finance.accounting.ui.PropoLettrage; |
import org.openconcerto.erp.core.finance.accounting.ui.SaisieKmItemTable; |
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieKm; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProvider; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProviderManager; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.BaseSQLComponent; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLBase; |
import org.openconcerto.sql.model.SQLName; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.TableRef; |
import org.openconcerto.sql.model.UndefinedRowValuesCache; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.request.UpdateBuilder; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.sql.utils.SQLUtils; |
import org.openconcerto.sql.view.list.RowValuesTableModel; |
440,25 → 432,9 |
} |
}); |
this.updateEcriture(getTable().getRow(id)); |
} catch (SQLException exn) { |
ExceptionHandler.handle("Erreur lors de la création des écritures associées à la saisie au kilometre.", exn); |
} |
boolean showPropoLettrage = Boolean.valueOf(DefaultNXProps.getInstance().getProperty(ComptabiliteWorkflowPreferencePanel.LETTRAGE_PROPO_KM)); |
if (showPropoLettrage) { |
if (id > SQLRow.NONEXISTANT_ID) { |
final SQLRow rowKM = getTable().getRow(id); |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
PropoLettrage lettragePropo = new PropoLettrage(getElement().getDirectory().getElement(EcritureSQLElement.class)); |
lettragePropo.transfert(rowKM); |
} |
}); |
} |
} |
return id; |
} |
490,19 → 466,7 |
this.tableKm.updateField("ID_SAISIE_KM", getSelectedID()); |
System.err.println("UPDATE ECRITURE"); |
this.updateEcriture(getElement().getTable().getRow(getSelectedID())); |
boolean showPropoLettrage = Boolean.valueOf(DefaultNXProps.getInstance().getProperty(ComptabiliteWorkflowPreferencePanel.LETTRAGE_PROPO_KM)); |
if (showPropoLettrage) { |
SQLRow rowKM = getTable().getRow(getSelectedID()); |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
PropoLettrage lettragePropo = new PropoLettrage(getElement().getDirectory().getElement(EcritureSQLElement.class)); |
lettragePropo.transfert(rowKM); |
} |
}); |
} |
} |
private Date dTemp = null; |
557,15 → 521,8 |
final SQLRow mvt = rowSaisieKm.getForeign("ID_MOUVEMENT"); |
final SQLRow piece = mvt.getForeign("ID_PIECE"); |
String labelSaisie = rowSaisieKm.getString("NOM"); |
AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(GenerationMvtSaisieKm.ID); |
piece.createEmptyUpdateRow().put("NOM", (labelSaisie.length() == 0 ? "Saisie au km " : labelSaisie)).commit(); |
SQLRowValues rowValsPiece = piece.asRowValues(); |
rowValsPiece.put("NOM", (labelSaisie.length() == 0 ? "Saisie au km " : labelSaisie)); |
if (provider != null) { |
provider.putPieceLabel(rowSaisieKm, rowValsPiece); |
} |
rowValsPiece.commit(); |
// Mise à jour des écritures |
for (SQLRow rowKmElement : myListKmItem) { |
624,54 → 581,11 |
listEcr.remove(sqlRow); |
} |
} |
} |
} |
// Suppression des lettrages déséquilibré (ex : si on modifie un |
// montant d'une écriture lettrée) |
SQLSelect sel = new SQLSelect(); |
sel.addSelect(ecritureTable.getField("LETTRAGE")); |
sel.addGroupBy(ecritureTable.getField("LETTRAGE")); |
final TableRef aliasEcrTable = sel.getAlias(ecritureTable); |
final String quoteDebit = new SQLName(aliasEcrTable.getAlias(), "DEBIT").quote(); |
final String quoteCredit = new SQLName(aliasEcrTable.getAlias(), "CREDIT").quote(); |
sel.setHaving(Where.createRaw("SUM (" + quoteCredit + ") != SUM(" + quoteDebit + ")", aliasEcrTable.getField("DEBIT"))); |
List<String> resultBadLettrage = getElement().getTable().getDBSystemRoot().getDataSource().executeCol(sel.asString()); |
if (resultBadLettrage != null && !resultBadLettrage.isEmpty()) { |
UpdateBuilder update = new UpdateBuilder(ecritureTable); |
update.setObject(ecritureTable.getField("LETTRAGE"), ""); |
update.setObject(ecritureTable.getField("DATE_LETTRAGE"), null); |
Where w = new Where(ecritureTable.getField("LETTRAGE"), resultBadLettrage); |
update.setWhere(w); |
getElement().getTable().getDBSystemRoot().getDataSource().execute(update.asString()); |
} |
} |
// Suppression des lettrages déséquilibré (ex : si on modifie un |
// montant d'une écriture lettrée) |
SQLSelect sel = new SQLSelect(); |
sel.addSelect(ecritureTable.getField("LETTRAGE")); |
sel.addGroupBy(ecritureTable.getField("LETTRAGE")); |
final TableRef aliasEcrTable = sel.getAlias(ecritureTable); |
final String quoteDebit = new SQLName(aliasEcrTable.getAlias(), "DEBIT").quote(); |
final String quoteCredit = new SQLName(aliasEcrTable.getAlias(), "CREDIT").quote(); |
sel.setWhere(Where.isNotNull(ecritureTable.getField("LETTRAGE")).and(new Where(ecritureTable.getField("LETTRAGE"), "!=", ""))); |
sel.setHaving(Where.createRaw("SUM (" + quoteCredit + ") != SUM(" + quoteDebit + ")", aliasEcrTable.getField("DEBIT"))); |
List<String> resultBadLettrage = getTable().getDBSystemRoot().getDataSource().executeCol(sel.asString()); |
if (resultBadLettrage != null && !resultBadLettrage.isEmpty()) { |
UpdateBuilder update = new UpdateBuilder(ecritureTable); |
update.setObject(ecritureTable.getField("LETTRAGE"), ""); |
update.setObject(ecritureTable.getField("DATE_LETTRAGE"), null); |
Where w = new Where(ecritureTable.getField("LETTRAGE"), resultBadLettrage); |
update.setWhere(w); |
getTable().getDBSystemRoot().getDataSource().execute(update.asString()); |
} |
if (!listEcr.isEmpty()) { |
final EcritureSQLElement e = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement(ecritureTable); |
for (SQLRow sqlRow : listEcr) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java |
---|
35,7 → 35,6 |
import org.openconcerto.sql.model.SQLBase; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowListRSH; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLTable; |
293,7 → 292,6 |
public final SQLTableModelSourceOnline createLettrageTableSource() { |
final List<String> listEcriture = new ArrayList<String>(); |
listEcriture.add("LETTRAGE"); |
listEcriture.add("LETTRAGE_PARTIEL"); |
listEcriture.add("ID_COMPTE_PCE"); |
listEcriture.add("ID_MOUVEMENT"); |
if (getTable().contains("NOM_PIECE")) { |
670,16 → 668,14 |
@Override |
public Object create() throws SQLException { |
// on recupere l'ensemble des ecritures associées au mouvement |
SQLSelect selEcritures = new SQLSelect(); |
selEcritures.addSelect(tableEcriture.getField("ID")); |
selEcritures.addSelect(tableEcriture.getField("VALIDE")); |
selEcritures.addSelect(tableEcriture.getField("LETTRAGE")); |
selEcritures.setWhere(tableEcriture.getField("ID_MOUVEMENT"), "=", idMvt); |
List<SQLRow> rowEcr = SQLRowListRSH.execute(selEcritures); |
for (SQLRow r : rowEcr) { |
archiveEcriture(r); |
List l = (List) base.getDataSource().execute(selEcritures.asString(), new ArrayListHandler()); |
for (int i = 0; i < l.size(); i++) { |
Object[] tmp = (Object[]) l.get(i); |
archiveEcriture(tableEcriture.getRow(Integer.parseInt(tmp[0].toString()))); |
} |
return null; |
721,15 → 717,14 |
* @param row |
* @throws SQLException |
*/ |
public void archiveEcriture(SQLRowAccessor row) throws SQLException { |
public void archiveEcriture(SQLRow row) throws SQLException { |
if (!row.getBoolean("VALIDE")) { |
UpdateBuilder builderArc = new UpdateBuilder(getTable()); |
builderArc.setObject("IDUSER_DELETE", UserManager.getInstance().getCurrentUser().getId()); |
builderArc.setObject("ARCHIVE", 1); |
builderArc.setWhere(new Where(getTable().getKey(), "=", row.getID())); |
getTable().getDBSystemRoot().getDataSource().execute(builderArc.asString()); |
SQLRowValues rowVals = new SQLRowValues(this.getTable()); |
rowVals.put("IDUSER_DELETE", UserManager.getInstance().getCurrentUser().getId()); |
rowVals.put("ARCHIVE", 1); |
rowVals.update(row.getID()); |
// Annulation du lettrage si l'ecriture est lettrée pour ne pas avoir de lettrage |
// déséquilibré |
741,7 → 736,7 |
builder.setWhere(new Where(getTable().getField("LETTRAGE"), "=", codeLettrage)); |
getTable().getDBSystemRoot().getDataSource().execute(builder.asString()); |
} |
getTable().fireRowDeleted(row.getID()); |
// super.archive(row, true); |
} else { |
System.err.println("Impossible de supprimer une ecriture validée"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java |
---|
404,9 → 404,9 |
// 'Caisse |
// Racine = "53" |
// S084=511+512(D)...517+5187+54+58(D)+53 |
long v084 = this.sommeCompte.soldeCompteDebiteur(510, 517, true, this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompteDebiteur(518, 518, true, this.dateDebut, this.dateFin) |
+ this.sommeCompte.sommeCompteFils("54", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("53", this.dateDebut, this.dateFin) |
+ this.sommeCompte.sommeCompteFils("58", this.dateDebut, this.dateFin); |
long v084 = this.sommeCompte.soldeCompteDebiteur(510, 517, true, this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompteDebiteur(5180, 5185, true, this.dateDebut, this.dateFin) |
+ this.sommeCompte.soldeCompteDebiteur(5187, 5189, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("54", this.dateDebut, this.dateFin) |
+ this.sommeCompte.sommeCompteFils("53", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("58", this.dateDebut, this.dateFin); |
this.m.put("ACTIF1.11", GestionDevise.currencyToString(v084, false)); |
682,13 → 682,13 |
* this.sommeCompte.soldeCompteCrediteur(5180, 5180, true) - |
* this.sommeCompte.sommeCompteFils("5186") ; |
*/ |
long v156 = -this.sommeCompte.sommeCompteFils("160", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("161", this.dateDebut, this.dateFin) |
- this.sommeCompte.soldeCompte(163, 166, true, this.dateDebut, this.dateFin) - this.sommeCompte.soldeCompte(1680, 1681, true, this.dateDebut, this.dateFin) |
- this.sommeCompte.soldeCompte(1682, 1682, true, this.dateDebut, this.dateFin) - this.sommeCompte.soldeCompte(1684, 1689, true, this.dateDebut, this.dateFin) |
- this.sommeCompte.sommeCompteFils("17", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("426", this.dateDebut, this.dateFin) |
+ this.sommeCompte.soldeCompteCrediteur(450, 454, true, this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompteCrediteur(456, 456, true, this.dateDebut, this.dateFin) |
+ this.sommeCompte.soldeCompteCrediteur(458, 459, true, this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompteCrediteur(512, 517, true, this.dateDebut, this.dateFin) |
+ this.sommeCompte.soldeCompteCrediteur(518, 518, true, this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("519", this.dateDebut, this.dateFin); |
long v156 = -this.sommeCompte.sommeCompteFils("161", this.dateDebut, this.dateFin) - this.sommeCompte.soldeCompte(163, 166, true, this.dateDebut, this.dateFin) |
- this.sommeCompte.soldeCompte(1680, 1681, true, this.dateDebut, this.dateFin) - this.sommeCompte.soldeCompte(1682, 1682, true, this.dateDebut, this.dateFin) |
- this.sommeCompte.soldeCompte(1684, 1689, true, this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("17", this.dateDebut, this.dateFin) |
- this.sommeCompte.sommeCompteFils("426", this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompteCrediteur(450, 454, true, this.dateDebut, this.dateFin) |
+ this.sommeCompte.soldeCompteCrediteur(456, 456, true, this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompteCrediteur(458, 459, true, this.dateDebut, this.dateFin) |
+ this.sommeCompte.soldeCompteCrediteur(512, 517, true, this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("518", this.dateDebut, this.dateFin) |
- this.sommeCompte.sommeCompteFils("519", this.dateDebut, this.dateFin); |
this.m.put("PASSIF3.25", GestionDevise.currencyToString(v156, false)); |
// 151 |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033B.java |
---|
183,8 → 183,7 |
******************************************************************************************/ |
// 234 SommeSolde( 607, 608* )+SommeSolde( 6097, 6097* ) |
long v234 = this.sommeCompte.soldeCompte(607, 607, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(6097, 6097, true, this.dateDeb, this.dateFin) |
+ this.sommeCompte.soldeCompte(608, 608, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(6081, 6086, true, this.dateDeb, this.dateFin); |
+ this.sommeCompte.soldeCompte(6087, 6087, true, this.dateDeb, this.dateFin); |
this.m.put("CHARGES3.8", GestionDevise.currencyToString(v234, false)); |
// 208 |
207,7 → 206,7 |
// S238=601+602+6091+6092 |
// FIX Abaque ajout 609 |
long v238 = this.sommeCompte.soldeCompte(601, 602, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(609, 609, true, this.dateDeb, this.dateFin) |
- this.sommeCompte.soldeCompte(6093, 6099, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(6081, 6083, true, this.dateDeb, this.dateFin); |
- this.sommeCompte.soldeCompte(6093, 6099, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(6081, 6082, true, this.dateDeb, this.dateFin); |
this.m.put("CHARGES3.10", GestionDevise.currencyToString(v238, false)); |
// 212 |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/GrandLivreSheetXML.java |
---|
72,6 → 72,14 |
Date date; |
@Override |
public String getName() { |
if (this.date == null) { |
this.date = new Date(); |
} |
return "GrandLivre" + date.getTime(); |
} |
@Override |
protected String getStoragePathP() { |
return "Grand Livre"; |
} |
101,16 → 109,21 |
private String toDay = dateFormat.format(new Date()); |
private int size; |
// private void makeEntete(int rowDeb) { |
// |
// this.mCell.put("A" + rowDeb, this.rowSociete.getObject("NOM")); |
// this.mCell.put("G" + rowDeb, "Edition du " + this.toDay); |
// // this.mCell.put("D" + (rowDeb + 2), "Grand livre"); |
// // System.err.println("MAKE ENTETE"); |
// } |
// |
// private void makePiedPage(int row, String comptes) { |
// this.mCell.put("A" + row, "Compte : " + comptes); |
// this.mCell.put("E" + row, "Période du " + dateFormatEcr.format(this.dateDu) + " au " + |
// dateFormatEcr.format(this.dateAu)); |
// } |
private List<Map<String, Object>> recapSousTotaux = new ArrayList<>(); |
@Override |
public String getName() { |
if (this.date == null) { |
this.date = new Date(); |
} |
return "GrandLivre" + this.date.getTime(); |
} |
private void makeSousTotal(String numCpt, String nomCpt, Map<String, Object> line, Map<Integer, String> style, int pos, long debit, long credit) { |
style.put(pos, "Titre 1"); |
509,8 → 522,9 |
} |
private List<Integer> getListeCompteSolde() { |
SQLSelect sel = new SQLSelect(); |
sel.addSelect(tableEcriture.getField("ID_COMPTE_PCE")); |
SQLSelect sel = new SQLSelect(base); |
sel.addSelect(tableCompte.getField("ID")); |
sel.addSelect(tableEcriture.getField("DEBIT"), "SUM"); |
sel.addSelect(tableEcriture.getField("CREDIT"), "SUM"); |
517,9 → 531,8 |
Where w = getWhere(null); |
sel.setWhere(w); |
sel.addGroupBy(tableEcriture.getField("ID_COMPTE_PCE")); |
String req = sel.asString(); |
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\""; |
System.err.println(req); |
List<Object[]> l = (List) base.getDataSource().execute(req, new ArrayListHandler()); |
List<Integer> list = new ArrayList<Integer>(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceSheet.java |
---|
350,7 → 350,7 |
} |
if (this.centralClient && !numeroCpt.equalsIgnoreCase("411") && numeroCpt.startsWith("411")) { |
if (addedLine) { |
if (addedLine || !this.centralFournImmo) { |
posLine--; |
j--; |
} else { |
370,7 → 370,7 |
this.mCell.put("A" + posLine, numCptFourn); |
this.mCell.put("B" + posLine, nomCptFourn); |
} else if (this.centralFournImmo && !numeroCpt.equalsIgnoreCase("404") && numeroCpt.startsWith("404")) { |
if (addedLineImmo) { |
if (addedLineImmo || !this.centralFourn) { |
posLine--; |
j--; |
} else { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PropoLettrageRenderer.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PropoLettrageTableModel.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptabiliteWorkflowPreferencePanel.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PropoLettrage.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CloturePanel.java |
---|
95,7 → 95,7 |
JLabel label = new JLabel("- report des charges et produits constatés d'avance"); |
JLabel label2 = new JLabel("- report des charges à payer et produits à recevoir"); |
JLabel label3 = new JLabel("- impression du bilan, compte de résultat, grand livre, journaux et balance"); |
JLabel label5 = new JLabel("- génération des écritures comptables des payes"); |
JLabel label5 = new JLabel("- génération les écritures comptables des payes"); |
JLabel label4 = new JLabel("Il est préférable de réaliser une sauvegarde avant de continuer."); |
JLabel op = new JLabelBold("Opérations qui vont etre effectuées: "); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptaPrefTreeNode.java |
---|
96,10 → 96,6 |
nsGlobale.add(new PrefTreeNode(PayeGlobalPreferencePanel.class, "Paye", new String[] { "paye", "csg" })); |
// Comptabilité |
final PrefTreeNode nCompta = new PrefTreeNode(ComptabiliteWorkflowPreferencePanel.class, "Comptabilité", new String[] { "comptabilité", "lettrage" }); |
nsGlobale.add(nCompta); |
// Gestion commerciale |
final PrefTreeNode nGestionArticle = new PrefTreeNode(GestionArticlePreferencePanel.class, "Gestion des articles", new String[] { "articles", "gestion", "longueur", "largeur", "poids" }); |
final PrefTreeNode nGestionPiece = new PrefTreeNode(GestionPieceCommercialePanel.class, "Gestion des pièces commerciales", new String[] { "mouvements", "pieces", "facture" }); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/LettragePanel.java |
---|
18,12 → 18,10 |
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer; |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement; |
import org.openconcerto.erp.core.finance.accounting.model.LettrageModel; |
import org.openconcerto.erp.model.ISQLCompteSelector; |
import org.openconcerto.erp.rights.ComptaUserRight; |
import org.openconcerto.erp.utils.LowerCaseFormatFilter; |
import org.openconcerto.erp.utils.UpperCaseFormatFilter; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
30,29 → 28,18 |
import org.openconcerto.sql.element.SQLElementDirectory; |
import org.openconcerto.sql.model.SQLBase; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowListRSH; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLSystem; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.UndefinedRowValuesCache; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.request.ComboSQLRequest; |
import org.openconcerto.sql.users.rights.UserRightsManager; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanel.EditMode; |
import org.openconcerto.sql.view.EditPanelListener; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.FontUtils; |
import org.openconcerto.ui.JDate; |
import org.openconcerto.ui.TitledSeparator; |
import org.openconcerto.ui.warning.JLabelWarning; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.ListMap; |
import org.openconcerto.utils.text.DocumentFilterList; |
import org.openconcerto.utils.text.DocumentFilterList.FilterType; |
import org.openconcerto.utils.text.SimpleDocumentListener; |
76,10 → 63,7 |
import java.text.ParseException; |
import java.util.ArrayList; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
import java.util.Map.Entry; |
import javax.swing.AbstractAction; |
import javax.swing.BorderFactory; |
101,7 → 85,7 |
public class LettragePanel extends JPanel { |
private ListPanelEcritures ecriturePanel; |
private JTextField codeLettrage, codeLettragePartiel; |
private JTextField codeLettrage; |
private ISQLCompteSelector selCompte; |
private JCheckBox boxValidEcriture, boxAddSousCompte; |
private JPanel warningPanel, warningSolde; |
117,7 → 101,6 |
private int modeSelect; |
private LettrageModel model; |
private JButton buttonLettrer; |
private final JButton buttonRegler = new JButton("Régler"); |
private JDate dateDeb, dateFin, dateLettrage; |
public LettragePanel() { |
179,20 → 162,6 |
this.add(this.codeLettrage, c); |
this.codeLettrage.setText(NumerotationAutoSQLElement.getNextCodeLettrage()); |
JLabel labelCodepartiel = new JLabel("Code lettrage partiel"); |
labelCodepartiel.setHorizontalAlignment(SwingConstants.RIGHT); |
c.gridx++; |
c.gridwidth = 1; |
c.weightx = 0; |
this.add(labelCodepartiel, c); |
this.codeLettragePartiel = new JTextField(10); |
DocumentFilterList.add((AbstractDocument) this.codeLettragePartiel.getDocument(), new LowerCaseFormatFilter(), FilterType.SIMPLE_FILTER); |
c.gridx++; |
c.weightx = 1; |
this.add(this.codeLettragePartiel, c); |
this.codeLettragePartiel.setText(getNextCodeLettragePartiel()); |
// Warning si aucun code rentré |
createPanelWarning(); |
c.gridwidth = GridBagConstraints.REMAINDER; |
354,7 → 323,6 |
this.add(this.boxValidEcriture, c); |
JPanel panelButton = new JPanel(); |
panelButton.add(this.buttonRegler, c); |
// Boutton lettrer |
387,276 → 355,20 |
this.add(buttonClose, c); |
this.buttonLettrer.addActionListener(new ActionListener() { |
public void actionPerformed(ActionEvent e) { |
try { |
int[] rowIndex = LettragePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows(); |
actionLettrage(rowIndex, false); |
} catch (SQLException e1) { |
ExceptionHandler.handle("Erreur de lettrage", e1); |
} |
} |
}); |
// System.err.println("Action lettrage sur " + i); |
actionLettrage(rowIndex); |
this.buttonRegler.addActionListener(new ActionListener() { |
public void actionPerformed(ActionEvent e) { |
final List<SQLRowValues> res = LettragePanel.this.ecriturePanel.getListe().getSelectedRows(); |
final SQLTable tableKm = LettragePanel.this.ecriturePanel.getListe().getSource().getPrimaryTable().getTable("SAISIE_KM"); |
SQLRowValues rowValsKm = new SQLRowValues(tableKm); |
rowValsKm.put("DATE", new Date()); |
rowValsKm.put("ID_JOURNAL", JournalSQLElement.BANQUES); |
long solde = LettragePanel.this.model.getSoldeSelection(); |
final SQLTable tableKmItem = tableKm.getTable("SAISIE_KM_ELEMENT"); |
List<String> pieces = new ArrayList<>(); |
for (SQLRowValues sqlRowValues : res) { |
SQLRowValues rowValsKmItemTiers = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableKmItem)); |
rowValsKmItemTiers.put("NUMERO", sqlRowValues.getForeign("ID_COMPTE_PCE").getString("NUMERO")); |
rowValsKmItemTiers.put("NOM", sqlRowValues.getForeign("ID_COMPTE_PCE").getString("NOM")); |
final String pieceNom; |
if (sqlRowValues.getString("NOM_PIECE").trim().length() > 0) { |
pieceNom = sqlRowValues.getString("NOM_PIECE"); |
} else { |
pieceNom = sqlRowValues.getForeign("ID_MOUVEMENT").getForeign("ID_PIECE").getString("NOM"); |
} |
rowValsKmItemTiers.put("NOM_PIECE", pieceNom); |
if (pieceNom != null && pieceNom.trim().length() > 0) { |
pieces.add(pieceNom); |
} |
rowValsKmItemTiers.put("CREDIT", sqlRowValues.getLong("DEBIT")); |
rowValsKmItemTiers.put("DEBIT", sqlRowValues.getLong("CREDIT")); |
if (rowValsKmItemTiers.getTable().contains("MONTANT_ECHEANCE")) { |
rowValsKmItemTiers.put("MONTANT_ECHEANCE", sqlRowValues.getLong("CREDIT")); |
} |
rowValsKmItemTiers.put("ID_SAISIE_KM", rowValsKm); |
} |
SQLRowValues rowValsKmItemBq = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableKmItem)); |
boolean achat = solde < 0; |
// Compte bq |
int idPce = tableKm.getTable("TYPE_REGLEMENT").getRow(2).getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT")); |
if (idPce <= 1) { |
try { |
idPce = ComptePCESQLElement.getIdComptePceDefault("VenteCB"); |
} catch (Exception e1) { |
// TODO Auto-generated catch block |
e1.printStackTrace(); |
} |
} |
final SQLTable tableAccount = tableKmItem.getTable("COMPTE_PCE"); |
SQLRow rowCptBq = tableAccount.getRow(idPce); |
rowValsKmItemBq.put("NUMERO", rowCptBq.getString("NUMERO")); |
rowValsKmItemBq.put("NOM", rowCptBq.getString("NOM")); |
if (!pieces.isEmpty()) { |
StringBuilder build = new StringBuilder(); |
int nbPieces = pieces.size(); |
int i = 0; |
for (String string : pieces) { |
build.append(string); |
i++; |
if (i < nbPieces) { |
build.append(", "); |
} |
} |
rowValsKmItemBq.put("NOM_PIECE", build.toString()); |
} |
if (solde > 0) { |
rowValsKmItemBq.put("CREDIT", solde); |
rowValsKmItemBq.put("DEBIT", 0L); |
} else { |
rowValsKmItemBq.put("DEBIT", -solde); |
rowValsKmItemBq.put("CREDIT", 0L); |
} |
rowValsKmItemBq.put("ID_SAISIE_KM", rowValsKm); |
EditFrame frame = new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_KM"), EditMode.CREATION); |
frame.getSQLComponent().select(rowValsKm); |
frame.setVisible(true); |
frame.addEditPanelListener(new EditPanelListener() { |
@Override |
public void modified() { |
// TODO Auto-generated method stub |
} |
@Override |
public void inserted(int id) { |
List<SQLRow> rowsInserted = tableKm.getRow(id).getReferentRows(tableKmItem); |
List<String> piece = new ArrayList<>(); |
List<SQLRowAccessor> rowsToLettre = new ArrayList<>(); |
long solde = 0; |
for (SQLRowValues sqlRowValues : res) { |
rowsToLettre.add(sqlRowValues); |
final String nomPiece = sqlRowValues.getString("NOM_PIECE"); |
if (sqlRowValues.getForeign("ID_COMPTE_PCE").getString("NUMERO").startsWith("4") && nomPiece.trim().length() > 0) { |
piece.add(nomPiece); |
} |
solde += sqlRowValues.getLong("DEBIT"); |
solde -= sqlRowValues.getLong("CREDIT"); |
} |
for (SQLRow sqlRow : rowsInserted) { |
SQLRow rowEcr = sqlRow.getForeign("ID_ECRITURE"); |
final String nomPiece = sqlRow.getString("NOM_PIECE"); |
if (rowEcr.getString("COMPTE_NUMERO").startsWith("4")) { |
solde += rowEcr.getLong("DEBIT"); |
solde -= rowEcr.getLong("CREDIT"); |
if (nomPiece.trim().length() > 0) { |
piece.add(nomPiece); |
} |
rowsToLettre.add(rowEcr); |
} |
} |
if (solde == 0) { |
final String codeLettre = codeLettrage.getText().trim(); |
for (SQLRowAccessor row2 : rowsToLettre) { |
SQLRowValues rowVals = new SQLRowValues(row2.getTable()); |
// Lettrage |
// On lettre ou relettre la ligne avec le code saisi |
if (codeLettre.length() > 0) { |
rowVals.put("LETTRAGE_PARTIEL", ""); |
rowVals.put("LETTRAGE", codeLettre); |
rowVals.put("DATE_LETTRAGE", dateLettrage.getDate()); |
try { |
rowVals.update(row2.getID()); |
} catch (SQLException e1) { |
e1.printStackTrace(); |
} |
} |
} |
// Mise à jour du code de lettrage |
SQLElement elt = Configuration.getInstance().getDirectory().getElement("NUMEROTATION_AUTO"); |
SQLRowValues rowVals = elt.getTable().getRow(2).createEmptyUpdateRow(); |
rowVals.put("CODE_LETTRAGE", codeLettre); |
try { |
rowVals.update(); |
} catch (SQLException e) { |
e.printStackTrace(); |
} |
codeLettrage.setText(getNextCodeLettrage()); |
model.updateTotauxCompte(); |
} else { |
String codeLettreP = codeLettragePartiel.getText().trim(); |
String codeLettre = codeLettrage.getText().trim(); |
SQLSelect selEcr = new SQLSelect(); |
SQLTable tableEcr = tableKm.getTable("ECRITURE"); |
selEcr.addSelect(tableEcr.getKey()); |
selEcr.addSelect(tableEcr.getField("NOM_PIECE")); |
selEcr.addSelect(tableEcr.getField("DEBIT")); |
selEcr.addSelect(tableEcr.getField("CREDIT")); |
selEcr.addSelect(tableEcr.getField("LETTRAGE")); |
selEcr.addSelect(tableEcr.getField("LETTRAGE_PARTIEL")); |
Where w2 = new Where(tableEcr.getField("NOM_PIECE"), piece); |
w2 = w2.and(new Where(tableEcr.getField("COMPTE_NUMERO"), "LIKE", "40%").or(new Where(tableEcr.getField("COMPTE_NUMERO"), "LIKE", "41%"))); |
w2 = w2.and(new Where(tableEcr.getField("DATE_LETTRAGE"), "=", (Object) null)); |
selEcr.setWhere(w2); |
List<SQLRow> rows = SQLRowListRSH.execute(selEcr); |
ListMap<String, SQLRow> mapPiece = new ListMap<>(); |
Map<String, Long> soldePiece = new HashMap<>(); |
for (SQLRow sqlRow : rows) { |
String pieceName = sqlRow.getString("NOM_PIECE"); |
mapPiece.add(pieceName, sqlRow); |
long soldeRow = sqlRow.getLong("DEBIT") - sqlRow.getLong("CREDIT"); |
if (soldePiece.containsKey(pieceName)) { |
soldePiece.put(pieceName, soldePiece.get(pieceName) + soldeRow); |
} else { |
soldePiece.put(pieceName, soldeRow); |
} |
} |
for (Entry<String, List<SQLRow>> entry : mapPiece.entrySet()) { |
if (soldePiece.get(entry.getKey()) == 0) { |
try { |
for (SQLRow rowEcr : entry.getValue()) { |
SQLRowValues rowVals = rowEcr.createEmptyUpdateRow(); |
// Lettrage |
// On lettre ou relettre la ligne avec le code saisi |
if (codeLettre.length() > 0) { |
rowVals.put("LETTRAGE_PARTIEL", ""); |
rowVals.put("LETTRAGE", codeLettre); |
rowVals.put("DATE_LETTRAGE", dateLettrage.getDate()); |
rowVals.update(); |
} |
} |
// Mise à jour du code de lettrage |
SQLElement elt = Configuration.getInstance().getDirectory().getElement("NUMEROTATION_AUTO"); |
SQLRowValues rowVals = elt.getTable().getRow(2).createEmptyUpdateRow(); |
rowVals.put("CODE_LETTRAGE", codeLettre); |
rowVals.update(); |
codeLettre = getNextCodeLettrage(); |
} catch (SQLException e) { |
e.printStackTrace(); |
} |
} else { |
try { |
for (SQLRow rowEcr : entry.getValue()) { |
SQLRowValues rowVals = rowEcr.createEmptyUpdateRow(); |
// Lettrage |
// On lettre ou relettre la ligne avec le code saisi |
if (codeLettreP.length() > 0) { |
rowVals.put("LETTRAGE_PARTIEL", codeLettreP); |
rowVals.update(); |
} |
} |
// Mise à jour du code de lettrage |
SQLElement elt = Configuration.getInstance().getDirectory().getElement("NUMEROTATION_AUTO"); |
SQLRowValues rowVals = elt.getTable().getRow(2).createEmptyUpdateRow(); |
rowVals.put("CODE_LETTRAGE_PARTIEL", codeLettreP); |
rowVals.update(); |
codeLettreP = getNextCodeLettragePartiel(); |
} catch (SQLException e) { |
e.printStackTrace(); |
} |
} |
} |
codeLettrage.setText(getNextCodeLettrage()); |
codeLettragePartiel.setText(getNextCodeLettragePartiel()); |
model.updateTotauxCompte(); |
} |
} |
@Override |
public void deleted() { |
// TODO Auto-generated method stub |
} |
@Override |
public void cancelled() { |
// TODO Auto-generated method stub |
} |
}); |
} |
}); |
buttonDelettrer.addActionListener(new ActionListener() { |
public void actionPerformed(ActionEvent e) { |
int[] rowIndex = LettragePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows(); |
actionDelettrage(rowIndex, false); |
actionDelettrage(rowIndex); |
} |
}); |
685,7 → 397,6 |
LettragePanel.this.warningSolde.setVisible(LettragePanel.this.model.getSoldeSelection() != 0); |
buttonDelettrer.setEnabled(LettragePanel.this.model.getSoldeSelection() == 0); |
LettragePanel.this.buttonLettrer.setEnabled(LettragePanel.this.model.getSoldeSelection() == 0); |
LettragePanel.this.buttonRegler.setEnabled(!LettragePanel.this.ecriturePanel.getListe().getSelectedRows().isEmpty()); |
} |
}); |
723,59 → 434,27 |
this.buttonLettrer.setEnabled((this.codeLettrage.getText().trim().length() != 0)); |
} |
private String getNextCodeLettragePartiel() { |
return Configuration.getInstance().getDirectory().getElement(NumerotationAutoSQLElement.class).getNextCodeLettragePartiel(); |
} |
private String getNextCodeLettrage() { |
return Configuration.getInstance().getDirectory().getElement(NumerotationAutoSQLElement.class).getNextCodeLettrage(); |
} |
/* Menu clic Droit */ |
private void addActionMenuDroit() { |
// JPopupMenu menu = new JPopupMenu(); |
PredicateRowAction action = new PredicateRowAction(new AbstractAction() { |
this.ecriturePanel.getListe().addRowAction(new AbstractAction("Voir la source") { |
public void actionPerformed(ActionEvent e) { |
SQLRow rowEcr = LettragePanel.this.ecriturePanel.getListe().fetchSelectedRow(); |
MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT")); |
} |
}, false, "financing.accouning.entries.source.show"); |
action.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
}, "financing.accouning.entries.source.show"); |
this.ecriturePanel.getListe().addIListeAction(action); |
// if (this.codeLettrage.getText().trim().length() != 0) { |
final AbstractAction abstractAction = new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
try { |
int[] rowIndex = LettragePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows(); |
actionLettrage(rowIndex, false); |
} catch (SQLException e1) { |
ExceptionHandler.handle("erreur de lettrage", e1); |
actionLettrage(rowIndex); |
} |
} |
}; |
PredicateRowAction actionLettre = new PredicateRowAction(abstractAction, false, "financing.accouning.entries.match"); |
actionLettre.setPredicate(IListeEvent.getNonEmptySelectionPredicate()); |
this.ecriturePanel.getListe().addIListeAction(actionLettre); |
final AbstractAction abstractActionPartiel = new AbstractAction("Lettrage Partiel") { |
public void actionPerformed(ActionEvent e) { |
try { |
int[] rowIndex = LettragePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows(); |
actionLettrage(rowIndex, true); |
} catch (SQLException e1) { |
ExceptionHandler.handle("erreur de lettrage", e1); |
} |
} |
}; |
PredicateRowAction actionLettreP = new PredicateRowAction(abstractActionPartiel, false, "financing.accouning.entries.match.partial"); |
actionLettreP.setPredicate(IListeEvent.getNonEmptySelectionPredicate()); |
this.ecriturePanel.getListe().addIListeAction(actionLettreP); |
this.ecriturePanel.getListe().addRowAction(abstractAction, "financing.accouning.entries.match"); |
// } |
this.codeLettrage.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
788,20 → 467,13 |
public void actionPerformed(ActionEvent e) { |
int[] rowIndex = LettragePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows(); |
actionDelettrage(rowIndex, false); |
actionDelettrage(rowIndex); |
} |
}, "financing.accouning.entries.unmatch"); |
this.ecriturePanel.getListe().addRowAction(new AbstractAction("Délettrer partiel") { |
public void actionPerformed(ActionEvent e) { |
int[] rowIndex = LettragePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows(); |
actionDelettrage(rowIndex, true); |
// menu.show(mE.getComponent(), mE.getPoint().x, mE.getPoint().y); |
} |
}, "financing.accouning.entries.unmatch.partial"); |
} |
/* Panel Warning no numero releve */ |
private void createPanelWarning() { |
853,17 → 525,9 |
} |
// Lettre la ligne passée en parametre |
private void actionLettrage(int[] rowIndex) { |
String codeLettre = this.codeLettrage.getText().trim(); |
private void actionLettrage(int[] rowIndex, boolean partiel) throws SQLException { |
String codeLettre; |
if (partiel) { |
codeLettre = this.codeLettragePartiel.getText().trim(); |
} else { |
codeLettre = this.codeLettrage.getText().trim(); |
} |
// FIXME : transaction |
List<SQLRow> rowsSelected = new ArrayList<SQLRow>(rowIndex.length); |
long solde = 0; |
876,7 → 540,7 |
solde -= ((Long) row.getObject("CREDIT")).longValue(); |
} |
if (partiel || solde == 0) { |
if (solde == 0) { |
for (SQLRow row2 : rowsSelected) { |
891,12 → 555,8 |
EcritureSQLElement.validationEcritures(row2.getInt("ID_MOUVEMENT")); |
} |
if (partiel) { |
rowVals.put("LETTRAGE_PARTIEL", codeLettre); |
} else { |
rowVals.put("LETTRAGE", codeLettre); |
rowVals.put("DATE_LETTRAGE", this.dateLettrage.getDate()); |
} |
try { |
rowVals.update(row2.getID()); |
} catch (SQLException e1) { |
908,11 → 568,7 |
// Mise à jour du code de lettrage |
SQLElement elt = Configuration.getInstance().getDirectory().getElement("NUMEROTATION_AUTO"); |
SQLRowValues rowVals = elt.getTable().getRow(2).createEmptyUpdateRow(); |
if (partiel) { |
rowVals.put("CODE_LETTRAGE_PARTIEL", codeLettre); |
} else { |
rowVals.put("CODE_LETTRAGE", codeLettre); |
} |
try { |
rowVals.update(); |
} catch (SQLException e) { |
920,12 → 576,6 |
} |
this.codeLettrage.setText(NumerotationAutoSQLElement.getNextCodeLettrage()); |
if (partiel) { |
this.codeLettragePartiel.setText(getNextCodeLettragePartiel()); |
} else { |
this.codeLettrage.setText(getNextCodeLettrage()); |
} |
this.model.updateTotauxCompte(); |
} |
} |
942,7 → 592,7 |
} |
// Pointe la ligne passée en parametre |
private void actionDelettrage(int[] rowIndex, boolean partiel) { |
private void actionDelettrage(int[] rowIndex) { |
List<SQLRow> rowsSelected = new ArrayList<SQLRow>(rowIndex.length); |
956,22 → 606,11 |
solde -= ((Long) row.getObject("CREDIT")).longValue(); |
} |
if (partiel || solde == 0) { |
if (solde == 0) { |
for (SQLRow row : rowsSelected) { |
SQLRowValues rowVals = new SQLRowValues(this.tableEcr); |
if (partiel) { |
// Dépointage |
if (row.getString("LETTRAGE_PARTIEL").trim().length() != 0) { |
rowVals.put("LETTRAGE_PARTIEL", ""); |
try { |
rowVals.update(row.getID()); |
} catch (SQLException e1) { |
e1.printStackTrace(); |
} |
} |
} else { |
// Dépointage |
if (row.getString("LETTRAGE").trim().length() != 0) { |
985,7 → 624,6 |
} |
} |
} |
} |
this.model.updateTotauxCompte(); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PointagePanel.java |
---|
14,7 → 14,6 |
package org.openconcerto.erp.core.finance.accounting.ui; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer; |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement; |
75,6 → 74,7 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingWorker; |
import javax.swing.event.DocumentEvent; |
import javax.swing.event.DocumentListener; |
import javax.swing.event.TableModelEvent; |
import javax.swing.event.TableModelListener; |
86,9 → 86,6 |
private final JDate datePointee; |
private JCheckBox boxValidEcriture; |
private JPanel warningPanel; |
private final DeviseField fieldSoldeD = new DeviseField(15); |
private final DeviseField fieldSoldeA = new DeviseField(15); |
private final DeviseField fieldEcart = new DeviseField(15); |
private final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); |
private final SQLTable tableEcr = this.base.getTable("ECRITURE"); |
207,67 → 204,6 |
c.gridwidth = 1; |
this.add(this.datePointee, c); |
JPanel panelCheckValue = new JPanel(new GridBagLayout()); |
GridBagConstraints cCheck = new DefaultGridBagConstraints(); |
JLabel labelSoldeD = new JLabel("Solde de départ"); |
labelSoldeD.setHorizontalAlignment(SwingConstants.RIGHT); |
cCheck.gridwidth = 1; |
cCheck.weightx = 0; |
panelCheckValue.add(labelSoldeD, cCheck); |
cCheck.fill = GridBagConstraints.NONE; |
cCheck.weightx = 1; |
cCheck.gridx++; |
cCheck.gridwidth = 1; |
panelCheckValue.add(this.fieldSoldeD, cCheck); |
JLabel labelSoldeA = new JLabel("Solde d'arrivée"); |
labelSoldeA.setHorizontalAlignment(SwingConstants.RIGHT); |
cCheck.gridx++; |
cCheck.gridwidth = 1; |
cCheck.weightx = 0; |
panelCheckValue.add(labelSoldeA, cCheck); |
cCheck.fill = GridBagConstraints.NONE; |
cCheck.weightx = 1; |
cCheck.gridx++; |
cCheck.gridwidth = 1; |
panelCheckValue.add(this.fieldSoldeA, cCheck); |
JLabel labelEcart = new JLabel("Ecart pointage"); |
labelEcart.setHorizontalAlignment(SwingConstants.RIGHT); |
cCheck.gridx++; |
cCheck.gridwidth = 1; |
cCheck.weightx = 0; |
panelCheckValue.add(labelEcart, cCheck); |
cCheck.fill = GridBagConstraints.NONE; |
cCheck.weightx = 1; |
cCheck.gridx++; |
cCheck.gridwidth = 1; |
this.fieldEcart.setEditable(false); |
panelCheckValue.add(this.fieldEcart, cCheck); |
c.gridx++; |
c.gridwidth = 3; |
c.weightx = 1; |
this.add(panelCheckValue, c); |
this.fieldSoldeA.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
} |
}); |
this.fieldSoldeD.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
} |
}); |
TitledSeparator sepPeriode = new TitledSeparator("Filtre "); |
c.gridy++; |
c.gridx = 0; |
308,7 → 244,7 |
this.dateDeb.addValueListener(new PropertyChangeListener() { |
public void propertyChange(PropertyChangeEvent evt) { |
changeListRequest(); |
PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
PointagePanel.this.model.updateTotauxCompte(); |
} |
}); |
318,7 → 254,7 |
this.dateFin.addValueListener(new PropertyChangeListener() { |
public void propertyChange(PropertyChangeEvent evt) { |
changeListRequest(); |
PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
PointagePanel.this.model.updateTotauxCompte(); |
} |
}); |
510,7 → 446,7 |
this.ecriturePanel.getListe().addListener(new TableModelListener() { |
@Override |
public void tableChanged(TableModelEvent e) { |
PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
PointagePanel.this.model.updateTotauxCompte(); |
} |
}); |
521,7 → 457,7 |
public void update(DocumentEvent e) { |
PointagePanel.this.warningPanel.setVisible((PointagePanel.this.codePointage.getText().trim().length() == 0)); |
PointagePanel.this.buttonPointer.setEnabled((PointagePanel.this.codePointage.getText().trim().length() != 0)); |
PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
PointagePanel.this.model.updateTotauxCompte(); |
} |
}); |
633,7 → 569,7 |
e1.printStackTrace(); |
} |
} |
this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
this.model.updateTotauxCompte(); |
} |
public ListPanelEcritures getEcriturePanel() { |
660,7 → 596,7 |
e1.printStackTrace(); |
} |
} |
this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart); |
this.model.updateTotauxCompte(); |
} |
/* |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SuppressionEcrituresPanel.java |
---|
20,7 → 20,6 |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.warning.JLabelWarning; |
28,10 → 27,7 |
import java.awt.GridBagLayout; |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.util.ArrayList; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import javax.swing.JButton; |
import javax.swing.JFrame; |
73,20 → 69,13 |
c.gridx = 0; |
this.add(labelMouv, c); |
s.append(idS[0]); |
List<Integer> idMvts = new ArrayList<>(); |
for (int i = 1; i < idS.length; i++) { |
idMvts.add(idS[i]); |
s.append(", "); |
s.append(idS[i]); |
} |
s.append(')'); |
Set<String> lettrage = getLettrage(idMvts); |
if (lettrage != null && !lettrage.isEmpty()) { |
s.append("\nAttention certaines écritures sont lettrées avec les codes(" + org.openconcerto.utils.CollectionUtils.join(lettrage, ",") + "!"); |
} |
labelMouv.setText(s.toString()); |
} |
JButton buttonOK = new JButton("OK"); |
143,26 → 132,4 |
return idS; |
} |
private Set<String> getLettrage(List<Integer> mvtIds) { |
Set<String> codes = new HashSet<>(); |
SQLBase b = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); |
SQLTable tableEcr = b.getTable("ECRITURE"); |
SQLSelect sel = new SQLSelect(); |
sel.setDistinct(true); |
sel.addSelect(tableEcr.getField("LETTRAGE")); |
sel.setWhere(new Where(tableEcr.getField("ID_MOUVEMENT"), mvtIds).and(new Where(tableEcr.getField("LETTRAGE"), "=", "").and(new Where(tableEcr.getField("LETTRAGE"), "!=", (Object) null)))); |
List l = (List) b.getDataSource().execute(sel.asString(), new ArrayListHandler()); |
for (int i = 0; i < l.size(); i++) { |
Object[] tmp = (Object[]) l.get(i); |
codes.add(((String) tmp[0])); |
} |
return codes; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteGestCommPreferencePanel.java |
---|
18,6 → 18,7 |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement; |
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture; |
import org.openconcerto.erp.model.ISQLCompteSelector; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLBase; |
import org.openconcerto.sql.model.SQLRow; |
35,6 → 36,7 |
import java.awt.Insets; |
import java.sql.SQLException; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JOptionPane; |
import javax.swing.JPanel; |
48,6 → 50,10 |
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); |
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE"); |
private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte); |
private JCheckBox checkLettrageAuto = new JCheckBox("Activer le lettrage automatique."); |
private JCheckBox checkHideCompteFacture = new JCheckBox("Ne pas afficher les comptes dans les factures."); |
private JCheckBox checkHideCompteClient = new JCheckBox("Ne pas afficher les comptes dans les clients."); |
private JCheckBox checkHideAnalytique = new JCheckBox("Ne pas afficher l'analytique dans les saisies au kilomètre."); |
public CompteGestCommPreferencePanel() { |
super(); |
72,6 → 78,14 |
c.weighty = 0; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(this.checkLettrageAuto, c); |
c.gridy++; |
this.add(this.checkHideCompteClient, c); |
c.gridy++; |
this.add(this.checkHideCompteFacture, c); |
c.gridy++; |
this.add(this.checkHideAnalytique, c); |
c.gridy++; |
/******************************************************************************************* |
* SAISIE DES ACHATS |
361,6 → 375,11 |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_IMMO", this.selCompteTVAImmo.getValue()); |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_PORT_SOUMIS", this.selComptePortSoumis.getValue()); |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_PORT_NON_SOUMIS", this.selComptePortNonSoumis.getValue()); |
this.rowPrefCompteVals.put("AUTO_LETTRAGE", this.checkLettrageAuto.isSelected()); |
DefaultNXProps.getInstance().setProperty("HideCompteClient", String.valueOf(this.checkHideCompteClient.isSelected())); |
DefaultNXProps.getInstance().setProperty("HideCompteFacture", String.valueOf(this.checkHideCompteFacture.isSelected())); |
DefaultNXProps.getInstance().setProperty("HideAnalytique", String.valueOf(this.checkHideAnalytique.isSelected())); |
DefaultNXProps.getInstance().store(); |
try { |
final Object[] pb = this.rowPrefCompteVals.getInvalid(); |
if (pb != null) { |
383,6 → 402,8 |
compte = ComptePCESQLElement.getComptePceDefault("Achats"); |
this.checkLettrageAuto.setSelected(false); |
int value = ComptePCESQLElement.getId(compte); |
this.selCompteAchat.setValue(value); |
504,16 → 525,20 |
} |
this.selJrnlValEnc.setValue(value); |
} |
setComboValues(this.selCompteFourn, "ID_COMPTE_PCE_FOURNISSEUR", "Fournisseurs"); |
setComboValues(this.selCompteClient, "ID_COMPTE_PCE_CLIENT", "Clients"); |
setComboValues(this.selCompteAvanceClient, "ID_COMPTE_PCE_AVANCE_CLIENT", "AvanceClients"); |
setComboValues(this.selCompteValeurEncaissement, "ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", "ValeurEncaissement"); |
setComboValues(this.selComptePortSoumis, "ID_COMPTE_PCE_PORT_SOUMIS", "PortVenteSoumisTVA"); |
setComboValues(this.selComptePortNonSoumis, "ID_COMPTE_PCE_PORT_NON_SOUMIS", "PortVenteNonSoumisTVA"); |
setComboValues(this.selCompteTVACol, "ID_COMPTE_PCE_TVA_VENTE", "TVACollectee"); |
setComboValues(this.selCompteTVADed, "ID_COMPTE_PCE_TVA_ACHAT", "TVADeductible"); |
setComboValues(this.selCompteTVAIntraComm, "ID_COMPTE_PCE_TVA_INTRA", "TVAIntraComm"); |
setComboValues(this.selCompteTVAImmo, "ID_COMPTE_PCE_TVA_IMMO", "TVAImmo"); |
setComboValues(selCompteFourn, "ID_COMPTE_PCE_FOURNISSEUR", "Fournisseurs"); |
setComboValues(selCompteClient, "ID_COMPTE_PCE_CLIENT", "Clients"); |
setComboValues(selCompteAvanceClient, "ID_COMPTE_PCE_AVANCE_CLIENT", "AvanceClients"); |
setComboValues(selCompteValeurEncaissement, "ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", "ValeurEncaissement"); |
setComboValues(selComptePortSoumis, "ID_COMPTE_PCE_PORT_SOUMIS", "PortVenteSoumisTVA"); |
setComboValues(selComptePortNonSoumis, "ID_COMPTE_PCE_PORT_NON_SOUMIS", "PortVenteNonSoumisTVA"); |
setComboValues(selCompteTVACol, "ID_COMPTE_PCE_TVA_VENTE", "TVACollectee"); |
setComboValues(selCompteTVADed, "ID_COMPTE_PCE_TVA_ACHAT", "TVADeductible"); |
setComboValues(selCompteTVAIntraComm, "ID_COMPTE_PCE_TVA_INTRA", "TVAIntraComm"); |
setComboValues(selCompteTVAImmo, "ID_COMPTE_PCE_TVA_IMMO", "TVAImmo"); |
this.checkLettrageAuto.setSelected(rowPrefCompteVals.getBoolean("AUTO_LETTRAGE")); |
this.checkHideCompteClient.setSelected(Boolean.valueOf(DefaultNXProps.getInstance().getProperty("HideCompteClient"))); |
this.checkHideCompteFacture.setSelected(Boolean.valueOf(DefaultNXProps.getInstance().getProperty("HideCompteFacture"))); |
this.checkHideAnalytique.setSelected(Boolean.valueOf(DefaultNXProps.getInstance().getProperty("HideAnalytique"))); |
} catch (Exception e) { |
e.printStackTrace(); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ListeGestCommEltPanel.java |
---|
152,9 → 152,6 |
} |
editModifyFrame.selectionId(this.getListe().getSelectedId()); |
editModifyFrame.setVisible(true); |
// Bouton delete retiré pour passer par la méthode qui supprime les |
// ecritures comptables |
editModifyFrame.getPanel().disableDelete(); |
} else { |
if (this.editReadOnlyFrame == null) { |
this.editReadOnlyFrame = new EditFrame(this.element, EditPanel.READONLY); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/PointageModel.java |
---|
14,7 → 14,6 |
package org.openconcerto.erp.core.finance.accounting.model; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.core.finance.accounting.ui.PointagePanel; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLBase; |
112,11 → 111,6 |
private SwingWorker<String, Object> workerUpdater; |
public void updateTotauxCompte() { |
updateTotauxCompte(null, null, null); |
} |
public void updateTotauxCompte(final DeviseField depart, final DeviseField arrive, final DeviseField ecart) { |
final Date deb = panel.getDateDeb(); |
final Date fin = panel.getDateFin(); |
238,15 → 232,6 |
if (isCancelled()) { |
return; |
} |
if (arrive != null && depart != null && ecart != null) { |
final Long valueArrive = arrive.getValue(); |
final Long valueDepart = depart.getValue(); |
if (valueArrive != null && valueDepart != null) { |
ecart.setValue(valueArrive - valueDepart + PointageModel.this.debitNonPointe - PointageModel.this.creditNonPointe); |
} else { |
ecart.setValue(null); |
} |
} |
PointageModel.this.fireTableDataChanged(); |
} |
}; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/EditionFichePayePanel.java |
---|
259,7 → 259,7 |
public void mousePressed(final MouseEvent e) { |
int row = ((TableSorter) table.getModel()).modelIndex(table.rowAtPoint(e.getPoint())); |
int row = table.rowAtPoint(e.getPoint()); |
final int idSal = model.getIdSalAtRow(row); |
if (e.getButton() == MouseEvent.BUTTON3) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/DiplomePrepareSQLElement.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/InfosSalariePayeSQLElement.java |
---|
141,30 → 141,6 |
this.add(comboConvention, c); |
c.gridwidth = 1; |
// Contrat |
c.fill = GridBagConstraints.BOTH; |
JPanel panelContrat = new JPanel(); |
panelContrat.setOpaque(false); |
panelContrat.setBorder(BorderFactory.createTitledBorder("Contrat de travail")); |
panelContrat.setLayout(new GridBagLayout()); |
GridBagConstraints c2 = new DefaultGridBagConstraints(); |
c2.fill = GridBagConstraints.HORIZONTAL; |
c2.weighty = 1; |
c2.weightx = 1; |
c2.anchor = GridBagConstraints.NORTH; |
this.addView("ID_CONTRAT_SALARIE", REQ + ";" + DEC + ";" + SEP); |
ElementSQLObject eltContrat = (ElementSQLObject) this.getView("ID_CONTRAT_SALARIE"); |
panelContrat.add(eltContrat, c2); |
c.gridx = 0; |
c.gridy++; |
c.gridheight = 1; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.weightx = 1; |
this.add(panelContrat, c); |
c.gridwidth = 1; |
c.gridheight = 1; |
// Classement conventionnel |
c.fill = GridBagConstraints.BOTH; |
JPanel panelClassement = new JPanel(); |
178,10 → 154,10 |
c.weightx = 1; |
panelClassement.add(eltClassement, c); |
c.gridy = 2; |
c.gridy = 1; |
c.gridx = 0; |
c.gridwidth = 2; |
c.weightx = 1; |
c.weightx = 0; |
this.add(panelClassement, c); |
// Classement conventionnel |
198,7 → 174,7 |
c.gridy = 0; |
c.weightx = 1; |
panelCoeff.add(eltCoeff, c); |
c.gridy = 3; |
c.gridy = 2; |
c.gridx = 0; |
c.gridwidth = 2; |
c.weightx = 0; |
205,7 → 181,30 |
this.add(panelCoeff, c); |
c.gridwidth = 1; |
} |
// Contrat |
c.fill = GridBagConstraints.BOTH; |
JPanel panelContrat = new JPanel(); |
panelContrat.setOpaque(false); |
panelContrat.setBorder(BorderFactory.createTitledBorder("Contrat de travail")); |
panelContrat.setLayout(new GridBagLayout()); |
GridBagConstraints c2 = new DefaultGridBagConstraints(); |
c2.fill = GridBagConstraints.HORIZONTAL; |
c2.weighty = 1; |
c2.weightx = 1; |
c2.anchor = GridBagConstraints.NORTH; |
this.addView("ID_CONTRAT_SALARIE", REQ + ";" + DEC + ";" + SEP); |
ElementSQLObject eltContrat = (ElementSQLObject) this.getView("ID_CONTRAT_SALARIE"); |
panelContrat.add(eltContrat, c2); |
c.gridx = 2; |
c.gridy = 1; |
c.gridheight = 4; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.weightx = 1; |
this.add(panelContrat, c); |
c.gridwidth = 1; |
c.gridheight = 1; |
/*********************************************************************************** |
* DATE ENTREE / SORTIE |
**********************************************************************************/ |
249,8 → 248,8 |
* c.gridy++; c.gridx = 0; c.fill = GridBagConstraints.HORIZONTAL; |
* panelEntreeSortie.add(labelAnc, c); c.gridx++; panelEntreeSortie.add(textAnc, c); |
*/ |
c.gridx = 2; |
c.gridy = 2; |
c.gridx = 0; |
c.gridy = 3; |
c.gridwidth = 2; |
this.add(panelEntreeSortie, c); |
c.gridwidth = 1; |
308,7 → 307,6 |
labelSalaireBase.setHorizontalAlignment(SwingConstants.RIGHT); |
JTextField salaireBase = new JTextField(); |
c.gridx++; |
c.weightx = 0; |
panelBase.add(labelSalaireBase, c); |
c.gridx++; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratSalarieSQLElement.java |
---|
246,7 → 246,7 |
this.add(selStatutCatConv, c); |
List<String> dsnFF = Arrays.asList("ID_CONTRAT_MODALITE_TEMPS", "ID_CONTRAT_REGIME_MALADIE", "ID_CONTRAT_REGIME_VIEILLESSE", "ID_CONTRAT_DETACHE_EXPATRIE", |
"ID_CONTRAT_DISPOSITIF_POLITIQUE", "ID_CONTRAT_MOTIF_RECOURS", "ID_DIPLOME_PREPARE"); |
"ID_CONTRAT_DISPOSITIF_POLITIQUE", "ID_CONTRAT_MOTIF_RECOURS"); |
int p = 0; |
for (String ffName : dsnFF) { |
JLabel labelFF = new JLabel(getLabelFor(ffName)); |
266,7 → 266,7 |
c.weighty = 1; |
c.weightx = 1; |
this.add(selFF, c); |
if (ffName.equals("ID_CONTRAT_MOTIF_RECOURS") || ffName.equals("ID_DIPLOME_PREPARE")) { |
if (ffName.equals("ID_CONTRAT_MOTIF_RECOURS")) { |
this.addSQLObject(selFF, ffName); |
} else { |
this.addRequiredSQLObject(selFF, ffName); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/SalarieSQLElement.java |
---|
49,9 → 49,11 |
import java.util.ArrayList; |
import java.util.Date; |
import java.util.List; |
import java.util.Map; |
import javax.swing.AbstractAction; |
import javax.swing.BorderFactory; |
import javax.swing.JComponent; |
import javax.swing.JLabel; |
import javax.swing.JOptionPane; |
import javax.swing.JPanel; |
314,7 → 316,8 |
this.tabbedPane.add("Cumuls et variables de la période", new JScrollPane(panelAllCumul)); |
// this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() - 1, false); |
if (!getElement().getAdditionalFields().isEmpty()) { |
Map<String, JComponent> additionalFields = getElement().getAdditionalFields(); |
if (additionalFields != null && additionalFields.size() > 0) { |
// Champ Module |
c.gridx = 0; |
c.gridy++; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/FichePayeSheetXML.java |
---|
220,11 → 220,11 |
tauxPatLigne = sqlRowAccessor.getBigDecimal("TAUX_PAT"); |
} |
if (tauxSalLigne.signum() > 0 && montantSalLigne.signum() != 0) { |
if (tauxSalLigne.signum() > 0) { |
ligneSimplifiee.put("TAUX_SAL", tauxSalBulletinSimpl.add(tauxSalLigne)); |
} |
if (tauxPatLigne.signum() > 0 && montantPatLigne.signum() != 0) { |
if (tauxPatLigne.signum() > 0) { |
ligneSimplifiee.put("TAUX_PAT", tauxPatBulletinSimpl.add(tauxPatLigne)); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/element/CommercialSQLElement.java |
---|
14,10 → 14,7 |
package org.openconcerto.erp.core.humanresources.employe.element; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.edm.AttachmentAction; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.utils.ListMap; |
import java.util.ArrayList; |
31,12 → 28,7 |
public CommercialSQLElement(String tableName, String singular, String plural) { |
super(tableName, singular, plural); |
if (getTable().contains("ATTACHMENTS")) { |
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true); |
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
getRowActions().add(actionAttachment); |
} |
} |
protected List<String> getListFields() { |
final List<String> l = new ArrayList<String>(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentPanel.java |
---|
45,7 → 45,6 |
import java.io.IOException; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.Collections; |
import java.util.Comparator; |
import java.util.HashSet; |
66,7 → 65,6 |
public class AttachmentPanel extends JPanel { |
private final SQLRowAccessor rowSource; |
private final Collection<SQLRowAccessor> rowSecondaires; |
private List<ListDataListener> listeners = new ArrayList<>(); |
private int idParent = 1; |
76,14 → 74,8 |
private List<FilePanel> filePanels = new ArrayList<>(); |
public AttachmentPanel(SQLRowAccessor rowSource) { |
this(rowSource, Collections.emptyList()); |
} |
public AttachmentPanel(SQLRowAccessor rowSource, Collection<SQLRowAccessor> rowSecondaires) { |
super(); |
this.rowSource = rowSource; |
this.rowSecondaires = rowSecondaires; |
this.setLayout(new GridBagLayout()); |
this.parents.add(1); |
this.parentsNames.add("Racine"); |
100,17 → 92,13 |
} |
public void fireDataChanged() { |
for (ListDataListener listDataListener : this.listeners) { |
for (ListDataListener listDataListener : listeners) { |
listDataListener.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, 0)); |
} |
} |
public int getAttachementsSize() { |
return this.filePanels.size(); |
} |
public void initUI() { |
this.filePanels.clear(); |
filePanels.clear(); |
this.invalidate(); |
this.removeAll(); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
118,7 → 106,7 |
// Recupération de la liste des fichiers |
// TODO requete dans un SwingWorker |
final SQLTable tableAttachment = this.rowSource.getTable().getTable("ATTACHMENT"); |
final SQLTable tableAttachment = rowSource.getTable().getTable("ATTACHMENT"); |
SQLRowValues rowVals = new SQLRowValues(tableAttachment); |
rowVals.putNulls(tableAttachment.getFieldsName()); |
127,13 → 115,7 |
where = where.and(new Where(tableAttachment.getField("SOURCE_ID"), "=", this.rowSource.getID())); |
where = where.and(new Where(tableAttachment.getField("ID_PARENT"), "=", this.idParent)); |
for (SQLRowAccessor rowSecondaire : this.rowSecondaires) { |
Where whereSec = new Where(tableAttachment.getField("SOURCE_TABLE"), "=", rowSecondaire.getTable().getName()); |
whereSec = whereSec.and(new Where(tableAttachment.getField("SOURCE_ID"), "=", rowSecondaire.getID())); |
where = where.or(whereSec); |
} |
final List<SQLRowValues> rAttachments = fetcher.fetch(where); |
c.fill = GridBagConstraints.BOTH; |
c.anchor = GridBagConstraints.WEST; |
229,7 → 211,7 |
public void actionPerformed(ActionEvent e) { |
AttachmentUtils utils = new AttachmentUtils(); |
try { |
utils.createFolder("Nouveau dossier", AttachmentPanel.this.rowSource, AttachmentPanel.this.idParent); |
utils.createFolder("Nouveau dossier", rowSource, idParent); |
} catch (SQLException e1) { |
JOptionPane.showMessageDialog(null, "Impossible de créer le dossier.", "Erreur", JOptionPane.ERROR_MESSAGE); |
} |
247,17 → 229,12 |
fd.setVisible(true); |
final String fileName = fd.getFile(); |
if (fileName != null) { |
try { |
File inFile = new File(fd.getDirectory(), fileName); |
AttachmentUtils utils = new AttachmentUtils(); |
utils.uploadFile(inFile, AttachmentPanel.this.rowSource, AttachmentPanel.this.idParent); |
utils.uploadFile(inFile, rowSource, idParent); |
initUI(); |
} catch (Exception ex) { |
ex.printStackTrace(); |
JOptionPane.showMessageDialog(AttachmentPanel.this, "Erreur lors de l'ajout du fichier " + fileName + "(" + ex.getMessage() + ")"); |
} |
} |
} |
}); |
ScrollablePanel files = new ScrollablePanel() { |
373,6 → 350,7 |
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); |
Transferable t = dtde.getTransferable(); |
try { |
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { |
@SuppressWarnings("unchecked") |
List<File> fileList = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor); |
384,15 → 362,10 |
if (cancelledByUser) { |
break; |
} |
try { |
if (!f.isDirectory()) { |
utils.uploadFile(f, AttachmentPanel.this.rowSource, AttachmentPanel.this.idParent); |
utils.uploadFile(f, rowSource, idParent); |
} |
} catch (Exception ex) { |
ex.printStackTrace(); |
JOptionPane.showMessageDialog(AttachmentPanel.this, "Erreur lors de l'ajout du fichier " + f.getAbsolutePath() + "(" + ex.getMessage() + ")"); |
} |
} |
initUI(); |
} |
} catch (Exception e) { |
406,7 → 379,7 |
} |
public Set<Attachment> getSelectedAttachments() { |
return this.selectedAttachments; |
return selectedAttachments; |
} |
public void select(Attachment a) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentUtils.java |
---|
17,14 → 17,10 |
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager; |
import org.openconcerto.erp.storage.StorageEngine; |
import org.openconcerto.erp.storage.StorageEngines; |
import org.openconcerto.sql.model.SQLInsert; |
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.utils.Base64; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.FileUtils; |
import org.openconcerto.utils.sync.SyncClient; |
33,80 → 29,22 |
import java.io.File; |
import java.io.FileInputStream; |
import java.io.IOException; |
import java.nio.charset.StandardCharsets; |
import java.nio.file.Files; |
import java.security.InvalidAlgorithmParameterException; |
import java.security.InvalidKeyException; |
import java.security.NoSuchAlgorithmException; |
import java.sql.SQLException; |
import java.util.List; |
import javax.crypto.BadPaddingException; |
import javax.crypto.Cipher; |
import javax.crypto.IllegalBlockSizeException; |
import javax.crypto.KeyGenerator; |
import javax.crypto.NoSuchPaddingException; |
import javax.crypto.SecretKey; |
import javax.crypto.spec.GCMParameterSpec; |
import javax.crypto.spec.SecretKeySpec; |
import javax.swing.JOptionPane; |
public class AttachmentUtils { |
String generateBase64Key() throws NoSuchAlgorithmException { |
final KeyGenerator generator = KeyGenerator.getInstance("AES"); |
generator.init(16 * 8); |
final SecretKey k = generator.generateKey(); |
return Base64.encodeBytes(k.getEncoded(), Base64.DONT_BREAK_LINES); |
} |
public void uploadFile(File inFile, SQLRowAccessor rowSource, int idParent) { |
try { |
SecretKey getSecretKey(String base64key) { |
byte[] b = Base64.decode(base64key.getBytes(StandardCharsets.UTF_8)); |
if (b.length != 16) { |
throw new IllegalStateException("key length must be 16 bytes for AES"); |
} |
return new SecretKeySpec(b, "AES"); |
} |
public byte[] encrypt(SecretKey secretKey, byte[] in) |
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException { |
return process(secretKey, in, Cipher.ENCRYPT_MODE); |
} |
public byte[] decrypt(SecretKey secretKey, byte[] in) |
throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException { |
return process(secretKey, in, Cipher.DECRYPT_MODE); |
} |
public byte[] process(SecretKey secretKey, byte[] in, int mode) |
throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException { |
final Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); |
final byte[] nonce = new byte[12]; |
final byte[] e = secretKey.getEncoded(); |
for (int i = 0; i < nonce.length; i++) { |
nonce[i] = (byte) (e[i] * e[i + 1] + e[i + 2]); |
} |
GCMParameterSpec spec = new GCMParameterSpec(16 * 8, nonce); |
cipher.init(mode, secretKey, spec); |
return cipher.doFinal(in); |
} |
public void uploadFile(File inFile, SQLRowAccessor rowSource, int idParent) throws SQLException { |
uploadFile(inFile, rowSource, idParent, null); |
} |
public void uploadFile(File inFile, SQLRowAccessor rowSource, int idParent, String nameInGed) throws SQLException { |
String encodeKey = fetchEncodedKey(rowSource.getTable().getTable("FWK_SCHEMA_METADATA")); |
// Création de la row attachment |
SQLRowValues rowValsAttachment = new SQLRowValues(rowSource.getTable().getTable("ATTACHMENT")); |
rowValsAttachment.put("SOURCE_TABLE", rowSource.getTable().getName()); |
rowValsAttachment.put("SOURCE_ID", rowSource.getID()); |
rowValsAttachment.put("ID_PARENT", idParent); |
if (encodeKey != null) { |
rowValsAttachment.put("ENCRYPTED", true); |
} |
SQLRow rowAttachment = rowValsAttachment.insert(); |
int id = rowAttachment.getID(); |
125,36 → 63,39 |
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta(); |
boolean isOnCloud = config.isOnCloud(); |
try { |
if (isOnCloud) { |
String remotePath = subDir; |
final List<StorageEngine> engines = StorageEngines.getInstance().getActiveEngines(); |
File encodedFile = inFile; |
if (encodeKey != null) { |
encodedFile = File.createTempFile("encrypted", inFile.getName()); |
final byte[] enc = encrypt(getSecretKey(encodeKey), FileUtils.readBytes(inFile)); |
Files.write(encodedFile.toPath(), enc); |
} |
List<StorageEngine> engines = StorageEngines.getInstance().getActiveEngines(); |
for (StorageEngine storageEngine : engines) { |
if (storageEngine.isConfigured() && storageEngine.allowAutoStorage()) { |
final String path = remotePath; |
try (FileInputStream in = new FileInputStream(encodedFile)) { |
try (FileInputStream in = new FileInputStream(inFile)) { |
storageEngine.connect(); |
final BufferedInputStream inStream = new BufferedInputStream(in); |
storageEngine.store(inStream, path, fileWithIDNAme, true); |
inStream.close(); |
storageEngine.disconnect(); |
} catch (IOException e) { |
ExceptionHandler.handle("Impossible de sauvegarder le fichier " + inFile.getAbsolutePath() + " vers " + path + "(" + storageEngine + ")", e); |
} |
// if (storageEngine instanceof CloudStorageEngine) { |
// try { |
// storageEngine.connect(); |
// final BufferedInputStream inStream = new BufferedInputStream(new |
// FileInputStream(generatedFile)); |
// storageEngine.store(inStream, path, generatedFile.getName(), true); |
// inStream.close(); |
// storageEngine.disconnect(); |
// } catch (IOException e) { |
// ExceptionHandler.handle("Impossible de sauvegarder le fichier généré " + |
// generatedFile.getAbsolutePath() + " vers " + path + "(" + storageEngine + |
// ")", e); |
// } |
// } |
} |
} |
if (encodeKey != null) { |
encodedFile.delete(); |
} |
} else { |
// Upload File |
163,14 → 104,9 |
File storagePathFile = new File(dirRoot, subDir); |
storagePathFile.mkdirs(); |
// TODO CHECK IF FILE EXISTS |
if (encodeKey == null) { |
FileUtils.copyFile(inFile, new File(storagePathFile, fileWithIDNAme)); |
} else { |
final File encodedFile = new File(storagePathFile, fileWithIDNAme); |
final byte[] enc = encrypt(getSecretKey(encodeKey), FileUtils.readBytes(inFile)); |
Files.write(encodedFile.toPath(), enc); |
} |
} |
// Update rowAttachment |
rowValsAttachment = rowAttachment.createEmptyUpdateRow(); |
177,9 → 113,6 |
// Default is without extension |
String fileName = inFile.getName(); |
if (nameInGed != null) { |
rowValsAttachment.put("NAME", nameInGed); |
} else { |
String name = fileName; |
int index = name.lastIndexOf('.'); |
if (index > 0) { |
186,11 → 119,8 |
name = name.substring(0, index); |
} |
rowValsAttachment.put("NAME", name); |
} |
rowValsAttachment.put("SOURCE_TABLE", rowSource.getTable().getName()); |
rowValsAttachment.put("SOURCE_ID", rowSource.getID()); |
rowValsAttachment.put("ID_PARENT", idParent); |
final String mimeType = Files.probeContentType(inFile.toPath()); |
rowValsAttachment.put("MIMETYPE", mimeType != null ? mimeType : "application/octet-stream"); |
rowValsAttachment.put("FILENAME", fileName); |
197,7 → 127,6 |
rowValsAttachment.put("FILESIZE", inFile.length()); |
rowValsAttachment.put("STORAGE_PATH", subDir); |
rowValsAttachment.put("STORAGE_FILENAME", fileWithIDNAme); |
rowValsAttachment.put("ENCRYPTED", (encodeKey != null)); |
// TODO THUMBNAIL |
// rowVals.put("THUMBNAIL", ); |
// rowVals.put("THUMBNAIL_WIDTH", ); |
208,39 → 137,11 |
rowValsAttachment.commit(); |
final Attachment a = new Attachment(rowValsAttachment); |
updateAttachmentsCountFromAttachment(a); |
} catch (Exception e) { |
if (rowAttachment != null) { |
config.getDirectory().getElement(AttachmentSQLElement.class).archive(rowAttachment.getID()); |
e.printStackTrace(); |
} |
ExceptionHandler.handle("Impossible de sauvegarder le fichier " + inFile.getAbsolutePath(), e); |
} |
} |
public String fetchEncodedKey(SQLTable table) { |
final SQLSelect select = new SQLSelect(); |
select.addSelect(table.getField("VALUE")); |
select.setWhere(new Where(table.getField("NAME"), "=", AttachmentSQLElement.EDM_KEY_METADATA)); |
final List<?> rows = table.getDBSystemRoot().getDataSource().executeCol(select.asString()); |
if (rows.size() == 1) { |
return rows.get(0).toString(); |
} |
return null; |
} |
public void createKeyOnDatabase(SQLTable table) throws NoSuchAlgorithmException { |
final String s = fetchEncodedKey(table); |
if (s != null) { |
throw new IllegalStateException("key alread exists"); |
} |
final SQLInsert insert = new SQLInsert(); |
insert.add(table.getField("NAME"), AttachmentSQLElement.EDM_KEY_METADATA); |
insert.add(table.getField("VALUE"), generateBase64Key()); |
table.getDBSystemRoot().getDataSource().execute(insert.asString()); |
} |
public File getFile(Attachment attachment) { |
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta(); |
301,21 → 202,6 |
} |
} |
final File outFile = new File(f, fileName); |
if (attachment.isEncrypted() && outFile.length() > 0) { |
try { |
final byte[] bytes = FileUtils.readBytes(outFile); |
final String encodeKey = fetchEncodedKey(config.getRootSociete().getTable("FWK_SCHEMA_METADATA")); |
if (encodeKey == null) { |
throw new IllegalStateException("missing key"); |
} |
final byte[] decrypted = decrypt(getSecretKey(encodeKey), bytes); |
Files.write(outFile.toPath(), decrypted); |
} catch (Exception e) { |
ExceptionHandler.handle("Impossible de decrypter le fichier\n" + outFile.getAbsolutePath(), e); |
return null; |
} |
} |
outFile.setReadOnly(); |
return outFile; |
322,12 → 208,8 |
} |
public void deleteFile(Attachment rowAttachment) throws SQLException, IllegalStateException { |
// Delete Row |
// Remove from DB first |
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta(); |
config.getDirectory().getElement(AttachmentSQLElement.class).archive(rowAttachment.getId()); |
updateAttachmentsCountFromAttachment(rowAttachment); |
if (!rowAttachment.isFolder()) { |
boolean isOnCloud = config.isOnCloud(); |
// Delete File |
355,7 → 237,9 |
} |
} |
} |
// Delete Row |
config.getDirectory().getElement(AttachmentSQLElement.class).archive(rowAttachment.getId()); |
updateAttachmentsCountFromAttachment(rowAttachment); |
} |
private void updateAttachmentsCountFromAttachment(Attachment rowAttachment) { |
415,10 → 299,6 |
final String req = "UPDATE " + attachmentTable.getSQLName().quote() + " SET " + attachmentTable.getField("ID_PARENT").getQuotedName() + "=" + folderId + " WHERE " |
+ attachmentTable.getKey().getQuotedName() + "=" + a.getId(); |
attachmentTable.getDBSystemRoot().getDataSource().execute(req); |
} |
public static void main(String[] args) throws NoSuchAlgorithmException { |
System.err.println("AttachmentUtils.main() key : " + new AttachmentUtils().generateBase64Key()); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentSQLElement.java |
---|
22,22 → 22,8 |
public class AttachmentSQLElement extends ComptaSQLConfElement { |
public static final String EDM_KEY_METADATA = "EDM_KEY"; |
public static final String DIRECTORY_PREFS = "EDMdirectory"; |
public static final String ITEM_SOURCE_TABLE = "source.table"; |
public static final String ITEM_SOURCE_ID = "source.id"; |
public static final String ITEM_NAME = "name"; |
public static final String ITEM_MIMETYPE = "mimetype"; |
public static final String ITEM_FILENAME = "filename"; |
public static final String ITEM_STORAGE_PATH = "storage.path"; |
public static final String ITEM_THUMBNAIL = "thumbnail"; |
public static final String ITEM_THUMBNAIL_WIDTH = "thumbnail.width"; |
public static final String ITEM_THUMBNAIL_HEIGHT = "thumbnail.height"; |
public static final String ITEM_TAG = "tag"; |
public static final String ITEM_PARENT = "parent.id"; |
public AttachmentSQLElement() { |
super("ATTACHMENT", "un attachement", "attachements"); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/Attachment.java |
---|
29,7 → 29,7 |
private String sourceTable; |
private int sourceId; |
private int parentId; |
private boolean encrypted; |
public static final String MIMETYPE_FOLDER = "inode/directory"; |
public Attachment(SQLRowValues rowAttachment) { |
43,15 → 43,14 |
this.sourceTable = rowAttachment.getString("SOURCE_TABLE"); |
this.sourceId = rowAttachment.getInt("SOURCE_ID"); |
this.parentId = rowAttachment.getInt("ID_PARENT"); |
this.encrypted = rowAttachment.getBoolean("ENCRYPTED"); |
} |
public int getId() { |
return this.id; |
return id; |
} |
public String getName() { |
return this.name; |
return name; |
} |
public void setName(String newName) { |
59,35 → 58,35 |
} |
public String getMimeType() { |
return this.mimeType; |
return mimeType; |
} |
public String getFileName() { |
return this.fileName; |
return fileName; |
} |
public int getFileSize() { |
return this.fileSize; |
return fileSize; |
} |
public String getStorageFileName() { |
return this.storageFileName; |
return storageFileName; |
} |
public String getStoragePath() { |
return this.storagePath; |
return storagePath; |
} |
public String getSourceTable() { |
return this.sourceTable; |
return sourceTable; |
} |
public int getSourceId() { |
return this.sourceId; |
return sourceId; |
} |
public int getParentId() { |
return this.parentId; |
return parentId; |
} |
public boolean isFolder() { |
94,10 → 93,6 |
return this.mimeType.equals(MIMETYPE_FOLDER); |
} |
public boolean isEncrypted() { |
return this.encrypted; |
} |
@Override |
public String toString() { |
return super.toString() + " attachment id:" + this.getId() + " name:" + this.getName(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/CustomerProductFamilyQtyPriceSQLElement.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReferenceArticleSQLElement.java |
---|
212,8 → 212,6 |
l.add("PV_HT"); |
l.add("ID_TAXE"); |
l.add("PV_TTC"); |
l.add("ID_COMPTE_PCE"); |
l.add("ID_COMPTE_PCE_ACHAT"); |
l.add("ID_FAMILLE_ARTICLE"); |
l.add("ID_FOURNISSEUR"); |
l.add("POIDS"); |
228,7 → 226,6 |
if (b != null && b.booleanValue()) { |
l.add("SERVICE"); |
} |
return l; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/TransfertStockPanel.java |
---|
20,9 → 20,7 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem.TypeStockMouvement; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.ConnectionHandlerNoSetup; |
import org.openconcerto.sql.model.DBRoot; |
import org.openconcerto.sql.model.SQLDataSource; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
83,6 → 81,7 |
final SQLRequestComboBox comboStockArrive = new SQLRequestComboBox(); |
comboStockArrive.uiInit(stockElt.createComboRequest()); |
JLabel qteReel = new JLabel("Quantité", SwingConstants.RIGHT); |
final NumericTextField fieldReel = new NumericTextField(); |
fieldReel.getDocument().addDocumentListener(new SimpleDocumentListener() { |
89,7 → 88,8 |
@Override |
public void update(DocumentEvent e) { |
updateButtons(buttonUpdate, comboArticle, comboStockDepart, comboStockArrive, fieldReel); |
buttonUpdate.setEnabled( |
fieldReel.getText().trim().length() > 0 && comboArticle.getSelectedRow() != null && comboStockArrive.getSelectedRow() != null && comboStockDepart.getSelectedRow() != null); |
} |
}); |
97,7 → 97,8 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
updateButtons(buttonUpdate, comboArticle, comboStockDepart, comboStockArrive, fieldReel); |
buttonUpdate.setEnabled( |
fieldReel.getText().trim().length() > 0 && comboArticle.getSelectedRow() != null && comboStockArrive.getSelectedRow() != null && comboStockDepart.getSelectedRow() != null); |
} |
}); |
105,7 → 106,8 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
updateButtons(buttonUpdate, comboArticle, comboStockDepart, comboStockArrive, fieldReel); |
buttonUpdate.setEnabled( |
fieldReel.getText().trim().length() > 0 && comboArticle.getSelectedRow() != null && comboStockArrive.getSelectedRow() != null && comboStockDepart.getSelectedRow() != null); |
} |
}); |
113,16 → 115,17 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
updateButtons(buttonUpdate, comboArticle, comboStockDepart, comboStockArrive, fieldReel); |
buttonUpdate.setEnabled( |
fieldReel.getText().trim().length() > 0 && comboArticle.getSelectedRow() != null && comboStockArrive.getSelectedRow() != null && comboStockDepart.getSelectedRow() != null); |
} |
}); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
c.gridx = 0; |
this.add(new JLabel("Intitulé"), c); |
final JTextField label = new JTextField(); |
c.gridx++; |
c.gridwidth = 1; |
c.gridwidth = 2; |
c.weightx = 1; |
this.add(label, c); |
label.setText(defaultLabel); |
129,49 → 132,72 |
c.gridy++; |
c.gridx = 0; |
c.gridwidth = 1; |
c.weightx = 0; |
this.add(new JLabel("Date", SwingConstants.RIGHT), c); |
final JDate date = new JDate(true); |
c.gridx++; |
c.weightx = 0; |
this.add(date, c); |
c.gridy++; |
c.gridx = 0; |
c.gridwidth = 2; |
c.weightx = 0; |
this.add(new JLabel("Article", SwingConstants.RIGHT), c); |
c.gridx++; |
c.gridx += 2; |
c.gridwidth = 1; |
c.weightx = 1; |
this.add(comboArticle, c); |
c.gridy++; |
c.gridx = 0; |
c.gridwidth = 2; |
c.weightx = 0; |
this.add(new JLabel("Départ", SwingConstants.RIGHT), c); |
c.gridx++; |
c.gridx += 2; |
c.gridwidth = 1; |
c.weightx = 1; |
this.add(comboStockDepart, c); |
c.gridy++; |
c.gridx = 0; |
c.gridwidth = 2; |
c.weightx = 0; |
this.add(new JLabel("Arrivée", SwingConstants.RIGHT), c); |
c.gridx++; |
c.gridx += 2; |
c.gridwidth = 1; |
c.weightx = 1; |
this.add(comboStockArrive, c); |
c.gridy++; |
c.gridx = 0; |
c.gridwidth = 2; |
c.weightx = 0; |
this.add(new JLabel("Quantité", SwingConstants.RIGHT), c); |
c.gridx++; |
this.add(qteReel, c); |
c.gridx += 2; |
c.gridwidth = 1; |
c.weightx = 1; |
this.add(fieldReel, c); |
c.gridy++; |
c.gridx = 0; |
c.gridwidth = 2; |
c.weightx = 0; |
this.add(qteReel, c); |
c.gridx += 2; |
c.gridwidth = 1; |
c.weightx = 1; |
this.add(fieldReel, c); |
c.gridy++; |
c.gridx = 0; |
JButton buttonCancel = new JButton("Annuler"); |
JPanel pButton = new JPanel(); |
pButton.add(buttonCancel); |
pButton.add(buttonUpdate); |
c.gridwidth = 2; |
c.anchor = GridBagConstraints.SOUTHEAST; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.anchor = GridBagConstraints.EAST; |
c.weightx = 0; |
c.fill = GridBagConstraints.NONE; |
this.add(pButton, c); |
186,19 → 212,19 |
@Override |
public void actionPerformed(ActionEvent e) { |
buttonUpdate.setEnabled(false); |
BigDecimal qteReel = fieldReel.getValue(); |
List<String> multipleRequestsHundred = new ArrayList<String>(100); |
boolean usePrice = mvtStockTable.contains("PRICE"); |
List<StockItem> stockItems = new ArrayList<StockItem>(); |
final Date dateValue = date.getValue(); |
final SQLRow selectedRowArticle = comboArticle.getSelectedRow(); |
final SQLRow selectedRowDepotDepart = comboStockDepart.getSelectedRow(); |
final SQLRow selectedRowDepotArrivee = comboStockArrive.getSelectedRow(); |
try { |
SQLUtils.executeAtomic(selectedRowDepotDepart.getTable().getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, SQLException>() { |
@Override |
public Object handle(SQLDataSource ds) throws SQLException { |
{ |
// DEPART |
final SQLRowAccessor rowStockDepart = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotDepart); |
207,7 → 233,12 |
SQLRowValues rowVals = new SQLRowValues(mvtStockTable.getTable("STOCK")); |
rowVals.put("ID_ARTICLE", selectedRowArticle.getID()); |
rowVals.put("ID_DEPOT_STOCK", selectedRowDepotDepart.getID()); |
try { |
rowVals.commit(); |
} catch (SQLException e1) { |
// TODO Auto-generated catch block |
e1.printStackTrace(); |
} |
selectedRowArticle.fetchValues(); |
item = new StockItem(selectedRowArticle, rowStockDepart); |
} |
214,22 → 245,28 |
stockItems.add(item); |
double diff = -qteReel.doubleValue(); |
item.updateQty(diff, TypeStockMouvement.REEL); |
multipleRequestsHundred |
.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), true, usePrice)); |
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), true, usePrice)); |
item.updateQty(diff, TypeStockMouvement.THEORIQUE); |
multipleRequestsHundred |
.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice)); |
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice)); |
multipleRequestsHundred.add(item.getUpdateRequest()); |
} |
// ARRIVEE |
{ |
final SQLRowAccessor rowStockArrivee = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotArrivee); |
StockItem item = new StockItem(selectedRowArticle, rowStockArrivee); |
if (!item.isStockInit()) { |
SQLRowValues rowVals = new SQLRowValues(mvtStockTable.getTable("STOCK")); |
rowVals.put("ID_ARTICLE", selectedRowArticle.getID()); |
rowVals.put("ID_DEPOT_STOCK", selectedRowDepotArrivee.getID()); |
try { |
rowVals.commit(); |
} catch (SQLException e1) { |
// TODO Auto-generated catch block |
e1.printStackTrace(); |
} |
selectedRowArticle.fetchValues(); |
item = new StockItem(selectedRowArticle, rowStockArrivee); |
} |
236,14 → 273,16 |
stockItems.add(item); |
double diff = qteReel.doubleValue(); |
item.updateQty(diff, TypeStockMouvement.REEL); |
multipleRequestsHundred |
.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), true, usePrice)); |
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), true, usePrice)); |
item.updateQty(diff, TypeStockMouvement.THEORIQUE); |
multipleRequestsHundred |
.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice)); |
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice)); |
multipleRequestsHundred.add(item.getUpdateRequest()); |
} |
try { |
final int size = multipleRequestsHundred.size(); |
List<? extends ResultSetHandler> handlers = new ArrayList<ResultSetHandler>(size); |
for (int i = 0; i < size; i++) { |
251,18 → 290,28 |
} |
SQLUtils.executeMultiple(instance.getRoot().getDBSystemRoot(), multipleRequestsHundred, handlers); |
} catch (SQLException e1) { |
ExceptionHandler.handle("Stock update error", e1); |
} |
final DBRoot root = mvtStockTable.getDBRoot(); |
if (root.contains("ARTICLE_ELEMENT")) { |
// List<StockItem> stockItems = new ArrayList<StockItem>(); |
// for (SQLRowAccessor sqlRowAccessor2 : stocks) { |
// final SQLRow asRow = sqlRowAccessor2.asRow(); |
// asRow.fetchValues(); |
// stockItems.add(new StockItem(asRow)); |
// } |
// Mise à jour des stocks des nomenclatures |
ComposedItemStockUpdater comp = new ComposedItemStockUpdater(root, stockItems); |
try { |
comp.update(); |
} catch (SQLException e1) { |
e1.printStackTrace(); |
} |
return null; |
} |
}); |
} catch (SQLException e1) { |
ExceptionHandler.handle("Stock update error", e1); |
} |
// liste.getModel().updateAll(); |
((JFrame) SwingUtilities.getRoot(TransfertStockPanel.this)).dispose(); |
} |
}); |
269,12 → 318,14 |
} |
private String getLabel(String label, SQLRowAccessor fromDepot, SQLRowAccessor toDepot) { |
return label + " de " + fromDepot.getString("NOM") + " vers " + toDepot.getString("NOM"); |
} |
private String getMvtRequest(Date time, BigDecimal prc, double qteFinal, StockItem item, String label, boolean reel, boolean usePrice) { |
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
String mvtStockQuery = "INSERT INTO " + this.mvtStockTableQuoted + " (\"QTE\",\"DATE\",\"ID_ARTICLE\",\"ID_STOCK\",\"NOM\",\"REEL\",\"ORDRE\""; |
String mvtStockQuery = "INSERT INTO " + mvtStockTableQuoted + " (\"QTE\",\"DATE\",\"ID_ARTICLE\",\"ID_STOCK\",\"NOM\",\"REEL\",\"ORDRE\""; |
if (usePrice && prc != null) { |
mvtStockQuery += ",\"PRICE\""; |
281,7 → 332,7 |
} |
mvtStockQuery += ") VALUES(" + qteFinal + ",'" + dateFormat.format(time) + "'," + item.getArticle().getID() + "," + item.stock.getID() + ",'" + label + "'," + reel |
+ ", (SELECT (MAX(\"ORDRE\")+1) FROM " + this.mvtStockTableQuoted + ")"; |
+ ", (SELECT (MAX(\"ORDRE\")+1) FROM " + mvtStockTableQuoted + ")"; |
if (usePrice && prc != null) { |
mvtStockQuery += "," + prc.setScale(6, RoundingMode.HALF_UP).toString(); |
} |
288,10 → 339,4 |
mvtStockQuery += ")"; |
return mvtStockQuery; |
} |
private void updateButtons(final JButton buttonUpdate, final SQLRequestComboBox comboArticle, final SQLRequestComboBox comboStockDepart, final SQLRequestComboBox comboStockArrive, |
final NumericTextField fieldReel) { |
buttonUpdate.setEnabled(fieldReel.getText().trim().length() > 0 && comboArticle.getSelectedRow() != null && comboStockArrive.getSelectedRow() != null |
&& comboStockDepart.getSelectedRow() != null && comboStockArrive.getSelectedRow().getID() != comboStockDepart.getSelectedRow().getID()); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/CustomerProductFamilyQtyPriceListTable.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductHelper.java |
---|
320,9 → 320,7 |
for (ProductComponent productParent : source) { |
final SQLRowAccessor foreignArticle = childRowValues.getForeign("ID_ARTICLE"); |
int childQ = childRowValues.getInt("QTE"); |
BigDecimal childqD = childRowValues.getBigDecimal("QTE_UNITAIRE"); |
ProductComponent childComponent = ProductComponent.createFromRowArticle(foreignArticle, childqD.multiply(new BigDecimal(childQ)), productParent.getSource()); |
ProductComponent childComponent = ProductComponent.createFromRowArticle(foreignArticle, productParent.getSource()); |
// parentsArticleIDs.remove(foreignArticleParent.getID()); |
// Calcul de la quantité qte_unit * qte * qteMergedParent |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductComponent.java |
---|
134,16 → 134,12 |
return null; |
} |
public static ProductComponent createFromRowArticle(SQLRowAccessor rowArticle, BigDecimal qty, SQLRowAccessor rowValsSource) { |
public static ProductComponent createFromRowArticle(SQLRowAccessor rowArticle, SQLRowAccessor rowValsSource) { |
SQLRowAccessor rowStock = getStock(rowArticle, rowArticle, rowValsSource); |
return new ProductComponent(rowArticle, qty, rowValsSource, rowStock); |
return new ProductComponent(rowArticle, BigDecimal.ONE, rowValsSource, rowStock); |
} |
public static ProductComponent createFromRowArticle(SQLRowAccessor rowArticle, SQLRowAccessor rowValsSource) { |
return createFromRowArticle(rowArticle, BigDecimal.ONE, rowValsSource); |
} |
public static ProductComponent createFrom(SQLRowAccessor rowVals) { |
return createFrom(rowVals, 1, rowVals); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ReferenceArticleSQLComponent.java |
---|
89,36 → 89,36 |
public class ReferenceArticleSQLComponent extends BaseSQLComponent { |
protected JTextField textPVHT, textPVTTC, textPAHT; |
protected JTextField textMetrique1VT, textMetrique1HA; |
private JTextField textPVHT, textPVTTC, textPAHT; |
private JTextField textMetrique1VT, textMetrique1HA; |
protected final JCheckBox boxService = new JCheckBox(getLabelFor("SERVICE")); |
protected final JCheckBox checkObs = new JCheckBox(getLabelFor("OBSOLETE")); |
protected JTextField textNom, textCode; |
protected JTextField textPoids; |
protected JTextField textValMetrique1, textValMetrique2, textValMetrique3; |
protected DocumentListener htDocListener, ttcDocListener, detailsListener; |
protected PropertyChangeListener propertyChangeListener; |
protected PropertyChangeListener taxeListener; |
protected final ElementComboBox comboSelTaxe = new ElementComboBox(false, 10); |
protected final ElementComboBox comboSelModeVente = new ElementComboBox(false, 25); |
protected JLabel labelMetriqueHA1 = new JLabel(getLabelFor("PRIX_METRIQUE_HA_1"), SwingConstants.RIGHT); |
protected JLabel labelMetriqueVT1 = new JLabel(getLabelFor("PRIX_METRIQUE_VT_1"), SwingConstants.RIGHT); |
private final JCheckBox boxService = new JCheckBox(getLabelFor("SERVICE")); |
private final JCheckBox checkObs = new JCheckBox(getLabelFor("OBSOLETE")); |
private JTextField textNom, textCode; |
private JTextField textPoids; |
private JTextField textValMetrique1, textValMetrique2, textValMetrique3; |
private DocumentListener htDocListener, ttcDocListener, detailsListener; |
private PropertyChangeListener propertyChangeListener; |
private PropertyChangeListener taxeListener; |
private final ElementComboBox comboSelTaxe = new ElementComboBox(false, 10); |
private final ElementComboBox comboSelModeVente = new ElementComboBox(false, 25); |
private JLabel labelMetriqueHA1 = new JLabel(getLabelFor("PRIX_METRIQUE_HA_1"), SwingConstants.RIGHT); |
private JLabel labelMetriqueVT1 = new JLabel(getLabelFor("PRIX_METRIQUE_VT_1"), SwingConstants.RIGHT); |
protected ArticleDesignationTable tableDes = new ArticleDesignationTable(); |
protected ArticleCodeClientTable tableCodeClient = new ArticleCodeClientTable(); |
protected ArticleTarifTable tableTarifVente = new ArticleTarifTable(this); |
protected ArticleCategorieComptableTable tableCatComptable = new ArticleCategorieComptableTable(); |
protected SupplierPriceListTable tableFourSec = new SupplierPriceListTable(); |
private ArticleDesignationTable tableDes = new ArticleDesignationTable(); |
private ArticleCodeClientTable tableCodeClient = new ArticleCodeClientTable(); |
private ArticleTarifTable tableTarifVente = new ArticleTarifTable(this); |
private ArticleCategorieComptableTable tableCatComptable = new ArticleCategorieComptableTable(); |
private SupplierPriceListTable tableFourSec = new SupplierPriceListTable(); |
protected ProductQtyPriceListTable tableTarifQteVente = new ProductQtyPriceListTable(this); |
protected ProductItemListTable tableBom; |
protected final JTextField textMarge = new JTextField(10); |
protected final JLabel labelMarge = new JLabel("% "); |
protected ElementComboBox boxCR; |
protected JCheckBox boxMargeWithCR; |
private ProductQtyPriceListTable tableTarifQteVente = new ProductQtyPriceListTable(this); |
private ProductItemListTable tableBom; |
private final JTextField textMarge = new JTextField(10); |
private final JLabel labelMarge = new JLabel("% "); |
private ElementComboBox boxCR; |
private JCheckBox boxMargeWithCR; |
protected DocumentListener pieceHAArticle = new SimpleDocumentListener() { |
private DocumentListener pieceHAArticle = new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
129,7 → 129,7 |
} |
}; |
protected DocumentListener pieceVTArticle = new SimpleDocumentListener() { |
private DocumentListener pieceVTArticle = new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
140,7 → 140,7 |
}; |
protected DocumentListener listenerMargeTextMarge = new SimpleDocumentListener() { |
private DocumentListener listenerMargeTextMarge = new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
ReferenceArticleSQLComponent.this.textPVHT.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT); |
150,7 → 150,7 |
}; |
protected DocumentListener listenerMargeTextVT = new SimpleDocumentListener() { |
private DocumentListener listenerMargeTextVT = new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
ReferenceArticleSQLComponent.this.textMarge.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextMarge); |
196,7 → 196,7 |
} |
}; |
protected DocumentListener listenerMargeTextHA = new SimpleDocumentListener() { |
private DocumentListener listenerMargeTextHA = new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
ReferenceArticleSQLComponent.this.textPVHT.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT); |
205,7 → 205,7 |
} |
}; |
public void updateVtFromMarge() { |
private void updateVtFromMarge() { |
if (this.textPAHT.getText().trim().length() > 0) { |
BigDecimal ha = StringUtils.getBigDecimalFromUserText(this.textPAHT.getText()); |
474,7 → 474,7 |
this.comboSelModeVente.setValue(ReferenceArticleSQLElement.A_LA_PIECE); |
} |
protected Component createInfosPanel() { |
private Component createInfosPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
586,7 → 586,7 |
return panel; |
} |
protected Component createDescriptifPanel() { |
private Component createDescriptifPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
666,7 → 666,7 |
return panel; |
} |
protected Component createDesignationPanel() { |
private Component createDesignationPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
744,7 → 744,7 |
return panel; |
} |
protected Component createCodeClientPanel() { |
private Component createCodeClientPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
760,7 → 760,7 |
return panel; |
} |
protected Component createStockPanel() { |
private Component createStockPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
830,7 → 830,7 |
return panel; |
} |
protected Component createComptaPanel() { |
private Component createComptaPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
872,10 → 872,10 |
return panel; |
} |
protected SQLRowValues rowValuesDefaultCodeFournisseur; |
protected CodeFournisseurItemTable codeFournisseurTable; |
private SQLRowValues rowValuesDefaultCodeFournisseur; |
private CodeFournisseurItemTable codeFournisseurTable; |
protected Component createAchatPanel() { |
private Component createAchatPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
1003,7 → 1003,7 |
} |
protected JPanel createExportationPanel() { |
private JPanel createExportationPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
1043,7 → 1043,7 |
return panel; |
} |
protected JPanel createTarifPanel() { |
private JPanel createTarifPanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
1127,7 → 1127,7 |
return panel; |
} |
protected JPanel createCategorieComptablePanel() { |
private JPanel createCategorieComptablePanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
1204,7 → 1204,7 |
return panel; |
} |
protected JPanel createBOMpanel() { |
private JPanel createBOMpanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
1255,7 → 1255,7 |
} |
protected void updatePricesNomenclature(final JCheckBox checkAutoPrice, final JCheckBox checkAutoPriceHA) { |
private void updatePricesNomenclature(final JCheckBox checkAutoPrice, final JCheckBox checkAutoPriceHA) { |
final Boolean vtAuto = checkAutoPrice.isSelected(); |
final Boolean haAuto = checkAutoPriceHA.isSelected(); |
if (vtAuto || haAuto) { |
1271,7 → 1271,7 |
} |
} |
protected JPanel createTarifQtePanel() { |
private JPanel createTarifQtePanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
1563,7 → 1563,7 |
} |
protected void setListenerModeVenteActive(boolean b) { |
private void setListenerModeVenteActive(boolean b) { |
if (b) { |
this.comboSelModeVente.addValueListener(this.propertyChangeListener); |
} else { |
1575,7 → 1575,7 |
* @param c |
* @param props |
*/ |
protected void addModeVenteAvance(GridBagConstraints c) { |
private void addModeVenteAvance(GridBagConstraints c) { |
DefaultProps props = DefaultNXProps.getInstance(); |
JSeparator sep = new JSeparator(); |
JLabel labelDetails = new JLabel("Article détaillé", SwingConstants.RIGHT); |
1769,7 → 1769,7 |
* |
* @param id id du mode de vente |
*/ |
protected void selectModeVente(int id) { |
private void selectModeVente(int id) { |
this.labelMetriqueHA1.setEnabled(true); |
this.labelMetriqueVT1.setEnabled(true); |
1850,7 → 1850,7 |
return rowVals; |
} |
protected void setTextHT() { |
private void setTextHT() { |
if (!isFilling()) { |
this.textPVHT.getDocument().removeDocumentListener(this.htDocListener); |
final BigDecimal ttc = StringUtils.getBigDecimalFromUserText(this.textPVTTC.getText()); |
1867,7 → 1867,7 |
} |
} |
protected void setTextTTC() { |
private void setTextTTC() { |
if (!isFilling()) { |
this.textPVTTC.getDocument().removeDocumentListener(this.ttcDocListener); |
final BigDecimal ht = StringUtils.getBigDecimalFromUserText(this.textPVHT.getText()); |
1887,7 → 1887,7 |
/** |
* calcul du prix achat et vente ainsi que le poids total pour la piece |
*/ |
protected void updatePiece() { |
private void updatePiece() { |
if (this.comboSelModeVente.getSelectedId() > 1 && this.comboSelModeVente.getSelectedId() != ReferenceArticleSQLElement.A_LA_PIECE) { |
SQLRowValues rowVals = getDetailsRowValues(); |
float poidsTot = ReferenceArticleSQLElement.getPoidsFromDetails(rowVals); |
1924,7 → 1924,7 |
return rowVals; |
} |
protected void put(SQLRowValues rowVals, JTextField comp) { |
private void put(SQLRowValues rowVals, JTextField comp) { |
Float f = (comp.getText() == null || comp.getText().trim().length() == 0) ? 0.0F : Float.valueOf(comp.getText()); |
rowVals.put(this.getView(comp).getField().getName(), f); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseControler.java |
---|
537,30 → 537,11 |
TicketItem item = new TicketItem(article, a.getQty().multiply(new BigDecimal(-1))); |
this.t.addItem(item); |
} |
// Annulation de chaque paiement |
final List<Paiement> typesAdded = new ArrayList<>(); |
for (Paiement p : ticket.getPaiements()) { |
final Paiement paiement = new Paiement(p.getType()); |
paiement.setMontantInCents(-1 * p.getMontantInCents()); |
this.t.addPaiement(paiement); |
typesAdded.add(p); |
} |
// On complete avec les autres types |
final List<Paiement> types = new ArrayList<>(); |
types.add(new Paiement(Paiement.CB)); |
types.add(new Paiement(Paiement.CHEQUE)); |
types.add(new Paiement(Paiement.ESPECES)); |
for (Paiement paiement : types) { |
boolean typeFound = false; |
for (Paiement p : typesAdded) { |
if (paiement.getType() == p.getType()) { |
typeFound = true; |
} |
} |
if (!typeFound) { |
this.t.addPaiement(paiement); |
} |
} |
this.caisseFrame.showCaisse(); |
fire(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/io/BarcodeReader.java |
---|
16,7 → 16,6 |
import org.openconcerto.erp.core.sales.pos.ui.BarcodeListener; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.utils.StringUtils; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
62,16 → 61,16 |
this.timer = null; |
this.task = null; |
this.maxInterKeyDelay = maxInterKeyDelay; |
this.mapCharacterFR.put((int) '&', "1"); |
this.mapCharacterFR.put((int) 'é', "2"); |
this.mapCharacterFR.put((int) '"', "3"); |
this.mapCharacterFR.put((int) '\'', "4"); |
this.mapCharacterFR.put((int) '(', "5"); |
this.mapCharacterFR.put((int) '-', "6"); |
this.mapCharacterFR.put((int) 'è', "7"); |
this.mapCharacterFR.put((int) '_', "8"); |
this.mapCharacterFR.put((int) 'ç', "9"); |
this.mapCharacterFR.put((int) 'à', "0"); |
mapCharacterFR.put((int) '&', "1"); |
mapCharacterFR.put((int) 'é', "2"); |
mapCharacterFR.put((int) '"', "3"); |
mapCharacterFR.put((int) '\'', "4"); |
mapCharacterFR.put((int) '(', "5"); |
mapCharacterFR.put((int) '-', "6"); |
mapCharacterFR.put((int) 'è', "7"); |
mapCharacterFR.put((int) '_', "8"); |
mapCharacterFR.put((int) 'ç', "9"); |
mapCharacterFR.put((int) 'à', "0"); |
} |
public synchronized void removeBarcodeListener(BarcodeListener l) { |
103,7 → 102,7 |
// init avant que les listeners s'en servent |
this.timer = new Timer(getClass().getName(), true); |
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this); |
System.err.println("BarcodeReader start : scan delay " + this.maxInterKeyDelay + " ms"); |
System.err.println("BarcodeReader start : scan delay " + maxInterKeyDelay + " ms"); |
} |
} |
121,9 → 120,9 |
@Override |
public boolean dispatchKeyEvent(KeyEvent e) { |
if (!this.enable) { |
if (!enable) |
return false; |
} |
if (this.task != null) |
this.task.cancel(); |
134,10 → 133,10 |
int keyCode = e.getKeyCode(); |
final long delay = t - this.firstTime; |
if (keyCode == KeyEvent.VK_BACK_SPACE || keyCode == KeyEvent.VK_DELETE || (delay > this.maxInterKeyDelay && keyCode != KeyEvent.VK_SHIFT)) { |
if (keyCode == KeyEvent.VK_BACK_SPACE || keyCode == KeyEvent.VK_DELETE || (delay > maxInterKeyDelay && keyCode != KeyEvent.VK_SHIFT)) { |
// touche normale |
if (this.debug) { |
System.err.println("Touche normale " + keyCode); |
System.err.println("TOuche normale " + keyCode); |
} |
this.eve.add(e); |
redispatch(); |
152,11 → 151,6 |
if (this.debug) { |
System.err.println("SHIFT " + keyCode); |
} |
} else if (keyChar == ']') { |
this.value += keyChar; |
if (this.debug) { |
System.err.println("]"); |
} |
} else if (keyChar == '*' || keyChar == '$' || keyChar == '+' || keyChar == '/' || keyChar == '%' || keyChar == ' ') { |
this.value += keyChar; |
if (this.debug) { |
165,7 → 159,7 |
} else if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9 || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) { |
// from KeyEvent : same as ASCII |
if (this.debug) { |
System.err.println("[0-9] [A-Z] " + keyCode + " : " + keyChar); |
System.err.println("[0-9] [A-Z] " + keyCode); |
} |
this.value += (char) keyCode; |
} else if (keyCode == KeyEvent.VK_ENTER && this.value.length() >= MIN_BARCODE_LENGTH) { |
176,27 → 170,20 |
this.value = this.value.trim(); |
fire(this.value); |
reset(); |
} else if (this.mapCharacterFR.containsKey((int) keyChar)) { |
} else if (mapCharacterFR.containsKey((int) keyChar)) { |
if (this.debug) { |
System.err.println("MAP DEFAULT FR CHAR " + keyChar + " WITH " + this.mapCharacterFR.get((int) keyChar)); |
System.err.println("MAP DEFAULT FR CHAR " + keyChar + " WITH " + mapCharacterFR.get((int) keyChar)); |
} |
this.value += this.mapCharacterFR.get((int) keyChar); |
this.value += mapCharacterFR.get((int) keyChar); |
} else if (Character.isLetter(keyChar) || Character.isDigit(keyChar)) { |
this.value += keyChar; |
if (this.debug) { |
System.err.println("LETTER OR DIGIT " + keyChar); |
} |
} else if (keyChar == 29) { |
this.value += '\u001D'; |
if (this.debug) { |
System.err.println("<GS>"); |
} |
} else if (keyChar == KeyEvent.CHAR_UNDEFINED) { |
System.err.println("CHAR_UNDEFINED"); |
} else { |
// Caractere non code barre |
if (this.debug) { |
System.err.println("CHAR NON CODE BARRE keyCode:" + keyCode + " keyChar:" + keyChar); |
System.err.println("CHAR NON CODE BARRE " + e); |
} |
redispatch(); |
} |
209,13 → 196,12 |
redispatchLater(); |
} |
}; |
this.timer.schedule(this.task, this.maxInterKeyDelay); |
this.timer.schedule(this.task, maxInterKeyDelay); |
} |
// si pas d'evenement, pas de temps associé |
assert !this.eve.isEmpty() || this.firstTime == -1; |
} |
return true; |
} |
private void redispatchLater() { |
245,7 → 231,7 |
} |
public Map<Integer, String> getMapCharacterFR() { |
return this.mapCharacterFR; |
return mapCharacterFR; |
} |
public void setDebug(boolean debug) { |
303,7 → 289,6 |
@Override |
public void barcodeRead(String code) { |
t1.append("Barcode OK : '" + code + "'\n"); |
t1.append("Hex: " + StringUtils.bytesToHexString(code.getBytes())); |
} |
}); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/component/BonDeLivraisonSQLComponent.java |
---|
391,9 → 391,10 |
} else { |
tableBonItem.setRowCatComptable(null); |
} |
if (!isFilling()) { |
tableBonItem.setClient(rowClient, true); |
} |
tableBonItem.setClient(rowClient, !isFilling()); |
} else { |
comboContact.getRequest().setWhere(Where.FALSE); |
tableBonItem.setRowCatComptable(null); |
408,7 → 409,7 |
// Commercial |
JLabel labelCommercial = new JLabel(getLabelFor("ID_COMMERCIAL")); |
labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT); |
c.fill = GridBagConstraints.HORIZONTAL; |
c.gridx++; |
c.weightx = 0; |
this.add(labelCommercial, c); |
1085,17 → 1086,9 |
private void updateStock(int id) throws SQLException { |
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot()); |
// Check if tr from bl or cmd pour DS |
boolean stockWithBL = !prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true); |
if (getTable().getForeignTable("ID_CLIENT").contains("NOTE_2018")) { |
if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) { |
SQLRow row = getTable().getRow(id); |
List<SQLRow> trCmd = row.getReferentRows(getTable().getTable("TR_COMMANDE_CLIENT")); |
if (!trCmd.isEmpty()) { |
stockWithBL = true; |
} |
} |
if (stockWithBL) { |
SQLRow row = getTable().getRow(id); |
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() { |
@Override |
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/credit/component/AvoirClientSQLComponent.java |
---|
118,6 → 118,8 |
private ElementComboBox selectContact; |
private JLabel labelCompteServ; |
private ISQLCompteSelector compteSelService; |
private static final SQLTable TABLE_PREFS_COMPTE = Configuration.getInstance().getBase().getTable("PREFS_COMPTE"); |
private static final SQLRow ROW_PREFS_COMPTE = TABLE_PREFS_COMPTE.getRow(2); |
private final boolean displayDpt; |
private final ElementComboBox comboDpt = new ElementComboBox(); |
192,9 → 194,10 |
boxTarif.setValue(foreignRow.getID()); |
} |
} |
if (!isFilling()) { |
AvoirClientSQLComponent.this.table.setClient(row, true); |
} |
AvoirClientSQLComponent.this.table.setClient(row, !isFilling()); |
} else { |
table.setRowCatComptable(null); |
selectContact.getRequest().setWhere(Where.FALSE); |
218,8 → 221,7 |
// Selection du compte de service |
final SQLRow prefs = getTable().getDBRoot().getTable("PREFS_COMPTE").getTable().getRow(2); |
int idCompteVenteService = prefs.getInt("ID_COMPTE_PCE_VENTE_SERVICE"); |
int idCompteVenteService = ROW_PREFS_COMPTE.getInt("ID_COMPTE_PCE_VENTE_SERVICE"); |
if (idCompteVenteService <= 1) { |
try { |
idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices"); |
652,38 → 654,20 |
JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT")); |
labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT); |
cFrais.gridy++; |
panelPortEtRemise.add(labelPortHT, cFrais); |
// panelPortEtRemise.add(labelPortHT, cFrais); |
cFrais.gridx++; |
DefaultGridBagConstraints.lockMinimumSize(textPortHT); |
panelPortEtRemise.add(textPortHT, cFrais); |
// panelPortEtRemise.add(textPortHT, cFrais); |
JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT")); |
labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT); |
cFrais.gridx = 1; |
cFrais.gridy++; |
panelPortEtRemise.add(labelTaxeHT, cFrais); |
cFrais.gridx++; |
SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8); |
panelPortEtRemise.add(boxTaxePort, cFrais); |
this.addView(boxTaxePort, "ID_TAXE_PORT", REQ); |
boxTaxePort.addValueListener(new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
totalTTC.updateTotal(); |
} |
}); |
// Remise |
JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT")); |
labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT); |
cFrais.gridy++; |
cFrais.gridx = 1; |
panelPortEtRemise.add(labelRemiseHT, cFrais); |
// panelPortEtRemise.add(labelRemiseHT, cFrais); |
cFrais.gridx++; |
DefaultGridBagConstraints.lockMinimumSize(textRemiseHT); |
panelPortEtRemise.add(textRemiseHT, cFrais); |
// panelPortEtRemise.add(textRemiseHT, cFrais); |
cFrais.gridy++; |
c.gridx++; |
715,7 → 699,7 |
JTextField poids = new JTextField(); |
if (getTable().getFieldsName().contains("T_POIDS")) |
addSQLObject(poids, "T_POIDS"); |
this.totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, poids, null, boxTaxePort, null); |
this.totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, poids, null); |
totalTTC.setOpaque(false); |
c.gridx++; |
c.gridy = 0; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/component/CommandeClientSQLComponent.java |
---|
25,7 → 25,6 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType; |
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI; |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache; |
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.sales.order.ui.EtatCommandeClient; |
63,6 → 62,7 |
import org.openconcerto.ui.TitledSeparator; |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.text.SimpleDocumentListener; |
import java.awt.Color; |
import java.awt.GridBagConstraints; |
72,7 → 72,6 |
import java.sql.SQLException; |
import java.util.Date; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import javax.swing.JLabel; |
257,7 → 256,9 |
// } |
// table.setTarif(foreignRow, true); |
} |
table.setClient(row, !isFilling()); |
if (!isFilling()) { |
table.setClient(row, true); |
} |
} else { |
if (!isFilling()) { |
551,20 → 552,8 |
pane.add("Facturation", this.tableFacturationItem); |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CHIFFRAGE_COMMANDE_CLIENT, false)) { |
this.tableChiffrageItem = new ChiffrageCommandeTable(this); |
this.tableChiffrageItem.getRowValuesTable().setEditable(((CommandeClientSQLElement) getElement()).isChiffrageEditableInUI()); |
pane.add("Chiffrage", this.tableChiffrageItem); |
} |
if (this.getTable().contains("INFOS_DEVIS")) { |
JPanel panelInfosDevis = new JPanel(new GridBagLayout()); |
DefaultGridBagConstraints cI = new DefaultGridBagConstraints(); |
cI.weightx = 1; |
cI.weighty = 1; |
cI.fill = GridBagConstraints.BOTH; |
ITextArea infosDevis = new ITextArea(); |
panelInfosDevis.add(new JScrollPane(infosDevis), cI); |
this.addView(infosDevis, "INFOS_DEVIS"); |
pane.add("Informations devis", panelInfosDevis); |
} |
this.add(pane, c); |
DeviseField textPortHT = new DeviseField(5); |
758,8 → 747,6 |
textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal())); |
} |
}); |
this.addView(this.table.getRowValuesTable(), ""); |
DefaultGridBagConstraints.lockMinimumSize(comboClient); |
DefaultGridBagConstraints.lockMinimumSize(comboCommercial); |
DefaultGridBagConstraints.lockMinimumSize(comboDevis); |
1019,50 → 1006,4 |
this.table.setDateDevise(r.getDate("DATE").getTime()); |
} |
} |
/** |
* Création d'une commande à partir d'un devis existant |
* |
* @param idCommande |
* |
*/ |
public void loadCommandeExistant(final int idCommande) { |
final SQLElement commande =getElement(); |
final SQLElement commandeElt = getElement().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT"); |
// On duplique la commande |
if (idCommande > 1) { |
final SQLRow row = getTable().getRow(idCommande); |
final SQLRowValues rowVals = new SQLRowValues(getTable()); |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT")); |
if (row.getObject("ID_TARIF") != null && !row.isForeignEmpty("ID_TARIF")) { |
rowVals.put("ID_TARIF", row.getInt("ID_TARIF")); |
} |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass())); |
this.select(rowVals); |
} |
// On duplique les elements des commandes |
final List<SQLRow> myListItem = getTable().getRow(idCommande).getReferentRows(commandeElt.getTable()); |
if (myListItem.size() != 0) { |
this.table.getModel().clearRows(); |
for (final SQLRow rowElt : myListItem) { |
final SQLRowValues rowVals = rowElt.createUpdateRow(); |
rowVals.clearPrimaryKeys(); |
this.table.getModel().addRow(rowVals); |
final int rowIndex = this.table.getModel().getRowCount() - 1; |
this.table.getModel().fireTableModelModified(rowIndex); |
} |
} else { |
this.table.getModel().clearRows(); |
} |
this.table.getModel().fireTableDataChanged(); |
this.table.repaint(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/CommandeClientElementSQLElement.java |
---|
171,10 → 171,6 |
final SQLTable tableCmdElt = tableStock.getTable("COMMANDE_ELEMENT"); |
selCmdElt.addSelectStar(tableCmdElt); |
Where w = new Where(tableCmdElt.getField("RECU_FORCED"), "=", Boolean.FALSE).and(new Where(tableCmdElt.getField("RECU"), "=", Boolean.FALSE)); |
w = w.and(Where.createRaw( |
tableCmdElt.getField("QTE_RECUE").getQuotedName() + " < (" + tableCmdElt.getField("QTE").getQuotedName() + "*" + tableCmdElt.getField("QTE_UNITAIRE").getQuotedName() + ")", |
tableCmdElt.getField("QTE_UNITAIRE"), tableCmdElt.getField("QTE"), tableCmdElt.getField("QTE_RECUE"))); |
selCmdElt.setWhere(w); |
List<SQLRow> res = SQLRowListRSH.execute(selCmdElt); |
if (res != null && res.size() > 0) { |
197,10 → 193,6 |
final SQLTable tableCmdElt = tableStock.getTable("COMMANDE_CLIENT_ELEMENT"); |
selCmdElt.addSelectStar(tableCmdElt); |
Where w = new Where(tableCmdElt.getField("LIVRE_FORCED"), "=", Boolean.FALSE).and(new Where(tableCmdElt.getField("LIVRE"), "=", Boolean.FALSE)); |
w = w.and(Where.createRaw( |
tableCmdElt.getField("QTE_LIVREE").getQuotedName() + " < (" + tableCmdElt.getField("QTE").getQuotedName() + "*" + tableCmdElt.getField("QTE_UNITAIRE").getQuotedName() + ")", |
tableCmdElt.getField("QTE_UNITAIRE"), tableCmdElt.getField("QTE"), tableCmdElt.getField("QTE_LIVREE"))); |
selCmdElt.setWhere(w); |
List<SQLRow> res = SQLRowListRSH.execute(selCmdElt); |
if (res != null && res.size() > 0) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/CommandeClientSQLElement.java |
---|
52,7 → 52,6 |
import org.openconcerto.sql.request.UpdateBuilder; |
import org.openconcerto.sql.utils.SQLUtils; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanel; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction; |
246,10 → 245,6 |
mouseSheetXmlListeListener.setGenerateHeader(true); |
mouseSheetXmlListeListener.setShowHeader(true); |
// Dupliquer |
RowAction cloneAction = getCloneAction(); |
allowedActions.add(cloneAction); |
allowedActions.add(bonAction); |
allowedActions.add(factureAction); |
allowedActions.add(acompteAction); |
259,16 → 254,6 |
getRowActions().addAll(allowedActions); |
} |
private boolean chiffrageEditableInUI = true; |
public void setChiffrageEditableInUI(boolean chiffrageEditableInUI) { |
this.chiffrageEditableInUI = chiffrageEditableInUI; |
} |
public boolean isChiffrageEditableInUI() { |
return this.chiffrageEditableInUI; |
} |
@Override |
protected void setupLinks(SQLElementLinksSetup links) { |
super.setupLinks(links); |
740,26 → 725,7 |
} |
} |
public RowAction getCloneAction() { |
return new RowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
SQLRowAccessor selectedRow = IListe.get(e).getSelectedRow(); |
EditFrame editFrame = new EditFrame(CommandeClientSQLElement.this, EditPanel.CREATION); |
((CommandeClientSQLComponent) editFrame.getSQLComponent()).loadCommandeExistant(selectedRow.getID()); |
editFrame.setVisible(true); |
} |
}, true, "sales.quote.clone") { |
@Override |
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowValues> selection) { |
return (selection != null && selection.size() == 1); |
} |
}; |
} |
@Override |
protected String createCode() { |
return "sales.order"; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/FacturationCommandeClientSQLElement.java |
---|
27,7 → 27,6 |
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.graph.Path; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanelListener; |
44,7 → 43,6 |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.Collection; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
119,11 → 117,6 |
public void inserted(int id) { |
try { |
sel.createEmptyUpdateRow().put("ID_SAISIE_VENTE_FACTURE", id).commit(); |
SQLTable tableFacture = getForeignElement("ID_SAISIE_VENTE_FACTURE").getTable(); |
SQLRowValues rowValsFact = new SQLRowValues(tableFacture); |
rowValsFact.put(tableFacture.getKey().getName(), id); |
rowValsFact.put("ID_FACTURATION_COMMANDE_CLIENT", sel.getID()); |
rowValsFact.commit(); |
} catch (SQLException e) { |
ExceptionHandler.handle("Erreur lors de l'affectation de la facture", e); |
} |
230,7 → 223,7 |
res.init(); |
res.getColumn(getTable().getField("POURCENT")).setRenderer(new DeviseTableCellRenderer()); |
res.getColumn(getTable().getField("TYPE_FACTURE")).setRenderer(new TypeFactureCommandeCellRenderer()); |
final BaseSQLTableModelColumn pourcentFact = new BaseSQLTableModelColumn("Montant à facturer", BigDecimal.class) { |
final BaseSQLTableModelColumn pourcentFact = new BaseSQLTableModelColumn("Montant facturé", BigDecimal.class) { |
@Override |
protected Object show_(SQLRowAccessor r) { |
248,31 → 241,6 |
}; |
pourcentFact.setRenderer(new DeviseTableCellRenderer()); |
res.getColumns().add(pourcentFact); |
final BaseSQLTableModelColumn montantFact = new BaseSQLTableModelColumn("Montant facturé", BigDecimal.class) { |
@Override |
protected Object show_(SQLRowAccessor r) { |
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(getForeignElement("ID_SAISIE_VENTE_FACTURE").getTable()); |
long ht = 0; |
for (SQLRowAccessor sqlRowAccessor : rows) { |
ht += sqlRowAccessor.getLong("T_TTC"); |
} |
return new BigDecimal(ht).movePointLeft(2); |
} |
@Override |
public Set<FieldPath> getPaths() { |
Path p = new Path(getTable()); |
Path p2 = p.add(p.getFirst().getField("ID_COMMANDE_CLIENT")); |
Path p3 = new Path(getTable()); |
p3 = p3.add(getTable().getForeignTable("ID_SAISIE_VENTE_FACTURE").getField("ID_FACTURATION_COMMANDE_CLIENT")); |
return CollectionUtils.createSet(new FieldPath(p, "POURCENT"), new FieldPath(p2, "T_TTC"), new FieldPath(p3, "T_TTC"), new FieldPath(p2, "T_HT"), new FieldPath(p3, "T_HT")); |
} |
}; |
montantFact.setRenderer(new DeviseTableCellRenderer()); |
res.getColumns().add(montantFact); |
super._initTableSource(res); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSituationSQLComponent.java |
---|
207,11 → 207,9 |
@Override |
public void update(DocumentEvent e) { |
if (!isFilling()) { |
Acompte a = acompteField.getValue(); |
table.calculPourcentage(a, TypeCalcul.CALCUL_FACTURABLE); |
} |
} |
}; |
acompteField.getDocument().addDocumentListener(listenerAcompteField); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/EcheanceClientSQLElement.java |
---|
25,7 → 25,6 |
import org.openconcerto.erp.core.finance.payment.element.EncaisserMontantSQLElement; |
import org.openconcerto.erp.core.sales.invoice.action.ImportReglementSage; |
import org.openconcerto.erp.core.sales.invoice.report.MailRelanceCreator; |
import org.openconcerto.erp.core.sales.invoice.report.SituationCompteClientPanel; |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet; |
import org.openconcerto.erp.rights.ComptaUserRight; |
import org.openconcerto.sql.Configuration; |
63,7 → 62,6 |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.EmailComposer; |
import org.openconcerto.ui.JDate; |
import org.openconcerto.ui.PanelFrame; |
import org.openconcerto.ui.SwingThreadUtils; |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.ExceptionHandler; |
215,18 → 213,7 |
}, true); |
action.setPredicate(IListeEvent.createTotalRowCountPredicate(0, Integer.MAX_VALUE)); |
getRowActions().add(action); |
PredicateRowAction actionSituation = new PredicateRowAction(new AbstractAction("Générer une situationde compte") { |
@Override |
public void actionPerformed(ActionEvent e) { |
PanelFrame frame = new PanelFrame(new SituationCompteClientPanel(ComptaPropsConfiguration.getInstanceCompta()), "Situation client"); |
frame.setVisible(true); |
} |
}, true); |
actionSituation.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE)); |
getRowActions().add(actionSituation); |
} |
if (UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.MENU)) { |
RowAction actionCancel = new RowAction(new AbstractAction("Annuler la régularisation en comptabilité") { |
563,7 → 550,6 |
SQLRow rowMvtSource = getTable().getTable("MOUVEMENT").getRow(idMvtSource); |
if (!rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) { |
JOptionPane.showMessageDialog(null, "Impossible de relancer un échéance qui n'est pas issue d'une facture."); |
return; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/SituationCompteXmlSheet.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/SituationCompteClientPanel.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/VenteFactureXmlSheet.java |
---|
23,7 → 23,6 |
public class VenteFactureXmlSheet extends AbstractSheetXMLWithDate { |
public static final String TEMPLATE_ID = "VenteFacture"; |
public static final String TEMPLATE_SITUATION_SUFFIX = "Situation"; |
public static final String TEMPLATE_PROPERTY_NAME = "LocationFacture"; |
@Override |
47,14 → 46,9 |
@Override |
public SQLRow getRowLanguage() { |
SQLRow rowClient = this.row.getForeignRow("ID_CLIENT"); |
if (rowClient.getTable().contains("ID_LANGUE")) { |
if (!rowClient.isForeignEmpty("ID_LANGUE")) { |
return rowClient.getForeign("ID_LANGUE"); |
return rowClient.getForeignRow("ID_LANGUE"); |
} else { |
return null; |
} |
} else { |
return super.getRowLanguage(); |
} |
} |
74,7 → 68,7 |
} else if (row.getBoolean("ACOMPTE")) { |
type = "Acompte"; |
} else if (row.getBoolean("PARTIAL") || row.getBoolean("SOLDE")) { |
type = TEMPLATE_SITUATION_SUFFIX; |
type = "Situation"; |
} else { |
type = null; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/ReportingStockXmlSheet.java |
---|
13,9 → 13,8 |
package org.openconcerto.erp.core.sales.invoice.report; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement; |
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml; |
import org.openconcerto.erp.preferences.PrinterNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLRow; |
24,15 → 23,11 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.TableRef; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.utils.cc.ITransformer; |
import java.math.BigDecimal; |
import java.text.DateFormat; |
import java.text.SimpleDateFormat; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.Collections; |
import java.util.Comparator; |
import java.util.Date; |
47,20 → 42,16 |
public static final String TEMPLATE_ID = "EtatStocks"; |
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME; |
private int intIDDepot = DepotStockSQLElement.DEFAULT_ID; |
private boolean bTousLesDepots = false; |
private Date date; |
private SQLElement eltArticle = Configuration.getInstance().getDirectory().getElement("ARTICLE"); |
private SQLElement eltStock = Configuration.getInstance().getDirectory().getElement("STOCK"); |
public ReportingStockXmlSheet(ComptaPropsConfiguration conf, Integer intIDDepot, boolean bTousLesDepots) { |
this.eltArticle = conf.getDirectory().getElement("ARTICLE"); |
this.eltStock = conf.getDirectory().getElement("STOCK"); |
if (intIDDepot != null) { |
this.intIDDepot = intIDDepot; |
public ReportingStockXmlSheet(boolean fournisseur) { |
super(); |
this.printer = PrinterNXProps.getInstance().getStringProperty("BonPrinter"); |
} |
this.bTousLesDepots = bTousLesDepots; |
} |
@Override |
public String getStoragePathP() { |
82,33 → 73,17 |
protected void createListeValues() { |
final SQLTable tableArt = this.eltArticle.getTable(); |
SQLRowValues rowvArticle = new SQLRowValues(tableArt); |
rowvArticle.put("ID_FOURNISSEUR", null); |
rowvArticle.put("ID_FAMILLE_ARTICLE", null); |
rowvArticle.put("CODE", null); |
rowvArticle.put("NOM", null); |
rowvArticle.put("PA_HT", null); |
rowvArticle.put("PV_HT", null); |
final SQLTable tableArt = eltArticle.getTable(); |
SQLRowValues rowVals = new SQLRowValues(tableArt); |
rowVals.put("ID_FOURNISSEUR", null); |
rowVals.put("ID_FAMILLE_ARTICLE", null); |
rowVals.put("CODE", null); |
rowVals.put("NOM", null); |
rowVals.put("PA_HT", null); |
rowVals.put("PV_HT", null); |
rowVals.putRowValues("ID_STOCK").putNulls("QTE_REEL"); |
SQLRowValues rowvStock = new SQLRowValues(this.eltStock.getTable()); |
rowvStock.put("QTE_REEL", null).put("ID_ARTICLE", rowvArticle); |
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowvArticle); |
if (!this.bTousLesDepots) { |
fetch.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() { |
@Override |
public SQLSelect transformChecked(SQLSelect input) { |
TableRef join = input.getAlias(ReportingStockXmlSheet.this.eltArticle.getTable().getTable("STOCK")); |
input.setWhere(new Where(join.getField("ID_DEPOT_STOCK"), "=", ReportingStockXmlSheet.this.intIDDepot)); |
System.out.println(input.toString()); |
return input; |
} |
}); |
} |
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals); |
List<SQLRowValues> values = fetch.fetch(); |
final SQLTable tableF = tableArt.getTable("FAMILLE_ARTICLE"); |
144,11 → 119,7 |
Line lineTotal = new Line("Total", "", BigDecimal.ZERO, 0F); |
final HashMap<Integer, String> style = new HashMap<Integer, String>(); |
for (SQLRowValues vals : values) { |
Collection<SQLRowValues> stocks = vals.getReferentRows(this.eltStock.getTable()); |
Float qte = 0f; |
for (SQLRowValues stock : stocks) { |
qte += stock.getFloat("QTE_REEL"); |
} |
Float qte = vals.getForeign("ID_STOCK").getFloat("QTE_REEL"); |
BigDecimal ha = BigDecimal.ZERO; |
if (qte > 0) { |
final BigDecimal puHA = vals.getBigDecimal("PA_HT"); |
242,7 → 213,7 |
style.put(style.keySet().size(), "Titre 1"); |
final Map<String, Object> valuesSheet = new HashMap<String, Object>(); |
valuesSheet.put("DATE", "Au " + this.dateFormat.format(new Date())); |
valuesSheet.put("DATE", "Au " + dateFormat.format(new Date())); |
// |
this.listAllSheetValues.put(0, listValues); |
268,23 → 239,23 |
} |
public Float getQte() { |
return this.qte; |
return qte; |
} |
public String getCodeArt() { |
return this.codeArt; |
return codeArt; |
} |
public BigDecimal getPuHA() { |
return this.puHA; |
return puHA; |
} |
public String getNomArt() { |
return this.nomArt; |
return nomArt; |
} |
public BigDecimal getTotalHA() { |
return this.totalHA; |
return totalHA; |
} |
public void add(Line l) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/ImportReglementSage.java |
---|
170,7 → 170,7 |
SQLRow rowEncaisser = rowValsEncaisser.commit(); |
this.encaisserSQLElement.regleFacture(rowEncaisser, null, false); |
this.encaisserSQLElement.regleFacture(rowEncaisser); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/GenEtatStockAction.java |
---|
13,19 → 13,11 |
package org.openconcerto.erp.core.sales.invoice.action; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.sales.invoice.ui.RapportEtatDeStockDepotSelectionPanel; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.ui.FrameUtil; |
import org.openconcerto.ui.state.WindowStateManager; |
import org.openconcerto.utils.FileUtils; |
import org.openconcerto.erp.core.sales.invoice.report.ReportingStockXmlSheet; |
import org.openconcerto.utils.ExceptionHandler; |
import java.awt.Dimension; |
import java.io.File; |
import javax.swing.AbstractAction; |
import javax.swing.Action; |
import javax.swing.JFrame; |
public class GenEtatStockAction extends AbstractAction { |
public GenEtatStockAction() { |
35,23 → 27,17 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
final Thread thread = new Thread(new Runnable() { |
public void run() { |
try { |
// Création de la fenêtre de popup de séléction du dépot. |
JFrame frame = new JFrame(); |
frame.setTitle("Sélection des dépôts."); |
frame.setPreferredSize(new Dimension(500, 130)); |
frame.setLocationRelativeTo(null); // la fenêtre est centrée à l'écran |
ReportingStockXmlSheet sheet = new ReportingStockXmlSheet(false); |
WindowStateManager stateManager; |
stateManager = new WindowStateManager(frame, |
new File(Configuration.getInstance().getConfDir(), "Configuration" + File.separator + "Frame" + File.separator + FileUtils.sanitize("RapportEtatDeStockPanel") + ".xml")); |
sheet.createDocumentAsynchronous().get(); |
sheet.openDocument(false); |
frame.getContentPane().add(new RapportEtatDeStockDepotSelectionPanel((ComptaPropsConfiguration) Configuration.getInstance())); |
FrameUtil.showPacked(frame); |
stateManager.loadState(); |
} catch (Exception e) { |
ExceptionHandler.handle("Erreur de traitement", e); |
} |
} |
}); |
thread.start(); |
}; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/RapportEtatDeStockDepotSelectionPanel.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeDesEcheancesClientsPanel.java |
---|
54,6 → 54,7 |
public class ListeDesEcheancesClientsPanel extends JPanel { |
private ListPanelEcheancesClients panelEcheances; |
private EditFrame editEncaisse = null; |
private EditFrame editRelance = null; |
private JButton relancer; |
private JButton encaisser; |
191,7 → 192,10 |
} |
SQLElement encaisseElt = Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT"); |
EditFrame editEncaisse = new EditFrame(encaisseElt); |
if (ListeDesEcheancesClientsPanel.this.editEncaisse == null) { |
ListeDesEcheancesClientsPanel.this.editEncaisse = new EditFrame(encaisseElt); |
ListeDesEcheancesClientsPanel.this.editEncaisse.setIconImages(Gestion.getFrameIcon()); |
} |
SQLRowValues rowVals = new SQLRowValues(encaisseElt.getTable()); |
if (idClient > -1) { |
203,23 → 207,60 |
rowVals.put("ID_COMPTE_PCE_TIERS", idCptTiers); |
} |
final EncaisserMontantSQLComponent sqlComponent = (EncaisserMontantSQLComponent) editEncaisse.getSQLComponent(); |
final EncaisserMontantSQLComponent sqlComponent = (EncaisserMontantSQLComponent) ListeDesEcheancesClientsPanel.this.editEncaisse.getSQLComponent(); |
sqlComponent.resetValue(); |
sqlComponent.select(rowVals); |
sqlComponent.loadEcheancesFromRows(selectedRows); |
editEncaisse.setTitle("Encaissement de factures clients"); |
editEncaisse.pack(); |
editEncaisse.setVisible(true); |
ListeDesEcheancesClientsPanel.this.editEncaisse.setTitle("Encaissement de factures clients"); |
ListeDesEcheancesClientsPanel.this.editEncaisse.pack(); |
ListeDesEcheancesClientsPanel.this.editEncaisse.setVisible(true); |
} |
}); |
// Gestion de la souris |
this.panelEcheances.getJTable().addMouseListener(new MouseAdapter() { |
@Override |
public void mousePressed(MouseEvent mE) { |
if (mE.getButton() == MouseEvent.BUTTON1) { |
// Mise à jour de l'echeance sur la frame de reglement |
// si cette derniere est cree |
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); |
final SQLRowValues selectedRow = panelEcheances.getListe().getSelectedRow(); |
final SQLRow row = selectedRow.asRow(); |
if (row == null) { |
JOptionPane.showMessageDialog(ListeDesEcheancesClientsPanel.this, "Selection", "Merci de sélectionner une ligne", JOptionPane.PLAIN_MESSAGE); |
return; |
} |
if (ListeDesEcheancesClientsPanel.this.editEncaisse != null) { |
final SQLRowValues rowVals = new SQLRowValues(base.getTable("ENCAISSER_MONTANT")); |
rowVals.put("ID_ECHEANCE_CLIENT", row.getID()); |
ListeDesEcheancesClientsPanel.this.editEncaisse.getSQLComponent().select(rowVals); |
ListeDesEcheancesClientsPanel.this.editEncaisse.pack(); |
} |
} |
} |
}); |
liste.addIListener(new IListener() { |
public void selectionId(int id, int field) { |
if (id > 1) { |
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); |
final SQLTable tableEch = base.getTable("ECHEANCE_CLIENT"); |
final SQLRow rowEch = tableEch.getRow(id); |
final int idMvtSource = MouvementSQLElement.getSourceId(rowEch.getInt("ID_MOUVEMENT")); |
final SQLRow rowMvtSource = base.getTable("MOUVEMENT").getRow(idMvtSource); |
ListeDesEcheancesClientsPanel.this.relancer.setEnabled(id > 1); |
ListeDesEcheancesClientsPanel.this.encaisser.setEnabled(id > 1); |
ListeDesEcheancesClientsPanel.this.relancer.setEnabled(rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")); |
ListeDesEcheancesClientsPanel.this.encaisser.setEnabled(true); |
} else { |
ListeDesEcheancesClientsPanel.this.relancer.setEnabled(false); |
ListeDesEcheancesClientsPanel.this.encaisser.setEnabled(false); |
} |
} |
}); |
this.relancer.setEnabled(false); |
this.encaisser.setEnabled(false); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/component/SaisieVenteFactureSQLComponent.java |
---|
161,7 → 161,9 |
tableFacture.setRowCatComptable(null); |
} |
SaisieVenteFactureSQLComponent.this.tableFacture.setClient(rowCli, !isFilling()); |
if (!isFilling()) { |
tableFacture.setClient(rowCli, true); |
} |
if (getMode() == SQLComponent.Mode.INSERTION || !isFilling()) { |
SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT"); |
299,7 → 301,7 |
public void propertyChange(PropertyChangeEvent evt) { |
if (!isFilling() && dateSaisie.getValue() != null) { |
final String nextNumero = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateSaisie.getValue(), defaultNum); |
final String nextNumero = NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, dateSaisie.getValue(), defaultNum); |
if (textNumeroUnique.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(textNumeroUnique.getText())) { |
1413,10 → 1415,11 |
rowFacture = getTable().getRow(idSaisieVF); |
// incrémentation du numéro auto |
final SQLRow rowNum = comboNumAuto == null ? this.tableNum.getRow(2) : comboNumAuto.getSelectedRow(); |
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), rowFacture.getDate("DATE").getTime(), rowNum).equalsIgnoreCase(this.textNumeroUnique.getText().trim())) { |
if (NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, rowFacture.getDate("DATE").getTime(), rowNum) |
.equalsIgnoreCase(this.textNumeroUnique.getText().trim())) { |
SQLRowValues rowVals = rowNum.createEmptyUpdateRow(); |
String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()); |
String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(SaisieVenteFactureSQLElement.class); |
int val = rowNum.getInt(labelNumberFor); |
val++; |
rowVals.put(labelNumberFor, Integer.valueOf(val)); |
1605,9 → 1608,9 |
SQLRowValues rowVals = new SQLRowValues(fact.getTable()); |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT")); |
if (getTable().contains("ID_NUMEROTATION_AUTO")) { |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date(), row.getForeign("ID_NUMEROTATION_AUTO"))); |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date(), row.getForeign("ID_NUMEROTATION_AUTO"))); |
} else { |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date())); |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date())); |
} |
rowVals.put("NOM", row.getObject("NOM")); |
this.select(rowVals); |
1645,7 → 1648,7 |
SQLRowValues rowVals = new SQLRowValues(fact.getTable()); |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT")); |
rowVals.put("ID_AFFAIRE", row.getInt("ID_AFFAIRE")); |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date())); |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date())); |
rowVals.put("NOM", "Acompte de " + GestionDevise.currencyToString(acompte) + "€"); |
this.select(rowVals); |
} |
1805,9 → 1808,9 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance()); |
if (getTable().contains("ID_NUMEROTATION_AUTO")) { |
vals.put("ID_NUMEROTATION_AUTO", this.defaultNum.getID()); |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date(), vals.getForeign("ID_NUMEROTATION_AUTO"))); |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date(), vals.getForeign("ID_NUMEROTATION_AUTO"))); |
} else { |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date())); |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date())); |
} |
int idCompteVenteProduit = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_PRODUIT"); |
if (idCompteVenteProduit <= 1) { |
1849,7 → 1852,7 |
public void setDefaults() { |
this.resetValue(); |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new java.util.Date(), defaultNum)); |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new java.util.Date(), defaultNum)); |
this.tableFacture.getModel().clearRows(); |
} |
1867,7 → 1870,7 |
public void setPrevisonnelle(boolean b) { |
this.checkPrevisionnelle.setSelected(b); |
if (!b) { |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date())); |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date())); |
} |
} |
1913,15 → 1916,6 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) { |
SQLRow row = getTable().getRow(id); |
// Check if tr from bl or cmd pour DS |
if (getTable().getForeignTable("ID_CLIENT").contains("NOTE_2018")) { |
List<SQLRow> trCmd = row.getReferentRows(getTable().getTable("TR_COMMANDE_CLIENT")); |
if (!trCmd.isEmpty()) { |
return; |
} |
} |
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() { |
@Override |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/component/DevisSQLComponent.java |
---|
436,9 → 436,10 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID); |
int idClient = rowClient.getID(); |
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient)); |
if (!isFilling()) { |
table.setClient(rowClient, true); |
} |
table.setClient(rowClient, !isFilling()); |
} else { |
comboContact.getRequest().setWhere(Where.FALSE); |
if (!isFilling()) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/NumerotationAutoSQLElement.java |
---|
361,13 → 361,6 |
return getNextCodeLetrrage(s); |
} |
public final String getNextCodeLettragePartiel() { |
SQLRow rowNum = this.getTable().getRow(2); |
final String string = rowNum.getString("CODE_LETTRAGE_PARTIEL"); |
String s = (string == null) ? "" : string.trim().toLowerCase(); |
return getNextCodeLettragePartiel(s); |
} |
public static final String getNextCodeLetrrage(String code) { |
code = code.trim(); |
if (code == null || code.length() == 0) { |
401,41 → 394,7 |
} |
public static final String getNextCodeLettragePartiel(String code) { |
code = code.trim(); |
if (code == null || code.length() == 0) { |
return "aaa"; |
} else { |
char[] charArray = code.toCharArray(); |
char c = 'a'; |
int i = charArray.length - 1; |
while (i >= 0 && (c = charArray[i]) == 'z') { |
i--; |
} |
if (i >= 0) { |
c++; |
charArray[i] = c; |
for (int j = i + 1; j < charArray.length; j++) { |
charArray[j] = 'a'; |
} |
code = String.valueOf(charArray); |
} else { |
// On ajoute une lettre |
final StringBuffer buf = new StringBuffer(code.length() + 1); |
final int nb = code.length() + 1; |
for (int j = 0; j < nb; j++) { |
buf.append('a'); |
} |
code = buf.toString(); |
} |
return code; |
} |
} |
private static boolean isNumeroExist(SQLElement element, int num) { |
if (num < 0) { |
return true; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/TitrePersonnelSQLElement.java |
---|
16,8 → 16,6 |
import org.openconcerto.sql.element.BaseSQLComponent; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.request.ComboSQLRequest; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
35,12 → 33,6 |
} |
@Override |
protected void _initComboRequest(ComboSQLRequest req) { |
super._initComboRequest(req); |
req.setWhere(new Where(getTable().getField("OBSOLETE"), "=", Boolean.FALSE)); |
} |
@Override |
public boolean isShared() { |
return true; |
} |
50,7 → 42,6 |
l.add("CODE"); |
l.add("NOM"); |
l.add("SEXE_M"); |
l.add("OBSOLETE"); |
return l; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculator.java |
---|
572,9 → 572,7 |
if (compteArticle != null && !compteArticle.isUndefined()) { |
cpt = compteArticle; |
} else { |
final SQLBackgroundTableCacheItem cacheForTableFamille = SQLBackgroundTableCache.getInstance().getCacheForTable(article.getTable().getForeignTable("ID_FAMILLE_ARTICLE")); |
SQLRowAccessor familleArticle = cacheForTableFamille.getRowFromId(article.getForeignID("ID_FAMILLE_ARTICLE")); |
SQLRowAccessor familleArticle = article.getForeign("ID_FAMILLE_ARTICLE"); |
Set<SQLRowAccessor> unique = new HashSet<SQLRowAccessor>(); |
while (familleArticle != null && !familleArticle.isUndefined() && !unique.contains(familleArticle)) { |
586,7 → 584,7 |
break; |
} |
} |
familleArticle = cacheForTableFamille.getRowFromId(familleArticle.getForeignID("ID_FAMILLE_ARTICLE_PERE")); |
familleArticle = familleArticle.getForeign("ID_FAMILLE_ARTICLE_PERE"); |
} |
} |
} else { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractAchatArticleItemTable.java |
---|
161,15 → 161,17 |
} |
SQLTableElement tableElementArticle = new SQLTableElement(e.getTable().getField("ID_ARTICLE"), true, true, true) { |
@Override |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) { |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex); |
if (vals.getTable().contains("ID_COMMANDE_ELEMENT")) { |
boolean noCmdElt = vals.getObject("ID_COMMANDE_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_ELEMENT"); |
return b && noCmdElt; |
} else { |
return b; |
} |
return b && !isFromTranferred(vals); |
} |
}; |
list.add(tableElementArticle); |
205,7 → 207,12 |
@Override |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) { |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex); |
return b && !isFromTranferred(vals); |
if (vals.getTable().contains("ID_COMMANDE_ELEMENT")) { |
boolean noCmdElt = vals.getObject("ID_COMMANDE_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_ELEMENT"); |
return b && noCmdElt; |
} else { |
return b; |
} |
} |
}; |
215,7 → 222,12 |
@Override |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) { |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex); |
return b && !isFromTranferred(vals); |
if (vals.getTable().contains("ID_COMMANDE_ELEMENT")) { |
boolean noCmdElt = vals.getObject("ID_COMMANDE_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_ELEMENT"); |
return b && noCmdElt; |
} else { |
return b; |
} |
} |
}; |
324,13 → 336,6 |
list.add(tableCmdElt); |
} |
if (e.getTable().contains("ID_BON_RECEPTION_ELEMENT")) { |
SQLTableElement tableBrElt = null; |
tableBrElt = new SQLTableElement(e.getTable().getField("ID_BON_RECEPTION_ELEMENT")); |
tableBrElt.setEditable(false); |
list.add(tableBrElt); |
} |
if (e.getTable().getFieldsName().contains("QTE_ORIGINE")) { |
final SQLTableElement tableQteO = new SQLTableElement(e.getTable().getField("QTE_ORIGINE")); |
tableQteO.setEditable(false); |
506,7 → 511,7 |
this.defaultRowVals.put("ID_DEPOT_STOCK", depotDefault); |
} |
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("QTE"), false, this.defaultRowVals) { |
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, this.defaultRowVals) { |
@Override |
public void commitData() { |
super.commitData(true); |
524,14 → 529,7 |
this.table.getClearCloneTableElement().add("RECU_FORCED"); |
} else if (getSQLElement().getTable().getName().equals("BON_RECEPTION_ELEMENT")) { |
this.table.getClearCloneTableElement().add("ID_COMMANDE_ELEMENT"); |
} else if (getSQLElement().getTable().getName().equals("FACTURE_FOURNISSEUR_ELEMENT")) { |
if (getSQLElement().getTable().contains("ID_COMMANDE_ELEMENT")) { |
this.table.getClearCloneTableElement().add("ID_COMMANDE_ELEMENT"); |
} |
if (getSQLElement().getTable().contains("ID_BON_RECEPTION_ELEMENT")) { |
this.table.getClearCloneTableElement().add("ID_BON_RECEPTION_ELEMENT"); |
} |
} |
table.addMouseListener(new MouseAdapter() { |
@Override |
888,10 → 886,6 |
setColumnVisible(model.getColumnForField("ID_COMMANDE_ELEMENT"), false); |
} |
if (e.getTable().contains("ID_BON_RECEPTION_ELEMENT")) { |
setColumnVisible(model.getColumnForField("ID_BON_RECEPTION_ELEMENT"), false); |
} |
// Gestion des unités de vente |
final boolean gestionUV = prefs.getBoolean(GestionArticleGlobalPreferencePanel.UNITE_VENTE, true); |
setColumnVisible(model.getColumnForField("QTE_UNITAIRE"), gestionUV); |
1431,19 → 1425,4 |
} |
} |
private final List<String> trFields = Arrays.asList("ID_COMMANDE_ELEMENT", "ID_BON_RECEPTION_ELEMENT"); |
private boolean isFromTranferred(SQLRowValues vals) { |
for (String trField : this.trFields) { |
if (vals.getTable().contains(trField)) { |
boolean noCmdElt = vals.getObject(trField) == null || vals.isForeignEmpty(trField); |
if (!noCmdElt) { |
return true; |
} |
} |
} |
return false; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListTotalPanel.java |
---|
41,8 → 41,6 |
import javax.swing.JPanel; |
import javax.swing.SwingConstants; |
import javax.swing.event.EventListenerList; |
import javax.swing.event.ListSelectionEvent; |
import javax.swing.event.ListSelectionListener; |
import javax.swing.event.TableModelEvent; |
import javax.swing.event.TableModelListener; |
import javax.swing.table.TableModel; |
95,16 → 93,9 |
} |
public IListTotalPanel(IListe l, final List<Tuple2<? extends SQLTableModelColumn, Type>> listField, final List<Tuple2<SQLField, ?>> filters, String title) { |
this(l, listField, filters, null, title, false); |
this(l, listField, filters, null, title); |
} |
public IListTotalPanel(IListe l, final List<Tuple2<? extends SQLTableModelColumn, Type>> listField, final List<Tuple2<SQLField, ?>> filters, final List<Tuple2<SQLField, ?>> filtersNot, |
String title) { |
this(l, listField, filters, filtersNot, title, false); |
} |
private final boolean onSelection; |
/** |
* |
* @param l |
112,11 → 103,11 |
* @param filters filtre ex : Tuple((SQLField)NATEXIER,(Boolean)FALSE) |
*/ |
public IListTotalPanel(IListe l, final List<Tuple2<? extends SQLTableModelColumn, Type>> listField, final List<Tuple2<SQLField, ?>> filters, final List<Tuple2<SQLField, ?>> filtersNot, |
String title, boolean onSelection) { |
String title) { |
super(new GridBagLayout()); |
this.list = l; |
this.setOpaque(false); |
this.onSelection = onSelection; |
GridBagConstraints c = new DefaultGridBagConstraints(); |
c.gridx = GridBagConstraints.RELATIVE; |
c.weightx = 0; |
152,25 → 143,16 |
c.gridy++; |
} |
if (this.onSelection) { |
this.list.getJTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
this.list.addListener(new TableModelListener() { |
@Override |
public void valueChanged(ListSelectionEvent e) { |
final List<ListSQLLine> listLines = list.getSelectedLines(); |
for (Tuple2<? extends SQLTableModelColumn, Type> field : listField) { |
if (field.get1() == Type.COUNT) { |
map.get(field.get0()).setText(String.valueOf(listLines.size())); |
private Object getValueAt(final ListSQLLine line, final SQLTableModelColumn col, final List<SQLTableModelColumn> columns) { |
final int indexOf = columns.indexOf(col); |
final Object res = line.getValueAt(indexOf); |
if (res == null) |
throw new IllegalStateException("Null value for " + col + " in " + line); |
return res; |
} |
} |
computeValues(listField, filters, filtersNot, listLines); |
} |
}); |
} else { |
this.list.addListener(new TableModelListener() { |
@Override |
public void tableChanged(TableModelEvent e) { |
final TableModel model = (TableModel) e.getSource(); |
180,48 → 162,17 |
else |
sqlModel = (ITableModel) ((TableSorter) model).getTableModel(); |
final List<ListSQLLine> listLines = new ArrayList<>(); |
for (int i = 0; i < sqlModel.getRowCount(); i++) { |
listLines.add(sqlModel.getRow(i)); |
} |
Map<SQLTableModelColumn, BigDecimal> mapTotal = new HashMap<SQLTableModelColumn, BigDecimal>(); |
Map<SQLTableModelColumn, Double> mapPourcent = new HashMap<SQLTableModelColumn, Double>(); |
Map<SQLTableModelColumn, Integer> mapPourcentSize = new HashMap<SQLTableModelColumn, Integer>(); |
for (Tuple2<? extends SQLTableModelColumn, Type> field : listField) { |
if (field.get1() == Type.COUNT) { |
map.get(field.get0()).setText(String.valueOf(model.getRowCount())); |
} |
} |
computeValues(listField, filters, filtersNot, listLines); |
} |
}); |
} |
} |
public void fireUpdated() { |
for (PropertyChangeListener l : this.loadingListener.getListeners(PropertyChangeListener.class)) { |
l.propertyChange(null); |
} |
} |
public void addListener(PropertyChangeListener l) { |
this.loadingListener.add(PropertyChangeListener.class, l); |
} |
private Object getValueAt(final ListSQLLine line, final SQLTableModelColumn col, final List<SQLTableModelColumn> columns) { |
final int indexOf = columns.indexOf(col); |
final Object res = line.getValueAt(indexOf); |
if (res == null) |
throw new IllegalStateException("Null value for " + col + " in " + line); |
return res; |
} |
private void computeValues(final List<Tuple2<? extends SQLTableModelColumn, Type>> listField, final List<Tuple2<SQLField, ?>> filters, final List<Tuple2<SQLField, ?>> filtersNot, |
final List<ListSQLLine> listLines) { |
Map<SQLTableModelColumn, BigDecimal> mapTotal = new HashMap<SQLTableModelColumn, BigDecimal>(); |
Map<SQLTableModelColumn, Double> mapPourcent = new HashMap<SQLTableModelColumn, Double>(); |
Map<SQLTableModelColumn, Integer> mapPourcentSize = new HashMap<SQLTableModelColumn, Integer>(); |
for (ListSQLLine line : listLines) { |
for (int i = 0; i < model.getRowCount(); i++) { |
final ListSQLLine line = sqlModel.getRow(i); |
final SQLRowValues rowAt = line.getRow(); |
final List<SQLTableModelColumn> columns = line.getColumns().getColumns(); |
346,4 → 297,17 |
} |
fireUpdated(); |
} |
}); |
} |
public void fireUpdated() { |
for (PropertyChangeListener l : this.loadingListener.getListeners(PropertyChangeListener.class)) { |
l.propertyChange(null); |
} |
} |
public void addListener(PropertyChangeListener l) { |
this.loadingListener.add(PropertyChangeListener.class, l); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractVenteArticleItemTable.java |
---|
36,8 → 36,6 |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.FieldPath; |
import org.openconcerto.sql.model.SQLBackgroundTableCache; |
import org.openconcerto.sql.model.SQLBackgroundTableCacheItem; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
1740,7 → 1738,6 |
} |
Collection<? extends SQLRowAccessor> cacheRemise = null; |
Collection<? extends SQLRowAccessor> cacheRemiseFamille = null; |
protected BigDecimal getTarifRemiseClient(SQLRowAccessor article, BigDecimal pv) { |
if (cacheRemise != null) { |
1759,60 → 1756,19 |
} |
protected Acompte getRemiseClient(SQLRowAccessor article) { |
Acompte remise = null; |
if (this.cacheRemiseFamille != null) { |
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) { |
if (article.getForeign("ID_FAMILLE_ARTICLE") != null && !article.isForeignEmpty("ID_FAMILLE_ARTICLE")) { |
Integer fID = article.getForeignID("ID_FAMILLE_ARTICLE"); |
remise = getRemiseFamille(fID); |
// TODO faire une fonction recursive avec un test pour eviter les boucles |
if (remise == null) { |
SQLBackgroundTableCacheItem cacheTableFamille = SQLBackgroundTableCache.getInstance().getCacheForTable(article.getTable().getForeignTable("ID_FAMILLE_ARTICLE")); |
SQLRow rowFamille = cacheTableFamille.getRowFromId(fID); |
if (rowFamille != null && rowFamille.getObject("ID_FAMILLE_ARTICLE_PERE") != null && !rowFamille.isForeignEmpty("ID_FAMILLE_ARTICLE_PERE")) { |
Integer fIDPere = rowFamille.getForeignID("ID_FAMILLE_ARTICLE_PERE"); |
remise = getRemiseFamille(fIDPere); |
if (remise == null) { |
SQLRow rowFamille2 = cacheTableFamille.getRowFromId(fIDPere); |
if (rowFamille2 != null && rowFamille2.getObject("ID_FAMILLE_ARTICLE_PERE") != null && !rowFamille2.isForeignEmpty("ID_FAMILLE_ARTICLE_PERE")) { |
Integer fIDPere2 = rowFamille2.getForeignID("ID_FAMILLE_ARTICLE_PERE"); |
remise = getRemiseFamille(fIDPere2); |
} |
} |
} |
} |
} |
} |
} |
Acompte remise = new Acompte(BigDecimal.ZERO, BigDecimal.ZERO); |
if (this.cacheRemise != null) { |
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) { |
for (SQLRowAccessor sqlRowAccessor : this.cacheRemise) { |
if (!sqlRowAccessor.isForeignEmpty("ID_ARTICLE") && sqlRowAccessor.getForeignID("ID_ARTICLE") == article.getID()) { |
BigDecimal r = sqlRowAccessor.getBigDecimal("POURCENT_REMISE"); |
if (remise != null) { |
remise = new Acompte(r, null); |
break; |
} |
} |
} |
} |
if (remise == null) { |
return new Acompte(BigDecimal.ZERO, BigDecimal.ZERO); |
} else { |
return remise; |
} |
} |
private Acompte getRemiseFamille(int fID) { |
Acompte remise = null; |
for (SQLRowAccessor sqlRowAccessor : this.cacheRemiseFamille) { |
if (!sqlRowAccessor.isForeignEmpty("ID_FAMILLE_ARTICLE") && sqlRowAccessor.getForeignID("ID_FAMILLE_ARTICLE") == fID) { |
BigDecimal r = sqlRowAccessor.getBigDecimal("POURCENT_REMISE"); |
remise = new Acompte(r, null); |
break; |
} |
} |
return remise; |
} |
1963,8 → 1919,7 |
super.setClient(rowClient, ask); |
if (getRowClient() != null && !getRowClient().isUndefined()) { |
this.cacheRemise = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_ARTICLE_CLIENT")); |
this.cacheRemiseFamille = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_FAMILLE_ARTICLE_CLIENT")); |
if (ask && (!this.cacheRemise.isEmpty() || !this.cacheRemiseFamille.isEmpty()) && getRowValuesTable().getRowCount() > 0 |
if (ask && this.cacheRemise.size() > 0 && getRowValuesTable().getRowCount() > 0 |
&& JOptionPane.showConfirmDialog(null, "Appliquer les remises associées au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) { |
int nbRows = this.table.getRowCount(); |
for (int i = 0; i < nbRows; i++) { |
1988,7 → 1943,6 |
} |
} else { |
this.cacheRemise = null; |
this.cacheRemiseFamille = null; |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalPanel.java |
---|
172,6 → 172,7 |
GridBagConstraints c = new DefaultGridBagConstraints(); |
c.gridheight = 1; |
c.weighty = 0; |
c.fill = GridBagConstraints.HORIZONTAL; |
// Collone 1 : Selection |
301,6 → 302,7 |
c.gridx = 3; |
c.gridy = 0; |
c.gridheight = GridBagConstraints.REMAINDER; |
c.weighty = 1; |
c.fill = GridBagConstraints.VERTICAL; |
c.weightx = 0; |
this.add(createSeparator(), c); |
307,6 → 309,7 |
c.gridheight = 1; |
c.fill = GridBagConstraints.HORIZONTAL; |
c.weighty = 0; |
c.gridx++; |
this.add(new JLabelBold(TM.tr("TotalPanel.global")), c); //$NON-NLS-1$ |
c.gridy++; |
/trunk/OpenConcerto/src/org/openconcerto/erp/element/objet/ClasseCompte.java |
---|
14,7 → 14,8 |
package org.openconcerto.erp.element.objet; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.sql.model.DBRoot; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLBase; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLTable; |
29,12 → 30,12 |
private static List<ClasseCompte> liste; |
public static void loadClasseCompte(ComptaPropsConfiguration conf) { |
DBRoot base = conf.getRootSociete(); |
public static void loadClasseCompte() { |
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); |
SQLTable classeCompteTable = base.getTable("CLASSE_COMPTE"); |
SQLSelect selClasse = new SQLSelect(); |
SQLSelect selClasse = new SQLSelect(base); |
selClasse.addSelect(classeCompteTable.getField("ID")); |
selClasse.addSelect(classeCompteTable.getField("NOM")); |
44,7 → 45,7 |
String reqClasse = selClasse.asString(); |
System.err.println(reqClasse); |
List<Map<String, Object>> obClasse = base.getDBSystemRoot().getDataSource().execute(reqClasse); |
List<Map<String, Object>> obClasse = base.getDataSource().execute(reqClasse); |
liste = new ArrayList<ClasseCompte>(); |
for (Map<String, Object> map : obClasse) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportToQuadraCompta.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportPanel.java |
---|
99,12 → 99,6 |
return new ExportSageEtendu(root); |
} |
}, |
QUADRACOMPTA("Quadratus : Export des écritures vers QuadraCompta") { |
@Override |
public AbstractExport createExport(DBRoot root) { |
return new ExportToQuadraCompta(root); |
} |
}, |
CCMX("Cegid CCMX") { |
@Override |
public AbstractExport createExport(DBRoot root) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/AbstractExport.java |
---|
29,7 → 29,6 |
import java.io.IOException; |
import java.io.OutputStream; |
import java.text.DateFormat; |
import java.text.ParseException; |
import java.text.SimpleDateFormat; |
import java.util.Date; |
171,7 → 170,7 |
protected abstract int fetchData(Date from, Date to, SQLRow selectedJournal, boolean onlyNew); |
protected abstract void export(final OutputStream out) throws IOException, ParseException; |
protected abstract void export(final OutputStream out) throws IOException; |
public static final String fixedLengthLeftAlign(final String str, final int fixedWidth) { |
if (str.length() >= fixedWidth) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportEBP_ComptaPro.java |
---|
160,6 → 160,5 |
bufOut.write(StringUtils.getFixedWidthString(amount, wAmount, Side.RIGHT, false)); |
bufOut.write("\r\n"); |
} |
bufOut.flush(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/utils/LowerCaseFormat.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/utils/LowerCaseFormatFilter.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/UIPreferencePanel.java |
---|
40,8 → 40,6 |
import javax.swing.UnsupportedLookAndFeelException; |
import javax.swing.border.LineBorder; |
import com.formdev.flatlaf.FlatLightLaf; |
public class UIPreferencePanel extends DefaultLocalPreferencePanel { |
private static final String UI_PROPERTIES = "ui.properties"; |
63,12 → 61,10 |
final GridBagConstraints c = new DefaultGridBagConstraints(); |
c.fill = GridBagConstraints.NONE; |
this.add(new JLabel("Look"), c); |
comboLook = new JComboBox(new String[] { "natif du système", "Nimbus", "Flat" }); |
comboLook = new JComboBox(new String[] { "natif du système", "Nimbus" }); |
String look = this.properties.getProperty(UI_LOOK); |
if (look != null && look.equals("nimbus")) { |
if (look != null && !look.equals("system")) { |
comboLook.setSelectedIndex(1); |
} else if (look != null && look.equals("flat")) { |
comboLook.setSelectedIndex(2); |
} else { |
comboLook.setSelectedIndex(0); |
} |
215,10 → 211,8 |
AlternateTableCellRenderer.setDefaultMap(Collections.singletonMap(Color.WHITE, background)); |
if (this.comboLook.getSelectedIndex() == 0) { |
properties.setProperty(UI_LOOK, "system"); |
} else if (this.comboLook.getSelectedIndex() == 1) { |
} else { |
properties.setProperty(UI_LOOK, "nimbus"); |
} else { |
properties.setProperty(UI_LOOK, "flat"); |
} |
if (this.comboDPI.getSelectedIndex() == 1) { |
278,9 → 272,8 |
final String look = properties.getProperty(UI_LOOK); |
final String nimbusClassName = getNimbusClassName(); |
if (look != null && look.equals("flat")) { |
FlatLightLaf.install(); |
} else if (look != null && look.equals("system")) { |
if (look != null && look.equals("system")) { |
useSystemLF(); |
} else if (look != null && look.equals("nimbus")) { |
useNimbusLF(); |
287,7 → 280,7 |
} else if (nimbusClassName == null || !System.getProperty("os.name", "??").toLowerCase().contains("linux")) { |
useSystemLF(); |
} else { |
FlatLightLaf.install(); |
useNimbusLF(); |
} |
final String dpi = properties.getProperty(UI_DPI); |
if (dpi != null && dpi.length() > 0 && !dpi.equalsIgnoreCase("1")) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/TemplateNXProps.java |
---|
53,7 → 53,6 |
import org.openconcerto.task.config.ComptaBasePropsConfiguration; |
import org.openconcerto.ui.preferences.TemplateProps; |
import org.openconcerto.utils.StreamUtils; |
import org.openconcerto.utils.prog.VMLauncher; |
import java.io.File; |
import java.io.IOException; |
135,8 → 134,6 |
register(DemandePrixSheetXML.TEMPLATE_ID, DemandePrixSheetXML.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("DEMANDE_PRIX")); |
register(DevisXmlSheet.TEMPLATE_ID, DevisXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("DEVIS")); |
register(VenteFactureXmlSheet.TEMPLATE_ID, VenteFactureXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("SAISIE_VENTE_FACTURE")); |
register(VenteFactureXmlSheet.TEMPLATE_ID + VenteFactureXmlSheet.TEMPLATE_SITUATION_SUFFIX, VenteFactureXmlSheet.TEMPLATE_PROPERTY_NAME, |
AbstractGenerationDocumentPreferencePanel.getLabelFromTable("SAISIE_VENTE_FACTURE") + " " + VenteFactureXmlSheet.TEMPLATE_SITUATION_SUFFIX); |
register(CommandeClientXmlSheet.TEMPLATE_ID, CommandeClientXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("COMMANDE_CLIENT")); |
register(BonLivraisonXmlSheet.TEMPLATE_ID, BonLivraisonXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("BON_DE_LIVRAISON")); |
register(AvoirClientXmlSheet.TEMPLATE_ID, AvoirClientXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("AVOIR_CLIENT")); |
232,8 → 229,6 |
if (property != null) { |
File storage = new File(property); |
((DefaultLocalTemplateProvider) provider).setBaseDirectory(storage); |
} else if (VMLauncher.getJPackageAppDir() != null) { |
((DefaultLocalTemplateProvider) provider).setBaseDirectory(new File(VMLauncher.getJPackageAppDir(), "Configuration/Template/Default")); |
} |
} else { |
provider = new DefaultCloudTemplateProvider(configuration.getSocieteID()); |
/trunk/OpenConcerto/src/org/openconcerto/erp/config/DSNInstallationUtils.java |
---|
161,33 → 161,6 |
} |
} |
if (!root.contains("DIPLOME_PREPARE")) { |
final SQLCreateTable createTableDiplome = new SQLCreateTable(root, "DIPLOME_PREPARE"); |
createTableDiplome.addVarCharColumn("CODE", 25); |
createTableDiplome.addVarCharColumn("NOM", 512); |
try { |
root.getBase().getDataSource().execute(createTableDiplome.asString()); |
insertUndef(createTableDiplome); |
root.refetchTable("DIPLOME_PREPARE"); |
root.getSchema().updateVersion(); |
final SQLTable table = root.getTable("DIPLOME_PREPARE"); |
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>(); |
v.add(Tuple2.create("03", "Niveau de formation équivalent au CAP (certificat d'aptitude professionnelle) ou au BEP (brevet d'études professionnelles)")); |
v.add(Tuple2.create("04", "Formation de niveau du bac (général, technologique ou professionnel), du brevet de technicien (BT) ou du brevet professionnel")); |
v.add(Tuple2.create("05", "Formation de niveau bac+2 : licence 2, BTS (brevet de technicien supérieur), DUT (diplôme universitaire de technologie), etc.")); |
v.add(Tuple2.create("06", "Formation de niveau bac+3 et bac+4 : licence 3, licence professionnelle, master 1, etc.")); |
v.add(Tuple2.create("07", "Formation de niveau bac+5 : master 2, diplôme d'études approfondies, diplôme d'études supérieures spécialisées, diplôme d'ingénieur, etc.")); |
v.add(Tuple2.create("08", "Formation de niveau bac+8 : doctorat, habilitation à diriger des recherches, etc. ")); |
insertValues(v, table); |
} catch (SQLException ex) { |
throw new IllegalStateException("Erreur lors de la création de la table " + "DIPLOME_PREPARE", ex); |
} |
} |
if (!root.contains("TYPE_PREAVIS")) { |
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "TYPE_PREAVIS"); |
createTableMotif.addVarCharColumn("CODE", 25); |
1679,14 → 1652,6 |
root.getSchema().updateVersion(); |
} |
if (!tableContrat.contains("ID_DIPLOME_PREPARE")) { |
updateContrat = true; |
AlterTable alter = new AlterTable(tableContrat); |
alter.addForeignColumn("ID_DIPLOME_PREPARE", root.findTable("DIPLOME_PREPARE")); |
root.getBase().getDataSource().execute(alter.asString()); |
root.getSchema().updateVersion(); |
} |
if (updateContrat) { |
root.refetchTable("CONTRAT_SALARIE"); |
tableContrat = root.findTable("CONTRAT_SALARIE"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/config/ComptaPropsConfiguration.java |
---|
26,7 → 26,6 |
import org.openconcerto.erp.core.common.element.SocieteCommonSQLElement; |
import org.openconcerto.erp.core.common.element.StyleSQLElement; |
import org.openconcerto.erp.core.common.element.TitrePersonnelSQLElement; |
import org.openconcerto.erp.core.customerrelationship.customer.element.AgenceSQLElement; |
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientDepartementSQLElement; |
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactAdministratifSQLElement; |
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactFournisseurSQLElement; |
123,7 → 122,6 |
import org.openconcerto.erp.core.humanresources.payroll.element.CumulsCongesSQLElement; |
import org.openconcerto.erp.core.humanresources.payroll.element.CumulsPayeSQLElement; |
import org.openconcerto.erp.core.humanresources.payroll.element.DSNNatureSQLElement; |
import org.openconcerto.erp.core.humanresources.payroll.element.DiplomePrepareSQLElement; |
import org.openconcerto.erp.core.humanresources.payroll.element.FichePayeElementSQLElement; |
import org.openconcerto.erp.core.humanresources.payroll.element.FichePayeSQLElement; |
import org.openconcerto.erp.core.humanresources.payroll.element.ImpressionRubriqueSQLElement; |
178,7 → 176,6 |
import org.openconcerto.erp.core.sales.product.element.ArticleFournisseurSecondaireSQLElement; |
import org.openconcerto.erp.core.sales.product.element.ArticleTarifSQLElement; |
import org.openconcerto.erp.core.sales.product.element.CoutRevientSQLElement; |
import org.openconcerto.erp.core.sales.product.element.CustomerProductFamilyQtyPriceSQLElement; |
import org.openconcerto.erp.core.sales.product.element.CustomerProductQtyPriceSQLElement; |
import org.openconcerto.erp.core.sales.product.element.EcoContributionSQLElement; |
import org.openconcerto.erp.core.sales.product.element.FamilleArticleSQLElement; |
276,9 → 273,7 |
import org.openconcerto.erp.injector.BonFactureEltSQLInjector; |
import org.openconcerto.erp.injector.BonFactureSQLInjector; |
import org.openconcerto.erp.injector.BonReceptionFactureFournisseurSQLInjector; |
import org.openconcerto.erp.injector.BrEltFactEltSQLInjector; |
import org.openconcerto.erp.injector.BrFactureAchatSQLInjector; |
import org.openconcerto.erp.injector.CmdEltFactEltSQLInjector; |
import org.openconcerto.erp.injector.CommandeBlEltSQLInjector; |
import org.openconcerto.erp.injector.CommandeBlSQLInjector; |
import org.openconcerto.erp.injector.CommandeBrEltSQLInjector; |
791,7 → 786,6 |
dir.addSQLElement(TypeTauxPasSQLElement.class, root); |
dir.addSQLElement(CodeAmenagementPartielSQLElement.class, root); |
dir.addSQLElement(CodeSuspensionSQLElement.class, root); |
dir.addSQLElement(DiplomePrepareSQLElement.class, root); |
// ECO |
dir.addSQLElement(FamilleEcoContributionSQLElement.class, root); |
838,7 → 832,6 |
dir.addSQLElement(AttachmentSQLElement.class); |
dir.addSQLElement(CustomerProductQtyPriceSQLElement.class); |
dir.addSQLElement(CustomerProductFamilyQtyPriceSQLElement.class); |
dir.addSQLElement(EtatStockSQLElement.class); |
dir.addSQLElement(EtatStockItemSQLElement.class); |
dir.addSQLElement(ArticleTarifSQLElement.class); |
861,7 → 854,6 |
dir.addSQLElement(ContactSalarieSQLElement.class); |
dir.addSQLElement(new TitrePersonnelSQLElement()); |
dir.addSQLElement(new ContactSQLElement()); |
dir.addSQLElement(new AgenceSQLElement(this.getRootSociete())); |
dir.addSQLElement(new SaisieKmItemSQLElement()); |
dir.addSQLElement(new EcritureSQLElement()); |
1113,8 → 1105,6 |
new DevisBlEltSQLInjector(rootSociete); |
new DevisBlSQLInjector(rootSociete); |
new CommandeBlEltSQLInjector(rootSociete); |
new CmdEltFactEltSQLInjector(rootSociete); |
new BrEltFactEltSQLInjector(rootSociete); |
new CommandeBrEltSQLInjector(rootSociete); |
new CommandeBlSQLInjector(rootSociete); |
new BonFactureSQLInjector(rootSociete); |
/trunk/OpenConcerto/src/org/openconcerto/erp/config/DefaultMenuConfiguration.java |
---|
96,7 → 96,6 |
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.ReportingCommercialAction; |
import org.openconcerto.erp.core.reports.stat.action.ReportingCommercialFournisseurAction; |
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; |
118,7 → 117,6 |
import org.openconcerto.erp.core.sales.invoice.action.NouveauSaisieVenteComptoirAction; |
import org.openconcerto.erp.core.sales.invoice.action.NouveauSaisieVenteFactureAction; |
import org.openconcerto.erp.core.sales.invoice.report.ReportingClientPanel; |
import org.openconcerto.erp.core.sales.invoice.report.SituationCompteClientPanel; |
import org.openconcerto.erp.core.sales.order.action.ListeDesCommandesClientAction; |
import org.openconcerto.erp.core.sales.order.action.ListeDesCommandesClientItemsAction; |
import org.openconcerto.erp.core.sales.order.action.ListeDesElementsACommanderClientAction; |
393,6 → 391,7 |
gCustomer.addItem("customer.payment.list"); |
gCustomer.addItem("customer.payment.followup.list"); |
gCustomer.addItem("customer.payment.check.pending.list"); |
gCustomer.addItem("customer.payment.check.deposit.list"); |
gCustomer.addItem("customer.payment.check.pending.create"); |
gCustomer.addItem("customer.payment.check.deposit.list"); |
gCustomer.addItem("customer.credit.check.list"); |
424,7 → 423,6 |
group.addItem("order.list.reporting"); |
group.addItem("sales.list.report"); |
group.addItem("sales.list.salesman.report"); |
group.addItem("sales.list.salesman.supplier.report"); |
group.addItem("sales.product.graph"); |
group.addItem("sales.product.margin.graph"); |
group.addItem("sales.product.family.graph"); |
733,7 → 731,6 |
mManager.putAction(new EvolutionCmdCumulAction(), "sales.graph.cmd.cumulate"); |
mManager.putAction(new ReportingCommercialAction(conf.getRootSociete()), "sales.list.salesman.report"); |
mManager.putAction(new ReportingCommercialFournisseurAction(conf), "sales.list.salesman.supplier.report"); |
mManager.putAction(new EvolutionMargeAction(), "sales.margin.graph"); |
mManager.putAction(new GenReportingVenteAction(false), "sales.list.reporting"); |
791,15 → 788,6 |
} |
}, "customer.payment.report"); |
mManager.putAction(new AbstractAction("Situation Client") { |
@Override |
public void actionPerformed(ActionEvent arg0) { |
PanelFrame frame = new PanelFrame(new SituationCompteClientPanel(conf), "Situation client"); |
frame.setVisible(true); |
} |
}, "customer.payment.details"); |
mManager.putAction(new ListeDesEncaissementsAction(), "customer.payment.list"); |
mManager.putAction(new ListeDesRelancesAction(), "customer.payment.followup.list"); |
mManager.putAction(new ListeDesChequesAEncaisserAction(), "customer.payment.check.pending.list"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/config/translation_fr.xml |
---|
189,9 → 189,7 |
<!-- Matching --> |
<action id="financing.accouning.entries.source.show" label="Voir la source" /> |
<action id="financing.accouning.entries.match" label="Lettrer" /> |
<action id="financing.accouning.entries.match.partial" label="Lettrer partiel" /> |
<action id="financing.accouning.entries.unmatch" label="Délettrer" /> |
<action id="financing.accouning.entries.unmatch.partial" label="Délettrer partiel" /> |
<!-- Invoice --> |
<item id="sales.invoice.number" label="Numéro" /> |
<item id="sales.invoice.date" label="Date" /> |
252,18 → 250,8 |
<item id="customerrelationship.customer.identifier" label="Code" /> |
<item id="customerrelationship.customer.date" label="Date" /> |
<item id="customerrelationship.customer.customproduct" label="Réf. Art. Interne" /> |
<item id="customerrelationship.customer.customtarif" label="Remises client sur article" /> |
<item id="customerrelationship.customer.customfamilytarif" label="Remises client sur famille d'article" /> |
<item id="customerrelationship.customer.customtarif" label="Remises client" /> |
<!-- Agence --> |
<item id="customerrelationship.customer.agency" label="Agences" /> |
<item id="customerrelationship.customer.agencies" label="Liste des agences" /> |
<item id="customerrelationship.customer.agency.designation" label="Designation" /> |
<item id="customerrelationship.customer.agency.phone1" label="Téléphone" /> |
<item id="customerrelationship.customer.agency.email" label="E-Mail" /> |
<item id="customerrelationship.customer.agency.fax" label="Fax" /> |
<item id="customerrelationship.customer.agency.customer" label="Client" /> |
<item id="customerrelationship.customer.agency.address" label="Adresse de l'agence" /> |
<!-- Currency --> |
<item id="currency.USD" label="Dollar américain" /> |
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_fr.xml |
---|
12,22 → 12,6 |
<FIELD name="MONTANT" label="Montant" /> |
<FIELD name="ID_MOUVEMENT" label="Mouvement" /> |
</element> |
<element refid="customerrelationship.customer.category" nameClass="feminine" name="catégorie de client"> |
<FIELD name="name" label="Nom" /> |
</element> |
<element refid="sales.customer.product.qty.price" nameClass="masculine" name="tarif client"> |
<FIELD name="QUANTITE" label="Quantité" /> |
<FIELD name="ID_ARTICLE" label="Article" /> |
<FIELD name="ID_CLIENT" label="Client" /> |
<FIELD name="POURCENT_REMISE" label="% remise" /> |
</element> |
<element refid="sales.customer.product.family.qty.price" nameClass="masculine" |
name="tarif famille d'article client"> |
<FIELD name="QUANTITE" label="Quantité" /> |
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille article" /> |
<FIELD name="ID_CLIENT" label="Client" /> |
<FIELD name="POURCENT_REMISE" label="% remise" /> |
</element> |
<element refid="address" nameClass="feminine" name="adresse"> |
<FIELD name="TYPE" label="Type" /> |
<FIELD name="LIBELLE" label="Libellé" /> |
307,7 → 291,6 |
<FIELD name="T_DEVISE" label="Total Devise" /> |
<FIELD name="ID_MODELE" label="Modèle" /> |
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." /> |
<FIELD name="ID_TAXE_PORT" label="Taxe sur port" /> |
</element> |
<element refid="sales.credit.item" nameClass="masculine" name="élément d'avoir" namePlural="éléments d'avoir"> |
<FIELD name="ID_DEPOT_STOCK" label="Dépôt Stock" /> |
382,7 → 365,6 |
<FIELD name="DATE" label="Date d'intervention" /> |
<FIELD name="DATE_FIN" label="Date de fin d'intervention" /> |
<FIELD name="POURCENT_SERVICE" label="Pourcentage service" /> |
<FIELD name="ID_TAXE_PORT" label="Taxe sur port" /> |
</element> |
<element refid="supplychain.credit.note" nameClass="feminine" name="facture d'avoir fournisseur" |
namePlural="factures d'avoir fournisseur"> |
485,7 → 467,7 |
<FIELD name="ID_TAXE" label="Taxe" /> |
<FIELD name="POIDS" label="Poids UV net" /> |
<FIELD name="PRIX_METRIQUE_VT_1" label="P.V. UV HT" /> |
<FIELD name="PRIX_METRIQUE_HA_1" label="P.A. UV HT" /> |
<FIELD name="PRIX_METRIQUE_HA_1" label="P.A. UV² HT" /> |
<FIELD name="VALEUR_METRIQUE_1" label="Longueur par défaut" /> |
<FIELD name="ID_METRIQUE_1" label="Métrique" /> |
<FIELD name="PRIX_METRIQUE_VT_2" label="P.V. HT au mètre" /> |
504,7 → 486,6 |
<FIELD name="ID_STYLE" label="Style" /> |
<FIELD name="SERVICE" label="Service" /> |
<FIELD name="ID_MODE_VENTE_ARTICLE" label="Mode de vente" /> |
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille" /> |
</element> |
<element refid="sales.shipment.delivery.note" nameClass="masculine" name="bon de livraison" |
namePlural="bons de livraison"> |
535,7 → 516,6 |
<FIELD name="ID_MODELE" label="Modèle" /> |
<FIELD name="T_ECO_CONTRIBUTION" label="Dont Eco-Contrib." /> |
<FIELD name="invoiceProgress" label="Avancement facturation" /> |
<FIELD name="ID_COMMERCIAL" label="Commercial" /> |
</element> |
<element refid="sales.shipment.item" nameClass="masculine" name="élément de bon de livraison" |
namePlural="éléments de bon de livraison"> |
1031,7 → 1011,7 |
</element> |
<element refid="humanresources.payroll.contract.employe" nameClass="masculine" name="contrat salarié" |
namePlural="contrats salariés"> |
<FIELD name="ID_DIPLOME_PREPARE" label="Diplôme préparé (S21.G00.30.025)" /> |
<FIELD name="ID_CODE_AMENAGEMENT_PARTIEL" label="Aménagement temps partiel (S21.G00.40.078)" /> |
<FIELD name="ID_CODE_SUSPENSION" label="Motif de suspension (S21.G00.65.001)" /> |
<FIELD name="DATE_FIN_SUSPENSION" label="Fin de supension (S21.G00.65.003)" /> |
1236,10 → 1216,8 |
<FIELD name="T_PA_HT" label="Total achat HT" /> |
<FIELD name="T_POIDS" label="Poids total net" /> |
<FIELD name="ID_MODE_VENTE_ARTICLE" label="Mode de vente" /> |
<FIELD name="POURCENT_ACOMPTE" label="% Acompte" /> |
<FIELD name="LIVRE" label="Livré" /> |
<FIELD name="QTE_LIVREE" label="Qté livrée" /> |
<FIELD name="LIVRE_FORCED" label="Livraison forcée" /> |
</element> |
<element refid="humanresources.employe.salesman" nameClass="masculine" name="commercial"> |
<FIELD name="ID_POLE_PRODUIT" label="Pôle produit" /> |
1332,7 → 1310,6 |
<FIELD name="ID_FABRICANT" label="Fabricant" /> |
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" /> |
<FIELD name="QTE" label="Quantité" /> |
<FIELD name="QTE_RECUE" label="Qté recues" /> |
<FIELD name="QTE_UNITAIRE" label="Quantité unitaire" /> |
<FIELD name="REPERE" label="Repère" /> |
<FIELD name="EN_STOCK" label="En stock" /> |
1736,7 → 1713,6 |
</element> |
<element refid="sales.order.facturation" nameClass="masculine" name="terme de facturation de commande client" |
namePlural="termes de facturation commandes clients"> |
<FIELD name="NOM" label="Désignation" /> |
<FIELD name="ID_SAISIE_VENTE_FACTURE" label="Facture" /> |
<FIELD name="ID_COMMANDE_CLIENT" label="Commande" /> |
<FIELD name="ID_TYPE_REGLEMENT" label="Type règlement" /> |
1753,8 → 1729,7 |
namePlural="factures fournisseur"> |
<FIELD name="DATE_REGLEMENT" label="Date de règlement" /> |
<FIELD name="TVA_ADJUSTMENT" label="Ajustement de TVA" /> |
<FIELD name="ID_AVOIR_FOURNISSEUR" label="Avoir N°1" /> |
<FIELD name="ID_AVOIR_FOURNISSEUR_2" label="Avoir N°2" /> |
<FIELD name="ID_AVOIR_FOURNISSEUR" label="Avoir" /> |
<FIELD name="NET_A_PAYER" label="Net à payer" /> |
<FIELD name="ID_TAXE_PORT" label="Taxe sur port" /> |
<FIELD name="PORT_HT" label="Frais de port HT" /> |
1795,7 → 1770,6 |
<FIELD name="ID_CODE_FOURNISSEUR" label="Code Fournisseur" /> |
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" /> |
<FIELD name="ID_ARTICLE" label="Article" /> |
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille" /> |
<FIELD name="ID_DEVISE" label="Devise" /> |
<FIELD name="PA_DEVISE" label="PA Devise" /> |
<FIELD name="PA_DEVISE_T" label="PA Devise Total" /> |
2067,7 → 2041,6 |
<FIELD name="DATE" label="Date" /> |
<FIELD name="ID_ARTICLE" label="Article" /> |
<FIELD name="REEL" label="Réel" /> |
<FIELD name="ID_STOCK" label="Stock" /> |
</element> |
<element refid="finance.accounting.account.kind" nameClass="feminine" name="nature du compte" |
namePlural="natures du compte"> |
2365,7 → 2338,7 |
<FIELD name="ANALYTIQUE" label="Analytique" /> |
<FIELD name="NUMERO" label="N° compte" /> |
<FIELD name="NOM" label="Compte" /> |
<FIELD name="NOM_ECRITURE" label="Libellé écriture" /> |
<FIELD name="NOM_ECRITURE" label="libellé écriture" /> |
<FIELD name="DEBIT" label="Débit" /> |
<FIELD name="CREDIT" label="Crédit" /> |
<FIELD name="ID_ECRITURE" label="Ecriture" /> |
/trunk/OpenConcerto/src/org/openconcerto/erp/config/fieldmapping.xml |
---|
7,14 → 7,7 |
<field id="customerrelationship.country" name="ID_PAYS" /> |
<field id="customerrelationship.phone" name="PHONE" /> |
</table> |
<table id="customerrelationship.customer.agency" name="AGENCE"> |
<field id="customerrelationship.customer.agency.designation" name="DESIGNATION" /> |
<field id="customerrelationship.customer.agency.phone1" name="TEL_1" /> |
<field id="customerrelationship.customer.agency.email" name="EMAIL" /> |
<field id="customerrelationship.customer.agency.fax" name="FAX" /> |
<field id="customerrelationship.customer.agency.customer" name="ID_CLIENT" /> |
<field id="customerrelationship.customer.agency.address" name="ID_ADRESSE" /> |
</table> |
<table id="sales.invoice" name="SAISIE_VENTE_FACTURE"> |
<field id="sales.invoice.number" name="NUMERO" /> |
<field id="sales.invoice.date" name="DATE" /> |
/trunk/OpenConcerto/src/org/openconcerto/erp/config/update/Updater_1_5.java |
---|
29,7 → 29,6 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement; |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem; |
import org.openconcerto.sql.changer.convert.AddMDFields; |
import org.openconcerto.sql.model.AliasedTable; |
import org.openconcerto.sql.model.DBRoot; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLField.Properties; |
81,24 → 80,6 |
tableCompte.fetchFields(); |
} |
// Champ obsolete sur compte |
SQLTable tableTitre = root.getTable("TITRE_PERSONNEL"); |
if (!tableTitre.contains("OBSOLETE")) { |
final AlterTable alter = new AlterTable(tableTitre); |
alter.addBooleanColumn("OBSOLETE", Boolean.FALSE, false); |
tableTitre.getBase().getDataSource().execute(alter.asString()); |
tableTitre.getSchema().updateVersion(); |
tableTitre.fetchFields(); |
final UpdateBuilder updBuilder = new UpdateBuilder(tableTitre).setObject(tableTitre.getField("OBSOLETE"), Boolean.TRUE); |
updBuilder.setWhere(new Where(tableTitre.getField("CODE"), "=", "Mlle")); |
tableTitre.getBase().getDataSource().execute(updBuilder.asString()); |
final UpdateBuilder updBuilder2 = new UpdateBuilder(tableTitre).setObject(tableTitre.getField("CODE"), "M."); |
updBuilder2.setWhere(new Where(tableTitre.getField("CODE"), "=", "Mr")); |
tableTitre.getBase().getDataSource().execute(updBuilder2.asString()); |
} |
// Transaction du solde |
if (!root.contains(COMPTE_CLIENT_TRANSACTION)) { |
final SQLCreateTable createTable = new SQLCreateTable(root, COMPTE_CLIENT_TRANSACTION); |
250,7 → 231,7 |
createTable.addVarCharColumn("TAG", 128); |
createTable.addIntegerColumn("VERSION", 0); |
createTable.addVarCharColumn("HASH", 32); |
createTable.addBooleanColumn("ENCRYPTED", Boolean.FALSE, false); |
try { |
root.getBase().getDataSource().execute(createTable.asString()); |
InstallationPanel.insertUndef(createTable); |
286,13 → 267,7 |
tableAttachment.getSchema().updateVersion(); |
tableAttachment.fetchFields(); |
} |
if (!tableAttachment.contains("ENCRYPTED")) { |
final AlterTable alter = new AlterTable(tableAttachment); |
alter.addBooleanColumn("ENCRYPTED", Boolean.FALSE, false); |
tableAttachment.getBase().getDataSource().execute(alter.asString()); |
tableAttachment.getSchema().updateVersion(); |
tableAttachment.fetchFields(); |
} |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "FACTURE_FOURNISSEUR", "SAISIE_VENTE_FACTURE", "SALARIE"); |
for (String string : gedTable) { |
SQLTable tableGED = root.getTable(string); |
434,6 → 409,7 |
root.getSchema().updateVersion(); |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt); |
build.setObject("RECU", Boolean.FALSE); |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\""); |
Where w = Where.createRaw(tableCmdFElt.getField("QTE_RECUE").getQuotedName() + " < (" + tableCmdFElt.getField("QTE").getQuotedName() + "*" |
+ tableCmdFElt.getField("QTE_UNITAIRE").getQuotedName() + ")", tableCmdFElt.getField("QTE_UNITAIRE"), tableCmdFElt.getField("QTE"), tableCmdFElt.getField("QTE_RECUE")); |
2310,118 → 2286,8 |
tableEtatStock.getSchema().updateVersion(); |
tableEtatStock.fetchFields(); |
} |
// Création de la table Agence |
if (!root.contains("AGENCE")) { |
SQLCreateTable createAgence = new SQLCreateTable(root, "AGENCE"); |
createAgence.addVarCharColumn("DESIGNATION", 256); |
createAgence.addVarCharColumn("TEL_1", 256); |
createAgence.addVarCharColumn("EMAIL", 256); |
createAgence.addVarCharColumn("FAX", 256); |
createAgence.addForeignColumn("ID_CLIENT", root.findTable("CLIENT")); |
createAgence.addForeignColumn("ID_ADRESSE", root.findTable("ADRESSE")); |
try { |
// test |
root.getBase().getDataSource().execute(createAgence.asString()); |
root.refetchTable("AGENCE"); |
SQLRowValues rowVals = new SQLRowValues(root.getTable("AGENCE")); |
SQLRow rowInserted = rowVals.commit(); |
SQLTable.setUndefID(root.getSchema(), "AGENCE", rowInserted.getID()); |
tableDevis.getSchema().updateVersion(); |
} catch (SQLException ex) { |
throw new IllegalStateException("Erreur lors de la création de la table AGENCE", ex); |
} |
} |
// Tarification client par famille article |
if (root.getTable("TARIF_FAMILLE_ARTICLE_CLIENT") == null) { |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_FAMILLE_ARTICLE_CLIENT"); |
createTableQtyTarif.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE")); |
createTableQtyTarif.addForeignColumn("ID_CLIENT", root.getTable("CLIENT")); |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false); |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true); |
// createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true); |
try { |
root.getBase().getDataSource().execute(createTableQtyTarif.asString()); |
InstallationPanel.insertUndef(createTableQtyTarif); |
root.refetchTable("TARIF_FAMILLE_ARTICLE_CLIENT"); |
root.getSchema().updateVersion(); |
} catch (SQLException ex) { |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_FAMILLE_ARTICLE_CLIENT", ex); |
} |
} |
// Tarification client par famille article |
if (root.getTable("TARIF_FAMILLE_ARTICLE_CLIENT") == null) { |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_FAMILLE_ARTICLE_CLIENT"); |
createTableQtyTarif.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE")); |
createTableQtyTarif.addForeignColumn("ID_CLIENT", root.getTable("CLIENT")); |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false); |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true); |
// createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true); |
try { |
root.getBase().getDataSource().execute(createTableQtyTarif.asString()); |
InstallationPanel.insertUndef(createTableQtyTarif); |
root.refetchTable("TARIF_FAMILLE_ARTICLE_CLIENT"); |
root.getSchema().updateVersion(); |
} catch (SQLException ex) { |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_FAMILLE_ARTICLE_CLIENT", ex); |
} |
} |
SQLTable tableAvoirC = root.getTable("AVOIR_CLIENT"); |
if (!tableAvoirC.contains("ID_TAXE_PORT")) { |
final AlterTable alterB = new AlterTable(tableAvoirC); |
alterB.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE")); |
root.getBase().getDataSource().execute(alterB.asString()); |
root.refetchTable(tableAvoirC.getName()); |
root.getSchema().updateVersion(); |
} |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE"); |
if (!tableVF.contains("ID_FACTURATION_COMMANDE_CLIENT")) { |
final AlterTable alter = new AlterTable(tableVF); |
final SQLTable tableFacturationCommandeClient = tableVF.getDBRoot().getTable("FACTURATION_COMMANDE_CLIENT"); |
alter.addForeignColumn("ID_FACTURATION_COMMANDE_CLIENT", tableFacturationCommandeClient); |
tableVF.getBase().getDataSource().execute(alter.asString()); |
tableVF.getSchema().updateVersion(); |
tableVF.fetchFields(); |
// update ID_FACTURATION_COMMANDE |
UpdateBuilder builder = new UpdateBuilder(tableVF); |
AliasedTable ref = new AliasedTable(tableFacturationCommandeClient, "tf"); |
builder.addBackwardVirtualJoin(ref, "ID_SAISIE_VENTE_FACTURE"); |
builder.setFromVirtualJoinField("ID_FACTURATION_COMMANDE_CLIENT", "tf", tableFacturationCommandeClient.getKey().getName()); |
tableVF.getBase().getDataSource().execute(builder.asString()); |
} |
if (!root.getTable("NUMEROTATION_AUTO").contains("CODE_LETTRAGE_PARTIEL")) { |
final AlterTable alterNumero = new AlterTable(root.getTable("NUMEROTATION_AUTO")); |
alterNumero.addVarCharColumn("CODE_LETTRAGE_PARTIEL", 256); |
root.getBase().getDataSource().execute(alterNumero.asString()); |
root.refetchTable("NUMEROTATION_AUTO"); |
root.getSchema().updateVersion(); |
} |
if (!root.getTable("ECRITURE").contains("LETTRAGE_PARTIEL")) { |
final AlterTable alterEcriture = new AlterTable(root.getTable("ECRITURE")); |
alterEcriture.addVarCharColumn("LETTRAGE_PARTIEL", 256); |
root.getBase().getDataSource().execute(alterEcriture.asString()); |
root.refetchTable("ECRITURE"); |
root.getSchema().updateVersion(); |
} |
SQLTable tableFactureF = root.getTable("FACTURE_FOURNISSEUR"); |
if (!tableFactureF.contains("ID_AVOIR_FOURNISSEUR_2")) { |
final AlterTable alter = new AlterTable(tableFactureF); |
final SQLTable tableAvoirF = tableVF.getDBRoot().getTable("AVOIR_FOURNISSEUR"); |
alter.addForeignColumn("ID_AVOIR_FOURNISSEUR_2", tableAvoirF); |
tableFactureF.getBase().getDataSource().execute(alter.asString()); |
tableFactureF.getSchema().updateVersion(); |
tableVF.fetchFields(); |
} |
} |
public static void initStock(SQLRow rowArticle, int idDepot) { |
SQLSelect selStock = new SQLSelect(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/modules/ModulePackager.java |
---|
216,7 → 216,7 |
final JarEntry e = entries.nextElement(); |
if (!e.getName().startsWith("META-INF")) { |
// use copy-constructor to keep all fields |
zip(out, new JarEntry(e.getName()), f.getInputStream(e)); |
zip(out, new JarEntry(e), f.getInputStream(e)); |
} |
} |
} finally { |
/trunk/OpenConcerto/src/org/openconcerto/erp/modules/ComponentsContext.java |
---|
17,7 → 17,6 |
import org.openconcerto.sql.element.SQLElementDirectory; |
import org.openconcerto.sql.model.DBRoot; |
import org.openconcerto.sql.model.SQLName; |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox; |
import org.openconcerto.sql.sqlobject.SQLTextCombo; |
import org.openconcerto.sql.view.DropManager; |
import org.openconcerto.sql.view.FileDropHandler; |
25,7 → 24,6 |
import org.openconcerto.utils.ListMap; |
import java.util.Set; |
import java.util.function.Supplier; |
import javax.swing.text.JTextComponent; |
75,9 → 73,9 |
} |
} |
public final void putAdditionalTextField(final String tableName, final String name, final Supplier<? extends JTextComponent> comp) { |
public final void putAdditionalField(final String tableName, final String name, final JTextComponent comp) { |
final SQLElement elem = checkField(tableName, name); |
if (elem.putAdditionalTextField(name, comp)) { |
if (elem.putAdditionalField(name, comp)) { |
this.fields.add(elem, name); |
} else { |
throw new IllegalStateException("Already added " + name + " in " + elem); |
84,9 → 82,9 |
} |
} |
public final void putAdditionalTextCombo(final String tableName, final String name, final Supplier<? extends SQLTextCombo> comp) { |
public final void putAdditionalField(final String tableName, final String name, final SQLTextCombo comp) { |
final SQLElement elem = checkField(tableName, name); |
if (elem.putAdditionalTextCombo(name, comp)) { |
if (elem.putAdditionalField(name, comp)) { |
this.fields.add(elem, name); |
} else { |
throw new IllegalStateException("Already added " + name + " in " + elem); |
93,15 → 91,6 |
} |
} |
public final void putAdditionalCombo(final String tableName, final String name, final Supplier<? extends SQLRequestComboBox> comp) { |
final SQLElement elem = checkField(tableName, name); |
if (elem.putAdditionalCombo(name, comp)) { |
this.fields.add(elem, name); |
} else { |
throw new IllegalStateException("Already added " + name + " in " + elem); |
} |
} |
final ListMap<SQLElement, String> getFields() { |
return this.fields; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateFrameAbstractAction.java |
---|
50,12 → 50,9 |
final Object name = action.getValue(Action.NAME); |
WindowStateManager stateManager = null; |
if (name != null) { |
if (conf == null) { |
System.err.println("Warning: no configuration for action " + action + ", unable to use a window state manager."); |
stateManager = new WindowStateManager(frame, new File(conf.getConfDir(), "Configuration" + File.separator + "Frame" + File.separator + name.toString() + ".xml"), |
true); |
} else { |
stateManager = new WindowStateManager(frame, new File(conf.getConfDir(), "Configuration" + File.separator + "Frame" + File.separator + name.toString() + ".xml"), true); |
} |
} else { |
System.err.println("Warning: no action name for action " + action + ", unable to use a window state manager."); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/action/NouvelleConnexionAction.java |
---|
35,9 → 35,6 |
import org.openconcerto.erp.rights.MenuComboRightEditor; |
import org.openconcerto.erp.utils.NXDatabaseAccessor; |
import org.openconcerto.map.model.Ville; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.PropsConfiguration; |
import org.openconcerto.sql.TM; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLBackgroundTableCache; |
import org.openconcerto.sql.model.SQLBase; |
67,7 → 64,6 |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.JImage; |
import org.openconcerto.utils.cc.IClosure; |
import org.openconcerto.utils.i18n.TranslationManager; |
import java.awt.Color; |
import java.awt.GridBagConstraints; |
85,7 → 81,6 |
import java.util.logging.Level; |
import javax.swing.Action; |
import javax.swing.JComponent; |
import javax.swing.JFrame; |
import javax.swing.JOptionPane; |
import javax.swing.JPanel; |
208,7 → 203,6 |
final String socTitle = comptaPropsConfiguration.getRowSociete() == null ? "" : ", [Société " + comptaPropsConfiguration.getRowSociete().getString("NOM") + "]"; |
f.setTitle(comptaPropsConfiguration.getAppName() + " " + version + socTitle); |
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); |
} |
}); |
final FutureTask<?> showMainFrame = new FutureTask<Object>(new Runnable() { |
281,29 → 275,11 |
c.fill = GridBagConstraints.BOTH; |
this.connexionPanel = ConnexionPanel.create(r, image, !Gestion.isMinimalMode()); |
final List<Locale> langs = Arrays.asList(Locale.FRANCE, Locale.CANADA_FRENCH, new Locale("fr", "CH"), new Locale("fr", "BE"), Locale.UK, Locale.CANADA, Locale.US, Locale.GERMANY, |
new Locale("de", "CH"), new Locale("es", "ES"), new Locale("pl", "PL")); |
if (this.connexionPanel == null) { |
final Locale locale = UserProps.getInstance().getLocale(); |
// for next launch |
UserProps.getInstance().setLocale(locale); |
// for current run |
((PropsConfiguration) Configuration.getInstance()).setLocale(locale); |
// for code that will never need more than one Locale concurrently |
// (e.g. used by TM singletons in various packages) |
Locale.setDefault(locale); |
// as explained in Locale.setDefault() javadoc : "be prepared to reinitialize |
// locale-sensitive code" |
JComponent.setDefaultLocale(locale); |
// throw RuntimeException like ResourceBundle.getBundle() at the beginning of this |
// method |
TranslationManager.createDefaultInstance(); |
TM.getInstance(); |
if (this.connexionPanel == null) |
return null; |
} |
this.connexionPanel.initLocalization(getClass().getName(), Arrays.asList(Locale.FRANCE, Locale.CANADA_FRENCH, new Locale("fr", "CH"), new Locale("fr", "BE"), Locale.UK, Locale.CANADA, |
Locale.US, Locale.GERMANY, new Locale("de", "CH"), new Locale("es", "ES"), new Locale("pl", "PL"))); |
this.connexionPanel.initLocalization(getClass().getName(), langs); |
p.add(this.connexionPanel, c); |
final PanelFrame panelFrame = new PanelFrame(p, "Connexion"); |
panelFrame.setLocationRelativeTo(null); |
323,12 → 299,12 |
@Override |
public void run() { |
// laisse le temps au logiciel de demarrer |
ClasseCompte.loadClasseCompte(comptaConf); |
try { |
Thread.sleep(1000); |
} catch (InterruptedException e) { |
e.printStackTrace(); |
} |
ClasseCompte.loadClasseCompte(); |
CaisseCotisationSQLElement.getCaisseCotisation(); |
SQLPreferences prefs = SQLPreferences.getMemCached(comptaConf.getRootSociete()); |
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CmdEltFactEltSQLInjector.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/BrEltFactEltSQLInjector.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLTableImage.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLElement.java |
---|
212,7 → 212,4 |
return (k == null) ? false : k.equalsIgnoreCase("true"); |
} |
public boolean isImage() { |
return this.elt.getAttributeValue("type").equalsIgnoreCase("image"); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/FormatedGlobalQtyTotalProvider.java |
---|
26,11 → 26,11 |
private final boolean shortName, alwaysShowOnZeroQty, pieceName; |
public static enum Type { |
private static enum Type { |
NORMAL, SHIPMENT |
} |
public final Type type; |
private final Type type; |
private FormatedGlobalQtyTotalProvider(Type t, boolean shortName) { |
this(t, shortName, false, false); |
46,7 → 46,7 |
public Object getValue(SpreadSheetCellValueContext context) { |
final SQLRowAccessor row = context.getRow(); |
final BigDecimal pv = row.getBigDecimal("PV_HT"); |
if (!this.alwaysShowOnZeroQty && pv.compareTo(BigDecimal.ZERO) == 0) { |
if (!alwaysShowOnZeroQty && pv.compareTo(BigDecimal.ZERO) == 0) { |
return null; |
} |
61,8 → 61,10 |
return String.valueOf(qte); |
} |
String result = ""; |
if (this.alwaysShowOnZeroQty || qte != 0) { |
if (qte > 0) { |
if (qte > 1) { |
result += qte + " x "; |
} |
final BigDecimal qteUV = row.getBigDecimal("QTE_UNITAIRE"); |
result += NumericFormat.getQtyDecimalFormat().format(qteUV); |
80,7 → 82,7 |
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit", new FormatedGlobalQtyTotalProvider(Type.NORMAL, false)); |
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.deliver.short", new FormatedGlobalQtyTotalProvider(Type.SHIPMENT, true)); |
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.deliver", new FormatedGlobalQtyTotalProvider(Type.SHIPMENT, false)); |
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.deliver.short.with.quantity", new FormatedGlobalQtyTotalProvider(Type.SHIPMENT, true, true, true)); |
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.alwaysnamed.short.with.quantity", new FormatedGlobalQtyTotalProvider(Type.NORMAL, true, true, true)); |
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.alwaysnamed.short", new FormatedGlobalQtyTotalProvider(Type.NORMAL, true, false, true)); |
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.alwaysnamed", new FormatedGlobalQtyTotalProvider(Type.NORMAL, false, false, true)); |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/ConditionsReglementDetailsProvider.java |
---|
44,15 → 44,15 |
if (ajours == 0 && njour == 0) { |
if (foreignRow.getBoolean("COMPTANT") != null && !foreignRow.getBoolean("COMPTANT")) { |
r += " Date de facture"; |
r = "Date de facture"; |
} else { |
r += " Comptant"; |
r = "Comptant"; |
} |
} else { |
if (ajours != 0) { |
r += " à " + ajours + ((ajours > 1) ? " jours" : " jour"); |
r = "à" + ajours + ((ajours > 1) ? " jours" : " jour"); |
} |
if (njour > 0 && njour < 31) { |
r += " le " + njour; |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/TotalCommandeClientProvider.java |
---|
24,7 → 24,7 |
public class TotalCommandeClientProvider implements SpreadSheetCellValueProvider { |
public enum TypeTotalCommandeClientProvider { |
HT, TTC, TVA; |
HT, TTC; |
}; |
private final TypeTotalCommandeClientProvider type; |
40,16 → 40,9 |
for (SQLRowAccessor sqlRowAccessor : rows) { |
if (!sqlRowAccessor.isForeignEmpty("ID_COMMANDE_CLIENT")) { |
SQLRowAccessor rowCmd = sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT"); |
if (this.type == TypeTotalCommandeClientProvider.HT) { |
total += rowCmd.getLong("T_HT"); |
} else if (this.type == TypeTotalCommandeClientProvider.TVA) { |
total += rowCmd.getLong("T_TVA"); |
} else if (this.type == TypeTotalCommandeClientProvider.TTC) { |
total += rowCmd.getLong("T_TTC"); |
total += (this.type == TypeTotalCommandeClientProvider.HT ? rowCmd.getLong("T_HT") : rowCmd.getLong("T_TTC")); |
} |
} |
} |
return new BigDecimal(total).movePointLeft(2); |
} |
56,7 → 49,6 |
public static void register() { |
SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.HT)); |
SpreadSheetCellValueProviderManager.put("sales.account.command.total.ttc", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TTC)); |
SpreadSheetCellValueProviderManager.put("sales.account.command.total.tva", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TVA)); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLTableField.java |
---|
43,9 → 43,6 |
private int idRef; |
private String style = ""; |
public OOXMLTableField(Element eltField, SQLRowAccessor row, SQLElement sqlElt, int id, int filterId, SQLRow rowLanguage, int idRef, OOXMLCache cache) { |
super(eltField, row, sqlElt, id, rowLanguage, cache); |
this.type = eltField.getAttributeValue("type"); |
250,9 → 247,4 |
return this.style; |
} |
public boolean isImage() { |
return this.type.equalsIgnoreCase("image"); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLCache.java |
---|
29,7 → 29,6 |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.utils.CompareUtils; |
import org.openconcerto.utils.ListMap; |
import org.openconcerto.utils.Tuple2; |
import org.openconcerto.utils.cc.ITransformer; |
import java.math.BigDecimal; |
40,30 → 39,16 |
import java.util.List; |
import java.util.Map; |
import org.jdom2.Element; |
public class OOXMLCache { |
private ITransformer<List<SQLRowAccessor>, List<SQLRowAccessor>> postProcess = null; |
private Map<SQLRowAccessor, Map<SQLTable, List<SQLRowAccessor>>> cacheReferent = new HashMap<SQLRowAccessor, Map<SQLTable, List<SQLRowAccessor>>>(); |
private Map<String, Map<Integer, SQLRowAccessor>> cacheForeign = new HashMap<String, Map<Integer, SQLRowAccessor>>(); |
private Map<Tuple2<String, SQLRowAccessor>, OOXMLTableImage> cacheImg = new HashMap<>(); |
public void setPostProcess(ITransformer<List<SQLRowAccessor>, List<SQLRowAccessor>> postProcess) { |
this.postProcess = postProcess; |
} |
public OOXMLTableImage getOOXMLTableImage(OOXMLElement x, Element e, SQLRowAccessor r) { |
Tuple2<String, SQLRowAccessor> key = Tuple2.create(e.getAttributeValue("fieldPathEDM"), r); |
if (this.cacheImg.containsKey(key)) { |
return this.cacheImg.get(key); |
} else { |
OOXMLTableImage img = new OOXMLTableImage(x, e, r); |
this.cacheImg.put(key, img); |
return img; |
} |
} |
protected SQLRowAccessor getForeignRow(SQLRowAccessor row, SQLField field) { |
Map<Integer, SQLRowAccessor> c = cacheForeign.get(field.getName()); |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/AbstractJOOReportsSheet.java |
---|
312,25 → 312,6 |
return new File(outputPDFDirectory, getFileName() + ".pdf"); |
} |
public void printDocument(PrinterJob job) { |
try { |
final File f = getDocumentFile(); |
if (!f.exists()) { |
generate(false, false, ""); |
} |
final Component doc = ComptaPropsConfiguration.getOOConnexion().loadDocument(f, true); |
doc.printDocument(job); |
doc.close(); |
} catch (Exception e) { |
ExceptionHandler.handle("Impossible d'imprimer le document OpenOffice", e); |
e.printStackTrace(); |
} |
} |
public void exportToPdf() { |
// Export vers PDF |
final File fileOutOO = getDocumentFile(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SheetUtils.java |
---|
154,18 → 154,9 |
PdfBoxGraphics2DFontTextDrawer fontTextDrawer = new PdfBoxGraphics2DFontTextDrawerDefaultFonts(); |
final File dir = new File("Fonts"); |
if (dir.exists()) { |
System.out.println("Using fonts dir : " + dir.getAbsolutePath()); |
for (File f : dir.listFiles()) { |
if (f.isFile() && f.getName().toLowerCase().endsWith(".ttf")) { |
System.out.println("Registering font : " + f.getAbsolutePath()); |
fontTextDrawer.registerFont(f); |
fontTextDrawer.registerFontFromDirectory(dir); |
} |
} |
} else { |
System.out.println("No custom fonts dir found : " + dir.getAbsolutePath()); |
} |
// Configure the renderer |
ODTRenderer renderer = new ODTRenderer(doc); |
renderer.setIgnoreMargins(false); |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/RelanceSheet.java |
---|
18,7 → 18,6 |
import org.openconcerto.erp.generationDoc.AbstractJOOReportsSheet; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowListRSH; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.users.UserManager; |
66,12 → 65,6 |
} |
// Infos societe |
map.put("SocieteType", rowSoc.getString("TYPE")); |
map.put("SocieteTel", rowSoc.getString("NUM_TEL")); |
map.put("SocieteFax", rowSoc.getString("NUM_FAX")); |
map.put("SocieteRCS", rowSoc.getString("RCS")); |
map.put("SocieteSiret", rowSoc.getString("NUM_SIRET")); |
map.put("SocieteAPE", rowSoc.getString("NUM_APE")); |
map.put("SocieteCapital", GestionDevise.currencyToString(rowSoc.getBigDecimal("CAPITAL"))); |
map.put("SocieteNom", rowSoc.getString("NOM")); |
map.put("SocieteAdresse", rowSocAdresse.getString("RUE")); |
map.put("SocieteCodePostal", rowSocAdresse.getString("CODE_POSTAL")); |
144,27 → 137,19 |
SQLSelect sel = new SQLSelect(); |
sel.addSelect(this.rowRelance.getTable().getKey()); |
sel.addSelect(this.rowRelance.getTable().getField("DATE")); |
sel.setWhere(new Where(this.rowRelance.getTable().getField("ID_SAISIE_VENTE_FACTURE"), "=", this.rowRelance.getInt("ID_SAISIE_VENTE_FACTURE"))); |
sel.addFieldOrder(this.rowRelance.getTable().getField("DATE")); |
@SuppressWarnings("unchecked") |
List<SQLRow> listResult = SQLRowListRSH.execute(sel); |
String oldDateRelance = ""; |
List<Map<String, Number>> listResult = Configuration.getInstance().getBase().getDataSource().execute(sel.asString()); |
if (listResult != null && listResult.size() > 0) { |
SQLRow rowOldRelance = listResult.get(0); |
Map<String, Number> o = listResult.get(0); |
Number n = o.get(this.rowRelance.getTable().getKey().getName()); |
SQLRow rowOldRelance = this.rowRelance.getTable().getRow(n.intValue()); |
Date dOldRelance = (Date) rowOldRelance.getObject("DATE"); |
map.put("DatePremiereRelance", dateFormat2.format(dOldRelance)); |
for (SQLRow rowOldR : listResult) { |
oldDateRelance += dateFormat2.format((Date) rowOldR.getObject("DATE")) + ", "; |
} |
} else { |
map.put("DatePremiereRelance", ""); |
} |
map.put("DateAncienneRelance", oldDateRelance); |
return map; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationXML.java |
---|
20,10 → 20,7 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.openoffice.LengthUnit; |
import org.openconcerto.openoffice.ODFrame; |
import org.openconcerto.openoffice.ODPackage; |
import org.openconcerto.openoffice.spreadsheet.BytesProducer.ByteArrayProducer; |
import org.openconcerto.openoffice.spreadsheet.MutableCell; |
import org.openconcerto.openoffice.spreadsheet.Sheet; |
import org.openconcerto.openoffice.spreadsheet.SpreadSheet; |
59,7 → 56,6 |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
import java.util.UUID; |
import javax.swing.JOptionPane; |
import javax.swing.SwingUtilities; |
704,28 → 700,10 |
value = null; |
styleOO = null; |
} |
int tmpCelluleAffect; |
if (tableField.isImage()) { |
OOXMLTableImage tableImage = this.rowRefCache.getOOXMLTableImage(tableField, e, rowElt); |
tmpCelluleAffect = 1; |
try { |
if (tableImage.getImgBytes() != null) { |
MutableCell cell = sheet.getCellAt(test ? "A1" : loc); |
if (!test) { |
final ODFrame<SpreadSheet> frame = cell.addFrame(tableImage.getX(), tableImage.getY(), tableImage.getWidth(), tableImage.getHeight(), LengthUnit.MM); |
frame.addImage(UUID.randomUUID() + ".png", new ByteArrayProducer(tableImage.getImgBytes(), false)); |
} |
tmpCelluleAffect = tableImage.getRowCount(); |
} |
} catch (Exception e1) { |
// TODO popup??? |
e1.printStackTrace(); |
} |
} else { |
tmpCelluleAffect = fill(test ? "A1" : loc, value, sheet, tableField.isTypeReplace(), null, styleOO, test, tableField.isMultilineAuto(), tableField.isKeepingEmptyLines()); |
} |
int tmpCelluleAffect = fill(test ? "A1" : loc, value, sheet, tableField.isTypeReplace(), null, styleOO, test, tableField.isMultilineAuto(), tableField.isKeepingEmptyLines()); |
// tmpCelluleAffect = Math.max(tmpCelluleAffect, |
// tableField.getLine()); |
if (tableField.getLine() != 1 && (!tableField.isLineOption() || (value != null && value.toString().trim().length() > 0))) { |
if (nbCellule >= tableField.getLine()) { |
tmpCelluleAffect = tmpCelluleAffect + nbCellule; |
817,27 → 795,11 |
if (result != null) { |
Object o = elt.getAttributeValue("sheet"); |
int sheet = (o == null) ? 0 : Integer.valueOf(o.toString().trim()); |
if (OOElt.isImage()) { |
OOXMLTableImage tableImage = new OOXMLTableImage(OOElt, elt, row); |
try { |
if (tableImage.getImgBytes() != null) { |
MutableCell cell = spreadSheet.getSheet(sheet).getCellAt(elt.getAttributeValue("location")); |
final ODFrame<SpreadSheet> frame = cell.addFrame(tableImage.getX(), tableImage.getY(), tableImage.getWidth(), tableImage.getHeight(), LengthUnit.MM); |
frame.addImage(UUID.randomUUID() + ".png", new ByteArrayProducer(tableImage.getImgBytes(), false)); |
} |
} catch (Exception e1) { |
// TODO popup??? |
e1.printStackTrace(); |
} |
} else { |
fill(elt.getAttributeValue("location"), result, spreadSheet.getSheet(sheet), OOElt.isTypeReplace(), OOElt.getReplacePattern(), null, false, OOElt.isMultilineAuto(), |
OOElt.isKeepingEmptyLines()); |
} |
} |
} |
} |
private static boolean isIncluded(int filterID, String foreignTable, int id, String fieldWhere, SQLRowAccessor rowElt) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementVenteNG.java |
---|
22,9 → 22,6 |
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement; |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement; |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement; |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProvider; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProviderManager; |
import org.openconcerto.erp.model.PrixTTC; |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel; |
import org.openconcerto.sql.Configuration; |
55,8 → 52,6 |
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE"); |
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2); |
public static final String ID = "accounting.records.invoice.sales.payment"; |
public SQLRow ecrClient = null; |
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource) throws SQLException { |
86,10 → 81,6 |
// TODO Nommage des ecritures |
this.nom = label; |
AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(ID); |
if (provider != null) { |
provider.putLabel(source, this.mEcritures); |
} |
this.putValue("DATE", this.date); |
this.putValue("NOM", this.nom); |
245,31 → 236,6 |
this.putValue("CREDIT", Long.valueOf(0)); |
ajoutEcriture(); |
// FIXME remove getConf |
SQLRow rowSoc = ComptaPropsConfiguration.getInstanceCompta().getRowSociete(); |
if (rowSoc.getTable().contains("TVA_ENCAISSEMENT") && rowSoc.getBoolean("TVA_ENCAISSEMENT")) { |
SQLRow rowTaxe = TaxeCache.getCache().getFirstTaxe(); |
if (rowTaxe.contains("ID_COMPTE_PCE_COLLECTE_ENCAISSEMENT")) { |
SQLRowAccessor rowCompteTvaEnc = rowTaxe.getNonEmptyForeign("ID_COMPTE_PCE_COLLECTE_ENCAISSEMENT"); |
SQLRowAccessor rowCompteTvaCol = rowTaxe.getNonEmptyForeign("ID_COMPTE_PCE_COLLECTE"); |
if (rowCompteTvaCol != null && rowCompteTvaEnc != null) { |
Float taux = rowTaxe.getFloat("TAUX"); |
long tva = ttc.calculLongTVA(taux / 100.0); |
this.putValue("ID_COMPTE_PCE", rowCompteTvaCol.getID()); |
this.putValue("DEBIT", Long.valueOf(tva)); |
this.putValue("CREDIT", Long.valueOf(0)); |
ajoutEcriture(); |
this.putValue("ID_COMPTE_PCE", rowCompteTvaEnc.getID()); |
this.putValue("DEBIT", Long.valueOf(0)); |
this.putValue("CREDIT", Long.valueOf(tva)); |
ajoutEcriture(); |
} |
} |
} |
List<Integer> pieceIDs = new ArrayList<Integer>(); |
if (source.getTable().getName().equals("ENCAISSER_MONTANT")) { |
List<SQLRow> l = source.getReferentRows(base.getTable("ENCAISSER_MONTANT_ELEMENT")); |
333,13 → 299,9 |
SQLRowValues rowVals = new SQLRowValues(tableMouvement); |
rowVals.put("IDSOURCE", row.getID()); |
rowVals.update(this.idMvt); |
if (source.getTable().getName().equalsIgnoreCase("ENCAISSER_MONTANT")) { |
source.createEmptyUpdateRow().put("ID_MOUVEMENT", this.idMvt).commit(); |
} |
} |
} |
private void setDateReglement(SQLRow source, Date d) throws SQLException { |
List<SQLRow> sources = new ArrayList<SQLRow>(); |
498,5 → 460,4 |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieKm.java |
---|
14,8 → 14,6 |
package org.openconcerto.erp.generationEcritures; |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProvider; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProviderManager; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowValues; |
30,8 → 28,6 |
private int idSaisieKm; |
private static final String source = "SAISIE_KM"; |
public static final String ID = "accounting.records.km"; |
public GenerationMvtSaisieKm(int idSaisieKm) { |
this.idSaisieKm = idSaisieKm; |
} |
51,15 → 47,8 |
this.putValue("ID_MOUVEMENT", new Integer(1)); |
// on calcule le nouveau numero de mouvement |
AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(ID); |
SQLRowValues rowValsPiece = new SQLRowValues(pieceTable); |
rowValsPiece.put("NOM", (labelSaisie.length() == 0 ? "Saisie au km " : labelSaisie)); |
if (provider != null) { |
provider.putPieceLabel(saisieRow, rowValsPiece); |
} |
getNewMouvement(GenerationMvtSaisieKm.source, this.idSaisieKm, 1, (labelSaisie.length() == 0 ? "Saisie au km " : labelSaisie)); |
getNewMouvement(GenerationMvtSaisieKm.source, this.idSaisieKm, 1, rowValsPiece); |
// gnération des ecritures |
SQLTable tableElt = Configuration.getInstance().getRoot().findTable("SAISIE_KM_ELEMENT"); |
List<SQLRow> set = saisieRow.getReferentRows(tableElt); |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtReglementChequeClient.java |
---|
13,10 → 13,9 |
package org.openconcerto.erp.generationEcritures; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement; |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLRow; |
111,31 → 110,6 |
this.putValue("CREDIT", new Long(0)); |
ajoutEcriture(); |
// FIXME remove getConf |
SQLRow rowSoc = ComptaPropsConfiguration.getInstanceCompta().getRowSociete(); |
if (rowSoc.getTable().contains("TVA_ENCAISSEMENT") && rowSoc.getBoolean("TVA_ENCAISSEMENT")) { |
SQLRow rowTaxe = TaxeCache.getCache().getFirstTaxe(); |
if (rowTaxe.contains("ID_COMPTE_PCE_COLLECTE_ENCAISSEMENT")) { |
SQLRowAccessor rowCompteTvaEnc = rowTaxe.getNonEmptyForeign("ID_COMPTE_PCE_COLLECTE_ENCAISSEMENT"); |
SQLRowAccessor rowCompteTvaCol = rowTaxe.getNonEmptyForeign("ID_COMPTE_PCE_COLLECTE"); |
if (rowCompteTvaCol != null && rowCompteTvaEnc != null) { |
Float taux = rowTaxe.getFloat("TAUX"); |
long ht = Math.round(montant / (1.0 + (taux / 100.0))); |
long tva = montant - ht; |
this.putValue("ID_COMPTE_PCE", rowCompteTvaCol.getID()); |
this.putValue("DEBIT", Long.valueOf(tva)); |
this.putValue("CREDIT", Long.valueOf(0)); |
ajoutEcriture(); |
this.putValue("ID_COMPTE_PCE", rowCompteTvaEnc.getID()); |
this.putValue("DEBIT", Long.valueOf(0)); |
this.putValue("CREDIT", Long.valueOf(tva)); |
ajoutEcriture(); |
} |
} |
} |
List<Integer> pieceIDs = new ArrayList<Integer>(); |
pieceIDs.add(mouvementTable.getRow(idMvt).getForeignID("ID_PIECE")); |
lettrageAuto(pieceIDs, this.date); |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirFournisseur.java |
---|
109,14 → 109,12 |
if (rowFourn.getBoolean("UE")) { |
idCompteTVA = taxe.getForeignID("ID_COMPTE_PCE_DED_INTRA"); |
if (idCompteTVA <= 1) { |
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_ACHAT"); |
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA"); |
if (idCompteTVA <= 1) { |
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVADeductible"); |
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm"); |
} |
} |
} else { |
idCompteTVA = taxe.getForeignID("ID_COMPTE_PCE_DED"); |
if (idCompteTVA <= 1) { |
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_ACHAT"); |
if (idCompteTVA <= 1) { |
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVADeductible"); |
123,7 → 121,6 |
} |
} |
} |
} |
this.putValue("ID_COMPTE_PCE", Integer.valueOf(idCompteTVA)); |
this.putValue("DEBIT", Long.valueOf(0)); |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementAchat.java |
---|
17,8 → 17,6 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement; |
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProvider; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProviderManager; |
import org.openconcerto.erp.model.PrixTTC; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowValues; |
37,10 → 35,6 |
public class GenerationReglementAchat extends GenerationEcritures { |
public static final String ID = "accounting.records.order.supplychain.payment"; |
// Journal Caisse |
private static final Integer journalCaisse = new Integer(JournalSQLElement.CAISSES); |
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE"); |
67,10 → 61,6 |
// "Règlement achat" + SOURCE.getNom() ?? |
this.nom = "Règlement achat " + rowFournisseur.getString("NOM") + " (" + typeRegRow.getString("NOM") + ")"; |
AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(ID); |
if (provider != null) { |
provider.putLabel(regMontantRow, this.mEcritures); |
} |
List<SQLRow> l = regMontantRow.getReferentRows(regMontantRow.getTable().getTable("REGLER_MONTANT_ELEMENT")); |
int mvtSource = -1; |
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtFactureFournisseur.java |
---|
16,8 → 16,6 |
import org.openconcerto.erp.core.common.ui.TotalCalculator; |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement; |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProvider; |
import org.openconcerto.erp.generationEcritures.provider.AccountingRecordsProviderManager; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
31,7 → 29,7 |
public class GenerationMvtFactureFournisseur extends GenerationEcritures implements Runnable { |
public static final String ID = "accounting.records.supplychain.order"; |
public static final String ID = "accounting.records.supply.order"; |
private int idFacture; |
private static final String source = "FACTURE_FOURNISSEUR"; |
67,11 → 65,6 |
// AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(ID); |
// provider.putLabel(saisieRow, this.mEcritures); |
this.putValue("NOM", nom); |
AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(ID); |
if (provider != null) { |
provider.putLabel(saisieRow, this.mEcritures); |
} |
this.putValue("ID_JOURNAL", GenerationMvtFactureFournisseur.journal); |
this.putValue("ID_MOUVEMENT", new Integer(1)); |
78,17 → 71,13 |
// on calcule le nouveau numero de mouvement |
if (this.idMvt == 1) { |
SQLRowValues rowValsPiece = new SQLRowValues(pieceTable); |
// provider.putPieceLabel(saisieRow, rowValsPiece); |
rowValsPiece.put("NOM", saisieRow.getObject("NUMERO").toString()); |
if (provider != null) { |
provider.putPieceLabel(saisieRow, rowValsPiece); |
} |
getNewMouvement(GenerationMvtFactureFournisseur.source, this.idFacture, 1, rowValsPiece); |
} else { |
SQLRowValues rowValsPiece = pieceTable.getTable("MOUVEMENT").getRow(idMvt).getForeign("ID_PIECE").asRowValues(); |
// provider.putPieceLabel(saisieRow, rowValsPiece); |
rowValsPiece.put("NOM", saisieRow.getObject("NUMERO").toString()); |
if (provider != null) { |
provider.putPieceLabel(saisieRow, rowValsPiece); |
} |
rowValsPiece.update(); |
this.putValue("ID_MOUVEMENT", new Integer(this.idMvt)); |
/trunk/OpenConcerto/src/org/openconcerto/ql/QLPrinter.java |
---|
23,12 → 23,10 |
import java.net.InetAddress; |
import java.net.Socket; |
import java.net.UnknownHostException; |
import java.nio.charset.StandardCharsets; |
import javax.imageio.ImageIO; |
public class QLPrinter { |
private static final int ESC = 0x1B; |
private String host; |
private boolean highQuality; |
private boolean paperCutAuto; |
51,7 → 49,7 |
/** |
* Set print width (in milimeters) |
*/ |
* */ |
public void setPrintWidth(int mm) { |
this.printWidth = mm; |
} |
79,18 → 77,16 |
for (int i = 0; i < 200; i++) { |
out.write(0x00); |
} |
// Select ESCP/P Mode : 0x1B 0x69 0x61 0x01 |
out.write(ESC); |
// Init 0x1B 0x40 |
out.write(0x1B); |
out.write(0x40); |
// ?? : 0x1B 0x69 0x61 0x01 |
out.write(0x1B); |
out.write(0x69); |
out.write(0x61); |
out.write(0x01); |
// Init 0x1B 0x40 |
out.write(ESC); |
out.write(0x40); |
// Page Length |
out.write(ESC); |
out.write(0x1B); |
out.write(0x69); |
out.write(0x7A); |
105,8 → 101,8 |
out.write(0); |
out.write(0); |
out.write(0); |
// Paper Cut : ESC i |
out.write(ESC); |
// Paper Cut |
out.write(0x1B); |
out.write(0x69); |
out.write(0x4D); |
if (this.paperCutAuto) { |
115,13 → 111,13 |
out.write(0x00); |
} |
// ?? : 0x1B 0x69 0x41 0x01 :ESC i A |
out.write(ESC); |
// ?? : 0x1B 0x69 0x41 0x01 |
out.write(0x1B); |
out.write(0x69); |
out.write(0x41); |
out.write(0x01); |
// Set Mode : ESC i K |
out.write(ESC); |
// Set Mode |
out.write(0x1B); |
out.write(0x69); |
out.write(0x4B); |
if (!this.highQuality) { |
130,7 → 126,7 |
out.write(0x48); |
} |
// Set Margin |
out.write(ESC); |
out.write(0x1B); |
out.write(0x69); |
out.write(0x64); |
out.write(0x00); |
336,7 → 332,6 |
out.close(); |
in.close(); |
socket.close(); |
System.out.println("QLPrinter.print() done"); |
} |
} |
351,92 → 346,4 |
return cfA; |
} |
/** |
* Print 2D barcode (DataMatrix) |
* |
* @param dotsPerCell (3 - 10) |
* @param barcode : barcode (ascii) |
* @throws IOException |
* |
*/ |
public void printDataMatrixBarCode2D(int dotsPerCell, String barcode) throws IOException { |
if (barcode.length() > (144 * 144)) { |
throw new IllegalArgumentException("barcode too long (max : 144x144:20736)"); |
} |
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
{ |
// Header: 0x00 : 200 fois |
for (int i = 0; i < 200; i++) { |
out.write(0x00); |
} |
} |
// Select ESCP/P Mode : 0x1B 0x69 0x61 0x00 |
out.write(ESC); |
out.write(0x69); |
out.write(0x61); |
out.write(0x00); // mode ESC/P standard |
// Init 0x1B 0x40 |
out.write(ESC); |
out.write(0x40); |
// ESC i D |
out.write(ESC); |
out.write(0x69); |
out.write(0x44); |
// |
out.write(dotsPerCell); |
out.write(0); // square |
out.write(0); // vertical size : auto |
out.write(0); // horizontal size : auto |
for (int i = 0; i < 5; i++) { |
out.write(0); // reserved |
} |
// data |
out.write(barcode.getBytes(StandardCharsets.US_ASCII)); |
out.write('\\'); |
out.write('\\'); |
out.write('\\'); |
// Page feed |
out.write(0x0C); |
out.flush(); |
final byte[] byteArray = out.toByteArray(); |
print(byteArray); |
} |
public void print(String string) throws IOException { |
ByteArrayOutputStream bOut = new ByteArrayOutputStream(); |
// Select ESCP/P Mode : 0x1B 0x69 0x61 0x00 |
bOut.write(ESC); |
bOut.write(0x69); |
bOut.write(0x61); |
bOut.write(0x0); // mode ESC/P standard |
// Init 0x1B 0x40 |
bOut.write(ESC); |
bOut.write(0x40); |
// Init |
bOut.write(ESC); |
bOut.write(0x40); |
// French characters |
bOut.write(ESC); |
bOut.write(0x52); |
bOut.write(0x01); |
// Normal |
bOut.write(ESC); |
bOut.write(0x21); |
bOut.write(0);// Default |
bOut.write(string.getBytes(StandardCharsets.US_ASCII)); |
bOut.write(0x0A);// Retour a la ligne |
// Page feed |
bOut.write(0x0C); |
print(bOut.toByteArray()); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ql/QLPrinterExample.java |
---|
18,19 → 18,15 |
public class QLPrinterExample { |
public static void main(String[] args) { |
QLPrinter prt = new QLPrinter("192.168.168.53"); |
QLPrinter prt = new QLPrinter("192.168.1.103"); |
prt.setHighQuality(true); |
try { |
prt.print(new File("Hello_720x300.png")); |
String code = "123456789"; |
prt.printDataMatrixBarCode2D(10, code); |
prt.print("Hello"); |
} catch (IOException e) { |
e.printStackTrace(); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/generation/ReportGeneration.java |
---|
39,14 → 39,13 |
import java.util.Map.Entry; |
import java.util.Stack; |
import java.util.concurrent.Callable; |
import java.util.concurrent.ExecutionException; |
import java.util.concurrent.FutureTask; |
import java.util.concurrent.TimeoutException; |
import org.jdom.Element; |
import org.jdom.JDOMException; |
import org.jdom.filter.Filter; |
import net.jcip.annotations.GuardedBy; |
import ognl.Ognl; |
import ognl.OgnlException; |
import ognl.OgnlRuntime; |
88,11 → 87,9 |
// Inheritable to allow generators to spawn threads |
private final InheritableThreadLocal<ReportPart> currentParts; |
private final InheritableThreadLocal<DocumentGenerator> currentGenerator; |
@GuardedBy("this") |
private Throwable interruptCause; |
// tous les générateurs s'exécuter dans ce groupe |
@GuardedBy("this") |
private List<Thread> thg; |
private final ThreadGroup thg; |
private final List<PropertyChangeListener> taskListeners; |
private final PropertyChangeListener taskListener; |
private Map<String, Object> commonData; |
112,7 → 109,11 |
this.currentParts = new InheritableThreadLocal<ReportPart>(); |
this.currentGenerator = new InheritableThreadLocal<DocumentGenerator>(); |
this.interruptCause = null; |
this.thg = null; |
this.thg = new ThreadGroup("Generateurs") { |
public void uncaughtException(Thread t, Throwable e) { |
ReportGeneration.this.interrupt(e); |
} |
}; |
this.taskListeners = new ArrayList<PropertyChangeListener>(); |
this.taskListener = new PropertyChangeListener() { |
197,7 → 198,6 |
public final Map<String, ODSingleXMLDocument> generateMulti() throws Throwable { |
synchronized (this) { |
this.interruptCause = null; |
this.thg = new ArrayList<>(); |
} |
Map<String, ODSingleXMLDocument> f = null; |
206,34 → 206,17 |
return createDocument(); |
} |
}); |
// Don't pass a ThreadGroup, since every thread created, including "cache timeout", JDBC |
// threads will be in it. But these threads must out-live this generation. |
final Thread thr = new Thread(null, future); |
this.registerThread(thr); |
final Thread thr = new Thread(this.thg, future); |
thr.start(); |
try { |
thr.join(); |
f = future.get(); |
} catch (Exception e) { |
assert f == null; |
// If one thread was interrupted (or failed), interrupt the others |
if (isInterruptedExn(e) || (e instanceof ExecutionException && isInterruptedExn(e.getCause()))) |
f = null; |
else |
this.interrupt(e); |
} finally { |
// Make sure all threads are stopped and don't prevent this from being garbage |
// collected. |
final List<Thread> toJoin; |
synchronized (this) { |
toJoin = this.thg; |
this.thg = null; |
} |
for (final Thread t : toJoin) { |
// If no exception occurred, then should already be finished but if there was one in |
// a thread, another thread might be stuck on some I/O for a while before it can |
// process the interrupt. |
t.join(4500); |
if (t.isAlive()) |
throw new TimeoutException("Thread still not terminated : " + t); |
} |
} |
final Map<String, ODSingleXMLDocument> res; |
synchronized (this) { |
253,20 → 236,14 |
return res; |
} |
public final synchronized void registerThread(final Thread thr) { |
this.thg.add(thr); |
} |
protected final void interrupt(Throwable cause) { |
synchronized (this) { |
if (this.interruptCause == null) { |
this.interruptCause = cause; |
for (final Thread thr : this.thg) { |
thr.interrupt(); |
this.thg.interrupt(); |
} |
} |
} |
} |
private Map<String, ODSingleXMLDocument> createDocument() throws IOException, OgnlException, InterruptedException { |
// recompute common data for each run |
299,7 → 276,6 |
if (part instanceof ForkReportPart) { |
GenThread thread = new GenThread(part.getName(), ((ForkReportPart) part).getChildren()); |
forked.put(part.getName(), thread); |
this.registerThread(thread); |
thread.start(); |
} else if (part instanceof SubReportPart) { |
final SubReportPart subReportPart = (SubReportPart) part; |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/generation/view/BaseGenerationRapport.java |
---|
59,12 → 59,9 |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.SwingUtilities; |
import javax.swing.SwingWorker; |
import org.jdom.JDOMException; |
import net.jcip.annotations.GuardedBy; |
/** |
* A panel to choose a ReportType, see the tasks of the generation, and optionnaly open the |
* document. NOTE: you have to call {@link #enableGeneration(boolean)} before being able to |
98,11 → 95,11 |
private JList<GenerationTask> tasksView; |
private final JLabel status; |
@GuardedBy("EDT") |
private SwingWorker<Void, Void> generationWorker; |
// le groupe dans lequel doivent être toutes les thread de la génération |
private final ThreadGroup thg; |
public BaseGenerationRapport() throws JDOMException, IOException { |
this.generationWorker = null; |
this.thg = new ThreadGroup(this + " thread group"); |
this.status = new JLabel(); |
this.setStatus("Inactif"); |
} |
237,8 → 234,7 |
*/ |
public final void interrupt() { |
// pas de threads active, quand pas génération |
if (this.generationWorker != null) |
this.generationWorker.cancel(true); |
this.thg.interrupt(); |
} |
class GenerateAction implements ActionListener { |
250,22 → 246,21 |
enableGeneration(false); |
final FileAction sel = (FileAction) BaseGenerationRapport.this.fileActionCombo.getSelectedItem(); |
// "génération..." |
BaseGenerationRapport.this.generationWorker = new SwingWorker<Void, Void>() { |
new Thread(BaseGenerationRapport.this.thg, new Runnable() { |
@Override |
protected Void doInBackground() throws Exception { |
public void run() { |
generate(sel); |
return null; |
} |
// toujours le faire, même si interrompu |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
protected void done() { |
// toujours le faire, même si interrompu |
public void run() { |
enableGeneration(true); |
} |
}; |
BaseGenerationRapport.this.generationWorker.execute(); |
}); |
} |
}).start(); |
} |
} |
protected final void enableGeneration(final boolean b) { |
this.fileActionCombo.setEnabled(b); |
272,6 → 267,7 |
this.genererButton.setEnabled(b); |
} |
// doit s'exécuter dans this.thg |
protected final void generate(final FileAction sel) { |
final ReportType type = (ReportType) this.typeRapportComboSelection.getSelectedItem(); |
final R rg = this.createGeneration(type); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/ODFrame.java |
---|
13,7 → 13,6 |
package org.openconcerto.openoffice; |
import org.openconcerto.openoffice.spreadsheet.BytesProducer; |
import org.openconcerto.openoffice.text.TextNode; |
import java.math.BigDecimal; |
29,20 → 28,6 |
*/ |
public class ODFrame<D extends ODDocument> extends ImmutableDocStyledNode<GraphicStyle, D> { |
static public Element createEmpty(XMLVersion ns, final Number w, final Number h, final LengthUnit unit) { |
return createEmpty(ns, BigDecimal.ZERO, BigDecimal.ZERO, w, h, unit); |
} |
static public Element createEmpty(XMLVersion ns, final Number x, final Number y, final Number w, final Number h, final LengthUnit unit) { |
final Namespace svgNS = ns.getNS("svg"); |
final Element res = new Element("frame", ns.getNS("draw")); |
res.setAttribute("x", unit.format(x), svgNS); |
res.setAttribute("y", unit.format(y), svgNS); |
res.setAttribute("width", unit.format(w), svgNS); |
res.setAttribute("height", unit.format(h), svgNS); |
return res; |
} |
/** |
* Parse SVG and OD length. |
* |
135,36 → 120,4 |
public final LengthUnit getUnit() { |
return LengthUnit.MM; |
} |
public final void addImage(final String name, final BytesProducer data) { |
final Element imageElem = new Element("image", getElement().getNamespace("draw")); |
this.getElement().addContent(imageElem); |
this.putImage(imageElem, name, data); |
} |
private final void putImage(final Element imageElem, final String name, final BytesProducer data) { |
final String imgPath = "Pictures/" + name + (data.getFormat() != null ? "." + data.getFormat() : ""); |
imageElem.setAttribute("href", imgPath, this.getODDocument().getVersion().getNS("xlink")); |
this.getODDocument().getPackage().putFile(imgPath, data.getBytes(this)); |
} |
public final void setImage(final String name, final BytesProducer data, final boolean allowAdd) { |
final Element imageElem = this.getElement().getChild("image", getElement().getNamespace("draw")); |
if (imageElem != null) { |
final String oldPath = imageElem.getAttributeValue("href", this.getODDocument().getVersion().getNS("xlink")); |
this.getODDocument().getPackage().putFile(oldPath, null); |
imageElem.removeChild("binary-data", this.getODDocument().getVersion().getOFFICE()); |
if (data == null) { |
imageElem.detach(); |
} else { |
this.putImage(imageElem, name, data); |
} |
} else if (data != null) { |
if (allowAdd) |
this.addImage(name, data); |
else |
throw new IllegalStateException("No image in " + this); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/ODEpoch.java |
---|
14,8 → 14,6 |
package org.openconcerto.openoffice; |
import org.openconcerto.utils.TimeUtils; |
import org.openconcerto.utils.cache.LRUMap; |
import org.openconcerto.utils.cc.CachedTransformer; |
import java.math.BigDecimal; |
import java.math.BigInteger; |
24,6 → 22,8 |
import java.text.ParseException; |
import java.text.SimpleDateFormat; |
import java.util.Calendar; |
import java.util.LinkedHashMap; |
import java.util.Map; |
import java.util.TimeZone; |
import javax.xml.datatype.DatatypeConstants; |
43,7 → 43,12 |
static private final DateFormat DATE_FORMAT; |
static private final ODEpoch DEFAULT_EPOCH; |
@GuardedBy("cache") |
static private final CachedTransformer<String, ODEpoch, ParseException> cache = new CachedTransformer<>(new LRUMap<>(16, 4), ODEpoch::new); |
static private final Map<String, ODEpoch> cache = new LinkedHashMap<String, ODEpoch>(4, 0.75f, true) { |
@Override |
protected boolean removeEldestEntry(Map.Entry<String, ODEpoch> eldest) { |
return this.size() > 16; |
} |
}; |
static { |
DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); |
65,19 → 70,16 |
return DEFAULT_EPOCH; |
} else { |
synchronized (cache) { |
return cache.transformChecked(date); |
ODEpoch res = cache.get(date); |
if (res == null) { |
res = new ODEpoch(date); |
cache.put(date, res); |
} |
return res; |
} |
} |
public static final BigDecimal getDays(final java.time.Duration d) { |
return getDays(d.toMillis()); |
} |
public static final BigDecimal getDays(final long millis) { |
return BigDecimal.valueOf(millis).divide(MS_PER_DAY, MathContext.DECIMAL128); |
} |
static private final Calendar parse(final String date) throws ParseException { |
synchronized (DATE_FORMAT) { |
final Calendar cal = (Calendar) DATE_FORMAT.getCalendar().clone(); |
137,7 → 139,7 |
// can't use Duration.normalizeWith() since it doesn't handle DST, i.e. going from winter to |
// summer at midnight will miss a day |
final long diff = TimeUtils.normalizeLocalTime(cal) - this.epochUTC.getTimeInMillis(); |
return getDays(diff); |
return BigDecimal.valueOf(diff).divide(MS_PER_DAY, MathContext.DECIMAL128); |
} |
public final Calendar getDate(final BigDecimal days) { |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/spreadsheet/CellStyle.java |
---|
132,11 → 132,10 |
super(pkg, tableColElem); |
} |
final DataStyle getDataStyle(final Attribute name) { |
private final DataStyle getDataStyle(final Attribute name) { |
return (DataStyle) Style.getReferencedStyle(getPackage(), name); |
} |
// see MutableCell#getDataStyle() |
final DataStyle getDataStyle() { |
return getDataStyle(this.getElement().getAttribute("data-style-name", this.getSTYLE())); |
} |
161,13 → 160,13 |
} |
} |
final List<Element> styleMaps = res.getMapChildren(); |
final List<?> styleMaps = res.getElement().getChildren("map", getSTYLE()); |
if (styleMaps.size() > 0) { |
final Object converted = convertForCondition(returnCellValue, res); |
// we can't compare() so don't try |
if (converted != null) { |
for (Element child : styleMaps) { |
final Element styleMap = child; |
for (Object child : styleMaps) { |
final Element styleMap = (Element) child; |
final Matcher matcher = conditionPatrn.matcher(styleMap.getAttributeValue("condition", getSTYLE()).trim()); |
if (!matcher.matches()) |
throw new IllegalStateException("Cannot parse " + JDOMUtils.output(styleMap)); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/spreadsheet/Lines.java |
---|
97,7 → 97,7 |
public Lines(final ODDocument doc, final String text) { |
super(); |
this.doc = doc; |
this.xml = doc.getFormatVersion().getXML(); |
this.xml = OOXML.get(doc.getFormatVersion(), false); |
this.lines = new LinkedList<String>(); |
this.separators = new LinkedList<Sep>(); |
this.parse(text, isCalc()); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/spreadsheet/MutableCell.java |
---|
13,14 → 13,9 |
package org.openconcerto.openoffice.spreadsheet; |
import static org.openconcerto.utils.TimeUtils.SECONDS_PER_HOUR; |
import static org.openconcerto.utils.TimeUtils.SECONDS_PER_MINUTE; |
import org.openconcerto.openoffice.LengthUnit; |
import org.openconcerto.openoffice.Log; |
import org.openconcerto.openoffice.ODDocument; |
import org.openconcerto.openoffice.ODFrame; |
import org.openconcerto.openoffice.ODPackage; |
import org.openconcerto.openoffice.ODValueType; |
import org.openconcerto.openoffice.StyleDesc; |
import org.openconcerto.openoffice.XMLVersion; |
34,8 → 29,6 |
import org.openconcerto.utils.TimeUtils.DurationNullsChanger; |
import org.openconcerto.utils.Tuple2; |
import org.openconcerto.utils.Tuple3; |
import org.openconcerto.utils.cache.LRUMap; |
import org.openconcerto.utils.cc.CachedTransformer; |
import java.awt.Color; |
import java.awt.Image; |
42,10 → 35,8 |
import java.awt.Point; |
import java.io.File; |
import java.io.IOException; |
import java.math.BigDecimal; |
import java.text.DateFormat; |
import java.text.DecimalFormat; |
import java.text.DecimalFormatSymbols; |
import java.text.NumberFormat; |
import java.util.Calendar; |
import java.util.Date; |
68,40 → 59,10 |
*/ |
public class MutableCell<D extends ODDocument> extends Cell<D> { |
static private final CachedTransformer<Locale, DateFormat, RuntimeException> TextPDateFormat = new CachedTransformer<>(new LRUMap<>(20), (l) -> DateFormat.getDateInstance(DateFormat.DEFAULT, l), |
false); |
static private final CachedTransformer<Locale, DateFormat, RuntimeException> TextPTimeFormat = new CachedTransformer<>(new LRUMap<>(20), (l) -> DateFormat.getTimeInstance(DateFormat.DEFAULT, l), |
false); |
static private final CachedTransformer<Locale, NumberFormat, RuntimeException> TextPMinuteSecondFormat = new CachedTransformer<>(new LRUMap<>(20), |
(l) -> new DecimalFormat("00.###", DecimalFormatSymbols.getInstance(l)), false); |
static private final char TEXTP_SEP = ':'; |
static private final DateFormat TextPDateFormat = DateFormat.getDateInstance(); |
static private final DateFormat TextPTimeFormat = DateFormat.getTimeInstance(); |
static private final NumberFormat TextPMinuteSecondFormat = new DecimalFormat("00.###"); |
// HH:mm:ss.SSS |
static String textPDuration(final long hours, final int minutes, final BigDecimal secsAndNanos, final Locale locale) { |
final StringBuilder res = new StringBuilder(16); |
res.append(hours); |
res.append(TEXTP_SEP); |
res.append(TextPMinuteSecondFormat.get(locale).format(minutes)); |
res.append(TEXTP_SEP); |
res.append(TextPMinuteSecondFormat.get(locale).format(secsAndNanos)); |
return res.toString(); |
} |
static String textPDuration(final java.time.Duration d, final Locale locale) { |
// -1H is treated as 23:00 in LO |
if (d.isNegative()) |
throw new UnsupportedOperationException("Negative duration"); |
final long seconds = d.getSeconds(); |
// from Duration.toString() |
final long hours = seconds / SECONDS_PER_HOUR; |
final int minutes = (int) ((seconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE); |
final int secs = (int) (seconds % SECONDS_PER_MINUTE); |
final BigDecimal secsAndNanos = BigDecimal.valueOf(secs).add(BigDecimal.valueOf(d.getNano()).movePointLeft(9)); |
return textPDuration(hours, minutes, secsAndNanos, locale); |
} |
static private boolean LO_MODE = true; |
// no date part, all time part to zero |
static private final DurationNullsChanger TIME_NULLS = new TimeUtils.DurationNullsBuilder(TimeUtils.EmptyFieldPolicy.SET_TO_ZERO).setToNull(TimeUtils.getDateFields()).build(); |
178,8 → 139,8 |
// Like LO, do not generate string-value |
if (type != null && type != ODValueType.STRING) { |
// LO cells don't support the full syntax of a duration (user meta fields do) |
// instead it support only values without nYnMnD (as does java.time.Duration) |
if (type == ODValueType.TIME && getTimeValueMode() && !(val instanceof java.time.Duration)) { |
// instead it support only values without nYnMnD |
if (type == ODValueType.TIME && getTimeValueMode()) { |
final Duration d = val instanceof Duration ? (Duration) val : TimeUtils.timePartToDuration((Calendar) val); |
val = TIME_NULLS.apply(getODDocument().getEpoch().normalizeToHours(d)); |
} |
253,15 → 214,13 |
if (formatted.get0() != null) { |
text = formatted.get0(); |
} else { |
// either there were no format, formatting failed or wasn't attempted because the data |
// style cannot format vt |
// either there were no format or formatting failed |
if (vt == ODValueType.FLOAT) { |
text = ODPackage.formatNumber((Number) obj, getDataLocale(), getDefaultStyle()); |
text = getODDocument().getPackage().formatNumber((Number) obj, getDefaultStyle()); |
} else if (vt == ODValueType.PERCENTAGE) { |
text = ODPackage.formatPercent((Number) obj, getDataLocale(), getDefaultStyle()); |
text = getODDocument().getPackage().formatPercent((Number) obj, getDefaultStyle()); |
} else if (vt == ODValueType.CURRENCY) { |
text = ODPackage.formatCurrency((Number) obj, getDataLocale(), getDefaultStyle()); |
text = getODDocument().getPackage().formatCurrency((Number) obj, getDefaultStyle()); |
} else if (vt == ODValueType.DATE) { |
final Date d; |
if (obj instanceof Calendar) { |
269,18 → 228,25 |
} else { |
d = (Date) obj; |
} |
text = TextPDateFormat.get(getDataLocale()).format(d); |
text = TextPDateFormat.format(d); |
} else if (vt == ODValueType.TIME) { |
if (obj instanceof Duration) { |
final Duration normalized = getODDocument().getEpoch().normalizeToHours((Duration) obj); |
text = textPDuration(normalized.getHours(), normalized.getMinutes(), TimeUtils.getSeconds(normalized), getDataLocale()); |
} else if (obj instanceof java.time.Duration) { |
text = textPDuration((java.time.Duration) obj, getDataLocale()); |
text = "" + normalized.getHours() + ':' + TextPMinuteSecondFormat.format(normalized.getMinutes()) + ':' + TextPMinuteSecondFormat.format(TimeUtils.getSeconds(normalized)); |
} else { |
text = TextPTimeFormat.get(getDataLocale()).format(((Calendar) obj).getTime()); |
text = TextPTimeFormat.format(((Calendar) obj).getTime()); |
} |
} else if (vt == ODValueType.BOOLEAN) { |
text = BooleanStyle.toString((Boolean) obj, getDataLocale(), lenient); |
Locale l = null; |
final CellStyle s = getStyle(); |
if (s != null) { |
final DataStyle ds = s.getDataStyle(); |
if (ds != null) |
l = ds.getLocale(); |
} |
if (l == null) |
l = getODDocument().getPackage().getLocale(); |
text = BooleanStyle.toString((Boolean) obj, l, lenient); |
} else if (vt == ODValueType.STRING) { |
text = obj.toString(); |
} else { |
290,54 → 256,6 |
this.setValue(vt, obj, text); |
} |
/** |
* The locale of the data style. NOTE this doesn't evaluate the map elements with the current |
* cell value. |
* |
* @return the locale of the data style, or if none, the ODPackage locale. |
*/ |
public final Locale getDataLocale() { |
return this.getDataLocale(false); |
} |
public final Locale getDataLocale(final boolean local) { |
Locale res = null; |
final CellStyle s = getStyle(); |
if (s != null) { |
final DataStyle ds = s.getDataStyle(); |
if (ds != null) |
res = ds.getLocale(local); |
} |
if (local || res != null) |
return res; |
return getODDocument().getPackage().getLocale(); |
} |
/** |
* Set the locale for the data style. This is different from the locale of the |
* {@link CellStyle#getTextProperties() text properties}. Like LibreOffice, this set the |
* attributes of the main {@link DataStyle}, and all {@link #getDataStyle() mapped} ones. |
* |
* @param locale the new locale, <code>null</code> to remove attributes. |
* @throws IllegalStateException if there's no {@link DataStyle}. |
*/ |
public final void setDataLocale(final Locale locale) throws IllegalStateException { |
final CellStyle s = getStyle(); |
if (s != null) { |
final DataStyle ds = s.getDataStyle(); |
if (ds != null) { |
ds.setLocale(locale); |
// LO does this, and this avoids the need for mapped styles to have a reference to |
// their parent. |
for (final Element mapElem : ds.getMapChildren()) { |
s.getDataStyle(mapElem.getAttribute("apply-style-name", mapElem.getNamespace())).setLocale(locale); |
} |
return; |
} |
} |
throw new IllegalStateException("No data style for " + this); |
} |
// return null String if no data style exists, or if one exists but we couldn't use it |
private Tuple3<String, ODValueType, Object> format(Object obj, ODValueType valueType, boolean onlyCast, boolean lenient) { |
String res = null; |
534,12 → 452,6 |
return this.getRow().getSheet().getTableCellPropertiesAt(this.getX(), this.getY()); |
} |
public final ODFrame<D> addFrame(final Number x, final Number y, final Number w, final Number h, final LengthUnit unit) { |
final Element elem = ODFrame.createEmpty(getNS(), x, y, w, h, unit); |
this.getElement().addContent(elem); |
return new ODFrame<>(getODDocument(), elem); |
} |
public void setImage(final File pic) throws IOException { |
this.setImage(pic, false); |
} |
555,11 → 467,20 |
private void setImage(final String name, final BytesProducer data) { |
final Namespace draw = this.getNS().getNS("draw"); |
final Element frame = this.getElement().getChild("frame", draw); |
final Element imageElem = frame == null ? null : frame.getChild("image", draw); |
if (frame != null) { |
new ODFrame<>(getODDocument(), frame).setImage(name, data, false); |
if (imageElem != null) { |
final Attribute refAttr = imageElem.getAttribute("href", this.getNS().getNS("xlink")); |
this.getODDocument().getPackage().putFile(refAttr.getValue(), null); |
if (data == null) |
frame.detach(); |
else { |
refAttr.setValue("Pictures/" + name + (data.getFormat() != null ? "." + data.getFormat() : "")); |
this.getODDocument().getPackage().putFile(refAttr.getValue(), data.getBytes(new ODFrame<D>(getODDocument(), frame))); |
} |
} else if (data != null) |
throw new IllegalStateException("this cell doesn't contain a frame: " + this); |
throw new IllegalStateException("this cell doesn't contain an image: " + this); |
} |
public final void setBackgroundColor(final Color color) { |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/spreadsheet/BytesProducer.java |
---|
28,7 → 28,7 |
import org.jdom.Element; |
public abstract class BytesProducer { |
abstract class BytesProducer { |
/** |
* The data of an image to put in <code>frame</code>. |
36,7 → 36,7 |
* @param frame the frame where this image will be put. |
* @return the corresponding bytes. |
*/ |
public abstract byte[] getBytes(ODFrame<?> frame); |
abstract byte[] getBytes(ODFrame<?> frame); |
/** |
* The format of the data returned by {@link #getBytes(Element)}. |
43,12 → 43,12 |
* |
* @return the name of the format, <code>null</code> if unknown, eg "png". |
*/ |
public abstract String getFormat(); |
abstract String getFormat(); |
// *** concrete subclasses |
// a no-op Producer |
static public final class ByteArrayProducer extends BytesProducer { |
static final class ByteArrayProducer extends BytesProducer { |
private final byte[] data; |
private final boolean keepRatio; |
104,7 → 104,7 |
} |
// will generate a new png image (and can also keep ratio) |
static public final class ImageProducer extends BytesProducer { |
static final class ImageProducer extends BytesProducer { |
private final Image img; |
private final boolean keepRatio; |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/Grep.java |
---|
72,10 → 72,6 |
this.pattern = Pattern.compile(pattern); |
} |
public final Pattern getPattern() { |
return this.pattern; |
} |
public final void grep(final File dir) { |
FileUtils.walk(dir, new IClosure<File>() { |
@Override |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/OOXML.java |
---|
41,6 → 41,10 |
import javax.xml.validation.Schema; |
import javax.xml.validation.SchemaFactory; |
import net.jcip.annotations.GuardedBy; |
import net.jcip.annotations.Immutable; |
import net.jcip.annotations.ThreadSafe; |
import org.jdom.Content; |
import org.jdom.DocType; |
import org.jdom.Document; |
52,10 → 56,6 |
import org.jdom.xpath.XPath; |
import org.xml.sax.SAXException; |
import net.jcip.annotations.GuardedBy; |
import net.jcip.annotations.Immutable; |
import net.jcip.annotations.ThreadSafe; |
/** |
* Various bits of OpenDocument XML. |
* |
69,7 → 69,6 |
* never return <code>null</code>, allowing to support unknown versions. |
*/ |
public static final String LAST_FOR_UNKNOWN_PROP = OOXML.class.getPackage().getName() + ".lastOOXMLForUnknownVersion"; |
private static final boolean LAST_FOR_UNKNOWN = Boolean.getBoolean(LAST_FOR_UNKNOWN_PROP); |
private static final XML_OO instanceOO = new XML_OO(); |
@GuardedBy("OOXML") |
private static final SortedMap<String, XML_OD> instancesODByDate = new TreeMap<String, XML_OD>(); |
84,7 → 83,6 |
register(new XML_OD_1_0()); |
register(new XML_OD_1_1()); |
register(new XML_OD_1_2()); |
register(new XML_OD_1_3()); |
final List<OOXML> tmp = new ArrayList<OOXML>(instancesODByDate.size() + 1); |
tmp.add(instanceOO); |
108,7 → 106,7 |
* @see #LAST_FOR_UNKNOWN_PROP |
*/ |
public static OOXML get(XMLFormatVersion version) { |
return get(version, LAST_FOR_UNKNOWN); |
return get(version, Boolean.getBoolean(LAST_FOR_UNKNOWN_PROP)); |
} |
public static synchronized OOXML get(XMLFormatVersion version, final boolean lastForUnknown) { |
743,17 → 741,11 |
} |
} |
private static final class XML_OD_1_2 extends XML_OD_1_2plus { |
private static final class XML_OD_1_2 extends XML_OD { |
public XML_OD_1_2() { |
super("20110317", "1.2", "OpenDocument-v1.2-schema.rng", "OpenDocument-v1.2-manifest-schema.rng"); |
} |
} |
private static abstract class XML_OD_1_2plus extends XML_OD { |
protected XML_OD_1_2plus(final String dateString, final String versionString, final String schemaFile, final String manifestSchemaFile) { |
super(dateString, versionString, schemaFile, manifestSchemaFile); |
} |
@Override |
public Document createManifestDoc() { |
final Document res = super.createManifestDoc(); |
761,13 → 753,4 |
return res; |
} |
} |
// https://issues.oasis-open.org/issues/?jql=project%20%3D%20OFFICE%20AND%20resolution%20%3D%20Fixed%20AND%20fixVersion%20%3D%20%22ODF%201.3%22 |
// - https://issues.oasis-open.org/browse/OFFICE-3860 : New attributes "min-decimal-places" and |
// "forced-exponent-sign" parsed in DataStyle.formatNumberOrScientificNumber() |
private static final class XML_OD_1_3 extends XML_OD_1_2plus { |
public XML_OD_1_3() { |
super("20191225", "1.3", "OpenDocument-schema-v1.3.rng", "OpenDocument-manifest-schema-v1.3.rng"); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/OOUtils.java |
---|
20,10 → 20,8 |
import java.io.File; |
import java.io.IOException; |
import java.io.StringReader; |
import java.util.Locale; |
import org.jdom.Document; |
import org.jdom.Element; |
import org.jdom.JDOMException; |
import org.jdom.Namespace; |
import org.jdom.input.SAXBuilder; |
122,33 → 120,4 |
public static Color decodeRGB(String color) { |
return color == null ? null : Color.decode(color.trim()); |
} |
public static final Locale getElementLocale(final Element elem) { |
return getElementLocale(elem, elem.getNamespace()); |
} |
public static final Locale getElementLocale(final Element elem, final Namespace ns) { |
final Locale res; |
final String country = elem.getAttributeValue("country", ns); |
final String lang = elem.getAttributeValue("language", ns); |
if (lang != null) { |
res = new Locale.Builder().setLanguage(lang).setRegion(country).build(); |
} else { |
res = null; |
} |
return res; |
} |
public static final void setElementLocale(final Element elem, final Namespace ns, final Locale l) { |
if (l == null) |
elem.removeAttribute("country", ns); |
else |
elem.setAttribute("country", l.getCountry(), ns); |
final String lang = l == null ? null : l.getLanguage(); |
if (lang == null || lang.isEmpty()) |
elem.removeAttribute("language", ns); |
else |
elem.setAttribute("language", lang, ns); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/ODValueType.java |
---|
85,7 → 85,6 |
return FLOAT.parse(s); |
} |
}, |
// TODO support LocalDateTime |
DATE("date-value", Date.class, Calendar.class) { |
@Override |
107,15 → 106,12 |
} |
}, |
TIME("time-value", Duration.class, java.time.Duration.class, Calendar.class) { |
TIME("time-value", Duration.class, Calendar.class) { |
@Override |
public String format(Object o) { |
if (o instanceof Duration) { |
return o.toString(); |
} else if (o instanceof java.time.Duration) { |
// w/o days or larger : PTnHnMnS |
return o.toString(); |
} else { |
final Calendar cal = (Calendar) o; |
return TimeUtils.timePartToDuration(cal).toString(); |
222,7 → 218,7 |
return BOOLEAN; |
else if (o instanceof String) |
return STRING; |
else if (o instanceof Duration || o instanceof java.time.Duration) |
else if (o instanceof Duration) |
return TIME; |
else if (DATE.canFormat(o.getClass())) |
return DATE; |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/text/TextNode.java |
---|
158,7 → 158,7 |
static private final String getCharacterContent(final List<Content> pElem, final XMLFormatVersion vers, final boolean ooMode, final boolean useSeparator, final Option option) { |
if (pElem.isEmpty()) |
return ""; |
final OOXML xml = vers.getXML(); |
final OOXML xml = OOXML.get(vers, false); |
final StringBuilder sb = new StringBuilder(); |
final Namespace textNS = xml.getVersion().getTEXT(); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/ODPackage.java |
---|
268,8 → 268,11 |
} |
public static ODPackage createFromFile(final File f) throws IOException { |
try (final FileInputStream ins = new FileInputStream(f)) { |
final FileInputStream ins = new FileInputStream(f); |
try { |
return create(f, ins, f.getName()); |
} finally { |
ins.close(); |
} |
} |
597,19 → 600,19 |
return this.locale == null ? Locale.getDefault() : this.locale; |
} |
public static final String formatNumber(Number n, final Locale locale, final CellStyle defaultStyle) { |
return formatNumber(NumberFormat.getNumberInstance(locale), n, defaultStyle); |
public final String formatNumber(Number n, final CellStyle defaultStyle) { |
return formatNumber(NumberFormat.getNumberInstance(getLocale()), n, defaultStyle); |
} |
public static final String formatPercent(Number n, final Locale locale, final CellStyle defaultStyle) { |
return formatNumber(NumberFormat.getPercentInstance(locale), n, defaultStyle); |
public final String formatPercent(Number n, final CellStyle defaultStyle) { |
return formatNumber(NumberFormat.getPercentInstance(getLocale()), n, defaultStyle); |
} |
public static final String formatCurrency(Number n, final Locale locale, final CellStyle defaultStyle) { |
return formatNumber(NumberFormat.getCurrencyInstance(locale), n, defaultStyle); |
public final String formatCurrency(Number n, final CellStyle defaultStyle) { |
return formatNumber(NumberFormat.getCurrencyInstance(getLocale()), n, defaultStyle); |
} |
private static final String formatNumber(NumberFormat format, Number n, final CellStyle defaultStyle) { |
private final String formatNumber(NumberFormat format, Number n, final CellStyle defaultStyle) { |
synchronized (format) { |
final int decPlaces = DataStyle.getDecimalPlaces(defaultStyle); |
format.setMinimumFractionDigits(0); |
1180,13 → 1183,13 |
final Object val = entry.getData(); |
if (val != null) { |
if (val instanceof ODXMLDocument) { |
try (final OutputStream o = z.createEntryStream(name)) { |
final OutputStream o = z.createEntry(name); |
outputter.output(((ODXMLDocument) val).getDocument(), o); |
} |
o.close(); |
} else if (val instanceof Document) { |
try (final OutputStream o = z.createEntryStream(name)) { |
final OutputStream o = z.createEntry(name); |
outputter.output((Document) val, o); |
} |
o.close(); |
} else { |
z.zip(name, (byte[]) val, entry.isCompressed()); |
} |
1242,7 → 1245,8 |
if (pageCount != null && getContentType() != null && ContentType.TEXT.equals(getContentType().getType())) |
this.getMeta().getMetaChild("document-statistic").setAttribute("page-count", pageCount, getVersion().getMETA()); |
try (final Zip z = new Zip(out)) { |
final Zip z = new Zip(out); |
// magic number, see section 17.4 |
z.zipNonCompressed(MIMETYPE_ENTRY, this.getMimeType().getBytes(MIMETYPE_ENC)); |
1249,8 → 1253,8 |
final Manifest manifest = createManifest(z); |
z.zip(Manifest.ENTRY_NAME, new StringInputStream(manifest.asString())); |
z.close(); |
} |
} |
/** |
* Save the content of this package to our file, overwriting it if it exists. |
1268,8 → 1272,12 |
f.getParentFile().mkdirs(); |
// ATTN at this point, we must have read all the content of this file |
// otherwise we could save to File.createTempFile("oofd", null).deleteOnExit(); |
try (final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(f), 512 * 1024);) { |
final FileOutputStream out = new FileOutputStream(f); |
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(out, 512 * 1024); |
try { |
this.save(bufferedOutputStream); |
} finally { |
bufferedOutputStream.close(); |
} |
return f; |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/style/data/OD 1.3.fods |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/style/data/CurrencyStyle.java |
---|
58,12 → 58,12 |
// ATTN OpenOffice Fix (it generates <text>-</text>, so we have to use the |
// absolute value) |
final int multiplier = n.doubleValue() > 0 ? 1 : -1; |
sb.append(formatNumberOrScientificNumber(elem, n, multiplier, defaultStyle, lenient)); |
sb.append(formatNumberOrScientificNumber(elem, n, multiplier, defaultStyle)); |
} else if (elem.getName().equals("currency-symbol")) { |
if (elem.getTextTrim().length() > 0) { |
sb.append(elem.getText()); |
} else { |
sb.append(new DecimalFormatSymbols(this.getLocale(elem, false)).getCurrencySymbol()); |
sb.append(new DecimalFormatSymbols(this.getLocale(elem)).getCurrencySymbol()); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/style/data/DateStyle.java |
---|
54,6 → 54,18 |
return !"long".equals(elem.getAttributeValue("style", elem.getNamespace("number"))); |
} |
static final Locale getElementLocale(final Element elem) { |
final Locale res; |
final String country = elem.getAttributeValue("country", elem.getNamespace()); |
final String lang = elem.getAttributeValue("language", elem.getNamespace()); |
if (lang != null) { |
res = new Locale(lang, country == null ? "" : country); |
} else { |
res = null; |
} |
return res; |
} |
private static final Calendar getCalendar(final Element elem, Calendar defaultCal) { |
final Calendar res; |
final String cal = elem.getAttributeValue("calendar", elem.getNamespace()); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/style/data/TimeStyle.java |
---|
65,13 → 65,7 |
@Override |
public String format(Object o, CellStyle defaultStyle, boolean lenient) { |
final Duration d; |
if (o instanceof Calendar) |
d = TimeUtils.timePartToDuration((Calendar) o); |
else if (o instanceof java.time.Duration) |
d = TimeUtils.getTypeFactory().newDurationDayTime(o.toString()); |
else |
d = (Duration) o; |
final Duration d = o instanceof Calendar ? TimeUtils.timePartToDuration((Calendar) o) : (Duration) o; |
final Namespace numberNS = this.getElement().getNamespace(); |
final StringBuilder sb = new StringBuilder(); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/style/data/PercentStyle.java |
---|
54,7 → 54,7 |
if (elem.getName().equals("text")) { |
sb.append(elem.getText()); |
} else if (elem.getName().equals("number")) { |
sb.append(formatNumberOrScientificNumber(elem, n, 100, defaultStyle, lenient)); |
sb.append(formatNumberOrScientificNumber(elem, n, 100, defaultStyle)); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/style/data/NumberStyle.java |
---|
44,8 → 44,6 |
res = (Number) value; |
} else if (value instanceof Boolean) { |
res = ((Boolean) value).booleanValue() ? 1 : 0; |
} else if (value instanceof java.time.Duration) { |
res = ODEpoch.getDays((java.time.Duration) value); |
} else if ((value instanceof Duration || value instanceof Date || value instanceof Calendar)) { |
if (value instanceof Duration) { |
res = epoch.getDays((Duration) value); |
86,11 → 84,11 |
if (elem.getName().equals("text")) { |
sb.append(elem.getText()); |
} else if (elem.getName().equals("number") || elem.getName().equals("scientific-number")) { |
sb.append(formatNumberOrScientificNumber(elem, n, defaultStyle, lenient)); |
sb.append(formatNumberOrScientificNumber(elem, n, defaultStyle)); |
} else if (elem.getName().equals("fraction")) { |
// TODO fractions |
reportError("Fractions not supported", lenient); |
sb.append(ODPackage.formatNumber(n, getLocale(), defaultStyle)); |
sb.append(getPackage().formatNumber(n, defaultStyle)); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/style/data/DataStyle.java |
---|
17,7 → 17,6 |
import org.openconcerto.openoffice.ODEpoch; |
import org.openconcerto.openoffice.ODPackage; |
import org.openconcerto.openoffice.ODValueType; |
import org.openconcerto.openoffice.OOUtils; |
import org.openconcerto.openoffice.Style; |
import org.openconcerto.openoffice.StyleDesc; |
import org.openconcerto.openoffice.StyleProperties; |
52,29 → 51,18 |
/** |
* The default number of decimal digits if neither defined in the style nor in default-style. |
*/ |
public static final int DEFAULT_DECIMAL_PLACES; |
public static final int DEFAULT_DECIMAL_PLACES = Integer.parseInt(System.getProperty("openDocument.defaultDecimalPlaces", "15")); |
private static final Pattern QUOTE_PATRN = Pattern.compile("'", Pattern.LITERAL); |
private static final Pattern EXP_PATTERN = Pattern.compile("E(\\d+)$"); |
public static int getDecimalPlaces(final CellStyle defaultStyle) { |
if (defaultStyle != null) { |
final int res = defaultStyle.getTableCellProperties(null).getDecimalPlaces(); |
// Ignore invalid value |
return res < 0 ? DEFAULT_DECIMAL_PLACES : res; |
return defaultStyle.getTableCellProperties(null).getDecimalPlaces(); |
} else { |
return DEFAULT_DECIMAL_PLACES; |
} |
} |
protected static final int parsePositive(final String attr, final boolean lenient) { |
final int res = Integer.parseInt(attr); |
if (res < 0) { |
reportError("Negative value for " + attr, lenient); |
return 0; |
} |
return res; |
} |
public static void addStringLiteral(final StringBuilder formatSB, final String s) { |
formatSB.append('\''); |
formatSB.append(QUOTE_PATRN.matcher(s).replaceAll("''")); |
95,12 → 83,6 |
l.add(BooleanStyle.class); |
DATA_STYLES = Collections.unmodifiableSet(l); |
assert DATA_STYLES_DESCS.length == DATA_STYLES.size() : "Discrepancy between classes and descs"; |
final String decPlacesProp = System.getProperty("openDocument.defaultDecimalPlaces"); |
final int decPlacesParsed = decPlacesProp == null ? -1 : Integer.parseInt(decPlacesProp); |
// Ignore invalid value |
DEFAULT_DECIMAL_PLACES = decPlacesParsed < 0 ? 15 : decPlacesParsed; |
assert DEFAULT_DECIMAL_PLACES >= 0; |
} |
public static abstract class DataStyleDesc<S extends DataStyle> extends StyleDesc<S> { |
200,32 → 182,19 |
} |
public final Locale getLocale() { |
return this.getLocale(false); |
return this.getLocale(this.getElement()); |
} |
public final Locale getLocale(final boolean local) { |
return this.getLocale(this.getElement(), local); |
protected final Locale getLocale(final Element elem) { |
final Locale res = DateStyle.getElementLocale(elem); |
return res != null ? res : this.getPackage().getLocale(); |
} |
protected final Locale getLocale(final Element elem, final boolean local) { |
final Locale res = OOUtils.getElementLocale(elem); |
return local || res != null ? res : this.getPackage().getLocale(); |
protected final String formatNumberOrScientificNumber(final Element elem, final Number n, CellStyle defaultStyle) { |
return this.formatNumberOrScientificNumber(elem, n, 1, defaultStyle); |
} |
public final void setLocale(final Locale l) { |
OOUtils.setElementLocale(this.getElement(), this.getElement().getNamespace(), l); |
} |
@SuppressWarnings("unchecked") |
public final List<Element> getMapChildren() { |
return this.getElement().getChildren("map", getSTYLE()); |
} |
protected final String formatNumberOrScientificNumber(final Element elem, final Number n, CellStyle defaultStyle, final boolean lenient) { |
return this.formatNumberOrScientificNumber(elem, n, 1, defaultStyle, lenient); |
} |
protected final String formatNumberOrScientificNumber(final Element elem, final Number n, final int multiplier, CellStyle defaultStyle, final boolean lenient) { |
protected final String formatNumberOrScientificNumber(final Element elem, final Number n, final int multiplier, CellStyle defaultStyle) { |
final Namespace numberNS = this.getElement().getNamespace(); |
final StringBuilder numberSB = new StringBuilder(); |
252,10 → 221,9 |
} |
// e.g. if it's "--", 12,3 is displayed "12,3" and 12 is displayed "12,--" |
// From v1.3 §19.356.2 decimal-replacement can be empty |
final String decReplacement = elem.getAttributeValue("decimal-replacement", numberNS, ""); |
final String decReplacement = elem.getAttributeValue("decimal-replacement", numberNS); |
final boolean decSeparatorAlwaysShown; |
if (!decReplacement.isEmpty() && !NumberUtils.hasFractionalPart(n)) { |
if (decReplacement != null && !NumberUtils.hasFractionalPart(n)) { |
decSeparatorAlwaysShown = true; |
numberSB.append('.'); |
// escape quote in replacement |
263,47 → 231,30 |
} else { |
decSeparatorAlwaysShown = false; |
// see 19.343.2 |
final String decPlacesAttr = elem.getAttributeValue("decimal-places", numberNS, ""); |
final String minDecPlacesAttr = elem.getAttributeValue("min-decimal-places", numberNS, ""); |
final int forcedPlaces, nonZeroPlaces; |
if (!decPlacesAttr.isEmpty()) { |
final int decPlaces = parsePositive(decPlacesAttr, lenient); |
if (minDecPlacesAttr.isEmpty()) { |
forcedPlaces = decPlaces; |
nonZeroPlaces = 0; |
final Attribute decPlacesAttr = elem.getAttribute("decimal-places", numberNS); |
final int decPlaces; |
final char decChar; |
if (decPlacesAttr != null) { |
decChar = '0'; |
decPlaces = Integer.parseInt(decPlacesAttr.getValue()); |
} else { |
forcedPlaces = parsePositive(minDecPlacesAttr, lenient); |
if (forcedPlaces > decPlaces) { |
DataStyle.reportError("min-decimal-places greater than decimal-places : " + minDecPlacesAttr + " > " + decPlacesAttr, lenient); |
nonZeroPlaces = 0; |
} else { |
nonZeroPlaces = decPlaces - forcedPlaces; |
} |
} |
} else { |
// default style specifies the maximum |
forcedPlaces = 0; |
nonZeroPlaces = getDecimalPlaces(defaultStyle); |
decChar = '#'; |
decPlaces = getDecimalPlaces(defaultStyle); |
} |
if (forcedPlaces + nonZeroPlaces > 0) { |
if (decPlaces > 0) { |
numberSB.append('.'); |
for (int i = 0; i < forcedPlaces; i++) |
numberSB.append('0'); |
for (int i = 0; i < nonZeroPlaces; i++) |
numberSB.append('#'); |
for (int i = 0; i < decPlaces; i++) |
numberSB.append(decChar); |
} |
} |
final Attribute minExpAttr = elem.getAttribute("min-exponent-digits", numberNS); |
final boolean forcedExpSign; |
if (minExpAttr != null) { |
forcedExpSign = Boolean.parseBoolean(elem.getAttributeValue("forced-exponent-sign", numberNS, "true")); |
numberSB.append('E'); |
for (int i = 0; i < Integer.parseInt(minExpAttr.getValue()); i++) |
numberSB.append('0'); |
} else { |
forcedExpSign = false; |
} |
final DecimalFormatSymbols symbols = new DecimalFormatSymbols(this.getLocale()); |
316,8 → 267,8 |
decFormat.setGroupingSize(DEFAULT_GROUPING_SIZE); |
decFormat.setDecimalSeparatorAlwaysShown(decSeparatorAlwaysShown); |
String res = decFormat.format(NumberUtils.divide(n, factor)); |
// There's no way to force the plus sign in DecimalFormat |
if (forcedExpSign) { |
// java only puts the minus sign, OO also puts the plus sign |
if (minExpAttr != null) { |
final Matcher m = EXP_PATTERN.matcher(res); |
if (m.find()) |
res = res.substring(0, m.start()) + "E+" + m.group(1); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/ODXMLDocument.java |
---|
17,7 → 17,6 |
package org.openconcerto.openoffice; |
import org.openconcerto.openoffice.ODPackage.RootElement; |
import org.openconcerto.utils.cache.LRUMap; |
import org.openconcerto.utils.cc.IFactory; |
import org.openconcerto.xml.JDOMUtils; |
import org.openconcerto.xml.Validator; |
27,6 → 26,7 |
import java.util.Collections; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.LinkedHashMap; |
import java.util.List; |
import java.util.Map; |
import java.util.Set; |
113,8 → 113,13 |
this.content = content; |
this.version = version; |
this.childCreator = new ChildCreator(this.content.getRootElement(), ELEMS_ORDER.get(this.getVersion())); |
this.styleNamesLast = new LRUMap<>(15, 4); |
this.styleNamesLast = new LinkedHashMap<String, Integer>(4, 0.75f, true) { |
@Override |
protected boolean removeEldestEntry(java.util.Map.Entry<String, Integer> eldest) { |
return this.size() > 15; |
} |
}; |
} |
public ODXMLDocument(Document content) { |
this(content, XMLFormatVersion.get(content.getRootElement())); |
/trunk/OpenConcerto/src/org/openconcerto/openoffice/ODSingleXMLDocument.java |
---|
14,11 → 14,6 |
package org.openconcerto.openoffice; |
import static org.openconcerto.openoffice.ODPackage.RootElement.CONTENT; |
import static org.openconcerto.xml.Step.createAttributeStep; |
import static org.openconcerto.xml.Step.createAttributeStepFromQualifiedName; |
import static org.openconcerto.xml.Step.createElementStep; |
import static org.openconcerto.xml.Step.createElementStepFromQualifiedName; |
import org.openconcerto.openoffice.ODPackage.RootElement; |
import org.openconcerto.openoffice.style.data.DataStyle; |
import org.openconcerto.utils.Base64; |
33,7 → 28,6 |
import java.awt.Point; |
import java.io.File; |
import java.io.FileOutputStream; |
import java.io.IOException; |
import java.io.InputStream; |
import java.io.OutputStream; |
52,6 → 46,7 |
import java.util.Map.Entry; |
import java.util.Set; |
import org.apache.commons.collections.Transformer; |
import org.jdom.Attribute; |
import org.jdom.Content; |
import org.jdom.DocType; |
1047,8 → 1042,12 |
*/ |
protected final void detachDuplicate(Element elem) throws JDOMException { |
final String singularName = elem.getName().substring(0, elem.getName().length() - 1); |
final SimpleXMLPath<Attribute> simplePath = SimpleXMLPath.create(createElementStep(singularName + "s", "text"), createElementStep(singularName, "text"), createAttributeStep("name", "text")); |
final List<String> thisNames = simplePath.selectValues(getChild("body")); |
final List thisNames = getXPath("./text:" + singularName + "s/text:" + singularName + "/@text:name").selectNodes(getChild("body")); |
org.apache.commons.collections.CollectionUtils.transform(thisNames, new Transformer() { |
public Object transform(Object obj) { |
return ((Attribute) obj).getValue(); |
} |
}); |
final Iterator iter = elem.getChildren().iterator(); |
while (iter.hasNext()) { |
1203,19 → 1202,24 |
} |
private List<String> mergeUnique(ODXMLDocument doc, String topElem, String elemToMerge, String attrFQName, ElementTransformer addTransf) throws JDOMException { |
final Element other = doc.getChild(topElem); |
if (other == null) |
return Collections.emptyList(); |
List<String> added = new ArrayList<String>(); |
Element thisParent = this.getChild(topElem, true); |
final SimpleXMLPath<Attribute> simplePath = SimpleXMLPath.create(createElementStepFromQualifiedName(elemToMerge), createAttributeStepFromQualifiedName(attrFQName)); |
XPath xp = this.getXPath("./" + elemToMerge + "/@" + attrFQName); |
// les styles de ce document |
final List<String> thisElemNames = simplePath.selectValues(thisParent); |
List thisElemNames = xp.selectNodes(thisParent); |
// on transforme la liste d'attributs en liste de String |
org.apache.commons.collections.CollectionUtils.transform(thisElemNames, new Transformer() { |
public Object transform(Object obj) { |
return ((Attribute) obj).getValue(); |
} |
}); |
// pour chaque style de l'autre document |
for (final Attribute attr : simplePath.selectNodes(other)) { |
Iterator otherElemNames = xp.selectNodes(doc.getChild(topElem)).iterator(); |
while (otherElemNames.hasNext()) { |
Attribute attr = (Attribute) otherElemNames.next(); |
// on l'ajoute si non déjà dedans |
if (!thisElemNames.contains(attr.getValue())) { |
thisParent.addContent(addTransf.transform((Element) attr.getParent().clone())); |
1405,7 → 1409,7 |
throw new IllegalStateException("Cannot convert to binary data element : " + hrefParent); |
final Element binaryData = new Element("binary-data", getPackage().getVersion().getOFFICE()); |
binaryData.setText(Base64.encodeBytesBreakLines(getPackage().getBinaryFile(href))); |
binaryData.setText(Base64.encodeBytes(getPackage().getBinaryFile(href))); |
hrefParent.addContent(binaryData); |
// If this element is present, an xlink:href attribute in its parent element |
// shall be ignored. But LO doesn't respect that |
1414,11 → 1418,7 |
} |
final File f = this.getPackage().getContentType().addExt(fNoExt, true); |
try (final FileOutputStream outs = new FileOutputStream(f)) { |
// Use OutputStream parameter so that the encoding used for the Writer matches the |
// XML declaration. |
ODPackage.createOutputter().output(doc, outs); |
} |
FileUtils.write(ODPackage.createOutputter().outputString(doc), f); |
return f; |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/WindowUtils.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/ui/WrapLayout.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/ui/group/LayoutHints.java |
---|
17,7 → 17,7 |
@Immutable |
public class LayoutHints { |
private boolean visible; |
private final boolean visible; |
private final boolean largeWidth; |
private final boolean largeHeight; |
private boolean foldable = false; |
39,7 → 39,6 |
public static final LayoutHints DEFAULT_GROUP_HINTS = new LayoutHints(true, false, false, false, true, true); |
public static final LayoutHints DEFAULT_SEPARATED_GROUP_HINTS = new LayoutHints(true, false, true, true, true, true); |
public static final LayoutHints DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS = new LayoutHints(true, false, false, true, true, true); |
public static final LayoutHints DEFAULT_SEPARATED_VERY_LARGE_HINTS = new LayoutHints(false, false, true, true, true, false, false, true); |
public LayoutHints(boolean largeWidth, boolean largeHeight, boolean showLabel) { |
this(largeWidth, largeHeight, showLabel, false, false, false); |
158,13 → 157,9 |
} |
public boolean isVisible() { |
return this.visible; |
return visible; |
} |
public void setVisible(boolean b) { |
this.visible = b; |
} |
@Override |
public int hashCode() { |
final int prime = 31; |
192,5 → 187,4 |
return this.fillHeight == other.fillHeight && this.fillWidth == other.fillWidth && this.largeHeight == other.largeHeight && this.largeWidth == other.largeWidth |
&& this.separated == other.separated && this.showLabel == other.showLabel && this.split == other.split && this.visible == other.visible; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/group/Group.java |
---|
21,11 → 21,6 |
import java.util.Comparator; |
import java.util.List; |
/** |
* Allow to customize UI layout. |
* |
* @author guillaume |
*/ |
public class Group extends Item { |
public static Group copy(final Group g, final Group newParent) { |
68,33 → 63,11 |
} |
} |
public final Group toImmutable() { |
return this.toImmutable(true); |
} |
public final Group toImmutable(final boolean onlyDesc) { |
if (this.isFrozen()) |
return this; |
final Group res; |
if (onlyDesc) { |
res = copy(this, null); |
res.freeze(); |
} else { |
final List<String> p = this.getAbsolutePath(); |
final Group copy = copy(this.getRoot(), null); |
copy.freeze(); |
res = copy.followPath(p, false); |
} |
assert res.isFrozen(); |
return res; |
} |
@Override |
protected synchronized void _freeze() { |
super._freeze(); |
public synchronized void freeze() { |
super.freeze(); |
for (final Tuple2<Item, Integer> child : this.list) { |
child.get0()._freeze(); |
child.get0().freeze(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/group/Item.java |
---|
15,10 → 15,6 |
import java.util.Collection; |
import java.util.Collections; |
import java.util.LinkedList; |
import java.util.List; |
import java.util.concurrent.atomic.AtomicReference; |
import java.util.function.Consumer; |
import net.jcip.annotations.GuardedBy; |
70,13 → 66,7 |
throw new IllegalStateException("Frozen cannot " + op); |
} |
public synchronized final void freeze() { |
if (this.getParent() != null) |
throw new IllegalStateException("Can only freeze from the root down"); |
this._freeze(); |
} |
protected synchronized void _freeze() { |
public synchronized void freeze() { |
this.frozen = true; |
} |
123,26 → 113,14 |
this.localHint = new LayoutHints(localHint == null ? LayoutHints.DEFAULT_FIELD_HINTS : localHint); |
} |
public final void applyUntilRoot(final Consumer<Item> cons) { |
public final Group getRoot() { |
Item current = this; |
while (current != null) { |
cons.accept(current); |
while (current.getParent() != null) { |
current = current.getParent(); |
} |
return current instanceof Group ? (Group) current : null; |
} |
public final List<String> getAbsolutePath() { |
final LinkedList<String> res = new LinkedList<>(); |
this.applyUntilRoot((item) -> res.addFirst(item.getId())); |
return res; |
} |
public final Group getRoot() { |
final AtomicReference<Item> current = new AtomicReference<>(); |
this.applyUntilRoot((item) -> current.set(item)); |
return current.get() instanceof Group ? (Group) current.get() : null; |
} |
protected void printTree(final StringBuilder builder, final int localOrder, final int level) { |
for (int i = 0; i < level - 1; i++) { |
builder.append(" "); |
/trunk/OpenConcerto/src/org/openconcerto/ui/component/InteractionMode.java |
---|
76,10 → 76,6 |
return comp; |
} |
public final InteractionMode and(InteractionMode m) { |
return from(this.isEnabled() && m.isEnabled(), this.isEditable() && m.isEditable()); |
} |
/** |
* Try to infer the mode of the passed component. This method has special cases for known |
* component (.e.g {@link JTextComponent}) otherwise generic components are presumed to not have |
/trunk/OpenConcerto/src/org/openconcerto/ui/DefaultGridBagConstraints.java |
---|
13,11 → 13,11 |
package org.openconcerto.ui; |
import java.awt.Component; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
import java.awt.Insets; |
import javax.swing.JComponent; |
import javax.swing.UIManager; |
public class DefaultGridBagConstraints extends GridBagConstraints { |
43,11 → 43,11 |
return new Insets(2, 3, 2, 2); |
} |
public static void lockMinimumSize(Component c) { |
public static void lockMinimumSize(JComponent c) { |
c.setMinimumSize(new Dimension(c.getPreferredSize())); |
} |
public static void lockMaximumSize(Component c) { |
public static void lockMaximumSize(JComponent c) { |
c.setMaximumSize(new Dimension(c.getPreferredSize())); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUITable.java |
---|
517,7 → 517,7 |
if (this.hasRow()) { |
final int size = this.getRowsCount(); |
if (jsonContext.size() != size) { |
throw new IllegalStateException("LightUITable.setValueFromContext() - Incorrect line count in JSON, row count:" + size + " context:" + jsonContext.size() + " (" + value + ")"); |
System.err.println("LightUITable.setValueFromContext() - Incorrect line count in JSON"); |
} else { |
for (int i = 0; i < size; i++) { |
/trunk/OpenConcerto/src/org/openconcerto/ui/FormLayouter.java |
---|
146,9 → 146,9 |
} |
/** |
* Ajout un composant sur une ligne. |
* Ajout un composant sur une ligne Si comp est null, un titre est créé. |
* |
* @param desc le label du champ, <code>null</code> if <code>comp</<code> should use its area. |
* @param desc le label du champ. |
* @param comp le composant graphique d'edition. |
* @param w la largeur, entre 1 et la largeur de ce layout, ou 0 pour toute la largeur. |
* @return the created label. |
158,20 → 158,11 |
public JLabel add(String desc, Component comp, int w) { |
w = this.checkArgs(comp, w); |
int realWidth = this.getRealFieldWidth(w); |
final JLabel lab; |
final int fieldX; |
if (desc == null) { |
lab = null; |
fieldX = this.getLabelX(); |
realWidth += this.getFieldX() - fieldX; |
} else { |
lab = new JLabel(desc); |
final int realWidth = this.getRealFieldWidth(w); |
// Guillaume : right alignment like the Mac |
final JLabel lab = new JLabel(desc); |
this.co.add(lab, this.constraints.xy(this.getLabelX(), this.getY(), CellConstraints.RIGHT, this.getRowAlign())); |
fieldX = this.getFieldX(); |
} |
this.co.add(comp, this.constraints.xyw(fieldX, this.getY(), realWidth, CellConstraints.DEFAULT, this.getRowAlign())); |
this.co.add(comp, this.constraints.xyw(this.getFieldX(), this.getY(), realWidth, CellConstraints.DEFAULT, this.getRowAlign())); |
this.x += w; |
return lab; |
} |
/trunk/OpenConcerto/src/org/openconcerto/odtemplate/TemplateGenerator.java |
---|
80,9 → 80,7 |
try { |
this.transform(pkg.toSingle()); |
// MAYBE fireStatusChange with the number of tag done out of the total |
try (final Template template = new Template(pkg)) { |
return template.createDocument(new OGNLDataModel(data)); |
} |
return new Template(pkg).createDocument(new OGNLDataModel(data)); |
} catch (Exception exn) { |
throw ExceptionUtils.createExn(IOException.class, "generation error in " + this, exn); |
} |
/trunk/OpenConcerto/src/org/openconcerto/odtemplate/engine/Parsed.java |
---|
114,9 → 114,4 |
} |
return new Processor<E>(this, data).process().getWhole(); |
} |
public void destroy() { |
for (final Statement st : this.statements.values()) |
st.destroy(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/odtemplate/statements/Include.java |
---|
36,10 → 36,7 |
private static final String PREFIX = "[IOD"; |
// Cache whole file to avoid disk access since there can be a lot of sections in a single file |
private final ICache<File, ODSingleXMLDocument, File> cache; |
// Cache the Parsed of just one section in the above file |
// { filePath#sectionName -> Parsed } |
private final ICache<String, Parsed<ODSingleXMLDocument>, File> parsedCache; |
public Include() { |
48,13 → 45,6 |
this.parsedCache = new ICache<String, Parsed<ODSingleXMLDocument>, File>(180); |
} |
@Override |
public void destroy() { |
this.cache.getSupp().die(); |
this.parsedCache.getSupp().die(); |
super.destroy(); |
} |
public boolean matches(Element elem) { |
if (!elem.getQualifiedName().equals("text:a")) |
return false; |
139,10 → 129,9 |
private Parsed<ODSingleXMLDocument> createParsed(final File ref, final String sectionName, final Parsed<?> parsed) throws JDOMException, IOException, TemplateException { |
final ODSingleXMLDocument docToAdd = getXMLDocument(ref).clone(); |
// replace the body with just sectionName |
final XPath sectionXP = docToAdd.getXPath("//text:section[@text:name = '" + sectionName + "']"); |
final Element section = (Element) sectionXP.selectSingleNode(docToAdd.getDocument()); |
// ajouter la section elle-même car souvent des if s'y réfèrent. |
// ajouter la section car souvent des if s'y réfèrent. |
docToAdd.getBody().setContent(section.detach()); |
final Material<ODSingleXMLDocument> from = Material.from(docToAdd); |
/trunk/OpenConcerto/src/org/openconcerto/odtemplate/statements/Statement.java |
---|
72,9 → 72,6 |
*/ |
public abstract void execute(Processor<?> processor, Element elem, DataModel model) throws TemplateException; |
public void destroy() { |
} |
@Override |
public String toString() { |
return this.getClass().getSimpleName() + " " + this.getName(); |
/trunk/OpenConcerto/src/org/openconcerto/odtemplate/Template.java |
---|
37,7 → 37,7 |
* template.createDocument(vars, new FileOutputStream("document.sxw")); |
* </pre> |
*/ |
public class Template implements AutoCloseable { |
public class Template { |
protected final Parsed<ODPackage> contentTemplate; |
62,11 → 62,6 |
this.contentTemplate = new Parsed<ODPackage>(Material.from(contents)); |
} |
@Override |
public void close() throws Exception { |
this.contentTemplate.destroy(); |
} |
/** |
* Generates a document merging template and data. |
* |
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/ITextArticleWithCompletion.java |
---|
16,8 → 16,6 |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLRowValuesListFetcher; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
359,42 → 357,13 |
MultipleSQLSelectExecutor mult = new MultipleSQLSelectExecutor(this.tableArticle.getDBSystemRoot(), listSel); |
List<List<? extends SQLRowAccessor>> resultList = new ArrayList<>(); |
resultList.addAll(mult.execute()); |
List<List<SQLRow>> resultList = mult.execute(); |
// Recherche dans les codes fournisseurs |
SQLTable tableCodeArt = this.tableArticle.getDBRoot().getTable("CODE_FOURNISSEUR"); |
SQLRowValues rowValsCodeF = new SQLRowValues(tableCodeArt); |
rowValsCodeF.putNulls("CODE"); |
rowValsCodeF.putRowValues("ID_ARTICLE").putNulls(this.tableArticle.getFieldsName()); |
for (List<SQLRow> list : resultList) { |
final String codeText = aText; |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsCodeF); |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() { |
@Override |
public SQLSelect transformChecked(SQLSelect input) { |
for (SQLRow sqlRow : list) { |
Where wCodeFContains = new Where(tableCodeArt.getField("CODE"), "LIKE", "%" + codeText + "%"); |
input.setWhere(wCodeFContains); |
input.setLimit(SQL_RESULT_LIMIT); |
return input; |
} |
}); |
List<SQLRowValues> resultCodeF = fetcher.fetch(); |
resultList.add(2, resultCodeF); |
for (List<? extends SQLRowAccessor> list : resultList) { |
for (SQLRowAccessor sqlRow : list) { |
StringBuffer buf = new StringBuffer(); |
if (sqlRow.getTable().getName().equals("CODE_FOURNISSEUR")) { |
SQLRowAccessor rArt = sqlRow.getForeign("ID_ARTICLE"); |
buf.append(sqlRow.getString("CODE") + " -- "); |
buf.append(rArt.getString("CODE") + " -- "); |
buf.append(rArt.getString("NOM")); |
result.add(new IComboSelectionItem(rArt, buf.toString())); |
} else { |
if (sqlRow.getString("CODE_BARRE") != null && sqlRow.getString("CODE_BARRE").trim().length() > 0) { |
buf.append(sqlRow.getString("CODE_BARRE") + " -- "); |
} |
403,7 → 372,6 |
result.add(new IComboSelectionItem(sqlRow, buf.toString())); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/request/RSTransformer.java |
---|
New file |
0,0 → 1,32 |
/* |
* 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.sql.request; |
import org.openconcerto.utils.cc.Transformer; |
import java.sql.ResultSet; |
public abstract class RSTransformer<E, T> extends Transformer<E, T> { |
private ResultSet rs; |
protected final ResultSet getRs() { |
return this.rs; |
} |
protected final void setRs(ResultSet rs) { |
this.rs = rs; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/element/SQLElementDirectory.java |
---|
195,17 → 195,15 |
} |
/** |
* Search for an SQLElement which is an {@link Class#isInstance(Object) instance of} |
* <code>clazz</code>. |
* Search for an SQLElement whose class is <code>clazz</code>. |
* |
* @param <S> type of SQLElement |
* @param clazz the class. |
* @return the corresponding SQLElement, or <code>null</code> if none can be found. |
* @throws IllegalArgumentException if there's more than one match. |
* @see #getElementsOfClass(Class, boolean) |
*/ |
public final <S extends SQLElement> S getElement(Class<S> clazz) { |
return this.getElementOfClass(clazz, true); |
return this.getElementOfClass(clazz, false); |
} |
public final <S extends SQLElement> S getElementOfClass(Class<S> clazz, final boolean allowSubclass) { |
/trunk/OpenConcerto/src/org/openconcerto/sql/element/GroupSQLComponent.java |
---|
168,7 → 168,8 |
} |
if (this.hasAdditionnalFields) { |
if ((currentGroup == this.group && this.additionnalFieldsGroup == null) || (currentGroup == this.additionnalFieldsGroup)) { |
for (String field : this.getElement().getAdditionalFields().keySet()) { |
final Map<String, JComponent> additionalFields = this.getElement().getAdditionalFields(); |
for (String field : additionalFields.keySet()) { |
Item item = new Item(field, new LayoutHints(false, false, true, false, true, false)); |
int fill = c.fill; |
double weightx = c.weightx; |
/trunk/OpenConcerto/src/org/openconcerto/sql/element/SQLElement.java |
---|
56,7 → 56,6 |
import org.openconcerto.sql.request.ListSQLRequest; |
import org.openconcerto.sql.request.SQLCache; |
import org.openconcerto.sql.request.SQLFieldTranslator; |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox; |
import org.openconcerto.sql.sqlobject.SQLTextCombo; |
import org.openconcerto.sql.ui.light.CustomRowEditor; |
import org.openconcerto.sql.ui.light.GroupToLightUIConvertor; |
128,7 → 127,6 |
import java.util.SortedMap; |
import java.util.concurrent.atomic.AtomicReference; |
import java.util.logging.Level; |
import java.util.function.Supplier; |
import javax.swing.JComponent; |
import javax.swing.JOptionPane; |
204,7 → 202,7 |
@GuardedBy("this") |
private SQLCache<SQLRow, Object> modelCache; |
private final Map<String, Supplier<? extends JComponent>> additionalFields; |
private final Map<String, JComponent> additionalFields; |
private final List<SQLTableModelColumn> additionalListCols; |
@GuardedBy("this") |
private List<String> mdPath; |
244,7 → 242,7 |
this.modelCache = null; |
// the components should always be in the same order |
this.additionalFields = new LinkedHashMap<>(); |
this.additionalFields = new LinkedHashMap<String, JComponent>(); |
this.additionalListCols = new ArrayList<SQLTableModelColumn>(); |
this.mdPath = Collections.emptyList(); |
} |
3016,23 → 3014,19 |
* @return <code>true</code> if no view existed. |
*/ |
public final boolean putAdditionalField(final String field) { |
return this.putAdditionalField(field, null); |
return this.putAdditionalField(field, (JComponent) null); |
} |
public final boolean putAdditionalTextField(final String field, final Supplier<? extends JTextComponent> comp) { |
return this.putAdditionalField(field, comp); |
public final boolean putAdditionalField(final String field, final JTextComponent comp) { |
return this.putAdditionalField(field, (JComponent) comp); |
} |
public final boolean putAdditionalTextCombo(final String field, final Supplier<? extends SQLTextCombo> comp) { |
return this.putAdditionalField(field, comp); |
public final boolean putAdditionalField(final String field, final SQLTextCombo comp) { |
return this.putAdditionalField(field, (JComponent) comp); |
} |
public final boolean putAdditionalCombo(final String field, final Supplier<? extends SQLRequestComboBox> comp) { |
return this.putAdditionalField(field, comp); |
} |
// private as only a few JComponent are OK |
private final boolean putAdditionalField(final String field, final Supplier<? extends JComponent> comp) { |
private final boolean putAdditionalField(final String field, final JComponent comp) { |
if (this.additionalFields.containsKey(field)) { |
return false; |
} else { |
3041,7 → 3035,7 |
} |
} |
public final Map<String, Supplier<? extends JComponent>> getAdditionalFields() { |
public final Map<String, JComponent> getAdditionalFields() { |
return Collections.unmodifiableMap(this.additionalFields); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/element/BaseSQLComponent.java |
---|
84,7 → 84,6 |
import java.util.Map; |
import java.util.Map.Entry; |
import java.util.Set; |
import java.util.function.Supplier; |
import javax.swing.JCheckBox; |
import javax.swing.JComponent; |
430,11 → 429,11 |
|| (this.getMode() != Mode.INSERTION && CollectionUtils.containsAny(this.getElement().getInsertOnlyFields(), fieldsNames)); |
} |
@Override |
protected final void inited() { |
super.inited(); |
if (!(this instanceof GroupSQLComponent)) { |
for (final Entry<String, Supplier<? extends JComponent>> e : this.getElement().getAdditionalFields().entrySet()) { |
for (final Entry<String, JComponent> e : this.getElement().getAdditionalFields().entrySet()) { |
final SpecParser spec; |
// FIXME Required à spécifier directement depuis le module |
if (this.requiredNames != null && this.requiredNames.contains(e.getKey())) { |
442,16 → 441,14 |
} else { |
spec = new SpecParser(null, true); |
} |
final Supplier<? extends JComponent> comp = e.getValue(); |
if (comp == null) { |
final JComponent comp = e.getValue(); |
if (comp == null) |
// infer component |
this.addViewJComponent(e.getKey(), spec); |
} else { |
// create component |
this.addView(comp.get(), e.getKey(), spec); |
else |
this.addView(comp, e.getKey(), spec); |
} |
} |
} |
// assure that added views are consistent with our editable status |
this.updateChildrenEditable(); |
for (final SQLRowItemView v : this.getRequest().getViews()) { |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLResultSet.java |
---|
13,8 → 13,6 |
package org.openconcerto.sql.model; |
import org.openconcerto.utils.cc.CachedTransformer; |
import java.io.InputStream; |
import java.io.Reader; |
import java.math.BigDecimal; |
38,6 → 36,9 |
import java.util.HashMap; |
import java.util.Map; |
import org.apache.commons.collections.Transformer; |
import org.apache.commons.collections.map.LazyMap; |
/** |
* A resultSet that wraps onto another one, caching name to index translation, and using a |
* ResultSetFullnameHelper. |
119,14 → 120,23 |
private final ResultSet delegate; |
private final ResultSetFullnameHelper helper; |
private final CachedTransformer<String, Integer, SQLException> indexes; |
private final Map indexes; |
private int rowProcessedCount; |
public SQLResultSet(ResultSet delegate) { |
this.delegate = delegate; |
this.helper = new ResultSetFullnameHelper(this); |
this.indexes = new CachedTransformer<>(new HashMap<>(), this::doFindColumn); |
this.indexes = LazyMap.decorate(new HashMap(), new Transformer() { |
public Object transform(Object input) { |
final String colName = (String) input; |
try { |
return new Integer(doFindColumn(colName)); |
} catch (SQLException e) { |
return e; |
} |
} |
}); |
} |
private ResultSet getDelegate() { |
return this.delegate; |
161,12 → 171,17 |
} |
public int findColumn(String columnName) throws SQLException { |
final int index = this.indexes.get(columnName).intValue(); |
final Object res = this.indexes.get(columnName); |
if (res instanceof SQLException) |
throw (SQLException) res; |
else { |
final int index = ((Number) res).intValue(); |
if (index < 1) |
throw new SQLException(columnName + " not found"); |
else |
return index; |
} |
} |
private int doFindColumn(String columnName) throws SQLException { |
try { |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/ResultSetFullnameHelper.java |
---|
19,6 → 19,9 |
import java.util.HashMap; |
import java.util.Map; |
import org.apache.commons.collections.Factory; |
import org.apache.commons.collections.map.LazyMap; |
/** |
* A class to help find fields by their fullname in resultset. Some jdbc drivers only accept the |
* short name of fields, eg you execute "select B.DESIGNATION from BATIMENT B" but you can only |
30,11 → 33,15 |
public final class ResultSetFullnameHelper { |
private final ResultSet delegate; |
private ResultSetMetaData rsMD; |
private final Map<String, Map<String, Integer>> tablesMap; |
private final Map tablesMap; |
public ResultSetFullnameHelper(ResultSet rs) { |
this.delegate = rs; |
this.tablesMap = new HashMap<>(); |
this.tablesMap = LazyMap.decorate(new HashMap(), new Factory() { |
public Object create() { |
return new HashMap(); |
} |
}); |
this.rsMD = null; |
} |
67,12 → 74,12 |
* @throws SQLException if an error occur while retrieving metadata. |
*/ |
public final int getIndex(String tableName, String fieldName) throws SQLException { |
final Map<String, Integer> m = this.tablesMap.computeIfAbsent(tableName, (k) -> new HashMap<>()); |
final Map m = (Map) this.tablesMap.get(tableName); |
if (!m.containsKey(fieldName)) { |
final int index = this.searchIndex(tableName, fieldName); |
m.put(fieldName, index < 1 ? null : new Integer(index)); |
} |
final Integer val = m.get(fieldName); |
final Integer val = (Integer) m.get(fieldName); |
return val == null ? -1 : val.intValue(); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLRowMode.java |
---|
14,7 → 14,11 |
package org.openconcerto.sql.model; |
import org.openconcerto.sql.model.SQLSelect.ArchiveMode; |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.cc.IPredicate; |
import java.util.Collection; |
/** |
* Allow to specify which rows we're interested in. |
* |
88,4 → 92,14 |
public SQLRow filter(SQLRow r) { |
return this.check(r) ? r : null; |
} |
public void filter(Collection<SQLRow> rows) { |
CollectionUtils.filter(rows, new IPredicate<SQLRow>() { |
@Override |
public boolean evaluateChecked(SQLRow r) { |
return check(r); |
} |
}); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLInjector.java |
---|
169,24 → 169,6 |
rowVals.put(field.getName(), value); |
} |
private String cleanRef(String value) { |
List<String> l = StringUtils.fastSplit(value, ','); |
Set<String> s = new HashSet<>(l); |
String nom = ""; |
if (s.size() > 1) { |
Set<String> refAdded = new HashSet<>(); |
for (String string : s) { |
if (string.trim().length() > 0 && !refAdded.contains(string.trim())) { |
nom += string + ","; |
refAdded.add(string.trim()); |
} |
} |
} else if (s.size() == 1) { |
nom = s.iterator().next(); |
} |
return nom; |
} |
protected void transfertReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField, String from, String to) { |
String label = rowVals.getString(to); |
194,7 → 176,7 |
if (prefs.getBoolean("TransfertRef", true) || !to.equals("NOM")) { |
if (label != null && label.trim().length() > 0) { |
rowVals.put(to, cleanRef(label + ", " + srcRow.getString(from))); |
rowVals.put(to, label + ", " + srcRow.getString(from)); |
} else { |
rowVals.put(to, srcRow.getString(from)); |
} |
216,7 → 198,17 |
String label = rowVals.getString("NOM"); |
if (label != null && label.trim().length() > 0) { |
final String value = label + ", " + srcRow.getString("NUMERO"); |
rowVals.put("NOM", cleanRef(value)); |
List<String> l = StringUtils.fastSplit(value, ','); |
Set<String> s = new HashSet<>(l); |
String nom = ""; |
if (s.size() > 1) { |
for (String string : s) { |
nom += string + ","; |
} |
} else if (s.size() == 1) { |
nom = s.iterator().next(); |
} |
rowVals.put("NOM", nom); |
} else { |
rowVals.put("NOM", srcRow.getString("NUMERO")); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLSyntaxMS.java |
---|
23,6 → 23,7 |
import org.openconcerto.utils.FileUtils; |
import org.openconcerto.utils.ListMap; |
import org.openconcerto.utils.ProcessStreams; |
import org.openconcerto.utils.ProcessStreams.Action; |
import org.openconcerto.utils.RTInterruptedException; |
import org.openconcerto.utils.StringUtils; |
import org.openconcerto.utils.Tuple2; |
394,7 → 395,8 |
pb.command().add("-E"); |
} |
final Process p = ProcessStreams.redirect(pb).start(); |
final Process p = pb.start(); |
ProcessStreams.handle(p, Action.REDIRECT); |
try { |
final int returnCode = p.waitFor(); |
if (returnCode != 0) |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLSyntax.java |
---|
673,8 → 673,8 |
/** |
* Get the default clause. |
* |
* @param def the default, e.g. "0" or <code>null</code>. |
* @return the default clause, e.g. " DEFAULT 0" or " ". |
* @param def the default, e.g. "0". |
* @return the default clause, e.g. "DEFAULT 0". |
*/ |
public final String getDefaultClause(final String def) { |
if (def == null) |
/trunk/OpenConcerto/src/org/openconcerto/sql/changer/correct/FixSharedPrivate.java |
---|
25,7 → 25,6 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLSelect.ArchiveMode; |
import org.openconcerto.sql.model.SQLSystem; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.model.graph.Path; |
35,7 → 34,6 |
import org.openconcerto.utils.cc.ITransformer; |
import java.sql.SQLException; |
import java.util.EnumSet; |
import java.util.List; |
/** |
72,14 → 70,6 |
} |
@Override |
protected EnumSet<SQLSystem> getCompatibleSystems() { |
// When executing deleteReq : |
// - if PRIVATE_REFS is temporary : "Can't reopen table" |
// - if not : "You can't specify target table 'PRIVATE_REFS' for update in FROM clause" |
return EnumSet.complementOf(EnumSet.of(SQLSystem.MYSQL)); |
} |
@Override |
protected void changeImpl(final SQLTable t) throws SQLException { |
getStream().print(t); |
final SQLElement elem = this.getDir().getElement(t); |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/RowValuesTableModel.java |
---|
153,10 → 153,6 |
this.list.add(e); |
} |
public void setValidationField(SQLField validationField) { |
this.validationField = validationField; |
} |
public synchronized int getColumnCount() { |
return this.nbColumn; |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/function/FunctionalSupplier.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/utils/function/ConstantSupplier.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/utils/Destroyable.java |
---|