OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | 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.core.common.ui.DeviseField;
80 ilm 17
import org.openconcerto.erp.generationDoc.SpreadSheetGeneratorCompta;
18
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeEmisSheet;
19
import org.openconcerto.erp.generationEcritures.GenerationMvtReglementChequeFourn;
20
import org.openconcerto.sql.ShowAs;
18 ilm 21
import org.openconcerto.sql.element.BaseSQLComponent;
22
import org.openconcerto.sql.element.SQLComponent;
80 ilm 23
import org.openconcerto.sql.model.SQLRowAccessor;
24
import org.openconcerto.sql.model.SQLTable;
18 ilm 25
import org.openconcerto.sql.sqlobject.ElementComboBox;
80 ilm 26
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
18 ilm 27
import org.openconcerto.ui.DefaultGridBagConstraints;
28
import org.openconcerto.ui.JDate;
29
 
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.util.ArrayList;
80 ilm 33
import java.util.Date;
18 ilm 34
import java.util.List;
35
 
36
import javax.swing.JLabel;
180 ilm 37
import javax.swing.JPanel;
18 ilm 38
import javax.swing.SwingConstants;
39
 
80 ilm 40
public class ChequeFournisseurSQLElement extends ChequeSQLElement {
18 ilm 41
 
42
    public ChequeFournisseurSQLElement() {
132 ilm 43
        super("CHEQUE_FOURNISSEUR", "un chéque fournisseur", "chéques fournisseurs à décaisser");
18 ilm 44
    }
45
 
46
    protected List<String> getListFields() {
47
        final List<String> l = new ArrayList<String>();
73 ilm 48
        l.add("ID_FOURNISSEUR");
49
        l.add("ETS");
50
        l.add("NUMERO");
51
        l.add("DATE");
18 ilm 52
        l.add("MONTANT");
53
        l.add("DATE_ACHAT");
54
        l.add("DATE_DECAISSE");
55
        l.add("DECAISSE");
56
        return l;
57
    }
58
 
59
    protected List<String> getComboFields() {
60
        final List<String> l = new ArrayList<String>();
61
        l.add("DATE_ACHAT");
62
        l.add("MONTANT");
63
        l.add("ID_FOURNISSEUR");
64
        return l;
65
    }
66
 
80 ilm 67
    @Override
68
    public String getDoneFieldName() {
69
        return "DECAISSE";
70
    }
71
 
72
    @Override
73
    public String getDateFieldName() {
74
        return "DATE_DECAISSE";
75
    }
76
 
77
    @Override
78
    public String getMinDateFieldName() {
79
        return "DATE_MIN_DECAISSE";
80
    }
81
 
82
    @Override
83
    public void print(List<Integer> listeCheque, boolean preview, Date d) {
84
        ReleveChequeEmisSheet sheet = new ReleveChequeEmisSheet(listeCheque);
85
        new SpreadSheetGeneratorCompta(sheet, "ReleveChequeEmis", false, true);
86
    }
87
 
88
    @Override
144 ilm 89
    public void handle(final SQLRowAccessor rowBanque, SQLRowAccessor rowCheque, Date d, String label) throws Exception {
80 ilm 90
        new GenerationMvtReglementChequeFourn(rowCheque.getForeignID("ID_MOUVEMENT"), rowCheque.getLong("MONTANT"), rowCheque.getID(), d);
91
    }
92
 
93
    @Override
94
    public SQLTableModelSourceOnline createDepositTableSource() {
95
        final List<String> l = new ArrayList<String>();
96
        l.add("MONTANT");
97
        // TYPE, NOM
98
        l.add("ID_FOURNISSEUR");
99
        l.add("ID_MOUVEMENT");
83 ilm 100
 
101
        l.add("ETS");
102
        l.add("NUMERO");
103
        l.add("DATE");
104
 
80 ilm 105
        l.add("DATE_ACHAT");
106
        l.add(getMinDateFieldName());
107
        l.add(getDoneFieldName());
108
 
109
        final ShowAs showAs = new ShowAs(getTable().getDBRoot());
110
        final SQLTable mvtT = getTable().getForeignTable("ID_MOUVEMENT");
111
        showAs.show(mvtT, "ID_PIECE");
112
        showAs.show(mvtT.getForeignTable("ID_PIECE"), "NOM");
113
        showAs.show(getTable().getForeignTable("ID_FOURNISSEUR"), "TYPE", "NOM");
114
 
115
        return this.createDepositTableSource(l, showAs, null);
116
    }
117
 
18 ilm 118
    /*
119
     * (non-Javadoc)
120
     *
121
     * @see org.openconcerto.devis.SQLElement#getComponent()
122
     */
123
    public SQLComponent createComponent() {
124
        return new BaseSQLComponent(this) {
125
 
126
            private DeviseField textMontant = new DeviseField();
127
 
128
            public void addViews() {
129
                this.setLayout(new GridBagLayout());
130
                final GridBagConstraints c = new DefaultGridBagConstraints();
131
 
132
                // Montant
180 ilm 133
                JLabel labelMontant = new JLabel("Montant", SwingConstants.RIGHT);
18 ilm 134
 
135
                this.add(labelMontant, c);
136
                c.gridx++;
137
                c.weightx = 1;
138
                this.add(this.textMontant, c);
139
 
140
                // Date
180 ilm 141
                JLabel labelDate = new JLabel("Date", SwingConstants.RIGHT);
18 ilm 142
                c.weightx = 0;
143
                c.gridx++;
144
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
145
                this.add(labelDate, c);
146
 
147
                JDate dateAchat = new JDate(true);
148
                c.gridx++;
149
                this.add(dateAchat, c);
150
 
151
                c.gridy++;
152
                c.gridx = 0;
180 ilm 153
                JLabel labelFournisseurNom = new JLabel("Fournisseur", SwingConstants.RIGHT);
18 ilm 154
                this.add(labelFournisseurNom, c);
155
 
156
                final ElementComboBox nomFournisseur = new ElementComboBox();
157
                c.gridx++;
180 ilm 158
                c.gridwidth = 3;
18 ilm 159
                this.add(nomFournisseur, c);
160
 
180 ilm 161
                JPanel spacer = new JPanel();
162
                spacer.setOpaque(false);
163
                c.weighty = 1;
164
                c.gridy++;
165
                this.add(spacer, c);
166
 
18 ilm 167
                this.addRequiredSQLObject(nomFournisseur, "ID_FOURNISSEUR");
168
                this.addRequiredSQLObject(this.textMontant, "MONTANT");
169
                this.addRequiredSQLObject(dateAchat, "DATE_ACHAT");
170
            }
171
        };
172
    }
57 ilm 173
 
174
    @Override
175
    protected String createCode() {
156 ilm 176
        return createCodeOfPackage() + ".cheque.supplier";
57 ilm 177
    }
18 ilm 178
}