18 |
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.injector;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.sql.model.DBRoot;
|
|
|
17 |
import org.openconcerto.sql.model.SQLInjector;
|
73 |
ilm |
18 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
19 |
import org.openconcerto.sql.model.SQLRowValues;
|
18 |
ilm |
20 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
21 |
|
73 |
ilm |
22 |
import java.math.BigDecimal;
|
|
|
23 |
import java.util.Collection;
|
|
|
24 |
|
18 |
ilm |
25 |
public class CommandeFactureClientSQLInjector extends SQLInjector {
|
|
|
26 |
public CommandeFactureClientSQLInjector(final DBRoot root) {
|
73 |
ilm |
27 |
super(root, "COMMANDE_CLIENT", "SAISIE_VENTE_FACTURE", true);
|
18 |
ilm |
28 |
final SQLTable tableCommande = getSource();
|
|
|
29 |
final SQLTable tableFacture = getDestination();
|
|
|
30 |
map(tableCommande.getField("ID_CLIENT"), tableFacture.getField("ID_CLIENT"));
|
|
|
31 |
map(tableCommande.getField("NOM"), tableFacture.getField("NOM"));
|
|
|
32 |
map(tableCommande.getField("INFOS"), tableFacture.getField("INFOS"));
|
73 |
ilm |
33 |
|
18 |
ilm |
34 |
}
|
73 |
ilm |
35 |
|
|
|
36 |
@Override
|
|
|
37 |
protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
|
|
|
38 |
super.merge(srcRow, rowVals);
|
|
|
39 |
|
|
|
40 |
// Merge elements
|
|
|
41 |
final SQLTable tableElementSource = getSource().getTable("COMMANDE_CLIENT_ELEMENT");
|
|
|
42 |
final SQLTable tableElementDestination = getSource().getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
43 |
final Collection<? extends SQLRowAccessor> myListItem = srcRow.asRow().getReferentRows(tableElementSource);
|
|
|
44 |
|
|
|
45 |
if (myListItem.size() != 0) {
|
|
|
46 |
final SQLInjector injector = SQLInjector.getInjector(tableElementSource, tableElementDestination);
|
|
|
47 |
for (SQLRowAccessor rowElt : myListItem) {
|
|
|
48 |
System.err.println("CommandeFactureClientSQLInjector.merge():" + rowElt);
|
|
|
49 |
final SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(rowElt.asRow());
|
|
|
50 |
if (createRowValuesFrom.getTable().getFieldsName().contains("POURCENT_ACOMPTE")) {
|
|
|
51 |
if (createRowValuesFrom.getObject("POURCENT_ACOMPTE") == null) {
|
|
|
52 |
createRowValuesFrom.put("POURCENT_ACOMPTE", new BigDecimal(100.0));
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
createRowValuesFrom.put("ID_SAISIE_VENTE_FACTURE", rowVals);
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
}
|
|
|
59 |
|
18 |
ilm |
60 |
}
|