Line 15... |
Line 15... |
15 |
|
15 |
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
17 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
17 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
18 |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
|
18 |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.payment.component.EncaisserMontantSQLComponent;
|
19 |
import org.openconcerto.erp.core.finance.payment.component.EncaisserMontantSQLComponent;
|
- |
|
20 |
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent;
|
- |
|
21 |
import org.openconcerto.erp.generationEcritures.GenerationReglementVenteNG;
|
- |
|
22 |
import org.openconcerto.erp.model.PrixTTC;
|
20 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
23 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
21 |
import org.openconcerto.sql.Configuration;
|
24 |
import org.openconcerto.sql.Configuration;
|
22 |
import org.openconcerto.sql.element.SQLComponent;
|
25 |
import org.openconcerto.sql.element.SQLComponent;
|
- |
|
26 |
import org.openconcerto.sql.element.SQLElement;
|
23 |
import org.openconcerto.sql.element.TreesOfSQLRows;
|
27 |
import org.openconcerto.sql.element.TreesOfSQLRows;
|
24 |
import org.openconcerto.sql.model.FieldPath;
|
28 |
import org.openconcerto.sql.model.FieldPath;
|
25 |
import org.openconcerto.sql.model.SQLRow;
|
29 |
import org.openconcerto.sql.model.SQLRow;
|
26 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
30 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
27 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
31 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
Line 30... |
Line 34... |
30 |
import org.openconcerto.sql.model.SQLTable;
|
34 |
import org.openconcerto.sql.model.SQLTable;
|
31 |
import org.openconcerto.sql.model.Where;
|
35 |
import org.openconcerto.sql.model.Where;
|
32 |
import org.openconcerto.sql.model.graph.Path;
|
36 |
import org.openconcerto.sql.model.graph.Path;
|
33 |
import org.openconcerto.sql.model.graph.PathBuilder;
|
37 |
import org.openconcerto.sql.model.graph.PathBuilder;
|
34 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
38 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
- |
|
39 |
import org.openconcerto.sql.view.EditFrame;
|
35 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
40 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
36 |
import org.openconcerto.sql.view.list.IListe;
|
41 |
import org.openconcerto.sql.view.list.IListe;
|
37 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
42 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
38 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
43 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
39 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
44 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
40 |
import org.openconcerto.utils.CollectionUtils;
|
45 |
import org.openconcerto.utils.CollectionUtils;
|
41 |
import org.openconcerto.utils.ExceptionHandler;
|
46 |
import org.openconcerto.utils.ExceptionHandler;
|
- |
|
47 |
import org.openconcerto.utils.StringUtils;
|
42 |
|
48 |
|
43 |
import java.awt.event.ActionEvent;
|
49 |
import java.awt.event.ActionEvent;
|
44 |
import java.sql.SQLException;
|
50 |
import java.sql.SQLException;
|
45 |
import java.util.ArrayList;
|
51 |
import java.util.ArrayList;
|
46 |
import java.util.Arrays;
|
52 |
import java.util.Arrays;
|
Line 49... |
Line 55... |
49 |
import java.util.HashSet;
|
55 |
import java.util.HashSet;
|
50 |
import java.util.List;
|
56 |
import java.util.List;
|
51 |
import java.util.Set;
|
57 |
import java.util.Set;
|
52 |
|
58 |
|
53 |
import javax.swing.AbstractAction;
|
59 |
import javax.swing.AbstractAction;
|
- |
|
60 |
import javax.swing.JOptionPane;
|
- |
|
61 |
import javax.swing.SwingUtilities;
|
54 |
|
62 |
|
55 |
public class EncaisserMontantSQLElement extends ComptaSQLConfElement {
|
63 |
public class EncaisserMontantSQLElement extends ComptaSQLConfElement {
|
56 |
|
64 |
|
57 |
public EncaisserMontantSQLElement() {
|
65 |
public EncaisserMontantSQLElement() {
|
58 |
super("ENCAISSER_MONTANT", "un encaissement de montant", "encaissements de montant");
|
66 |
super("ENCAISSER_MONTANT", "un encaissement de montant", "encaissements de montant");
|
Line 162... |
Line 170... |
162 |
}
|
170 |
}
|
163 |
|
171 |
|
164 |
super.archive(trees, cutLinks);
|
172 |
super.archive(trees, cutLinks);
|
165 |
}
|
173 |
}
|
166 |
|
174 |
|
- |
|
175 |
public void regleFacture(SQLRow row) throws Exception {
|
- |
|
176 |
|
- |
|
177 |
System.out.println("Génération des ecritures du reglement");
|
- |
|
178 |
String s = row.getString("NOM");
|
- |
|
179 |
SQLRow rowModeRegl = row.getForeignRow("ID_MODE_REGLEMENT");
|
- |
|
180 |
SQLRow rowTypeRegl = rowModeRegl.getForeignRow("ID_TYPE_REGLEMENT");
|
- |
|
181 |
|
- |
|
182 |
// Compte Client
|
- |
|
183 |
SQLRow clientRow = row.getForeignRow("ID_CLIENT");
|
- |
|
184 |
|
- |
|
185 |
String label = "Règlement vente " + ((s == null) ? "" : s) + " (" + rowTypeRegl.getString("NOM") + ") " + StringUtils.limitLength(clientRow.getString("NOM"), 20);
|
- |
|
186 |
long montant = row.getLong("MONTANT");
|
- |
|
187 |
PrixTTC ttc = new PrixTTC(montant);
|
- |
|
188 |
|
- |
|
189 |
List<SQLRow> l = row.getReferentRows(row.getTable().getTable("ENCAISSER_MONTANT_ELEMENT"));
|
- |
|
190 |
if (l.isEmpty()) {
|
- |
|
191 |
SwingUtilities.invokeLater(new Runnable() {
|
- |
|
192 |
|
- |
|
193 |
@Override
|
- |
|
194 |
public void run() {
|
- |
|
195 |
JOptionPane.showMessageDialog(null, "Un problème a été rencontré lors de l'encaissement! \n Les écritures comptables non pu être générer!");
|
- |
|
196 |
}
|
- |
|
197 |
});
|
- |
|
198 |
System.err.println("Liste des échéances vides pour l'encaissement ID " + row.getID());
|
- |
|
199 |
Thread.dumpStack();
|
- |
|
200 |
return;
|
- |
|
201 |
}
|
- |
|
202 |
new GenerationReglementVenteNG(label, clientRow, ttc, row.getDate("DATE").getTime(), rowModeRegl, row, l.get(0).getForeignRow("ID_MOUVEMENT_ECHEANCE"), false, false, row.getString("TIERS"),
|
- |
|
203 |
row.getForeign("ID_COMPTE_PCE_TIERS"));
|
- |
|
204 |
|
- |
|
205 |
// Mise a jour du montant de l'echeance
|
- |
|
206 |
boolean supplement = false;
|
- |
|
207 |
|
- |
|
208 |
if (!row.getBoolean("ACOMPTE")) {
|
- |
|
209 |
// On marque les echeances comme reglees
|
- |
|
210 |
for (SQLRow sqlRow : l) {
|
- |
|
211 |
|
- |
|
212 |
final SQLRow rowEch = sqlRow.getForeignRow("ID_ECHEANCE_CLIENT");
|
- |
|
213 |
SQLRowValues rowValsEch = rowEch.createEmptyUpdateRow();
|
- |
|
214 |
if (sqlRow.getLong("MONTANT_REGLE") >= sqlRow.getLong("MONTANT_A_REGLER")) {
|
- |
|
215 |
rowValsEch.put("REGLE", Boolean.TRUE);
|
- |
|
216 |
if (sqlRow.getLong("MONTANT_REGLE") > sqlRow.getLong("MONTANT_A_REGLER")) {
|
- |
|
217 |
supplement = true;
|
- |
|
218 |
}
|
- |
|
219 |
}
|
- |
|
220 |
rowValsEch.put("MONTANT", Long.valueOf(rowEch.getLong("MONTANT") - sqlRow.getLong("MONTANT_REGLE")));
|
- |
|
221 |
|
- |
|
222 |
rowValsEch.update();
|
- |
|
223 |
// this.comboEcheance.rowDeleted(tableEch, rowEch.getID());
|
- |
|
224 |
// getTable().fireTableModified(rowEch.getID());
|
- |
|
225 |
}
|
- |
|
226 |
}
|
- |
|
227 |
// si le montant réglé est supérieur, on crée une facture de complément
|
- |
|
228 |
if (supplement) {
|
- |
|
229 |
SQLElement elt = getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
- |
|
230 |
SwingUtilities.invokeLater(new Runnable() {
|
- |
|
231 |
|
- |
|
232 |
@Override
|
- |
|
233 |
public void run() {
|
- |
|
234 |
|
- |
|
235 |
EditFrame f = new EditFrame(elt, EditFrame.CREATION);
|
- |
|
236 |
SaisieVenteFactureSQLComponent comp = (SaisieVenteFactureSQLComponent) f.getSQLComponent();
|
- |
|
237 |
comp.setComplement(true);
|
- |
|
238 |
f.setVisible(true);
|
- |
|
239 |
}
|
- |
|
240 |
});
|
- |
|
241 |
}
|
- |
|
242 |
|
- |
|
243 |
}
|
- |
|
244 |
|
167 |
@Override
|
245 |
@Override
|
168 |
protected String createCodeSuffix() {
|
246 |
protected String createCodeSuffix() {
|
169 |
return ".category";
|
247 |
return ".category";
|
170 |
}
|
248 |
}
|
171 |
}
|
249 |
}
|