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.sales.pos.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.sql.element.SQLComponent;
18
import org.openconcerto.sql.element.UISQLComponent;
144 ilm 19
import org.openconcerto.sql.model.SQLBase;
20
import org.openconcerto.sql.utils.PartialUniqueTrigger;
18 ilm 21
 
22
import java.util.ArrayList;
144 ilm 23
import java.util.Arrays;
18 ilm 24
import java.util.List;
25
 
26
import javax.swing.JTextField;
27
 
28
public class TicketCaisseSQLElement extends ComptaSQLConfElement {
29
 
144 ilm 30
    static public final String UNARCHIVED_WHERE = SQLBase.quoteIdentifier("ARCHIVE") + " = " + 0;
31
    static public final String DATE_WHERE = UNARCHIVED_WHERE + " and " + SQLBase.quoteIdentifier("FILE_HASH") + " is not null";
32
 
174 ilm 33
    // needed until H2 databases are upgraded to use JS code
144 ilm 34
    static public final class UniqueNumber_PartialUniqueTrigger extends PartialUniqueTrigger {
35
        public UniqueNumber_PartialUniqueTrigger() {
36
            super(Arrays.asList("NUMERO"), UNARCHIVED_WHERE);
37
        }
38
    }
39
 
174 ilm 40
    // needed until H2 databases are upgraded to use JS code
144 ilm 41
    static public final class UniqueDate_PartialUniqueTrigger extends PartialUniqueTrigger {
42
        public UniqueDate_PartialUniqueTrigger() {
43
            super(Arrays.asList("ID_CAISSE", "DATE"), DATE_WHERE);
44
        }
45
    }
46
 
18 ilm 47
    public TicketCaisseSQLElement() {
48
        super("TICKET_CAISSE", "un ticket de caisse", "tickets de caisses");
49
    }
50
 
51
    protected List<String> getListFields() {
52
        final List<String> l = new ArrayList<String>();
53
        l.add("NUMERO");
21 ilm 54
        l.add("DATE");
55
        l.add("ID_CAISSE");
56
        l.add("TOTAL_HT");
18 ilm 57
        l.add("TOTAL_TTC");
58
        return l;
59
    }
60
 
61
    protected List<String> getComboFields() {
62
        final List<String> l = new ArrayList<String>();
63
        l.add("NOM");
64
        return l;
65
    }
66
 
67
    /*
68
     * (non-Javadoc)
69
     *
70
     * @see org.openconcerto.devis.SQLElement#getComponent()
71
     */
72
    public SQLComponent createComponent() {
73
        return new UISQLComponent(this) {
74
            public void addViews() {
75
                this.addRequiredSQLObject(new JTextField(), "NOM", "right");
76
            }
77
        };
78
    }
57 ilm 79
 
80
    @Override
81
    protected String createCode() {
156 ilm 82
        return createCodeOfPackage() + ".ticket";
57 ilm 83
    }
18 ilm 84
}