OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Ignore whitespace Rev 176 → Rev 177

/trunk/OpenConcerto/.classpath
22,7 → 22,6
<classpathentry kind="lib" path="lib/commons-pool-1.6.jar"/>
<classpathentry kind="lib" path="lib/h2-1.3.175.jar"/>
<classpathentry kind="lib" path="lib/xercesImpl-2.9.1.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="lib/h2-1.3.175-triggerSource.jar"/>
<classpathentry kind="lib" path="lib/jaxen-1.1.6.jar"/>
<classpathentry kind="lib" path="lib/jdom-2.0.5.jar"/>
32,7 → 31,6
<classpathentry exported="true" kind="lib" path="lib/jOpenCalendar.jar"/>
<classpathentry kind="lib" path="lib/h2-1.3.175-dropTableRestrict.jar"/>
<classpathentry kind="lib" path="lib/icu4j-56_1-module_format+calendar.jar"/>
<classpathentry kind="lib" path="lib/icu4j-56-data-western_europe.jar"/>
<classpathentry kind="lib" path="lib/DS_Desktop_Notify.jar"/>
<classpathentry kind="lib" path="lib/mime_util.jar"/>
<classpathentry kind="lib" path="lib/accessors-smart-1.1.jar"/>
44,5 → 42,10
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/postgresql-42.2.2.jre7.jar"/>
<classpathentry kind="lib" path="lib/poi-3.17.jar"/>
<classpathentry kind="lib" path="lib/piccolo-1.04.jar"/>
<classpathentry kind="lib" path="lib/fontbox-2.0.19.jar"/>
<classpathentry kind="lib" path="lib/javax.activation-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/pdfbox-2.0.19.jar"/>
<classpathentry kind="lib" path="lib/pdfbox.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_en.xml
925,7 → 925,7
<element refid="sales.quote.state" name="état de devis" namePlural="états de devis">
<FIELD name="NOM" label="Quote status" />
</element>
<element refid="controle.EtatRapportSQLElement.report.state" name="état rapport" namePlural="états rapports">
<element refid="controle.report.state" name="état rapport" namePlural="états rapports">
<FIELD name="NOM" label="Report status" />
</element>
<element refid="humanresources.employe.info" name="état civil" namePlural="états civils">
962,6 → 962,7
<FIELD name="ID_COMPTE_PCE" label="Compte de charge" />
<FIELD name="ID_CLIENT" label="Customer" />
<FIELD name="ID_ADRESSE" label="Adresse de livraison spécifique" />
<FIELD name="DATE_REGLEMENT" label="Date of payment" />
</element>
<element refid="supplychain.orderinvoice.purchase.item" name="element de facture"
namePlural="éléments de facture">
1051,7 → 1052,7
<FIELD name="IN_PERIODE" label="Dans la période" />
<FIELD name="ID_FICHE_PAYE" label="Fiche de paye" />
</element>
<element refid="controle.FicheRendezVousSQLElement.appointment.form" name="appointment form">
<element refid="controle.appointment.form" name="appointment form">
<FIELD name="DATE" label="Date de création" />
<FIELD name="ID_VERIFICATEUR" label="Pilote" />
<FIELD name="ID_CLIENT" label="Customer" />
1071,7 → 1072,7
<FIELD name="ID_POLE_PRODUIT" label="Pôle produit" />
<FIELD name="VALID" label="Valider par le responsable" />
</element>
<element refid="controle.FicheRdvItemSQLElement.appointment.form.item" name="appointment form item">
<element refid="controle.appointment.form.item" name="appointment form item">
<FIELD name="ECHEANCE_RAPPORT" label="Ech. remise rapport en jour" />
<FIELD name="DATE" label="Date" />
<FIELD name="ID_MISSION" label="Mission" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mapping_fr.xml
208,6 → 208,8
<FIELD name="PART_BRUT" label="Participe à la base brut" />
<FIELD name="COTISABLE" label="Participe à la base cotisable" />
<FIELD name="PART_CP" label="Participe aux congés payés" />
<FIELD name="CSG_NORMAL" label="Participe à la base CSG normale" />
<FIELD name="CSG_REDUIT" label="Participe à la base CSG réduite" />
</element>
<element refid="humanresources.payroll.category.comment" nameClass="feminine" name="rubrique de commentaire"
namePlural="rubriques de commentaire">
/trunk/OpenConcerto/src/org/openconcerto/erp/config/update/Updater_1_5.java
14,6 → 14,7
package org.openconcerto.erp.config.update;
 
import org.openconcerto.erp.config.InstallationPanel;
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplateSQLElement;
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
39,7 → 40,6
import org.openconcerto.sql.model.SQLSyntax;
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.SQLTable.Index;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.UpdateBuilder;
370,7 → 370,7
if (!tableCmdFElt.contains("RECU")) {
AlterTable t = new AlterTable(tableCmdFElt);
t.addBooleanColumn("RECU_FORCED", Boolean.FALSE, false);
t.addBooleanColumn("RECU", Boolean.TRUE, false);
t.addBooleanColumn("RECU", Boolean.FALSE, false);
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
tableCmdFElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableCmdFElt.getName());
398,6 → 398,26
System.err.println(build.asString());
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
}
} else {
// Fix bad default value
String defaultValue = tableCmdFElt.getField("RECU").getDefaultValue();
if (defaultValue != null && defaultValue.equals("true")) {
AlterTable t = new AlterTable(tableCmdFElt);
t.alterColumn("RECU", EnumSet.allOf(Properties.class), "boolean", "false", false);
tableCmdFElt.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableCmdFElt.getName());
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"));
build.setWhere(w.or(new Where(tableCmdFElt.getKey(), "=", 1)));
System.err.println(build.asString());
tableCmdFElt.getDBSystemRoot().getDataSource().execute(build.asString());
}
 
}
 
// Champ matière
805,6 → 825,16
 
}
 
if (!tableFpaye.contains("CSG_REDUITE")) {
final AlterTable alterB = new AlterTable(tableFpaye);
alterB.addDecimalColumn("CSG_REDUITE", 16, 2, BigDecimal.ZERO, false);
alterB.addDecimalColumn("SAL_BRUT_CSG", 16, 2, BigDecimal.ZERO, false);
alterB.addDecimalColumn("SAL_BRUT_CSG_REDUITE", 16, 2, BigDecimal.ZERO, false);
root.getBase().getDataSource().execute(alterB.asString());
root.refetchTable("FICHE_PAYE");
root.getSchema().updateVersion();
}
 
SQLTable tableCpaye = root.findTable("CUMULS_PAYE");
if (!tableCpaye.contains("TAXE_CM_SAL_C")) {
final AlterTable alterB = new AlterTable(tableCpaye);
873,6 → 903,13
tableArticle.getSchema().updateVersion();
tableArticle.fetchFields();
}
if (!tableArticle.contains("DLC")) {
final AlterTable alterArticle = new AlterTable(tableArticle);
alterArticle.addColumn("DLC", "date");
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
tableArticle.getSchema().updateVersion();
tableArticle.fetchFields();
}
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
if (!tableFournisseur.contains("NUMERO_TVA")) {
final AlterTable alter = new AlterTable(tableFournisseur);
1035,14 → 1072,19
root.getSchema().updateVersion();
}
 
if (!tableVarSal.contains("IJSS_BRUT")) {
final AlterTable alterB = new AlterTable(tableVarSal);
List<String> f = Arrays.asList("IJSS_BRUT", "IJSS_NET", "FRAIS_PRO", "RBT_TRANSPORT");
for (String field : f) {
alterB.addColumn(field, "real DEFAULT 0");
alterB.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
boolean upVar = false;
List<String> f = Arrays.asList("IJSS_BRUT", "IJSS_NET", "FRAIS_PRO", "RBT_TRANSPORT", "HEURE_CHOM", "TAUX_CHOM", "HEURE_INDEM", "ECRETEMENT_CSG", "IJSS_BRUT_SECU_PAS");
final AlterTable alterVarSal = new AlterTable(tableVarSal);
for (String field : f) {
if (!tableVarSal.contains(field)) {
upVar = true;
alterVarSal.addColumn(field, "real DEFAULT 0");
alterVarSal.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
alterVarSal.addColumn(field + "_CUMUL_VAL", "real DEFAULT 0");
}
root.getBase().getDataSource().execute(alterB.asString());
}
if (upVar) {
root.getBase().getDataSource().execute(alterVarSal.asString());
root.refetchTable(tableVarSal.getName());
root.getSchema().updateVersion();
}
1136,6 → 1178,22
table.fetchFields();
}
 
if (!table.getFieldsName().contains("ID_JOURNAL_CB_ATTENTE")) {
AlterTable t = new AlterTable(table);
t.addForeignColumn("ID_JOURNAL_CB_ATTENTE", root.getTable("JOURNAL"));
table.getBase().getDataSource().execute(t.asString());
table.getSchema().updateVersion();
table.fetchFields();
}
 
if (!table.getFieldsName().contains("ID_COMPTE_PCE_CB_ATTENTE")) {
AlterTable t = new AlterTable(table);
t.addForeignColumn("ID_COMPTE_PCE_CB_ATTENTE", root.getTable("COMPTE_PCE"));
table.getBase().getDataSource().execute(t.asString());
table.getSchema().updateVersion();
table.fetchFields();
}
 
if (!table.getFieldsName().contains("AUTO_LETTRAGE")) {
AlterTable t = new AlterTable(table);
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
1904,7 → 1962,29
root.refetchTable(tableContrat.getName());
root.getSchema().updateVersion();
}
if (!tableContrat.contains("SPECTACLE_OBJET")) {
AlterTable t = new AlterTable(tableContrat);
t.addVarCharColumn("SPECTACLE_OBJET", 54);
tableContrat.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableContrat.getName());
root.getSchema().updateVersion();
}
 
if (!tableContrat.contains("SPECTACLE_OBJET")) {
AlterTable t = new AlterTable(tableContrat);
t.addVarCharColumn("SPECTACLE_OBJET", 54);
tableContrat.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableContrat.getName());
root.getSchema().updateVersion();
}
if (!tableContrat.contains("SPECTACLE_JOUR_CONTRAT")) {
AlterTable t = new AlterTable(tableContrat);
t.addDecimalColumn("SPECTACLE_JOUR_CONTRAT", 16, 2, null, true);
tableContrat.getBase().getDataSource().execute(t.asString());
root.refetchTable(tableContrat.getName());
root.getSchema().updateVersion();
}
 
List<String> tablesCatComptable = Arrays.asList("DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT");
for (String tableToUp : tablesCatComptable) {
final SQLTable tableCatComptToAdd = root.getTable(tableToUp);
1937,7 → 2017,7
}
// Force undefined policy to inDb
root.setMetadata(SQLTable.UNDEFINED_ID_POLICY, "inDB");
final Map<String, Number> mapTableNameUndefined = SQLTable.getUndefIDs(root.getSchema());
final Map<String, Number> mapTableNameUndefined = SQLTable.getUndefinedIDs(root.getSchema());
final Set<String> tables = root.getSchema().getTableNames();
for (String tName : tables) {
if (!mapTableNameUndefined.containsKey(tName)) {
2006,7 → 2086,206
root.refetchTable(tableSalarie.getName());
root.getSchema().updateVersion();
}
boolean upDimensionArt = false;
 
final AlterTable alterDimensionArt = new AlterTable(tableArt);
if (!tableArt.contains("LONGUEUR")) {
alterDimensionArt.addDecimalColumn("LONGUEUR", 16, 8, null, true);
upDimensionArt = true;
}
if (!tableArt.contains("LARGEUR")) {
alterDimensionArt.addDecimalColumn("LARGEUR", 16, 8, null, true);
upDimensionArt = true;
}
if (!tableArt.contains("HAUTEUR")) {
alterDimensionArt.addDecimalColumn("HAUTEUR", 16, 8, null, true);
upDimensionArt = true;
}
if (upDimensionArt) {
tableArt.getBase().getDataSource().execute(alterDimensionArt.asString());
tableArt.getSchema().updateVersion();
tableArt.fetchFields();
}
 
List<String> tableElementWithTable = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "DEVIS_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT",
"BON_DE_LIVRAISON_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", "AVOIR_CLIENT_ELEMENT", "DEMANDE_PRIX_ELEMENT");
for (String tableName : tableElementWithTable) {
final SQLTable tableToAddDimension = root.getTable(tableName);
boolean upDimensionArtItem = false;
 
final AlterTable alterDimensionArtItem = new AlterTable(tableToAddDimension);
if (!tableToAddDimension.contains("LONGUEUR")) {
alterDimensionArtItem.addDecimalColumn("LONGUEUR", 16, 8, null, true);
upDimensionArtItem = true;
}
if (!tableToAddDimension.contains("LARGEUR")) {
alterDimensionArtItem.addDecimalColumn("LARGEUR", 16, 8, null, true);
upDimensionArtItem = true;
}
if (!tableToAddDimension.contains("HAUTEUR")) {
alterDimensionArtItem.addDecimalColumn("HAUTEUR", 16, 8, null, true);
upDimensionArtItem = true;
}
if (upDimensionArtItem) {
tableToAddDimension.getBase().getDataSource().execute(alterDimensionArtItem.asString());
tableToAddDimension.getSchema().updateVersion();
tableToAddDimension.fetchFields();
}
}
 
if (!tTva.contains("DEFAULT_ACHAT")) {
final AlterTable alterTaxe = new AlterTable(tTva);
alterTaxe.addBooleanColumn("DEFAULT_ACHAT", Boolean.FALSE, false);
tTva.getBase().getDataSource().execute(alterTaxe.asString());
tTva.getSchema().updateVersion();
tTva.fetchFields();
}
SQLTable tableTypeRglt = root.getTable("TYPE_REGLEMENT");
if (!tableTypeRglt.contains("SEPA")) {
final AlterTable alterTaxe = new AlterTable(tableTypeRglt);
alterTaxe.addBooleanColumn("SEPA", Boolean.FALSE, false);
tableTypeRglt.getBase().getDataSource().execute(alterTaxe.asString());
tableTypeRglt.getSchema().updateVersion();
tableTypeRglt.fetchFields();
UpdateBuilder upSEPA = new UpdateBuilder(tableTypeRglt);
upSEPA.setObject("SEPA", Boolean.TRUE);
upSEPA.setObject("ECHEANCE", Boolean.TRUE);
upSEPA.setWhere(new Where(tableTypeRglt.getField("NOM"), "=", "Prélèvement"));
tTva.getBase().getDataSource().execute(upSEPA.asString());
}
 
SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
if (!tableEch.contains("ID_SEPA_MANDATE")) {
 
final AlterTable alterEch = new AlterTable(tableEch);
alterEch.addForeignColumn("ID_SEPA_MANDATE", root.getTable("SEPA_MANDATE"));
alterEch.addForeignColumn("ID_SDD_MESSAGE", root.getTable(SDDMessageSQLElement.TABLE_NAME));
alterEch.addVarCharColumn("SDD_EndToEndId", 35);
alterEch.addBooleanColumn("FICHIER_CREE", Boolean.FALSE, false);
alterEch.addBooleanColumn("REJETER", Boolean.FALSE, false);
alterEch.addVarCharColumn("ETS", 256);
alterEch.addForeignColumn("ID_" + BanqueSQLElement.TABLENAME, root.getTable(BanqueSQLElement.TABLENAME));
tableEch.getBase().getDataSource().execute(alterEch.asString());
tableEch.getSchema().updateVersion();
tableEch.fetchFields();
 
}
if (!tClient.contains("ID_SEPA_MANDATE_DEFAULT")) {
final AlterTable alterClient = new AlterTable(tClient);
alterClient.addForeignColumn("ID_SEPA_MANDATE_DEFAULT", root.getTable("SEPA_MANDATE"));
tClient.getBase().getDataSource().execute(alterClient.asString());
tClient.getSchema().updateVersion();
tClient.fetchFields();
}
 
if (!tableArt.contains("AUTO_PRIX_MIN_VENTE_NOMENCLATURE")) {
final AlterTable alter = new AlterTable(tableArt);
alter.addBooleanColumn("AUTO_PRIX_MIN_VENTE_NOMENCLATURE", Boolean.FALSE, false);
tableArt.getBase().getDataSource().execute(alter.asString());
tableArt.getSchema().updateVersion();
tableArt.fetchFields();
}
if (!tableArt.contains("DERNIER_DATE_ACHAT")) {
final AlterTable alter = new AlterTable(tableArt);
alter.addColumn("DERNIER_DATE_ACHAT", "date");
tableArt.getBase().getDataSource().execute(alter.asString());
tableArt.getSchema().updateVersion();
tableArt.fetchFields();
ReferenceArticleSQLElement.updateDateAchat(tableArt, null);
}
 
SQLTable tableFactF = root.getTable("FACTURE_FOURNISSEUR");
if (!tableFactF.contains("DATE_REGLEMENT")) {
final AlterTable alter = new AlterTable(tableFactF);
alter.addColumn("DATE_REGLEMENT", "date");
tableFactF.getBase().getDataSource().execute(alter.asString());
tableFactF.getSchema().updateVersion();
tableFactF.fetchFields();
}
 
SQLTable tableEchF = root.getTable("ECHEANCE_FOURNISSEUR");
if (!tableEchF.contains("ID_FACTURE_FOURNISSEUR")) {
final AlterTable alter = new AlterTable(tableEchF);
alter.addForeignColumn("ID_FACTURE_FOURNISSEUR", tableFactF);
tableEchF.getBase().getDataSource().execute(alter.asString());
tableEchF.getSchema().updateVersion();
tableEchF.fetchFields();
}
 
List<String> achatItems = Arrays.asList("DEMANDE_PRIX_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "FACTURE_FOURNISSEUR_ELEMENT");
for (String string : achatItems) {
boolean alter = false;
SQLTable tableItems = root.getTable(string);
final AlterTable t = new AlterTable(tableItems);
 
if (!tableItems.getFieldsName().contains("POIDS_COLIS_NET")) {
t.addColumn("POIDS_COLIS_NET", "numeric (16,8) DEFAULT 1");
alter = true;
}
 
if (!tableItems.getFieldsName().contains("T_POIDS_COLIS_NET")) {
t.addColumn("T_POIDS_COLIS_NET", "numeric (16,8) DEFAULT 1");
alter = true;
}
 
if (!tableItems.getFieldsName().contains("NB_COLIS")) {
t.addColumn("NB_COLIS", "integer DEFAULT 0");
alter = true;
}
if (alter) {
tableItems.getBase().getDataSource().execute(t.asString());
tableItems.getSchema().updateVersion();
tableItems.fetchFields();
}
}
 
for (String tableName : tableElementWithTable) {
final SQLTable tableToAddTare = root.getTable(tableName);
boolean upTareArtItem = false;
 
final AlterTable alterTareArtItem = new AlterTable(tableToAddTare);
if (!tableToAddTare.contains("TARE")) {
alterTareArtItem.addDecimalColumn("TARE", 16, 8, null, true);
alterTareArtItem.alterColumn("POIDS_COLIS_NET", EnumSet.allOf(Properties.class), "numeric(16,8)", "0", true);
alterTareArtItem.alterColumn("T_POIDS_COLIS_NET", EnumSet.allOf(Properties.class), "numeric(16,8)", "0", true);
 
alterTareArtItem.addDecimalColumn("T_POIDS_BRUT", 16, 8, BigDecimal.ZERO, true);
 
upTareArtItem = true;
}
 
if (upTareArtItem) {
tableToAddTare.getBase().getDataSource().execute(alterTareArtItem.asString());
tableToAddTare.getSchema().updateVersion();
tableToAddTare.fetchFields();
 
int id = tableToAddTare.getUndefinedID();
if (id != SQLRow.NONEXISTANT_ID) {
UpdateBuilder build = new UpdateBuilder(tableToAddTare);
build.setObject("POIDS_COLIS_NET", BigDecimal.ZERO);
build.setWhere(new Where(tableToAddTare.getKey(), "=", id));
tableToAddTare.getDBSystemRoot().getDataSource().execute(build.asString());
}
}
}
 
// Fix nb char MOUVEMENT_STOCK.NOM
if (tableMvtStock.getField("NOM").getType().getSize() == 45) {
AlterTable alterMvt = new AlterTable(tableMvtStock);
alterMvt.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(512)", "''", false);
tableMvtStock.getDBSystemRoot().getDataSource().execute(alterMvt.asString());
tableMvtStock.getSchema().updateVersion();
}
 
SQLTable tableEtatStock = root.getTable("ETAT_STOCK");
SQLTable tableDepotStock = root.getTable("DEPOT_STOCK");
if (!tableEtatStock.contains("ID_DEPOT_STOCK")) {
final AlterTable alter = new AlterTable(tableEtatStock);
alter.addForeignColumn("ID_DEPOT_STOCK", tableDepotStock);
tableEtatStock.getBase().getDataSource().execute(alter.asString());
tableEtatStock.getSchema().updateVersion();
tableEtatStock.fetchFields();
}
}
 
public static void initStock(SQLRow rowArticle, int idDepot) {
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_es.xml
59,7 → 59,7
<FIELD name="ID_ADRESSE_COURRIER_2" label="Dirección de correo 2" />
<FIELD name="ID_ADRESSE_COURRIER_3" label="Dirección de correo 3" />
</element>
<element refid="controle.AffaireElementSQLElement.project.item" nameClass="feminine"
<element refid="controle.project.item" nameClass="feminine"
name="mission de l'affaire" namePlural="missions de l'affaire">
<FIELD name="FIN_CONTRAT" label="Fin de contrato" />
<FIELD name="DATE_FIN_CONTRAT" label="Fecha de fin de contrato" />
1455,7 → 1455,7
namePlural="états de demande d'achat">
<FIELD name="NOM" label="Estado" />
</element>
<element refid="controle.EtatRapportSQLElement.report.state" nameClass="masculine" name="état rapport"
<element refid="controle.report.state" nameClass="masculine" name="état rapport"
namePlural="états rapports">
<FIELD name="NOM" label="Etat du rapport" titlelabel="Estado del informe" />
</element>
1640,7 → 1640,7
<FIELD name="IN_PERIODE" label="En el periodo" />
<FIELD name="ID_FICHE_PAYE" label="Recibo de nómina" />
</element>
<element refid="controle.FicheRendezVousSQLElement.appointment.form" nameClass="feminine"
<element refid="controle.appointment.form" nameClass="feminine"
name="fiche de prise de rendez-vous" namePlural="fiches de prise de rendez-vous">
<FIELD name="DATE" label="Fecha de creación" />
<FIELD name="ID_VERIFICATEUR" label="Piloto" />
1661,7 → 1661,7
<FIELD name="ID_POLE_PRODUIT" label="Polo producto" />
<FIELD name="VALID" label="Validar por el responsable" />
</element>
<element refid="controle.FicheRdvItemSQLElement.appointment.form.item" nameClass="masculine"
<element refid="controle.appointment.form.item" nameClass="masculine"
name="element de fiche" namePlural="éléments de fiche">
<FIELD name="ECHEANCE_RAPPORT" label="Plazo entrega informe en día" />
<FIELD name="DATE" label="Fecha" />
1869,7 → 1869,7
<FIELD name="CHIFFRE_AFFAIRE" label="Volumen de negocios" />
<FIELD name="ID_COMMERCIAL" label="Vendedor" />
</element>
<element refid="controle.OrdreMissionSQLElement.mission.note" nameClass="masculine" name="ordre de mission"
<element refid="controle.mission.note" nameClass="masculine" name="ordre de mission"
namePlural="ordres de mission">
<FIELD name="ID_VERIFICATEUR" label="Verificador" />
<FIELD name="ID_FICHE_RENDEZ_VOUS" label="Ficha de cita" />
1891,7 → 1891,7
<TABLE name="POCHETTE">
<FIELD name="CODE" label="Sobre" />
</TABLE>
<element refid="controle.PoleProduitSQLElement.product.pole" nameClass="masculine" name="pôle produit"
<element refid="controle.product.pole" nameClass="masculine" name="pôle produit"
namePlural="pôles produit">
<FIELD name="CODE" label="Código Polo producto" />
<FIELD name="NOM" label="Nombre" />
1954,7 → 1954,7
<FIELD name="DATE_CONFIRM" label="Fecha de confirmación" />
<FIELD name="CCI" label="CCI" />
</element>
<element refid="controle.PropositionElementSQLElement.proposal.item" nameClass="feminine"
<element refid="controle.proposal.item" nameClass="feminine"
name="mission d'une proposition" namePlural="missions par propositions">
<FIELD name="ID_PROPOSITION" label="Propuesta" />
<FIELD name="FIN_CONTRAT" label="Fin de contrato" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/InstallationPanel.java
3239,7 → 3239,9
List<String> cols = Arrays.asList("PV_HT", "PA_DEVISE_T", "T_PV_HT", "T_PA_TTC", "T_PA_HT", "PA_HT", "T_PV_TTC", "PRIX_METRIQUE_HA_2", "PRIX_METRIQUE_HA_1", "PRIX_METRIQUE_HA_3",
"PRIX_METRIQUE_VT_2", "PRIX_METRIQUE_VT_1", "MONTANT_HT", "MONTANT_INITIAL", "PRIX_METRIQUE_VT_3", "MARGE_HT", "PA_DEVISE", "PV_U_DEVISE", "PV_T_DEVISE", "PV_TTC", "TARIF_Q18_HT",
"T_PRIX_FINAL_TTC", "PRIX_FINAL_TTC", "PV_UNIT_HT", "PREBILAN", "MARGE_PREBILAN_HT");
 
if (table == null) {
return;
}
if ((table.contains("PV_HT") && table.getField("PV_HT").getType().getDecimalDigits() == 0)
|| (table.contains("PV_UNIT_HT") && table.getField("PV_UNIT_HT").getType().getDecimalDigits() == 0)) {
AlterTable t = new AlterTable(table);
4011,7 → 4013,7
new AddFK(root.getDBSystemRoot()).changeAll(root);
 
// Couleur
final SQLTable tableUser = root.getTable("USER_COMMON");
final SQLTable tableUser = root.findTable("USER_COMMON");
if (!tableUser.contains("COLOR")) {
final AlterTable alter = new AlterTable(tableUser);
alter.addIntegerColumn("COLOR", 0, false);
/trunk/OpenConcerto/src/org/openconcerto/erp/config/DSNInstallationUtils.java
272,6 → 272,21
root.getSchema().updateVersion();
}
 
if (!tableRubBrut.contains("CSG_NORMAL")) {
AlterTable alterTableBrut = new AlterTable(tableRubBrut);
alterTableBrut.addBooleanColumn("CSG_NORMAL", Boolean.TRUE, false);
root.getBase().getDataSource().execute(alterTableBrut.asString());
root.refetchTable("RUBRIQUE_BRUT");
root.getSchema().updateVersion();
}
if (!tableRubBrut.contains("CSG_REDUIT")) {
AlterTable alterTableBrut = new AlterTable(tableRubBrut);
alterTableBrut.addBooleanColumn("CSG_REDUIT", Boolean.FALSE, false);
root.getBase().getDataSource().execute(alterTableBrut.asString());
root.refetchTable("RUBRIQUE_BRUT");
root.getSchema().updateVersion();
}
 
SQLTable tableRubNet = root.getTable("RUBRIQUE_NET");
if (!tableRubNet.contains("ID_CODE_TYPE_RUBRIQUE_BRUT")) {
 
543,6 → 558,134
}
}
 
if (!root.contains("CODE_AMENAGEMENT_PARTIEL")) {
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CODE_AMENAGEMENT_PARTIEL");
createTableMotif.addVarCharColumn("CODE", 25);
createTableMotif.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableMotif.asString());
insertUndef(createTableMotif);
root.refetchTable("CODE_AMENAGEMENT_PARTIEL");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("CODE_AMENAGEMENT_PARTIEL");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
 
v.add(Tuple2.create("01", "Forfait hebdomadaire"));
v.add(Tuple2.create("02", "Autre temps de travail hebdomadaire"));
v.add(Tuple2.create("03", "Equivalent à 35h - 39h (Mayotte)"));
v.add(Tuple2.create("04", "Forfait mensuel"));
v.add(Tuple2.create("05", "Forfait annuel en jour"));
v.add(Tuple2.create("06", "Forfait annuel en heures"));
v.add(Tuple2.create("07", "Cycle"));
v.add(Tuple2.create("08", "Modulation"));
v.add(Tuple2.create("09", "Aménagement du temps de travail (Loi du 20 août 2008)"));
v.add(Tuple2.create("10", "Personnel navigant ou autres"));
 
insertValues(v, table);
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_AMENAGEMENT_PARTIEL", ex);
}
}
 
if (!root.contains("CODE_SUSPENSION")) {
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CODE_SUSPENSION");
createTableMotif.addVarCharColumn("CODE", 25);
createTableMotif.addVarCharColumn("NOM", 512);
 
try {
root.getBase().getDataSource().execute(createTableMotif.asString());
insertUndef(createTableMotif);
root.refetchTable("CODE_SUSPENSION");
root.getSchema().updateVersion();
 
final SQLTable table = root.getTable("CODE_SUSPENSION");
List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
 
v.add(Tuple2.create("112", "Invalidité catégorie 1"));
v.add(Tuple2.create("114", "Invalidité catégorie 2"));
v.add(Tuple2.create("116", "Invalidité catégorie 3"));
v.add(Tuple2.create("200", "COP (Congés payés)"));
v.add(Tuple2.create("301", "Congé de Formation Professionnelle"));
v.add(Tuple2.create("501", "Congé divers non rémunéré"));
v.add(Tuple2.create("507", "Chômage intempéries"));
v.add(Tuple2.create("601", "Mobilité volontaire sécurisée"));
v.add(Tuple2.create("602", "Chômage sans rupture de contrat"));
v.add(Tuple2.create("603", "Détention provisoire"));
v.add(Tuple2.create("604", "Journée de perception de l'allocation journalière de présence parentale"));
v.add(Tuple2.create("605", "Congé statutaire"));
v.add(Tuple2.create("606", "Détachement d'un salarié IEG en France"));
v.add(Tuple2.create("607", "Congé de présence parentale"));
v.add(Tuple2.create("608", "CASA"));
v.add(Tuple2.create("609", "CIF (Congé Individuel de Formation)"));
v.add(Tuple2.create("611", "Congé de bilan de compétences"));
v.add(Tuple2.create("612", "Congé de candidat parlementaire ou élu à un mandat local"));
v.add(Tuple2.create("615", "Congé de formation de cadres et d'animateurs pour la jeunesse"));
v.add(Tuple2.create("617", "Congé de formation pour les salariés de moins de 25 ans"));
v.add(Tuple2.create("618", "Congé de formation économique, sociale et syndicale"));
v.add(Tuple2.create("620", "Congé de mobilité"));
v.add(Tuple2.create("621", "Congé de participation aux instances d'emploi ou de formation professionnelle"));
v.add(Tuple2.create("625", "Congé de reclassement"));
v.add(Tuple2.create("626", "Congé de représentation"));
v.add(Tuple2.create("627", "Congé de solidarité familiale"));
v.add(Tuple2.create("628", "Congé de solidarité internationale"));
v.add(Tuple2.create("630", "Congé d'enseignement ou de recherche"));
v.add(Tuple2.create("631", "Congé mutualiste de formation"));
v.add(Tuple2.create("632", "Congé parental d'éducation"));
v.add(Tuple2.create("633", "Congé pour acquisition de la nationalité"));
v.add(Tuple2.create("634", "Congé pour catastrophe naturelle"));
v.add(Tuple2.create("635", "Congé pour création ou reprise d'entreprise"));
v.add(Tuple2.create("636", "Congé pour enfant malade"));
v.add(Tuple2.create("637", "Congé pour évènement familial"));
v.add(Tuple2.create("638", "Congé pour validation des acquis de l'expérience"));
v.add(Tuple2.create("639", "Congé sabbatique"));
v.add(Tuple2.create("642", "Convention FNE d'aide au passage à temps partiel"));
v.add(Tuple2.create("643", "Congé de conversion avec prise en charge par l'Etat"));
v.add(Tuple2.create("644", "Congé de conversion sans prise en charge par l'Etat"));
v.add(Tuple2.create("645", "Préretraite progressive"));
v.add(Tuple2.create("646", "Préretraite d'entreprise sans rupture de contrat de travail"));
v.add(Tuple2.create("647", "Réduction temps d'emploi"));
v.add(Tuple2.create("648", "Conventions d'Allocations Spéciales du FNE (ASFNE)"));
v.add(Tuple2.create("650", "Congé de proche aidant"));
v.add(Tuple2.create("651", "Congé pour mandat parlementaire"));
v.add(Tuple2.create("652", "Inaptitude temporaire liée à la grossesse"));
v.add(Tuple2.create("653", "Maintien de salaire – personnel navigant de l’aéronautique civile"));
v.add(Tuple2.create("654", "Inactivité temps alterné – personnel navigant de l’aéronautique civile"));
v.add(Tuple2.create("655", "[FP] Détachement conduisant à pension (ECP)"));
v.add(Tuple2.create("656", "[FP] Congé pour cessation anticipée d’activité du fait d’une maladie professionnelle provoquée par l’amiante"));
v.add(Tuple2.create("657", "[FP] Absence concertée de travail"));
v.add(Tuple2.create("658", "[FP] Congé spécial"));
v.add(Tuple2.create("659", "[FP] Période d'instruction militaire ou réserve opérationnelle"));
v.add(Tuple2.create("660", "[FP] Congé avec traitement période d'instruction militaire obligatoire"));
v.add(Tuple2.create("661", "[FP] Congé organisations de jeunesse"));
v.add(Tuple2.create("662", "[FP] Congé pour siéger auprès d’une association, d’une mutuelle, d’une instance de l’Etat ou d’une collectivité territoriale"));
v.add(Tuple2.create("663", "[FP] Congé non rémunéré de 18 jours pour mandats municipaux ou départementaux ou régionaux"));
v.add(Tuple2.create("664", "[FP] Congé avec traitement pour période d'activité dans la réserve de sécurité civile"));
v.add(Tuple2.create("665", "[FP] Congé pour période d'activité dans la réserve sanitaire"));
v.add(Tuple2.create("666", "[FP] Congé pour recherches ou conversions thématiques"));
v.add(Tuple2.create("667", "[FP] Congé pour raisons opérationnelles et activités privées des sapeurs"));
v.add(Tuple2.create("668", "[FP] Congé pour raisons opérationnelles cotisé des sapeurs"));
v.add(Tuple2.create("669", "[FP] Congé pour difficultés opérationnelles des sapeurs"));
v.add(Tuple2.create("670", "[FP] Congé pour période d'activité dans la réserve civile de la police"));
v.add(Tuple2.create("671", "[FP] Exclusion temporaire de fonctions"));
v.add(Tuple2.create("672", "[FP] Suspension"));
v.add(Tuple2.create("673", "[FP] Absences irrégulières (service non fait)"));
v.add(Tuple2.create("674", "[FP] Détachement ne conduisant pas à pension (ENCP)"));
v.add(Tuple2.create("675", "[FP] Disponibilité"));
v.add(Tuple2.create("676", "[FP] Disponibilité pour maladie"));
v.add(Tuple2.create("677", "[FP] Disponibilité pour élever un enfant âgé de moins de 8 ans"));
v.add(Tuple2.create("678", "[FP] Position hors cadres"));
v.add(Tuple2.create("680", "Congé sans solde cotisés"));
v.add(Tuple2.create("681", "Détachement hors IEG"));
v.add(Tuple2.create("998", "Annulation"));
 
insertValues(v, table);
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_SUSPENSION", ex);
}
}
 
if (!root.contains("MOTIF_REPRISE_ARRET_TRAVAIL")) {
final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_REPRISE_ARRET_TRAVAIL");
createTableMotif.addVarCharColumn("CODE", 25);
1189,6 → 1332,7
List<Tuple2<String, String>> vCTP = new ArrayList<>();
vCTP.add(Tuple2.create("003", "Réduction cotisations salariale heures supplémentaires"));
vCTP.add(Tuple2.create("510", "Prime exceptionnelle de pouvoir d’achat"));
vCTP.add(Tuple2.create("060", "RR Chômage CSG-CRDS taux plein"));
insertValues(vCTP, tableCTP);
 
final SQLTable tableTypeBrut = root.getTable("CODE_TYPE_RUBRIQUE_BRUT");
1196,6 → 1340,8
vbrutType.add(Tuple3.create("016", "[FP] Heures affectées à un travail d’aide à domicile", DsnTypeCodeBrut.REMUNERATION.getName()));
vbrutType.add(Tuple3.create("017", "Heures supplémentaires ou complémentaires aléatoires", DsnTypeCodeBrut.REMUNERATION.getName()));
vbrutType.add(Tuple3.create("018", "Heures supplémentaires structurelles", DsnTypeCodeBrut.REMUNERATION.getName()));
vbrutType.add(Tuple3.create("019", "Heures d'activité partielle", DsnTypeCodeBrut.REMUNERATION.getName()));
vbrutType.add(Tuple3.create("020", "Heures affectées à un travail d’aide à domicile de publics fragiles", DsnTypeCodeBrut.REMUNERATION.getName()));
DsnBrutCode dsnBurCode = new DsnBrutCode();
dsnBurCode.updateTable(vbrutType, tableTypeBrut);
 
1488,7 → 1634,24
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
if (!tableContrat.contains("ID_CODE_AMENAGEMENT_PARTIEL")) {
updateContrat = true;
AlterTable alter = new AlterTable(tableContrat);
alter.addForeignColumn("ID_CODE_AMENAGEMENT_PARTIEL", root.findTable("CODE_AMENAGEMENT_PARTIEL"));
alter.addColumn("DATE_DEBUT_SUSPENSION", "date");
alter.addColumn("DATE_FIN_SUSPENSION", "date");
root.getBase().getDataSource().execute(alter.asString());
root.getSchema().updateVersion();
}
 
if (!tableContrat.contains("ID_CODE_SUSPENSION")) {
updateContrat = true;
AlterTable alter = new AlterTable(tableContrat);
alter.addForeignColumn("ID_CODE_SUSPENSION", root.findTable("CODE_SUSPENSION"));
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
89,6 → 89,7
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseModePaiementSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ClassementConventionnelSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeAmenagementPartielSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeBaseAssujettieSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCaisseTypeRubriqueSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCaractActiviteSQLElement;
104,6 → 105,7
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutCategorielConventionnelSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutCategorielSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutProfSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeSuspensionSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CodeTypeRubriqueBrutSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.CoefficientPrimeSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.ContratDetacheExpatrieSQLElement;
235,7 → 237,12
import org.openconcerto.erp.generationDoc.provider.DateBLProvider;
import org.openconcerto.erp.generationDoc.provider.DateProvider;
import org.openconcerto.erp.generationDoc.provider.FacturableValueProvider;
import org.openconcerto.erp.generationDoc.provider.FichePayeHeureSupTotalProvider;
import org.openconcerto.erp.generationDoc.provider.FichePayeHeureTotalProvider;
import org.openconcerto.erp.generationDoc.provider.FichePayePlafondAProvider;
import org.openconcerto.erp.generationDoc.provider.FichePayeSmicHProvider;
import org.openconcerto.erp.generationDoc.provider.FormatedGlobalQtyTotalProvider;
import org.openconcerto.erp.generationDoc.provider.IbanProvider;
import org.openconcerto.erp.generationDoc.provider.LabelAccountInvoiceProvider;
import org.openconcerto.erp.generationDoc.provider.MergedGlobalQtyTotalProvider;
import org.openconcerto.erp.generationDoc.provider.ModeDeReglementDetailsProvider;
296,6 → 303,7
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.erp.storage.CloudStorageEngine;
import org.openconcerto.erp.storage.StorageEngines;
import org.openconcerto.erp.utils.TM;
import org.jopendocument.link.OOConnexion;
import org.openconcerto.sql.ShowAs;
import org.openconcerto.sql.element.SQLElement;
579,6 → 587,10
}
}
 
public final TM getERP_TM() {
return TM.getERP_TM(this.getLocale());
}
 
private void registerAccountingProvider() {
SalesInvoiceAccountingRecordsProvider.register();
SalesCreditAccountingRecordsProvider.register();
610,6 → 622,10
RefClientValueProvider.register();
ModeDeReglementDetailsProvider.register();
FormatedGlobalQtyTotalProvider.register();
FichePayeHeureSupTotalProvider.register();
FichePayeHeureTotalProvider.register();
FichePayePlafondAProvider.register();
FichePayeSmicHProvider.register();
MergedGlobalQtyTotalProvider.register();
PaiementRemainedProvider.register();
PaiementRemainedDevisProvider.register();
620,6 → 636,7
RestantAReglerProvider.register();
SaledTotalNotDiscountedProvider.register();
ArticleCodeFournisseurProvider.register();
IbanProvider.register();
}
 
@Override
628,6 → 645,7
ds.setInitialSize(3);
ds.setMinIdle(2);
ds.setMaxActive(4);
ds.setMaxWait(30000);
}
 
public String getToken() {
766,6 → 784,8
dir.addSQLElement(TypePreavisSQLElement.class, root);
dir.addSQLElement(DSNNatureSQLElement.class, root);
dir.addSQLElement(TypeTauxPasSQLElement.class, root);
dir.addSQLElement(CodeAmenagementPartielSQLElement.class, root);
dir.addSQLElement(CodeSuspensionSQLElement.class, root);
 
// ECO
dir.addSQLElement(FamilleEcoContributionSQLElement.class, root);
1112,12 → 1132,6
final DBRoot root = this.getRootSociete();
showAs.setRoot(getRootSociete());
 
List<String> listAdrShowAs = SQLRow.toList("RUE,CODE_POSTAL,VILLE");
if (root.contains("ADRESSE") && root.getTable("ADRESSE").contains("DISTRICT")) {
listAdrShowAs = SQLRow.toList("RUE,DISTRICT,DEPARTEMENT,CODE_POSTAL,VILLE");
}
showAs.show("ADRESSE", listAdrShowAs);
 
showAs.show("AXE_ANALYTIQUE", "NOM");
 
List<String> lEcr = new ArrayList<String>();
1208,10 → 1222,11
final SQLElementDirectory directory = this.getDirectory();
showAs.show("REPARTITION_ANALYTIQUE", "NOM");
showAs.show("REGIME_BASE", "ID_CODE_REGIME_BASE");
showAs.show("REGLEMENT_PAYE", "NOM_BANQUE", "RIB");
showAs.show("REGLEMENT_PAYE", "NOM_BANQUE", "IBAN", "BIC");
 
List<String> listFieldModReglMontant = new ArrayList<String>();
listFieldModReglMontant.add("ID_TYPE_REGLEMENT");
listFieldModReglMontant.add("ID_" + BanqueSQLElement.TABLENAME);
 
showAs.showField("REGLER_MONTANT.ID_MODE_REGLEMENT", listFieldModReglMontant);
showAs.showField("ENCAISSER_MONTANT.ID_MODE_REGLEMENT", listFieldModReglMontant);
/trunk/OpenConcerto/src/org/openconcerto/erp/config/MainFrame.java
13,7 → 13,6
package org.openconcerto.erp.config;
 
import org.openconcerto.erp.action.AboutAction;
import org.openconcerto.erp.core.common.ui.StatusPanel;
import org.openconcerto.erp.panel.UserExitConf;
import org.openconcerto.erp.panel.UserExitPanel;
319,6 → 318,10
fg = new Color(200, 65, 95);
} else {
action = mngrAction;
// Allow to leave the name blank at action creation, then set it here so that it can be
// used in actionPerformed()
if (mngrActionName == null)
action.putValue(Action.NAME, label);
fg = label.equals(id) ? new Color(20, 65, 200) : null;
}
 
404,7 → 407,7
}
 
public final void about() {
AboutAction.getInstance().actionPerformed(null);
MenuManager.getInstance().getActionForId("information").actionPerformed(null);
}
 
public boolean quit() {
/trunk/OpenConcerto/src/org/openconcerto/erp/config/DefaultMenuConfiguration.java
39,6 → 39,7
import org.openconcerto.erp.core.finance.accounting.action.GenerePointageAction;
import org.openconcerto.erp.core.finance.accounting.action.GestionPlanComptableEAction;
import org.openconcerto.erp.core.finance.accounting.action.ImportEcritureAction;
import org.openconcerto.erp.core.finance.accounting.action.ImportEcritureFECAction;
import org.openconcerto.erp.core.finance.accounting.action.ImpressionJournauxAnalytiqueAction;
import org.openconcerto.erp.core.finance.accounting.action.ImpressionLivrePayeAction;
import org.openconcerto.erp.core.finance.accounting.action.ImpressionRepartitionAnalytiqueAction;
109,6 → 110,7
import org.openconcerto.erp.core.sales.invoice.action.ListeDesElementsFactureAction;
import org.openconcerto.erp.core.sales.invoice.action.ListeDesFactureItemsAction;
import org.openconcerto.erp.core.sales.invoice.action.ListeDesVentesAction;
import org.openconcerto.erp.core.sales.invoice.action.ListeEcheancePrelevementAction;
import org.openconcerto.erp.core.sales.invoice.action.ListeSDDMessageAction;
import org.openconcerto.erp.core.sales.invoice.action.ListeSaisieVenteFactureAction;
import org.openconcerto.erp.core.sales.invoice.action.ListesFacturesClientsImpayeesAction;
383,6 → 385,7
if (rights.haveRight(NXRights.GESTION_ENCAISSEMENT.getCode())) {
Group gCustomer = new Group("menu.payment.customer");
gCustomer.addItem("customer.invoice.unpaid.list");
gCustomer.addItem("customer.payment.prelevement.list");
gCustomer.addItem("customer.payment.report");
gCustomer.addItem("customer.dept.list");
gCustomer.addItem("customer.payment.list");
391,7 → 394,6
gCustomer.addItem("customer.payment.check.deposit.list");
gCustomer.addItem("customer.payment.check.pending.create");
gCustomer.addItem("customer.payment.check.deposit.list");
gCustomer.addItem("customer.payment.sddMessage.list");
gCustomer.addItem("customer.credit.check.list");
gCustomer.addItem("customer.credit.check.create");
group.add(gCustomer);
458,6 → 460,7
 
final Group gIO = new Group("menu.accounting.io", LayoutHints.DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS);
gIO.addItem("accounting.import");
gIO.addItem("accounting.import.fec");
gIO.addItem("accounting.export");
group.add(gIO);
 
654,7 → 657,7
 
boolean useListDesVentesAction = bModeVenteComptoir;
if (useListDesVentesAction) {
mManager.putAction(new ListeDesVentesAction(), "sales.list");
mManager.putAction(new ListeDesVentesAction(conf), "sales.list");
 
} else {
 
707,6 → 710,7
mManager.putAction(new NouveauClotureAction(), "accounting.closing");
mManager.putAction(new ImportEcritureAction(), "accounting.import");
mManager.putAction(new ExportRelationExpertAction(), "accounting.export");
mManager.putAction(new ImportEcritureFECAction(), "accounting.import.fec");
}
 
public void registerStatsDocumentsActions(final MenuAndActions mManager) {
790,8 → 794,10
mManager.putAction(new ListeDesDepostChequesAction(), "customer.payment.check.deposit.list");
mManager.putAction(new NouveauListeDesChequesAEncaisserAction(conf), "customer.payment.check.pending.create");
mManager.putAction(new ListeSDDMessageAction(conf.getDirectory()), "customer.payment.sddMessage.list");
mManager.putAction(new ListeEcheancePrelevementAction(conf), "customer.payment.prelevement.list");
mManager.putAction(new ListeDesChequesAvoirAction(), "customer.credit.check.list");
mManager.putAction(new NouveauDecaissementChequeAvoirAction(conf), "customer.credit.check.create");
 
}
if (rights.haveRight(NXRights.LOCK_MENU_ACHAT.getCode())) {
mManager.putAction(new ListesFacturesFournImpayeesAction(), "supplier.invoice.unpaid.list");
863,7 → 869,7
}
 
public void registerHelpMenuActions(final MenuAndActions mManager) {
mManager.putAction(AboutAction.getInstance(), "information");
mManager.putAction(new AboutAction(getConfiguration()), "information");
mManager.putAction(new AstuceAction(), "tips");
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/config/translation_fr.xml
100,6 → 100,7
<menu id="customer.payment.check.pending.list" label="Chèques des clients" />
<menu id="customer.payment.check.pending.create" label="Chèques à encaisser" />
<menu id="customer.payment.check.deposit.list" label="Liste des dépôts de chèques" />
<menu id="customer.payment.prelevement.list" label="Prélèvements SEPA" />
<menu id="customer.payment.sddMessage.list" label="Liste des ordres de prélèvement SEPA" />
<menu id="customer.credit.check.list" label="Chèques d'avoir" />
<menu id="customer.credit.check.create" label="Chèques d'avoir à décaisser" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_fr.xml
1,11 → 1,12
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<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.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="humanresources.payroll.advance" nameClass="masculine" name="acompte">
<FIELD name="ID_SALARIE" label="Salarié" />
<FIELD name="MONTANT" label="Montant" />
65,8 → 66,8
<FIELD name="ID_ADRESSE_COURRIER_2" label="Adresse de courrier 2" />
<FIELD name="ID_ADRESSE_COURRIER_3" label="Adresse de courrier 3" />
</element>
<element refid="controle.AffaireElementSQLElement.project.item" nameClass="feminine"
name="mission de l'affaire" namePlural="missions de l'affaire">
<element refid="controle.project.item" nameClass="feminine" name="mission de l'affaire"
namePlural="missions de l'affaire">
<FIELD name="FIN_CONTRAT" label="Fin de contrat" />
<FIELD name="DATE_FIN_CONTRAT" label="Date de fin de contrat" />
<FIELD name="CODE" label="Code" />
98,11 → 99,16
<FIELD name="NOTA" label="Nota" />
</element>
<element refid="sales.product.ref" nameClass="masculine" name="article">
<FIELD name="HAUTEUR" label="Hauteur" />
<FIELD name="LARGEUR" label="Largeur" />
<FIELD name="LONGUEUR" label="Longueur" />
<FIELD name="POIDS_COLIS_NET" label="Poids colis" />
<FIELD name="MARGE_WITH_COUT_REVIENT" label="Inclure le coût de revient dans le calcul du prix de vente" />
<FIELD name="ID_COUT_REVIENT" label="%CR" />
<FIELD name="QTE_UNITAIRE" label="Quantité unitaire par défaut" />
<FIELD name="MASQUE_CAISSE" label="Ne pas charger sur la caisse" />
<FIELD name="TARE" label="Tare" />
<FIELD name="DLC" label="DLC" />
<FIELD name="IFCO" label="IFCO" />
<FIELD name="MATIERE" label="Matière" />
<FIELD name="ID_TAXE_COMPLEMENTAIRE" label="Taxe complémentaire" />
148,6 → 154,8
<FIELD name="ID_COMPTE_PCE_ACHAT" label="Compte spécifique d'achat" />
<FIELD name="SKU" label="SKU" />
<FIELD name="ID_DEPOT_STOCK" label="Dépôt Stock" />
<FIELD name="AUTO_PRIX_ACHAT_NOMENCLATURE" label="Prix d'achat calculé depuis la nomenclature" />
<FIELD name="AUTO_PRIX_MIN_VENTE_NOMENCLATURE" label="Prix de vente calculé depuis la nomenclature" />
</element>
<element refid="sales.product.compta" nameClass="feminine" name="liaison article catégorie comptable"
namePlural="liaisons article catégorie comptable">
294,6 → 302,7
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
<FIELD name="T_POIDS_BRUT" label="Pds Brut Total" />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" />
<FIELD name="ID_ARTICLE" label="Article" />
311,8 → 320,8
<FIELD name="PA_HT" label="PA Unitaire HT" />
<FIELD name="PV_HT" label="PV Unitaire HT" />
<FIELD name="ID_TAXE" label="Taxe" />
<FIELD name="POIDS" label="Poids UV" />
<FIELD name="T_POIDS" label="Poids total" />
<FIELD name="POIDS" label="Poids UV net" />
<FIELD name="T_POIDS" label="Poids total net" />
<FIELD name="T_PA_HT" label="Total d'achat HT" />
<FIELD name="T_PV_HT" label="Total HT" />
<FIELD name="MARGE_HT" label="Marge HT" />
432,6 → 441,10
</element>
<element refid="supplychain.receipt.item" nameClass="masculine" name="élément de bon"
namePlural="éléments de bon">
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
<FIELD name="T_POIDS_BRUT" label="Pds Brut Total" />
<FIELD name="ID_DEMANDE_ACHAT_ELEMENT" label="Dmd Achat" />
<FIELD name="ID_DEPOT_STOCK" label="Dépôt Stock" />
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
452,7 → 465,7
<FIELD name="QTE_ORIGINE" label="Qté cdée" />
<FIELD name="QTE" label="Qté reçue" />
<FIELD name="ID_TAXE" label="Taxe" />
<FIELD name="POIDS" label="Poids UV" />
<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="VALEUR_METRIQUE_1" label="Longueur par défaut" />
469,7 → 482,7
<FIELD name="T_PV_HT" label="Total HT" />
<FIELD name="T_PA_HT" label="Total Achat HT" />
<FIELD name="T_PA_TTC" label="Total Achat TTC" />
<FIELD name="T_POIDS" label="Poids total" />
<FIELD name="T_POIDS" label="Poids total net" />
<FIELD name="ID_STYLE" label="Style" />
<FIELD name="SERVICE" label="Service" />
<FIELD name="ID_MODE_VENTE_ARTICLE" label="Mode de vente" />
514,6 → 527,7
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
<FIELD name="T_POIDS_BRUT" label="Pds Brut Total" />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" />
<FIELD name="ID_ARTICLE" label="Article" />
538,7 → 552,7
<FIELD name="QTE_LIVREE" label="Quantité livrée" titlelabel="Qté livrée" />
<FIELD name="QTE_A_LIVRER" label="Quantité à livrer" titlelabel="Qté à livrer" />
<FIELD name="ID_TAXE" label="Taxe" />
<FIELD name="POIDS" label="Poids UV" />
<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="VALEUR_METRIQUE_1" label="Longueur par défaut" />
554,7 → 568,7
<FIELD name="T_PV_TTC" label="Total TTC" />
<FIELD name="T_PV_HT" label="Total vente HT" />
<FIELD name="T_PA_HT" label="Total achat HT" />
<FIELD name="T_POIDS" label="Poids total" />
<FIELD name="T_POIDS" label="Poids total net" />
<FIELD name="T_POIDS_LIVREE" label="Poids total livré" />
<FIELD name="ID_STYLE" label="Style" />
<FIELD name="SERVICE" label="Service" />
624,6 → 638,8
<FIELD name="QTE" label="Qté" />
<FIELD name="PA_HT" label="P.A. HT" />
<FIELD name="PV_HT" label="P.V. HT" />
<FIELD name="ANT" label="Cumul antérieur" />
<FIELD name="MOTIF" label="Motif" />
<FIELD name="T_PA_HT" label="Total P.A. HT" />
<FIELD name="MARGE" label="Marge" />
<FIELD name="T_PV_HT" label="Total P.V. HT" />
642,7 → 658,96
<FIELD name="POSITION" label="Position" />
<FIELD name="ECHELON" label="Echelon" />
</element>
<!-- Mapping pour client partagé KD/Preventec -->
<element refid="controle.customer" nameClass="masculine" name="client">
 
<FIELD name="ID_SEPA_MANDATE_DEFAULT" label="Mandat par défaut" />
<FIELD name="ID_FRAIS_DOCUMENT" label="Frais de création de documents" />
<FIELD name="CODE_FOURNISSEUR" label="Code interne fournisseur" />
<FIELD name="CONDITIONS_LIVRAISON" label="Conditions de livraison" />
<FIELD name="ID_CATEGORIE_COMPTABLE" label="Catégorie comptable" />
<FIELD name="TIMBRE_FISCAL" label="Soumis au timbre" />
<FIELD name="ID_COMPTE_PCE_SERVICE" label="Compte de service spécifique" />
<FIELD name="ID_TARIF_MISSION_LIBELLE" label="Tarif" />
<FIELD name="ID_TYPE_CLIENT" label="Type de client" />
<FIELD name="REMIND_DATE" label="Date de rappel" />
<FIELD name="ID_GROUPE_CLIENT" label="Groupe" />
<FIELD name="ID_PAYS" label="Pays" />
<FIELD name="ID_LANGUE" label="Langue" />
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="FORME_JURIDIQUE" label="Forme juridique" />
<FIELD name="NOM" label="Nom client" />
<FIELD name="CODE" label="Code client" />
<FIELD name="TEL" label="Téléphone" />
<FIELD name="TEL_P" label="Portable" />
<FIELD name="FAX" label="Fax" />
<FIELD name="MAIL" label="Mail" />
<FIELD name="ACCEPTE_EMAIL" label="Accepte e-mail" titlelabel="E-mail OK" />
<FIELD name="ACCEPTE_COURRIER" label="Accepte courrier" titlelabel="Courrier OK" />
<FIELD name="ACCEPTE_SMS" label="Accepte SMS" titlelabel="SMS OK" />
<FIELD name="ACCEPTE_TEL" label="Accepte appel téléphonique" titlelabel="Appel tél. OK" />
<FIELD name="RESPONSABLE" label="Responsable" />
<FIELD name="RESPONSABLE_TECH" label="Responsable tech." />
<FIELD name="RESPONSABLE_COM" label="Responsable comm." />
<FIELD name="TEL_COM" label="Téléphone" />
<FIELD name="FAX_COM" label="Fax" />
<FIELD name="TEL_P_COM" label="Portable" />
<FIELD name="MAIL_COM" label="E-mail" />
<FIELD name="TEL_TECH" label="Téléphone" />
<FIELD name="FAX_TECH" label="Fax" />
<FIELD name="TEL_P_TECH" label="Portable" />
<FIELD name="MAIL_TECH" label="E-mail" />
<FIELD name="ID_COMPTE_PCE" label="Compte PCE associé" />
<FIELD name="ID_COMPTE_PCE_PRODUIT" label="Compte PCE Produit associé" />
<FIELD name="ID_ADRESSE" label="Adr. Principale" />
<FIELD name="ID_ADRESSE_L" label="Adr. Livraison" />
<FIELD name="ID_ADRESSE_F" label="Adr. Facturation" />
<FIELD name="NUMERO_TVA" label="N° Intracommunautaire" titlelabel="N° Intracom" />
<FIELD name="ID_ADRESSE" label="Adresse" />
<FIELD name="MARCHE_PUBLIC" label="Marché public" />
<FIELD name="MARCHE_PRIVE" label="Marché privé" />
<FIELD name="ID_ADRESSE_L" label="Adresse de livraison" titlelabel="Adresse livraison" />
<FIELD name="ID_ADRESSE_L_2" label="Adresse de livraison" titlelabel="Adresse livraison 2" />
<FIELD name="ID_ADRESSE_L_3" label="Adresse de livraison" titlelabel="Adresse livraison 3" />
<FIELD name="RIB" label="RIB" />
<FIELD name="IBAN" label="IBAN" />
<FIELD name="BIC" label="BIC" />
<FIELD name="SIRET" label="SIRET" />
<FIELD name="ID_SECTEUR_ACTIVITE" label="Secteur d'activité" />
<FIELD name="ID_BANQUE_POLE_PRODUIT" label="Banque" />
<FIELD name="ID_POLE_PRODUIT" label="Pôle produit" />
<FIELD name="ID_SECTEUR_ACTIVITE" label="Secteur d'activité" />
<FIELD name="INFOS" label="Informations complémentaires" />
<FIELD name="ID_MODE_REGLEMENT" label="Mode de règlement par défaut" />
<FIELD name="AFFACTURAGE" label="Possibilité d'affacturage" />
<FIELD name="MAX_FACTURE" label="Facturation limitée à" />
<FIELD name="COMPTANT" label="Règlement comptant obligatoire" />
<FIELD name="ID_TARIF" label="Tarif" />
<FIELD name="EXTRANET_LOGIN" label="Identifiant extranet" />
<FIELD name="EXTRANET_PASSWORD" label="Mot de passe extranet" />
 
<FIELD name="DATE" label="Date de création" />
<FIELD name="SITE_INTERNET" label="Site web" />
<FIELD name="CATEGORIES" label="Catégories" />
<FIELD name="ID_DEVISE" label="Devise" />
<FIELD name="ENCOURS_MAX" label="Encours max." />
<FIELD name="NOTE_FINANCIERE" label="Note financière" />
<FIELD name="METHODE_RELANCE" label="Méthode de relance" />
<FIELD name="ID_COMMERCIAL" label="Commercial" />
<FIELD name="CENTRE_GESTION" label="Centre de gestion" />
<FIELD name="ID_ADRESSE" label="Adresse du siège" />
<FIELD name="ID_ADRESSE_F" label="Adresse de facturation" />
<FIELD name="COMMENTAIRES" label="Commentaires" />
<FIELD name="BLOQUE" label="Bloquer les interactions" />
<FIELD name="GROUPE" label="Groupe" />
<FIELD name="BLOQUE_LIVRAISON" label="Bloquer les livraisons" />
<FIELD name="OBSOLETE" label="Obsolète" />
 
</element>
<!-- Mapping pour client standard OpenConcerto -->
<element refid="customerrelationship.customer" nameClass="masculine" name="client">
<FIELD name="ID_SEPA_MANDATE_DEFAULT" label="Mandat par défaut" />
<FIELD name="ID_FRAIS_DOCUMENT" label="Frais de création de documents" />
<FIELD name="CODE_FOURNISSEUR" label="Code interne fournisseur" />
<FIELD name="CONDITIONS_LIVRAISON" label="Conditions de livraison" />
906,6 → 1011,18
</element>
<element refid="humanresources.payroll.contract.employe" nameClass="masculine" name="contrat salarié"
namePlural="contrats salariés">
 
<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)" />
<FIELD name="DATE_DEBUT_SUSPENSION" label="Début de supension (S21.G00.65.002)" />
 
<FIELD name="SPECTACLE_OBJET" label="Objet spectacle (S21.G00.40.019)" />
<FIELD name="SPECTACLE_JOUR_CONTRAT" label="Nb jour contrat spectacle (S21.G00.53.003)" />
<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)" />
<FIELD name="DATE_DEBUT_SUSPENSION" label="Début de supension (S21.G00.65.002)" />
<FIELD name="NATURE" label="Nature de l'emploi (*)" titlelabel="Nature de l'emploi" />
<FIELD name="COMPLEMENT_PCS" label="Code complément PCS-ESE" />
<FIELD name="ID_CODE_EMPLOI" label="Catégorie socioprofessionnelle "
966,6 → 1083,10
</element>
<element refid="supplychain.order.item" nameClass="masculine" name="élément de commande"
namePlural="éléments de commande">
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
<FIELD name="T_POIDS_BRUT" label="Pds Brut Total" />
<FIELD name="ID_DEMANDE_ACHAT_ELEMENT" label="Dmd Achat" />
<FIELD name="ID_FAMILLE_ARTICLE" label="Famille d'article" />
<FIELD name="ID_DEPOT_STOCK" label="Dépôt Stock" />
988,7 → 1109,7
<FIELD name="PA_HT" label="PA Unitaire HT" />
<FIELD name="PV_HT" label="PV Unitaire HT" />
<FIELD name="ID_TAXE" label="Taxe" />
<FIELD name="POIDS" label="Poids UV" />
<FIELD name="POIDS" label="Poids UV net" />
<FIELD name="QTE" label="Quantité" titlelabel="Qté" />
<FIELD name="SERVICE" label="Service" />
<FIELD name="PRIX_METRIQUE_VT_1" label="P.V. UV HT" />
1008,7 → 1129,7
<FIELD name="T_PA_TTC" label="Total achat TTC" />
<FIELD name="T_PA_HT" label="Total achat HT" />
<FIELD name="POURCENT_REMISE" label="% Remise" />
<FIELD name="T_POIDS" label="Poids total" />
<FIELD name="T_POIDS" label="Poids total net" />
<FIELD name="ID_MODE_VENTE_ARTICLE" label="Mode de vente" />
</element>
<element refid="sales.order" nameClass="feminine" name="commande client" namePlural="commandes clients">
1056,7 → 1177,7
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
 
<FIELD name="T_POIDS_BRUT" label="Pds Brut Total" />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" />
<FIELD name="ID_ARTICLE" label="Article" />
1075,7 → 1196,7
<FIELD name="MARGE_HT" label="Marge HT" />
<FIELD name="PV_HT" label="PV Unitaire HT" />
<FIELD name="ID_TAXE" label="Taxe" />
<FIELD name="POIDS" label="Poids UV" />
<FIELD name="POIDS" label="Poids UV net" />
<FIELD name="QTE" label="Quantité" titlelabel="Qté" />
<FIELD name="SERVICE" label="Service" />
<FIELD name="PRIX_METRIQUE_VT_1" label="P.V. UV HT" />
1093,7 → 1214,7
<FIELD name="T_PV_TTC" label="Total TTC" />
<FIELD name="T_PV_HT" label="Total vente HT" />
<FIELD name="T_PA_HT" label="Total achat HT" />
<FIELD name="T_POIDS" label="Poids total" />
<FIELD name="T_POIDS" label="Poids total net" />
<FIELD name="ID_MODE_VENTE_ARTICLE" label="Mode de vente" />
 
<FIELD name="POURCENT_ACOMPTE" label="% Acompte" />
1387,8 → 1508,8
<FIELD name="PA_HT" label="PA Unitaire HT" />
<FIELD name="PV_HT" label="PV Unitaire HT" />
<FIELD name="ID_TAXE" label="Taxe" />
<FIELD name="POIDS" label="Poids UV" />
<FIELD name="T_POIDS" label="Poids total" />
<FIELD name="POIDS" label="Poids UV net" />
<FIELD name="T_POIDS" label="Poids total net" />
<FIELD name="T_PA_HT" label="Total achat HT" />
<FIELD name="T_PV_HT" label="Total HT" />
<FIELD name="T_PV_TTC" label="Total TTC" />
1411,8 → 1532,7
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
 
 
<FIELD name="T_POIDS_BRUT" label="Pds Brut Total" />
<FIELD name="MONTANT_INITIAL" label="Montant initial" />
<FIELD name="INDICE_0" label="Indice 0" />
<FIELD name="INDICE_N" label="Indice N" />
1544,8 → 1664,7
namePlural="états de demande d'achat">
<FIELD name="NOM" label="Etat" />
</element>
<element refid="controle.EtatRapportSQLElement.report.state" nameClass="masculine" name="état rapport"
namePlural="états rapports">
<element refid="controle.report.state" nameClass="masculine" name="état rapport" namePlural="états rapports">
<FIELD name="NOM" label="Etat du rapport" />
</element>
<element refid="humanresources.employe.info" nameClass="masculine" name="état civil" namePlural="états civils">
1608,6 → 1727,7
</element>
<element refid="supplychain.order.invoice.purchase" nameClass="feminine" name="facture fournisseur"
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" />
<FIELD name="NET_A_PAYER" label="Net à payer" />
1638,6 → 1758,9
</element>
<element refid="supplychain.orderinvoice.purchase.item" nameClass="masculine" name="élément de facture"
namePlural="éléments de facture">
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
<FIELD name="ID_COMPTE_PCE" label="Compte charge spécifique" />
<FIELD name="ID_DEPOT_STOCK" label="Dépôt Stock" />
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
1734,8 → 1857,8
<FIELD name="IN_PERIODE" label="Dans la période" />
<FIELD name="ID_FICHE_PAYE" label="Fiche de paye" />
</element>
<element refid="controle.FicheRendezVousSQLElement.appointment.form" nameClass="feminine"
name="fiche de prise de rendez-vous" namePlural="fiches de prise de rendez-vous">
<element refid="controle.appointment.form" nameClass="feminine" name="fiche de prise de rendez-vous"
namePlural="fiches de prise de rendez-vous">
<FIELD name="DATE" label="Date de création" />
<FIELD name="ID_VERIFICATEUR" label="Pilote" />
<FIELD name="ID_CLIENT" label="Client" />
1755,8 → 1878,8
<FIELD name="ID_POLE_PRODUIT" label="Pôle produit" />
<FIELD name="VALID" label="Valider par le responsable" />
</element>
<element refid="controle.FicheRdvItemSQLElement.appointment.form.item" nameClass="masculine"
name="element de fiche" namePlural="éléments de fiche">
<element refid="controle.appointment.form.item" nameClass="masculine" name="element de fiche"
namePlural="éléments de fiche">
<FIELD name="ECHEANCE_RAPPORT" label="Ech. remise rapport en jour" />
<FIELD name="DATE" label="Date" />
<FIELD name="ID_MISSION" label="Mission" />
1971,7 → 2094,7
<FIELD name="CHIFFRE_AFFAIRE" label="Chiffre d'affaire" />
<FIELD name="ID_COMMERCIAL" label="Commercial" />
</element>
<element refid="controle.OrdreMissionSQLElement.mission.note" nameClass="masculine" name="ordre de mission"
<element refid="controle.mission.note" nameClass="masculine" name="ordre de mission"
namePlural="ordres de mission">
<FIELD name="ID_VERIFICATEUR" label="Vérificateur" />
<FIELD name="ID_FICHE_RENDEZ_VOUS" label="Fiche de rendez vous" />
1998,8 → 2121,7
<TABLE name="POCHETTE">
<FIELD name="CODE" label="Pochette" />
</TABLE>
<element refid="controle.PoleProduitSQLElement.product.pole" nameClass="masculine" name="pôle produit"
namePlural="pôles produit">
<element refid="controle.product.pole" nameClass="masculine" name="pôle produit" namePlural="pôles produit">
<FIELD name="CODE" label="Code Pôle produit" />
<FIELD name="NOM" label="Nom" />
<FIELD name="RAISON_SOCIALE" label="Raison sociale" />
2011,6 → 2133,7
<FIELD name="NOM_DIRECTEUR" label="Nom directeur" />
<FIELD name="ID_ADRESSE_COMMON" label="Adresse" />
<FIELD name="FACTURE_ADRESSE" label="Facturer à cette adresse" />
<FIELD name="ID_POSTE_ANALYTIQUE" label="Poste analytique" />
</element>
<element refid="finance.accounting.analytic.set" nameClass="masculine" name="poste analytique"
namePlural="postes analytiques">
2062,8 → 2185,8
<FIELD name="DATE_CONFIRM" label="Date de confirmation" />
<FIELD name="CCI" label="CCI" />
</element>
<element refid="controle.PropositionElementSQLElement.proposal.item" nameClass="feminine"
name="mission d'une proposition" namePlural="missions par propositions">
<element refid="controle.proposal.item" nameClass="feminine" name="mission d'une proposition"
namePlural="missions par propositions">
<FIELD name="ID_PROPOSITION" label="Proposition" />
<FIELD name="FIN_CONTRAT" label="Fin de contrat" />
<FIELD name="ID_TAXE" label="TVA" />
2311,6 → 2434,7
<FIELD name="NB_COLIS" label="Nb Colis" />
<FIELD name="POIDS_COLIS_NET" label="Pds Colis" />
<FIELD name="T_POIDS_COLIS_NET" label="Pds Colis Total" />
<FIELD name="T_POIDS_BRUT" label="Pds Brut Total" />
<FIELD name="POURCENT_ACOMPTE" label="% Acompte" />
<FIELD name="QTE_UNITAIRE" label="Qté U.V." />
<FIELD name="ID_UNITE_VENTE" label="Unité de vente" />
2335,7 → 2459,7
<FIELD name="MARGE_HT" label="Marge HT" />
<FIELD name="PA_HT" label="PA Unitaire HT" />
<FIELD name="ID_TAXE" label="Taxe" />
<FIELD name="POIDS" label="Poids UV" />
<FIELD name="POIDS" label="Poids UV net" />
<FIELD name="QTE" label="Quantité" titlelabel="Qté" />
<FIELD name="QTE_LIVREE" label="Quantité livrée" titlelabel="Qté livrée" />
<FIELD name="LIVREE" label="Livrée" />
2353,7 → 2477,7
<FIELD name="PRIX_METRIQUE_HA_3" label="P.A. HT au kg" />
<FIELD name="VALEUR_METRIQUE_3" label="poids / m²" />
<FIELD name="ID_METRIQUE_3" label="Métrique" />
<FIELD name="T_POIDS" label="Poids total" />
<FIELD name="T_POIDS" label="Poids total net" />
<FIELD name="T_PA_HT" label="Total achat HT" />
<FIELD name="T_PV_HT" label="Total HT" />
<FIELD name="T_PV_TTC" label="Total TTC" />
2510,8 → 2634,18
<FIELD name="HEURE_ABS" label="Heures d'abscence" />
<FIELD name="IJSS_BRUT" label="IJSS Brut" />
<FIELD name="IJSS_NET" label="IJSS Net" />
<FIELD name="HEURE_CHOM" label="Heures chômage partiel" />
<FIELD name="TAUX_CHOM" label="Taux heures chômées" />
<FIELD name="HEURE_INDEM" label="Heures IJSS indemnisées" />
<FIELD name="ECRETEMENT_CSG" label="Ecrêtement CSG chômage" />
<FIELD name="IJSS_BRUT_SECU_PAS" label="IJSS Brut PAS" />
<FIELD name="FRAIS_PRO" label="Frais professionnels" />
<FIELD name="RBT_TRANSPORT" label="Rembousement transport" />
<FIELD name="HEURE_CHOM" label="Heures chômage partiel" />
<FIELD name="TAUX_CHOM" label="Taux heures chômées" />
<FIELD name="HEURE_INDEM" label="Heures IJSS indemnisées" />
<FIELD name="ECRETEMENT_CSG" label="Ecrêtement CSG chômage" />
<FIELD name="IJSS_BRUT_SECU_PAS" label="IJSS Brut PAS" />
</element>
<element refid="sales.product.unit" nameClass="feminine" name="unité de vente" namePlural="unité de vente">
<FIELD name="CODE" label="Code" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/Gestion.java
50,6 → 50,7
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.ThrowableHandler;
import org.openconcerto.utils.i18n.TranslationManager;
import org.openconcerto.utils.protocol.Helper;
import org.openconcerto.xml.FastXMLProperties;
 
57,7 → 58,6
import java.awt.Component;
import java.awt.Desktop;
import java.awt.Image;
import java.awt.SplashScreen;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.HierarchyEvent;
245,9 → 245,12
System.setProperty("apple.laf.useScreenMenuBar", "true");
 
// ToolTipManager.sharedInstance().setInitialDelay(0);
// SpeedUp Linux
System.setProperty("sun.java2d.pmoffscreen", "false");
if (false) {
// TODO : regarder si ne pas le forcer fix le bug de carré noir
// SpeedUp Linux
System.setProperty("sun.java2d.pmoffscreen", "false");
 
}
System.setProperty(EditPanel.NOBORDER, "true");
System.setProperty(EditPanel.ADD_AT_THE_END, "true");
System.setProperty("org.openconcerto.sql.listPanel.deafEditPanel", "true");
274,6 → 277,9
 
System.setProperty(ITextCombo.SIMPLE_TRAVERSAL, "true");
 
// Must be called before createDefaultInstance()
TranslationManager.addTranslationStreamFromClass(Gestion.class);
 
// Disable FOR SHARE lock
BaseFillSQLRequest.setDefaultLockSelect(false);
 
281,8 → 287,9
// Initialisation du splashScreen
// ne pas oublier en param -splash:image.png
try {
SplashScreen.getSplashScreen();
} catch (Exception e) {
// Ne fonctionne pas sur certains Linux
java.awt.SplashScreen.getSplashScreen();
} catch (Throwable e) {
// Can occur on OpenJDK...
System.out.println("SplashScreen failed... " + e.getMessage());
}
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_pl.xml
862,7 → 862,7
<element refid="sales.quote.state" nameClass="masculine" name="état de devis" namePlural="états de devis">
<FIELD name="NOM" label="Etat du devis" />
</element>
<element refid="controle.EtatRapportSQLElement.report.state" nameClass="masculine" name="état rapport"
<element refid="controle.report.state" nameClass="masculine" name="état rapport"
namePlural="états rapports">
<FIELD name="NOM" label="Etat du rapport" />
</element>
927,7 → 927,7
<FIELD name="IN_PERIODE" label="Dans la période" />
<FIELD name="ID_FICHE_PAYE" label="Fiche de paye" />
</element>
<element refid="controle.FicheRendezVousSQLElement.appointment.form" nameClass="feminine"
<element refid="controle.appointment.form" nameClass="feminine"
name="fiche de prise de rendez-vous" namePlural="fiches de prise de rendez-vous">
<FIELD name="DATE" label="Date de création" />
<FIELD name="ID_VERIFICATEUR" label="Pilote" />
948,7 → 948,7
<FIELD name="ID_POLE_PRODUIT" label="Pôle produit" />
<FIELD name="VALID" label="Valider par le responsable" />
</element>
<element refid="controle.FicheRdvItemSQLElement.appointment.form.item" nameClass="masculine"
<element refid="controle.appointment.form.item" nameClass="masculine"
name="element de fiche" namePlural="éléments de fiche">
<FIELD name="ECHEANCE_RAPPORT" label="Ech. remise rapport en jour" />
<FIELD name="DATE" label="Date" />
1165,7 → 1165,7
<FIELD name="ID" label="Numer części" />
<FIELD name="NOM" label="Nazwa części" />
</element>
<element refid="controle.PoleProduitSQLElement.product.pole" nameClass="masculine" name="pôle produit"
<element refid="controle.product.pole" nameClass="masculine" name="pôle produit"
namePlural="pôles produit">
<FIELD name="CODE" label="Kod" />
<FIELD name="NOM" label="Nazwa" />
/trunk/OpenConcerto/src/org/openconcerto/erp/modules/ModuleManager.java
20,7 → 20,6
import org.openconcerto.erp.modules.DepSolverResult.Factory;
import org.openconcerto.erp.modules.ModuleTableModel.ModuleRow;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.TM;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.element.SQLElementNamesFromXML;
1291,7 → 1290,7
final SQLElementDirectory dir = getDirectory();
final ComponentsContext ctxt = new ComponentsContext(dir, getRoot(), alreadyCreatedItems.get0(), alreadyCreatedItems.get1());
module.setupComponents(ctxt);
TranslationManager.getInstance().addTranslationStreamFromClass(module.getClass());
TranslationManager.addTranslationStreamFromClass(module.getClass());
this.setupMenu(module, ma);
this.modulesComponents.put(id, ctxt);
}
1832,7 → 1831,7
}
 
private final Set<SQLTable> loadTranslations(final SQLFieldTranslator trns, final AbstractModule module, final String mdVariant) throws IOException {
final Locale locale = TM.getInstance().getTranslationsLocale();
final Locale locale = getConf().getLocale();
final Control cntrl = TranslationManager.getControl();
final String baseName = "labels";
 
2070,7 → 2069,7
e.getKey().removeAdditionalField(fieldName);
for (final Entry<SQLElement, ? extends Collection<IListeAction>> e : ctxt.getRowActions().entrySet())
e.getKey().getRowActions().removeAll(e.getValue());
TranslationManager.getInstance().removeTranslationStreamFromClass(module.getClass());
TranslationManager.removeTranslationStreamFromClass(module.getClass());
// can't undo so menu is reset in stopModule()
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateListFrameAbstractAction.java
14,7 → 14,6
package org.openconcerto.erp.action;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.element.SQLElement;
67,10 → 66,9
protected CreateListFrameAbstractAction(final ComptaPropsConfiguration conf, final E elem) {
super(elem);
this.conf = conf;
// TODO use conf to find TM
final NounClass nounClass = this.getElem().getName().getNounClass();
final String[] translationKeys = nounClass == null ? TRANSLATION_KEY_ARRAY : new String[] { TRANSLATION_KEY + '.' + nounClass.getName(), TRANSLATION_KEY };
this.putValue(NAME, StringUtils.firstUp(TM.getTM().translateFirst(MissingMode.NULL, MessageArgs.create("elem", this.getElem().getName()), translationKeys)));
this.putValue(NAME, StringUtils.firstUp(conf.getERP_TM().translateFirst(MissingMode.STRING, MessageArgs.create("elem", this.getElem().getName()), translationKeys)));
}
 
public final ComptaPropsConfiguration getConf() {
/trunk/OpenConcerto/src/org/openconcerto/erp/action/CreateEditFrameAbstractAction.java
13,7 → 13,8
package org.openconcerto.erp.action;
 
import org.openconcerto.erp.utils.TM;
import static org.openconcerto.erp.utils.TM.getERP_TM;
 
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.EditFrame;
34,10 → 35,9
 
protected CreateEditFrameAbstractAction(final PropsConfiguration conf, final E elem) {
super(elem);
// TODO use conf to find TM
final NounClass nounClass = this.getElem().getName().getNounClass();
final String[] translationKeys = nounClass == null ? TRANSLATION_KEY_ARRAY : new String[] { TRANSLATION_KEY + '.' + nounClass.getName(), TRANSLATION_KEY };
this.putValue(NAME, StringUtils.firstUp(TM.getTM().translateFirst(MissingMode.NULL, MessageArgs.create("elem", this.getElem().getName()), translationKeys)));
this.putValue(NAME, StringUtils.firstUp(getERP_TM(conf.getLocale()).translateFirst(MissingMode.STRING, MessageArgs.create("elem", this.getElem().getName()), translationKeys)));
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/action/AboutAction.java
44,15 → 44,11
 
public final class AboutAction extends AbstractAction {
 
static private final AboutAction instance = new AboutAction();
private final ComptaPropsConfiguration conf;
 
public static AboutAction getInstance() {
return instance;
}
 
private AboutAction() {
public AboutAction(final ComptaPropsConfiguration conf) {
super("Informations");
 
this.conf = conf;
}
 
@Override
61,7 → 57,7
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
 
final JScrollPane contentPane = new JScrollPane(new InfoPanel());
final JScrollPane contentPane = new JScrollPane(new InfoPanel(this.conf.getLocale()));
p.add(createComptaInfoPanel(), BorderLayout.NORTH);
p.add(contentPane, BorderLayout.CENTER);
p.add(createBenchMarkPanel(), BorderLayout.SOUTH);
107,9 → 103,9
p.add(new JLabel(path), c);
c.gridy++;
c.gridx = 0;
final String serverIp = ComptaPropsConfiguration.getInstanceCompta().getServerIp();
final String serverIp = this.conf.getServerIp();
if (serverIp.startsWith("file:")) {
final String dbPath = ComptaPropsConfiguration.getInstanceCompta().getServerIp().substring(5);
final String dbPath = serverIp.substring(5);
c.weightx = 0;
c.anchor = GridBagConstraints.EAST;
p.add(new JLabelBold("Fichier de base de données : "), c);
/trunk/OpenConcerto/src/org/openconcerto/erp/action/NouvelleConnexionAction.java
64,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;
110,9 → 109,6
 
public void run() {
try {
TranslationManager.getInstance().addTranslationStreamFromClass(MainFrame.class);
TranslationManager.getInstance().setLocale(UserProps.getInstance().getLocale());
 
final Boolean booleanValue = UserProps.getInstance().getBooleanValue("HideTips");
if (!booleanValue) {
SwingUtilities.invokeLater(new Runnable() {
304,7 → 300,7
public void run() {
// laisse le temps au logiciel de demarrer
try {
Thread.sleep(10000);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/injector/CommandeBrSQLInjector.java
43,6 → 43,9
if (getSource().contains("ID_AFFAIRE") && getDestination().contains("ID_AFFAIRE")) {
map(getSource().getField("ID_AFFAIRE"), getDestination().getField("ID_AFFAIRE"));
}
if (getSource().contains("ID_POLE_PRODUIT") && getDestination().contains("ID_POLE_PRODUIT")) {
map(getSource().getField("ID_POLE_PRODUIT"), getDestination().getField("ID_POLE_PRODUIT"));
}
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SheetUtils.java
19,12 → 19,12
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
 
import java.awt.Graphics2D;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
32,14 → 32,22
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
 
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
import org.apache.pdfbox.util.Matrix;
import org.jopendocument.model.OpenDocument;
import org.jopendocument.renderer.ODTRenderer;
 
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;
 
import de.rototor.pdfbox.graphics2d.PdfBoxGraphics2D;
import de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DFontTextDrawer;
import de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DFontTextDrawerDefaultFonts;
 
public class SheetUtils {
 
public static File convertToOldFile(DBRoot root, String fileName, File pathDest, File fDest) {
132,40 → 140,41
 
public static void convert2PDF(final OpenDocument doc, final File pdfFileToCreate) throws Exception {
assert (!SwingUtilities.isEventDispatchThread());
// Open the PDF document
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
 
try {
PDDocument document = new PDDocument();
PDDocumentInformation info = new PDDocumentInformation();
info.setCreator("OpenConcerto");
info.setProducer("OpenConcerto");
info.setCreationDate(Calendar.getInstance());
info.setModificationDate(Calendar.getInstance());
document.setDocumentInformation(info);
 
FileOutputStream fileOutputStream = new FileOutputStream(pdfFileToCreate);
 
// Create the writer
PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
writer.setPdfVersion(PdfWriter.VERSION_1_6);
writer.setFullCompression();
PdfBoxGraphics2DFontTextDrawer fontTextDrawer = new PdfBoxGraphics2DFontTextDrawerDefaultFonts();
final File dir = new File("Fonts");
if (dir.exists()) {
fontTextDrawer.registerFontFromDirectory(dir);
}
 
document.open();
 
PdfContentByte cb = writer.getDirectContent();
 
// Configure the renderer
ODTRenderer renderer = new ODTRenderer(doc);
renderer.setIgnoreMargins(false);
renderer.setPaintMaxResolution(true);
PDRectangle pageSize = PDRectangle.A4;
 
// Scale the renderer to fit width or height
final double widthFactor = renderer.getPrintWidth() / document.getPageSize().getWidth();
final double heightFactor = renderer.getPrintHeight() / document.getPageSize().getHeight();
final double widthFactor = renderer.getPrintWidth() / pageSize.getWidth();
final double heightFactor = renderer.getPrintHeight() / pageSize.getHeight();
renderer.setResizeFactor(Math.max(widthFactor, heightFactor));
 
// Print pages
for (int i = 0; i < renderer.getPrintedPagesNumber(); i++) {
PDPage page = new PDPage(pageSize);
document.addPage(page);
PdfBoxGraphics2D g2 = new PdfBoxGraphics2D(document, pageSize.getWidth(), pageSize.getHeight());
g2.setFontTextDrawer(fontTextDrawer);
 
Graphics2D g2 = cb.createGraphics(PageSize.A4.getWidth(), PageSize.A4.getHeight());
 
// If you want to prevent copy/paste, you can use
// g2 = tp.createGraphicsShapes(w, h, true, 0.9f);
 
// centrage horizontal, alignement vertical en haut
g2.translate((PageSize.A4.getWidth() - renderer.getPrintWidthInPixel()) / 2.0, 0);
 
174,15 → 183,17
renderer.paintComponent(g2);
g2.dispose();
 
// Add our spreadsheet in the middle of the page
if (i < renderer.getPrintedPagesNumber() - 1)
document.newPage();
 
final PDFormXObject xform = g2.getXFormObject();
final Matrix matrix = new Matrix();
matrix.translate(0, 0);
final PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.transform(matrix);
contentStream.drawForm(xform);
contentStream.close();
}
document.save(fileOutputStream);
// Close the PDF document
document.close();
// writer.close();
fileOutputStream.close();
 
} catch (Exception originalExn) {
ExceptionHandler.handle("Impossible de créer le PDF " + pdfFileToCreate.getAbsolutePath(), originalExn);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLElement.java
176,7 → 176,7
int aJ = row.getInt("AJOURS");
int nJ = row.getInt("LENJOUR");
if (aJ + nJ == 0) {
if (row.getBoolean("DATE_FACTURE")) {
if (!row.getBoolean("COMPTANT") && row.getBoolean("DATE_FACTURE")) {
return Configuration.getInstance().getTranslator().getLabelFor(row.getTable().getField("DATE_FACTURE"));
} else {
return " ";
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/QteTotalDocProvider.java
24,13 → 24,19
public class QteTotalDocProvider extends UserInitialsValueProvider {
 
private enum TypeQteTotalDocProvider {
QTE, COLIS
QTE_KG, QTE, COLIS, PDS_BRUT, QTE_MULT
};
 
private final TypeQteTotalDocProvider type;
private boolean ha = false;
 
public QteTotalDocProvider(TypeQteTotalDocProvider t) {
this(t, false);
}
 
public QteTotalDocProvider(TypeQteTotalDocProvider t, boolean ha) {
this.type = t;
this.ha = ha;
}
 
@Override
43,18 → 49,29
for (SQLRowAccessor sqlRowAccessor : cols) {
 
if (!sqlRowAccessor.getTable().contains("NIVEAU") || sqlRowAccessor.getInt("NIVEAU") == 1) {
String field = "PV_HT";
if (this.ha) {
field = "PA_HT";
}
BigDecimal prixUnitaire = sqlRowAccessor.getBigDecimal(field);
if (prixUnitaire != null && prixUnitaire.signum() != 0) {
if (this.type == TypeQteTotalDocProvider.QTE || this.type == TypeQteTotalDocProvider.QTE_KG) {
if (this.type == TypeQteTotalDocProvider.QTE || sqlRowAccessor.getForeignID("ID_UNITE_VENTE") == 7) {
 
if (this.type == TypeQteTotalDocProvider.QTE) {
BigDecimal qte = sqlRowAccessor.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowAccessor.getInt("QTE")));
 
total = total.add(qte);
 
} else {
if (sqlRowAccessor.getObject("NB_COLIS") != null) {
total = total.add(new BigDecimal(sqlRowAccessor.getInt("NB_COLIS")));
BigDecimal qte = sqlRowAccessor.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowAccessor.getInt("QTE")));
total = total.add(qte);
}
} else if (this.type == TypeQteTotalDocProvider.PDS_BRUT) {
total = total.add(sqlRowAccessor.getBigDecimal("T_POIDS_BRUT"));
} else if (this.type == TypeQteTotalDocProvider.QTE_MULT) {
BigDecimal qte = new BigDecimal(sqlRowAccessor.getInt("QTE"));
total = total.add(qte);
} else {
if (sqlRowAccessor.getObject("NB_COLIS") != null) {
total = total.add(new BigDecimal(sqlRowAccessor.getInt("NB_COLIS")));
}
}
}
 
}
}
 
62,7 → 79,11
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.qty.multiple.total", new QteTotalDocProvider(TypeQteTotalDocProvider.QTE_MULT));
SpreadSheetCellValueProviderManager.put("sales.qty.total", new QteTotalDocProvider(TypeQteTotalDocProvider.QTE));
SpreadSheetCellValueProviderManager.put("purchase.qty.total", new QteTotalDocProvider(TypeQteTotalDocProvider.QTE, true));
SpreadSheetCellValueProviderManager.put("sales.qty.total.kg", new QteTotalDocProvider(TypeQteTotalDocProvider.QTE_KG));
SpreadSheetCellValueProviderManager.put("sales.package.total", new QteTotalDocProvider(TypeQteTotalDocProvider.COLIS));
SpreadSheetCellValueProviderManager.put("sales.package.brut", new QteTotalDocProvider(TypeQteTotalDocProvider.PDS_BRUT));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/IbanProvider.java
New file
0,0 → 1,69
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.utils.Tuple2;
 
public class IbanProvider implements SpreadSheetCellValueProvider {
 
private static Tuple2<Integer, Integer> CODE_PAYS = Tuple2.create(0, 2);
private static Tuple2<Integer, Integer> CLE_IBAN = Tuple2.create(2, 4);
private static Tuple2<Integer, Integer> CODE_BANQUE = Tuple2.create(4, 9);
private static Tuple2<Integer, Integer> CODE_GUICHET = Tuple2.create(9, 14);
private static Tuple2<Integer, Integer> NUMERO_COMPTE = Tuple2.create(14, 25);
private static Tuple2<Integer, Integer> CLE_RIB = Tuple2.create(25, 27);
 
private final Tuple2<Integer, Integer> currentTuple;
 
public IbanProvider(Tuple2<Integer, Integer> tuple) {
this.currentTuple = tuple;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
final SQLRowAccessor row = context.getRow();
 
String iban = row.getString("IBAN").trim().replaceAll(" ", "");
 
if (iban.length() >= this.currentTuple.get1()) {
return iban.substring(this.currentTuple.get0(), this.currentTuple.get1());
} else {
return "";
}
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("iban.codepays", new IbanProvider(CODE_PAYS));
SpreadSheetCellValueProviderManager.put("iban.cleiban", new IbanProvider(CLE_IBAN));
SpreadSheetCellValueProviderManager.put("iban.codebanque", new IbanProvider(CODE_BANQUE));
SpreadSheetCellValueProviderManager.put("iban.codeguichet", new IbanProvider(CODE_GUICHET));
SpreadSheetCellValueProviderManager.put("iban.numerocompte", new IbanProvider(NUMERO_COMPTE));
SpreadSheetCellValueProviderManager.put("iban.clerib", new IbanProvider(CLE_RIB));
}
 
public static void main(String[] args) {
String iban = "FR763000401587000260111220";
System.err.println(iban.substring(CODE_PAYS.get0(), CODE_PAYS.get1()));
System.err.println(iban.substring(CLE_IBAN.get0(), CLE_IBAN.get1()));
System.err.println(iban.substring(CODE_BANQUE.get0(), CODE_BANQUE.get1()));
System.err.println(iban.substring(CODE_GUICHET.get0(), CODE_GUICHET.get1()));
System.err.println(iban.substring(NUMERO_COMPTE.get0(), NUMERO_COMPTE.get1()));
if (iban.length() >= CLE_RIB.get1()) {
System.err.println(iban.substring(CLE_RIB.get0(), CLE_RIB.get1()));
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/FichePayeSmicHProvider.java
New file
0,0 → 1,47
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLTable;
 
import java.util.List;
 
import com.ibm.icu.math.BigDecimal;
 
public class FichePayeSmicHProvider implements SpreadSheetCellValueProvider {
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
SQLTable tableVar = context.getRow().getTable().getDBRoot().findTable("VARIABLE_PAYE");
List<SQLRow> rows = SQLBackgroundTableCache.getInstance().getCacheForTable(tableVar).getRows();
for (SQLRow sqlRow : rows) {
if (sqlRow.getString("NOM").equals("SMIC")) {
return new BigDecimal(sqlRow.getFloat("VALEUR"));
}
}
BigDecimal smic = new BigDecimal(10.03);
return smic;
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("fichepaye.smic", new FichePayeSmicHProvider());
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/FichePayeHeureSupTotalProvider.java
New file
0,0 → 1,55
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.util.Arrays;
import java.util.List;
 
import com.ibm.icu.math.BigDecimal;
 
public class FichePayeHeureSupTotalProvider implements SpreadSheetCellValueProvider {
 
private boolean cumul = false;
 
public FichePayeHeureSupTotalProvider(boolean c) {
this.cumul = c;
}
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
 
BigDecimal total = BigDecimal.ZERO;
SQLRowAccessor rowVar = context.getRow().getForeign("ID_VARIABLE_SALARIE");
List<String> fieldHeures = Arrays.asList("HEURE_110", "HEURE_125", "HEURE_150", "HEURE_200");
for (String field : fieldHeures) {
if (cumul) {
field = field + "_CUMUL_VAL";
}
 
total = total.add(new BigDecimal(rowVar.getFloat(field)));
}
return total;
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("fichepaye.heure.sup.total", new FichePayeHeureSupTotalProvider(false));
SpreadSheetCellValueProviderManager.put("fichepaye.heure.sup.cumul.total", new FichePayeHeureSupTotalProvider(true));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/FichePayeHeureTotalProvider.java
New file
0,0 → 1,55
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.util.Arrays;
import java.util.List;
 
import com.ibm.icu.math.BigDecimal;
 
public class FichePayeHeureTotalProvider implements SpreadSheetCellValueProvider {
 
private boolean cumul = false;
 
public FichePayeHeureTotalProvider(boolean c) {
this.cumul = c;
}
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
 
BigDecimal total = BigDecimal.ZERO;
SQLRowAccessor rowVar = context.getRow().getForeign("ID_VARIABLE_SALARIE");
List<String> fieldHeures = Arrays.asList("HEURE_TRAV", "HEURE_110", "HEURE_125", "HEURE_150", "HEURE_200");
for (String field : fieldHeures) {
if (cumul) {
field = field + "_CUMUL_VAL";
}
 
total = total.add(new BigDecimal(rowVar.getFloat(field)));
}
return total;
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("fichepaye.heure.total", new FichePayeHeureTotalProvider(false));
SpreadSheetCellValueProviderManager.put("fichepaye.heure.cumul.total", new FichePayeHeureTotalProvider(true));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/FichePayePlafondAProvider.java
New file
0,0 → 1,46
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLTable;
 
import java.util.List;
 
import com.ibm.icu.math.BigDecimal;
 
public class FichePayePlafondAProvider implements SpreadSheetCellValueProvider {
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
SQLTable tableVar = context.getRow().getTable().getDBRoot().findTable("VARIABLE_PAYE");
List<SQLRow> rows = SQLBackgroundTableCache.getInstance().getCacheForTable(tableVar).getRows();
for (SQLRow sqlRow : rows) {
if (sqlRow.getString("NOM").equals("PLAFOND_TRANCHE_A")) {
return new BigDecimal(sqlRow.getFloat("VALEUR"));
}
}
BigDecimal smic = new BigDecimal(3377);
return smic;
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("fichepaye.plafond", new FichePayePlafondAProvider());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationListeXML.java
479,7 → 479,14
}
y++;
} catch (IllegalArgumentException e) {
JOptionPane.showMessageDialog(null, "La cellule " + resolveHint + " n'existe pas ou est fusionnée.", "Erreur pendant la génération", JOptionPane.ERROR_MESSAGE);
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
System.err.println(resolveHint + " : " + value);
JOptionPane.showMessageDialog(null, "La cellule " + resolveHint + " n'existe pas ou est fusionnée.", "Erreur pendant la génération", JOptionPane.ERROR_MESSAGE);
}
});
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Mouvement.java
16,6 → 16,7
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInsert;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.users.User;
 
import java.math.BigDecimal;
import java.util.ArrayList;
61,7 → 62,7
return this.id;
}
 
SQLInsert createInsert(DBRoot root) {
SQLInsert createInsert(DBRoot root, User user) {
final SQLInsert insert = new SQLInsert();
final SQLTable table = root.getTable("MOUVEMENT");
// FIXME le numero doit être généré en auto
77,7 → 78,7
if (this.pere != null) {
insert.add(table.getField("ID_MOUVEMENT_PERE"), this.pere.getId().intValue());
}
// TODO CREATION_DATE MODIFICATION_DATE
insert.addCreationTrackedField(user, table);
return insert;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Ecriture.java
92,7 → 92,7
insert.add(table.getField("VALIDE"), Boolean.FALSE);
}
insert.add(table.getField("DATE_LETTRAGE"), this.dateLettrage);
insert.add(table.getField("LETTRAGE"), this.lettrage == null || this.lettrage.isEmpty() ? " " : this.lettrage);
insert.add(table.getField("LETTRAGE"), this.lettrage == null || this.lettrage.isEmpty() ? "" : this.lettrage);
return insert;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementVenteNG.java
20,6 → 20,7
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
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.model.PrixTTC;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
53,21 → 54,21
 
public SQLRow ecrClient = null;
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource) throws Exception {
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource) throws SQLException {
this(label, rowClient, ttc, d, modeReglement, source, mvtSource, true);
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse) throws Exception {
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse) throws SQLException {
this(label, rowClient, ttc, d, modeReglement, source, mvtSource, createEncaisse, false);
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance)
throws Exception {
throws SQLException {
this(label, rowClient, ttc, d, modeReglement, source, mvtSource, createEncaisse, avance, rowClient.getString("NOM"), null);
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance, String tiers,
SQLRowAccessor cptTiers) throws Exception {
SQLRowAccessor cptTiers) throws SQLException {
 
SQLRow typeRegRow = modeReglement.getForeignRow("ID_TYPE_REGLEMENT");
setRowAnalytiqueSource(source);
155,8 → 156,8
if (modeReglement.getObject("DATE") != null) {
dateTmp = modeReglement.getDate("DATE").getTime();
}
// On fixe la date du règlement de la facture
setDateReglement(source, dateTmp);
// On fixe la date du règlement de la facture à reception du cheque
setDateReglement(source, this.date);
 
Calendar c = modeReglement.getDate("DATE_DEPOT");
if (c != null) {
182,6 → 183,11
this.putValue("ID_JOURNAL", JournalSQLElement.CAISSES);
}
 
if (typeRegRow.getID() == TypeReglementSQLElement.CB && this.rowPrefsCompte.getTable().contains("ID_JOURNAL_CB_ATTENTE")
&& !this.rowPrefsCompte.isForeignEmpty("ID_JOURNAL_CB_ATTENTE")) {
this.putValue("ID_JOURNAL", this.rowPrefsCompte.getForeignID("ID_JOURNAL_CB_ATTENTE"));
}
 
int idCompteClient = cptTiers != null && !cptTiers.isUndefined() ? cptTiers.getID() : rowClient.getInt("ID_COMPTE_PCE");
if (avance) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
214,8 → 220,18
 
this.putValue("ID_COMPTE_PCE", Integer.valueOf(idCompteRegl));
} else {
fillCompteBanqueFromRow(modeReglement, "VenteCB", false);
try {
fillCompteBanqueFromRow(modeReglement, "VenteCB", false);
} catch (Exception e) {
throw new SQLException(e);
}
}
if (typeRegRow.getID() == TypeReglementSQLElement.CB && this.rowPrefsCompte.getTable().contains("ID_COMPTE_PCE_CB_ATTENTE")
&& !this.rowPrefsCompte.isForeignEmpty("ID_COMPTE_PCE_CB_ATTENTE")) {
 
this.putValue("ID_COMPTE_PCE", this.rowPrefsCompte.getForeignID("ID_COMPTE_PCE_CB_ATTENTE"));
}
 
this.putValue("DEBIT", Long.valueOf(ttc.getLongValue()));
this.putValue("CREDIT", Long.valueOf(0));
ajoutEcriture();
251,7 → 267,33
if (source.getTable().equals(tableSaisieVenteFacture)) {
valEcheance.put("ID_SAISIE_VENTE_FACTURE", source.getID());
}
if (source.getTable().getName().equals(valEcheance.getTable().getName())) {
valEcheance.put("ID_SAISIE_VENTE_FACTURE", source.getObject("ID_SAISIE_VENTE_FACTURE"));
}
if (modeReglement.getForeign("ID_TYPE_REGLEMENT").getBoolean("SEPA")) {
final String foreignBanqueFieldName = "ID_" + BanqueSQLElement.TABLENAME;
if (valEcheance.getTable().contains(foreignBanqueFieldName))
valEcheance.put(foreignBanqueFieldName, modeReglement.getInt(foreignBanqueFieldName));
 
valEcheance.put("ETS", modeReglement.getObject("ETS"));
 
if (!modeReglement.isForeignEmpty("ID_SEPA_MANDATE")) {
valEcheance.put("ID_SEPA_MANDATE", modeReglement.getForeignID("ID_SEPA_MANDATE"));
} else if (rowClient != null && !rowClient.isForeignEmpty("ID_SEPA_MANDATE_DEFAULT")) {
valEcheance.put("ID_SEPA_MANDATE", rowClient.getForeignID("ID_SEPA_MANDATE_DEFAULT"));
} else {
SEPAMandateSQLElement mandateElem = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(SEPAMandateSQLElement.class);
final String mandateID = mandateElem.generateMandateIdentification("Facturation", '0', true, true);
// TODO gestion si pas de client (ex : don ou cotisation association)
if (rowClient != null) {
final SQLRowValues newVals = mandateElem.createRecurrent(rowClient.getID(), mandateID, source.getDate("DATE").getTime());
SQLRow rowMandate = newVals.commit();
valEcheance.put("ID_SEPA_MANDATE", rowMandate.getID());
rowClient.createEmptyUpdateRow().put("ID_SEPA_MANDATE_DEFAULT", rowMandate.getID()).commit();
}
}
}
 
// ajout de l'ecriture
SQLRow row = valEcheance.insert();
SQLRowValues rowVals = new SQLRowValues(tableMouvement);
342,7 → 384,8
}
}
 
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, SQLRow rowClient, SQLRow modeRegl, SQLRow mvtSource, boolean avance, String tiers, SQLRowAccessor cptTiers) throws Exception {
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, SQLRow rowClient, SQLRow modeRegl, SQLRow mvtSource, boolean avance, String tiers, SQLRowAccessor cptTiers)
throws SQLException {
 
SQLRowValues valCheque = new SQLRowValues(base.getTable("CHEQUE_A_ENCAISSER"));
SQLPreferences prefs = SQLPreferences.getMemCached(valCheque.getTable().getDBRoot());
396,7 → 439,7
if (rowPrefsCompte.getObject("ID_JOURNAL_VALEUR_ENCAISSEMENT") != null && !rowPrefsCompte.isForeignEmpty("ID_JOURNAL_VALEUR_ENCAISSEMENT")) {
idJournal = rowPrefsCompte.getForeignID("ID_JOURNAL_VALEUR_ENCAISSEMENT");
}
 
this.putValue("ID_JOURNAL", idJournal);
this.putValue("ID_COMPTE_PCE", idCompteClient);
this.putValue("DEBIT", Long.valueOf(0));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirFournisseur.java
64,7 → 64,9
this.putValue("NOM", "Avoir fournisseur : " + avoirRow.getString("NUMERO") + " " + rowFourn.getString("NOM"));
this.putValue("ID_JOURNAL", GenerationMvtAvoirFournisseur.journal);
this.putValue("ID_MOUVEMENT", Integer.valueOf(1));
 
if (rowFourn.getTable().getTable("ECRITURE").contains("CODE_CLIENT")) {
this.putValue("CODE_CLIENT", rowFourn.getString("CODE"));
}
// on cree un nouveau mouvement
if (this.idMvt == 1) {
getNewMouvement(GenerationMvtAvoirFournisseur.source, this.idAvoirFourn, 1, "Avoir Fournisseur : " + avoirRow.getString("NUMERO"));
87,6 → 89,7
}
}
}
 
this.putValue("ID_COMPTE_PCE", Integer.valueOf(idCompteAchat));
this.putValue("DEBIT", Long.valueOf(0));
this.putValue("CREDIT", Long.valueOf(prixHT.getLongValue()));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtDepotChequeClient.java
96,7 → 96,7
rowValsDepotElt.putNulls("MONTANT", "TIERS", "PIECE");
rowValsDepotElt.putRowValues("ID_CLIENT").putNulls("NOM", "ID_COMPTE_PCE");
final SQLRowValues rowValuesChq = rowValsDepotElt.putRowValues("ID_CHEQUE_A_ENCAISSER");
rowValuesChq.putNulls("SANS_VALEUR_ENCAISSEMENT").putRowValues("ID_MOUVEMENT").putNulls("ID_PIECE");
rowValuesChq.putNulls("SANS_VALEUR_ENCAISSEMENT").putRowValues("ID_MOUVEMENT").putRowValues("ID_PIECE").putNulls("NOM");
rowValuesChq.putNulls("ID_COMPTE_PCE_TIERS").putNulls("NUMERO");
List<SQLRowValues> cheques = SQLRowValuesListFetcher.create(rowValsDepotElt).fetch(new Where(rowValsDepotElt.getTable().getField("ID_DEPOT_CHEQUE"), "=", depot.getID()));
for (SQLRowValues sqlRowAccessor : cheques) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Piece.java
15,6 → 15,8
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInsert;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.users.User;
 
import java.util.ArrayList;
import java.util.List;
41,9 → 43,11
return mouvements;
}
 
public SQLInsert createInsert(final DBRoot root) {
public SQLInsert createInsert(final DBRoot root, User user) {
final SQLInsert insert = new SQLInsert();
insert.add(root.getTable("PIECE").getField("NOM"), this.nom);
final SQLTable table = root.getTable("PIECE");
insert.add(table.getField("NOM"), this.nom);
insert.addCreationTrackedField(user, table);
return insert;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Compte.java
16,6 → 16,7
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInsert;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.users.User;
 
public class Compte {
private final Long id;
54,14 → 55,16
return ((Compte) obj).numero.equalsIgnoreCase(this.numero);
}
 
SQLInsert createInsert(DBRoot root) {
SQLInsert createInsert(DBRoot root, User user) {
final SQLInsert insert = new SQLInsert();
final SQLTable table = root.getTable("COMPTE_PCE");
insert.add(table.getField("NUMERO"), this.numero);
insert.add(table.getField("NOM"), this.nom);
insert.addCreationTrackedField(user, table);
return insert;
}
 
 
@Override
public String toString() {
return "Compte numero:" + this.numero + " " + this.nom + " (id:" + this.id + ")";
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Exercice.java
72,7 → 72,7
LOGGER.log(Level.INFO, "insertion de {0} pièces comptables", pieces.size());
for (Piece p : pieces) {
// Pièces
insertsPiece.add(p.createInsert(root));
insertsPiece.add(p.createInsert(root, user));
 
// Vérification des mouvements
final List<Mouvement> mouvements = p.getMouvements();
156,7 → 156,7
// journal non déjà existant
if (codesDesJournauxExistants.get(journal.getCode().toLowerCase()) == null) {
list.add(journal);
insertsJournaux.add(journal.createInsert(root));
insertsJournaux.add(journal.createInsert(root, user));
}
}
final List<Number> journauxIds = new ArrayList<>();
207,7 → 207,7
LOGGER.fine("création du compte : " + c.getNumero().toLowerCase());
}
list.add(c);
insertsComptes.add(c.createInsert(root));
insertsComptes.add(c.createInsert(root, user));
}
}
List<Number> comptesIds = new ArrayList<>();
352,7 → 352,7
piece.setId(idsPieces.get(i));
for (Mouvement m : piece.getMouvements()) {
listMvtWithoutIDs.add(m);
insertsMouvement.add(m.createInsert(root));
insertsMouvement.add(m.createInsert(root, user));
}
}
 
370,11 → 370,11
}
List<SQLUpdate> mvtUpdate = new ArrayList<>();
for (int i = 0; i < idsMouvements.size(); i++) {
maxMvt++;
Number mvtId = idsMouvements.get(i);
SQLUpdate update = new SQLUpdate(new Where(tableMvt.getKey(), "=", mvtId));
update.add(tableMvt.getField("NUMERO"), maxMvt);
mvtUpdate.add(update);
maxMvt++;
listMvtWithoutIDs.get(i).setId(mvtId);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSepa.java
New file
0,0 → 1,171
/*
* 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.
*/
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
 
package org.openconcerto.erp.generationEcritures;
 
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.StringUtils;
 
import java.util.ArrayList;
import java.util.List;
 
public class GenerationMvtSepa extends GenerationEcritures {
 
private long montant;
 
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
private final List<SQLRow> sepaRows;
private SQLRowAccessor banque;
 
public GenerationMvtSepa(List<SQLRow> sepaRows) {
 
this.sepaRows = sepaRows;
// SQLRow chequeRow = base.getTable("CHEQUE_A_ENCAISSER").getRow(this.idCheque);
// String num = "";
// if (chequeRow != null && !chequeRow.isUndefined() &&
// chequeRow.getString("NUMERO").trim().length() > 0) {
// num = " N° " + chequeRow.getString("NUMERO");
// }
//
// if (s != null && s.trim().length() > 0) {
// this.nom = s + (num.trim().length() > 0 ? " - Cheque" + num : "");
// } else {
// this.nom = "Reglement cheque client" + num;
// }
}
 
public void genere() throws Exception {
System.err.println("génération des ecritures de règlement d'un prelevement client du mouvement " + this.idMvt);
List<Integer> pieceIDs = new ArrayList<>();
for (SQLRow rowSepa : sepaRows) {
this.montant = rowSepa.getLong("MONTANT");
this.date = rowSepa.getDate("DATE").getTime();
this.banque = rowSepa.getForeign("ID_" + BanqueSQLElement.TABLENAME);
 
final SQLRowAccessor foreignPiece = rowSepa.getForeign("ID_MOUVEMENT").getForeign("ID_PIECE");
this.nom = "Prélèvement " + foreignPiece.getString("NOM");
final SQLRowAccessor clientRow = rowSepa.getForeign("ID_CLIENT");
 
// Création de l'encaissement
SQLRowValues rowVals = new SQLRowValues(base.getTable("ENCAISSER_MONTANT"));
rowVals.put("MONTANT", montant);
rowVals.put("ID_CLIENT", clientRow != null ? clientRow.getID() : null);
rowVals.put("TIERS", rowSepa.getString("TIERS"));
rowVals.put("DATE", this.date);
SQLRowValues rowValsRegl = new SQLRowValues(base.getTable("MODE_REGLEMENT"));
rowValsRegl.put("ID_TYPE_REGLEMENT", TypeReglementSQLElement.PRELEVEMENT);
SQLRow copy = rowValsRegl.insert();
rowVals.put("ID_MODE_REGLEMENT", copy.getID());
rowVals.put("NOM", this.nom);
// rowVals.put("ID_MOUVEMENT", this.idMvt);
SQLRow rowEncaisse = rowVals.insert();
 
SQLRowValues rowValsElt = new SQLRowValues(base.getTable("ENCAISSER_MONTANT_ELEMENT"));
rowValsElt.put("MONTANT_REGLE", this.montant);
rowValsElt.put("ID_ENCAISSER_MONTANT", rowEncaisse.getID());
rowValsElt.put("ID_MOUVEMENT_ECHEANCE", rowSepa.getForeignID("ID_MOUVEMENT"));
rowValsElt.insert();
 
this.idMvt = getNewMouvement(rowEncaisse.getTable().getName(), rowEncaisse.getID(), rowSepa.getForeignID("ID_MOUVEMENT"), foreignPiece.getID());
rowEncaisse.createEmptyUpdateRow().put("ID_MOUVEMENT", this.idMvt).commit();
 
// initialisation des valeurs de la map
this.putValue("ID_MOUVEMENT", new Integer(this.idMvt));
this.putValue("DATE", new java.sql.Date(this.date.getTime()));
this.putValue("NOM", this.nom);
if (this.banque == null || this.banque.isUndefined() || this.banque.isForeignEmpty("ID_JOURNAL")) {
fillJournalBanqueFromRow(rowSepa);
} else {
int idJrnl = this.banque.getForeignID("ID_JOURNAL");
this.putValue("ID_JOURNAL", idJrnl);
}
 
this.putValue("NOM", this.nom + " " + foreignPiece.getString("NOM") + " " + StringUtils.limitLength(clientRow.getString("NOM"), 20));
// compte Clients
SQLRowAccessor rowCptTiers = rowSepa.getForeign("ID_COMPTE_PCE_TIERS");
int idCompteClient = rowCptTiers != null && !rowCptTiers.isUndefined() ? rowCptTiers.getID() : -1;
 
if (idCompteClient == -1) {
if (clientRow != null) {
idCompteClient = clientRow.getInt("ID_COMPTE_PCE");
}
if (idCompteClient <= 1) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
}
 
this.putValue("ID_COMPTE_PCE", new Integer(idCompteClient));
this.putValue("DEBIT", new Long(0));
this.putValue("CREDIT", new Long(rowSepa.getLong("MONTANT")));
ajoutEcriture();
 
// compte de reglement cheque, ...
fillCompteBanqueFromRow(rowSepa, "VenteCheque", false);
this.putValue("NOM", this.nom);
this.putValue("DEBIT", new Long(this.montant));
this.putValue("CREDIT", new Long(0));
ajoutEcriture();
 
pieceIDs.add(foreignPiece.getID());
 
System.err.println("Ecritures générées pour le mouvement " + this.idMvt);
}
 
lettrageAuto(pieceIDs, this.date);
 
// TODO mettre à jour la date de réglement dee la facture
}
 
// private void setDateReglement(int idCheque, Date d) throws SQLException {
// if (idCheque > 1) {
// SQLRow chequeRow =
// Configuration.getInstance().getBase().getTable("CHEQUE_A_ENCAISSER").getRow(idCheque);
// final int sourceId = MouvementSQLElement.getSourceId(chequeRow.getInt("ID_MOUVEMENT"));
// SQLRow rowMvt = Configuration.getInstance().getBase().getTable("MOUVEMENT").getRow(sourceId);
//
// if (rowMvt.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
// SQLElement eltFacture =
// Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
// SQLRow saisieRow = eltFacture.getTable().getRow(rowMvt.getInt("IDSOURCE"));
// // On fixe la date du paiement
// SQLRowValues rowValsUpdateVF = saisieRow.createEmptyUpdateRow();
// rowValsUpdateVF.put("DATE_REGLEMENT", new Timestamp(d.getTime()));
// rowValsUpdateVF.update();
// }
// }
// }
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementAchat.java
21,10 → 21,13
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.UpdateBuilder;
 
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
61,6 → 64,8
 
List<SQLRow> l = regMontantRow.getReferentRows(regMontantRow.getTable().getTable("REGLER_MONTANT_ELEMENT"));
int mvtSource = -1;
List<Integer> factureFids = new ArrayList<Integer>();
 
for (SQLRow sqlRow : l) {
SQLRow mvtEch = sqlRow.getForeignRow("ID_MOUVEMENT_ECHEANCE");
if (mvtEch.getID() != mvtSource) {
69,6 → 74,12
mvtSource = mvtEch.getID();
}
}
if (!sqlRow.isForeignEmpty("ID_ECHEANCE_FOURNISSEUR")) {
SQLRow ech = sqlRow.getForeign("ID_ECHEANCE_FOURNISSEUR");
if (!ech.isForeignEmpty("ID_FACTURE_FOURNISSEUR")) {
factureFids.add(ech.getForeignID("ID_FACTURE_FOURNISSEUR"));
}
}
}
 
SQLRow rowMvtSource = tableMouvement.getRow(mvtSource);
124,6 → 135,9
ajoutEcriture();
 
}
 
setDateReglement(regMontantRow.getTable().getTable("FACTURE_FOURNISSEUR"), factureFids, this.date);
 
} else {
 
Date dateEch = ModeDeReglementSQLElement.calculDate(modeRegRow.getInt("AJOURS"), modeRegRow.getInt("LENJOUR"), this.date);
141,7 → 155,7
// Ajout dans echeance
Map<String, Object> mEcheance = new HashMap<String, Object>();
 
this.idMvt = getNewMouvement("ECHEANCE_FOURNISSEUR", 1, rowMvtSource.getID(), rowMvtSource.getInt("ID_PIECE"));
this.idMvt = getNewMouvement(rowMvtSource.getString("SOURCE"), rowMvtSource.getInt("IDSOURCE"), rowMvtSource.getID(), rowMvtSource.getInt("ID_PIECE"));
mEcheance.put("ID_MOUVEMENT", new Integer(this.idMvt));
 
mEcheance.put("DATE", dateEch);
162,6 → 176,15
}
}
 
private void setDateReglement(SQLTable table, List<Integer> ids, Date d) throws SQLException {
if (!ids.isEmpty()) {
UpdateBuilder b = new UpdateBuilder(table);
b.setObject("DATE_REGLEMENT", d);
b.setWhere(new Where(table.getKey(), ids));
table.getDBSystemRoot().getDataSource().execute(b.asString());
}
}
 
private void paiementCheque(Date dateEch, SQLRow rowMvtSource, int idFourn, int idRegMontant) throws SQLException {
 
SQLRow regMontantRow = base.getTable("REGLER_MONTANT").getRow(idRegMontant);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtReglementFactureFournisseur.java
16,8 → 16,10
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
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.payment.element.ModeDeReglementSQLElement;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.model.PrixTTC;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
25,11 → 27,14
import org.openconcerto.utils.ExceptionHandler;
 
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
// FIXME mettre toute les generations dans des threads à part
78,7 → 83,7
this.nom = "Règlement Achat : " + rowFournisseur.getString("NOM") + " Facture : " + saisieRow.getObject("NUMERO").toString() + " (" + typeRegRow.getString("NOM") + ")";
 
// si paiement comptant
if ((modeRegRow.getInt("AJOURS") == 0) && (modeRegRow.getInt("LENJOUR") == 0)) {
if ((modeRegRow.getInt("AJOURS") == 0) && (modeRegRow.getInt("LENJOUR") == 0) && !typeRegRow.getBoolean("ECHEANCE")) {
 
System.out.println("Règlement Comptant");
// test Cheque
134,6 → 139,7
this.putValue("CREDIT", Long.valueOf(prixTTC.getLongValue()));
ajoutEcriture();
}
setDateReglement(saisieRow, this.date);
} else {
 
Date dateEch = ModeDeReglementSQLElement.calculDate(modeRegRow.getInt("AJOURS"), modeRegRow.getInt("LENJOUR"), this.date);
151,6 → 157,7
// Ajout dans echeance
Map<String, Object> mEcheance = new HashMap<String, Object>();
 
SQLTable echeanceTable = base.getTable("ECHEANCE_FOURNISSEUR");
SQLRow rowMvtPere = tableMouvement.getRow(this.idPere);
this.idMvt = getNewMouvement("ECHEANCE_FOURNISSEUR", 1, this.idPere, rowMvtPere.getInt("ID_PIECE"));
 
157,9 → 164,14
mEcheance.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
mEcheance.put("DATE", new java.sql.Date(dateEch.getTime()));
mEcheance.put("MONTANT", Long.valueOf(prixTTC.getLongValue()));
mEcheance.put("ID_FOURNISSEUR", Integer.valueOf(saisieRow.getInt("ID_FOURNISSEUR")));
mEcheance.put("ID_FOURNISSEUR", saisieRow.getForeignID("ID_FOURNISSEUR"));
mEcheance.put("ID_FACTURE_FOURNISSEUR", saisieRow.getID());
if (saisieRow.getTable().contains("ID_AFFAIRE") && echeanceTable.contains("ID_AFFAIRE")) {
if (!saisieRow.isForeignEmpty("ID_AFFAIRE")) {
mEcheance.put("ID_AFFAIRE", saisieRow.getForeignID("ID_AFFAIRE"));
}
}
 
SQLTable echeanceTable = base.getTable("ECHEANCE_FOURNISSEUR");
SQLRowValues valEcheance = new SQLRowValues(echeanceTable, mEcheance);
 
if (valEcheance.getInvalid() == null) {
227,6 → 239,14
 
}
 
private void setDateReglement(SQLRow source, Date d) throws SQLException {
 
SQLRowValues rowValsUpdateVF = source.createEmptyUpdateRow();
rowValsUpdateVF.put("DATE_REGLEMENT", d);
rowValsUpdateVF.update();
 
}
 
public void run() {
try {
genereReglement();
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Journal.java
16,6 → 16,7
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInsert;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.users.User;
 
public class Journal {
private final Long id;
54,11 → 55,12
return ((Journal) obj).code.equalsIgnoreCase(this.code);
}
 
SQLInsert createInsert(DBRoot root) {
SQLInsert createInsert(DBRoot root, User user) {
final SQLInsert insert = new SQLInsert();
final SQLTable table = root.getTable("JOURNAL");
insert.add(table.getField("CODE"), this.code);
insert.add(table.getField("NOM"), this.nom);
insert.addCreationTrackedField(user, table);
return insert;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLComponent.java
16,8 → 16,10
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
27,8 → 29,11
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenu;
49,6 → 54,7
 
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
70,8 → 76,6
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
import com.lowagie.text.Font;
 
public class CustomerSQLComponent extends GroupSQLComponent {
private ContactItemTable table;
private ClientCodeArticleTable tableCustomProduct;
326,9 → 330,48
});
}
}
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.COMPTE_CLIENT_AUTO, Boolean.FALSE)) {
createCompteClientFromCodeAuto(id);
}
return id;
}
 
private void createCompteClientFromCodeAuto(int idClient) {
final SQLRow rowClient = getTable().getRow(idClient);
if (rowClient.isForeignEmpty("ID_COMPTE_PCE")) {
 
SQLRowValues rowVals = rowClient.createEmptyUpdateRow();
final String text = rowClient.getString("CODE");
 
String compte = "411" + text;
 
SQLTable table = getTable().getForeignTable("ID_COMPTE_PCE");
SQLSelect selCompte = new SQLSelect();
selCompte.addSelectFunctionStar("COUNT");
selCompte.setArchivedPolicy(SQLSelect.BOTH);
selCompte.setWhere(new Where(table.getField("NUMERO"), "LIKE", compte + "%"));
System.err.println(selCompte.asString());
Object o = getTable().getDBRoot().getDBSystemRoot().getDataSource().executeScalar(selCompte.asString());
 
int nb = 0;
if (o != null) {
Long i = (Long) o;
nb = i.intValue();
}
if (nb > 0) {
compte = compte + nb;
}
int idCpt = ComptePCESQLElement.getId(compte, rowClient.getString("NOM"));
rowVals.put("ID_COMPTE_PCE", idCpt);
try {
rowVals.update();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
 
private JComponent createAdressesComponent() {
final JTabbedPane tabbedAdresse = new JTabbedPane() {
public void insertTab(String title, Icon icon, Component component, String tip, int index) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerGroup.java
75,6 → 75,7
gPayment.addItem("BIC", LayoutHints.DEFAULT_FIELD_HINTS);
gPayment.addItem("ID_MODE_REGLEMENT", new LayoutHints(true, true, true, true, true, false, true, true));
gPayment.addItem("ID_COMPTE_PCE");
gPayment.addItem("ID_SEPA_MANDATE_DEFAULT");
gPayment.addItem("ENCOURS_MAX");
gPayment.addItem("ID_COMPTE_PCE_PRODUIT");
gPayment.addItem("ID_COMPTE_PCE_SERVICE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/EmailTemplate.java
24,6 → 24,7
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
42,8 → 43,6
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
 
import com.lowagie.text.Font;
 
public class EmailTemplate {
private String name;
private String title;
137,7 → 136,7
if (t.isDefault) {
l.setFont(l.getFont().deriveFont(Font.BOLD));
} else {
l.setFont(l.getFont().deriveFont(Font.NORMAL));
l.setFont(l.getFont().deriveFont(Font.PLAIN));
}
return l;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/EmailTemplateSQLComponent.java
25,7 → 25,7
 
@Override
protected SQLRowValues createDefaults() {
final SQLRowValues defaultValues = super.createDefaults();
final SQLRowValues defaultValues = new SQLRowValues(getTable());
defaultValues.put("FORMAT_DATE", "dd/MM/yyyy");
return defaultValues;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceSheet.java
14,10 → 14,12
package org.openconcerto.erp.core.finance.accounting.report;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.element.objet.Compte;
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
import org.openconcerto.erp.generationDoc.SheetInterface;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
26,6 → 28,7
import org.openconcerto.utils.GestionDevise;
 
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
67,7 → 70,7
return TEMPLATE_ID;
}
 
public BalanceSheet(Date du, Date au, String compteDeb, String compteEnd, boolean centralClient, boolean centralFourn, boolean centralFournImmo) {
public BalanceSheet(Date du, Date au, String compteDeb, String compteEnd, boolean centralClient, boolean centralFourn, boolean centralFournImmo, boolean displayAll) {
super();
 
Calendar cal = Calendar.getInstance();
84,7 → 87,7
// this.locationPDF = storage.getPDFOutputDirectory(TEMPLATE_ID);
this.dateAu = au;
this.dateDu = du;
 
this.viewMode = displayAll;
this.compteDeb = compteDeb;
this.compteEnd = compteEnd;
this.centralClient = centralClient;
121,45 → 124,11
this.mapStyleRow.put(new Integer(row), "Titre 1");
}
 
private boolean viewMode = true;
 
protected void createMap() {
 
this.mapReplace = new HashMap();
this.mCell = new HashMap();
this.mapStyleRow = new HashMap();
 
SQLSelect sel = new SQLSelect();
sel.addSelect(tableCompte.getField("ID"));
sel.addSelect(tableEcriture.getField("DEBIT"), "SUM");
sel.addSelect(tableEcriture.getField("CREDIT"), "SUM");
 
Where w = (new Where(tableEcriture.getField("DATE"), this.dateDu, this.dateAu));
if (dateDu == null) {
w = (new Where(tableEcriture.getField("DATE"), "<=", this.dateAu));
}
 
if (compteDeb.equals(this.compteEnd)) {
w = w.and(new Where(tableCompte.getField("NUMERO"), "=", this.compteDeb));
} else {
w = w.and(new Where(tableCompte.getField("NUMERO"), (Object) this.compteDeb, (Object) this.compteEnd));
}
 
// FIXME use flag cloture
Where wCloture = new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%");
wCloture = wCloture.and(new Where(tableEcriture.getField("DATE"), "=", this.dateAu));
wCloture = wCloture.or(new Where(tableEcriture.getField("DATE"), "<", this.dateAu));
w = w.and(wCloture);
 
sel.setWhere(w);
 
String req = sel.asString() + " AND \"ECRITURE\".\"ID_COMPTE_PCE\" = \"COMPTE_PCE\".\"ID\" GROUP BY \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"ID\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
 
System.err.println(req);
 
List l = (List) base.getDataSource().execute(req, new ArrayListHandler());
 
int posLine = 1;
int firstLine = 1;
System.err.println("START CREATE Grand livre, NB ecritures " + l.size());
this.nbPage = 0;
long totalDebit, totalCredit, sousTotalDebit, sousTotalCredit;
 
189,160 → 158,279
int j = 0;
String classe = "";
 
SQLSelect selCompte = new SQLSelect();
selCompte.addSelectStar(tableCompte);
List<SQLRow> compteRows = SQLRowListRSH.execute(selCompte);
Map<Integer, SQLRow> mapCompte = new HashMap<Integer, SQLRow>();
for (SQLRow sqlRow : compteRows) {
mapCompte.put(sqlRow.getID(), sqlRow);
}
if (viewMode) {
getBalance();
 
for (int i = 0; i < l.size();) {
for (int i = 0; i < this.vecteurCompte.size();) {
 
System.err.println("START NEW PAGE; POS : " + posLine);
System.err.println("START NEW PAGE; POS : " + posLine);
 
/***************************************************************************************
* ENTETE
**************************************************************************************/
makeEntete(posLine);
posLine += debutFill - 1;
/***************************************************************************************
* ENTETE
**************************************************************************************/
makeEntete(posLine);
posLine += debutFill - 1;
 
/***************************************************************************************
* CONTENU
**************************************************************************************/
for (j = 0; (j < endFill - debutFill + 1) && i < l.size(); j++) {
Object[] o = (Object[]) l.get(i);
int idCpt = Integer.parseInt(o[0].toString());
// SQLRow rowCpt = tableCompte.getRow(idCpt);
SQLRow rowCpt = mapCompte.get(idCpt);
/***************************************************************************************
* CONTENU
**************************************************************************************/
for (j = 0; (j < endFill - debutFill + 1) && i < this.vecteurCompte.size(); j++) {
Compte compte = this.vecteurCompte.get(i);
 
String numeroCpt = rowCpt.getString("NUMERO").trim();
String nomCpt = rowCpt.getString("NOM");
// Changement de classe de compte
if (classe.trim().length() != 0 && numeroCpt.length() > 0 && !classe.trim().equalsIgnoreCase(numeroCpt.substring(0, 1))) {
String numeroCpt = compte.getNumero();
String nomCpt = compte.getNom();
 
makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
long deb = compte.getTotalDebit();
long cred = compte.getTotalCredit();
 
sousTotalCredit = 0;
sousTotalDebit = 0;
classe = numeroCpt.substring(0, 1);
 
} else {
if (classe.trim().length() == 0 && numeroCpt.trim().length() > 0) {
classe = numeroCpt.substring(0, 1);
}
 
long deb = new Double(o[1].toString()).longValue();
long cred = new Double(o[2].toString()).longValue();
 
totalCredit += cred;
sousTotalCredit += cred;
totalDebit += deb;
sousTotalDebit += deb;
 
// Centralisation compte client
if (this.centralClient && (numeroCpt.equalsIgnoreCase("411") || numeroCpt.startsWith("411"))) {
totalDebitClient += deb;
totalCreditClient += cred;
deb = totalDebitClient;
cred = totalCreditClient;
this.mCell.put("A" + posLine, numeroCpt);
this.mCell.put("B" + posLine, nomCpt);
this.mCell.put("C" + posLine, new Double(GestionDevise.currencyToString(deb, false)));
this.mCell.put("D" + posLine, new Double(GestionDevise.currencyToString(cred, false)));
this.mCell.put("E" + posLine, new Double(GestionDevise.currencyToString(deb - cred, false)));
 
if (compte.getSousCompte().isEmpty()) {
this.mapStyleRow.put(new Integer(posLine), "Normal");
} else {
this.mapStyleRow.put(new Integer(posLine), "Titre 1");
}
// Centralisation compte fournisseur immo
else if (this.centralFournImmo && (numeroCpt.equalsIgnoreCase("404") || numeroCpt.startsWith("404"))) {
totalDebitFournImmo += deb;
totalCreditFournImmo += cred;
deb = totalDebitFournImmo;
cred = totalCreditFournImmo;
}
// Centralisation compte fournisseur
else if (this.centralFourn && (numeroCpt.equalsIgnoreCase("401") || numeroCpt.startsWith("401"))) {
totalDebitFourn += deb;
totalCreditFourn += cred;
deb = totalDebitFourn;
cred = totalCreditFourn;
}
i++;
 
if (this.centralClient && !numeroCpt.equalsIgnoreCase("411") && numeroCpt.startsWith("411")) {
if (addedLine || !this.centralFournImmo) {
posLine--;
j--;
} else {
addedLine = true;
}
this.mCell.put("A" + posLine, numCptClient);
this.mCell.put("B" + posLine, nomCptClient);
} else if (this.centralFourn && !numeroCpt.equalsIgnoreCase("401") && numeroCpt.startsWith("401")) {
posLine++;
}
 
if (addedLineFourn) {
posLine--;
j--;
} else {
addedLineFourn = true;
}
if (i >= this.vecteurCompte.size() && j < endFill - debutFill + 1) {
 
this.mCell.put("A" + posLine, numCptFourn);
this.mCell.put("B" + posLine, nomCptFourn);
} else if (this.centralFournImmo && !numeroCpt.equalsIgnoreCase("404") && numeroCpt.startsWith("404")) {
if (addedLineImmo || !this.centralFourn) {
posLine--;
j--;
} else {
addedLineImmo = true;
}
makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
}
 
this.mCell.put("A" + posLine, numCptFournImmo);
this.mCell.put("B" + posLine, nomCptFournImmo);
} else {
this.mCell.put("A" + posLine, numeroCpt);
this.mCell.put("B" + posLine, nomCpt);
}
posLine = firstLine + endFill;
/*
* if (this.mapStyleRow.get(new Integer(posLine - 1)) != null) {
* this.mapStyleRow.put(new Integer(posLine - 1), "Titre 2"); }
*/
 
this.mCell.put("C" + posLine, new Double(GestionDevise.currencyToString(deb, false)));
this.mCell.put("D" + posLine, new Double(GestionDevise.currencyToString(cred, false)));
this.mCell.put("E" + posLine, new Double(GestionDevise.currencyToString(deb - cred, false)));
// Total
this.mCell.put("C" + posLine, ((totalDebit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit, false))));
this.mCell.put("D" + posLine, ((totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalCredit, false))));
this.mCell.put("E" + posLine, (totalDebit - totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit - totalCredit, false)));
 
this.mapStyleRow.put(new Integer(posLine), "Normal");
i++;
}
posLine += 2;
 
// bas de page
makePiedPage(posLine);
 
posLine++;
firstLine = posLine;
this.nbPage++;
 
// if (i >= this.vecteurCompte.size() && j >= (endFill - debutFill + 1)) {
//
// makeEntete(posLine);
// posLine += debutFill - 1;
//
// makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
//
// this.nbPage++;
// }
 
}
} else {
 
if (i >= l.size() && j < endFill - debutFill + 1) {
this.mapReplace = new HashMap();
this.mCell = new HashMap();
this.mapStyleRow = new HashMap();
 
makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
SQLSelect sel = new SQLSelect();
sel.addSelect(tableCompte.getField("ID"));
sel.addSelect(tableEcriture.getField("DEBIT"), "SUM");
sel.addSelect(tableEcriture.getField("CREDIT"), "SUM");
 
Where w = (new Where(tableEcriture.getField("DATE"), this.dateDu, this.dateAu));
if (dateDu == null) {
w = (new Where(tableEcriture.getField("DATE"), "<=", this.dateAu));
}
 
posLine = firstLine + endFill;
/*
* if (this.mapStyleRow.get(new Integer(posLine - 1)) != null) {
* this.mapStyleRow.put(new Integer(posLine - 1), "Titre 2"); }
*/
if (compteDeb.equals(this.compteEnd)) {
w = w.and(new Where(tableCompte.getField("NUMERO"), "=", this.compteDeb));
} else {
w = w.and(new Where(tableCompte.getField("NUMERO"), (Object) this.compteDeb, (Object) this.compteEnd));
}
 
// Total
this.mCell.put("C" + posLine, ((totalDebit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit, false))));
this.mCell.put("D" + posLine, ((totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalCredit, false))));
this.mCell.put("E" + posLine, (totalDebit - totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit - totalCredit, false)));
// FIXME use flag cloture
Where wCloture = new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%");
wCloture = wCloture.and(new Where(tableEcriture.getField("DATE"), "=", this.dateAu));
wCloture = wCloture.or(new Where(tableEcriture.getField("DATE"), "<", this.dateAu));
w = w.and(wCloture);
 
posLine += 2;
sel.setWhere(w);
 
// bas de page
makePiedPage(posLine);
String req = sel.asString() + " AND \"ECRITURE\".\"ID_COMPTE_PCE\" = \"COMPTE_PCE\".\"ID\" GROUP BY \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"ID\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
 
posLine++;
firstLine = posLine;
this.nbPage++;
System.err.println(req);
 
if (i >= l.size() && j >= (endFill - debutFill + 1)) {
List l = (List) base.getDataSource().execute(req, new ArrayListHandler());
 
SQLSelect selCompte = new SQLSelect();
selCompte.addSelectStar(tableCompte);
List<SQLRow> compteRows = SQLRowListRSH.execute(selCompte);
Map<Integer, SQLRow> mapCompte = new HashMap<Integer, SQLRow>();
for (SQLRow sqlRow : compteRows) {
mapCompte.put(sqlRow.getID(), sqlRow);
}
 
for (int i = 0; i < l.size();) {
 
System.err.println("START NEW PAGE; POS : " + posLine);
 
/***************************************************************************************
* ENTETE
**************************************************************************************/
makeEntete(posLine);
posLine += debutFill - 1;
 
makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
/***************************************************************************************
* CONTENU
**************************************************************************************/
for (j = 0; (j < endFill - debutFill + 1) && i < l.size(); j++) {
Object[] o = (Object[]) l.get(i);
int idCpt = Integer.parseInt(o[0].toString());
// SQLRow rowCpt = tableCompte.getRow(idCpt);
SQLRow rowCpt = mapCompte.get(idCpt);
 
String numeroCpt = rowCpt.getString("NUMERO").trim();
String nomCpt = rowCpt.getString("NOM");
// Changement de classe de compte
if (classe.trim().length() != 0 && numeroCpt.length() > 0 && !classe.trim().equalsIgnoreCase(numeroCpt.substring(0, 1))) {
 
makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
 
sousTotalCredit = 0;
sousTotalDebit = 0;
classe = numeroCpt.substring(0, 1);
 
} else {
if (classe.trim().length() == 0 && numeroCpt.trim().length() > 0) {
classe = numeroCpt.substring(0, 1);
}
 
long deb = new Double(o[1].toString()).longValue();
long cred = new Double(o[2].toString()).longValue();
 
totalCredit += cred;
sousTotalCredit += cred;
totalDebit += deb;
sousTotalDebit += deb;
 
// Centralisation compte client
if (this.centralClient && (numeroCpt.equalsIgnoreCase("411") || numeroCpt.startsWith("411"))) {
totalDebitClient += deb;
totalCreditClient += cred;
deb = totalDebitClient;
cred = totalCreditClient;
}
// Centralisation compte fournisseur immo
else if (this.centralFournImmo && (numeroCpt.equalsIgnoreCase("404") || numeroCpt.startsWith("404"))) {
totalDebitFournImmo += deb;
totalCreditFournImmo += cred;
deb = totalDebitFournImmo;
cred = totalCreditFournImmo;
}
// Centralisation compte fournisseur
else if (this.centralFourn && (numeroCpt.equalsIgnoreCase("401") || numeroCpt.startsWith("401"))) {
totalDebitFourn += deb;
totalCreditFourn += cred;
deb = totalDebitFourn;
cred = totalCreditFourn;
}
 
if (this.centralClient && !numeroCpt.equalsIgnoreCase("411") && numeroCpt.startsWith("411")) {
if (addedLine || !this.centralFournImmo) {
posLine--;
j--;
} else {
addedLine = true;
}
this.mCell.put("A" + posLine, numCptClient);
this.mCell.put("B" + posLine, nomCptClient);
} else if (this.centralFourn && !numeroCpt.equalsIgnoreCase("401") && numeroCpt.startsWith("401")) {
 
if (addedLineFourn) {
posLine--;
j--;
} else {
addedLineFourn = true;
}
 
this.mCell.put("A" + posLine, numCptFourn);
this.mCell.put("B" + posLine, nomCptFourn);
} else if (this.centralFournImmo && !numeroCpt.equalsIgnoreCase("404") && numeroCpt.startsWith("404")) {
if (addedLineImmo || !this.centralFourn) {
posLine--;
j--;
} else {
addedLineImmo = true;
}
 
this.mCell.put("A" + posLine, numCptFournImmo);
this.mCell.put("B" + posLine, nomCptFournImmo);
} else {
this.mCell.put("A" + posLine, numeroCpt);
this.mCell.put("B" + posLine, nomCpt);
}
 
this.mCell.put("C" + posLine, new Double(GestionDevise.currencyToString(deb, false)));
this.mCell.put("D" + posLine, new Double(GestionDevise.currencyToString(cred, false)));
this.mCell.put("E" + posLine, new Double(GestionDevise.currencyToString(deb - cred, false)));
 
this.mapStyleRow.put(new Integer(posLine), "Normal");
i++;
}
 
posLine++;
}
 
if (i >= l.size() && j < endFill - debutFill + 1) {
 
makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
}
 
posLine = firstLine + endFill;
/*
* if (this.mapStyleRow.get(new Integer(posLine - 1)) != null) {
* this.mapStyleRow.put(new Integer(posLine - 1), "Titre 2"); }
*/
 
// Total
this.mCell.put("C" + posLine, ((totalDebit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit, false))));
this.mCell.put("D" + posLine, ((totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalCredit, false))));
this.mCell.put("E" + posLine, (totalDebit - totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit - totalCredit, false)));
 
posLine += 2;
 
// bas de page
makePiedPage(posLine);
 
posLine++;
firstLine = posLine;
this.nbPage++;
 
if (i >= l.size() && j >= (endFill - debutFill + 1)) {
 
makeEntete(posLine);
posLine += debutFill - 1;
 
makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
 
this.nbPage++;
}
 
}
 
}
 
// on conserve la page d'origine du model
350,4 → 438,118
this.nbPage--;
}
}
 
private long totalDebitBalance = 0;
private long totalCreditBalance = 0;
private List<Compte> vecteurCompte = new ArrayList<Compte>();
 
public void getBalance() {
 
// Compte numero -- totalDebit
Map<Number, Long> mapCompteDebit = new HashMap<Number, Long>();
Map<Number, Long> mapCompteCredit = new HashMap<Number, Long>();
List<Compte> comptes = new ArrayList<Compte>();
this.totalDebitBalance = 0;
this.totalCreditBalance = 0;
 
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
SQLTable compteTable = base.getTable("COMPTE_PCE");
SQLTable ecritureTable = base.getTable("ECRITURE");
 
SQLSelect sel = new SQLSelect();
 
// On recupere le solde des comptes
sel.addSelect(compteTable.getField("ID"));
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
sel.addSelect(compteTable.getField("NUMERO"));
sel.setDistinct(true);
Where w = (new Where(tableEcriture.getField("DATE"), this.dateDu, this.dateAu));
if (dateDu == null) {
w = (new Where(tableEcriture.getField("DATE"), "<=", this.dateAu));
}
sel.setWhere(w.and(new Where(compteTable.getField("ID"), "=", ecritureTable.getField("ID_COMPTE_PCE"))));
 
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
 
System.out.println(req);
 
Object ob = base.getDataSource().execute(req, new ArrayListHandler());
 
List myList = (List) ob;
 
if (myList.size() != 0) {
 
for (int i = 0; i < myList.size(); i++) {
 
Object[] tmp = (Object[]) myList.get(i);
 
mapCompteDebit.put((Number) tmp[0], Long.parseLong(tmp[1].toString()));
mapCompteCredit.put((Number) tmp[0], Long.parseLong(tmp[2].toString()));
}
}
 
// Création du vecteur balance
sel = new SQLSelect();
 
sel.addSelect(compteTable.getKey());
sel.addSelect(compteTable.getField("NUMERO"));
sel.addSelect(compteTable.getField("NOM"));
 
sel.addRawOrder("\"COMPTE_PCE\".\"NUMERO\"");
 
String reqCompte = sel.asString();
System.out.println(req);
 
Object obCompte = base.getDataSource().execute(reqCompte, new ArrayListHandler());
 
List myListCompte = (List) obCompte;
 
if (myListCompte.size() != 0) {
 
for (int i = 0; i < myListCompte.size(); i++) {
 
Object[] tmp = (Object[]) myListCompte.get(i);
System.err.println("Compte " + tmp[1].toString().trim());
 
long totalDebit = 0;
long totalCredit = 0;
if (mapCompteDebit.get(tmp[0]) != null) {
totalDebit = Long.parseLong(mapCompteDebit.get(tmp[0]).toString());
}
 
if (mapCompteCredit.get(tmp[0]) != null) {
totalCredit = Long.parseLong(mapCompteCredit.get(tmp[0]).toString());
}
 
this.totalDebitBalance += totalDebit;
this.totalCreditBalance += totalCredit;
 
List<String> sousCompte = new ArrayList<>();
for (int j = i + 1; j < (myListCompte.size() - 1); j++) {
Object[] tmpNext = (Object[]) myListCompte.get(j);
if (tmpNext[1].toString().trim().startsWith(tmp[1].toString().trim())) {
System.err.println("Sous Compte " + tmpNext[1].toString().trim());
sousCompte.add(tmpNext[1].toString().trim());
if (mapCompteDebit.get(tmpNext[0]) != null) {
totalDebit += Long.parseLong(mapCompteDebit.get(tmpNext[0]).toString());
}
 
if (mapCompteCredit.get(tmpNext[0]) != null) {
totalCredit += Long.parseLong(mapCompteCredit.get(tmpNext[0]).toString());
}
} else {
break;
}
}
if ((totalDebit != 0.0) || (totalCredit != 0.0)) {
Compte cpt = new Compte(((Number) tmp[0]).intValue(), tmp[1].toString(), tmp[2].toString(), "", totalDebit, totalCredit);
cpt.addSousCompte(sousCompte);
comptes.add(cpt);
}
}
}
 
this.vecteurCompte = comptes;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/JournauxSheetXML.java
191,6 → 191,10
 
values.put("NUMERO_COMPTE", rowEcr.getString("COMPTE_NUMERO"));
 
if (tableEcriture.contains("NOM_PIECE")) {
values.put("NOM_PIECE", rowEcr.getObject("NOM_PIECE"));
}
 
values.put("NUMERO_MOUVEMENT", rowMvt.getObject("NUMERO"));
Object libelle = rowEcr.getObject("NOM");
values.put("LIBELLE", libelle);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java
17,7 → 17,9
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.GestionDevise;
 
import java.text.DateFormat;
24,8 → 26,10
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
 
117,8 → 121,9
// Fix Abaque 208 - 2087
long v014 = this.sommeCompte.soldeCompteDebiteur(109, 109, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("201", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("203", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("232", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("205", this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompte(208, 208, true, this.dateDebut, this.dateFin)
- this.sommeCompte.soldeCompte(2087, 2087, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin);
+ this.sommeCompte.sommeCompteFils("234", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("205", this.dateDebut, this.dateFin)
+ this.sommeCompte.soldeCompte(208, 208, true, this.dateDebut, this.dateFin) - this.sommeCompte.soldeCompte(2087, 2087, true, this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin);
this.m.put("ACTIF1.1", GestionDevise.currencyToString(v014, false));
 
// 016 -SommeSolde( 280, 280* ) - SommeSolde(2905) - SommeSolde (2908)
148,7 → 153,8
// Racine = "210-215, 218, 230-231, 238"
// S028=211...215+218+22+231+238
long v028 = this.sommeCompte.soldeCompte(211, 215, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("218", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("231", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("238", this.dateDebut, this.dateFin);
+ this.sommeCompte.sommeCompteFils("231", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("238", this.dateDebut, this.dateFin)
+ this.sommeCompte.soldeCompte(24, 24, true, this.dateDebut, this.dateFin);
this.m.put("ACTIF1.2", GestionDevise.currencyToString(v028, false));
 
// 030 -SommeSolde( 281, 289* )-SommeSolde( 290, 295* )
579,7 → 585,9
// Racine1 = "7"
// long v136 = -this.sommeCompte.sommeCompteFils("12", dateDebut,
// dateFin);
long v136 = -this.sommeCompte.sommeCompteFils("7", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("6", this.dateDebut, this.dateFin);
long v136 = -this.sommeCompte.sommeCompteFils("12", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("7", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("6", this.dateDebut, this.dateFin);
 
this.m.put("PASSIF3.21", GestionDevise.currencyToString(v136, false));
 
// 137 -N-1: +R136
847,6 → 855,15
this.m.put("PASSIF4.33", "");
this.m.put("PASSIF4.34", "");
 
final SQLField field = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable("COMPTE_PCE").getField("NUMERO");
Where where = new Where(field, "NOT LIKE", "6%");
where = where.and(new Where(field, "NOT LIKE", "7%"));
where = where.and(new Where(field, "NOT LIKE", "8%"));
List<String> unused = this.sommeCompte.getNonUsedCompte(where, this.dateDebut, this.dateFin);
if (unused != null && !unused.isEmpty()) {
JOptionPane.showMessageDialog(null, "Certains comptes n'ont pas été intégré : " + unused);
}
 
p.generateFrom(this.m);
 
SwingUtilities.invokeLater(new Runnable() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033B.java
17,7 → 17,9
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.GestionDevise;
 
import java.text.DateFormat;
24,8 → 26,10
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
 
82,7 → 86,9
this.m.put("PRODUIT1.1", GestionDevise.currencyToString(v215, false));
 
// 214 -SommeSolde( 700, 705* )-SommeSolde( 7090, 7095* )
long v214 = -this.sommeCompte.soldeCompte(700, 705, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(7090, 7095, true, this.dateDeb, this.dateFin);
long v214 = -this.sommeCompte.soldeCompte(700, 705, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte("709", this.dateDeb, this.dateFin)
- this.sommeCompte.soldeCompte(7090, 7095, true, this.dateDeb, this.dateFin);
 
this.m.put("PRODUIT2.1", GestionDevise.currencyToString(v214, false));
 
// 201
264,7 → 270,7
******************************************************************************************/
// 250 SommeSolde( 640, 644* )+SommeSolde( 648, 649* )
long v250 = this.sommeCompte.soldeCompte(644, 644, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(648, 649, true, this.dateDeb, this.dateFin)
+ this.sommeCompte.soldeCompte(641, 641, true, this.dateDeb, this.dateFin)+ this.sommeCompte.soldeCompte(642, 642, true, this.dateDeb, this.dateFin);
+ this.sommeCompte.soldeCompte(641, 641, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(642, 642, true, this.dateDeb, this.dateFin);
this.m.put("CHARGES3.14", GestionDevise.currencyToString(v250, false));
 
// 220
369,8 → 375,8
* PRODUITS EXCEPTIONNELS
******************************************************************************************/
// 290 -SommeSolde( 77, 77* )-SommeSolde( 787, 789* )-SommeSolde( 797, 799* )
long v290 = -this.sommeCompte.soldeCompte(770, 772, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(775, 778, true, this.dateDeb, this.dateFin)
- this.sommeCompte.soldeCompte(787, 787, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(797, 797, true, this.dateDeb, this.dateFin);
long v290 = -this.sommeCompte.soldeCompte(77, 77, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(787, 787, true, this.dateDeb, this.dateFin)
- this.sommeCompte.soldeCompte(797, 797, true, this.dateDeb, this.dateFin);
this.m.put("PCHARGES3.22", GestionDevise.currencyToString(v290, false));
 
// 245
484,6 → 490,14
this.m.put("T4.41", "");
this.m.put("T2.42", "");
 
final SQLField field = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable("COMPTE_PCE").getField("NUMERO");
Where where = new Where(field, "LIKE", "6%");
where = where.or(new Where(field, "LIKE", "7%"));
List<String> unused = this.sommeCompte.getNonUsedCompte(where, this.dateDeb, this.dateFin);
if (unused != null && !unused.isEmpty()) {
JOptionPane.showMessageDialog(null, "Certains comptes n'ont pas été intégré : " + unused);
}
 
// final SQLField field =
// ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable("COMPTE_PCE").getField("NUMERO");
// Where where = new Where(field, "LIKE", "6%");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ImportEcritureFECAction.java
New file
0,0 → 1,42
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.finance.accounting.action;
 
import org.openconcerto.erp.core.finance.accounting.ui.ImportEcritureFECPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.PanelFrame;
 
import java.awt.event.ActionEvent;
 
import javax.swing.AbstractAction;
 
public class ImportEcritureFECAction extends AbstractAction {
 
public ImportEcritureFECAction() {
super("Import d'écritures FEC");
 
}
 
@Override
public void actionPerformed(ActionEvent e) {
 
final PanelFrame frame = new PanelFrame(new ImportEcritureFECPanel(Configuration.getInstance().getDirectory()), "Import d'écritures FEC");
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
FrameUtil.show(frame);
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ImportEcriturePanel.java
112,12 → 112,6
button.setEnabled(false);
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, ImportEcriturePanel.this);
final FileDialog fd = new FileDialog(frame, "Import d'écritures", FileDialog.LOAD);
fd.setFilenameFilter(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith("." + ContentTypeVersioned.SPREADSHEET.getExtension());
}
});
fd.setVisible(true);
rlPanel.setMode(ReloadPanel.MODE_ROTATE);
if (fd.getFile() != null) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteGestCommPreferencePanel.java
44,9 → 44,9
 
public class CompteGestCommPreferencePanel extends DefaultPreferencePanel {
 
private ISQLCompteSelector selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteValeurEncaissement, selCompteAvanceClient, selCompteClient, selCompteVenteProduits,
private ISQLCompteSelector selCompteCBAttente, selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteValeurEncaissement, selCompteAvanceClient, selCompteClient, selCompteVenteProduits,
selCompteVenteService, selCompteTVACol, selCompteTVADed, selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis;
private ElementComboBox selJrnlFactor, selJrnlValEnc;
private ElementComboBox selJrnlFactor, selJrnlValEnc, selJrnlCB;
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte);
186,6 → 186,27
this.selJrnlValEnc.init(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
this.add(this.selJrnlValEnc, c);
 
// Journal
c.gridy++;
c.weightx = 0;
c.gridx = 0;
this.add(new JLabel("Journal CB Attente"), c);
c.weightx = 1;
c.gridx++;
this.selJrnlCB = new ElementComboBox();
this.selJrnlCB.init(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
this.add(this.selJrnlCB, c);
 
c.gridy++;
c.weightx = 0;
c.gridx = 0;
this.add(new JLabel("Compte CB Attente"), c);
c.weightx = 1;
c.gridx++;
this.selCompteCBAttente = new ISQLCompteSelector();
this.selCompteCBAttente.init();
this.add(this.selCompteCBAttente, c);
 
// Compte vente produits
c.gridy++;
c.weightx = 0;
341,6 → 362,9
final int selectedIdEnc = this.selJrnlValEnc.getSelectedId();
this.rowPrefCompteVals.put("ID_JOURNAL_VALEUR_ENCAISSEMENT", (selectedIdEnc > 1) ? selectedIdEnc : 1);
 
final int selectedIdCB = this.selJrnlCB.getSelectedId();
this.rowPrefCompteVals.put("ID_JOURNAL_CB_ATTENTE", (selectedIdCB > 1) ? selectedIdCB : 1);
this.rowPrefCompteVals.put("ID_COMPTE_PCE_CB_ATTENTE", this.selCompteCBAttente.getSelectedId() > 1 ? this.selCompteCBAttente.getSelectedId() : 1);
this.rowPrefCompteVals.put("ID_COMPTE_PCE_FOURNISSEUR", this.selCompteFourn.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_CLIENT", this.selCompteClient.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_AVANCE_CLIENT", this.selCompteAvanceClient.getValue());
480,7 → 504,20
}
this.selJrnlFactor.setValue(value);
}
 
{
// Journal CB
int value = (this.rowPrefCompteVals.getObject("ID_JOURNAL_CB_ATTENTE") == null ? 1 : this.rowPrefCompteVals.getInt("ID_JOURNAL_CB_ATTENTE"));
if (value > 1) {
this.selJrnlCB.setValue(value);
}
 
int valueCpt = (this.rowPrefCompteVals.getObject("ID_COMPTE_PCE_CB_ATTENTE") == null ? 1 : this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_CB_ATTENTE"));
if (valueCpt > 1) {
this.selCompteCBAttente.setValue(valueCpt);
}
}
{
// Journal Val enc
int value = (this.rowPrefCompteVals.getObject("ID_JOURNAL_VALEUR_ENCAISSEMENT") == null ? 1 : this.rowPrefCompteVals.getInt("ID_JOURNAL_VALEUR_ENCAISSEMENT"));
if (value <= 1) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieJournalItemTable.java
34,7 → 34,6
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JComponentUtils;
48,6 → 47,7
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
109,9 → 109,9
final SQLElement elt = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
 
// TODO Obligation de choisir un compte correct
final List<SQLTableElement> list = new Vector<SQLTableElement>();
final List<SQLTableElement> list = new Vector<>();
final SQLTable tableElement = elt.getTable();
final SQLTableElement tableElementJour = new SQLTableElement(tableElement.getField("JOUR"), Integer.class, rangedIntegerTableCellEditor) {
final SQLTableElement tableElementJour = new SQLTableElement(tableElement.getField("JOUR"), Integer.class, this.rangedIntegerTableCellEditor) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
 
158,6 → 158,7
final MultiLineTableCellEditor multiLineTableCellEditor = new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable);
 
SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class, multiLineTableCellEditor) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
return vals.getString("NUMERO") != null && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"));
};
173,12 → 174,10
final int debitIndex = getColumnIndexForElement(SaisieJournalItemTable.this.debit);
final int creditIndex = getColumnIndexForElement(SaisieJournalItemTable.this.credit);
 
// float debitVal = ((Float) model.getValueAt(rowIndex, debitIndex);
 
if (debitIndex == columnIndex && ((Long) aValue).longValue() != 0 && ((Long) getValueAt(rowIndex, creditIndex)).longValue() != 0) {
if (debitIndex == columnIndex && ((Number) aValue).longValue() != 0 && ((Number) getValueAt(rowIndex, creditIndex)).longValue() != 0) {
setValueAt(Long.valueOf(0), rowIndex, creditIndex);
} else {
if (creditIndex == columnIndex && ((Long) aValue).longValue() != 0 && ((Long) getValueAt(rowIndex, debitIndex)).longValue() != 0) {
if (creditIndex == columnIndex && ((Number) aValue).longValue() != 0 && ((Number) getValueAt(rowIndex, debitIndex)).longValue() != 0) {
setValueAt(Long.valueOf(0), rowIndex, debitIndex);
}
}
189,54 → 188,54
ToolTipManager.sharedInstance().unregisterComponent(this.table);
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
 
tableElementNomEcriture.getTableCellEditor(table).addCellEditorListener(new CellEditorListener() {
tableElementNomEcriture.getTableCellEditor(this.table).addCellEditorListener(new CellEditorListener() {
 
@Override
public void editingStopped(ChangeEvent e) {
e.getSource();
int row = table.getSelectedRow();
int row = SaisieJournalItemTable.this.table.getSelectedRow();
int col = 4;
if (table.getValueAt(row, col) != null) {
defaultRowVals.put("NOM_ECRITURE", table.getValueAt(row, col));
if (SaisieJournalItemTable.this.table.getValueAt(row, col) != null) {
defaultRowVals.put("NOM_ECRITURE", SaisieJournalItemTable.this.table.getValueAt(row, col));
}
// defaultRowVals.put
 
}
 
@Override
public void editingCanceled(ChangeEvent e) {
// TODO Auto-generated method stub
//
 
}
});
tableElementNomPiece.getTableCellEditor(table).addCellEditorListener(new CellEditorListener() {
tableElementNomPiece.getTableCellEditor(this.table).addCellEditorListener(new CellEditorListener() {
 
@Override
public void editingStopped(ChangeEvent e) {
e.getSource();
int row = table.getSelectedRow();
int row = SaisieJournalItemTable.this.table.getSelectedRow();
int col = 3;
if (table.getValueAt(row, col) != null) {
defaultRowVals.put("NOM_PIECE", table.getValueAt(row, col));
if (SaisieJournalItemTable.this.table.getValueAt(row, col) != null) {
defaultRowVals.put("NOM_PIECE", SaisieJournalItemTable.this.table.getValueAt(row, col));
}
// defaultRowVals.put
 
}
 
@Override
public void editingCanceled(ChangeEvent e) {
// TODO Auto-generated method stub
//
 
}
});
 
tableElementJour.getTableCellEditor(table).addCellEditorListener(new CellEditorListener() {
tableElementJour.getTableCellEditor(this.table).addCellEditorListener(new CellEditorListener() {
 
@Override
public void editingStopped(ChangeEvent e) {
final Object valueAt = table.getValueAt(0, 0);
final Object valueAt = SaisieJournalItemTable.this.table.getValueAt(0, 0);
defaultRowVals.put("JOUR", valueAt);
if (table.getRowCount() > 1) {
for (int i = 1; i < table.getRowCount(); i++) {
table.getRowValuesTableModel().putValue(valueAt, i, "JOUR");
if (SaisieJournalItemTable.this.table.getRowCount() > 1) {
for (int i = 1; i < SaisieJournalItemTable.this.table.getRowCount(); i++) {
SaisieJournalItemTable.this.table.getRowValuesTableModel().putValue(valueAt, i, "JOUR");
}
}
}
243,25 → 242,13
 
@Override
public void editingCanceled(ChangeEvent e) {
// TODO Auto-generated method stub
 
//
}
});
;
 
final KeyListener keyListenerContrepartie = new KeyListener() {
final KeyListener keyListenerContrepartie = new KeyAdapter() {
 
@Override
public void keyTyped(KeyEvent e) {
 
}
 
@Override
public void keyReleased(KeyEvent e) {
 
}
 
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
montantValid(defaultRowVals, false, textField);
281,7 → 268,7
@Override
public ValidState getValidState(Object o) {
if (o != null) {
return elt.getCompteNumeroValidState(o.toString());
return this.elt.getCompteNumeroValidState(o.toString());
}
return super.getValidState(o);
}
298,12 → 285,10
m2.setFillWithField("NOM");
m2.setWhere(w);
 
TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
 
JButton buttonClone = new JButton(TM.tr("duplicateLine"));
JButton buttonClone = new JButton(TM.tr(Configuration.getInstance().getLocale(), "duplicateLine"));
buttonClone.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
cloneLine(table.getSelectedRow());
cloneLine(SaisieJournalItemTable.this.table.getSelectedRow());
}
});
buttonClone.setEnabled(false);
332,7 → 317,7
public void tableChanged(TableModelEvent e) {
// Sélectionne automatiquement la ligne ajoutée
if (e.getType() == TableModelEvent.INSERT) {
if (table.getRowCount() == 1) {
if (SaisieJournalItemTable.this.table.getRowCount() == 1) {
editCellAt(e.getFirstRow(), 0);
} else {
editCellAt(e.getFirstRow(), 1);
397,7 → 382,7
final PropertyChangeListener lActiveAddButton = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
controlPanel.setButtonAjouterEnabled(!panel.getBoxJournal().isEmpty() && !panel.getBoxMois().isEmpty());
SaisieJournalItemTable.this.controlPanel.setButtonAjouterEnabled(!panel.getBoxJournal().isEmpty() && !panel.getBoxMois().isEmpty());
}
};
panel.getBoxJournal().addModelListener("wantedID", lActiveAddButton);
414,7 → 399,7
c.set(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.YEAR, (Integer) SaisieJournalItemTable.this.panel.spin.getValue());
c.set(Calendar.MONTH, SaisieJournalItemTable.this.panel.getSelectedMonth());
rangedIntegerTableCellEditor.setMax(c.getActualMaximum(Calendar.DAY_OF_MONTH));
SaisieJournalItemTable.this.rangedIntegerTableCellEditor.setMax(c.getActualMaximum(Calendar.DAY_OF_MONTH));
}
}
}
429,14 → 414,14
long totalD = 0L;
long totalC = 0L;
 
for (int i = 0; i < table.getRowCount(); i++) {
Long c = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("DEBIT"));
Long d = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("CREDIT"));
for (int i = 0; i < this.table.getRowCount(); i++) {
Number c = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("DEBIT"));
Number d = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("CREDIT"));
if (c != null) {
totalC += c;
totalC += c.longValue();
}
if (d != null) {
totalD += d;
totalD += d.longValue();
}
 
}
453,19 → 438,19
long totalC = 0L;
boolean cptOK = true;
String lib = null;
for (int i = 0; i < table.getRowCount(); i++) {
Long c = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("DEBIT"));
Long d = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("CREDIT"));
for (int i = 0; i < this.table.getRowCount(); i++) {
Number c = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("DEBIT"));
Number d = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("CREDIT"));
if (c != null) {
totalC += c;
totalC += c.longValue();
}
if (d != null) {
totalD += d;
totalD += d.longValue();
}
if (lib == null) {
lib = (String) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("NOM"));
lib = (String) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("NOM"));
}
String cptNUmber = (String) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("NUMERO"));
String cptNUmber = (String) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("NUMERO"));
cptOK = cptOK && cptNUmber != null && ComptePCESQLElement.isExist(cptNUmber);
}
return totalD + totalC != 0 && totalD == totalC && cptOK;
475,10 → 460,10
int day = 1;
String lib = null;
 
for (int i = 0; i < table.getRowCount(); i++) {
day = (Integer) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("JOUR"));
for (int i = 0; i < this.table.getRowCount(); i++) {
day = (Integer) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("JOUR"));
if (lib == null) {
lib = (String) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("NOM"));
lib = (String) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("NOM"));
}
}
// Create saisieKM
490,13 → 475,12
}
 
public void montantValid(final SQLRowValues defaultRowVals, final boolean fromAnalytique, final JTextField textPiece) {
System.err.println("Enter");
final SQLRowValues vals = SaisieJournalItemTable.this.table.getSelectedRowValues();
final int selectedRow = SaisieJournalItemTable.this.table.getSelectedRow();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
 
if (boxAutoInsert.isSelected() && isSaisieValid()) {
if (SaisieJournalItemTable.this.boxAutoInsert.isSelected() && isSaisieValid()) {
if (SaisieJournalItemTable.this.panel.getSelectedJournal() == SQLRow.NONEXISTANT_ID || SaisieJournalItemTable.this.panel.getSelectedMonth() == -1) {
JOptionPane.showMessageDialog(SaisieJournalItemTable.this.panel, "Impossible de créer la saisie si aucun journal ou aucun mois n'est sélectionné!");
} else {
503,7 → 487,8
createSaisie(defaultRowVals, textPiece);
}
} else {
if (!fromAnalytique && !hideAnalytique && vals.getString("NUMERO") != null && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"))) {
if (!fromAnalytique && !SaisieJournalItemTable.this.hideAnalytique && vals.getString("NUMERO") != null
&& (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"))) {
 
// Update montant
Collection<SQLRowValues> rowsLinked = vals.getReferentRows(vals.getTable().getTable("ASSOCIATION_ANALYTIQUE"));
513,7 → 498,7
.setScale(0, RoundingMode.HALF_UP).longValue());
}
 
editCellAt(selectedRow, table.getRowValuesTableModel().getColumnForField("ANALYTIQUE"));
editCellAt(selectedRow, SaisieJournalItemTable.this.table.getRowValuesTableModel().getColumnForField("ANALYTIQUE"));
} else {
 
long l = getContrepartie();
551,19 → 536,19
try {
id = rowVAlsKM.insert().getID();
 
table.updateField("ID_SAISIE_KM", id);
table.clear();
this.table.updateField("ID_SAISIE_KM", id);
this.table.clear();
GenerationMvtSaisieKm gen = new GenerationMvtSaisieKm(id);
int idMvt = gen.genereMouvement();
 
// maj de l'id du mouvement correspondant
SQLRowValues rowValsKMMvt = new SQLRowValues(SaisieJournalItemTable.this.table.getRowValuesTableModel().getSQLElement().getTable().getForeignTable("ID_SAISIE_KM"));
rowValsKMMvt.put("ID_MOUVEMENT", new Integer(idMvt));
rowValsKMMvt.put("ID_MOUVEMENT", Integer.valueOf(idMvt));
rowValsKMMvt.update(id);
 
defaultRowVals.put("NOM_PIECE", "");
defaultRowVals.put("NOM_ECRITURE", "");
table.getRowValuesTableModel().addNewRow();
this.table.getRowValuesTableModel().addNewRow();
pieceText.setText("");
} catch (SQLException e) {
e.printStackTrace();
626,11 → 611,11
final int debitIndex = model.getColumnIndexForElement(getDebitElement());
for (int i = 0; i < this.table.getRowCount(); i++) {
if (model.isRowValid(i)) {
final Long fTc = (Long) model.getValueAt(i, creditIndex);
final Number fTc = (Number) model.getValueAt(i, creditIndex);
if (fTc != null) {
totalCred += fTc.longValue();
}
final Long fTd = (Long) model.getValueAt(i, debitIndex);
final Number fTd = (Number) model.getValueAt(i, debitIndex);
if (fTd != null) {
totalDeb += fTd.longValue();
}
653,7 → 638,7
assert SwingUtilities.isEventDispatchThread();
if (text == null)
return;
RowValuesTableModel model = table.getRowValuesTableModel();
RowValuesTableModel model = this.table.getRowValuesTableModel();
int size = model.getRowCount();
for (int i = 0; i < size; i++) {
SQLRowValues r = model.getRowValuesAt(i);
664,6 → 649,7
model.fireTableDataChanged();
}
 
@Override
public void mousePressed(final MouseEvent e) {
final int rowSel = this.table.getSelectedRow();
if (e.getButton() == MouseEvent.BUTTON3 && rowSel >= 0 && rowSel < this.table.getRowCount()) {
692,22 → 678,28
}
}
 
@Override
public void mouseReleased(final MouseEvent e) {
// Nothing
}
 
@Override
public void mouseClicked(final MouseEvent e) {
// Nothing
}
 
@Override
public void mouseEntered(final MouseEvent e) {
// Nothing
}
 
@Override
public void mouseExited(final MouseEvent e) {
// Nothing
}
 
private void cloneLine(int row) {
if (row < 0) {
System.err.println("RowValuesTableControlPanel.cloneLine() wrong selected line, index = " + row);
Thread.dumpStack();
return;
}
SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(row);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ImpressionBalancePanel.java
50,6 → 50,7
private JCheckBox checkClientCentral;
private JCheckBox checkFournCentral;
private JCheckBox checkFournImmoCentral;
private JCheckBox checkTotalRacine;
private JProgressBar bar = new JProgressBar(0, 3);
private JTextField compteDeb, compteEnd;
 
122,6 → 123,13
this.checkFournImmoCentral = new JCheckBox("Centralisation des comptes fournisseurs d'immobilisations");
this.add(this.checkFournImmoCentral, c);
 
// Centralisation Fournisseurs
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridx = 0;
this.checkTotalRacine = new JCheckBox("Total par racine");
this.add(this.checkTotalRacine, c);
 
// Progress bar
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
163,7 → 171,7
new Thread(new Runnable() {
public void run() {
BalanceSheet bSheet = new BalanceSheet(dateStart.getDate(), dateEnd.getDate(), compteDeb.getText(), compteEnd.getText(), checkClientCentral.isSelected(),
checkFournCentral.isSelected(), checkFournImmoCentral.isSelected());
checkFournCentral.isSelected(), checkFournImmoCentral.isSelected(), checkTotalRacine.isSelected());
final SpreadSheetGeneratorCompta generator = new SpreadSheetGeneratorCompta(bSheet, "Balance" + new Date().getTime(), checkImpr.isSelected(), checkVisu.isSelected());
 
SwingUtilities.invokeLater(new Runnable() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieKmItemTable.java
166,7 → 166,7
m2.setWhere(w);
 
TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
JButton buttonClone = new JButton(TM.tr("duplicateLine"));
JButton buttonClone = new JButton(TM.tr(Configuration.getInstance().getLocale(), "duplicateLine"));
buttonClone.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
cloneLine(table.getSelectedRow());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ImportEcritureFECPanel.java
New file
0,0 → 1,110
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.panel.compta.ImportFEC;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.ReloadPanel;
import org.openconcerto.ui.SwingThreadUtils;
 
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
 
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 
public class ImportEcritureFECPanel extends JPanel {
 
private final Map<String, Integer> mapJournal = new HashMap<>();
private final Map<String, Integer> mapCompte = new HashMap<>();
 
public ImportEcritureFECPanel(final SQLElementDirectory dir) {
super(new GridBagLayout());
 
JLabel label = new JLabel("Import depuis un fichier au format FEC.");
final JButton button = new JButton("Sélectionner le ficher");
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = 2;
this.add(label, c);
c.gridy++;
c.gridwidth = 1;
c.weightx = 1;
final ReloadPanel rlPanel = new ReloadPanel();
c.anchor = GridBagConstraints.EAST;
c.fill = GridBagConstraints.NONE;
this.add(rlPanel, c);
c.gridx++;
c.weightx = 0;
this.add(button, c);
 
button.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
button.setEnabled(false);
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, ImportEcritureFECPanel.this);
final FileDialog fd = new FileDialog(frame, "Import d'écritures", FileDialog.LOAD);
fd.setVisible(true);
rlPanel.setMode(ReloadPanel.MODE_ROTATE);
if (fd.getFile() != null) {
 
new Thread() {
@Override
public void run() {
final File fileToImport = new File(fd.getDirectory(), fd.getFile());
ImportFEC fec = new ImportFEC();
try {
fec.loadFrom(fileToImport);
fec.importTo(dir, dir.getElement("ECRITURE").getTable().getDBRoot(), UserManager.getUser());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
if (fd != null) {
rlPanel.setMode(ReloadPanel.MODE_EMPTY);
}
JOptionPane.showMessageDialog(null, "Import terminé!");
}
});
 
}
}
}.start();
}
}
});
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/LettragePanel.java
104,6 → 104,10
private JDate dateDeb, dateFin, dateLettrage;
 
public LettragePanel() {
this(ComptePCESQLElement.getId("4"));
}
 
public LettragePanel(int idCompte) {
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
124,7 → 128,7
}
createComboRequest.setWhere(new Where(eltCpt.getTable().getField("NUMERO"), function, "^4.*$"));
this.selCompte.init(eltCpt, createComboRequest);
this.selCompte.setValue(ComptePCESQLElement.getId("4"));
this.selCompte.setValue(idCompte);
 
c.gridx++;
c.weightx = 1;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/SommeCompte.java
123,6 → 123,62
return sommeDebit - sommeCredit;
}
 
public long soldeCompte(String numeroCompte, Date dateDebut, Date dateFin) {
 
long sommeDebit = 0;
long sommeCredit = 0;
 
SQLTable ecritureTable = base.getTable("ECRITURE");
SQLTable compteTable = base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect();
 
sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
// sel.addSelect(compteTable.getField("ID"));
// sel.addSelect(compteTable.getField("NUMERO"));
 
// Where w = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=",
// compteTable.getField("ID"));
sel.addJoin("LEFT", ecritureTable.getField("ID_COMPTE_PCE"));
Where w2 = new Where(compteTable.getField("NUMERO"), "LIKE", numeroCompte);
this.compteUsed.add(numeroCompte);
Where w4 = new Where(ecritureTable.getField("DATE"), dateDebut, dateFin);
 
if (this.removeClotureCompte) {
 
Where w5 = new Where(ecritureTable.getField("NOM"), "NOT LIKE", "Fermeture du compte %");
sel.setWhere(w2.and(w4).and(w5));
} else {
sel.setWhere(w2.and(w4));
}
addAnalytiqueJoin(sel);
 
// String req = sel.asString() +
// " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\" ORDER BY
// \"COMPTE_PCE\".\"NUMERO\"";
String req = sel.asString();
 
Object ob = base.getDataSource().execute(req, new ArrayListHandler());
 
List myList = (List) ob;
 
if (myList.size() != 0) {
 
for (int i = 0; i < myList.size(); i++) {
 
Object[] objTmp = (Object[]) myList.get(i);
if (objTmp[0] != null) {
sommeDebit += ((Number) objTmp[0]).longValue();
}
if (objTmp[1] != null) {
sommeCredit += ((Number) objTmp[1]).longValue();
}
}
}
 
return sommeDebit - sommeCredit;
}
 
/***********************************************************************************************
* Calcul le solde débiteur des comptes compris dans l'intervalle numeroStart numeroEnd
*
380,7 → 436,7
this.compteUsed.clear();
}
 
public void getNonUsedCompte(Where where, Date dateDebut, Date dateFin) {
public List<String> getNonUsedCompte(Where where, Date dateDebut, Date dateFin) {
 
SQLSelect sel = new SQLSelect();
final SQLTable table = base.getTable("COMPTE_PCE");
402,6 → 458,6
for (String string : s) {
System.err.println("Compte " + s);
}
 
return s;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java
20,6 → 20,7
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.accounting.ui.AssociationAnalytiquePanel;
import org.openconcerto.erp.core.finance.accounting.ui.ConsultationCompteFrame;
import org.openconcerto.erp.core.finance.accounting.ui.LettragePanel;
import org.openconcerto.erp.core.finance.accounting.ui.LettrageRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.ListEcritureRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.ListeDesEcrituresPanel;
100,6 → 101,18
consult.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(consult);
 
PredicateRowAction interrogation = new PredicateRowAction(new AbstractAction("Interrogation du compte") {
public void actionPerformed(ActionEvent event) {
 
SQLRowAccessor row = IListe.get(event).getSelectedRow();
 
PanelFrame f = new PanelFrame(new LettragePanel(row.getForeignID("ID_COMPTE_PCE")), "Lettrage manuel par compte");
f.setVisible(true);
}
}, false);
interrogation.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(interrogation);
 
PredicateRowAction contre = new PredicateRowAction(new AbstractAction("Contrepassation") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.contrePassationPiece(IListe.get(event).getSelectedId());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/SaisieKmSQLElement.java
15,6 → 15,7
 
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.SaisieKmItemTable;
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieKm;
import org.openconcerto.sql.Configuration;
114,6 → 115,7
SQLTable ecrTable = base.getTable("ECRITURE");
SQLTable compteTable = base.getTable("COMPTE_PCE");
SQLTable saisieKmTable = base.getTable("SAISIE_KM_ELEMENT");
SQLTable assocTable = base.getTable("ASSOCIATION_ANALYTIQUE");
 
SQLRowValues vals = new SQLRowValues(base.getTable("SAISIE_KM"));
vals.put("ID_MOUVEMENT", new Integer(idMvt));
152,7 → 154,16
valsTmp.put("DEBIT", rowEcrTmp.getObject("DEBIT"));
valsTmp.put("CREDIT", rowEcrTmp.getObject("CREDIT"));
valsTmp.put("ID_ECRITURE", new Integer(rowEcrTmp.getID()));
valsTmp.insert();
 
List<SQLRow> assocRows = rowEcrTmp.getReferentRows(assocTable);
if (assocRows.size() > 0) {
for (int a = 0; a < assocRows.size(); a++) {
assocRows.get(a).createUpdateRow().put("ID_SAISIE_KM_ELEMENT", valsTmp);
}
valsTmp.put("ANALYTIQUE", AnalytiqueItemTable.getStringAssocs(valsTmp));
}
 
valsTmp.commit();
}
 
Object[] objTmp = (Object[]) myListEcriture.get(0);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/model/TaxeCache.java
38,7 → 38,7
final DBRoot root = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete();
final SQLTable table = root.getTable("TAXE");
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.putNulls("TAUX", "CODE", "NOM", "ID_TAXE", "DEFAULT");
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");
for (String foreignFieldName : compteFields) {
51,6 → 51,7
private final Map<SQLRowAccessor, Float> mapRowTaux = new LinkedHashMap<>();
private static TaxeCache instance;
private SQLRow firstIdTaxe = null;
private SQLRow firstIdTaxeAchat = null;
 
private TaxeCache() {
loadCache();
61,6 → 62,7
this.mapRowTaux.clear();
this.mapTaux.clear();
this.firstIdTaxe = null;
this.firstIdTaxeAchat = null;
 
final SQLRowValuesListFetcher sel = getSel();
 
71,6 → 73,9
if (sqlRow.getBoolean("DEFAULT")) {
this.firstIdTaxe = sqlRow.asRow();
}
if (sqlRow.getBoolean("DEFAULT_ACHAT")) {
this.firstIdTaxeAchat = sqlRow.asRow();
}
}
}
 
123,6 → 128,20
return this.firstIdTaxe;
}
 
public synchronized SQLRow getFirstTaxeAchat() {
if (this.firstIdTaxeAchat == null) {
final SQLRowValuesListFetcher sel = getSel();
final List<SQLRowValues> rows = sel.fetch(new Where(sel.getReq().getTable("TAXE").getField("DEFAULT_ACHAT"), "=", Boolean.TRUE));
if (rows != null && !rows.isEmpty()) {
this.firstIdTaxeAchat = rows.get(0).asRow();
} else {
this.firstIdTaxeAchat = getFirstTaxe();
}
 
}
return this.firstIdTaxeAchat;
}
 
public synchronized Integer getIdFromTaux(Float tax) {
Set<Integer> s = mapTaux.keySet();
for (Integer integer : s) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/SDDMessageSQLElement.java
75,10 → 75,12
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import java.util.prefs.Preferences;
 
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import javax.swing.SwingWorker;
 
import org.jdom2.Document;
import org.jdom2.Element;
113,11 → 115,29
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
// XML field values are quite large so only fetch them when needed
final SQLTable t = l.getSource().getPrimaryTable();
final SQLSelect sel = new SQLSelect().addSelectStar(t);
sel.setWhere(new Where(t.getKey(), l.getSelection().getUserSelectedIDs()));
exportXML(l, SQLRowListRSH.execute(sel));
final Set<Integer> userSelectedIDs = l.getSelection().getUserSelectedIDs();
new SwingWorker<List<SQLRow>, Void>() {
@Override
protected List<SQLRow> doInBackground() throws Exception {
final SQLSelect sel = new SQLSelect().addSelectStar(t);
// XML field values are quite large so only fetch them when needed
sel.setWhere(new Where(t.getKey(), userSelectedIDs));
return SQLRowListRSH.execute(sel);
}
 
@Override
protected void done() {
List<SQLRow> execute;
try {
execute = get();
exportXML(l, execute);
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
 
}
}.execute();
}
}, true, false).setPredicate(IListeEvent.getNonEmptySelectionPredicate()));
this.rowSociété = conf.getRowSociete();
196,7 → 216,11
}
 
protected static BigDecimal getInvoiceAmount(final SQLRowValues invoice) {
return BigDecimal.valueOf(invoice.getLong("NET_A_PAYER")).movePointLeft(2);
if (invoice.getTable().getName().equals("SAISIE_VENTE_FACTURE")) {
return BigDecimal.valueOf(invoice.getLong("NET_A_PAYER")).movePointLeft(2);
} else {
return BigDecimal.valueOf(invoice.getLong("MONTANT")).movePointLeft(2);
}
}
 
static private final class InvoiceElem extends Tuple2<SQLRowValues, Element> {
296,6 → 320,47
return IgnoreReason.NONE;
}
 
final IgnoreReason addEcheance(final SQLRowValues prlvt) {
Date date = prlvt.getDate("DATE").getTime();
 
// don't ask direct debit too far in advance
if (date.after(this.upperBound)) {
return IgnoreReason.TOO_FAR_IN_FUTURE;
} else if (date.before(this.lowerBound)) {
date = this.lowerBound;
}
 
final Element elem;
try {
elem = createDDTx(this.elemCreator, prlvt);
} catch (MissingInfoException e) {
return IgnoreReason.MISSING_INFO;
}
 
// needed so that EndToEndId is unique
if (!this.invoiceNumbers.add(prlvt.getForeign("ID_MOUVEMENT").getForeign("ID_PIECE").getString("NOM")))
throw new IllegalStateException("Duplicate invoice number : " + prlvt);
final SQLRowAccessor mandate = prlvt.getForeign("ID_SEPA_MANDATE");
if (!mandate.getBoolean("ACTIVE"))
throw new IllegalStateException("Inactive mandate for " + prlvt);
// needed otherwise would have to update seqType while generating
// MAYBE sum all invoices for a single mandate, but which date to choose ?
if (!this.invoiceMandates.add(mandate.getString("MandateIdentification")))
return IgnoreReason.DUPLICATE_MANDATE;
 
this.lockedInvoicesIDs.add(prlvt.getIDNumber());
ListMap<String, InvoiceElem> bySeqType = this.map.get(date);
if (bySeqType == null) {
bySeqType = new ListMap<>();
this.map.put(date, bySeqType);
}
bySeqType.add(mandate.getString("SequenceType"), new InvoiceElem(prlvt, elem));
 
this.sum = this.sum.add(BigDecimal.valueOf(prlvt.getLong("MONTANT")).movePointLeft(2));
 
return IgnoreReason.NONE;
}
 
public final int getTransactionCount() {
return this.lockedInvoicesIDs.size();
}
323,9 → 388,12
private final ListMapItf<IgnoreReason, SQLRowValues> ignoredInvoices;
private final SQLRow insertedMessage;
private final int invoiceCount;
private final SQLTable table;
 
protected GenerationResult(Collection<? extends Number> passedIDs, List<SQLRowValues> withDDWithoutMessage, ListMap<IgnoreReason, SQLRowValues> ignoredInvoices, SQLRow insertedMessage) {
protected GenerationResult(SQLTable table, Collection<? extends Number> passedIDs, List<SQLRowValues> withDDWithoutMessage, ListMap<IgnoreReason, SQLRowValues> ignoredInvoices,
SQLRow insertedMessage) {
super();
this.table = table;
this.passedIDs = passedIDs;
this.withDDWithoutMessage = Collections.unmodifiableList(withDDWithoutMessage);
assert !ignoredInvoices.containsKey(null) && !ignoredInvoices.containsKey(IgnoreReason.NONE);
353,6 → 421,10
return this.invoiceCount;
}
 
public SQLTable getTable() {
return table;
}
 
@Override
public String toString() {
return this.getClass().getSimpleName() + ": of the " + this.passedIDs.size() + " passed, " + this.withDDWithoutMessage.size() + " needed a SDD message, of those "
360,7 → 432,7
}
}
 
public GenerationResult generateXML(Collection<? extends Number> invoiceIDs) throws SQLException {
public GenerationResult generateXML(final SQLTable table, Collection<? extends Number> invoiceIDs) throws SQLException {
final Namespace painNS = Namespace.getNamespace("urn:iso:std:iso:20022:tech:xsd:pain.008.001.02");
final Element rootElem = new Element("Document", painNS);
final Namespace xsiNS = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
394,8 → 466,7
}
});
 
final SQLTable invoiceT = getDirectory().getElement(SaisieVenteFactureSQLElement.class).getTable();
final SQLField invoiceSDDMessageF = invoiceT.getField(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME);
final SQLField invoiceSDDMessageF = table.getField(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME);
return SQLUtils.executeAtomic(getTable().getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<GenerationResult, SQLException>() {
@Override
public GenerationResult handle(SQLDataSource ds) throws SQLException {
402,12 → 473,29
final SQLRowValues lockedSociété = selSociété.fetchOne(SDDMessageSQLElement.this.rowSociété.getIDNumber());
if (lockedSociété == null)
throw new IllegalStateException("Missing société " + SDDMessageSQLElement.this.rowSociété);
if (lockedSociété.getString("IBAN").trim().length() == 0) {
throw new IllegalStateException("Missing société IBAN " + SDDMessageSQLElement.this.rowSociété);
}
 
if (lockedSociété.getString("BIC").trim().length() == 0) {
throw new IllegalStateException("Missing société BIC " + SDDMessageSQLElement.this.rowSociété);
}
 
// find and lock invoices with TYPE_REGLEMENT direct debit and no message
final SQLRowValues invoiceVals = new SQLRowValues(invoiceT);
invoiceVals.putRowValues("ID_CLIENT").putNulls("NOM", "BIC", "IBAN");
invoiceVals.putRowValues("ID_MODE_REGLEMENT").putNulls("AJOURS", "LENJOUR").putRowValues("ID_SEPA_MANDATE").setAllToNull();
invoiceVals.putNulls("NET_A_PAYER", "DATE", "NUMERO", "NOM");
final SQLRowValues invoiceVals = new SQLRowValues(table);
 
final boolean fromInvoices = table.getName().equals("SAISIE_VENTE_FACTURE");
if (fromInvoices) {
invoiceVals.putRowValues("ID_CLIENT").putNulls("NOM", "BIC", "IBAN");
invoiceVals.putRowValues("ID_MODE_REGLEMENT").putNulls("AJOURS", "LENJOUR").putRowValues("ID_SEPA_MANDATE").setAllToNull();
invoiceVals.putNulls("NET_A_PAYER", "DATE", "NUMERO", "NOM");
} else {
invoiceVals.putRowValues("ID_CLIENT").putNulls("NOM", "BIC", "IBAN");
invoiceVals.putRowValues("ID_SEPA_MANDATE").setAllToNull();
invoiceVals.putNulls("MONTANT", "DATE");
invoiceVals.putRowValues("ID_MOUVEMENT").putRowValues("ID_PIECE").setAllToNull();
}
 
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(invoiceVals);
fetcher.setReturnedRowsUnmodifiable(true);
// required for locking rows and to make sure that there's a SEPA Mandate
417,19 → 505,28
public SQLSelect transformChecked(SQLSelect sel) {
// we will update FACTURE.ID_MESSAGE
sel.setLockStrength(LockStrength.UPDATE);
final SQLSelectJoin join = sel.getJoin(invoiceT.getField("ID_MODE_REGLEMENT"));
join.setWhere(new Where(join.getJoinedTable().getField("ID_TYPE_REGLEMENT"), "=", TypeReglementSQLElement.PRELEVEMENT));
if (fromInvoices) {
final SQLSelectJoin join = sel.getJoin(table.getField("ID_MODE_REGLEMENT"));
join.setWhere(new Where(join.getJoinedTable().getField("ID_TYPE_REGLEMENT"), "=", TypeReglementSQLElement.PRELEVEMENT));
}
return sel;
}
});
final List<SQLRowValues> ddInvoices = fetcher
.fetch(new Where(invoiceT.getKey(), invoiceIDs).and(new Where(invoiceSDDMessageF, "=", invoiceSDDMessageF.getForeignTable().getUndefinedIDNumber())));
.fetch(new Where(table.getKey(), invoiceIDs).and(new Where(invoiceSDDMessageF, "=", invoiceSDDMessageF.getForeignTable().getUndefinedIDNumber())));
final InvoicesByPaymentInfo map = new InvoicesByPaymentInfo(lowerBound, upperBound, new ElementCreator(painNS, SDDMessageSQLElement.this.fieldTranslator));
final ListMap<IgnoreReason, SQLRowValues> ignoredInvoices = new ListMap<>();
for (final SQLRowValues invoice : ddInvoices) {
final IgnoreReason ignoredReason = map.addInvoice(invoice);
if (ignoredReason != IgnoreReason.NONE) {
ignoredInvoices.add(ignoredReason, invoice);
if (fromInvoices) {
final IgnoreReason ignoredReason = map.addInvoice(invoice);
if (ignoredReason != IgnoreReason.NONE) {
ignoredInvoices.add(ignoredReason, invoice);
}
} else {
final IgnoreReason ignoredReason = map.addEcheance(invoice);
if (ignoredReason != IgnoreReason.NONE) {
ignoredInvoices.add(ignoredReason, invoice);
}
}
}
 
481,7 → 578,7
getTable().getDBRoot().setMetadata(SERIAL_MD, msgSerial);
}
 
return new GenerationResult(invoiceIDs, ddInvoices, ignoredInvoices, newMsg);
return new GenerationResult(table, invoiceIDs, ddInvoices, ignoredInvoices, newMsg);
}
});
}
555,7 → 652,8
res.addContent(creditor);
 
final Element creditorAccount = new Element("CdtrAcct", painNS);
creditorAccount.addContent(new Element("Id", painNS).addContent(elemCreator.createWithNonEmptyText("IBAN", lockedSociété, "IBAN")));
String iban = lockedSociété.getString("IBAN").replaceAll(" ", "");
creditorAccount.addContent(new Element("Id", painNS).addContent(elemCreator.createWithNonEmptyText("IBAN", iban, "IBAN")));
res.addContent(creditorAccount);
 
final Element creditorAgent = new Element("CdtrAgt", painNS);
592,7 → 690,13
invoiceElem.get1().addContent(0, paymentId);
 
// update mandate fields
final SQLRowAccessor mandate = invoiceElem.get0().getForeign("ID_MODE_REGLEMENT").getForeign("ID_SEPA_MANDATE");
final SQLRowAccessor mandate;
if (invoiceElem.get0().contains("ID_SEPA_MANDATE")) {
mandate = invoiceElem.get0().getForeign("ID_SEPA_MANDATE");
} else {
mandate = invoiceElem.get0().getForeign("ID_MODE_REGLEMENT").getForeign("ID_SEPA_MANDATE");
}
 
final String seqType = mandate.getString("SequenceType");
if (seqType.equals(SEPAMandateSQLElement.SEQ_FIRST)) {
mandate.createEmptyUpdateRow().put("SequenceType", SEPAMandateSQLElement.SEQ_RECURRENT).update();
610,7 → 714,14
res.addContent(new Element("InstdAmt", painNS).setAttribute("Ccy", "EUR").setText(getInvoiceAmount(invoice).toPlainString()));
 
final Element mandateRltdInfo = new Element("MndtRltdInf", painNS);
final SQLRowAccessor mandate = invoice.getForeign("ID_MODE_REGLEMENT").getForeign("ID_SEPA_MANDATE");
 
final SQLRowAccessor mandate;
final boolean fromInvoice = invoice.getTable().getName().equals("SAISIE_VENTE_FACTURE");
if (fromInvoice) {
mandate = invoice.getForeign("ID_MODE_REGLEMENT").getForeign("ID_SEPA_MANDATE");
} else {
mandate = invoice.getForeign("ID_SEPA_MANDATE");
}
assert !mandate.isUndefined() : "Undefined mandate returned by fetcher";
mandateRltdInfo.addContent(elemCreator.createWithNonEmptyText("MndtId", mandate, "MandateIdentification"));
mandateRltdInfo.addContent(elemCreator.createWithNonEmptyText("DtOfSgntr", formatDate(mandate.getObjectAs("DateOfSignature", Date.class))));
624,7 → 735,12
 
res.addContent(new Element("Purp", painNS).addContent(new Element("Cd", painNS).setText("OTHR")));
 
final String info = (invoice.getString("NUMERO") + ' ' + invoice.getString("NOM")).trim();
final String info;
if (fromInvoice) {
info = (invoice.getString("NUMERO") + ' ' + invoice.getString("NOM")).trim();
} else {
info = invoice.getForeign("ID_MOUVEMENT").getForeign("ID_PIECE").getString("NOM");
}
if (!info.isEmpty())
res.addContent(new Element("RmtInf", painNS).addContent(elemCreator.create("Ustrd").setText(elemCreator.shortenText(info, 140))));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ReglerMontantSQLElement.java
15,9 → 15,16
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.utils.CollectionUtils;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
 
public class ReglerMontantSQLElement extends ComptaSQLConfElement {
 
28,7 → 35,7
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_ECHEANCE_FOURNISSEUR");
l.add("ID_FOURNISSEUR");
l.add("ID_MODE_REGLEMENT");
l.add("MONTANT");
return l;
41,6 → 48,27
return l;
}
 
@Override
protected void _initTableSource(SQLTableModelSource res) {
super._initTableSource(res);
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"));
}
};
 
res.getColumns().add(racCol);
}
 
public SQLComponent createComponent() {
return new ReglerMontantSQLComponent(this);
};
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ReglerMontantSQLComponent.java
16,6 → 16,7
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.payment.component.ModeDeReglementSQLComponent;
import org.openconcerto.erp.core.finance.payment.ui.RegleMontantTable;
import org.openconcerto.erp.generationEcritures.GenerationReglementAchat;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
145,6 → 146,9
this.addView("ID_MODE_REGLEMENT", BaseSQLComponent.REQ + ";" + BaseSQLComponent.DEC + ";" + BaseSQLComponent.SEP);
final ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
this.add(eltModeRegl, c);
ModeDeReglementSQLComponent modeReglComp;
modeReglComp = (ModeDeReglementSQLComponent) eltModeRegl.getSQLChild();
modeReglComp.addDateCompListener(this.date);
 
this.addRequiredSQLObject(this.date, "DATE");
this.addRequiredSQLObject(this.montant, "MONTANT");
186,10 → 190,7
System.err.println("Set mode de règlement");
int idTypeRegl = rowModeRegl.getInt("ID_TYPE_REGLEMENT");
SQLTable tableModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT").getTable();
SQLRowValues rowVals = new SQLRowValues(tableModeRegl);
if (idTypeRegl > TypeReglementSQLElement.TRAITE) {
idTypeRegl = TypeReglementSQLElement.CHEQUE;
}
SQLRowValues rowVals = new SQLRowValues(tableModeRegl);
rowVals.put("ID_TYPE_REGLEMENT", idTypeRegl);
rowVals.put("COMPTANT", Boolean.TRUE);
rowVals.put("AJOURS", 0);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/DepotChequeSQLElement.java
13,6 → 13,7
package org.openconcerto.erp.core.finance.payment.element;
 
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.finance.payment.component.DepotChequeSQLComponent;
import org.openconcerto.erp.generationDoc.gestcomm.DepotChequeXmlSheet;
47,7 → 48,7
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("NOM");
l.add("ID_BANQUE");
l.add("ID_" + BanqueSQLElement.TABLENAME);
l.add("MONTANT");
return l;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/ui/EncaisseMontantTable.java
62,15 → 62,18
 
final SQLTableElement tableElement_Mvt = new SQLTableElement(e.getTable().getField("ID_MOUVEMENT_ECHEANCE"), Integer.class, new DefaultCellEditor(new JTextField()));
tableElement_Mvt.setRenderer(new KeyTableCellRenderer(Configuration.getInstance().getDirectory().getElement("MOUVEMENT")));
tableElement_Mvt.setEditable(false);
list.add(tableElement_Mvt);
 
// Date
final SQLTableElement dateElement = new SQLTableElement(e.getTable().getField("DATE"), Timestamp.class, new TimestampTableCellEditor());
dateElement.setEditable(false);
list.add(dateElement);
 
// Total HT
montantARegler = new SQLTableElement(e.getTable().getField("MONTANT_A_REGLER"), Long.class, new DeviseCellEditor());
montantARegler.setRenderer(new DeviseNiceTableCellRenderer());
montantARegler.setEditable(false);
list.add(montantARegler);
 
// Total HT
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/EncaisserMontantSQLComponent.java
17,7 → 17,6
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.payment.element.EncaisserMontantSQLElement;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.erp.core.finance.payment.ui.EncaisseMontantTable;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.sql.Configuration;
66,7 → 65,85
private JLabel labelWarning = new JLabelWarning("Le montant est trop élevé!");
 
private JDate date;
private ElementSQLObject eltModeRegl;
 
final TableModelListener tableListener = new TableModelListener() {
 
@Override
public void tableChanged(TableModelEvent e) {
final RowValuesTableModel model = table.getRowValuesTable().getRowValuesTableModel();
if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == model.getColumnIndexForElement(table.getMontantElement())) {
 
final int rowCount = model.getRowCount();
long total = 0;
for (int i = 0; i < rowCount; i++) {
Number nHT = (Number) model.getValueAt(i, model.getColumnIndexForElement(table.getMontantElement()));
if (nHT != null) {
total += nHT.longValue();
}
}
 
montant.getDocument().removeDocumentListener(listenerMontant);
montant.setText(GestionDevise.currencyToString(total));
montant.getDocument().addDocumentListener(listenerMontant);
// Selection du mode de reglement
if (getMode() == SQLComponent.Mode.INSERTION) {
if (rowCount >= 1) {
 
MouvementSQLElement element = getElement().getDirectory().getElement(MouvementSQLElement.class);
SQLRowValues row1 = model.getRowValuesAt(0);
if (row1.getObject("ID_MOUVEMENT_ECHEANCE") != null && !row1.isForeignEmpty("ID_MOUVEMENT_ECHEANCE")) {
final int idScr = element.getSourceId(row1.getForeignID("ID_MOUVEMENT_ECHEANCE"));
SQLTable tableMvt = element.getTable();
if (idScr > 1) {
SQLRow rowMvt = tableMvt.getRow(idScr);
String source = rowMvt.getString("SOURCE");
int idSource = rowMvt.getInt("IDSOURCE");
SQLElement eltSource = element.getDirectory().getElement(source);
if (eltSource != null) {
SQLRow rowSource = eltSource.getTable().getRow(idSource);
 
if (rowSource != null) {
SQLRow rowModeRegl = rowSource.getForeignRow("ID_MODE_REGLEMENT");
if (rowModeRegl != null) {
System.err.println("Set mode de règlement");
int idTypeRegl = rowModeRegl.getInt("ID_TYPE_REGLEMENT");
SQLTable tableModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT").getTable();
SQLRowValues rowVals = new SQLRowValues(tableModeRegl);
rowVals.put("ID_TYPE_REGLEMENT", idTypeRegl);
rowVals.put("COMPTANT", Boolean.TRUE);
rowVals.put("AJOURS", 0);
rowVals.put("LENJOUR", 0);
rowVals.put("ID_" + BanqueSQLElement.TABLENAME, rowModeRegl.getInt("ID_" + BanqueSQLElement.TABLENAME));
eltModeRegl.setValue(rowVals);
}
}
}
}
}
}
}
 
}
if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == model.getColumnIndexForElement(table.getMontantElement())
|| e.getColumn() == model.getColumnIndexForElement(table.getMontantAReglerElement())) {
updateWarning();
}
}
};
 
final SimpleDocumentListener listenerMontant = new SimpleDocumentListener() {
 
@Override
public void update(DocumentEvent e) {
table.getRowValuesTable().getRowValuesTableModel().removeTableModelListener(tableListener);
updateMontant(montant.getText());
table.getRowValuesTable().getRowValuesTableModel().addTableModelListener(tableListener);
updateWarning();
 
}
};
 
public EncaisserMontantSQLComponent(SQLElement elt) {
super(elt);
}
84,7 → 161,6
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.add(this.table, c);
this.table.getRowValuesTable().setEnabled(false);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
c.gridy++;
144,11 → 220,13
 
c.gridx++;
c.gridwidth = 3;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
this.add(this.montant, c);
 
// Warning
c.gridx++;
c.weightx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
this.labelWarning.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(this.labelWarning, c);
170,9 → 248,12
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
this.addView("ID_MODE_REGLEMENT", BaseSQLComponent.REQ + ";" + BaseSQLComponent.DEC + ";" + BaseSQLComponent.SEP);
final ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
this.add(eltModeRegl, c);
this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
this.add(this.eltModeRegl, c);
ModeDeReglementSQLComponent modeReglComp;
 
modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild();
modeReglComp.addDateCompListener(this.date);
this.addRequiredSQLObject(this.date, "DATE");
this.addRequiredSQLObject(this.montant, "MONTANT");
 
182,78 → 263,7
this.addSQLObject(new JTextField(), "TIERS");
DefaultGridBagConstraints.lockMinimumSize(this.montant);
 
final TableModelListener tableListener = new TableModelListener() {
 
@Override
public void tableChanged(TableModelEvent e) {
final RowValuesTableModel model = table.getRowValuesTable().getRowValuesTableModel();
if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == model.getColumnIndexForElement(table.getMontantElement())) {
 
final int rowCount = model.getRowCount();
long total = 0;
for (int i = 0; i < rowCount; i++) {
Number nHT = (Number) model.getValueAt(i, model.getColumnIndexForElement(table.getMontantElement()));
if (nHT != null) {
total += nHT.longValue();
}
}
 
montant.setText(GestionDevise.currencyToString(total));
 
// Selection du mode de reglement
if (getMode() == SQLComponent.Mode.INSERTION) {
if (rowCount >= 1 && model.getRowValuesAt(0).getObject("ID_MOUVEMENT_ECHEANCE") != null && !model.getRowValuesAt(0).isForeignEmpty("ID_MOUVEMENT_ECHEANCE")) {
final int idScr = MouvementSQLElement.getSourceId(model.getRowValuesAt(0).getInt("ID_MOUVEMENT_ECHEANCE"));
SQLTable tableMvt = Configuration.getInstance().getDirectory().getElement("MOUVEMENT").getTable();
if (idScr > 1) {
SQLRow rowMvt = tableMvt.getRow(idScr);
String source = rowMvt.getString("SOURCE");
int idSource = rowMvt.getInt("IDSOURCE");
SQLElement eltSource = Configuration.getInstance().getDirectory().getElement(source);
if (eltSource != null) {
SQLRow rowSource = eltSource.getTable().getRow(idSource);
 
if (rowSource != null) {
SQLRow rowModeRegl = rowSource.getForeignRow("ID_MODE_REGLEMENT");
if (rowModeRegl != null) {
System.err.println("Set mode de règlement");
int idTypeRegl = rowModeRegl.getInt("ID_TYPE_REGLEMENT");
SQLTable tableModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT").getTable();
SQLRowValues rowVals = new SQLRowValues(tableModeRegl);
if (idTypeRegl == TypeReglementSQLElement.INDEFINI) {
idTypeRegl = TypeReglementSQLElement.CHEQUE;
}
rowVals.put("ID_TYPE_REGLEMENT", idTypeRegl);
rowVals.put("COMPTANT", Boolean.TRUE);
rowVals.put("AJOURS", 0);
rowVals.put("LENJOUR", 0);
rowVals.put("ID_" + BanqueSQLElement.TABLENAME, rowModeRegl.getInt("ID_" + BanqueSQLElement.TABLENAME));
eltModeRegl.setValue(rowVals);
}
}
}
}
}
}
 
}
if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == model.getColumnIndexForElement(table.getMontantAReglerElement())) {
updateWarning();
}
}
};
 
this.montant.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void update(DocumentEvent e) {
table.getRowValuesTable().getRowValuesTableModel().removeTableModelListener(tableListener);
updateMontant(montant.getText());
table.getRowValuesTable().getRowValuesTableModel().addTableModelListener(tableListener);
updateWarning();
 
}
});
this.montant.getDocument().addDocumentListener(listenerMontant);
this.table.getRowValuesTable().getRowValuesTableModel().addTableModelListener(tableListener);
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/ModeDeReglementSQLComponent.java
15,6 → 15,7
 
import org.openconcerto.erp.config.Log;
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.erp.model.BanqueModifiedListener;
import org.openconcerto.sql.element.BaseSQLComponent;
40,6 → 41,7
import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
279,6 → 281,39
});
}
 
public void addDateCompListener(JDate dateParent) {
dateParent.addPropertyChangeListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
ModeDeReglementSQLComponent.this.currentDate = dateParent.getValue();
refreshDatePrev();
}
});
dateParent.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
ModeDeReglementSQLComponent.this.currentDate = dateParent.getValue();
refreshDatePrev();
}
});
}
 
private void refreshDatePrev() {
if (this.currentDate != null) {
int aJ = this.comboA.getValue().trim().length() == 0 ? 0 : Integer.valueOf(this.comboA.getValue());
int nJ = this.comboLe.getValue().trim().length() == 0 ? 0 : Integer.valueOf(this.comboLe.getValue());
Date d = ModeDeReglementSQLElement.calculDate(aJ, nJ, this.currentDate);
this.datePrev.setDate(d);
} else {
this.datePrev.setDate(null);
}
}
 
private JDate datePrev = new JDate();
private Date currentDate = null;
 
private void createPanelEcheance() {
 
final GridBagConstraints c = new DefaultGridBagConstraints();
290,6 → 325,13
this.comboA.setMinimumSize(new Dimension(60, this.comboA.getMinimumSize().height));
this.comboA.setPreferredSize(new Dimension(60, this.comboA.getMinimumSize().height));
this.comboA.setMaximumSize(new Dimension(60, this.comboA.getMinimumSize().height));
this.comboA.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
refreshDatePrev();
}
});
this.panelEcheance.add(this.comboA, c);
c.gridx += 1;
c.gridwidth = 1;
300,7 → 342,21
c.fill = GridBagConstraints.HORIZONTAL;
this.buttonDateFacture.setOpaque(false);
this.panelEcheance.add(this.buttonDateFacture, c);
 
c.gridy++;
c.gridx = 0;
c.weightx = 1;
c.gridwidth = 1;
// ((BaseSQLComponent)((ElementSQLObject)getSQLParent()).getSQLParent()).getView("DATE");
this.panelEcheance.add(new JLabel("Soit le"), c);
c.gridx++;
c.gridwidth = 1;
this.datePrev.setEnabled(false);
this.panelEcheance.add(this.datePrev, c);
 
// c.gridy++;
c.gridwidth = 2;
c.gridx = 3;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
this.buttonFinMois.setOpaque(false);
314,6 → 370,13
this.comboLe.setMinimumSize(new Dimension(60, this.comboLe.getMinimumSize().height));
this.comboLe.setPreferredSize(new Dimension(60, this.comboLe.getMinimumSize().height));
this.comboLe.setMaximumSize(new Dimension(60, this.comboLe.getMinimumSize().height));
this.comboLe.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
refreshDatePrev();
}
});
this.panelEcheance.add(this.comboLe, c);
this.panelActive = this.panelEcheance;
this.m.put(Mode.ECHEANCE, this.panelEcheance);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeAmenagementPartielSQLElement.java
New file
0,0 → 1,28
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class CodeAmenagementPartielSQLElement extends AbstractCodeSQLElement {
 
public CodeAmenagementPartielSQLElement(final DBRoot root) {
super(root.getTable("CODE_AMENAGEMENT_PARTIEL"), "un code d'aménagement partiel", "codes d'aménagement partiel");
}
 
@Override
protected String createCode() {
return createCodeOfPackage() + ".partiel.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ReglementPayeSQLElement.java
57,8 → 57,8
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM_BANQUE");
l.add("RIB");
l.add("IBAN");
l.add("BIC");
return l;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeSuspensionSQLElement.java
New file
0,0 → 1,28
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.sql.model.DBRoot;
 
public class CodeSuspensionSQLElement extends AbstractCodeSQLElement {
 
public CodeSuspensionSQLElement(final DBRoot root) {
super(root.getTable("CODE_SUSPENSION"), "un code de suspension", "codes suspension");
}
 
@Override
protected String createCode() {
return createCodeOfPackage() + ".supension.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueBrutSQLElement.java
27,6 → 27,7
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.NoneSelectedButtonGroup;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
69,7 → 70,8
l.add("COTISABLE");
l.add("PART_CP");
l.add("TAXABLE_CM");
 
l.add("CSG_NORMAL");
l.add("CSG_REDUIT");
return l;
}
 
339,6 → 341,28
JCheckBox checkCP = new JCheckBox(getLabelFor("PART_CP"));
panelProp.add(checkCP, cPanel);
 
// CSG Normal
cPanel.gridx = 1;
cPanel.weightx = 1;
cPanel.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
cPanel.gridwidth = GridBagConstraints.REMAINDER;
JCheckBox checkCSGN = new JCheckBox(getLabelFor("CSG_NORMAL"));
panelProp.add(checkCSGN, cPanel);
 
// CSG Réduite
cPanel.gridx = 1;
cPanel.weightx = 1;
cPanel.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
cPanel.gridwidth = GridBagConstraints.REMAINDER;
JCheckBox checkCSGR = new JCheckBox(getLabelFor("CSG_REDUIT"));
panelProp.add(checkCSGR, cPanel);
 
NoneSelectedButtonGroup groupCSG = new NoneSelectedButtonGroup();
groupCSG.add(checkCSGN);
groupCSG.add(checkCSGR);
 
// Type
JLabel labelSelCodeRubrique = new JLabel("Code DSN (S21.G00.51.011)");
labelSelCodeRubrique.setHorizontalAlignment(SwingConstants.RIGHT);
377,6 → 401,8
this.addSQLObject(checkCotis, "COTISABLE");
this.addSQLObject(checkCP, "PART_CP");
this.addSQLObject(checkImpo, "TAXABLE_CM");
this.addSQLObject(checkCSGN, "CSG_NORMAL");
this.addSQLObject(checkCSGR, "CSG_REDUIT");
 
selSalarie.addValueListener(new PropertyChangeListener() {
 
394,7 → 420,7
rowVals.put("TAXABLE_CM", Boolean.TRUE);
rowVals.put("COTISABLE", Boolean.TRUE);
rowVals.put("PART_BRUT", Boolean.TRUE);
 
rowVals.put("CSG_NORMAL", Boolean.TRUE);
return rowVals;
}
};
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/FichePayeSQLElement.java
21,7 → 21,6
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
import org.openconcerto.erp.core.humanresources.payroll.ui.FichePayeRenderer;
import org.openconcerto.erp.core.humanresources.payroll.ui.PanelCumulsPaye;
import org.openconcerto.erp.generationEcritures.GenerationMvtFichePaye;
import org.openconcerto.erp.model.FichePayeModel;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.erp.model.RubriquePayeTree;
49,9 → 48,9
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
102,9 → 101,32
}, true);
actionCumuls.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionCumuls);
PredicateRowAction genererNonSimplifie = new PredicateRowAction(new AbstractAction("Créer le bulletin détaillé") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
SQLRow row = IListe.get(e).getSelectedRow().asRow();
FichePayeSheetXML sheet = new FichePayeSheetXML(row, false);
try {
sheet.createDocument();
sheet.showPrintAndExport(true, false, true);
} catch (Exception e1) {
ExceptionHandler.handle("Erreur lors de la création du document.", e1);
}
}
}, false);
genererNonSimplifie.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(genererNonSimplifie);
}
 
@Override
public ListMap<String, String> getShowAs() {
final ListMap<String, String> map = new ListMap<>();
map.put("ID_SALARIE", Arrays.asList("CODE", "NOM", "PRENOM", "ID_REGLEMENT_PAYE"));
return map;
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_SALARIE");
155,7 → 177,6
JDate dateDu, dateAu;
private JScrollPane paneTreeLeft;
private JPanel pDate;
private JButton buttonValider, buttonGenCompta;
 
public void addViews() {
 
187,7 → 208,7
c.gridheight = 1;
c.gridwidth = 2;
this.selSalCombo = new ElementComboBox();
// c.gridx++;
 
panelRight.add(this.selSalCombo, c);
 
// Mois
199,7 → 220,6
this.dateDu = new JDate();
this.dateAu = new JDate();
 
// JTextField textMois = new JTextField();
JLabel labelAnnee = new JLabel("Année");
this.textAnnee = new JTextField();
{
225,7 → 245,6
this.pDate.add(this.dateAu, cDate);
 
c.gridy++;
// c.gridx++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.weighty = 0;
233,11 → 252,6
c.gridwidth = 2;
panelRight.add(this.pDate, c);
}
// c.gridx += 2;
// c.weightx = 1;
// c.gridwidth = 1;
// c.fill = GridBagConstraints.HORIZONTAL;
// panelRight.add(new JPanel(), c);
 
// Action Button
 
303,16 → 317,16
 
// Total Periode
JPanel panelTotal = new JPanel(new GridBagLayout());
panelTotal.setBorder(BorderFactory.createTitledBorder("Total période"));
panelTotal.setBorder(BorderFactory.createTitledBorder("Totaux sur la période"));
 
GridBagConstraints cPanel = new DefaultGridBagConstraints();
 
JLabel labelInfosConges = new JLabel(getLabelFor("DETAILS_CONGES"));
panelTotal.add(labelInfosConges, cPanel);
ITextArea textConges = new ITextArea();
JTextField textConges = new JTextField();
cPanel.gridx++;
cPanel.weightx = 1;
cPanel.gridwidth = GridBagConstraints.REMAINDER;
cPanel.gridwidth = 5;
panelTotal.add(textConges, cPanel);
addView(textConges, "DETAILS_CONGES");
 
325,7 → 339,7
panelTotal.add(labelBrut, cPanel);
JTextField textSalBrut = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 0;
cPanel.weightx = 1;
panelTotal.add(textSalBrut, cPanel);
textSalBrut.setEditable(false);
textSalBrut.setEnabled(false);
332,10 → 346,12
 
// acompte
cPanel.gridx++;
cPanel.weightx = 0;
JLabel labelAcompte = new JLabel(getLabelFor("ACOMPTE"));
panelTotal.add(labelAcompte, cPanel);
JTextField textAcompte = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textAcompte, cPanel);
// textAcompte.setEditable(false);
// textAcompte.setEnabled(false);
342,19 → 358,23
 
// Conges Acquis
cPanel.gridx++;
cPanel.weightx = 0;
JLabel labelCongesAcquis = new JLabel(getLabelFor("CONGES_ACQUIS"));
panelTotal.add(labelCongesAcquis, cPanel);
JTextField textCongesAcquis = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textCongesAcquis, cPanel);
 
// cotisation salariale
cPanel.gridx = 0;
cPanel.gridy++;
cPanel.weightx = 0;
JLabel labelCotSal = new JLabel(getLabelFor("COT_SAL"));
panelTotal.add(labelCotSal, cPanel);
JTextField textCotSal = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textCotSal, cPanel);
textCotSal.setEditable(false);
textCotSal.setEnabled(false);
361,10 → 381,12
 
// cotisation patronale
cPanel.gridx++;
cPanel.weightx = 0;
JLabel labelCotPat = new JLabel(getLabelFor("COT_PAT"));
panelTotal.add(labelCotPat, cPanel);
JTextField textCotPat = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textCotPat, cPanel);
textCotPat.setEditable(false);
textCotPat.setEnabled(false);
371,9 → 393,11
 
JLabel labelCSG = new JLabel(getLabelFor("CSG"));
cPanel.gridx++;
cPanel.weightx = 0;
panelTotal.add(labelCSG, cPanel);
JTextField textCSG = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textCSG, cPanel);
textCSG.setEditable(false);
textCSG.setEnabled(false);
381,28 → 405,34
// net imposable
cPanel.gridx = 0;
cPanel.gridy++;
cPanel.weightx = 0;
JLabel labelNetImp = new JLabel(getLabelFor("NET_IMP"));
panelTotal.add(labelNetImp, cPanel);
JTextField textNetImp = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textNetImp, cPanel);
textNetImp.setEditable(false);
textNetImp.setEnabled(false);
 
cPanel.gridx++;
cPanel.weightx = 0;
JLabel labelNetAPayer = new JLabel(getLabelFor("NET_A_PAYER"));
panelTotal.add(labelNetAPayer, cPanel);
JTextField textNetAPayer = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textNetAPayer, cPanel);
textNetAPayer.setEditable(false);
textNetAPayer.setEnabled(false);
 
cPanel.gridx++;
cPanel.weightx = 0;
JLabel labelCice = new JLabel(getLabelFor("CICE"));
panelTotal.add(labelCice, cPanel);
JTextField textCice = new JTextField(10);
cPanel.gridx++;
cPanel.weightx = 1;
panelTotal.add(textCice, cPanel);
textCice.setEditable(false);
textCice.setEnabled(false);
418,18 → 448,6
 
// Cumuls
 
c.gridx = 1;
c.gridy++;
c.gridwidth = 1;
c.fill = GridBagConstraints.NONE;
this.buttonValider = new JButton("Valider");
// panelRight.add(buttonValider, c);
 
c.gridx++;
c.gridwidth = 1;
this.buttonGenCompta = new JButton("Generer la comptabilité");
// panelRight.add(buttonGenCompta, c);
 
GridBagConstraints cGlobal = new DefaultGridBagConstraints();
cGlobal.gridx = 0;
cGlobal.gridy = 0;
440,32 → 458,6
cGlobal.weighty = 1;
this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), cGlobal);
 
// Listeners
this.buttonGenCompta.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int[] i = new int[1];
i[0] = getSelectedID();
 
SQLRow rowMois = getTable().getBase().getTable("MOIS").getRow(selMois.getSelectedId());
 
new GenerationMvtFichePaye(i, rowMois.getString("NOM"), textAnnee.getText());
} catch (Exception ex) {
ExceptionHandler.handle("Erreur de génération des mouvements", ex);
}
}
});
 
this.buttonValider.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
validationFiche();
} catch (SQLException e1) {
ExceptionHandler.handle("Error while updating pay slip", e1);
}
}
});
 
buttonUp.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent e) {
565,7 → 557,6
 
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
System.err.println("Du " + cal.getTime());
dateDu.setValue(cal.getTime());
}
fireValidChange();
591,7 → 582,6
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
System.err.println("Au " + cal.getTime());
dateAu.setValue(cal.getTime());
}
fireValidChange();
680,7 → 670,6
 
this.selSalCombo.setVisible(((Boolean) r.getObject("VALIDE")).booleanValue());
this.paneTreeLeft.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
this.buttonValider.setVisible(!((Boolean) r.getObject("VALIDE")).booleanValue());
setpDateEnabled(!((Boolean) r.getObject("VALIDE")).booleanValue());
}
this.selSalCombo.setInteractionMode(InteractionMode.DISABLED);
690,30 → 679,16
}
 
private void setpDateEnabled(boolean b) {
 
// System.err.println("Set date enable --> " + b);
 
this.selMois.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
// this.selMois.setEnabled(b);
 
this.textAnnee.setEditable(b);
this.textAnnee.setEnabled(b);
 
this.dateDu.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
this.dateAu.setInteractionMode((b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
}
 
private void validationFiche() throws SQLException {
 
this.update();
FichePayeSQLElement.validationFiche(this.getSelectedID());
}
 
protected SQLRowValues createDefaults() {
 
System.err.println("**********Set Defaults on FichePaye.date");
SQLRowValues rowVals = new SQLRowValues(getTable());
Calendar cal = Calendar.getInstance();
final SQLRowValues rowVals = new SQLRowValues(getTable());
final Calendar cal = Calendar.getInstance();
rowVals.put("ID_MOIS", cal.get(Calendar.MONTH) + 2);
rowVals.put("ANNEE", cal.get(Calendar.YEAR));
 
739,7 → 714,6
if (JOptionPane.showConfirmDialog(null, "Soustraire les cumuls de cette fiche à celle en cours?", "Suppression d'une fiche de paye",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
// on effectue le cumul
// System.err.println("Calcul des cumuls");
 
SQLRow rowSal = row.getForeignRow("ID_SALARIE");
 
845,13 → 819,8
// creer et associer une nouvelle fiche au salarie
final SQLRowValues rowValsNewFiche = new SQLRowValues(tableFiche);
 
try {
SQLRow r = rowValsNewFiche.insert();
rowValsNewFiche.put("ID", r.getID());
// System.err.println("rowValsNewFiche -----> " + r.getID());
} catch (SQLException e) {
e.printStackTrace();
}
SQLRow r = rowValsNewFiche.insert();
rowValsNewFiche.put("ID", r.getID());
 
// mis a jour de la periode
int mois = rowFiche.getInt("ID_MOIS");
865,22 → 834,6
calDu.set(Calendar.DAY_OF_MONTH, calDu.getActualMaximum(Calendar.DAY_OF_MONTH));
rowValsNewFiche.put("AU", calDu.getTime());
rowValsNewFiche.put("ID_PROFIL_PAYE", rowFiche.getInt("ID_PROFIL_PAYE"));
 
/*
* int ancMois = rowFiche.getInt("ID_MOIS"); int ancAnnee = rowFiche.getInt("ANNEE");
*
* rowValsSal.put("DERNIER_MOIS", ancMois); rowValsSal.put("DERNIERE_ANNEE", ancAnnee);
*
* try { rowValsSal.update(rowFiche.getInt("ID_SALARIE")); } catch (SQLException e1) {
* e1.printStackTrace(); }
*
* int mois = ancMois - 2; mois = (mois + 1) % 12; mois += 2; int annee = ancAnnee; if (mois
* == 2) { annee++; } rowValsNewFiche.put("ID_MOIS", mois); rowValsNewFiche.put("ANNEE",
* annee); rowValsNewFiche.put("ID_PROFIL_PAYE", rowFiche.getInt("ID_PROFIL_PAYE"));
*
* try { rowValsNewFiche.update(); } catch (SQLException e) { e.printStackTrace(); }
*/
 
rowValsNewFiche.put("ID_SALARIE", rowSal.getID());
rowValsSal.put("ID_FICHE_PAYE", rowValsNewFiche.getID());
 
919,7 → 872,6
}
 
// on effectue le cumul
// System.err.println("Calcul des cumuls");
final SQLRow rowVarSal = tableVariableSal.getRow(rowSal.getInt("ID_VARIABLE_SALARIE"));
int idCumuls = rowSal.getInt("ID_CUMULS_PAYE");
SQLRow rowCumuls = tableCumuls.getRow(idCumuls);
932,10 → 884,9
float netAPayer = rowCumuls.getFloat("NET_A_PAYER_C") + rowFiche.getFloat("NET_A_PAYER") + rowFiche.getFloat("ACOMPTE");
rowValsCumul.put("NET_A_PAYER_C", new Float(netAPayer));
 
SQLRow r = rowValsCumul.insert();
rowValsCumul.put("ID", r.getID());
SQLRow row = rowValsCumul.insert();
rowValsCumul.put("ID", row.getID());
 
// System.err.println("Mis a jour de la fiche de paye");
rowValsSal.put("ID_CUMULS_PAYE", rowValsCumul.getID());
 
SwingUtilities.invokeLater(new Runnable() {
1054,13 → 1005,7
e1.printStackTrace();
}
}
/*
* int mois = ancMois - 2; mois = (mois + 1) % 12; mois += 2; int annee = ancAnnee; if (mois
* == 2) { annee++; } rowValsNewFiche.put("ID_MOIS", mois); rowValsNewFiche.put("ANNEE",
* annee); rowValsNewFiche.put("ID_PROFIL_PAYE", rowFiche.getInt("ID_PROFIL_PAYE"));
*
* try { rowValsNewFiche.update(); } catch (SQLException e) { e.printStackTrace(); }
*/
 
}
 
// stocke les éléments validés (cumuls congés, paye, ...)
1094,7 → 1039,6
private static void validElements(int id) {
 
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
System.err.println("Validation des éléments de la fiche.");
String trueString = "1";
if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
trueString = "true";
1103,7 → 1047,6
 
base.getDataSource().execute(req);
 
System.err.println("Validation terminée.");
}
 
private static boolean checkDateValid(int idFiche) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/VariablePayeSQLElement.java
261,6 → 261,7
l2.add(tableFichePaye.getField("NET_IMP"));
l2.add(tableFichePaye.getField("NET_A_PAYER"));
l2.add(tableFichePaye.getField("CSG"));
l2.add(tableFichePaye.getField("CSG_REDUITE"));
 
mapTree.put("Contenu paye", l2);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratSalarieSQLElement.java
22,6 → 22,8
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
98,8 → 100,10
this.add(labelNature, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = 3;
this.add(textNature, c);
 
c.gridwidth = 1;
// Catégorie socioprofessionnelle
JLabel labelCatSocio = new JLabel(getLabelFor("ID_CODE_EMPLOI"));
labelCatSocio.setHorizontalAlignment(SwingConstants.RIGHT);
112,21 → 116,61
c.gridx++;
c.weightx = 1;
this.add(selCodeCatSocio, c);
 
JLabel complPCSLabel = new JLabel(getLabelFor("COMPLEMENT_PCS"));
complPCSLabel.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField complPCS = new JTextField();
c.gridy++;
c.gridx = 0;
c.gridx++;
c.weightx = 0;
this.add(complPCSLabel, c);
c.gridx++;
c.weightx = 1;
this.add(complPCS, c);
addView(complPCS,"COMPLEMENT_PCS");
addView(complPCS, "COMPLEMENT_PCS");
 
JLabel objetSpecLabel = new JLabel(getLabelFor("SPECTACLE_OBJET"));
objetSpecLabel.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField objetSpec = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(objetSpecLabel, c);
c.gridx++;
c.weightx = 1;
this.add(objetSpec, c);
addView(objetSpec, "SPECTACLE_OBJET");
objetSpec.setEditable(false);
 
JLabel jourContratLabel = new JLabel(getLabelFor("SPECTACLE_JOUR_CONTRAT"));
jourContratLabel.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField jourContrat = new JTextField();
c.gridx++;
c.weightx = 0;
this.add(jourContratLabel, c);
c.gridx++;
c.weightx = 1;
this.add(jourContrat, c);
addView(jourContrat, "SPECTACLE_JOUR_CONTRAT");
jourContrat.setEditable(false);
 
final ElementComboBox selCaractActivite = new ElementComboBox();
selCaractActivite.setInfoIconVisible(false);
this.addRequiredSQLObject(selCaractActivite, "ID_CODE_CARACT_ACTIVITE");
selCaractActivite.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
final boolean b = selCaractActivite.getSelectedRow() != null && selCaractActivite.getSelectedRow().getString("CODE").equals("04");
objetSpec.setEditable(b);
jourContrat.setEditable(b);
if (!b) {
objetSpec.setText("");
;
jourContrat.setText("");
}
}
});
 
// Contrat de travail
JLabel labelContratTravail = new JLabel(getLabelFor("ID_CODE_CONTRAT_TRAVAIL"));
labelContratTravail.setHorizontalAlignment(SwingConstants.RIGHT);
145,8 → 189,7
labelDroitContrat.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selDroitContrat = new ElementComboBox();
selDroitContrat.setInfoIconVisible(false);
c.gridy++;
c.gridx = 0;
c.gridx++;
c.weightx = 0;
this.add(labelDroitContrat, c);
c.gridx++;
156,8 → 199,7
// caracteristiques activité
JLabel labelCaractActivite = new JLabel(getLabelFor("ID_CODE_CARACT_ACTIVITE"));
labelCaractActivite.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selCaractActivite = new ElementComboBox();
selCaractActivite.setInfoIconVisible(false);
 
c.gridy++;
c.gridx = 0;
c.weightx = 0;
171,8 → 213,7
labelStatutProf.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selStatutProf = new ElementComboBox();
selStatutProf.setInfoIconVisible(false);
c.gridy++;
c.gridx = 0;
c.gridx++;
c.weightx = 0;
this.add(labelStatutProf, c);
c.gridx++;
189,7 → 230,6
c.weightx = 0;
this.add(labelStatutCat, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(selStatutCat, c);
 
198,25 → 238,28
labelStatutCatConv.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selStatutCatConv = new ElementComboBox();
selStatutCatConv.setInfoIconVisible(false);
c.gridy++;
c.gridx = 0;
c.gridx++;
c.weightx = 0;
this.add(labelStatutCatConv, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
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_DISPOSITIF_POLITIQUE", "ID_CONTRAT_MOTIF_RECOURS");
int p = 0;
for (String ffName : dsnFF) {
JLabel labelFF = new JLabel(getLabelFor(ffName));
labelFF.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selFF = new ElementComboBox();
selFF.setInfoIconVisible(false);
c.gridy++;
c.gridx = 0;
if (p % 2 == 0) {
c.gridy++;
c.gridx = 0;
} else {
c.gridx++;
}
p++;
c.weightx = 0;
this.add(labelFF, c);
c.gridx++;
223,21 → 266,12
c.weighty = 1;
c.weightx = 1;
this.add(selFF, c);
this.addRequiredSQLObject(selFF, ffName);
if (ffName.equals("ID_CONTRAT_MOTIF_RECOURS")) {
this.addSQLObject(selFF, ffName);
} else {
this.addRequiredSQLObject(selFF, ffName);
}
}
JLabel labelFF = new JLabel(getLabelFor("ID_CONTRAT_MOTIF_RECOURS"));
labelFF.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selFF = new ElementComboBox();
selFF.setInfoIconVisible(false);
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelFF, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(selFF, c);
this.addSQLObject(selFF, "ID_CONTRAT_MOTIF_RECOURS");
 
// Code Arrco, agirc retirés du contrat et ajoutés dans les caisses de cotisations
 
338,18 → 372,18
// this.add(textCodeRegimeRetraite, c);
// addRequiredSQLObject(textCodeRegimeRetraite, "CODE_REGIME_RETRAITE_DSN");
 
JLabel labelDateModif = new JLabel(getLabelFor("DATE_MODIFICATION"));
labelDateModif.setHorizontalAlignment(SwingConstants.RIGHT);
JDate textDateModif = new JDate();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(textDateModif, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textDateModif, c);
addSQLObject(textDateModif, "DATE_MODIFICATION");
// JLabel labelDateModif = new JLabel(getLabelFor("DATE_MODIFICATION"));
// labelDateModif.setHorizontalAlignment(SwingConstants.RIGHT);
// JDate textDateModif = new JDate();
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(textDateModif, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(textDateModif, c);
// addSQLObject(textDateModif, "DATE_MODIFICATION");
 
// JLabel labelCM = new JLabel(getLabelFor("ID_INFOS_SALARIE_PAYE_MODIFIE"));
// labelCM.setHorizontalAlignment(SwingConstants.RIGHT);
376,7 → 410,6
c.weightx = 0;
this.add(labelDateDebut, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textDateDebut, c);
addSQLObject(textDateDebut, "DATE_DEBUT", REQ);
384,19 → 417,64
JLabel labelDateFin = new JLabel(getLabelFor("DATE_PREV_FIN"));
labelDateFin.setHorizontalAlignment(SwingConstants.RIGHT);
JDate textDateFin = new JDate();
c.gridy++;
c.gridx = 0;
c.gridx++;
c.weightx = 0;
this.add(labelDateFin, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textDateFin, c);
addSQLObject(textDateFin, "DATE_PREV_FIN");
 
JLabel labelAmen = new JLabel(getLabelFor("ID_CODE_AMENAGEMENT_PARTIEL"));
labelAmen.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selAmen = new ElementComboBox();
selAmen.setInfoIconVisible(false);
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelAmen, c);
c.gridx++;
c.weightx = 1;
this.add(selAmen, c);
this.addSQLObject(selAmen, "ID_CODE_AMENAGEMENT_PARTIEL");
 
JLabel labelSupsension = new JLabel(getLabelFor("ID_CODE_SUSPENSION"));
labelSupsension.setHorizontalAlignment(SwingConstants.RIGHT);
ElementComboBox selSupsension = new ElementComboBox();
selSupsension.setInfoIconVisible(false);
c.gridx++;
c.weightx = 0;
this.add(labelSupsension, c);
c.gridx++;
c.weightx = 1;
this.add(selSupsension, c);
this.addSQLObject(selSupsension, "ID_CODE_SUSPENSION");
 
JLabel labelDateDebutSusp = new JLabel(getLabelFor("DATE_DEBUT_SUSPENSION"));
labelDateDebutSusp.setHorizontalAlignment(SwingConstants.RIGHT);
JDate textDateDebutSups = new JDate();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelDateDebutSusp, c);
c.gridx++;
c.weightx = 1;
this.add(textDateDebutSups, c);
this.addSQLObject(textDateDebutSups, "DATE_DEBUT_SUSPENSION");
 
JLabel labelDateFinSups = new JLabel(getLabelFor("DATE_FIN_SUSPENSION"));
labelDateFinSups.setHorizontalAlignment(SwingConstants.RIGHT);
JDate textDateFinSuspension = new JDate();
c.gridx++;
c.weightx = 0;
this.add(labelDateFinSups, c);
c.gridx++;
c.weightx = 1;
this.add(textDateFinSuspension, c);
this.addSQLObject(textDateFinSuspension, "DATE_FIN_SUSPENSION");
 
this.addRequiredSQLObject(selCodeCatSocio, "ID_CODE_EMPLOI");
this.addRequiredSQLObject(selContratTravail, "ID_CODE_CONTRAT_TRAVAIL");
this.addRequiredSQLObject(selCaractActivite, "ID_CODE_CARACT_ACTIVITE");
this.addRequiredSQLObject(selDroitContrat, "ID_CODE_DROIT_CONTRAT");
this.addRequiredSQLObject(selStatutProf, "ID_CODE_STATUT_PROF");
this.addRequiredSQLObject(selStatutCat, "ID_CODE_STATUT_CATEGORIEL");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/FichePayeSheetXML.java
46,13 → 46,16
final Map<Integer, String> cotisationSimplifieeLink = new HashMap<>();
 
public FichePayeSheetXML(final SQLRow row) {
this(row, !new SQLPreferences(row.getTable().getDBRoot()).getBoolean(PayeGlobalPreferencePanel.NOT_PAYE_SIMPL, Boolean.FALSE));
}
 
public FichePayeSheetXML(final SQLRow row, boolean simplifie) {
super(row);
this.printer = PrinterNXProps.getInstance().getStringProperty("FichePayePrinter");
this.elt = Configuration.getInstance().getDirectory().getElement("FICHE_PAYE");
SQLPreferences prefs = new SQLPreferences(elt.getTable().getDBRoot());
boolean prefBulletinSimpl = !prefs.getBoolean(PayeGlobalPreferencePanel.NOT_PAYE_SIMPL, Boolean.FALSE);
 
if (prefBulletinSimpl) {
if (simplifie) {
 
SQLSelect sel = new SQLSelect();
sel.addSelect(row.getTable().getDBRoot().findTable("RUBRIQUE_COTISATION").getField("LIGNE_PAYE_SIMPLIFIEE"));
sel.addSelect(row.getTable().getDBRoot().findTable("RUBRIQUE_COTISATION").getKey());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/LivrePayeSheet.java
21,6 → 21,7
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.StringUtils;
 
import java.text.DateFormat;
import java.util.Date;
156,75 → 157,88
 
mapSal.put(new Integer(idSal), "");
 
if (rowFicheElt.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_BRUT")) {
float montantTestTotal = 0;
if (rowFicheElt.getObject("MONTANT_SAL_AJ") != null) {
montantTestTotal += rowFicheElt.getFloat("MONTANT_SAL_AJ");
}
if (rowFicheElt.getObject("MONTANT_SAL_DED") != null) {
montantTestTotal -= rowFicheElt.getFloat("MONTANT_SAL_DED");
}
 
mapRubriqueBrut.put(new Integer(rowFicheElt.getInt("IDSOURCE")), "");
mapTotal = mapTotalbrut;
if (mapSalarieBrut.get(new Integer(idSal)) == null) {
mapSalarieBrut.put(new Integer(idSal), mapValue);
} else {
mapValue = (Map) mapSalarieBrut.get(new Integer(idSal));
}
} else {
if (rowFicheElt.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_COTISATION")) {
mapRubriqueCot.put(new Integer(rowFicheElt.getInt("IDSOURCE")), "");
mapTotal = mapTotalCot;
if (mapSalarieCot.get(new Integer(idSal)) == null) {
mapSalarieCot.put(new Integer(idSal), mapValue);
if (rowFicheElt.getObject("MONTANT_PAT") != null) {
montantTestTotal += rowFicheElt.getFloat("MONTANT_PAT");
}
if (montantTestTotal != 0) {
 
if (rowFicheElt.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_BRUT")) {
 
mapRubriqueBrut.put(new Integer(rowFicheElt.getInt("IDSOURCE")), "");
mapTotal = mapTotalbrut;
if (mapSalarieBrut.get(new Integer(idSal)) == null) {
mapSalarieBrut.put(new Integer(idSal), mapValue);
} else {
mapValue = (Map) mapSalarieCot.get(new Integer(idSal));
mapValue = (Map) mapSalarieBrut.get(new Integer(idSal));
}
} else {
if (rowFicheElt.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_NET")) {
mapRubriqueNet.put(new Integer(rowFicheElt.getInt("IDSOURCE")), "");
mapTotal = mapTotalNet;
if (mapSalarieNet.get(new Integer(idSal)) == null) {
mapSalarieNet.put(new Integer(idSal), mapValue);
if (rowFicheElt.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_COTISATION")) {
mapRubriqueCot.put(new Integer(rowFicheElt.getInt("IDSOURCE")), "");
mapTotal = mapTotalCot;
if (mapSalarieCot.get(new Integer(idSal)) == null) {
mapSalarieCot.put(new Integer(idSal), mapValue);
} else {
mapValue = (Map) mapSalarieNet.get(new Integer(idSal));
mapValue = (Map) mapSalarieCot.get(new Integer(idSal));
}
} else {
if (rowFicheElt.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_NET")) {
mapRubriqueNet.put(new Integer(rowFicheElt.getInt("IDSOURCE")), "");
mapTotal = mapTotalNet;
if (mapSalarieNet.get(new Integer(idSal)) == null) {
mapSalarieNet.put(new Integer(idSal), mapValue);
} else {
mapValue = (Map) mapSalarieNet.get(new Integer(idSal));
}
}
}
}
}
 
if (rowFicheElt.getObject("MONTANT_SAL_AJ") != null) {
Object o = mapValue.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
Object oTot = mapTotal.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
if (rowFicheElt.getObject("MONTANT_SAL_AJ") != null) {
Object o = mapValue.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
Object oTot = mapTotal.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
 
float montant = (o == null) ? 0.0F : ((Float) o).floatValue();
float montantTotal = (oTot == null) ? 0.0F : ((Float) oTot).floatValue();
montant += rowFicheElt.getFloat("MONTANT_SAL_AJ");
montantTotal += rowFicheElt.getFloat("MONTANT_SAL_AJ");
float montant = (o == null) ? 0.0F : ((Float) o).floatValue();
float montantTotal = (oTot == null) ? 0.0F : ((Float) oTot).floatValue();
montant += rowFicheElt.getFloat("MONTANT_SAL_AJ");
montantTotal += rowFicheElt.getFloat("MONTANT_SAL_AJ");
 
mapValue.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montant));
mapTotal.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montantTotal));
}
if (rowFicheElt.getObject("MONTANT_SAL_DED") != null) {
Object o = mapValue.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
Object oTot = mapTotal.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
mapValue.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montant));
mapTotal.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montantTotal));
}
if (rowFicheElt.getObject("MONTANT_SAL_DED") != null) {
Object o = mapValue.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
Object oTot = mapTotal.get(new Integer(rowFicheElt.getInt("IDSOURCE")));
 
float montant = (o == null) ? 0.0F : ((Float) o).floatValue();
float montantTot = (oTot == null) ? 0.0F : ((Float) oTot).floatValue();
montant -= rowFicheElt.getFloat("MONTANT_SAL_DED");
montantTot -= rowFicheElt.getFloat("MONTANT_SAL_DED");
float montant = (o == null) ? 0.0F : ((Float) o).floatValue();
float montantTot = (oTot == null) ? 0.0F : ((Float) oTot).floatValue();
montant -= rowFicheElt.getFloat("MONTANT_SAL_DED");
montantTot -= rowFicheElt.getFloat("MONTANT_SAL_DED");
 
mapValue.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montant));
mapTotal.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montantTot));
}
mapValue.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montant));
mapTotal.put(new Integer(rowFicheElt.getInt("IDSOURCE")), new Float(montantTot));
}
 
if (rowFicheElt.getObject("MONTANT_PAT") != null) {
Object o = mapValue.get(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT");
Object oTot = mapTotal.get(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT");
if (rowFicheElt.getObject("MONTANT_PAT") != null) {
Object o = mapValue.get(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT");
Object oTot = mapTotal.get(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT");
 
float montant = (o == null) ? 0.0F : ((Float) o).floatValue();
float montantTotal = (oTot == null) ? 0.0F : ((Float) oTot).floatValue();
montant += rowFicheElt.getFloat("MONTANT_PAT");
montantTotal += rowFicheElt.getFloat("MONTANT_PAT");
float montant = (o == null) ? 0.0F : ((Float) o).floatValue();
float montantTotal = (oTot == null) ? 0.0F : ((Float) oTot).floatValue();
montant += rowFicheElt.getFloat("MONTANT_PAT");
montantTotal += rowFicheElt.getFloat("MONTANT_PAT");
 
mapValue.put(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT", new Float(montant));
mapTotal.put(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT", new Float(montantTotal));
mapValue.put(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT", new Float(montant));
mapTotal.put(new Integer(rowFicheElt.getInt("IDSOURCE")) + "_PAT", new Float(montantTotal));
}
}
 
}
 
// Dump
287,7 → 301,7
int idRub = ((Number) mapRubriqueBrut.keySet().toArray()[i]).intValue();
SQLRow rowRub = tableRubBrut.getRow(idRub);
 
this.mCell.put("A" + posLine, rowRub.getObject("NOM"));
this.mCell.put("A" + posLine, StringUtils.limitLength(rowRub.getString("NOM"), 55));
 
this.mCell.put("B" + posLine, fillLine(mapSalarieBrut, idRub, mapSal, numFirstSal, mapTotalbrut, false));
this.mCell.put("C" + posLine, fillLine(mapSalarieBrut, idRub, mapSal, numFirstSal, mapTotalbrut, true));
303,7 → 317,7
int idRub = ((Number) mapRubriqueCot.keySet().toArray()[i]).intValue();
SQLRow rowRub = tableRubCot.getRow(idRub);
 
this.mCell.put("A" + posLine, rowRub.getObject("NOM"));
this.mCell.put("A" + posLine, StringUtils.limitLength(rowRub.getString("NOM"), 55));
 
this.mCell.put("B" + posLine, fillLine(mapSalarieCot, idRub, mapSal, numFirstSal, mapTotalCot, false));
this.mCell.put("C" + posLine, fillLine(mapSalarieCot, idRub, mapSal, numFirstSal, mapTotalCot, true));
320,7 → 334,7
int idRub = ((Number) mapRubriqueNet.keySet().toArray()[i]).intValue();
SQLRow rowRub = tableRubNet.getRow(idRub);
 
this.mCell.put("A" + posLine, rowRub.getObject("NOM"));
this.mCell.put("A" + posLine, StringUtils.limitLength(rowRub.getString("NOM"), 55));
 
this.mCell.put("B" + posLine, fillLine(mapSalarieNet, idRub, mapSal, numFirstSal, mapTotalNet, false));
this.mCell.put("C" + posLine, fillLine(mapSalarieNet, idRub, mapSal, numFirstSal, mapTotalNet, true));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/POSConfiguration.java
74,7 → 74,6
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Logger;
 
248,8 → 247,8
 
public ComptaPropsConfiguration createConnexion() {
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create();
TranslationManager.getInstance().addTranslationStreamFromClass(MainFrame.class);
TranslationManager.getInstance().setLocale(Locale.getDefault());
TranslationManager.addTranslationStreamFromClass(MainFrame.class);
TranslationManager.createDefaultInstance();
 
Configuration.setInstance(conf);
try {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseMenuPanel.java
159,7 → 159,7
@Override
public void actionPerformed(ActionEvent e) {
try {
final boolean quit = caisseFrame.getDB().fetchRegisterState().checkIfMoved();
final boolean quit = caisseFrame.getDB().fetchRegisterState().checkIfMoved(caisseFrame.getConf().getERP_TM());
if (!quit) {
frame.getControler().setLCD("Cloture", "En cours...", 0);
final int userID = caisseFrame.getPOSConf().getUserID();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PaiementPanel.java
47,11 → 47,13
*/
private char mode = ' ';
private boolean init = true;
private CaissePanel caissePanel;
 
public PaiementPanel(CaisseControler controller) {
this.controller = controller;
public PaiementPanel(CaissePanel caissePanel) {
this.controller = caissePanel.getControler();
this.controller.addCaisseListener(this);
this.controller.addBarcodeListener(this);
this.caissePanel = caissePanel;
this.setOpaque(false);
 
this.addMouseListener(this);
556,7 → 558,7
 
@Override
public void keyReceived(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_TYPED) {
if (!this.caissePanel.isModeSearch() && e.getID() == KeyEvent.KEY_TYPED) {
System.out.println("PaiementPanel.keyPressed()" + e.getKeyChar());
handleCharacter(e.getKeyChar());
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseFrame.java
134,6 → 134,7
 
}
final ComptaPropsConfiguration conf = posConf.createConnexion();
final TM erpTM = conf.getERP_TM();
 
final int userID = posConf.getUserID();
final int posID = posConf.getPosID();
143,13 → 144,13
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(new SQLRowValues(registerDB.getRegisterTable()));
if (fetcher.fetchOne(posID) == null) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null, TM.tr("register.missing", posID), TM.tr("register.missing.title"), JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, erpTM.translate("register.missing", posID), erpTM.translate("register.missing.title"), JOptionPane.ERROR_MESSAGE);
});
posConf.closeConnexion();
return;
}
// check before changing any state
final boolean quit = registerDB.fetchRegisterState().checkIfMoved();
final boolean quit = registerDB.fetchRegisterState().checkIfMoved(erpTM);
if (quit) {
quit(posConf);
return;
169,17 → 170,17
final String generalMsg;
boolean onlyOptionPane = false;
if (re instanceof OutsideMeddlingException) {
generalMsg = TM.tr("register.notReconciled.outsideMeddling") + '\n';
generalMsg = erpTM.translate("register.notReconciled.outsideMeddling") + '\n';
onlyOptionPane = true;
} else if (re instanceof ResumeException) {
generalMsg = TM.tr("register.notReconciled.resumeFailed") + '\n';
generalMsg = erpTM.translate("register.notReconciled.resumeFailed") + '\n';
} else {
generalMsg = "";
}
final String message = TM.getTM().trM("register.notReconciled." + re.getTranslationKey(), "localDate", re.getLocalState().copyDate(), "remoteDate", re.getRemoteState().copyDate());
final String message = erpTM.trM("register.notReconciled." + re.getTranslationKey(), "localDate", re.getLocalState().copyDate(), "remoteDate", re.getRemoteState().copyDate());
if (onlyOptionPane) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null, generalMsg + message, TM.tr("register.notReconciled.title"), JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, generalMsg + message, erpTM.translate("register.notReconciled.title"), JOptionPane.ERROR_MESSAGE);
});
} else {
ExceptionHandler.handle(generalMsg + message, re);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaissePanel.java
105,7 → 105,7
// Column 3
c.gridx++;
c.weightx = 0;
this.add(new PaiementPanel(this.controler), c);
this.add(new PaiementPanel(this), c);
this.controler.addCaisseListener(this);
}
 
433,6 → 433,10
 
}
 
public boolean isModeSearch() {
return this.selector == this.articleSearchPanel;
}
 
public CaisseControler getControler() {
return this.controler;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/DBState.java
144,11 → 144,12
* Check if the register installation has moved and ask the user about it if it did. This can be
* called from outside the EDT.
*
* @param erpTM UI locale
* @return <code>true</code> if the user wants to quit.
* @throws InterruptedException if this thread was interrupted while waiting on the EDT.
* @throws ExecutionException if there was an error while asking the user.
*/
public final boolean checkIfMoved() throws InterruptedException, ExecutionException {
public final boolean checkIfMoved(final TM erpTM) throws InterruptedException, ExecutionException {
final SQLRowValues lastEntry = this.getLastEntry();
if (lastEntry == null) {
return false;
159,13 → 160,14
if (dbValues.equals(currentValues) || NULL_VALUES.equals(dbValues)) {
return false;
} else {
final String message = TM.tr("register.moved", getPosID());
final String[] options = new String[] { TM.tr("register.moved.ignore"), TM.tr("register.moved.quit") };
final String message = erpTM.translate("register.moved", getPosID());
final String[] options = new String[] { erpTM.translate("register.moved.ignore"), erpTM.translate("register.moved.quit") };
final FutureTask<Boolean> askUserCallable = new FutureTask<>(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
// quit by default
final int ans = JOptionPane.showOptionDialog(null, message, TM.tr("register.moved.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
final int ans = JOptionPane.showOptionDialog(null, message, erpTM.translate("register.moved.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
options[1]);
// CLOSED_OPTION also means quit, only clicking "ignore" means don't quit
return ans != 0;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/RegisterFiles.java
48,6 → 48,7
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.logging.Level;
364,10 → 365,14
public final RegisterLog open(final int userID, final DBState dbState) throws IOException {
if (!this.hasLock.get())
throw new IllegalStateException("Not locked");
Objects.requireNonNull(dbState, "Missing DBState");
// pass null RegisterDB since the DB is already open
return createOpen(userID, null, dbState).transformChecked(this);
}
 
public final RegisterLog open(final int userID, final RegisterDB registerDB) throws IOException {
Objects.requireNonNull(registerDB, "Missing RegisterDB");
// pass null DBState to ask for the opening
return this.doWithLock(createOpen(userID, registerDB, null));
}
 
377,7 → 382,6
@Override
public RegisterLog transformChecked(RegisterFiles input) throws IOException {
POSConfiguration.getLogger().log(Level.FINE, "Begin opening of FS state for register {0}", input.getPosID());
POSConfiguration.checkRegisterID(input.getPosID(), registerDB.getPosID());
final RegisterLog lastLog = input.checkStatus(true);
final String lastLocalHash;
final Date prevDate;
398,6 → 402,7
final DBState dbState;
if (passedDBState == null) {
try {
POSConfiguration.checkRegisterID(input.getPosID(), registerDB.getPosID());
dbState = registerDB.open(lastLocalHash, userID);
} catch (SQLException e) {
throw new IOException("Couldn't open the register in the DB", e);
444,7 → 449,7
}
}
 
POSConfiguration.getLogger().log(Level.INFO, "Finished opening of FS state for register {0}", registerDB);
POSConfiguration.getLogger().log(Level.INFO, "Finished opening of FS state for register {0}", input.getPosID());
 
// TODO parse and validate before moving into place
try {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/action/ListeDesBonsDeLivraisonAction.java
21,7 → 21,6
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonSQLElement;
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
74,9 → 73,9
 
// Tabs
final JTabbedPane tabs = new JTabbedPane();
tabs.addTab(TM.tr("sales.shipment.allShipments"), createAllDeliveryPanel(toInvoiceAction));
tabs.addTab(TM.tr("sales.shipment.nonInvoicedShipments"), createDeliveryWithoutInvoicePanel(toInvoiceAction));
tabs.addTab(TM.tr("sales.shipment.invoicedShipments"), createDeliveryWithInvoicePanel());
tabs.addTab(getConf().getERP_TM().translate("sales.shipment.allShipments"), createAllDeliveryPanel(toInvoiceAction));
tabs.addTab(getConf().getERP_TM().translate("sales.shipment.nonInvoicedShipments"), createDeliveryWithoutInvoicePanel(toInvoiceAction));
tabs.addTab(getConf().getERP_TM().translate("sales.shipment.invoicedShipments"), createDeliveryWithInvoicePanel());
frame.setContentPane(tabs);
 
return frame;
87,7 → 86,7
 
final List<SQLField> fields = new ArrayList<SQLField>(2);
fields.add(eltCmd.getTable().getField("TOTAL_HT"));
final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, TM.tr("sales.shipment.listTotal"));
final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, getConf().getERP_TM().translate("sales.shipment.listTotal"));
 
final GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/ui/BonDeLivraisonItemTable.java
27,6 → 27,7
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
import org.openconcerto.erp.core.sales.pos.ui.BarcodeListener;
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.sales.product.ui.ArticleRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
import org.openconcerto.erp.core.sales.product.ui.DeliveredQtyRowValuesRenderer;
33,6 → 34,7
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.QtyToDeliverRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable;
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
import org.openconcerto.sql.Configuration;
51,6 → 53,8
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
import org.openconcerto.sql.users.rights.UserRights;
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.list.AutoCompletionManager;
import org.openconcerto.sql.view.list.CellDynamicModifier;
import org.openconcerto.sql.view.list.RowValuesTable;
66,6 → 70,7
 
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.awt.event.KeyEvent;
75,7 → 80,9
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
 
import javax.swing.AbstractAction;
105,12 → 112,20
this.reliquatTable = reliquatTable;
}
 
public static Map<String, Boolean> customVisibilityMap = new HashMap<String, Boolean>();
 
@Override
protected Map<String, Boolean> getCustomVisibilityMap() {
return customVisibilityMap;
}
 
@Override
protected void init() {
final SQLElement e = getSQLElement();
 
SQLPreferences prefs = new SQLPreferences(getSQLElement().getTable().getDBRoot());
final boolean selectArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.USE_CREATED_ARTICLE, false);
final boolean activeCalculM2 = prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVE_CALCUL_M2, false);
final boolean createAuto = prefs.getBoolean(GestionArticleGlobalPreferencePanel.CREATE_ARTICLE_AUTO, true);
final boolean filterFamilleArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.FILTER_BY_FAMILY, false);
final boolean showEco = prefs.getBoolean(AbstractVenteArticleItemTable.SHOW_ECO_CONTRIBUTION_COLUMNS, false);
126,7 → 141,11
 
final SQLTableElement tableFamille = new SQLTableElement(e.getTable().getField("ID_FAMILLE_ARTICLE"));
list.add(tableFamille);
 
// Article
SQLTableElement tableElementDepot = new SQLTableElement(e.getTable().getField("ID_DEPOT_STOCK"), true, true, true);
list.add(tableElementDepot);
// Article
final SQLTableElement tableElementArticle = new SQLTableElement(e.getTable().getField("ID_ARTICLE"), true, true, true) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
321,6 → 340,29
list.add(eltUnitDevise);
}
 
SQLTableElement eltLongueur = new SQLTableElement(e.getTable().getField("LONGUEUR")) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
 
int idUv = vals.getForeignID("ID_UNITE_VENTE");
return idUv == UniteVenteArticleSQLElement.M2;
}
};
list.add(eltLongueur);
 
SQLTableElement eltLargeur = new SQLTableElement(e.getTable().getField("LARGEUR")) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
 
int idUv = vals.getForeignID("ID_UNITE_VENTE");
return idUv == UniteVenteArticleSQLElement.M2;
}
};
list.add(eltLargeur);
 
SQLTableElement eltHauteur = new SQLTableElement(e.getTable().getField("HAUTEUR"));
list.add(eltHauteur);
 
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE_UNITAIRE"), BigDecimal.class) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
328,6 → 370,8
SQLRowAccessor row = vals.getForeign("ID_UNITE_VENTE");
if (row != null && !row.isUndefined() && row.getBoolean("A_LA_PIECE")) {
return false;
} else if (activeCalculM2 && row != null && !row.isUndefined() && row.getID() == UniteVenteArticleSQLElement.M2) {
return false;
} else {
return super.isCellEditable(vals, rowIndex, columnIndex);
}
596,7 → 640,7
rowVals.put("PV_T_DEVISE", rowVals.getBigDecimal("PRIX_METRIQUE_VT_1").multiply(globalQty));
}
}
super.commitData();
super.commitData(true);
}
};
this.setModel(model);
603,6 → 647,7
this.table = new RowValuesTable(model, getConfigurationFile());
ToolTipManager.sharedInstance().unregisterComponent(this.table);
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
this.table.getClearCloneTableElement().add("ID_COMMANDE_CLIENT_ELEMENT");
 
if (filterFamilleArticle) {
((SQLTextComboTableCellEditor) tableElementArticle.getTableCellEditor(this.table)).setDynamicWhere(e.getTable().getTable("ARTICLE").getField("ID_FAMILLE_ARTICLE"));
636,6 → 681,9
completionField.add("PRIX_METRIQUE_VT_3");
completionField.add("SERVICE");
completionField.add("ID_FAMILLE_ARTICLE");
completionField.add("LONGUEUR");
completionField.add("LARGEUR");
completionField.add("HAUTEUR");
if (getSQLElement().getTable().getFieldsName().contains("DESCRIPTIF")) {
completionField.add("DESCRIPTIF");
}
655,7 → 703,7
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
}
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
747,7 → 795,7
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
}
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
770,7 → 818,7
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
}
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
1071,6 → 1119,28
}
});
 
uniteVente.addModificationListener(qteU);
eltLargeur.addModificationListener(qteU);
eltLongueur.addModificationListener(qteU);
qteU.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
SQLRowAccessor rowUnite = row.getForeign("ID_UNITE_VENTE");
if (rowUnite != null && !rowUnite.isUndefined() && rowUnite.getBoolean("A_LA_PIECE")) {
return BigDecimal.ONE;
} else if (activeCalculM2 && rowUnite != null && !rowUnite.isUndefined() && rowUnite.getID() == UniteVenteArticleSQLElement.M2) {
BigDecimal longueur = row.getBigDecimal("LONGUEUR");
BigDecimal largeur = row.getBigDecimal("LARGEUR");
if (longueur == null || largeur == null) {
return BigDecimal.ONE;
}
return longueur.multiply(largeur);
} else {
return row.getObject("QTE_UNITAIRE");
}
}
 
});
 
// Mode Gestion article avancé
String valModeAvanceVt = DefaultNXProps.getInstance().getStringProperty("ArticleModeVenteAvance");
Boolean bModeAvance = Boolean.valueOf(valModeAvanceVt);
1088,6 → 1158,11
setColumnVisible(model.getColumnForField("T_POIDS_COLIS_NET"), false);
}
 
// ACtivation calcul m2
setColumnVisible(model.getColumnForField("HAUTEUR"), false);
setColumnVisible(model.getColumnForField("LARGEUR"), activeCalculM2);
setColumnVisible(model.getColumnForField("LONGUEUR"), activeCalculM2);
 
setColumnVisible(model.getColumnForField("ID_ARTICLE"), selectArticle);
setColumnVisible(model.getColumnForField("CODE"), !selectArticle || (selectArticle && createAuto));
setColumnVisible(model.getColumnForField("NOM"), !selectArticle || (selectArticle && createAuto));
1108,10 → 1183,23
setColumnVisible(model.getColumnForField("PRIX_METRIQUE_HA_1"), showHAPrice);
setColumnVisible(model.getColumnForField("MARGE_HT"), showHAPrice);
setColumnVisible(model.getColumnForField("T_PA_HT"), showHAPrice);
setColumnVisible(model.getColumnForField("ID_DEPOT_STOCK"), prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false));
 
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
setColumnVisible(model.getColumnForField("ID_COMMANDE_CLIENT_ELEMENT"), false);
}
 
for (String string : AbstractVenteArticleItemTable.getVisibilityMap().keySet()) {
setColumnVisible(model.getColumnForField(string), AbstractVenteArticleItemTable.getVisibilityMap().get(string));
}
 
Map<String, Boolean> mapCustom = getCustomVisibilityMap();
if (mapCustom != null) {
for (String string : mapCustom.keySet()) {
setColumnVisible(model.getColumnForField(string), mapCustom.get(string));
}
}
 
// Barcode reader
final BarcodeReader barcodeReader = ComptaPropsConfiguration.getInstanceCompta().getBarcodeReader();
if (barcodeReader != null) {
1159,6 → 1247,34
 
}
 
if (this.table.getRowValuesTableModel().getColumnForField("ID_DEPOT_STOCK") >= 0 && this.table.getRowValuesTableModel().getColumnForField("ID_ARTICLE") >= 0) {
if (this.buttons == null) {
this.buttons = new ArrayList<>();
}
 
JButton buttonStock = new JButton("Consulter le stock");
buttonStock.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
SQLRowValues rowValsSel = table.getSelectedRowValues();
if (rowValsSel != null) {
SQLRowAccessor foreignArt = rowValsSel.getForeign("ID_ARTICLE");
if (foreignArt != null && !foreignArt.isUndefined()) {
SQLRowAccessor rowValsStock = StockSQLElement.getStock(rowValsSel);
if (rowValsStock != null && !rowValsStock.isUndefined()) {
EditFrame frame = new EditFrame(table.getRowValuesTableModel().getSQLElement().getDirectory().getElement("STOCK"), EditMode.READONLY);
frame.selectionId(rowValsStock.getID());
frame.setVisible(true);
}
}
}
 
}
});
 
this.buttons.add(buttonStock);
 
}
 
// On réécrit la configuration au cas ou les preferences aurait changé
this.table.writeState();
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/credit/component/AvoirClientSQLComponent.java
956,13 → 956,16
}
 
rowVals.update();
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
final int foreignIDmvt = rowFacture.getForeignID("ID_MOUVEMENT");
eltEcr.archiveMouvementProfondeur(foreignIDmvt, false);
 
System.err.println("Regeneration des ecritures");
new GenerationMvtSaisieVenteFacture(rowFacture.getID(), foreignIDmvt);
System.err.println("Fin regeneration");
List<SQLRow> rowEch = rowFacture.getReferentRows(rowFacture.getTable().getTable("ECHEANCE_CLIENT"));
for (SQLRow sqlRow : rowEch) {
if (!sqlRow.getBoolean("REG_COMPTA") && !sqlRow.getBoolean("REGLE")) {
// update echeance
SQLRowValues createEmptyUpdateRow2 = sqlRow.createEmptyUpdateRow();
createEmptyUpdateRow2.put("MONTANT", Math.max(0, sqlRow.getLong("MONTANT") - totalAvoir));
createEmptyUpdateRow2.commit();
break;
}
}
} catch (SQLException e1) {
ExceptionHandler.handle("Erreur lors de l'affection de l'avoir sur la facture!", e1);
} finally {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/CommandeClientElementSQLElement.java
74,6 → 74,22
rowAction.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
getRowActions().add(rowAction);
 
PredicateRowAction rowActionBL = new PredicateRowAction(new AbstractAction("Transférer la commande en BL") {
 
@Override
public void actionPerformed(ActionEvent e) {
List<SQLRowValues> resultId = new ArrayList<>();
CommandeClientSQLElement cmdElt = (CommandeClientSQLElement) getForeignElement("ID_COMMANDE_CLIENT");
for (SQLRowValues sqlRowAccessor : IListe.get(e).getSelectedRows()) {
resultId.add(sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT").asRowValues());
}
cmdElt.transfertBonLivraisonClient(resultId);
}
 
}, true);
rowActionBL.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
getRowActions().add(rowActionBL);
 
PredicateRowAction rowActionCmd = new PredicateRowAction(new AbstractAction("Modifier la commande associée") {
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/ChiffrageCommandeClientSQLElement.java
17,11 → 17,14
import org.openconcerto.erp.core.common.ui.DeviseTableCellRenderer;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.utils.ListMap;
 
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
public class ChiffrageCommandeClientSQLElement extends ComptaSQLConfElement {
 
30,6 → 33,20
 
}
 
@Override
public Set<String> getReadOnlyFields() {
Set<String> s = new HashSet<>();
s.add("NOM");
s.add("ID_FAMILLE_ARTICLE");
s.add("PA_HT");
s.add("PV_HT");
s.add("QTE");
s.add("ID_UNITE_VENTE");
s.add("T_PA_HT");
s.add("T_PV_HT");
return s;
}
 
/*
* (non-Javadoc)
*
53,11 → 70,31
@Override
protected void _initTableSource(SQLTableModelSource res) {
super._initTableSource(res);
res.getColumn(getTable().getField("QTE")).setRenderer(new DeviseTableCellRenderer());
 
res.getColumn(getTable().getField("PA_HT")).setRenderer(new DeviseTableCellRenderer());
res.getColumn(getTable().getField("MARGE")).setRenderer(new DeviseTableCellRenderer());
res.getColumn(getTable().getField("T_PA_HT")).setRenderer(new DeviseTableCellRenderer());
SQLTableModelColumn columnQte = res.getColumn(getTable().getField("QTE"));
if (columnQte != null) {
columnQte.setRenderer(new DeviseTableCellRenderer());
}
 
if (getTable().contains("ANT")) {
final SQLTableModelColumn columnAnt = res.getColumn(getTable().getField("ANT"));
if (columnAnt != null) {
columnAnt.setRenderer(new DeviseTableCellRenderer());
}
}
 
final SQLTableModelColumn columnPA = res.getColumn(getTable().getField("PA_HT"));
if (columnPA != null) {
columnPA.setRenderer(new DeviseTableCellRenderer());
}
final SQLTableModelColumn columnmarge = res.getColumn(getTable().getField("MARGE"));
if (columnmarge != null) {
columnmarge.setRenderer(new DeviseTableCellRenderer());
}
SQLTableModelColumn column = res.getColumn(getTable().getField("T_PA_HT"));
if (column != null) {
column.setRenderer(new DeviseTableCellRenderer());
}
}
 
/*
92,16 → 129,25
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new UISQLComponent(this) {
return new UISQLComponent(this, 3) {
public void addViews() {
this.addView("NOM");
this.addView("ID_FAMILLE_ARTICLE");
this.addView("PA_HT");
this.addView("PV_HT");
this.addView("QTE");
this.addView("ID_UNITE_VENTE");
this.addView("T_PA_HT");
this.addView("T_PV_HT");
this.addView("NOM", "1");
this.addView("ID_FAMILLE_ARTICLE", "1");
this.addView("PA_HT", "1");
this.addView("PV_HT", "1");
this.addView("QTE", "1");
if (getTable().contains("RESTANT")) {
this.addView("RESTANT", "1");
}
this.addView("ID_UNITE_VENTE", "1");
this.addView("T_PA_HT", "1");
this.addView("T_PV_HT", "1");
if (getTable().contains("ANT")) {
this.addView("ANT", "1");
}
if (getTable().contains("MOTIF")) {
this.addView("MOTIF", "1");
}
}
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/component/CommandeClientSQLComponent.java
864,10 → 864,10
super.select(rVals);
}
if (r != null) {
this.table.insertFrom("ID_COMMANDE_CLIENT", r.getID());
this.tableFacturationItem.insertFrom("ID_COMMANDE_CLIENT", r.getID());
this.table.getRowValuesTable().insertFrom(r);
this.tableFacturationItem.getRowValuesTable().insertFrom(r);
if (this.tableChiffrageItem != null) {
this.tableChiffrageItem.insertFrom("ID_COMMANDE_CLIENT", r.getID());
this.tableChiffrageItem.getRowValuesTable().insertFrom(r);
}
}
// this.radioEtat.setVisible(r.getID() > 1);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSoldeSQLComponent.java
14,22 → 14,29
package org.openconcerto.erp.core.sales.account;
 
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable.TypeCalcul;
import org.openconcerto.erp.core.common.ui.Acompte;
import org.openconcerto.erp.core.common.ui.AcompteField;
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable.TypeCalcul;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.core.sales.invoice.ui.FactureSituationItemTable;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
import org.openconcerto.sql.element.GlobalMapper;
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.preferences.SQLPreferences;
import org.openconcerto.ui.group.Group;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Tuple2;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
66,10 → 73,28
 
@Override
public int insert(SQLRow order) {
return super.insert(order);
int id = super.insert(order);
try {
updateStock(id);
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors de la mise à jour du stock.", e);
e.printStackTrace();
}
return id;
}
 
@Override
public void update() {
super.update();
try {
updateStock(getSelectedID());
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors de la mise à jour du stock.", e);
e.printStackTrace();
}
}
 
@Override
public void importFrom(List<SQLRowValues> rows) {
 
super.importFrom(rows);
114,6 → 139,34
return l;
}
 
protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
return "Saisie vente facture N°" + row.getString("NUMERO");
}
 
/**
* Mise à jour des stocks pour chaque article composant la facture
*
* @throws SQLException
*/
private void updateStock(int id) throws SQLException {
 
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
SQLRow row = getTable().getRow(id);
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
 
@Override
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
return getLibelleStock(rowOrigin, rowElt);
}
}, row, row.getReferentRows(getTable().getTable("SAISIE_VENTE_FACTURE_ELEMENT")),
getTable().contains("CREATE_VIRTUAL_STOCK") && row.getBoolean("CREATE_VIRTUAL_STOCK") ? TypeStockUpdate.REAL_VIRTUAL_DELIVER : TypeStockUpdate.REAL_DELIVER);
 
stockUpdater.update();
 
}
}
 
// @Override
// public Component addView(MutableRowItemView rowItemView, String fields, Object specObj) {
//
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSituationSQLComponent.java
67,6 → 67,8
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
public class VenteFactureSituationSQLComponent extends TransfertGroupSQLComponent {
public static final String ID = "sales.invoice.partial";
201,7 → 203,7
sqlRequestComboBox.setEnabled(false);
 
final AcompteField acompteField = ((AcompteField) getEditor("sales.invoice.partial.amount"));
acompteField.getDocument().addDocumentListener(new SimpleDocumentListener() {
listenerAcompteField = new SimpleDocumentListener() {
 
@Override
public void update(DocumentEvent e) {
208,7 → 210,25
Acompte a = acompteField.getValue();
table.calculPourcentage(a, TypeCalcul.CALCUL_FACTURABLE);
}
});
 
};
acompteField.getDocument().addDocumentListener(listenerAcompteField);
 
listenerTable = new TableModelListener() {
 
@Override
public void tableChanged(TableModelEvent e) {
acompteField.getDocument().removeDocumentListener(listenerAcompteField);
if (e.getColumn() == table.getModel().getColumnForField("POURCENT_FACTURABLE")) {
Acompte a = new Acompte(null, table.getTotalHT(TypeCalcul.CALCUL_MONTANT_TOTAL));
acompteField.setValue(a);
 
}
acompteField.getDocument().addDocumentListener(listenerAcompteField);
}
 
};
table.getRowValuesTable().getModel().addTableModelListener(listenerTable);
total.addValueListener(new PropertyChangeListener() {
 
@Override
220,19 → 240,9
 
}
 
int countPole = 0;
private SimpleDocumentListener listenerAcompteField;
private TableModelListener listenerTable;
 
// @Override
// public Component addView(MutableRowItemView rowItemView, String fields, Object specObj) {
//
// if (fields.contains("ID_POLE_PRODUIT") && countPole == 0) {
// countPole++;
// return null;
// } else {
// return super.addView(rowItemView, fields, specObj);
// }
// }
 
@Override
public JComponent getLabel(String id) {
if (id.equals("sales.invoice.partial.amount")) {
283,10 → 293,11
// Set only VAT Editable
for (int i = 0; i < items.getRowValuesTable().getColumnModel().getColumnCount(false); i++) {
final SQLTableElement sqlTableElementAt = items.getRowValuesTable().getRowValuesTableModel().getSQLTableElementAt(i);
if (sqlTableElementAt.getField() == null || !sqlTableElementAt.getField().getName().equalsIgnoreCase("ID_TAXE")) {
if (sqlTableElementAt.getField() != null && (sqlTableElementAt.getField().getName().equalsIgnoreCase("ID_STYLE")
|| sqlTableElementAt.getField().getName().equalsIgnoreCase("POURCENT_FACTURABLE") || sqlTableElementAt.getField().getName().equalsIgnoreCase("ID_TAXE"))) {
sqlTableElementAt.setEditable(true);
} else {
sqlTableElementAt.setEditable(false);
} else {
sqlTableElementAt.setEditable(true);
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/ListeDesVentesAction.java
14,6 → 14,7
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.sales.invoice.ui.ListeDesVentesPanel;
 
20,15 → 21,17
import javax.swing.Action;
import javax.swing.JFrame;
 
 
public class ListeDesVentesAction extends CreateFrameAbstractAction {
 
public ListeDesVentesAction() {
private final ComptaPropsConfiguration conf;
 
public ListeDesVentesAction(final ComptaPropsConfiguration conf) {
super();
this.putValue(Action.NAME, "Liste des ventes");
this.conf = conf;
}
 
@Override
public JFrame createFrame() {
return new PanelFrame(new ListeDesVentesPanel(), "Liste des ventes");
return new PanelFrame(new ListeDesVentesPanel(this.conf), (String) this.getValue(Action.NAME));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/ListeEcheancePrelevementAction.java
New file
0,0 → 1,491
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement.GenerationResult;
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement.IgnoreReason;
import org.openconcerto.erp.core.sales.invoice.element.EcheanceClientSQLElement;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.generationEcritures.GenerationMvtSepa;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.model.FieldPath;
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.model.graph.Path;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.i18n.Grammar_fr;
 
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
 
import javax.swing.AbstractAction;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
 
public class ListeEcheancePrelevementAction extends CreateFrameAbstractAction {
 
private final EcheanceClientSQLElement elem;
private final ComptaPropsConfiguration conf;
 
public ListeEcheancePrelevementAction(ComptaPropsConfiguration conf) {
super();
this.elem = conf.getDirectory().getElement(EcheanceClientSQLElement.class);
this.conf = conf;
}
 
public final EcheanceClientSQLElement getElem() {
return this.elem;
}
 
private void setWhere(final SQLTableModelSourceOnline tableSource, boolean showHistory) {
final SQLTable tableEcheance = this.elem.getTable();
Where w = new Where(tableEcheance.getField("ID_SEPA_MANDATE"), "!=", (Object) null);
if (!showHistory) {
w = w.and(new Where(tableEcheance.getField("REGLE"), "=", Boolean.FALSE));
w = w.and(new Where(tableEcheance.getField("REG_COMPTA"), "=", Boolean.FALSE));
}
tableSource.getReq().setWhere(w);
}
 
@Override
public JFrame createFrame() {
final SQLTableModelSourceOnline tableSource = this.elem.getTableSource(true);
setWhere(tableSource, false);
final TM tm = conf.getERP_TM();
tableSource.getColumns().add(new BaseSQLTableModelColumn("Etat", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
if (r.getBoolean("REGLE")) {
return TM.tr("sepa.deadline.done");
} else if (r.getBoolean("REG_COMPTA")) {
return TM.tr("sepa.deadline.regul");
} else if (!r.isForeignEmpty("ID_SDD_MESSAGE")) {
return TM.tr("sepa.deadline.filecreated");
}
return TM.tr("sepa.deadline.waiting");
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(elem.getTable());
return CollectionUtils.createSet(new FieldPath(p, "REGLE"), new FieldPath(p, "REG_COMPTA"), new FieldPath(p, "ID_SDD_MESSAGE"));
}
});
tableSource.getColumns().add(new BaseSQLTableModelColumn("Fichier SEPA", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
if (r.isForeignEmpty("ID_SDD_MESSAGE")) {
return "";
} else {
return r.getForeign("ID_SDD_MESSAGE").getString("MessageIdentification");
}
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(elem.getTable());
p = p.add(elem.getTable().getField("ID_SDD_MESSAGE"));
return CollectionUtils.createSet(new FieldPath(p, "MessageIdentification"));
}
});
 
final ListeAddPanel panel = new ListeAddPanel(this.elem, new IListe(tableSource));
 
final IListFrame res = new IListFrame(panel);
res.setTextTitle("Prélèvements SEPA");
res.getPanel().setReadWriteButtonsVisible(false);
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridy += 2;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
final JCheckBox checkboxHistory = new JCheckBox(TM.tr("sepa.history.hide"));
checkboxHistory.setSelected(true);
checkboxHistory.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
setWhere(tableSource, !checkboxHistory.isSelected());
 
}
});
res.getPanel().add(checkboxHistory, c);
 
final SDDMessageSQLElement sepaMsgElem = this.elem.getDirectory().getElement(SDDMessageSQLElement.class);
final String aMessageLabel = this.elem.getForeignElement(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME).getName().getVariant(Grammar_fr.INDEFINITE_ARTICLE_SINGULAR);
RowAction actionFileCreate = new RowAction.PredicateRowAction(new AbstractAction("Générer " + aMessageLabel, null) {
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
final List<Integer> selectedIDs = new ArrayList<>();
final Set<Integer> selectedClientIDs = new HashSet<>();
for (SQLRowValues rowVals : l.getSelectedRows()) {
selectedClientIDs.add(rowVals.getForeignID("ID_CLIENT"));
if (rowVals.getLong("MONTANT") > 0) {
selectedIDs.add(rowVals.getID());
}
}
 
// TODO dialog with label informing of the successful creation of message for n
// invoices/n2 messages too far in the future/n3 messages with collection date
// changed and having a button to open the file chooser
 
new SwingWorker<String, Void>() {
 
@Override
protected String doInBackground() throws Exception {
 
return checkSEPA(selectedClientIDs);
}
 
@Override
protected void done() {
try {
String msg = get();
 
if (msg.trim().length() > 0) {
msg = "Des informations nécessaires à la création du fichier sont manquantes : \n" + msg;
msg += "Le fichier ne pourra être créer tant que ces informations n'auront pas été renseignées.";
JOptionPane.showMessageDialog(null, msg, "Création du fichier SEPA annulée", JOptionPane.WARNING_MESSAGE);
return;
}
} catch (Exception e) {
ExceptionHandler.handle(l, "Impossible de générer " + aMessageLabel, e);
return;
}
new SwingWorker<GenerationResult, Void>() {
@Override
protected GenerationResult doInBackground() throws Exception {
return sepaMsgElem.generateXML(elem.getTable(), selectedIDs);
}
 
@Override
protected void done() {
final GenerationResult genRes;
try {
genRes = this.get();
} catch (Exception e) {
ExceptionHandler.handle(l, "Impossible de générer " + aMessageLabel, e);
return;
}
final int includedInvoicesCount = genRes.getIncludedInvoicesCount();
final Map<String, Object> tmMap = new HashMap<>();
tmMap.put("msgElem", sepaMsgElem.getName());
tmMap.put("invoiceElem", elem.getName());
tmMap.put("invoiceElemCount", includedInvoicesCount);
 
if (genRes.getDDInvoicesWithoutMessage().isEmpty()) {
JOptionPane.showMessageDialog(l, tm.trM("sddMessage.generation.noneNeeded", tmMap));
} else if (genRes.getIgnoredInvoices().isEmpty()) {
JOptionPane.showMessageDialog(l, tm.trM("sddMessage.generation.noneIgnored", tmMap));
} else {
final int futureCount = genRes.getIgnoredInvoices().getNonNull(IgnoreReason.TOO_FAR_IN_FUTURE).size();
final int duplicateCount = genRes.getIgnoredInvoices().getNonNull(IgnoreReason.DUPLICATE_MANDATE).size();
final int missingInfoCount = genRes.getIgnoredInvoices().getNonNull(IgnoreReason.MISSING_INFO).size();
tmMap.put("futureCount", futureCount);
tmMap.put("duplicateCount", duplicateCount);
tmMap.put("missingInfoCount", missingInfoCount);
final StringBuilder msg = new StringBuilder(256);
msg.append(tm.trM("sddMessage.generation.someIgnored", tmMap));
if (futureCount > 0) {
msg.append("\n- ");
msg.append(tm.trM("sddMessage.generation.someIgnored.future", tmMap));
}
if (duplicateCount > 0) {
msg.append("\n- ");
msg.append(tm.trM("sddMessage.generation.someIgnored.duplicateMandate", tmMap));
}
if (missingInfoCount > 0) {
msg.append("\n- ");
msg.append(tm.trM("sddMessage.generation.someIgnored.missingInfo", tmMap));
}
final int messageType = duplicateCount == 0 ? JOptionPane.WARNING_MESSAGE : JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(l, msg.toString(), null, messageType);
}
if (genRes.getInsertedMessage() != null) {
sepaMsgElem.exportXML(l, Collections.singletonList(genRes.getInsertedMessage()));
}
}
}.execute();
}
}.execute();
 
}
}, true, true).setPredicate(IListeEvent.getNonEmptySelectionPredicate());
 
// TODO remove once we have a join with {SENT, OK, DEFINITIVE_ERROR, TRANSIENT_ERROR}
RowAction actionSepaAgain = new RowAction.PredicateRowAction(new AbstractAction("Prélever à nouveau", null) {
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
if (JOptionPane.showConfirmDialog(l, "Voulez-vous vraiment prélever à nouveau les factures sélectionnées ? Cette action est définitive.", "Prélever à nouveau",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION)
return;
final List<Integer> selectedIDs = l.getSelection().getSelectedIDs();
final SQLTable table = l.getSource().getPrimaryTable();
 
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
final UpdateBuilder upd = new UpdateBuilder(table);
upd.setObject(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, upd.getTable().getForeignTable(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME).getUndefinedIDNumber());
upd.setObject(SaisieVenteFactureSQLElement.END2END_FIELD_NAME, "");
// don't allow to debit already payed invoices
upd.setWhere(new Where(upd.getTable().getKey(), selectedIDs).and(new Where(upd.getTable().getField("REGLE"), "=", Boolean.FALSE))
.and(new Where(upd.getTable().getField("REG_COMPTA"), "=", Boolean.FALSE)));
 
upd.getTable().getDBSystemRoot().getDataSource().execute(upd.asString());
 
return null;
}
 
@Override
protected void done() {
try {
get();
final SQLTable table = l.getSource().getPrimaryTable().getTable();
final List<String> modifiedFields = Arrays.asList(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, SaisieVenteFactureSQLElement.END2END_FIELD_NAME);
for (final Integer id : selectedIDs) {
table.fireTableModified(id, modifiedFields);
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
}.execute();
 
}
}, false, true).setPredicate(IListeEvent.getNonEmptySelectionPredicate());
 
panel.getListe().addIListeAction(actionFileCreate);
 
panel.getListe().addIListeAction(actionSepaAgain);
 
RowAction actionCompta = new RowAction(new AbstractAction("Valider le paiement", null) {
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
if (JOptionPane.showConfirmDialog(l, "Voulez-vous vraiment transférer ces prélèvements en comptabilité ?", "Comptabiliser", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION)
return;
 
List<SQLRow> rows = new ArrayList<>();
List<Integer> ids = new ArrayList<>();
for (SQLRowAccessor sqlRow : l.getSelectedRows()) {
rows.add(sqlRow.asRow());
ids.add(sqlRow.getID());
}
 
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
try {
GenerationMvtSepa sepa = new GenerationMvtSepa(rows);
sepa.genere();
UpdateBuilder build = new UpdateBuilder(elem.getTable());
build.setObject(elem.getTable().getField("REGLE"), Boolean.TRUE);
build.setWhere(new Where(elem.getTable().getKey(), ids));
elem.getTable().getDBSystemRoot().getDataSource().execute(build.asString());
 
} catch (Exception e) {
ExceptionHandler.handle("Erreur lors du transfert en comptabilité", e);
 
}
return null;
}
 
@Override
protected void done() {
try {
get();
for (final Integer id : ids)
elem.getTable().fireTableModified(id, Arrays.asList("REGLE"));
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
}.execute();
}
}, true, true) {
 
@Override
public boolean enabledFor(List<SQLRowValues> selection) {
if (selection != null && selection.size() >= 1) {
for (SQLRowValues sqlRowValues : selection) {
if (sqlRowValues.getBoolean("REGLE")) {
return false;
}
}
return true;
}
return false;
}
};
 
panel.getListe().addIListeAction(actionCompta);
 
RowAction actionHistoSEPA = new RowAction.PredicateRowAction(new AbstractAction("Historique Fichiers SEPA", null) {
@Override
public void actionPerformed(ActionEvent e) {
final IListFrame res = new IListFrame(new ListeAddPanel(elem.getDirectory().getElement(SDDMessageSQLElement.class)));
res.getPanel().setReadWriteButtonsVisible(false);
FrameUtil.showPacked(res);
}
}, true, true).setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
 
panel.getListe().addIListeAction(actionHistoSEPA);
 
RowAction actionRelancer = new RowAction.PredicateRowAction(new AbstractAction("Relancer", null) {
@Override
public void actionPerformed(ActionEvent e) {
elem.relanceClient(IListe.get(e).getSelectedRow().asRow());
}
}, true, true).setPredicate(IListeEvent.getSingleSelectionPredicate());
 
panel.getListe().addIListeAction(actionRelancer);
 
RowAction actionCancelPaiement = new RowAction(new AbstractAction("Annuler la validation", null) {
 
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
if (JOptionPane.showConfirmDialog(l, "Voulez-vous vraiment annuler le transfert de ce prélèvement en comptabilité ?", "Comptabiliser", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION)
return;
 
final SQLRowValues selectedRow = IListe.get(e).getSelectedRow();
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
Collection<? extends SQLRowAccessor> res = selectedRow.asRow().getForeign("ID_MOUVEMENT")
.getReferentRows(elem.getTable().getTable("ENCAISSER_MONTANT_ELEMENT").getField("ID_MOUVEMENT_ECHEANCE"));
if (res.size() >= 1) {
try {
elem.getDirectory().getElement("MOUVEMENT").archive(res.iterator().next().getForeign("ID_ENCAISSER_MONTANT").getForeignID("ID_MOUVEMENT"));
UpdateBuilder build = new UpdateBuilder(elem.getTable());
build.setObject(elem.getTable().getField("REGLE"), Boolean.FALSE);
build.setWhere(new Where(elem.getTable().getKey(), "=", l.getSelectedId()));
elem.getTable().getDBSystemRoot().getDataSource().execute(build.asString());
} catch (SQLException e1) {
e1.printStackTrace();
}
}
 
return null;
}
 
@Override
protected void done() {
try {
get();
elem.getTable().fireTableModified(l.getSelectedId(), Arrays.asList("REGLE"));
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
 
}
}.execute();
 
}
 
}, false, true) {
 
@Override
public boolean enabledFor(List<SQLRowValues> selection) {
if (selection != null && selection.size() == 1) {
return selection.get(0).getBoolean("REGLE");
}
return false;
}
 
};
 
panel.getListe().addIListeAction(actionCancelPaiement);
return res;
 
}
 
private String checkSEPA(Set<Integer> selectedClientIDs) {
StringBuilder msg = new StringBuilder();
 
SQLRow rowSociete = conf.getRowSociete();
if (rowSociete.getString("IBAN").trim().length() == 0) {
msg.append("IBAN non renseigné dans les informations de la société.\n");
}
if (rowSociete.getString("BIC").trim().length() == 0) {
msg.append("BIC non renseigné dans les informations de la société.\n");
}
if (rowSociete.getString("SEPA_CREDITOR_ID").trim().length() == 0) {
msg.append("Idenfiant de créancier non renseigné dans les informations de la société.\n");
}
if (msg.length() == 0) {
SQLRowValues rowVals = new SQLRowValues(elem.getTable().getForeignTable("ID_CLIENT"));
rowVals.putNulls("CODE", "NOM", "IBAN", "BIC");
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
List<SQLRowValues> res = fetcher.fetch(new Where(rowVals.getTable().getKey(), selectedClientIDs));
for (SQLRowValues r : res) {
 
final int ibanLength = r.getString("IBAN").trim().length();
final int bicLength = r.getString("BIC").trim().length();
if (ibanLength == 0 && bicLength == 0) {
msg.append("IBAN et BIC non renseignés pour le client " + r.getString("NOM") + ".\n");
} else if (ibanLength == 0) {
msg.append("IBAN non renseignés pour le client " + r.getString("NOM") + ".\n");
} else if (bicLength == 0) {
msg.append("BIC non renseignés pour le client " + r.getString("NOM") + ".\n");
}
}
 
}
return msg.toString();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListPanelEcheancesClients.java
93,6 → 93,8
// FIXME : remove queries from AWT
final SQLTable elementEchT = getListe().getSource().getPrimaryTable();
Where wNotRegle = new Where(elementEchT.getField("REGLE"), "=", Boolean.FALSE);
wNotRegle = wNotRegle.and(new Where(elementEchT.getTable().getField("ID_SEPA_MANDATE"), "=", (Object) null));
 
if (!showRegCompta) {
wNotRegle = wNotRegle.and(new Where(elementEchT.getField("REG_COMPTA"), "=", Boolean.FALSE));
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeDesEcheancesClientsPanel.java
15,12 → 15,11
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.customerrelationship.customer.element.RelanceSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.payment.component.EncaisserMontantSQLComponent;
import org.openconcerto.erp.core.sales.invoice.element.EcheanceClientSQLElement;
import org.openconcerto.erp.rights.ComptaUserRight;
import org.openconcerto.erp.rights.NXRights;
import org.openconcerto.sql.Configuration;
31,12 → 30,10
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanelListener;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.sql.view.IListener;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
44,10 → 41,8
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
import javax.swing.JButton;
130,7 → 125,7
this.add(this.relancer, c);
this.relancer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
relanceClient();
((EcheanceClientSQLElement) panelEcheances.getElement()).relanceClient(getListPanelEcheancesClients().getListe().getSelectedRow().asRow());
}
});
}
272,70 → 267,6
 
}
 
private void relanceClient() {
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLElement relanceElt = Configuration.getInstance().getDirectory().getElement("RELANCE");
 
final SQLRow rowSource = this.panelEcheances.getListe().fetchSelectedRow();
 
if (rowSource != null) {
int idMvtSource = MouvementSQLElement.getSourceId(rowSource.getInt("ID_MOUVEMENT"));
SQLRow rowMvtSource = base.getTable("MOUVEMENT").getRow(idMvtSource);
 
if (!rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
this.relancer.setEnabled(false);
return;
}
 
if (this.editRelance == null) {
this.editRelance = new EditFrame(relanceElt);
this.editRelance.setIconImages(Gestion.getFrameIcon());
this.editRelance.addEditPanelListener(new EditPanelListener() {
 
public void cancelled() {
// rien
}
 
public void modified() {
// rien
}
 
public void deleted() {
// rien
}
 
public void inserted(int id) {
int nbRelance = rowSource.getInt("NOMBRE_RELANCE");
nbRelance++;
 
SQLRowValues rowValsEch = new SQLRowValues(rowSource.getTable());
rowValsEch.put("NOMBRE_RELANCE", nbRelance);
rowValsEch.put("DATE_LAST_RELANCE", new Date());
 
try {
rowValsEch.update(rowSource.getID());
relanceElt.getTable().getRow(id).createEmptyUpdateRow().put("ID_ECHEANCE_CLIENT", rowSource.getID()).commit();
} catch (SQLException e1) {
ExceptionHandler.handle("erreur lors de la mise à jour du nombre de relances", e1);
}
}
});
}
 
SQLRowValues rowVals = new SQLRowValues(relanceElt.getTable());
rowVals.put("ID_SAISIE_VENTE_FACTURE", rowMvtSource.getInt("IDSOURCE"));
rowVals.put("MONTANT", rowSource.getObject("MONTANT"));
rowVals.put("ID_CLIENT", rowSource.getInt("ID_CLIENT"));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(RelanceSQLElement.class, new Date()));
this.editRelance.getSQLComponent().select(rowVals);
 
this.editRelance.pack();
this.editRelance.setVisible(true);
} else {
Thread.dumpStack();
}
}
 
public IListPanel getListPanelEcheancesClients() {
return this.panelEcheances;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeDesVentesPanel.java
25,8 → 25,8
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.ui.TextAreaTicketPanel;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
79,7 → 79,7
private JLabelBold textField = new JLabelBold("0");
private JLabelBold textField2 = new JLabelBold("0");
 
public ListeDesVentesPanel() {
public ListeDesVentesPanel(final ComptaPropsConfiguration conf) {
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(2, 2, 1, 2);
94,7 → 94,8
 
JTabbedPane tabbedPane = new JTabbedPane();
 
final SQLElement elementVF = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
final SQLElementDirectory dir = conf.getDirectory();
final SQLElement elementVF = dir.getElement("SAISIE_VENTE_FACTURE");
// tab Vente facture
final SQLElement eltFacture = elementVF;
final SQLTableModelSourceOnline src = eltFacture.getTableSource(true);
150,91 → 151,7
src.getColumns().add(new SQLTableModelColumnPath(new FieldPath(new Path(eltFacture.getTable()).addForeignField(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME), "MessageIdentification")));
 
this.listeFact = new ListeGestCommEltPanel(eltFacture, new IListe(src), true);
final SDDMessageSQLElement sepaMsgElem = eltFacture.getDirectory().getElement(SDDMessageSQLElement.class);
final String aMessageLabel = sepaMsgElem.getName().getVariant(Grammar_fr.INDEFINITE_ARTICLE_SINGULAR);
this.listeFact.getListe().addIListeAction(new RowAction.PredicateRowAction(new AbstractAction("Générer " + aMessageLabel, null) {
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
final List<Integer> selectedIDs = l.getSelection().getSelectedIDs();
// TODO dialog with label informing of the successful creation of message for n
// invoices/n2 messages too far in the future/n3 messages with collection date
// changed and having a button to open the file chooser
new SwingWorker<GenerationResult, Void>() {
@Override
protected GenerationResult doInBackground() throws Exception {
return sepaMsgElem.generateXML(selectedIDs);
}
 
@Override
protected void done() {
final GenerationResult genRes;
try {
genRes = this.get();
} catch (Exception e) {
ExceptionHandler.handle(l, "Impossible de générer " + aMessageLabel, e);
return;
}
final int includedInvoicesCount = genRes.getIncludedInvoicesCount();
final Map<String, Object> tmMap = new HashMap<>();
tmMap.put("msgElem", sepaMsgElem.getName());
tmMap.put("invoiceElem", elementVF.getName());
tmMap.put("invoiceElemCount", includedInvoicesCount);
if (genRes.getDDInvoicesWithoutMessage().isEmpty()) {
JOptionPane.showMessageDialog(l, TM.getTM().trM("sddMessage.generation.noneNeeded", tmMap));
} else if (genRes.getIgnoredInvoices().isEmpty()) {
JOptionPane.showMessageDialog(l, TM.getTM().trM("sddMessage.generation.noneIgnored", tmMap));
} else {
final int futureCount = genRes.getIgnoredInvoices().getNonNull(IgnoreReason.TOO_FAR_IN_FUTURE).size();
final int duplicateCount = genRes.getIgnoredInvoices().getNonNull(IgnoreReason.DUPLICATE_MANDATE).size();
final int missingInfoCount = genRes.getIgnoredInvoices().getNonNull(IgnoreReason.MISSING_INFO).size();
tmMap.put("futureCount", futureCount);
tmMap.put("duplicateCount", duplicateCount);
tmMap.put("missingInfoCount", missingInfoCount);
final StringBuilder msg = new StringBuilder(256);
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored", tmMap));
if (futureCount > 0) {
msg.append("\n- ");
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored.future", tmMap));
}
if (duplicateCount > 0) {
msg.append("\n- ");
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored.duplicateMandate", tmMap));
}
if (missingInfoCount > 0) {
msg.append("\n- ");
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored.missingInfo", tmMap));
}
final int messageType = duplicateCount == 0 ? JOptionPane.WARNING_MESSAGE : JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(l, msg.toString(), null, messageType);
}
if (genRes.getInsertedMessage() != null) {
sepaMsgElem.exportXML(l, Collections.singletonList(genRes.getInsertedMessage()));
}
}
}.execute();
}
}, false, true).setPredicate(IListeEvent.getNonEmptySelectionPredicate()));
// TODO remove once we have a join with {SENT, OK, DEFINITIVE_ERROR, TRANSIENT_ERROR}
this.listeFact.getListe().addIListeAction(new RowAction.PredicateRowAction(new AbstractAction("Prélever à nouveau", null) {
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
if (JOptionPane.showConfirmDialog(l, "Voulez-vous vraiment prélever à nouveau les factures sélectionnées ? Cette action est définitive.", "Prélever à nouveau",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION)
return;
final List<Integer> selectedIDs = l.getSelection().getSelectedIDs();
final UpdateBuilder upd = new UpdateBuilder(l.getSource().getPrimaryTable());
upd.setObject(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, upd.getTable().getForeignTable(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME).getUndefinedIDNumber());
upd.setObject(SaisieVenteFactureSQLElement.END2END_FIELD_NAME, "");
// don't allow to debit already payed invoices
upd.setWhere(new Where(upd.getTable().getKey(), selectedIDs).and(Where.isNull(upd.getTable().getField("DATE_REGLEMENT"))));
 
upd.getTable().getDBSystemRoot().getDataSource().execute(upd.asString());
for (final Integer id : selectedIDs)
upd.getTable().fireTableModified(id, upd.getFieldsNames());
}
}, false, true).setPredicate(IListeEvent.getNonEmptySelectionPredicate()));
this.listeFact.setOpaque(false);
this.listeFact.getListe().setModificationAllowed(true);
final JTable tableFact = this.listeFact.getListe().getJTable();
316,7 → 233,7
 
{
// Tab Vente caisse
ListeViewPanel panelTicket = new ListeViewPanel(Configuration.getInstance().getDirectory().getElement("TICKET_CAISSE")) {
ListeViewPanel panelTicket = new ListeViewPanel(dir.getElement("TICKET_CAISSE")) {
@Override
protected void handleAction(JButton source, ActionEvent evt) {
if (source == this.buttonModifier) {
365,7 → 282,7
}
// Tab Vente comptoir
{
final ListeGestCommEltPanel listeVC = new ListeGestCommEltPanel(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_COMPTOIR"), true);
final ListeGestCommEltPanel listeVC = new ListeGestCommEltPanel(dir.getElement("SAISIE_VENTE_COMPTOIR"), true);
listeVC.getListe().setModificationAllowed(false);
listeVC.setOpaque(false);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/component/SaisieVenteFactureSQLComponent.java
935,6 → 935,7
ModeDeReglementSQLComponent modeReglComp;
 
modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild();
modeReglComp.addDateCompListener(this.dateSaisie);
this.selAvoir.getRequest().setWhere(new Where(this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE));
this.selAvoir.fillCombo();
 
1946,12 → 1947,13
 
// FIXME listener pour le module project à déplacer dans le module quand l'interface passera
// en group
if (getTable().contains("ID_AFFAIRE")) {
if (getTable().contains("ID_AFFAIRE") && getView("ID_AFFAIRE") != null && getView("ID_AFFAIRE") instanceof SQLRequestComboBox) {
 
final SQLRequestComboBox viewClient = (SQLRequestComboBox) getView("ID_CLIENT").getComp();
final SQLRequestComboBox viewAffaire = (SQLRequestComboBox) getView("ID_AFFAIRE").getComp();
final SQLRequestComboBox viewComm = (SQLRequestComboBox) getView("ID_COMMERCIAL").getComp();
final SQLRequestComboBox viewAgence;
if (getTable().contains("ID_POLE_PRODUIT")) {
if (getTable().contains("ID_POLE_PRODUIT") && (SQLRequestComboBox) getView("ID_POLE_PRODUIT") != null) {
viewAgence = (SQLRequestComboBox) getView("ID_POLE_PRODUIT").getComp();
} else {
viewAgence = null;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/SaisieVenteFactureItemSQLElement.java
164,23 → 164,23
*
* @see org.openconcerto.devis.BaseSQLElement#getListFields()
*/
@Override
protected List<String> getListFields() {
List<String> l = new ArrayList<String>();
l.add("ID_SAISIE_VENTE_FACTURE");
 
l.add("CODE");
l.add("NOM");
l.add("DESCRIPTIF");
String articleAdvanced = DefaultNXProps.getInstance().getStringProperty("ArticleModeVenteAvance");
Boolean bArticleAdvanced = Boolean.valueOf(articleAdvanced);
if (bArticleAdvanced) {
l.add("PRIX_METRIQUE_VT_1");
l.add("ID_MODE_VENTE_ARTICLE");
}
if (UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) {
l.add("PA_HT");
}
l.add("PV_HT");
l.add("CODE");
l.add("NOM");
l.add("DESCRIPTIF");
String articleAdvanced = DefaultNXProps.getInstance().getStringProperty("ArticleModeVenteAvance");
Boolean bArticleAdvanced = Boolean.valueOf(articleAdvanced);
if (bArticleAdvanced) {
l.add("PRIX_METRIQUE_VT_1");
l.add("ID_MODE_VENTE_ARTICLE");
}
if (UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) {
l.add("PA_HT");
}
l.add("PV_HT");
l.add("QTE");
if (getTable().contains("ID_ECO_CONTRIBUTION")) {
l.add("ID_ECO_CONTRIBUTION");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/EcheanceClientSQLElement.java
14,6 → 14,7
package org.openconcerto.erp.core.sales.invoice.element;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
51,6 → 52,7
import org.openconcerto.sql.utils.SQLUtils;
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.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
447,7 → 449,7
@Override
protected void _initListRequest(ListSQLRequest req) {
super._initListRequest(req);
req.addToGraphToFetch("REG_COMPTA", "REGLE");
req.addToGraphToFetch("REG_COMPTA", "REGLE","NOMBRE_RELANCE");
}
 
/*
538,4 → 540,63
return createCodeOfPackage() + ".commitment";
}
 
public void relanceClient(final SQLRow rowEch) {
final SQLElement relanceElt = getDirectory().getElement("RELANCE");
 
rowEch.fetchValues();
 
if (rowEch != null) {
int idMvtSource = MouvementSQLElement.getSourceId(rowEch.getForeignID("ID_MOUVEMENT"));
SQLRow rowMvtSource = getTable().getTable("MOUVEMENT").getRow(idMvtSource);
 
if (!rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
return;
}
 
EditFrame editRelance = new EditFrame(relanceElt);
editRelance.setIconImages(Gestion.getFrameIcon());
editRelance.addEditPanelListener(new EditPanelListener() {
 
public void cancelled() {
// rien
}
 
public void modified() {
// rien
}
 
public void deleted() {
// rien
}
 
public void inserted(int id) {
int nbRelance = rowEch.getInt("NOMBRE_RELANCE");
nbRelance++;
 
SQLRowValues rowValsEch = new SQLRowValues(rowEch.getTable());
rowValsEch.put("NOMBRE_RELANCE", nbRelance);
rowValsEch.put("DATE_LAST_RELANCE", new Date());
 
try {
rowValsEch.update(rowEch.getID());
relanceElt.getTable().getRow(id).createEmptyUpdateRow().put("ID_ECHEANCE_CLIENT", rowEch.getID()).commit();
} catch (SQLException e1) {
ExceptionHandler.handle("erreur lors de la mise à jour du nombre de relances", e1);
}
}
});
 
SQLRowValues rowVals = new SQLRowValues(relanceElt.getTable());
rowVals.put("ID_SAISIE_VENTE_FACTURE", rowMvtSource.getInt("IDSOURCE"));
rowVals.put("MONTANT", rowEch.getObject("MONTANT"));
rowVals.put("ID_CLIENT", rowEch.getForeignID("ID_CLIENT"));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(RelanceSQLElement.class, new Date()));
editRelance.getSQLComponent().select(rowVals);
 
editRelance.pack();
editRelance.setVisible(true);
}
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisSQLElement.java
677,16 → 677,19
@Override
protected Object show_(SQLRowAccessor r) {
 
SQLRowAccessor rowAd;
SQLRowAccessor rowAd = null;
if (!r.isForeignEmpty("ID_ADRESSE_LIVRAISON")) {
rowAd = r.getForeign("ID_ADRESSE_LIVRAISON");
} else if (r.getForeign("ID_CLIENT").getObject("ID_ADRESSE_L") != null && !r.getForeign("ID_CLIENT").isForeignEmpty("ID_ADRESSE_L")) {
rowAd = r.getForeign("ID_CLIENT").getForeign("ID_ADRESSE_L");
} else {
rowAd = r.getForeign("ID_CLIENT").getForeign("ID_ADRESSE");
} else if (!r.isForeignEmpty("ID_CLIENT")) {
if (r.getForeign("ID_CLIENT").getObject("ID_ADRESSE_L") != null && !r.getForeign("ID_CLIENT").isForeignEmpty("ID_ADRESSE_L")) {
 
rowAd = r.getForeign("ID_CLIENT").getForeign("ID_ADRESSE_L");
} else {
rowAd = r.getForeign("ID_CLIENT").getForeign("ID_ADRESSE");
}
}
 
String lib = rowAd.getString("LIBELLE") + " " + rowAd.getString("VILLE");
String lib = rowAd == null ? "" : rowAd.getString("LIBELLE") + " " + rowAd.getString("VILLE");
 
return lib;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductHelper.java
25,6 → 25,7
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.ITransformer;
 
import java.math.BigDecimal;
452,6 → 453,46
 
}
 
public Tuple2<BigDecimal, BigDecimal> getStandardBomPrices(Collection<? extends SQLRowAccessor> rowValuesProductItems) {
final Map<Long, Integer> productQties = new HashMap<Long, Integer>();
for (SQLRowAccessor v : rowValuesProductItems) {
if (v.getObject("ID_ARTICLE") != null) {
System.out.println("id:" + v.getObject("ID_ARTICLE"));
int id = v.getForeignID("ID_ARTICLE");
int qte = v.getInt("QTE");
Integer qteForId = productQties.get(Long.valueOf(id));
if (qteForId == null) {
productQties.put(Long.valueOf(id), qte);
} else {
productQties.put(Long.valueOf(id), qte + qteForId);
}
}
}
BigDecimal costPV = null;
BigDecimal costPA = null;
 
for (SQLRowAccessor v : rowValuesProductItems) {
if (v.getObject("ID_ARTICLE") != null) {
SQLRowAccessor rowChild = v.getForeign("ID_ARTICLE");
int qte = v.getInt("QTE");
BigDecimal unitCostPV = rowChild.getBigDecimal("PV_HT");
BigDecimal unitCostPA = rowChild.getBigDecimal("PA_HT");
BigDecimal lineCostPV = unitCostPV.multiply(BigDecimal.valueOf(qte)).multiply(v.getBigDecimal("QTE_UNITAIRE"));
if (costPV == null) {
costPV = BigDecimal.ZERO;
}
costPV = costPV.add(lineCostPV);
BigDecimal lineCostPA = unitCostPA.multiply(BigDecimal.valueOf(qte)).multiply(v.getBigDecimal("QTE_UNITAIRE"));
if (costPA == null) {
costPA = BigDecimal.ZERO;
}
costPA = costPA.add(lineCostPA);
}
}
return Tuple2.create(costPA, costPV);
 
}
 
public BigDecimal getUnitCost(int id, int qty, TypePrice type) {
Map<Long, Integer> productQties = new HashMap<Long, Integer>();
productQties.put(Long.valueOf(id), Integer.valueOf(qty));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ReferenceArticleSQLComponent.java
23,6 → 23,7
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.SupplierPriceListTable;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.sales.product.model.ProductHelper;
import org.openconcerto.erp.core.sales.product.ui.ArticleCategorieComptableTable;
import org.openconcerto.erp.core.sales.product.ui.ArticleDesignationTable;
import org.openconcerto.erp.core.sales.product.ui.ArticleTarifTable;
29,9 → 30,7
import org.openconcerto.erp.core.sales.product.ui.ProductItemListTable;
import org.openconcerto.erp.core.sales.product.ui.ProductQtyPriceListTable;
import org.openconcerto.erp.core.sales.product.ui.RowValuesTableEditionPanel;
import org.openconcerto.erp.core.supplychain.stock.element.ComposedItemStockUpdater;
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
import org.openconcerto.erp.model.ISQLCompteSelector;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
50,6 → 49,7
import org.openconcerto.sql.sqlobject.SQLTextCombo;
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;
56,6 → 56,7
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.Component;
69,7 → 70,6
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
84,6 → 84,8
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
public class ReferenceArticleSQLComponent extends BaseSQLComponent {
 
466,6 → 468,7
selectModeVente(ReferenceArticleSQLComponent.this.comboSelModeVente.getSelectedId());
 
}
 
};
setListenerModeVenteActive(true);
this.comboSelModeVente.setValue(ReferenceArticleSQLElement.A_LA_PIECE);
498,9 → 501,31
panel.add(textTare, c);
addView(textTare, "TARE");
 
c.gridy++;
c.gridx = 0;
c.weightx = 0;
JLabel labelDLC = new JLabel(getLabelFor("DLC"));
panel.add(labelDLC, c);
c.weightx = 1;
c.gridx++;
JDate dateDLC = new JDate();
panel.add(dateDLC, c);
addView(dateDLC, "DLC");
 
c.weightx = 0;
c.gridy++;
c.gridx = 0;
if (getTable().contains("POIDS_COLIS_NET")) {
JLabel labelPdsColis = new JLabel(getLabelFor("POIDS_COLIS_NET"));
panel.add(labelPdsColis, c);
c.weightx = 1;
c.gridx++;
JTextField textPdsColis = new JTextField(40);
panel.add(textPdsColis, c);
addView(textPdsColis, "POIDS_COLIS_NET");
c.gridx++;
}
 
JLabel labelMasque = new JLabel(getLabelFor("MASQUE_CAISSE"));
c.fill = GridBagConstraints.BOTH;
panel.add(labelMasque, c);
589,6 → 614,42
panel.add(fieldColoris, c);
this.addView(fieldColoris, "COLORIS");
}
JTextField fieldLongueur = new JTextField();
c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0;
c.gridwidth = 1;
panel.add(new JLabel(getLabelFor("LONGUEUR")), c);
 
c.weightx = 1;
c.gridx++;
panel.add(fieldLongueur, c);
this.addView(fieldLongueur, "LONGUEUR");
 
JTextField fieldLargeur = new JTextField();
c.gridx++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0;
c.gridwidth = 1;
panel.add(new JLabel(getLabelFor("LARGEUR")), c);
c.weightx = 1;
c.gridx++;
panel.add(fieldLargeur, c);
this.addView(fieldLargeur, "LARGEUR");
 
JTextField fieldHauteur = new JTextField();
c.gridy++;
c.gridx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0;
c.gridwidth = 1;
panel.add(new JLabel(getLabelFor("HAUTEUR")), c);
 
c.weightx = 1;
c.gridx++;
panel.add(fieldHauteur, c);
this.addView(fieldHauteur, "HAUTEUR");
 
ITextArea area = new ITextArea();
JLabel sep = new JLabel("Descriptif complet");
c.gridy++;
836,12 → 897,96
SQLPreferences prefs = new SQLPreferences(ComptaPropsConfiguration.getInstanceCompta().getRootSociete());
final boolean supplierCode = prefs.getBoolean(GestionArticleGlobalPreferencePanel.SUPPLIER_PRODUCT_CODE, false);
 
// Tarif fournisseur
c.gridy++;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
TitledSeparator sep = new TitledSeparator("Tarifs fournisseurs");
panel.add(sep, c);
 
// Ajout fournisseur
c.gridwidth = 1;
c.weightx = 0;
c.gridy++;
c.gridx = 0;
panel.add(new JLabel("Ajouter le fournisseur "), c);
 
final ElementComboBox boxF = new ElementComboBox();
boxF.init(Configuration.getInstance().getDirectory().getElement("FOURNISSEUR"));
 
c.gridx++;
panel.add(boxF, c);
 
c.fill = GridBagConstraints.NONE;
c.gridx++;
JButton buttonAjouter = new JButton("Ajouter");
buttonAjouter.setOpaque(false);
panel.add(buttonAjouter, c);
c.gridx++;
JButton buttonSupprimer = new JButton("Supprimer");
buttonSupprimer.setOpaque(false);
panel.add(buttonSupprimer, c);
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
c.gridy++;
c.gridx = 0;
c.fill = GridBagConstraints.BOTH;
this.tableFourSec.setOpaque(false);
panel.add(this.tableFourSec, c);
 
// Listeners
buttonAjouter.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
 
SQLRow rowCat = boxF.getSelectedRow();
if (rowCat == null || rowCat.isUndefined()) {
return;
}
int nbRows = tableFourSec.getModel().getRowCount();
 
// for (int i = 0; i < nbRows; i++) {
// SQLRowValues rowVals = tableFourSec.getModel().getRowValuesAt(i);
// int idTarif =
// Integer.parseInt(rowVals.getObject("ID_FOURNISSEUR").toString());
// if (idTarif == rowCat.getID()) {
// JOptionPane.showMessageDialog(null, "Impossible d'ajouter.\nLe fournisseur
// est déjà présent dans la liste!");
// return;
// }
// }
 
SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_TARIF_FOURNISSEUR"));
if (getSelectedID() > 1) {
rowVals.put("ID_ARTICLE", getSelectedID());
}
rowVals.put("ID_FOURNISSEUR", rowCat.getID());
tableFourSec.getModel().addRow(rowVals);
}
});
buttonSupprimer.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
tableFourSec.removeSelectedRow();
}
});
if (getTable().getSchema().contains("CODE_FOURNISSEUR") && supplierCode) {
c.gridy++;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
TitledSeparator sepC = new TitledSeparator("Codes fournisseurs");
panel.add(sepC, c);
 
this.rowValuesDefaultCodeFournisseur = new SQLRowValues(getTable().getTable("CODE_FOURNISSEUR"));
this.codeFournisseurTable = new CodeFournisseurItemTable(this.rowValuesDefaultCodeFournisseur);
c.gridy++;
c.gridx = 0;
c.gridwidth = 3;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weighty = 1;
c.weightx = 1;
c.fill = GridBagConstraints.BOTH;
853,88 → 998,9
rowValuesDefaultCodeFournisseur.put("ID_FOURNISSEUR", comboSelFournisseur.getSelectedId());
}
});
} else {
 
// Tarif fournisseur
c.gridy++;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
TitledSeparator sep = new TitledSeparator("Tarifs fournisseurs");
panel.add(sep, c);
 
// Ajout fournisseur
c.gridwidth = 1;
c.weightx = 0;
c.gridy++;
c.gridx = 0;
panel.add(new JLabel("Ajouter le fournisseur "), c);
 
final ElementComboBox boxF = new ElementComboBox();
boxF.init(Configuration.getInstance().getDirectory().getElement("FOURNISSEUR"));
 
c.gridx++;
panel.add(boxF, c);
 
c.fill = GridBagConstraints.NONE;
c.gridx++;
JButton buttonAjouter = new JButton("Ajouter");
buttonAjouter.setOpaque(false);
panel.add(buttonAjouter, c);
c.gridx++;
JButton buttonSupprimer = new JButton("Supprimer");
buttonSupprimer.setOpaque(false);
panel.add(buttonSupprimer, c);
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
c.gridy++;
c.gridx = 0;
c.fill = GridBagConstraints.BOTH;
this.tableFourSec.setOpaque(false);
panel.add(this.tableFourSec, c);
 
// Listeners
buttonAjouter.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
 
SQLRow rowCat = boxF.getSelectedRow();
if (rowCat == null || rowCat.isUndefined()) {
return;
}
int nbRows = tableFourSec.getModel().getRowCount();
 
// for (int i = 0; i < nbRows; i++) {
// SQLRowValues rowVals = tableFourSec.getModel().getRowValuesAt(i);
// int idTarif =
// Integer.parseInt(rowVals.getObject("ID_FOURNISSEUR").toString());
// if (idTarif == rowCat.getID()) {
// JOptionPane.showMessageDialog(null, "Impossible d'ajouter.\nLe fournisseur
// est déjà présent dans la liste!");
// return;
// }
// }
 
SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_TARIF_FOURNISSEUR"));
if (getSelectedID() > 1) {
rowVals.put("ID_ARTICLE", getSelectedID());
}
rowVals.put("ID_FOURNISSEUR", rowCat.getID());
tableFourSec.getModel().addRow(rowVals);
}
});
buttonSupprimer.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
tableFourSec.removeSelectedRow();
}
});
}
return panel;
 
}
 
private JPanel createExportationPanel() {
1143,17 → 1209,68
panel.setOpaque(false);
GridBagConstraints c = new DefaultGridBagConstraints();
 
final JCheckBox checkAutoPrice = new JCheckBox(getLabelFor("AUTO_PRIX_MIN_VENTE_NOMENCLATURE"));
panel.add(checkAutoPrice, c);
this.addView(checkAutoPrice, "AUTO_PRIX_MIN_VENTE_NOMENCLATURE");
c.gridx++;
final JCheckBox checkAutoPriceHA = new JCheckBox(getLabelFor("AUTO_PRIX_ACHAT_NOMENCLATURE"));
panel.add(checkAutoPriceHA, c);
this.addView(checkAutoPriceHA, "AUTO_PRIX_ACHAT_NOMENCLATURE");
 
checkAutoPrice.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
updatePricesNomenclature(checkAutoPrice, checkAutoPriceHA);
}
});
checkAutoPriceHA.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
updatePricesNomenclature(checkAutoPrice, checkAutoPriceHA);
}
});
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
this.tableBom.setOpaque(false);
panel.add(new RowValuesTableEditionPanel(this.tableBom), c);
 
this.tableBom.getModel().addTableModelListener(new TableModelListener() {
 
@Override
public void tableChanged(TableModelEvent e) {
updatePricesNomenclature(checkAutoPrice, checkAutoPriceHA);
 
}
 
});
return panel;
 
}
 
private void updatePricesNomenclature(final JCheckBox checkAutoPrice, final JCheckBox checkAutoPriceHA) {
final Boolean vtAuto = checkAutoPrice.isSelected();
final Boolean haAuto = checkAutoPriceHA.isSelected();
if (vtAuto || haAuto) {
ProductHelper helper = new ProductHelper(getTable().getDBRoot());
 
Tuple2<BigDecimal, BigDecimal> p = helper.getStandardBomPrices(tableBom.getRowValuesTable().getRowValuesTableModel().getCopyOfValues());
if (haAuto && p.get0() != null) {
textPAHT.setText(p.get0().toString());
}
if (vtAuto && p.get1() != null) {
textPVHT.setText(p.get1().toString());
}
}
}
 
private JPanel createTarifQtePanel() {
JPanel panel = new JPanel(new GridBagLayout());
panel.setOpaque(false);
1563,27 → 1680,28
@Override
public void update() {
SQLRow row = this.getTable().getRow(this.getSelectedID());
final int selectedID = getSelectedID();
super.update();
this.tableTarifVente.updateField("ID_ARTICLE", getSelectedID());
this.tableCatComptable.updateField("ID_ARTICLE", getSelectedID());
this.tableFourSec.updateField("ID_ARTICLE", getSelectedID());
this.tableTarifQteVente.updateField("ID_ARTICLE", getSelectedID());
this.tableTarifVente.updateField("ID_ARTICLE", selectedID);
this.tableCatComptable.updateField("ID_ARTICLE", selectedID);
this.tableFourSec.updateField("ID_ARTICLE", selectedID);
this.tableTarifQteVente.updateField("ID_ARTICLE", selectedID);
if (this.tableBom != null) {
this.tableBom.updateField("ID_ARTICLE_PARENT", getSelectedID());
this.tableBom.updateField("ID_ARTICLE_PARENT", selectedID);
}
 
this.tableDes.updateField("ID_ARTICLE", getSelectedID());
this.tableCodeClient.updateField("ID_ARTICLE", getSelectedID());
this.tableDes.updateField("ID_ARTICLE", selectedID);
this.tableCodeClient.updateField("ID_ARTICLE", selectedID);
if (this.codeFournisseurTable != null) {
this.codeFournisseurTable.updateField("ID_ARTICLE", getSelectedID());
this.codeFournisseurTable.updateField("ID_ARTICLE", selectedID);
}
 
((ReferenceArticleSQLElement) getElement()).initStock(getSelectedID());
((ReferenceArticleSQLElement) getElement()).initStock(selectedID);
 
SQLSelect sel = new SQLSelect();
SQLTable tableStock = getTable().getTable("STOCK");
sel.addSelect(tableStock.getKey());
Where w = new Where(tableStock.getField("ID_ARTICLE"), "=", getSelectedID()).and(new Where(tableStock.getField("ID_DEPOT_STOCK"), "=", row.getForeignID("ID_DEPOT_STOCK")));
Where w = new Where(tableStock.getField("ID_ARTICLE"), "=", selectedID).and(new Where(tableStock.getField("ID_DEPOT_STOCK"), "=", row.getForeignID("ID_DEPOT_STOCK")));
sel.setWhere(w);
 
List<SQLRow> stock = SQLRowListRSH.execute(sel);
1595,6 → 1713,54
}
}
 
Runnable r = new Runnable() {
@Override
public void run() {
SQLRow rowArticle = getTable().getRow(selectedID);
List<SQLRow> itemsRows = rowArticle.getReferentRows(getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE"));
for (SQLRow rowArticleItem : itemsRows) {
SQLRow rowA = rowArticleItem.getForeign("ID_ARTICLE_PARENT");
 
if (rowA != null && !rowA.isUndefined()) {
final Boolean vtAuto = rowA.getBoolean("AUTO_PRIX_MIN_VENTE_NOMENCLATURE");
final Boolean haAuto = rowA.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE");
if (vtAuto || haAuto) {
ProductHelper helper = new ProductHelper(rowA.getTable().getDBRoot());
Tuple2<BigDecimal, BigDecimal> p = helper.getStandardBomPrices(rowA.getReferentRows(rowA.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT")));
SQLRowValues rowVals = rowA.createEmptyUpdateRow();
boolean up = false;
if (vtAuto && p.get1() != null) {
rowVals.put("PRIX_METRIQUE_VT_1", p.get1());
rowVals.put("PV_HT", p.get1());
float t = TaxeCache.getCache().getFirstTaxe().getFloat("TAUX");
if (!rowA.isForeignEmpty("ID_TAXE")) {
t = TaxeCache.getCache().getTauxFromId(rowA.getForeignID("ID_TAXE"));
}
 
rowVals.put("PV_TTC", p.get1().multiply(new BigDecimal(t).movePointLeft(2).add(BigDecimal.ONE)).setScale(2, RoundingMode.HALF_UP));
up = true;
}
if (haAuto && p.get0() != null) {
rowVals.put("PRIX_METRIQUE_HA_1", p.get0());
rowVals.put("PA_HT", p.get0());
up = true;
}
if (up) {
try {
rowVals.commit();
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors de la mise à jour des tarifs des nomenclatures", e);
}
}
}
}
}
 
}
};
new Thread(r).run();
ReferenceArticleSQLElement.updateDateAchat(getTable(), getTable().getRow(selectedID));
 
}
 
/**
1661,6 → 1827,7
this.codeFournisseurTable.updateField("ID_ARTICLE", id);
}
((ReferenceArticleSQLElement) getElement()).initStock(id);
ReferenceArticleSQLElement.updateDateAchat(getTable(), getTable().getRow(id));
return id;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReferenceArticleSQLElement.java
59,9 → 59,7
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.AbstractAction;
216,6 → 214,7
l.add("PV_TTC");
l.add("ID_FAMILLE_ARTICLE");
l.add("ID_FOURNISSEUR");
l.add("POIDS");
l.add("SKU");
 
// if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false)) {
250,6 → 249,9
}
 
l.add("NOM");
l.add("PA_HT");
l.add("PV_HT");
l.add("DERNIER_DATE_ACHAT");
return l;
}
 
541,4 → 543,20
// req.addForeignToGraphToFetch("ID_DEPOT_STOCK", Arrays.asList("ID"));
}
 
static public void updateDateAchat(final SQLTable tableArticle, final SQLRow article) {
 
assert article == null || article.getTable() == tableArticle;
SQLTable tableTarifF = tableArticle.getTable("ARTICLE_TARIF_FOURNISSEUR");
String up = "UPDATE " + tableArticle.getSQLName().quote() + " a SET " + tableArticle.getField("DERNIER_DATE_ACHAT").getQuotedName();
up += " =(select MAX(" + tableTarifF.getField("DATE_PRIX").getQuotedName() + ") ";
up += " FROM " + tableTarifF.getSQLName().quote() + " t" + " WHERE (t." + tableTarifF.getKey().getQuotedName() + " <> 1) ";
up += " AND (t." + tableTarifF.getField("ARCHIVE").getQuotedName() + " = 0) ";
up += "AND t." + tableTarifF.getField("ID_ARTICLE").getQuotedName() + " = " + (article == null ? "a." + tableArticle.getKey().getQuotedName() : article.getID()) + ")";
if (article != null) {
up += "WHERE " + tableArticle.getKey().getQuotedName() + " = " + article.getID();
}
 
tableArticle.getDBSystemRoot().getDataSource().execute(up);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/UniteVenteArticleSQLElement.java
30,6 → 30,7
public class UniteVenteArticleSQLElement extends ComptaSQLConfElement {
 
public static final int A_LA_PIECE = 2;
public static final int M2 = 4;
 
public UniteVenteArticleSQLElement() {
super("UNITE_VENTE", "une unité de vente", "unité de vente");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/TransfertStockPanel.java
214,7 → 214,6
public void actionPerformed(ActionEvent e) {
 
buttonUpdate.setEnabled(false);
defaultLabel = label.getText();
BigDecimal qteReel = fieldReel.getValue();
 
List<String> multipleRequestsHundred = new ArrayList<String>(100);
224,9 → 223,10
 
final SQLRow selectedRowArticle = comboArticle.getSelectedRow();
 
final SQLRow selectedRowDepotDepart = comboStockDepart.getSelectedRow();
final SQLRow selectedRowDepotArrivee = comboStockArrive.getSelectedRow();
{
// DEPART
final SQLRow selectedRowDepotDepart = comboStockDepart.getSelectedRow();
final SQLRowAccessor rowStockDepart = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotDepart);
StockItem item = new StockItem(selectedRowArticle, rowStockDepart);
if (!item.isStockInit()) {
245,16 → 245,15
stockItems.add(item);
double diff = -qteReel.doubleValue();
item.updateQty(diff, TypeStockMouvement.REEL);
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, label.getText(), 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, label.getText(), false, usePrice));
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice));
 
multipleRequestsHundred.add(item.getUpdateRequest());
}
// ARRIVEE
{
final SQLRow selectedRowDepotArrivee = comboStockArrive.getSelectedRow();
final SQLRowAccessor rowStockArrivee = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotArrivee);
 
StockItem item = new StockItem(selectedRowArticle, rowStockArrivee);
274,10 → 273,10
stockItems.add(item);
double diff = qteReel.doubleValue();
item.updateQty(diff, TypeStockMouvement.REEL);
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, label.getText(), 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, label.getText(), false, usePrice));
multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice));
 
multipleRequestsHundred.add(item.getUpdateRequest());
}
318,6 → 317,12
});
}
 
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 " + mvtStockTableQuoted + " (\"QTE\",\"DATE\",\"ID_ARTICLE\",\"ID_STOCK\",\"NOM\",\"REEL\",\"ORDRE\"";
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/GestionArticlePreferencePanel.java
16,8 → 16,10
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.VerticalLayout;
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
30,6 → 32,7
 
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
public class GestionArticlePreferencePanel extends DefaultPreferencePanel {
36,8 → 39,9
 
private final JCheckBox checkModeVente, checkLongueur, checkLargeur, checkPoids;
private final JCheckBox checkService, checkVenteComptoir, checkShowPoids, checkShowStyle, checkSFE;
private final JCheckBox checkMarge;
private final JCheckBox checkMarge;
private JCheckBox checkSite;
private SQLRequestComboBox boxDepot = new SQLRequestComboBox();
 
public GestionArticlePreferencePanel() {
super();
57,7 → 61,18
this.checkShowPoids = new JCheckBox("Voir le Poids");
this.checkMarge = new JCheckBox("Afficher le taux de marque au lieu du taux de marge");
 
final ComptaPropsConfiguration comptaPropsConfiguration = (ComptaPropsConfiguration) Configuration.getInstance();
final DepotStockSQLElement elementDepot = comptaPropsConfiguration.getDirectory().getElement(DepotStockSQLElement.class);
this.boxDepot.uiInit(elementDepot.createComboRequest());
 
 
this.add(new JLabel("Dépôt de stock par défaut"), c);
c.gridx++;
this.add(this.boxDepot, c);
c.gridx = 0;
c.gridy++;
 
c.gridwidth = 2;
this.add(this.checkMarge, c);
c.gridy++;
this.add(this.checkService, c);
107,6 → 122,11
}
props.setProperty("ArticleVenteComptoir", String.valueOf(this.checkVenteComptoir.isSelected()));
props.setProperty(TotalPanel.MARGE_MARQUE, String.valueOf(this.checkMarge.isSelected()));
int selId = DepotStockSQLElement.DEFAULT_ID;
if (!this.boxDepot.isEmpty() && !this.boxDepot.getSelectedRow().isUndefined()) {
selId = this.boxDepot.getSelectedId();
}
props.setProperty("DepotStockDefault", String.valueOf(selId));
props.store();
}
 
132,6 → 152,11
 
private void setValues() {
final DefaultProps props = DefaultNXProps.getInstance();
 
// depot
final int depot = props.getIntProperty("DepotStockDefault");
this.boxDepot.setValue(depot);
 
// service
final String service = props.getStringProperty("ArticleService");
final Boolean bService = Boolean.valueOf(service);
167,7 → 192,6
// Show Style
this.checkShowStyle.setSelected(props.getBooleanValue("ArticleShowStyle", false));
 
// Devise
this.checkMarge.setSelected(props.getBooleanValue(TotalPanel.MARGE_MARQUE, false));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/DeliveredQtyRowValuesRenderer.java
18,6 → 18,7
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.table.AlternateTableCellRenderer;
import org.openconcerto.ui.table.XTableColumnModel;
import org.openconcerto.utils.CollectionUtils;
 
import java.awt.Color;
64,26 → 65,31
if (table instanceof RowValuesTable) {
 
((JLabel) comp).setHorizontalAlignment(SwingConstants.RIGHT);
RowValuesTableModel model = ((RowValuesTable) table).getRowValuesTableModel();
SQLRowValues rowVals = model.getRowValuesAt(row);
RowValuesTable rowValuesTable = (RowValuesTable) table;
XTableColumnModel columnModel = rowValuesTable.getColumnModel();
RowValuesTableModel model = rowValuesTable.getRowValuesTableModel();
boolean qteALivrerVisible = columnModel.isColumnVisible(columnModel.getColumnByModelIndex(model.getColumnForField("QTE_A_LIVRER")));
if (qteALivrerVisible) {
SQLRowValues rowVals = model.getRowValuesAt(row);
 
Number qte;
Number qteL;
if (this.customer) {
qte = (Number) rowVals.getObject("QTE");
qteL = (Number) rowVals.getObject("QTE_LIVREE");
} else {
qte = (Number) rowVals.getObject("QTE_ORIGINE");
qteL = (Number) rowVals.getObject("QTE");
}
if (qte != null && qteL != null) {
if (qte.intValue() < qteL.intValue()) {
comp.setBackground(red);
} else if (qteL.intValue() <= 0) {
comp.setBackground(lightBlack);
} else if (qteL.intValue() != qte.intValue()) {
comp.setBackground(orange);
Number qte;
Number qteL;
if (this.customer) {
qte = (Number) rowVals.getObject("QTE");
qteL = (Number) rowVals.getObject("QTE_LIVREE");
} else {
qte = (Number) rowVals.getObject("QTE_ORIGINE");
qteL = (Number) rowVals.getObject("QTE");
}
if (qte != null && qteL != null) {
if (qte.intValue() < qteL.intValue()) {
comp.setBackground(red);
} else if (qteL.intValue() <= 0) {
comp.setBackground(lightBlack);
} else if (qteL.intValue() != qte.intValue()) {
comp.setBackground(orange);
}
}
}
}
return comp;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractArticleItemTable.java
372,6 → 372,7
 
BigDecimal prixUnitHT = BigDecimal.ZERO;
BigDecimal prixUnitHA = BigDecimal.ZERO;
BigDecimal prixUnitEco = BigDecimal.ZERO;
 
boolean update = false;
int indexToUpdate = index;
391,6 → 392,10
// Cumul des valeurs
prixUnitHT = prixUnitHT.add(rowVals.getBigDecimal("PV_HT").multiply(new BigDecimal(rowVals.getInt("QTE"))).multiply(rowVals.getBigDecimal("QTE_UNITAIRE")));
prixUnitHA = prixUnitHA.add(rowVals.getBigDecimal("PA_HT").multiply(new BigDecimal(rowVals.getInt("QTE"))).multiply(rowVals.getBigDecimal("QTE_UNITAIRE")));
BigDecimal eco = rowVals.getBigDecimal("ECO_CONTRIBUTION");
if (eco != null) {
prixUnitEco = prixUnitEco.add(eco.multiply(new BigDecimal(rowVals.getInt("QTE"))).multiply(rowVals.getBigDecimal("QTE_UNITAIRE")));
}
}
}
}
404,6 → 409,10
if (columnForFieldPVht1 >= 0) {
this.model.setValueAt(prixUnitHT, indexToUpdate, columnForFieldPVht1);
}
final int columnForFieldEco = this.model.getColumnForField("ECO_CONTRIBUTION");
if (columnForFieldEco >= 0) {
this.model.setValueAt(prixUnitEco, indexToUpdate, columnForFieldEco);
}
}
index = indexToUpdate - 1;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractVenteArticleItemTable.java
19,6 → 19,7
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
import org.openconcerto.erp.core.sales.pos.ui.BarcodeListener;
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
import org.openconcerto.erp.core.sales.product.model.ProductHelper;
import org.openconcerto.erp.core.sales.product.model.ProductHelper.TypePrice;
26,6 → 27,7
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteMultipleRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
import org.openconcerto.erp.importer.ArrayTableModel;
import org.openconcerto.erp.importer.DataImporter;
58,6 → 60,7
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.sql.view.list.SQLTextComboTableCellEditor;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.CompareUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.StringUtils;
136,7 → 139,7
protected SQLTableElement tableElementRemise;
 
public enum TypeCalcul {
CALCUL_FACTURABLE("MONTANT_FACTURABLE", "POURCENT_FACTURABLE"), CALCUL_REMISE("MONTANT_REMISE", "POURCENT_REMISE");
CALCUL_MONTANT_TOTAL("MONTANT_FACTURABLE", "POURCENT_FACTURABLE"), CALCUL_FACTURABLE("MONTANT_FACTURABLE", "POURCENT_FACTURABLE"), CALCUL_REMISE("MONTANT_REMISE", "POURCENT_REMISE");
 
String fieldMontant, fieldPourcent;
 
154,7 → 157,10
}
};
 
private Acompte acompteFacturer = null;
 
public void calculPourcentage(final Acompte a, final TypeCalcul type) {
this.acompteFacturer = a;
Runnable r = new Runnable() {
 
@Override
178,39 → 184,8
tableElement.fireModification(model.getRowValuesAt(i));
}
} else {
// FIXME repartition du montant sur chaque ligne
BigDecimal totalHT = BigDecimal.ZERO;
for (SQLRowValues rowVals : getRowValuesAtLevel(1)) {
int qte = rowVals.getInt("QTE");
BigDecimal qteU = rowVals.getBigDecimal("QTE_UNITAIRE");
BigDecimal pU = rowVals.getBigDecimal("PV_HT");
BigDecimal totalHT = getTotalHT(type);
 
BigDecimal totalLine = pU.multiply(qteU, DecimalUtils.HIGH_PRECISION).multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).setScale(2, RoundingMode.HALF_UP);
 
// BigDecimal lremise = (type == TypeCalcul.CALCUL_FACTURABLE ?
// rowVals.getBigDecimal("POURCENT_REMISE") : BigDecimal.ZERO);
//
// if (lremise.compareTo(BigDecimal.ZERO) > 0 &&
// lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
// totalLine =
// totalLine.multiply(BigDecimal.valueOf(100).subtract(lremise),
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
// }
if (type == TypeCalcul.CALCUL_FACTURABLE) {
if (rowVals.getTable().getFieldsName().contains("MONTANT_REMISE")) {
final BigDecimal acomptePercent = rowVals.getBigDecimal("POURCENT_REMISE");
final BigDecimal acompteMontant = rowVals.getBigDecimal("MONTANT_REMISE");
Remise remise = new Remise(acomptePercent, acompteMontant);
totalLine = remise.getResultFrom(totalLine);
}
}
totalHT = totalHT.add(totalLine);
}
 
// BigDecimal percent = (totalHT.signum() != 0 ?
// a.getMontant().divide(totalHT, DecimalUtils.HIGH_PRECISION) :
// BigDecimal.ZERO);
 
for (int i = 0; i < model.getRowCount(); i++) {
// Restrict to level 1
if (model.getRowValuesAt(i).getInt("NIVEAU") != 1) {
224,15 → 199,6
 
BigDecimal totalLine = pU.multiply(qteU, DecimalUtils.HIGH_PRECISION).multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).setScale(2, RoundingMode.HALF_UP);
 
// BigDecimal lremise = (type == TypeCalcul.CALCUL_FACTURABLE ?
// rowVals.getBigDecimal("POURCENT_REMISE") : BigDecimal.ZERO);
//
// if (lremise.compareTo(BigDecimal.ZERO) > 0 &&
// lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
// totalLine =
// totalLine.multiply(BigDecimal.valueOf(100).subtract(lremise),
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
// }
if (rowVals.getTable().getFieldsName().contains("MONTANT_REMISE")) {
final BigDecimal acomptePercent = rowVals.getBigDecimal("POURCENT_REMISE");
final BigDecimal acompteMontant = rowVals.getBigDecimal("MONTANT_REMISE");
248,6 → 214,7
}
model.fireTableDataChanged();
}
 
});
}
};
255,6 → 222,37
 
}
 
public BigDecimal getTotalHT(final TypeCalcul type) {
BigDecimal totalHT = BigDecimal.ZERO;
for (SQLRowValues rowVals : getRowValuesAtLevel(1)) {
int qte = rowVals.getInt("QTE");
BigDecimal qteU = rowVals.getBigDecimal("QTE_UNITAIRE");
BigDecimal pU = rowVals.getBigDecimal("PV_HT");
 
BigDecimal totalLine = pU.multiply(qteU, DecimalUtils.HIGH_PRECISION).multiply(new BigDecimal(qte), DecimalUtils.HIGH_PRECISION).setScale(2, RoundingMode.HALF_UP);
 
if (type == TypeCalcul.CALCUL_FACTURABLE || type == TypeCalcul.CALCUL_MONTANT_TOTAL) {
if (rowVals.getTable().getFieldsName().contains("MONTANT_REMISE")) {
final BigDecimal acomptePercent = rowVals.getBigDecimal("POURCENT_REMISE");
final BigDecimal acompteMontant = rowVals.getBigDecimal("MONTANT_REMISE");
Remise remise = new Remise(acomptePercent, acompteMontant);
totalLine = remise.getResultFrom(totalLine);
}
}
 
if (type == TypeCalcul.CALCUL_MONTANT_TOTAL) {
if (rowVals.getTable().getFieldsName().contains("POURCENT_FACTURABLE")) {
final BigDecimal acomptePercent = rowVals.getBigDecimal("POURCENT_FACTURABLE");
final BigDecimal acompteMontant = rowVals.getBigDecimal("MONTANT_FACTURABLE");
Acompte acompte = new Acompte(acomptePercent, acompteMontant);
totalLine = acompte.getResultFrom(totalLine);
}
}
totalHT = totalHT.add(totalLine);
}
return totalHT;
}
 
private static Map<String, Boolean> visibilityMap = new HashMap<String, Boolean>();
 
public static Map<String, Boolean> getVisibilityMap() {
268,6 → 266,7
 
SQLPreferences prefs = SQLPreferences.getMemCached(getSQLElement().getTable().getDBRoot());
final boolean selectArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.USE_CREATED_ARTICLE, false);
final boolean activeCalculM2 = prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVE_CALCUL_M2, false);
final boolean filterFamilleArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.FILTER_BY_FAMILY, false);
final boolean createAuto = prefs.getBoolean(GestionArticleGlobalPreferencePanel.CREATE_ARTICLE_AUTO, true);
final boolean showEco = prefs.getBoolean(AbstractVenteArticleItemTable.SHOW_ECO_CONTRIBUTION_COLUMNS, false);
481,8 → 480,29
list.add(this.tableElementEco);
}
 
// // Prix d'achat HT de la métrique 1
SQLTableElement eltLongueur = new SQLTableElement(e.getTable().getField("LONGUEUR")) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
 
int idUv = vals.getForeignID("ID_UNITE_VENTE");
return idUv == UniteVenteArticleSQLElement.M2;
}
};
list.add(eltLongueur);
 
SQLTableElement eltLargeur = new SQLTableElement(e.getTable().getField("LARGEUR")) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
 
int idUv = vals.getForeignID("ID_UNITE_VENTE");
return idUv == UniteVenteArticleSQLElement.M2;
}
};
list.add(eltLargeur);
 
SQLTableElement eltHauteur = new SQLTableElement(e.getTable().getField("HAUTEUR"));
list.add(eltHauteur);
 
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE_UNITAIRE"), BigDecimal.class) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
490,6 → 510,8
SQLRowAccessor row = vals.getForeign("ID_UNITE_VENTE");
if (row != null && !row.isUndefined() && row.getBoolean("A_LA_PIECE")) {
return false;
} else if (activeCalculM2 && row != null && !row.isUndefined() && row.getID() == UniteVenteArticleSQLElement.M2) {
return false;
} else {
return super.isCellEditable(vals, rowIndex, columnIndex);
}
600,8 → 622,17
list.add(this.tableElementPoidsTotal);
 
// Packaging
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
if (e.getTable().contains("POIDS_COLIS_NET") && prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
 
SQLTableElement tareColis = new SQLTableElement(e.getTable().getField("TARE"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(tareColis);
 
SQLTableElement poidsColis = new SQLTableElement(e.getTable().getField("POIDS_COLIS_NET"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
627,18 → 658,57
nbColis.addModificationListener(totalPoidsColis);
totalPoidsColis.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
final Object o2 = row.getObject("POIDS_COLIS_NET");
final BigDecimal pdsColis = row.getBigDecimal("POIDS_COLIS_NET");
final Object o3 = row.getObject("NB_COLIS");
if (o2 != null && o3 != null) {
BigDecimal poids = (BigDecimal) o2;
 
BigDecimal pdsColisTotal = BigDecimal.ZERO;
 
if (pdsColis != null && o3 != null) {
int nb = (Integer) o3;
return poids.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
} else {
return row.getObject("T_POIDS_COLIS_NET");
pdsColisTotal = pdsColis.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION);
}
return pdsColisTotal.setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
}
});
 
final SQLTableElement totalPoidsBrut = new SQLTableElement(e.getTable().getField("T_POIDS_BRUT"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(totalPoidsBrut);
 
tareColis.addModificationListener(totalPoidsBrut);
poidsColis.addModificationListener(totalPoidsBrut);
nbColis.addModificationListener(totalPoidsBrut);
this.tableElementPoidsTotal.addModificationListener(totalPoidsBrut);
totalPoidsBrut.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
final BigDecimal tare = row.getBigDecimal("TARE");
final int qte = row.getInt("QTE");
final BigDecimal pdsColis = row.getBigDecimal("POIDS_COLIS_NET");
final Object o3 = row.getObject("NB_COLIS");
 
BigDecimal pdsBrutTotal = BigDecimal.ZERO;
 
if (row.getObject("T_POIDS") != null) {
pdsBrutTotal = new BigDecimal(row.getFloat("T_POIDS"));
}
 
if (tare != null) {
pdsBrutTotal = pdsBrutTotal.add(tare.multiply(new BigDecimal(qte)));
}
 
if (pdsColis != null && o3 != null) {
int nb = (Integer) o3;
pdsBrutTotal = pdsBrutTotal.add(pdsColis.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION));
}
return pdsBrutTotal.setScale(totalPoidsBrut.getDecimalDigits(), RoundingMode.HALF_UP);
}
});
 
}
 
// Service
657,6 → 727,8
totalRenderer.setHideZeroValue(true);
this.totalHT.setRenderer(totalRenderer);
this.totalHT.setEditable(false);
this.totalHA = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
 
if (e.getTable().getFieldsName().contains("MONTANT_FACTURABLE")) {
// SQLTableElement tableElementAcompte = new
// SQLTableElement(e.getTable().getField("POURCENT_ACOMPTE"));
690,6 → 762,7
}
});
tableElementFacturable.addModificationListener(this.totalHT);
tableElementFacturable.addModificationListener(this.totalHA);
list.add(tableElementFacturable);
}
 
738,7 → 811,6
}
 
// Total HT
this.totalHA = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
this.totalHA.setRenderer(totalRenderer);
this.totalHA.setEditable(false);
list.add(this.totalHA);
856,6 → 928,12
defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
defaultRowVals.put("CODE", "");
defaultRowVals.put("NOM", "");
if (e.getTable().contains("ID_DEPOT_STOCK")) {
DefaultProps props = DefaultNXProps.getInstance();
Integer depotDefault = props.getIntProperty("DepotStockDefault", DepotStockSQLElement.DEFAULT_ID);
this.defaultRowVals.put("ID_DEPOT_STOCK", depotDefault);
}
 
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("ID_TAXE"), false, defaultRowVals) {
@Override
public void commitData() {
868,7 → 946,7
rowVals.put("PV_T_DEVISE", rowVals.getBigDecimal("PRIX_METRIQUE_VT_1").multiply(globalQty));
}
}
super.commitData();
super.commitData(true);
}
};
setModel(model);
876,6 → 954,11
this.table = new RowValuesTable(model, getConfigurationFile());
ToolTipManager.sharedInstance().unregisterComponent(this.table);
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
if (getSQLElement().getTable().getName().equals("COMMANDE_CLIENT_ELEMENT")) {
this.table.getClearCloneTableElement().add("QTE_LIVREE");
this.table.getClearCloneTableElement().add("LIVRE");
this.table.getClearCloneTableElement().add("LIVRE_FORCED");
}
 
this.table.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
925,6 → 1008,7
if (e.getTable().getFieldsName().contains("ID_ECO_CONTRIBUTION")) {
completionField.add("ID_ECO_CONTRIBUTION");
}
 
if (showDevise) {
completionField.add("CODE_DOUANIER");
completionField.add("ID_PAYS");
948,6 → 1032,9
completionField.add("PRIX_METRIQUE_VT_3");
completionField.add("SERVICE");
completionField.add("ID_FAMILLE_ARTICLE");
completionField.add("LONGUEUR");
completionField.add("LARGEUR");
completionField.add("HAUTEUR");
if (getSQLElement().getTable().getFieldsName().contains("DESCRIPTIF")) {
completionField.add("DESCRIPTIF");
}
959,6 → 1046,13
completionField.add("QTE_ACHAT");
}
 
if (getSQLElement().getTable().getFieldsName().contains("POIDS_COLIS_NET") && sqlTableArticle.getTable().getFieldsName().contains("POIDS_COLIS_NET")) {
completionField.add("POIDS_COLIS_NET");
}
if (getSQLElement().getTable().getFieldsName().contains("TARE") && sqlTableArticle.getTable().getFieldsName().contains("TARE")) {
completionField.add("TARE");
}
 
final AutoCompletionManager m = new AutoCompletionManager(tableElementCode, sqlTableArticle.getField("CODE"), this.table, this.table.getRowValuesTableModel()) {
 
@Override
1235,7 → 1329,7
 
BigDecimal fVT = (BigDecimal) row.getObject("PV_HT");
BigDecimal r = b.multiply(fVT.multiply(BigDecimal.valueOf(qte), DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION);
if (lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
if (lremise.compareTo(BigDecimal.ZERO) > 0) {
r = r.multiply(BigDecimal.valueOf(100).subtract(lremise), DecimalUtils.HIGH_PRECISION).movePointLeft(2);
}
 
1244,6 → 1338,16
final BigDecimal acompteMontantR = row.getBigDecimal("MONTANT_REMISE");
Remise remise = new Remise(acomptePercentR, acompteMontantR);
r = remise.getResultFrom(r);
// Si factrue d'avancement et remise =100% ou pv =0 alors on
// applique le
// ratio entre le montant facturer et le montant global
if (acompteMontant.signum() == 0 && (acomptePercentR != null && acomptePercentR.compareTo(BigDecimal.ONE.movePointRight(2)) == 0)) {
r = BigDecimal.ZERO;
BigDecimal totalHTGlobal = getTotalHT(TypeCalcul.CALCUL_FACTURABLE);
if (acompteFacturer != null && acompteFacturer.getMontant() != null && totalHTGlobal != null && totalHTGlobal.signum() != 0) {
rHA = rHA.multiply(acompteFacturer.getMontant().divide(totalHTGlobal, DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION);
}
}
}
if (r.signum() != 0) {
rHA = rHA.multiply(acompteMontant.divide(r, DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION);
1364,11 → 1468,20
 
});
uniteVente.addModificationListener(qteU);
eltLargeur.addModificationListener(qteU);
eltLongueur.addModificationListener(qteU);
qteU.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
SQLRowAccessor rowUnite = row.getForeign("ID_UNITE_VENTE");
if (rowUnite != null && !rowUnite.isUndefined() && rowUnite.getBoolean("A_LA_PIECE")) {
return BigDecimal.ONE;
} else if (activeCalculM2 && rowUnite != null && !rowUnite.isUndefined() && rowUnite.getID() == UniteVenteArticleSQLElement.M2) {
BigDecimal longueur = row.getBigDecimal("LONGUEUR");
BigDecimal largeur = row.getBigDecimal("LARGEUR");
if (longueur == null || largeur == null) {
return BigDecimal.ONE;
}
return longueur.multiply(largeur);
} else {
return row.getObject("QTE_UNITAIRE");
}
1497,6 → 1610,11
setColumnVisible(model.getColumnForField("T_ECO_CONTRIBUTION"), showEco);
}
 
// ACtivation calcul m2
setColumnVisible(model.getColumnForField("HAUTEUR"), false);
setColumnVisible(model.getColumnForField("LARGEUR"), activeCalculM2);
setColumnVisible(model.getColumnForField("LONGUEUR"), activeCalculM2);
 
// Gestion des unités de vente
final boolean gestionUV = prefs.getBoolean(GestionArticleGlobalPreferencePanel.UNITE_VENTE, true);
setColumnVisible(model.getColumnForField("QTE_UNITAIRE"), gestionUV);
1524,6 → 1642,9
 
setColumnVisible(model.getColumnForField("ID_DEPOT_STOCK"), prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false));
 
setColumnVisible(model.getColumnForField("T_POIDS_COLIS_NET"), false);
setColumnVisible(model.getColumnForField("T_POIDS_BRUT"), false);
 
for (String string : visibilityMap.keySet()) {
setColumnVisible(model.getColumnForField(string), visibilityMap.get(string));
}
1798,7 → 1919,7
super.setClient(rowClient, ask);
if (getRowClient() != null && !getRowClient().isUndefined()) {
this.cacheRemise = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_ARTICLE_CLIENT"));
if (ask && 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++) {
1830,8 → 1951,8
public void setTarif(SQLRowAccessor rowValuesTarif, boolean ask) {
if (rowValuesTarif == null || getTarif() == null || rowValuesTarif.getID() != getTarif().getID()) {
super.setTarif(rowValuesTarif, ask);
if (ask && getRowValuesTable().getRowCount() > 0
&& JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {
if (ask && getRowValuesTable().getRowCount() > 0 && (rowValuesTarif == null || getTarif() == null || rowValuesTarif.isUndefined()
|| JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION)) {
int nbRows = this.table.getRowCount();
for (int i = 0; i < nbRows; i++) {
SQLRowValues rowVals = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(i);
1865,7 → 1986,9
// }
 
SQLRowAccessor rowA = row.getForeign("ID_ARTICLE");
if (rowA != null && !rowA.isUndefined() && rowA.getTable().contains("AUTO_PRIX_MIN_VENTE_NOMENCLATURE") && rowA.getBoolean("AUTO_PRIX_MIN_VENTE_NOMENCLATURE")) {
 
if (rowA != null && !rowA.isUndefined() && rowA.getTable().getDBRoot().contains("ARTICLE_PRIX_PUBLIC") && rowA.getTable().contains("AUTO_PRIX_MIN_VENTE_NOMENCLATURE")
&& rowA.getBoolean("AUTO_PRIX_MIN_VENTE_NOMENCLATURE")) {
BigDecimal b = row.getBigDecimal("QTE_UNITAIRE");
int q = row.getInt("QTE");
BigDecimal qteTotal = b.multiply(new BigDecimal(q), DecimalUtils.HIGH_PRECISION);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculator.java
554,14 → 554,18
// TODO Optimiser les requetes
if (this.rowCatComptable != null && !this.rowCatComptable.isUndefined()) {
String suffix = (this.achat ? "_ACHAT" : "_VENTE");
if (!this.rowCatComptable.isForeignEmpty("ID_COMPTE_PCE" + suffix)) {
cptCatComptable = cacheForTableCompte.getRowFromId(this.rowCatComptable.getForeignID("ID_COMPTE_PCE" + suffix));
}
Collection<? extends SQLRowAccessor> rows = article.getReferentRows(this.compteTable.getTable("ARTICLE_CATEGORIE_COMPTABLE"));
for (SQLRowAccessor sqlRowAccessor : rows) {
if (sqlRowAccessor.getForeignID("ID_CATEGORIE_COMPTABLE") == this.rowCatComptable.getID()) {
cptCatComptable = cacheForTableCompte.getRowFromId(this.rowCatComptable.getForeignID("ID_COMPTE_PCE" + suffix));
if (!sqlRowAccessor.isForeignEmpty("ID_COMPTE_PCE" + suffix)) {
cptCatComptable = cacheForTableCompte.getRowFromId(sqlRowAccessor.getForeignID("ID_COMPTE_PCE" + suffix));
}
}
}
}
 
if (cptCatComptable == null) {
String suffix = (this.achat ? "_ACHAT" : "");
SQLRowAccessor compteArticle = cacheForTableCompte.getRowFromId(article.getForeignID("ID_COMPTE_PCE" + suffix));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractAchatArticleItemTable.java
23,6 → 23,8
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
import org.openconcerto.erp.core.sales.product.ui.DeliveredQtyRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
import org.openconcerto.sql.Configuration;
40,6 → 42,8
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.AutoCompletionManager;
import org.openconcerto.sql.view.list.CellDynamicModifier;
import org.openconcerto.sql.view.list.RowValuesTable;
46,6 → 50,7
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.Tuple3;
import org.openconcerto.utils.i18n.TranslationManager;
52,6 → 57,7
 
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.awt.event.KeyEvent;
70,6 → 76,7
import java.util.Vector;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
355,7 → 362,96
// Poids total
this.tableElementPoidsTotal = new SQLTableElement(e.getTable().getField("T_POIDS"), Float.class);
list.add(this.tableElementPoidsTotal);
// Packaging
if (e.getTable().contains("POIDS_COLIS_NET") && prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
 
SQLTableElement tareColis = new SQLTableElement(e.getTable().getField("TARE"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(tareColis);
 
SQLTableElement poidsColis = new SQLTableElement(e.getTable().getField("POIDS_COLIS_NET"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(poidsColis);
 
SQLTableElement nbColis = new SQLTableElement(e.getTable().getField("NB_COLIS"), Integer.class);
list.add(nbColis);
 
final SQLTableElement totalPoidsColis = new SQLTableElement(e.getTable().getField("T_POIDS_COLIS_NET"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(totalPoidsColis);
 
poidsColis.addModificationListener(totalPoidsColis);
nbColis.addModificationListener(totalPoidsColis);
totalPoidsColis.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
final BigDecimal pdsColis = row.getBigDecimal("POIDS_COLIS_NET");
final Object o3 = row.getObject("NB_COLIS");
 
BigDecimal pdsColisTotal = BigDecimal.ZERO;
 
if (pdsColis != null && o3 != null) {
int nb = (Integer) o3;
pdsColisTotal = pdsColis.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION);
}
return pdsColisTotal.setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
}
});
 
final SQLTableElement totalPoidsBrut = new SQLTableElement(e.getTable().getField("T_POIDS_BRUT"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(totalPoidsBrut);
 
tareColis.addModificationListener(totalPoidsBrut);
poidsColis.addModificationListener(totalPoidsBrut);
nbColis.addModificationListener(totalPoidsBrut);
this.tableElementPoidsTotal.addModificationListener(totalPoidsBrut);
totalPoidsBrut.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
final BigDecimal tare = row.getBigDecimal("TARE");
final int qte = row.getInt("QTE");
final BigDecimal pdsColis = row.getBigDecimal("POIDS_COLIS_NET");
final Object o3 = row.getObject("NB_COLIS");
 
BigDecimal pdsBrutTotal = BigDecimal.ZERO;
 
if (row.getObject("T_POIDS") != null) {
pdsBrutTotal = new BigDecimal(row.getFloat("T_POIDS"));
}
 
if (tare != null) {
pdsBrutTotal = pdsBrutTotal.add(tare.multiply(new BigDecimal(qte)));
}
 
if (pdsColis != null && o3 != null) {
int nb = (Integer) o3;
pdsBrutTotal = pdsBrutTotal.add(pdsColis.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION));
}
// return row.getObject("T_POIDS_COLIS_NET");
return pdsBrutTotal.setScale(totalPoidsBrut.getDecimalDigits(), RoundingMode.HALF_UP);
}
});
 
}
// Service
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean b = Boolean.valueOf(val);
401,7 → 497,7
list.add(this.tableElementTotalTTC);
 
this.defaultRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
this.defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
this.defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxeAchat().getID());
this.defaultRowVals.put("CODE", "");
this.defaultRowVals.put("NOM", "");
this.defaultRowVals.put("QTE", 1);
408,12 → 504,32
this.defaultRowVals.put("QTE_UNITAIRE", BigDecimal.ONE);
this.defaultRowVals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE);
this.defaultRowVals.put("ID_MODE_VENTE_ARTICLE", ReferenceArticleSQLElement.A_LA_PIECE);
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, this.defaultRowVals);
 
if (e.getTable().contains("ID_DEPOT_STOCK")) {
DefaultProps props = DefaultNXProps.getInstance();
Integer depotDefault = props.getIntProperty("DepotStockDefault", DepotStockSQLElement.DEFAULT_ID);
this.defaultRowVals.put("ID_DEPOT_STOCK", depotDefault);
}
 
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, this.defaultRowVals) {
@Override
public void commitData() {
super.commitData(true);
}
};
 
setModel(model);
 
this.table = new RowValuesTable(model, getConfigurationFile());
ToolTipManager.sharedInstance().unregisterComponent(this.table);
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
if (getSQLElement().getTable().getName().equals("COMMANDE_ELEMENT")) {
this.table.getClearCloneTableElement().add("QTE_RECUE");
this.table.getClearCloneTableElement().add("RECU");
this.table.getClearCloneTableElement().add("RECU_FORCED");
} else if (getSQLElement().getTable().getName().equals("BON_RECEPTION_ELEMENT")) {
this.table.getClearCloneTableElement().add("ID_COMMANDE_ELEMENT");
}
 
table.addMouseListener(new MouseAdapter() {
@Override
506,9 → 622,14
if (e.getTable().getFieldsName().contains("ID_FAMILLE_ARTICLE")) {
completionFields.add("ID_FAMILLE_ARTICLE");
}
 
this.m = new AutoCompletionManager(tableElementCode, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.CODE"), this.table,
this.table.getRowValuesTableModel()) {
final SQLTable sqlTableArticle = e.getTable().getTable("ARTICLE");
if (getSQLElement().getTable().getFieldsName().contains("POIDS_COLIS_NET") && sqlTableArticle.getTable().getFieldsName().contains("POIDS_COLIS_NET")) {
completionFields.add("POIDS_COLIS_NET");
}
if (getSQLElement().getTable().getFieldsName().contains("TARE") && sqlTableArticle.getTable().getFieldsName().contains("TARE")) {
completionFields.add("TARE");
}
this.m = new AutoCompletionManager(tableElementCode, sqlTableArticle.getField("CODE"), this.table, this.table.getRowValuesTableModel()) {
@Override
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
Object res = tarifCompletion(row, field);
521,10 → 642,12
};
m.fill("NOM", "NOM");
m.fill("ID", "ID_ARTICLE");
if (e.getTable().contains("ID_CODE_FOURNISSEUR") && supplierCode) {
m.fill("ID_CODE_FOURNISSEUR", "ID_CODE_FOURNISSEUR");
}
for (String string : completionFields) {
m.fill(string, string);
}
final SQLTable sqlTableArticle = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("ARTICLE");
final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
m.setWhere(w);
 
579,6 → 702,7
}
}
};
m4.fill("ID", "ID_ARTICLE");
m4.fill("CODE", "CODE");
m4.fill("NOM", "NOM");
for (String string : completionFields) {
727,10 → 851,12
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal f = (BigDecimal) row.getObject("PA_HT");
int idTaux = Integer.parseInt(row.getObject("ID_TAXE").toString());
if (idTaux < 0) {
System.out.println(row);
Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
if (resultTaux == null) {
SQLRow rowTax = TaxeCache.getCache().getFirstTaxe();
row.put("ID_TAXE", rowTax.getID());
resultTaux = rowTax.getFloat("TAUX");
}
Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
editorPAHT.setTaxe(resultTaux);
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION).setScale(tableElementTotalTTC.getDecimalDigits(),
779,6 → 905,9
 
setColumnVisible(model.getColumnForField("ID_DEPOT_STOCK"), prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false));
 
setColumnVisible(model.getColumnForField("T_POIDS_COLIS_NET"), false);
setColumnVisible(model.getColumnForField("T_POIDS_BRUT"), false);
 
// Calcul automatique du poids unitaire
tableElement_ValeurMetrique1.addModificationListener(tableElementPoids);
tableElement_ValeurMetrique2.addModificationListener(tableElementPoids);
916,6 → 1045,34
 
// On réécrit la configuration au cas ou les preferences aurait changé
this.table.writeState();
 
if (this.table.getRowValuesTableModel().getColumnForField("ID_DEPOT_STOCK") >= 0 && this.table.getRowValuesTableModel().getColumnForField("ID_ARTICLE") >= 0) {
if (this.buttons == null) {
this.buttons = new ArrayList<>();
}
 
JButton buttonStock = new JButton("Consulter le stock");
buttonStock.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
SQLRowValues rowValsSel = table.getSelectedRowValues();
if (rowValsSel != null) {
SQLRowAccessor foreignArt = rowValsSel.getForeign("ID_ARTICLE");
if (foreignArt != null && !foreignArt.isUndefined()) {
SQLRowAccessor rowValsStock = StockSQLElement.getStock(rowValsSel);
if (rowValsStock != null && !rowValsStock.isUndefined()) {
EditFrame frame = new EditFrame(table.getRowValuesTableModel().getSQLElement().getDirectory().getElement("STOCK"), EditMode.READONLY);
frame.selectionId(rowValsStock.getID());
frame.setVisible(true);
}
}
}
 
}
});
 
this.buttons.add(buttonStock);
 
}
}
 
private static Map<String, Boolean> visibilityMap = new HashMap<String, Boolean>();
963,6 → 1120,23
public Object tarifCompletion(SQLRow row, String field) {
final SQLTable tTarifFournisseur = this.getSQLElement().getTable().getDBRoot().getTable("ARTICLE_TARIF_FOURNISSEUR");
 
if (row != null && !row.isUndefined() && (field.equalsIgnoreCase("ID_CODE_FOURNISSEUR")) && this.rowFournisseur != null && !this.rowFournisseur.isUndefined()) {
final SQLTable foreignTableCodeF = getSQLElement().getTable().getForeignTable("ID_CODE_FOURNISSEUR");
List<SQLRow> resultCode = row.getReferentRows(foreignTableCodeF);
int idCode = foreignTableCodeF.getUndefinedID();
for (SQLRow sqlRow : resultCode) {
if (sqlRow.getForeignID("ID_FOURNISSEUR") == this.rowFournisseur.getID()) {
return sqlRow.getID();
}
 
}
return idCode;
}
if (field.equalsIgnoreCase("ID_CODE_FOURNISSEUR")) {
final SQLTable foreignTableCodeF = getSQLElement().getTable().getForeignTable("ID_CODE_FOURNISSEUR");
return foreignTableCodeF.getUndefinedID();
}
 
if (row != null && !row.isUndefined() && (field.equalsIgnoreCase("PRIX_METRIQUE_HA_1") || field.equalsIgnoreCase("PA_HT")) && tTarifFournisseur != null) {
List<String> incoTerms;
 
974,7 → 1148,7
incoTerms = Arrays.asList("PRIX_ACHAT");
}
List<SQLRow> rows = row.getReferentRows(tTarifFournisseur);
if (row.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE")) {
if (row.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE") && row.getTable().getDBRoot().contains("ARTICLE_PRIX_REVIENT")) {
 
List<SQLRow> rowsElt = row.getReferentRows(row.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
BigDecimal price = BigDecimal.ZERO;
1236,7 → 1410,7
Float resultTaux = TaxeCache.getCache().getTauxFromId(row2Insert.getForeignID("ID_TAXE"));
 
if (resultTaux == null) {
SQLRow rowTax = TaxeCache.getCache().getFirstTaxe();
SQLRow rowTax = TaxeCache.getCache().getFirstTaxeAchat();
resultTaux = rowTax.getFloat("TAUX");
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/MontantPanel.java
85,7 → 85,37
calculMontant();
}
};
private final DocumentListener listenerTextTaxe = new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
 
if (MontantPanel.this.enabled) {
long taxe = GestionDevise.parseLongCurrency(MontantPanel.this.textTaxe.getText());
if (MontantPanel.this.checkHT.isSelected()) {
long ht = GestionDevise.parseLongCurrency(MontantPanel.this.textHT.getText());
long ttc = taxe + ht;
MontantPanel.this.textTTC.getDocument().removeDocumentListener(MontantPanel.this.listenerTextTTC);
MontantPanel.this.textTTC.setText(GestionDevise.currencyToString(ttc));
MontantPanel.this.textTTC.getDocument().addDocumentListener(MontantPanel.this.listenerTextTTC);
} else {
long ttc = GestionDevise.parseLongCurrency(MontantPanel.this.textTTC.getText());
long ht = ttc - taxe;
MontantPanel.this.textHT.getDocument().removeDocumentListener(MontantPanel.this.listenerTextHT);
MontantPanel.this.textHT.setText(GestionDevise.currencyToString(ht));
MontantPanel.this.textHT.getDocument().addDocumentListener(MontantPanel.this.listenerTextHT);
}
}
 
}
 
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
}
 
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
};
 
public MontantPanel() {
uiInit();
}
137,8 → 167,6
 
this.comboTaxe.addValueListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
// System.out.println("ID TAXE Changed " +
// MontantPanel.this.comboTaxe.getSelectedId());
calculMontant();
}
});
183,10 → 211,10
setHT(true);
this.textTTC.getDocument().addDocumentListener(this.listenerTextTTC);
this.textHT.getDocument().addDocumentListener(this.listenerTextHT);
this.textTaxe.getDocument().addDocumentListener(this.listenerTextTaxe);
}
 
private void setHT(boolean b) {
System.err.println("MontantPanel.setHT()" + b);
if (b) {
this.textHT.setEditable(true);
this.textHT.setEnabled(true);
202,16 → 230,13
 
public void calculMontant() {
 
float taux;
PrixHT pHT;
PrixTTC pTTC;
System.out.println("Recalcul montant");
 
if (this.enabled) {
 
float taux;
PrixHT pHT;
PrixTTC pTTC;
// taux de la TVA selectionnee
int idTaxe = this.comboTaxe.getSelectedId();
System.out.println("ID_TAXE = " + idTaxe);
if (idTaxe > 1) {
SQLRow ligneTaxe = SQLBackgroundTableCache.getInstance().getCacheForTable(((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("TAXE"))
.getRowFromId(idTaxe);
239,8 → 264,9
ttc = GestionDevise.currencyToString(pHT.calculLongTTC(taux));
}
updateText(tva, ttc, pHT.toString(), true);
} else
} else {
updateText("", "", "", true);
}
} else {
 
if (this.textTTC.getText().trim().length() > 0) {
281,7 → 307,7
public void run() {
MontantPanel.this.textHT.getDocument().removeDocumentListener(MontantPanel.this.listenerTextHT);
MontantPanel.this.textTTC.getDocument().removeDocumentListener(MontantPanel.this.listenerTextTTC);
 
MontantPanel.this.textTaxe.getDocument().removeDocumentListener(MontantPanel.this.listenerTextTaxe);
// Update text with formated values
if (!isHT) {
MontantPanel.this.textHT.setText(prixHT);
292,6 → 318,7
setHT(isHT);
MontantPanel.this.textHT.getDocument().addDocumentListener(MontantPanel.this.listenerTextHT);
MontantPanel.this.textTTC.getDocument().addDocumentListener(MontantPanel.this.listenerTextTTC);
MontantPanel.this.textTaxe.getDocument().addDocumentListener(MontantPanel.this.listenerTextTaxe);
}
});
}
300,7 → 327,7
this.enabled = b;
this.checkHT.setEnabled(b);
this.checkTTC.setEnabled(b);
this.setHT(checkHT.isSelected());
this.setHT(this.checkHT.isSelected());
}
 
public DeviseField getMontantTTC() {
328,4 → 355,5
this.labelUE.setVisible(b);
calculMontant();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListTotalPanel.java
19,9 → 19,11
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.ITableModel;
import org.openconcerto.sql.view.list.ListSQLLine;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.TableSorter;
import org.openconcerto.utils.Tuple2;
 
import java.awt.GridBagConstraints;
41,6 → 43,7
import javax.swing.event.EventListenerList;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
 
public class IListTotalPanel extends JPanel {
CurrencyConverter cc = new CurrencyConverter();
81,7 → 84,10
List<Tuple2<? extends SQLTableModelColumn, Type>> lFinal = new ArrayList<Tuple2<? extends SQLTableModelColumn, Type>>();
 
for (SQLField field : l) {
lFinal.add(Tuple2.create(iL.getSource().getColumn(field), Type.SOMME));
final SQLTableModelColumn col = iL.getSource().getColumn(field);
if (col == null)
throw new IllegalArgumentException("No column with just " + field + " : " + iL.getSource().getColumns());
lFinal.add(Tuple2.create(col, Type.SOMME));
}
return lFinal;
}
138,27 → 144,44
}
 
this.list.addListener(new TableModelListener() {
 
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;
}
 
@Override
public void tableChanged(TableModelEvent e) {
final TableModel model = (TableModel) e.getSource();
final ITableModel sqlModel;
if (model instanceof ITableModel)
sqlModel = (ITableModel) model;
else
sqlModel = (ITableModel) ((TableSorter) model).getTableModel();
 
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(list.getRowCount()));
map.get(field.get0()).setText(String.valueOf(model.getRowCount()));
}
}
 
for (int i = 0; i < list.getRowCount(); i++) {
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();
 
final SQLRowValues rowAt = ITableModel.getLine(list.getModel(), i).getRow();
for (final Tuple2<? extends SQLTableModelColumn, Type> field : listField) {
final Type type = field.get1();
 
for (Tuple2<? extends SQLTableModelColumn, Type> field : listField) {
if (type == Type.MOYENNE_POURCENT) {
final Double n2 = (Double) getValueAt(line, field.get0(), columns);
 
if (field.get1() == Type.MOYENNE_POURCENT) {
 
Double n2 = (Double) list.getModel().getValueAt(i, list.getSource().getColumns().indexOf(field.get0()));
 
boolean in = true;
 
if (filters != null) {
188,13 → 211,12
}
 
}
} else if (field.get1() == Type.AVANCEMENT_TTC) {
} else if (type == Type.AVANCEMENT_TTC) {
 
BigDecimal n = mapTotal.get(field.get0());
final SQLTableModelColumn columnTTC = list.getSource().getColumn(list.getSource().getPrimaryTable().getField("T_TTC"));
BigDecimal ttc = BigDecimal.valueOf(((Number) list.getModel().getValueAt(i, list.getSource().getColumns().indexOf(columnTTC))).doubleValue());
BigDecimal ttc = BigDecimal.valueOf(line.getRow().getObjectAs("T_TTC", Number.class).doubleValue());
 
BigDecimal av = BigDecimal.valueOf(((Number) list.getModel().getValueAt(i, list.getSource().getColumns().indexOf(field.get0()))).doubleValue());
BigDecimal av = BigDecimal.valueOf(((Number) getValueAt(line, field.get0(), columns)).doubleValue());
 
boolean in = true;
 
216,10 → 238,11
mapTotal.put(field.get0(), n.add(ttc.multiply(av).movePointLeft(2)));
}
}
} else if (field.get1() != Type.MOYENNE_MARGE && field.get1() != Type.COUNT) {
} else if (type != Type.MOYENNE_MARGE && type != Type.COUNT) {
BigDecimal n = mapTotal.get(field.get0());
 
BigDecimal n2 = BigDecimal.valueOf(((Number) list.getModel().getValueAt(i, list.getSource().getColumns().indexOf(field.get0()))).doubleValue());
final Object value = getValueAt(line, field.get0(), columns);
final BigDecimal n2 = BigDecimal.valueOf(((Number) value).doubleValue());
 
boolean in = true;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/BanqueSQLElement.java
17,6 → 17,7
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.request.ComboSQLRequest.KeepMode;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.ProductInfo;
 
import java.util.ArrayList;
32,6 → 33,13
}
 
@Override
public ListMap<String, String> getShowAs() {
ListMap<String, String> map = new ListMap<>();
map.add(null, "NOM");
return map;
}
 
@Override
protected void _initComboRequest(ComboSQLRequest req) {
super._initComboRequest(req);
req.addForeignToGraphToFetch("ID_JOURNAL", Arrays.asList("ID", "CODE", "NOM"));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/AdresseSQLElement.java
15,6 → 15,7
 
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.utils.ListMap;
 
import java.util.ArrayList;
import java.util.List;
25,6 → 26,15
super("ADRESSE", "une adresse", "adresses");
}
 
@Override
public ListMap<String, String> getShowAs() {
if (this.getTable().contains("DISTRICT")) {
return ListMap.singleton(null, "RUE", "DISTRICT", "DEPARTEMENT", "CODE_POSTAL", "VILLE");
} else {
return ListMap.singleton(null, "RUE", "CODE_POSTAL", "VILLE");
}
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("RUE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/ListeHistoriquePanel.java
26,6 → 26,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLFieldsSet;
65,6 → 66,7
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.SQLException;
import java.util.ArrayList;
124,7 → 126,7
 
SQLRowAccessor row = ListeHistoriquePanel.this.jListePanel.getModel().getRowAt(selectIndex);
 
if ((row == null || row.isUndefined()) && undefinedLabel == null) {
if ((row == null || row.isUndefined()) && ListeHistoriquePanel.this.undefinedLabel == null) {
return;
}
 
160,10 → 162,53
w2 = w2.and(new Where(table.getForeignTable(field.getName()).getField("ID_" + ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName()), "=", id));
liste.getListe().getRequest().setWhere(w2.and(w));
} else {
if (liste.getElement().getTable().equals(jListePanel.getModel().getTable())) {
liste.getListe().getRequest().setWhere(new Where(table.getKey(), "=", id).and(w));
if (liste.getElement().getTable().equals(ListeHistoriquePanel.this.jListePanel.getModel().getTable())) {
final Where whereMatch = new Where(table.getField("ID_" + ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName()), "=", id);
if ((table.getName().equals("COMMANDE_ELEMENT") || table.getName().equals("BON_RECEPTION_ELEMENT"))
&& ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName().equals("AFFAIRE")) {
 
// FIXME alias forcé à la main, voir pour remplacer avec un
// selectTransformer
final String tablePere = table.getName().replaceAll("_ELEMENT", "");
AliasedTable tableAlias = new AliasedTable(table.getTable(tablePere), "tAlias__ID_" + tablePere + "__" + tablePere);
final int idAffaire = id;
Where wPere = new Where(tableAlias.getField("ID_AFFAIRE"), "=", idAffaire);
liste.getListe().getRequest().setWhere(whereMatch.or(wPere).and(w));
// whereMatch = whereMatch.or(new Where(new
// AliasedTable(table.getForeignTable("ID_"+tablePere),
// alias).getField("ID_AFFAIRE"), "=", id));
 
} else {
liste.getListe().getRequest().setWhere(whereMatch.and(w));
}
} else {
liste.getListe().getRequest().setWhere(new Where(table.getField("ID_" + ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName()), "=", id).and(w));
if ((table.getName().equals("MOUVEMENT_STOCK")) && ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName().equals("AFFAIRE")) {
 
final String tableStock = "STOCK";
AliasedTable tableAlias = new AliasedTable(table.getTable(tableStock), "tAlias__ID_" + tableStock + "__" + tableStock);
final int idAffaire = table.getTable("AFFAIRE").getRow(id).getForeignID("ID_DEPOT_STOCK");
Where w2 = new Where(table.getField("REEL"), "=", Boolean.TRUE);
w2 = w2.and(new Where(table.getField("SOURCE"), "=", ""));
Where wPere = new Where(tableAlias.getField("ID_DEPOT_STOCK"), "=", idAffaire).and(w2);
liste.getListe().getRequest().setWhere(wPere);
 
} else {
final Where whereMatch = new Where(table.getField("ID_" + ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName()), "=", id);
if ((table.getName().equals("FACTURE_FOURNISSEUR_ELEMENT") || table.getName().equals("COMMANDE_ELEMENT") || table.getName().equals("BON_RECEPTION_ELEMENT"))
&& ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName().equals("AFFAIRE")) {
 
// FIXME alias forcé à la main, voir pour remplacer avec un
// selectTransformer
final String tablePere = table.getName().replaceAll("_ELEMENT", "");
AliasedTable tableAlias = new AliasedTable(table.getTable(tablePere), "tAlias__ID_" + tablePere + "__" + tablePere);
final int idAffaire = id;
Where wPere = new Where(tableAlias.getField("ID_AFFAIRE"), "=", idAffaire);
liste.getListe().getRequest().setWhere(whereMatch.or(wPere).and(w).and(new Where(table.getField("PA_HT"), "!=", BigDecimal.ZERO)));
 
} else {
liste.getListe().getRequest().setWhere(whereMatch.and(w));
}
}
}
}
} else {
342,8 → 387,10
}
};
 
} else {
} else
 
{
 
liste = new ListeAddPanel(elt, new IListe(createTableSource), "historique-" + title) {
@Override
protected void handleAction(JButton source, ActionEvent evt) {
499,7 → 546,7
this.addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
jListePanel.addListSelectionListener(listListener);
ListeHistoriquePanel.this.jListePanel.addListSelectionListener(ListeHistoriquePanel.this.listListener);
}
 
@Override
509,7 → 556,7
 
@Override
public void ancestorRemoved(AncestorEvent event) {
jListePanel.removeListSelectionListener(listListener);
ListeHistoriquePanel.this.jListePanel.removeListSelectionListener(ListeHistoriquePanel.this.listListener);
}
});
 
547,7 → 594,7
 
public void addListSelectionListener(ListSelectionListener l) {
this.jListePanel.addListSelectionListener(l);
System.out.println("ListeHistoriquePanel.addListSelectionListener()" + jListePanel);
System.out.println("ListeHistoriquePanel.addListSelectionListener()" + this.jListePanel);
}
 
public void removeListSelectionListener(ListSelectionListener l) {
583,11 → 630,17
IListe liste = getIListeFromTableName(tableName);
List<Integer> listeIds = null;
if (liste != null) {
int size = liste.getRowCount();
listeIds = new ArrayList<Integer>(size);
ITableModel m = liste.getModel();
int size = m.getRowCount();
listeIds = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
listeIds.add(liste.idFromIndex(i));
try {
listeIds.add(m.idFromIndex(i));
} catch (Exception e) {
e.printStackTrace();
}
}
 
} else {
listeIds = Collections.emptyList();
}
597,7 → 650,7
public void removeAllTableListener() {
this.jListePanel.removeAllTableListener();
for (Integer i : this.mapListener.keySet()) {
IListPanel panel = vectListePanel.get(i);
IListPanel panel = this.vectListePanel.get(i);
List<TableModelListener> l = this.mapListener.get(i);
for (TableModelListener tableModelListener : l) {
final IListe liste = panel.getListe();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/EtatStockSnapshotCreator.java
15,6 → 15,7
 
import org.openconcerto.sql.model.DBRoot;
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.SQLRowValuesListFetcher;
27,7 → 28,6
 
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
37,9 → 37,11
 
private final Date d;
private final DBRoot root;
private final SQLRowAccessor depot;
 
public EtatStockSnapshotCreator(Date d, DBRoot root) {
public EtatStockSnapshotCreator(SQLRowAccessor depot, Date d, DBRoot root) {
this.d = d;
this.depot = depot;
this.root = root;
}
 
49,15 → 51,19
SQLSelect sel = new SQLSelect();
sel.addSelectStar(tableEtatStock);
Where wEtat = new Where(tableEtatStock.getField("INVENTAIRE"), "=", Boolean.TRUE);
wEtat = wEtat.and(new Where(tableEtatStock.getField("ID_DEPOT_STOCK"), "=", this.depot.getID()));
sel.setWhere(wEtat);
List<SQLRow> rowsEtatStock = SQLRowListRSH.execute(sel);
Map<Integer, Integer> mapEtatStock = new HashMap<Integer, Integer>();
for (SQLRow sqlRow : rowsEtatStock) {
SQLTable tableMvtStock = this.root.getTable("MOUVEMENT_STOCK");
SQLTable tableStock = this.root.getTable("STOCK");
SQLSelect selMvt = new SQLSelect();
selMvt.addSelect(tableMvtStock.getKey(), "MIN");
Where wMvt = new Where(tableMvtStock.getField("OUVERTURE"), "=", Boolean.TRUE);
wMvt = new Where(tableMvtStock.getField("ID_ETAT_STOCK"), "=", sqlRow.getID());
wMvt = wMvt.and(new Where(tableMvtStock.getField("ID_ETAT_STOCK"), "=", sqlRow.getID()));
wMvt = wMvt.and(new Where(tableMvtStock.getField("ID_STOCK"), "=", tableStock.getKey()));
wMvt = wMvt.and(new Where(tableStock.getField("ID_DEPOT_STOCK"), "=", depot.getID()));
selMvt.setWhere(wMvt);
Integer idMvt = (Integer) tableMvtStock.getDBSystemRoot().getDataSource().executeScalar(selMvt.asString());
if (idMvt != null) {
76,6 → 82,8
vals.put("PRICE", null);
}
vals.put("ID_ARTICLE", null);
vals.putRowValues("ID_STOCK").putNulls("QTE_REEL").putRowValues("ID_DEPOT_STOCK").putNulls("ID", "NOM", "CODE");
// Calendar cal0116 = Calendar.getInstance();
// cal0116.set(2016, Calendar.JANUARY, 1, 0, 0, 0);
// final Date dateDeb = cal0116.getTime();
84,6 → 92,7
SQLSelect selEtatD = new SQLSelect();
selEtatD.addSelectStar(tableEtatStock);
Where wEtatD = new Where(tableEtatStock.getField("INVENTAIRE"), "=", Boolean.TRUE);
wEtatD = wEtatD.and(new Where(tableEtatStock.getField("ID_DEPOT_STOCK"), "=", this.depot.getID()));
selEtatD.setWhere(wEtatD);
List<SQLRow> rowsEtatStockD = SQLRowListRSH.execute(selEtatD);
SQLRow rowEtatStockDeb = null;
120,6 → 129,7
w = w.and(new Where(tableStock.getField("CLOTURE"), "!=", Boolean.TRUE));
}
w = w.and(new Where(tableStock.getField("REEL"), "=", Boolean.TRUE));
w = w.and(new Where(sel.getJoin(tableStock.getField("ID_STOCK")).getJoinedTable().getField("ID_DEPOT_STOCK"), "=", depot.getID()));
 
sel.setWhere(w);
return sel;
150,6 → 160,7
SQLRowValues rowVals = new SQLRowValues(tableEtatStock);
rowVals.put("DATE", d);
rowVals.put("MONTANT_HA", totalHT);
rowVals.put("ID_DEPOT_STOCK", depot.getID());
 
for (EtatStock etatItem : mapStockSnap.values()) {
SQLRowValues rowValsItem = new SQLRowValues(tableEtatStock.getTable("ETAT_STOCK_ELEMENT"));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/ImportInventairePanel.java
New file
0,0 → 1,122
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
/*
* Créé le 23 avr. 2012
*/
package org.openconcerto.erp.core.supplychain.stock.element;
 
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.SwingThreadUtils;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 
public class ImportInventairePanel extends JPanel {
 
public ImportInventairePanel(final SQLElement depotElt) {
super(new GridBagLayout());
 
final SQLRequestComboBox boxDepot = new SQLRequestComboBox(false);
boxDepot.uiInit(depotElt.createComboRequest());
 
GridBagConstraints c = new DefaultGridBagConstraints();
JLabel labelCom = new JLabel("Dépôt ");
this.add(labelCom, c);
c.gridx++;
this.add(boxDepot, c);
 
// final JDate dateDeb = new JDate();
// this.add(dateDeb, c);
// c.gridx++;
// JLabel labelD = new JLabel("Début au");
// final JDate dateDebut = new JDate();
 
final JButton buttonValid = new JButton(new AbstractAction("Valider") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRowAccessor row = boxDepot.getSelectedRow();
final SQLRowAccessor rowDepot;
if (row != null && !row.isUndefined()) {
rowDepot = boxDepot.getSelectedRow();
} else {
rowDepot = depotElt.getTable().getRow(DepotStockSQLElement.DEFAULT_ID);
 
}
 
((Window) SwingUtilities.getRoot(ImportInventairePanel.this)).dispose();
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
final FileDialog fd = new FileDialog(frame, "Import Inventaire", FileDialog.LOAD);
fd.setVisible(true);
if (fd.getFile() != null) {
final File f = new File(fd.getDirectory(), fd.getFile());
if (!f.exists()) {
JOptionPane.showMessageDialog(null, "Le ficher selectionné n'existe pas", "Erreur", JOptionPane.ERROR_MESSAGE);
} else if (f.isDirectory()) {
JOptionPane.showMessageDialog(null, "Le fichier selectionné n'est pas valide", "Erreur", JOptionPane.ERROR_MESSAGE);
} else {
new Thread(new Runnable() {
 
@Override
public void run() {
final InventaireFromEtatStockImporter impoter = new InventaireFromEtatStockImporter(rowDepot);
try {
SQLUtils.executeAtomic(depotElt.getTable().getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
@Override
public Object handle(final SQLDataSource ds) throws SQLException, IOException {
 
impoter.importArticles(f, depotElt.getTable().getDBRoot());
return null;
}
});
} catch (Exception e1) {
ExceptionHandler.handle("Erreur lors de l'importation", e1);
}
 
}
}).start();
}
}
}
 
});
c.gridx++;
// buttonValid.setEnabled(false);
this.add(buttonValid, c);
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/EtatStockSQLElement.java
19,11 → 19,8
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
30,16 → 27,10
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.SwingThreadUtils;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
46,7 → 37,6
 
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
 
public class EtatStockSQLElement extends ComptaSQLConfElement {
59,7 → 49,7
 
@Override
public void actionPerformed(ActionEvent e) {
EtatStockSnapshotCreator creator = new EtatStockSnapshotCreator(new Date(), getTable().getDBRoot());
EtatStockSnapshotCreator creator = new EtatStockSnapshotCreator(getTable().getTable("DEPOT_STOCK").getRow(DepotStockSQLElement.DEFAULT_ID), new Date(), getTable().getDBRoot());
creator.create();
}
}, true);
103,38 → 93,8
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Import Inventaire") {
@Override
public void actionPerformed(ActionEvent e) {
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
final FileDialog fd = new FileDialog(frame, "Import Inventaire", FileDialog.LOAD);
fd.setVisible(true);
if (fd.getFile() != null) {
final File f = new File(fd.getDirectory(), fd.getFile());
if (!f.exists()) {
JOptionPane.showMessageDialog(null, "Le ficher selectionné n'existe pas", "Erreur", JOptionPane.ERROR_MESSAGE);
} else if (f.isDirectory()) {
JOptionPane.showMessageDialog(null, "Le fichier selectionné n'est pas valide", "Erreur", JOptionPane.ERROR_MESSAGE);
} else {
new Thread(new Runnable() {
 
@Override
public void run() {
final InventaireFromEtatStockImporter impoter = new InventaireFromEtatStockImporter();
try {
SQLUtils.executeAtomic(getTable().getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
@Override
public Object handle(final SQLDataSource ds) throws SQLException, IOException {
 
impoter.importArticles(f, getTable().getDBRoot());
return null;
}
});
} catch (Exception e1) {
ExceptionHandler.handle("Erreur lors de l'importation", e1);
}
 
}
}).start();
}
}
PanelFrame frame = new PanelFrame(new ImportInventairePanel(getDirectory().getElement(DepotStockSQLElement.class)), "Import inventaire");
FrameUtil.showPacked(frame);
}
}, true);
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/InventaireFromEtatStockImporter.java
27,6 → 27,7
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.utils.Tuple2;
 
import java.io.File;
import java.io.IOException;
45,11 → 46,12
 
public class InventaireFromEtatStockImporter {
 
Map<String, SQLRowValues> kits = new HashMap<String, SQLRowValues>();
List<String> codeKits = new ArrayList<String>();
private Map<String, SQLRowValues> kits = new HashMap<String, SQLRowValues>();
private List<String> codeKits = new ArrayList<String>();
private SQLRowAccessor depot;
 
public InventaireFromEtatStockImporter() {
 
public InventaireFromEtatStockImporter(SQLRowAccessor depot) {
this.depot = depot;
}
 
public void importArticles(File file, DBRoot root) throws IOException, SQLException {
57,7 → 59,7
final SQLTable table = root.findTable("ARTICLE");
final SQLTable tableArtElt = root.findTable("ARTICLE_ELEMENT");
 
Map<String, SQLRowValues> articles = getArticles();
Map<String, Tuple2<SQLRowValues, SQLRowValues>> articles = getArticles();
 
final DataImporter importer = new DataImporter(table) {
@Override
81,6 → 83,7
SQLRowValues rowVals = new SQLRowValues(table.getTable("ETAT_STOCK"));
rowVals.put("DATE", today);
rowVals.put("INVENTAIRE", Boolean.TRUE);
rowVals.put("ID_DEPOT_STOCK", this.depot.getID());
SQLRow rowEtat = rowVals.commit();
 
for (int i = 1; i < m.getRowCount(); i++) {
95,21 → 98,21
final String stringQtyOld = o.get(3).toString();
float qtyOld = stringQtyOld.trim().length() == 0 ? 0 : Float.valueOf(stringQtyOld);
 
SQLRowValues match = articles.get(code);
Tuple2<SQLRowValues, SQLRowValues> match = articles.get(code);
if (match != null) {
 
SQLRowAccessor stockValues = match.getForeign("ID_STOCK");
SQLRowAccessor stockValues = match.get1();
 
final SQLTable tableMvt = table.getTable("MOUVEMENT_STOCK");
SQLRowValues rowValsMvtStockClotureFermeture = new SQLRowValues(tableMvt);
rowValsMvtStockClotureFermeture.put("QTE", -qtyOld);
rowValsMvtStockClotureFermeture.put("NOM", "Clôture stock avant inventaire");
rowValsMvtStockClotureFermeture.put("ID_ARTICLE", match.getID());
rowValsMvtStockClotureFermeture.put("ID_ARTICLE", match.get0().getID());
rowValsMvtStockClotureFermeture.put("DATE", today);
rowValsMvtStockClotureFermeture.put("REEL", Boolean.TRUE);
rowValsMvtStockClotureFermeture.put("ID_STOCK", stockValues.getID());
 
BigDecimal prc = getPRC(match, Math.round(qtyOld), today);
BigDecimal prc = getPRC(match.get0(), Math.round(qtyOld), today);
if (prc == null) {
prc = BigDecimal.ZERO;
}
127,9 → 130,9
rowValsItem.put("QTE", qtyOld);
rowValsItem.put("T_PA", prc.multiply(new BigDecimal(qtyOld)));
rowValsItem.put("T_PV", BigDecimal.ZERO);
rowValsItem.put("CODE", match.getString("CODE"));
rowValsItem.put("NOM", match.getString("NOM"));
rowValsItem.put("ID_ARTICLE", match.getID());
rowValsItem.put("CODE", match.get0().getString("CODE"));
rowValsItem.put("NOM", match.get0().getString("NOM"));
rowValsItem.put("ID_ARTICLE", match.get0().getID());
rowValsItem.getGraph().store(StoreMode.COMMIT, false);
 
SQLRowValues rowValsMvtStockClotureOuverture = new SQLRowValues(tableMvt);
136,24 → 139,25
rowValsMvtStockClotureOuverture.put("QTE", qty);
rowValsMvtStockClotureOuverture.put("NOM", "Mise en stock inventaire");
rowValsMvtStockClotureOuverture.put("ID_ETAT_STOCK", rowEtat.getID());
rowValsMvtStockClotureOuverture.put("ID_ARTICLE", match.getID());
rowValsMvtStockClotureOuverture.put("ID_ARTICLE", match.get0().getID());
rowValsMvtStockClotureOuverture.put("DATE", today);
rowValsMvtStockClotureOuverture.put("REEL", Boolean.TRUE);
rowValsMvtStockClotureOuverture.put("ID_STOCK", stockValues.getID());
rowValsMvtStockClotureOuverture.put("OUVERTURE", Boolean.TRUE);
if (tableMvt.contains("PRICE")) {
rowValsMvtStockClotureOuverture.put("PRICE", getPRC(match, qty.intValue(), today));
rowValsMvtStockClotureOuverture.put("PRICE", getPRC(match.get0(), qty.intValue(), today));
}
rowValsMvtStockClotureOuverture.getGraph().store(StoreMode.COMMIT, false);
 
if (!match.isForeignEmpty("ID_STOCK")) {
match.getForeign("ID_STOCK").createEmptyUpdateRow().put("QTE_REEL", qty).commit();
} else {
final SQLRowValues createEmptyUpdateRow = match.createEmptyUpdateRow();
createEmptyUpdateRow.putRowValues("ID_STOCK").put("QTE_REEL", qty);
createEmptyUpdateRow.getGraph().store(StoreMode.COMMIT, false);
// if (!match.isForeignEmpty("ID_STOCK")) {
// match.getForeign("ID_STOCK").createEmptyUpdateRow().put("QTE_REEL",
// qty).commit();
// } else {
final SQLRowValues createEmptyUpdateRow = match.get1().createEmptyUpdateRow();
createEmptyUpdateRow.put("QTE_REEL", qty);
createEmptyUpdateRow.getGraph().store(StoreMode.COMMIT, false);
 
}
// }
 
} else {
System.err.println("Aucun article correspondant au code " + code);
305,7 → 309,7
// return result;
}
 
private Map<String, SQLRowValues> getArticles() throws SQLException {
private Map<String, Tuple2<SQLRowValues, SQLRowValues>> getArticles() throws SQLException {
final SQLTable table = Configuration.getInstance().getRoot().findTable("ARTICLE");
SQLRowValues graph = new SQLRowValues(table);
graph.put("ID", null);
312,7 → 316,10
graph.put("CODE", null);
graph.put("NOM", null);
graph.put("NOM", null);
graph.putRowValues("ID_STOCK").putNulls("ID_DEPOT_STOCK", "ID", "QTE_REEL", "QTE_TH", "QTE_LIV_ATTENTE", "QTE_RECEPT_ATTENTE");
final SQLTable foreignTableStock = table.getForeignTable("ID_STOCK");
SQLRowValues graphStock = new SQLRowValues(foreignTableStock);
graphStock.putNulls("ID_DEPOT_STOCK", "ID", "QTE_REEL", "QTE_TH", "QTE_LIV_ATTENTE", "QTE_RECEPT_ATTENTE");
graphStock.put("ID_ARTICLE", graph);
 
final SQLTable tableArtElt = table.getTable("ARTICLE_ELEMENT");
SQLRowValues artElt = new SQLRowValues(tableArtElt);
320,7 → 327,11
artElt.put("QTE", null);
artElt.put("QTE_UNITAIRE", null);
artElt.put("ID_ARTICLE_PARENT", graph);
artElt.putRowVa