67 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
185 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
67 |
ilm |
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.provider;
|
|
|
15 |
|
73 |
ilm |
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
67 |
ilm |
17 |
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
|
185 |
ilm |
18 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
73 |
ilm |
19 |
import org.openconcerto.sql.Configuration;
|
67 |
ilm |
20 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
21 |
import org.openconcerto.sql.model.SQLRowValues;
|
185 |
ilm |
22 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
151 |
ilm |
23 |
import org.openconcerto.utils.StringUtils;
|
67 |
ilm |
24 |
|
|
|
25 |
import java.util.Map;
|
|
|
26 |
|
|
|
27 |
public class SalesInvoiceAccountingRecordsProvider implements AccountingRecordsProvider {
|
|
|
28 |
|
|
|
29 |
@Override
|
|
|
30 |
public void putPieceLabel(SQLRowAccessor rowSource, SQLRowValues rowValsPiece) {
|
73 |
ilm |
31 |
rowValsPiece.put("NOM", rowSource.getString("NUMERO"));
|
67 |
ilm |
32 |
}
|
|
|
33 |
|
|
|
34 |
@Override
|
|
|
35 |
public void putLabel(SQLRowAccessor rowSource, Map<String, Object> values) {
|
|
|
36 |
String nom = "";
|
73 |
ilm |
37 |
|
|
|
38 |
|
|
|
39 |
Boolean acompte = rowSource.getBoolean("ACOMPTE");
|
|
|
40 |
if (acompte != null && acompte) {
|
|
|
41 |
nom = "Fact. acompte client" + rowSource.getObject("NUMERO").toString();
|
|
|
42 |
} else {
|
|
|
43 |
nom = "Fact. vente " + rowSource.getObject("NUMERO").toString();
|
|
|
44 |
}
|
185 |
ilm |
45 |
SQLRowAccessor modeRegl = rowSource.getForeign("ID_MODE_REGLEMENT");
|
|
|
46 |
final SQLRowAccessor typeRegRow = modeRegl.getForeign("ID_TYPE_REGLEMENT");
|
|
|
47 |
final SQLRowAccessor nonEmptyForeign = modeRegl.getNonEmptyForeign("ID_BANQUE");
|
|
|
48 |
if (nonEmptyForeign != null && nonEmptyForeign.getTable().contains("TYPE_CAISSE") && nonEmptyForeign.getBoolean("TYPE_CAISSE")) {
|
|
|
49 |
|
|
|
50 |
nom += " (" + typeRegRow.getString("NOM") + ") ";
|
|
|
51 |
}
|
|
|
52 |
|
151 |
ilm |
53 |
nom += " " + StringUtils.limitLength(rowSource.getForeign("ID_CLIENT").getString("NOM"), 20);
|
185 |
ilm |
54 |
|
|
|
55 |
if (SQLPreferences.getMemCached(rowSource.getTable().getDBRoot()).getBoolean(GestionCommercialeGlobalPreferencePanel.ECRITURE_FACTURE_REF_LIBELLE, false)) {
|
|
|
56 |
if (rowSource.getString("NOM") != null && rowSource.getString("NOM").trim().length() > 0)
|
|
|
57 |
nom += " " + StringUtils.limitLength(rowSource.getString("NOM"), 30);
|
|
|
58 |
}
|
|
|
59 |
|
67 |
ilm |
60 |
values.put("NOM", nom);
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public static void register() {
|
|
|
64 |
AccountingRecordsProviderManager.put(GenerationMvtSaisieVenteFacture.ID, new SalesInvoiceAccountingRecordsProvider());
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
}
|