OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 182 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 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
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
83 ilm 17
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
18 ilm 18
import org.openconcerto.erp.core.common.ui.DeviseField;
80 ilm 19
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeSheet;
20
import org.openconcerto.erp.generationEcritures.GenerationMvtReglementChequeClient;
18 ilm 21
import org.openconcerto.sql.Configuration;
80 ilm 22
import org.openconcerto.sql.ShowAs;
18 ilm 23
import org.openconcerto.sql.element.BaseSQLComponent;
24
import org.openconcerto.sql.element.SQLComponent;
80 ilm 25
import org.openconcerto.sql.model.SQLRowAccessor;
26
import org.openconcerto.sql.model.SQLTable;
27
import org.openconcerto.sql.model.Where;
18 ilm 28
import org.openconcerto.sql.sqlobject.ElementComboBox;
80 ilm 29
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
18 ilm 30
import org.openconcerto.ui.DefaultGridBagConstraints;
31
import org.openconcerto.ui.JDate;
32
 
33
import java.awt.GridBagConstraints;
34
import java.awt.GridBagLayout;
35
import java.util.ArrayList;
80 ilm 36
import java.util.Date;
18 ilm 37
import java.util.List;
38
 
39
import javax.swing.JLabel;
40
import javax.swing.SwingConstants;
41
 
80 ilm 42
public class ChequeAEncaisserSQLElement extends ChequeSQLElement {
18 ilm 43
 
44
    public ChequeAEncaisserSQLElement() {
45
        super("CHEQUE_A_ENCAISSER", "un chéque client", "chéques clients");
46
    }
47
 
48
    protected List<String> getListFields() {
49
        final List<String> l = new ArrayList<String>();
50
 
51
        l.add("ID_MOUVEMENT");
52
        l.add("ID_CLIENT");
83 ilm 53
        l.add("ID_" + BanqueSQLElement.TABLENAME);
73 ilm 54
        l.add("DATE");
55
        l.add("ETS");
56
        l.add("NUMERO");
18 ilm 57
        l.add("DATE_VENTE");
58
        l.add("DATE_DEPOT");
59
        l.add("MONTANT");
60
        l.add("REG_COMPTA");
61
        l.add("ENCAISSE");
62
        return l;
63
    }
64
 
80 ilm 65
    @Override
66
    public String getDoneFieldName() {
67
        return "ENCAISSE";
68
    }
69
 
70
    @Override
71
    public String getDateFieldName() {
72
        return "DATE_DEPOT";
73
    }
74
 
75
    @Override
76
    public String getMinDateFieldName() {
77
        return "DATE_MIN_DEPOT";
78
    }
79
 
80
    @Override
81
    public void print(final List<Integer> listeCheque, final boolean preview, final Date d) {
82
        ReleveChequeSheet sheet = new ReleveChequeSheet(listeCheque, d, preview);
83
        sheet.createDocumentAsynchronous();
84
        sheet.showPrintAndExportAsynchronous(true, false, true);
85
    }
86
 
87
    @Override
144 ilm 88
    public void handle(SQLRowAccessor rowBanque, SQLRowAccessor rowCheque, Date d, String label) throws Exception {
89
        GenerationMvtReglementChequeClient gen = new GenerationMvtReglementChequeClient(rowCheque.getForeignID("ID_MOUVEMENT"), rowCheque.getLong("MONTANT"), d, rowCheque.getID(), label, rowBanque);
80 ilm 90
        gen.genere();
91
    }
92
 
93
    @Override
94
    public SQLTableModelSourceOnline createDepositTableSource() {
95
        final List<String> l = new ArrayList<String>();
96
        l.add("ETS");
97
        l.add("NUMERO");
98
        l.add("DATE");
99
        l.add("ID_MOUVEMENT");
100
        l.add("DATE_VENTE");
101
        l.add(getMinDateFieldName());
102
        l.add("ID_CLIENT");
174 ilm 103
        final ShowAs showAs = new ShowAs(getTable().getDBRoot());
104
        if (getTable().contains("ID_BANQUE")) {
105
            l.add("ID_BANQUE");
106
            showAs.show(getTable().getForeignTable("ID_BANQUE"), "NOM");
107
        }
80 ilm 108
        l.add("MONTANT");
109
 
110
 
111
        final SQLTable mvtT = getTable().getForeignTable("ID_MOUVEMENT");
112
        showAs.show(mvtT, "ID_PIECE");
113
        showAs.show(mvtT.getForeignTable("ID_PIECE"), "NOM");
114
 
115
        final SQLTable clientERP = getTable().getForeignTable("ID_CLIENT");
116
        {
117
            showAs.show(clientERP, "NOM");
118
        }
119
 
120
        return this.createDepositTableSource(l, showAs, new Where(getTable().getField("REG_COMPTA"), "=", Boolean.FALSE));
121
    }
122
 
18 ilm 123
    protected List<String> getComboFields() {
124
        final List<String> l = new ArrayList<String>();
125
        l.add("DATE_VENTE");
126
        l.add("MONTANT");
127
        l.add("ID_CLIENT");
128
        return l;
129
    }
130
 
131
    /*
132
     * (non-Javadoc)
133
     *
134
     * @see org.openconcerto.devis.SQLElement#getComponent()
135
     */
136
    public SQLComponent createComponent() {
137
        return new BaseSQLComponent(this) {
138
 
139
            private DeviseField textMontant = new DeviseField();
140
 
141
            public void addViews() {
142
                this.setLayout(new GridBagLayout());
143
                final GridBagConstraints c = new DefaultGridBagConstraints();
144
 
145
                // Montant
146
                JLabel labelMontant = new JLabel("Montant ");
147
 
148
                this.add(labelMontant, c);
149
                c.gridx++;
150
                c.weightx = 1;
151
                this.add(this.textMontant, c);
152
 
153
                // Date
154
                JLabel labelDate = new JLabel("Date ");
155
                c.weightx = 0;
156
                c.gridx++;
157
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
158
                this.add(labelDate, c);
159
 
160
                JDate dateVente = new JDate(true);
161
                c.gridx++;
162
                c.gridwidth = GridBagConstraints.REMAINDER;
163
                this.add(dateVente, c);
164
 
165
                // Date echeance
166
                JLabel labelDateEcheance = new JLabel("Date d'échéance");
167
                c.weightx = 0;
168
                c.gridy++;
169
                c.gridwidth = 1;
170
                c.gridx = 0;
171
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
172
                this.add(labelDateEcheance, c);
173
 
174
                JDate dateEcheance = new JDate(true);
175
                c.gridx++;
176
                c.gridwidth = 1;
177
                this.add(dateEcheance, c);
178
 
179
                c.gridy++;
180
                c.gridx = 0;
181
                JLabel labelClientNom = new JLabel("Client ");
182
                this.add(labelClientNom, c);
183
 
184
                ElementComboBox nomClient = new ElementComboBox();
185
                c.gridx++;
186
                c.gridwidth = GridBagConstraints.REMAINDER;
187
                this.add(nomClient, c);
188
 
189
                this.addRequiredSQLObject(nomClient, "ID_CLIENT");
190
                this.addRequiredSQLObject(this.textMontant, "MONTANT");
191
                this.addRequiredSQLObject(dateVente, "DATE_VENTE");
192
                this.addRequiredSQLObject(dateEcheance, "DATE_MIN_DEPOT");
193
            }
194
        };
195
    }
57 ilm 196
 
197
    @Override
198
    protected String createCode() {
156 ilm 199
        return createCodeOfPackage() + ".cheque";
57 ilm 200
    }
18 ilm 201
}