OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 182
Line 1... Line 1...
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-2019 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.
Line 63... Line 63...
63
                line = bReader.readLine();
63
                line = bReader.readLine();
64
            }
64
            }
65
            line = bReader.readLine();
65
            line = bReader.readLine();
66
            while (line != null && !line.contains("#Section")) {
66
            while (line != null && !line.contains("#Section")) {
67
                final List<String> parts = StringUtils.fastSplit(line, '\t');
67
                final List<String> parts = StringUtils.fastSplit(line, '\t');
-
 
68
                if (parts.size() > 6) {
68
                final String journalCode = unquote(parts.get(1).trim());
69
                    final String journalCode = unquote(parts.get(1).trim());
69
                final Date ecritureDate = parseDate(unquote(parts.get(2).trim()));
70
                    final Date ecritureDate = parseDate(unquote(parts.get(2).trim()));
70
                final String compteNum = unquote(parts.get(3).trim());
71
                    final String compteNum = unquote(parts.get(3).trim());
71
                final String compteLib = unquote(parts.get(4).trim());
72
                    final String compteLib = unquote(parts.get(4).trim());
72
                final BigDecimal m = new BigDecimal(cleanMontant(parts.get(5)));
73
                    final BigDecimal m = new BigDecimal(cleanMontant(parts.get(5)));
Line 88... Line 89...
88
                Mouvement mouvement;
89
                    Mouvement mouvement;
89
                if (p == null) {
90
                    if (p == null) {
90
                    p = new Piece(pieceRef);
91
                        p = new Piece(pieceRef);
91
                    mouvement = new Mouvement();
92
                        mouvement = new Mouvement();
92
                    p.add(mouvement);
93
                        p.add(mouvement);
93
 
-
 
-
 
94
                        this.mapPiece.put(pieceRef, p);
94
                } else {
95
                    } else {
95
                    mouvement = p.getMouvements().get(0);
96
                        mouvement = p.getMouvements().get(0);
96
                }
97
                    }
97
                final Ecriture ecriture = new Ecriture(ecritureDate, debit, credit);
98
                    final Ecriture ecriture = new Ecriture(ecritureDate, debit, credit);
98
                ecriture.setNom(ecritureLib);
99
                    ecriture.setNom(ecritureLib);
Line 105... Line 106...
105
                ecriture.setJournal(journalCode, journal);
106
                    ecriture.setJournal(journalCode, journal);
106
                ecriture.setDateValidation(validDate);
107
                    ecriture.setDateValidation(validDate);
107
                if ("AN".equals(journalCode)) {
108
                    if ("AN".equals(journalCode)) {
108
                    ecriture.setaNouveau(true);
109
                        ecriture.setaNouveau(true);
109
                }
110
                    }
110
                mouvement.add(ecriture);
-
 
111
 
111
 
-
 
112
                    mouvement.add(ecriture);
-
 
113
                } else {
-
 
114
                    System.err.println("Ignoring : " + line);
-
 
115
                }
112
                // Next
116
                // Next
113
                line = bReader.readLine();
117
                line = bReader.readLine();
114
            }
118
            }
115
 
119
 
116
        }
120
        }
Line 174... Line 178...
174
    // return null is no error
178
    // return null is no error
175
    public String getError() {
179
    public String getError() {
176
        return this.error;
180
        return this.error;
177
    }
181
    }
178
 
182
 
-
 
183
    public List<Piece> getPieces() {
-
 
184
        return new ArrayList<Piece>(this.mapPiece.values());
-
 
185
    }
-
 
186
 
179
    public void importTo(SQLElementDirectory directory, DBRoot rootSociete, User user) throws SQLException {
187
    public void importTo(SQLElementDirectory directory, DBRoot rootSociete, User user) throws SQLException {
180
        Exercice e = new Exercice();
188
        Exercice e = new Exercice();
181
        e.insert(directory, rootSociete, user, new ArrayList<Piece>(this.mapPiece.values()));
189
        e.insert(directory, rootSociete, user, new ArrayList<Piece>(this.mapPiece.values()));
182
    }
190
    }
183
 
191
 
184
    public static void main(String[] args) throws IOException {
192
    public static void main(String[] args) throws IOException {
185
        ImportRImport i = new ImportRImport();
193
        ImportRImport i = new ImportRImport();
186
        i.loadFrom(new File("Y:\\Projets\\OpenConcerto\\ExportCiel\\RImport.txt"));
194
        i.loadFrom(new File("Y:\\Projets\\OpenConcerto\\ExportCiel\\RImport.txt"));
-
 
195
        System.err.println("ImportRImport.main() " + i.getPieces().size() + " pieces");
187
        System.err.println("ImportRImport.main()" + i.getError());
196
        System.err.println("ImportRImport.main()" + i.getError());
-
 
197
        for (Piece p : i.getPieces()) {
-
 
198
            System.err.println(p.getNom() + " " + p.getMouvements().size() + " mouvements");
-
 
199
            for (Mouvement m : p.getMouvements()) {
-
 
200
                System.err.println(m.asString());
-
 
201
            }
-
 
202
        }
-
 
203
 
188
    }
204
    }
189
 
205
 
190
}
206
}