OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 90 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
90 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
 /*
15
 * Créé le 27 oct. 2014
16
 */
17
package org.openconcerto.erp.core.common.ui;
18
 
19
import org.openconcerto.erp.preferences.DefaultNXProps;
156 ilm 20
import org.openconcerto.erp.utils.TM;
90 ilm 21
import org.openconcerto.sql.model.SQLRowAccessor;
22
import org.openconcerto.ui.DefaultGridBagConstraints;
23
import org.openconcerto.ui.JLabelBold;
24
 
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
 
28
import javax.swing.JLabel;
29
import javax.swing.JPanel;
30
import javax.swing.JSeparator;
31
 
32
public class TotalCommandePanel extends JPanel {
33
 
34
    DeviseField textTotalHT, textTotalTVA, textTotalTTC, textPortHT, textRemiseHT, textService, textTotalHA, textTotalDevise, marge;
35
 
36
    public TotalCommandePanel() {
37
 
38
        super(new GridBagLayout());
39
        textTotalHT = new DeviseField();
40
        textTotalTVA = new DeviseField();
41
        textTotalTTC = new DeviseField();
42
        textPortHT = new DeviseField();
43
        textRemiseHT = new DeviseField();
44
        textService = new DeviseField();
45
        textTotalHA = new DeviseField();
46
        textTotalDevise = new DeviseField();
47
        marge = new DeviseField();
48
        GridBagConstraints c = new DefaultGridBagConstraints();
49
 
50
        c.gridheight = 1;
51
        c.weighty = 0;
52
        c.fill = GridBagConstraints.HORIZONTAL;
53
 
54
        // Global
55
        c.gridx = 3;
56
        c.gridy = 0;
57
        c.gridheight = GridBagConstraints.REMAINDER;
58
        c.weighty = 1;
59
        c.fill = GridBagConstraints.VERTICAL;
60
        c.weightx = 0;
61
        this.add(createSeparator(), c);
62
 
63
        c.gridheight = 1;
64
        c.fill = GridBagConstraints.HORIZONTAL;
65
        c.weighty = 0;
66
        c.gridx++;
156 ilm 67
        this.add(new JLabelBold(TM.tr("TotalPanel.global")), c); //$NON-NLS-1$
90 ilm 68
        c.gridy++;
69
        c.gridx = 4;
70
        c.gridwidth = 2;
71
        c.weightx = 1;
72
        this.add(createSeparator(), c);
73
        this.marge = new DeviseField();
74
        c.gridwidth = 1;
75
        c.weightx = 0;
76
 
77
        // Total HA HT
78
        c.gridy++;
156 ilm 79
        this.add(new JLabel(TM.tr("TotalPanel.purchaseTotal.taxExcluded")), c); //$NON-NLS-1$
90 ilm 80
 
81
        c.gridx++;
82
        c.weightx = 1;
83
        this.add(this.textTotalHA, c);
84
 
85
        // Marge
86
        c.gridy++;
87
        c.gridx = 4;
88
        c.weightx = 0;
156 ilm 89
        this.add(new JLabel(TM.tr("TotalPanel.margin")), c); //$NON-NLS-1$
90 ilm 90
 
91
        c.gridx++;
92
        c.weightx = 1;
93
        this.add(this.marge, c);
94
 
95
        c.gridy++;
96
        c.gridx = 4;
97
        c.gridwidth = 2;
98
        c.weightx = 1;
99
        this.add(createSeparator(), c);
100
 
101
        c.gridwidth = 1;
102
        c.weightx = 0;
103
 
104
        // Total HT
105
        c.gridy++;
106
        c.gridx = 4;
107
        c.weightx = 0;
156 ilm 108
        this.add(new JLabelBold(TM.tr("TotalPanel.total.taxExcluded")), c); //$NON-NLS-1$
90 ilm 109
 
110
        c.gridx++;
111
        c.weightx = 1;
112
        this.add(textTotalHT, c);
113
 
114
        if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SERVICE, false)) {
115
            // Service
116
            c.gridx = 4;
117
            c.gridy++;
118
            c.weightx = 0;
156 ilm 119
            this.add(new JLabelBold(TM.tr("TotalPanel.service.taxExcluded")), c); //$NON-NLS-1$
90 ilm 120
            c.gridx++;
121
            c.weightx = 1;
122
            this.add(this.textService, c);
123
        }
124
        // TVA
125
        c.gridx = 4;
126
        c.gridy++;
127
        c.weightx = 0;
156 ilm 128
        this.add(new JLabelBold(TM.tr("TotalPanel.total.VAT")), c); //$NON-NLS-1$
90 ilm 129
        c.gridx++;
130
        c.weightx = 1;
131
        this.add(textTotalTVA, c);
132
 
133
        // Sep
134
        c.gridwidth = 2;
135
        c.gridx = 4;
136
        c.gridy++;
137
        c.weightx = 1;
138
        c.fill = GridBagConstraints.BOTH;
139
        this.add(createSeparator(), c);
140
 
141
        // TTC
142
        c.gridwidth = 1;
143
        c.gridx = 4;
144
        c.gridy++;
145
        c.weightx = 0;
146
        c.fill = GridBagConstraints.HORIZONTAL;
156 ilm 147
        this.add(new JLabelBold(TM.tr("TotalPanel.total.taxIncluded")), c); //$NON-NLS-1$
90 ilm 148
        c.gridx++;
149
        c.weightx = 1;
150
        textTotalTTC.setFont(textTotalHT.getFont());
151
        this.add(textTotalTTC, c);
152
 
153
    }
154
 
155
    private final JSeparator createSeparator() {
156
        final JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
157
        DefaultGridBagConstraints.lockMinimumSize(sep);
158
        return sep;
159
    }
160
 
161
    public void loadFromCmd(SQLRowAccessor rowCmd) {
156 ilm 162
        this.textTotalHT.setValue(rowCmd.getLong("T_HT")); //$NON-NLS-1$
163
        this.textTotalTVA.setValue(rowCmd.getLong("T_TVA")); //$NON-NLS-1$
164
        this.textTotalTTC.setValue(rowCmd.getLong("T_TTC")); //$NON-NLS-1$
165
        this.textTotalHA.setValue(rowCmd.getLong("T_HA")); //$NON-NLS-1$
166
        this.marge.setValue(rowCmd.getLong("T_HT") - rowCmd.getLong("T_HA")); //$NON-NLS-1$ //$NON-NLS-2$
90 ilm 167
 
168
    }
169
}