OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
174 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.generationEcritures;
15
 
16
import org.openconcerto.sql.model.DBRoot;
17
import org.openconcerto.sql.model.SQLInsert;
18
import org.openconcerto.sql.model.SQLTable;
177 ilm 19
import org.openconcerto.sql.users.User;
174 ilm 20
 
21
public class Compte {
22
    private final Long id;
23
    private String numero;
24
    private String nom;
25
 
26
    public Compte(Long id, String numero, String nom) {
27
        this.id = id;
28
        this.numero = numero;
29
        this.nom = nom;
30
    }
31
 
32
    public Long getId() {
33
        return this.id;
34
    }
35
 
36
    public String getNumero() {
37
        return this.numero;
38
    }
39
 
40
    public String getNom() {
41
        return this.nom;
42
    }
43
 
44
    @Override
45
    public int hashCode() {
46
        return this.numero.hashCode();
47
    }
48
 
49
    @Override
50
    public boolean equals(Object obj) {
51
        if (obj == null)
52
            return false;
53
        if (this.getClass() != obj.getClass())
54
            return false;
55
        return ((Compte) obj).numero.equalsIgnoreCase(this.numero);
56
    }
57
 
177 ilm 58
    SQLInsert createInsert(DBRoot root, User user) {
174 ilm 59
        final SQLInsert insert = new SQLInsert();
60
        final SQLTable table = root.getTable("COMPTE_PCE");
61
        insert.add(table.getField("NUMERO"), this.numero);
62
        insert.add(table.getField("NOM"), this.nom);
177 ilm 63
        insert.addCreationTrackedField(user, table);
174 ilm 64
        return insert;
65
    }
66
 
177 ilm 67
 
174 ilm 68
    @Override
69
    public String toString() {
70
        return "Compte numero:" + this.numero + " " + this.nom + " (id:" + this.id + ")";
71
    }
72
}