156 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
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
|
|
|
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.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.finance.payment.element;
|
|
|
15 |
|
177 |
ilm |
16 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
156 |
ilm |
17 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
|
|
18 |
import org.openconcerto.erp.core.finance.payment.component.DepotChequeSQLComponent;
|
|
|
19 |
import org.openconcerto.erp.generationDoc.gestcomm.DepotChequeXmlSheet;
|
|
|
20 |
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
|
|
|
21 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
22 |
import org.openconcerto.sql.element.SQLElementLinksSetup;
|
|
|
23 |
import org.openconcerto.sql.element.TreesOfSQLRows;
|
|
|
24 |
import org.openconcerto.sql.element.SQLElementLink.LinkType;
|
|
|
25 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
26 |
|
|
|
27 |
import java.sql.SQLException;
|
|
|
28 |
import java.util.ArrayList;
|
|
|
29 |
import java.util.HashSet;
|
|
|
30 |
import java.util.List;
|
|
|
31 |
import java.util.Set;
|
|
|
32 |
|
|
|
33 |
public class DepotChequeSQLElement extends ComptaSQLConfElement {
|
|
|
34 |
|
|
|
35 |
public DepotChequeSQLElement() {
|
|
|
36 |
super("DEPOT_CHEQUE", "un dépot de chèque", "dépots de chèque");
|
|
|
37 |
MouseSheetXmlListeListener listener = new MouseSheetXmlListeListener(DepotChequeXmlSheet.class);
|
|
|
38 |
getRowActions().addAll(listener.getRowActions());
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
@Override
|
|
|
42 |
protected void setupLinks(SQLElementLinksSetup links) {
|
|
|
43 |
super.setupLinks(links);
|
|
|
44 |
links.get("ID_MOUVEMENT").setType(LinkType.ASSOCIATION);
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
protected List<String> getListFields() {
|
|
|
48 |
final List<String> l = new ArrayList<String>();
|
|
|
49 |
l.add("DATE");
|
|
|
50 |
l.add("NOM");
|
177 |
ilm |
51 |
l.add("ID_" + BanqueSQLElement.TABLENAME);
|
156 |
ilm |
52 |
l.add("MONTANT");
|
|
|
53 |
return l;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
protected List<String> getComboFields() {
|
|
|
57 |
final List<String> l = new ArrayList<String>();
|
|
|
58 |
l.add("DATE");
|
|
|
59 |
l.add("MONTANT");
|
|
|
60 |
return l;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public SQLComponent createComponent() {
|
|
|
64 |
return new DepotChequeSQLComponent(this);
|
|
|
65 |
};
|
|
|
66 |
|
|
|
67 |
@Override
|
|
|
68 |
public Set<String> getReadOnlyFields() {
|
|
|
69 |
Set<String> s = new HashSet<>();
|
|
|
70 |
s.add("MONTANT");
|
|
|
71 |
return s;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
@Override
|
|
|
75 |
protected String createCode() {
|
|
|
76 |
return createCodeOfPackage() + ".depot";
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
@Override
|
|
|
80 |
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
|
|
|
81 |
for (SQLRow row : trees.getRows()) {
|
|
|
82 |
List<SQLRow> rowCheques = row.getReferentRows(getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
|
|
|
83 |
for (SQLRow depotElt : rowCheques) {
|
|
|
84 |
if (depotElt.getObject("ID_CHEQUE_A_ENCAISSER") != null && !depotElt.isForeignEmpty("ID_CHEQUE_A_ENCAISSER")) {
|
|
|
85 |
depotElt.getForeign("ID_CHEQUE_A_ENCAISSER").createEmptyUpdateRow().put("ENCAISSE", Boolean.FALSE).commit();
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
super.archive(trees, cutLinks);
|
|
|
90 |
}
|
|
|
91 |
}
|