OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Go to most recent revision | Details | 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;
19
 
20
public class Compte {
21
    private final Long id;
22
    private String numero;
23
    private String nom;
24
 
25
    public Compte(Long id, String numero, String nom) {
26
        this.id = id;
27
        this.numero = numero;
28
        this.nom = nom;
29
    }
30
 
31
    public Long getId() {
32
        return this.id;
33
    }
34
 
35
    public String getNumero() {
36
        return this.numero;
37
    }
38
 
39
    public String getNom() {
40
        return this.nom;
41
    }
42
 
43
    @Override
44
    public int hashCode() {
45
        return this.numero.hashCode();
46
    }
47
 
48
    @Override
49
    public boolean equals(Object obj) {
50
        if (obj == null)
51
            return false;
52
        if (this.getClass() != obj.getClass())
53
            return false;
54
        return ((Compte) obj).numero.equalsIgnoreCase(this.numero);
55
    }
56
 
57
    SQLInsert createInsert(DBRoot root) {
58
        final SQLInsert insert = new SQLInsert();
59
        final SQLTable table = root.getTable("COMPTE_PCE");
60
        insert.add(table.getField("NUMERO"), this.numero);
61
        insert.add(table.getField("NOM"), this.nom);
62
        return insert;
63
    }
64
 
65
    @Override
66
    public String toString() {
67
        return "Compte numero:" + this.numero + " " + this.nom + " (id:" + this.id + ")";
68
    }
69
}