OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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