OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | Rev 174 | 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");
103
        l.add("MONTANT");
104
 
105
        final ShowAs showAs = new ShowAs(getTable().getDBRoot());
106
 
107
        final SQLTable mvtT = getTable().getForeignTable("ID_MOUVEMENT");
108
        showAs.show(mvtT, "ID_PIECE");
109
        showAs.show(mvtT.getForeignTable("ID_PIECE"), "NOM");
110
 
111
        final SQLTable clientERP = getTable().getForeignTable("ID_CLIENT");
112
        {
113
            showAs.show(clientERP, "NOM");
114
        }
115
 
116
        return this.createDepositTableSource(l, showAs, new Where(getTable().getField("REG_COMPTA"), "=", Boolean.FALSE));
117
    }
118
 
18 ilm 119
    protected List<String> getComboFields() {
120
        final List<String> l = new ArrayList<String>();
121
        l.add("DATE_VENTE");
122
        l.add("MONTANT");
123
        l.add("ID_CLIENT");
124
        return l;
125
    }
126
 
127
    /*
128
     * (non-Javadoc)
129
     *
130
     * @see org.openconcerto.devis.SQLElement#getComponent()
131
     */
132
    public SQLComponent createComponent() {
133
        return new BaseSQLComponent(this) {
134
 
135
            private DeviseField textMontant = new DeviseField();
136
 
137
            public void addViews() {
138
                this.setLayout(new GridBagLayout());
139
                final GridBagConstraints c = new DefaultGridBagConstraints();
140
 
141
                // Montant
142
                JLabel labelMontant = new JLabel("Montant ");
143
 
144
                this.add(labelMontant, c);
145
                c.gridx++;
146
                c.weightx = 1;
147
                this.add(this.textMontant, c);
148
 
149
                // Date
150
                JLabel labelDate = new JLabel("Date ");
151
                c.weightx = 0;
152
                c.gridx++;
153
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
154
                this.add(labelDate, c);
155
 
156
                JDate dateVente = new JDate(true);
157
                c.gridx++;
158
                c.gridwidth = GridBagConstraints.REMAINDER;
159
                this.add(dateVente, c);
160
 
161
                // Date echeance
162
                JLabel labelDateEcheance = new JLabel("Date d'échéance");
163
                c.weightx = 0;
164
                c.gridy++;
165
                c.gridwidth = 1;
166
                c.gridx = 0;
167
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
168
                this.add(labelDateEcheance, c);
169
 
170
                JDate dateEcheance = new JDate(true);
171
                c.gridx++;
172
                c.gridwidth = 1;
173
                this.add(dateEcheance, c);
174
 
175
                c.gridy++;
176
                c.gridx = 0;
177
                JLabel labelClientNom = new JLabel("Client ");
178
                this.add(labelClientNom, c);
179
 
180
                ElementComboBox nomClient = new ElementComboBox();
181
                c.gridx++;
182
                c.gridwidth = GridBagConstraints.REMAINDER;
183
                this.add(nomClient, c);
184
 
185
                this.addRequiredSQLObject(nomClient, "ID_CLIENT");
186
                this.addRequiredSQLObject(this.textMontant, "MONTANT");
187
                this.addRequiredSQLObject(dateVente, "DATE_VENTE");
188
                this.addRequiredSQLObject(dateEcheance, "DATE_MIN_DEPOT");
189
            }
190
        };
191
    }
57 ilm 192
 
193
    @Override
194
    protected String createCode() {
156 ilm 195
        return createCodeOfPackage() + ".cheque";
57 ilm 196
    }
18 ilm 197
}