Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
9 |
* language governing permissions and limitations under the License.
|
9 |
* language governing permissions and limitations under the License.
|
Line 70... |
Line 70... |
70 |
PredicateRowAction actionClient = new PredicateRowAction(new AbstractAction("Annuler l'acompte") {
|
70 |
PredicateRowAction actionClient = new PredicateRowAction(new AbstractAction("Annuler l'acompte") {
|
71 |
|
71 |
|
72 |
public void actionPerformed(ActionEvent e) {
|
72 |
public void actionPerformed(ActionEvent e) {
|
73 |
final SQLRow selRow = IListe.get(e).getSelectedRow().asRow();
|
73 |
final SQLRow selRow = IListe.get(e).getSelectedRow().asRow();
|
74 |
if (selRow.getBoolean("ACOMPTE")) {
|
74 |
if (selRow.getBoolean("ACOMPTE")) {
|
- |
|
75 |
if (!selRow.isForeignEmpty("ID_DEVIS")) {
|
75 |
int idDevis = selRow.getForeignID("ID_DEVIS");
|
76 |
int idDevis = selRow.getForeignID("ID_DEVIS");
|
76 |
try {
|
77 |
try {
|
77 |
archive(selRow.getID());
|
78 |
archive(selRow.getID());
|
78 |
String up = "UPDATE " + getTable().getTable("DEVIS").getSQLName().quote() + " set \"T_ACOMPTE\"=(SELECT COALESCE(SUM(\"MONTANT\"),0) from "
|
79 |
String up = "UPDATE " + getTable().getTable("DEVIS").getSQLName().quote() + " set \"T_ACOMPTE\"=(SELECT COALESCE(SUM(\"MONTANT\"),0) from "
|
79 |
+ getTable().getSQLName().quote() + " where \"ID_DEVIS\"=" + idDevis + " AND \"ARCHIVE\"=0) where \"ID_DEVIS\"=" + idDevis;
|
80 |
+ getTable().getSQLName().quote() + " where \"ID_DEVIS\"=" + idDevis + " AND \"ARCHIVE\"=0) where \"ID_DEVIS\"=" + idDevis;
|
80 |
getTable().getDBSystemRoot().getDataSource().execute(up);
|
81 |
getTable().getDBSystemRoot().getDataSource().execute(up);
|
81 |
} catch (SQLException e1) {
|
82 |
} catch (SQLException e1) {
|
82 |
e1.printStackTrace();
|
83 |
e1.printStackTrace();
|
83 |
ExceptionHandler.handle("Erreur lors de l'annulation de l'acompte!", e1);
|
84 |
ExceptionHandler.handle("Erreur lors de l'annulation de l'acompte!", e1);
|
84 |
}
|
85 |
}
|
- |
|
86 |
} else if (!selRow.isForeignEmpty("ID_COMMANDE_CLIENT")) {
|
- |
|
87 |
int idDevis = selRow.getForeignID("ID_COMMANDE_CLIENT");
|
- |
|
88 |
try {
|
- |
|
89 |
archive(selRow.getID());
|
- |
|
90 |
String up = "UPDATE " + getTable().getTable("COMMANDE_CLIENT").getSQLName().quote() + " set \"T_ACOMPTE\"=(SELECT COALESCE(SUM(\"MONTANT\"),0) from "
|
- |
|
91 |
+ getTable().getSQLName().quote() + " where \"ID_COMMANDE_CLIENT\"=" + idDevis + " AND \"ARCHIVE\"=0) where \"ID\"=" + idDevis;
|
- |
|
92 |
getTable().getDBSystemRoot().getDataSource().execute(up);
|
- |
|
93 |
} catch (SQLException e1) {
|
- |
|
94 |
e1.printStackTrace();
|
- |
|
95 |
ExceptionHandler.handle("Erreur lors de l'annulation de l'acompte!", e1);
|
- |
|
96 |
}
|
- |
|
97 |
}
|
85 |
}
|
98 |
}
|
86 |
}
|
99 |
}
|
87 |
}, false);
|
100 |
}, false);
|
88 |
actionClient.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
101 |
actionClient.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
89 |
getRowActions().add(actionClient);
|
102 |
getRowActions().add(actionClient);
|
Line 116... |
Line 129... |
116 |
}
|
129 |
}
|
117 |
|
130 |
|
118 |
@Override
|
131 |
@Override
|
119 |
public Set<String> getReadOnlyFields() {
|
132 |
public Set<String> getReadOnlyFields() {
|
120 |
|
133 |
|
- |
|
134 |
Set<String> s = new HashSet<>();
|
- |
|
135 |
s.add("ACOMPTE");
|
121 |
return Collections.singleton("ID_CLIENT");
|
136 |
s.add("ID_CLIENT");
|
- |
|
137 |
return s;
|
122 |
}
|
138 |
}
|
123 |
|
139 |
|
124 |
@Override
|
140 |
@Override
|
125 |
protected synchronized void _initTableSource(final SQLTableModelSource table) {
|
141 |
protected synchronized void _initTableSource(final SQLTableModelSource table) {
|
126 |
super._initTableSource(table);
|
142 |
super._initTableSource(table);
|
Line 157... |
Line 173... |
157 |
@Override
|
173 |
@Override
|
158 |
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
|
174 |
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
|
159 |
|
175 |
|
160 |
// On rétablit les échéances
|
176 |
// On rétablit les échéances
|
161 |
for (SQLRow row : trees.getRows()) {
|
177 |
for (SQLRow row : trees.getRows()) {
|
162 |
for (SQLRow rowEncaisse : row.getReferentRows()) {
|
178 |
for (SQLRow rowEncaisseItems : row.getReferentRows(row.getTable().getTable("ENCAISSER_MONTANT_ELEMENT").getField("ID_ENCAISSER_MONTANT"))) {
|
163 |
|
179 |
|
164 |
SQLRow rowEch = rowEncaisse.getForeignRow("ID_ECHEANCE_CLIENT");
|
180 |
SQLRow rowEch = rowEncaisseItems.getForeignRow("ID_ECHEANCE_CLIENT");
|
165 |
// SI une echeance est associée (paiement non comptant)
|
181 |
// SI une echeance est associée (paiement non comptant)
|
166 |
if (rowEch.getID() > 1) {
|
182 |
if (rowEch.getID() > 1) {
|
167 |
SQLRowValues rowVals = rowEch.createEmptyUpdateRow();
|
183 |
SQLRowValues rowVals = rowEch.createEmptyUpdateRow();
|
168 |
rowVals.put("REGLE", Boolean.FALSE);
|
184 |
rowVals.put("REGLE", Boolean.FALSE);
|
169 |
if (rowEch.getBoolean("REGLE")) {
|
185 |
if (rowEch.getBoolean("REGLE")) {
|
170 |
rowVals.put("MONTANT", rowEncaisse.getLong("MONTANT_REGLE"));
|
186 |
rowVals.put("MONTANT", rowEncaisseItems.getLong("MONTANT_REGLE"));
|
171 |
} else {
|
187 |
} else {
|
172 |
rowVals.put("MONTANT", rowEch.getLong("MONTANT") + rowEncaisse.getLong("MONTANT_REGLE"));
|
188 |
rowVals.put("MONTANT", rowEch.getLong("MONTANT") + rowEncaisseItems.getLong("MONTANT_REGLE"));
|
173 |
}
|
189 |
}
|
174 |
rowVals.update();
|
190 |
rowVals.update();
|
175 |
}
|
191 |
}
|
176 |
Configuration.getInstance().getDirectory().getElement(rowEncaisse.getTable()).archive(rowEncaisse);
|
192 |
Configuration.getInstance().getDirectory().getElement(rowEncaisseItems.getTable()).archive(rowEncaisseItems);
|
- |
|
193 |
}
|
- |
|
194 |
if (row.getBoolean("ACOMPTE")) {
|
- |
|
195 |
if (!row.isForeignEmpty("ID_DEVIS")) {
|
- |
|
196 |
int idDevis = row.getForeignID("ID_DEVIS");
|
- |
|
197 |
try {
|
- |
|
198 |
archive(row.getID());
|
- |
|
199 |
String up = "UPDATE " + getTable().getTable("DEVIS").getSQLName().quote() + " set \"T_ACOMPTE\"=(SELECT COALESCE(SUM(\"MONTANT\"),0) from " + getTable().getSQLName().quote()
|
- |
|
200 |
+ " where \"ID_DEVIS\"=" + idDevis + " AND \"ARCHIVE\"=0) where \"ID_DEVIS\"=" + idDevis;
|
- |
|
201 |
getTable().getDBSystemRoot().getDataSource().execute(up);
|
- |
|
202 |
} catch (SQLException e1) {
|
- |
|
203 |
e1.printStackTrace();
|
- |
|
204 |
ExceptionHandler.handle("Erreur lors de l'annulation de l'acompte!", e1);
|
- |
|
205 |
}
|
- |
|
206 |
} else if (!row.isForeignEmpty("ID_COMMANDE_CLIENT")) {
|
- |
|
207 |
int idDevis = row.getForeignID("ID_COMMANDE_CLIENT");
|
- |
|
208 |
try {
|
- |
|
209 |
archive(row.getID());
|
- |
|
210 |
String up = "UPDATE " + getTable().getTable("COMMANDE_CLIENT").getSQLName().quote() + " set \"T_ACOMPTE\"=(SELECT COALESCE(SUM(\"MONTANT\"),0) from "
|
- |
|
211 |
+ getTable().getSQLName().quote() + " where \"ID_COMMANDE_CLIENT\"=" + idDevis + " AND \"ARCHIVE\"=0) where \"ID\"=" + idDevis;
|
- |
|
212 |
getTable().getDBSystemRoot().getDataSource().execute(up);
|
- |
|
213 |
} catch (SQLException e1) {
|
- |
|
214 |
e1.printStackTrace();
|
- |
|
215 |
ExceptionHandler.handle("Erreur lors de l'annulation de l'acompte!", e1);
|
- |
|
216 |
}
|
- |
|
217 |
}
|
177 |
}
|
218 |
}
|
178 |
|
219 |
|
179 |
// On supprime les mouvements
|
220 |
// On supprime les mouvements
|
180 |
SQLSelect sel = new SQLSelect(getTable().getBase());
|
221 |
SQLSelect sel = new SQLSelect(getTable().getBase());
|
181 |
|
222 |
|