OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 177
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.generationEcritures;
14
 package org.openconcerto.erp.generationEcritures;
15
 
15
 
16
import org.openconcerto.sql.model.DBRoot;
16
import org.openconcerto.sql.model.DBRoot;
17
import org.openconcerto.sql.model.SQLInsert;
17
import org.openconcerto.sql.model.SQLInsert;
18
import org.openconcerto.sql.model.SQLTable;
18
import org.openconcerto.sql.model.SQLTable;
-
 
19
import org.openconcerto.sql.users.User;
19
 
20
 
20
public class Compte {
21
public class Compte {
21
    private final Long id;
22
    private final Long id;
22
    private String numero;
23
    private String numero;
23
    private String nom;
24
    private String nom;
24
 
25
 
25
    public Compte(Long id, String numero, String nom) {
26
    public Compte(Long id, String numero, String nom) {
26
        this.id = id;
27
        this.id = id;
27
        this.numero = numero;
28
        this.numero = numero;
28
        this.nom = nom;
29
        this.nom = nom;
29
    }
30
    }
30
 
31
 
31
    public Long getId() {
32
    public Long getId() {
32
        return this.id;
33
        return this.id;
33
    }
34
    }
34
 
35
 
35
    public String getNumero() {
36
    public String getNumero() {
36
        return this.numero;
37
        return this.numero;
37
    }
38
    }
38
 
39
 
39
    public String getNom() {
40
    public String getNom() {
40
        return this.nom;
41
        return this.nom;
41
    }
42
    }
42
 
43
 
43
    @Override
44
    @Override
44
    public int hashCode() {
45
    public int hashCode() {
45
        return this.numero.hashCode();
46
        return this.numero.hashCode();
46
    }
47
    }
47
 
48
 
48
    @Override
49
    @Override
49
    public boolean equals(Object obj) {
50
    public boolean equals(Object obj) {
50
        if (obj == null)
51
        if (obj == null)
51
            return false;
52
            return false;
52
        if (this.getClass() != obj.getClass())
53
        if (this.getClass() != obj.getClass())
53
            return false;
54
            return false;
54
        return ((Compte) obj).numero.equalsIgnoreCase(this.numero);
55
        return ((Compte) obj).numero.equalsIgnoreCase(this.numero);
55
    }
56
    }
56
 
57
 
57
    SQLInsert createInsert(DBRoot root) {
58
    SQLInsert createInsert(DBRoot root, User user) {
58
        final SQLInsert insert = new SQLInsert();
59
        final SQLInsert insert = new SQLInsert();
59
        final SQLTable table = root.getTable("COMPTE_PCE");
60
        final SQLTable table = root.getTable("COMPTE_PCE");
60
        insert.add(table.getField("NUMERO"), this.numero);
61
        insert.add(table.getField("NUMERO"), this.numero);
61
        insert.add(table.getField("NOM"), this.nom);
62
        insert.add(table.getField("NOM"), this.nom);
-
 
63
        insert.addCreationTrackedField(user, table);
62
        return insert;
64
        return insert;
63
    }
65
    }
64
 
66
 
-
 
67
 
65
    @Override
68
    @Override
66
    public String toString() {
69
    public String toString() {
67
        return "Compte numero:" + this.numero + " " + this.nom + " (id:" + this.id + ")";
70
        return "Compte numero:" + this.numero + " " + this.nom + " (id:" + this.id + ")";
68
    }
71
    }
69
}
72
}