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 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.
|
10 |
*
|
10 |
*
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.generationDoc;
|
14 |
package org.openconcerto.erp.generationDoc;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
17 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
17 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
18 |
import org.openconcerto.map.model.Ville;
|
18 |
import org.openconcerto.map.model.Ville;
|
19 |
import org.openconcerto.sql.Configuration;
|
19 |
import org.openconcerto.sql.Configuration;
|
20 |
import org.openconcerto.sql.element.SQLElement;
|
20 |
import org.openconcerto.sql.element.SQLElement;
|
21 |
import org.openconcerto.sql.model.SQLField;
|
21 |
import org.openconcerto.sql.model.SQLField;
|
22 |
import org.openconcerto.sql.model.SQLRow;
|
22 |
import org.openconcerto.sql.model.SQLRow;
|
23 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
23 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
24 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
24 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
25 |
import org.openconcerto.sql.model.SQLSelect;
|
25 |
import org.openconcerto.sql.model.SQLSelect;
|
26 |
import org.openconcerto.sql.model.SQLTable;
|
26 |
import org.openconcerto.sql.model.SQLTable;
|
27 |
import org.openconcerto.sql.model.Where;
|
27 |
import org.openconcerto.sql.model.Where;
|
28 |
import org.openconcerto.utils.DecimalUtils;
|
28 |
import org.openconcerto.utils.DecimalUtils;
|
29 |
import org.openconcerto.utils.GestionDevise;
|
29 |
import org.openconcerto.utils.GestionDevise;
|
30 |
import org.openconcerto.utils.Nombre;
|
30 |
import org.openconcerto.utils.Nombre;
|
31 |
import org.openconcerto.utils.StringUtils;
|
31 |
import org.openconcerto.utils.StringUtils;
|
32 |
import org.openconcerto.utils.Tuple2;
|
32 |
import org.openconcerto.utils.Tuple2;
|
33 |
|
33 |
|
34 |
import java.math.BigDecimal;
|
34 |
import java.math.BigDecimal;
|
35 |
import java.math.RoundingMode;
|
35 |
import java.math.RoundingMode;
|
36 |
import java.text.DateFormat;
|
36 |
import java.text.DateFormat;
|
37 |
import java.text.SimpleDateFormat;
|
37 |
import java.text.SimpleDateFormat;
|
38 |
import java.util.ArrayList;
|
38 |
import java.util.ArrayList;
|
39 |
import java.util.Arrays;
|
39 |
import java.util.Arrays;
|
40 |
import java.util.Calendar;
|
40 |
import java.util.Calendar;
|
41 |
import java.util.Collection;
|
41 |
import java.util.Collection;
|
42 |
import java.util.Date;
|
42 |
import java.util.Date;
|
43 |
import java.util.HashMap;
|
43 |
import java.util.HashMap;
|
44 |
import java.util.List;
|
44 |
import java.util.List;
|
45 |
import java.util.Map;
|
45 |
import java.util.Map;
|
46 |
|
46 |
|
47 |
import org.jdom2.Attribute;
|
47 |
import org.jdom2.Attribute;
|
48 |
import org.jdom2.Element;
|
48 |
import org.jdom2.Element;
|
49 |
|
49 |
|
50 |
public class OOXMLField extends OOXMLElement {
|
50 |
public class OOXMLField extends OOXMLElement {
|
51 |
|
51 |
|
52 |
private String op = "";
|
52 |
private String op = "";
|
53 |
|
53 |
|
54 |
public OOXMLField(Element eltField, SQLRowAccessor row, SQLElement sqlElt, int id, SQLRow rowLanguage, OOXMLCache cache) {
|
54 |
public OOXMLField(Element eltField, SQLRowAccessor row, SQLElement sqlElt, int id, SQLRow rowLanguage, OOXMLCache cache) {
|
55 |
super(eltField, sqlElt, id, rowLanguage, cache);
|
55 |
super(eltField, sqlElt, id, rowLanguage, cache);
|
56 |
|
56 |
|
57 |
String base = eltField.getAttributeValue("base");
|
57 |
String base = eltField.getAttributeValue("base");
|
58 |
this.op = eltField.getAttributeValue("op");
|
58 |
this.op = eltField.getAttributeValue("op");
|
59 |
|
59 |
|
60 |
this.row = row;
|
60 |
this.row = row;
|
61 |
if ((this.row == null || !this.row.getTable().getSchema().getName().equalsIgnoreCase("Common")) && base != null && base.equalsIgnoreCase("COMMON")) {
|
61 |
if ((this.row == null || !this.row.getTable().getSchema().getName().equalsIgnoreCase("Common")) && base != null && base.equalsIgnoreCase("COMMON")) {
|
62 |
this.row = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
|
62 |
this.row = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
|
63 |
}
|
63 |
}
|
64 |
if (this.row == null) {
|
64 |
if (this.row == null) {
|
65 |
this.row = sqlElt.getTable().getRow(id);
|
65 |
this.row = sqlElt.getTable().getRow(id);
|
66 |
}
|
66 |
}
|
67 |
|
67 |
|
68 |
}
|
68 |
}
|
69 |
|
69 |
|
70 |
/**
|
70 |
/**
|
71 |
* permet d'obtenir la valeur d'un élément field
|
71 |
* permet d'obtenir la valeur d'un élément field
|
72 |
*
|
72 |
*
|
73 |
* @param eltField
|
73 |
* @param eltField
|
74 |
* @param row
|
74 |
* @param row
|
75 |
* @param elt
|
75 |
* @param elt
|
76 |
* @param id
|
76 |
* @param id
|
77 |
* @return la valeur du composant
|
77 |
* @return la valeur du composant
|
78 |
*/
|
78 |
*/
|
79 |
public Object getValue() {
|
79 |
public Object getValue() {
|
80 |
if (this.row != null && !this.row.isUndefined()) {
|
80 |
if (this.row != null && !this.row.isUndefined()) {
|
81 |
|
81 |
|
82 |
// if
|
82 |
// if
|
83 |
// (this.row.getTable().getName().equalsIgnoreCase(this.elt.getAttributeValue("table")))
|
83 |
// (this.row.getTable().getName().equalsIgnoreCase(this.elt.getAttributeValue("table")))
|
84 |
// {
|
84 |
// {
|
85 |
String field = this.elt.getAttributeValue("name");
|
85 |
String field = this.elt.getAttributeValue("name");
|
86 |
|
86 |
|
- |
|
87 |
if (field != null && field.trim().length() > 0 && !this.row.getTable().contains(field)) {
|
- |
|
88 |
throw new InvalidTemplateException("Le champ " + field + " n'existe pas dans la table " + this.row.getTable().getName());
|
- |
|
89 |
}
|
87 |
final SQLField sqlField = (field == null || field.trim().length() == 0) ? null : this.row.getTable().getField(field);
|
90 |
final SQLField sqlField = (field == null || field.trim().length() == 0) ? null : this.row.getTable().getField(field);
|
88 |
boolean isForeignField = (sqlField == null) ? false : this.row.getTable().getForeignKeys().contains(sqlField);
|
91 |
boolean isForeignField = (sqlField == null) ? false : this.row.getTable().getForeignKeys().contains(sqlField);
|
89 |
|
92 |
|
90 |
// le champ est une clef etrangere, on recupere la valeur du sous composant
|
93 |
// le champ est une clef etrangere, on recupere la valeur du sous composant
|
91 |
if (isForeignField && this.elt.getChild("field") != null) {
|
94 |
if (isForeignField && this.elt.getChild("field") != null) {
|
92 |
|
95 |
|
93 |
String condField = this.elt.getAttributeValue("conditionField");
|
96 |
String condField = this.elt.getAttributeValue("conditionField");
|
94 |
|
97 |
|
95 |
if (condField != null && this.row.getTable().getField(condField).getType().getJavaType() == Boolean.class) {
|
98 |
if (condField != null && this.row.getTable().getField(condField).getType().getJavaType() == Boolean.class) {
|
96 |
final Boolean boolean1 = this.row.getBoolean(condField);
|
99 |
final Boolean boolean1 = this.row.getBoolean(condField);
|
97 |
if (!(boolean1 != null && boolean1)) {
|
100 |
if (!(boolean1 != null && boolean1)) {
|
98 |
return null;
|
101 |
return null;
|
99 |
}
|
102 |
}
|
100 |
}
|
103 |
}
|
101 |
|
104 |
|
102 |
SQLRowAccessor foreignRow = cache.getForeignRow(this.row, sqlField);
|
105 |
SQLRowAccessor foreignRow = cache.getForeignRow(this.row, sqlField);
|
103 |
if (foreignRow != null && foreignRow.getID() > 1) {
|
106 |
if (foreignRow != null && foreignRow.getID() > 1) {
|
104 |
final List<Element> children = this.elt.getChildren("field");
|
107 |
final List<Element> children = this.elt.getChildren("field");
|
105 |
if (children.size() > 1) {
|
108 |
if (children.size() > 1) {
|
106 |
if (isValid()) {
|
109 |
if (isValid()) {
|
107 |
|
110 |
|
108 |
String result = "";
|
111 |
String result = "";
|
109 |
for (Element ssComposant : children) {
|
112 |
for (Element ssComposant : children) {
|
110 |
OOXMLField childElt = new OOXMLField(ssComposant, foreignRow, this.sqlElt, this.id, this.rowLanguage, cache);
|
113 |
OOXMLField childElt = new OOXMLField(ssComposant, foreignRow, this.sqlElt, this.id, this.rowLanguage, cache);
|
111 |
final Object valueComposantO = childElt.getValue();
|
114 |
final Object valueComposantO = childElt.getValue();
|
112 |
result += (valueComposantO == null) ? "" : valueComposantO.toString() + " ";
|
115 |
result += (valueComposantO == null) ? "" : valueComposantO.toString() + " ";
|
113 |
}
|
116 |
}
|
114 |
String cellSize = this.elt.getAttributeValue("cellSize");
|
117 |
String cellSize = this.elt.getAttributeValue("cellSize");
|
115 |
if (cellSize != null && cellSize.trim().length() != 0) {
|
118 |
if (cellSize != null && cellSize.trim().length() != 0) {
|
116 |
result = splitStringCell(cellSize, result);
|
119 |
result = splitStringCell(cellSize, result);
|
117 |
}
|
120 |
}
|
118 |
return result.trim();
|
121 |
return result.trim();
|
119 |
} else {
|
122 |
} else {
|
120 |
return "";
|
123 |
return "";
|
121 |
}
|
124 |
}
|
122 |
} else {
|
125 |
} else {
|
123 |
if (isValid()) {
|
126 |
if (isValid()) {
|
124 |
OOXMLField childElt = new OOXMLField(this.elt.getChild("field"), foreignRow, this.sqlElt, this.id, this.rowLanguage, cache);
|
127 |
OOXMLField childElt = new OOXMLField(this.elt.getChild("field"), foreignRow, this.sqlElt, this.id, this.rowLanguage, cache);
|
125 |
return childElt.getValue();
|
128 |
return childElt.getValue();
|
126 |
} else {
|
129 |
} else {
|
127 |
return "";
|
130 |
return "";
|
128 |
}
|
131 |
}
|
129 |
}
|
132 |
}
|
130 |
} else {
|
133 |
} else {
|
131 |
return null;
|
134 |
return null;
|
132 |
}
|
135 |
}
|
133 |
} else {
|
136 |
} else {
|
134 |
|
137 |
|
135 |
// sinon on recupere directement la valeur
|
138 |
// sinon on recupere directement la valeur
|
136 |
|
139 |
|
137 |
String typeComp = this.elt.getAttributeValue("type");
|
140 |
String typeComp = this.elt.getAttributeValue("type");
|
138 |
if (this.op != null && this.op.trim().length() > 0 && !(typeComp != null && typeComp.trim().length() > 0 && typeComp.toLowerCase().startsWith("deviselettre"))) {
|
141 |
if (this.op != null && this.op.trim().length() > 0 && !(typeComp != null && typeComp.trim().length() > 0 && typeComp.toLowerCase().startsWith("deviselettre"))) {
|
139 |
String field2 = this.elt.getAttributeValue("name2");
|
142 |
String field2 = this.elt.getAttributeValue("name2");
|
- |
|
143 |
if (!this.row.getTable().contains(field)) {
|
- |
|
144 |
throw new InvalidTemplateException("Le champ " + field + " n'existe pas dans la table " + this.row.getTable().getName());
|
- |
|
145 |
}
|
140 |
Number o = (Number) this.row.getObject(field);
|
146 |
Number o = (Number) this.row.getObject(field);
|
141 |
|
147 |
|
142 |
Number o2;
|
148 |
Number o2;
|
143 |
if (field2 != null && field2.trim().length() > 0) {
|
149 |
if (field2 != null && field2.trim().length() > 0) {
|
- |
|
150 |
if (!this.row.getTable().contains(field2)) {
|
- |
|
151 |
throw new InvalidTemplateException("Le champ " + field2 + " n'existe pas dans la table " + this.row.getTable().getName());
|
- |
|
152 |
}
|
144 |
o2 = (Number) this.row.getObject(field2);
|
153 |
o2 = (Number) this.row.getObject(field2);
|
145 |
} else {
|
154 |
} else {
|
146 |
o2 = Double.parseDouble(this.elt.getAttributeValue("number"));
|
155 |
o2 = Double.parseDouble(this.elt.getAttributeValue("number"));
|
147 |
}
|
156 |
}
|
148 |
|
157 |
|
149 |
if (typeComp != null && typeComp.trim().length() > 0) {
|
158 |
if (typeComp != null && typeComp.trim().length() > 0) {
|
150 |
|
159 |
|
151 |
// Devise en Long transformée en double
|
160 |
// Devise en Long transformée en double
|
152 |
if (typeComp.equalsIgnoreCase("Devise")) {
|
161 |
if (typeComp.equalsIgnoreCase("Devise")) {
|
153 |
|
162 |
|
154 |
BigDecimal result = calcul(o, o2, this.op);
|
163 |
BigDecimal result = calcul(o, o2, this.op);
|
155 |
if (o != null && o.getClass().isAssignableFrom(Long.class)) {
|
164 |
if (o != null && o.getClass().isAssignableFrom(Long.class)) {
|
156 |
long resultLong = Math.round(result.doubleValue());
|
165 |
long resultLong = Math.round(result.doubleValue());
|
157 |
return Double.valueOf(GestionDevise.currencyToString(resultLong, false));
|
166 |
return Double.valueOf(GestionDevise.currencyToString(resultLong, false));
|
158 |
} else {
|
167 |
} else {
|
159 |
return result;
|
168 |
return result;
|
160 |
}
|
169 |
}
|
161 |
}
|
170 |
}
|
162 |
}
|
171 |
}
|
163 |
|
172 |
|
164 |
return calcul(o, o2, this.op);
|
173 |
return calcul(o, o2, this.op);
|
165 |
|
174 |
|
166 |
}
|
175 |
}
|
167 |
|
176 |
|
168 |
// Liste des valeurs à ne pas afficher
|
177 |
// Liste des valeurs à ne pas afficher
|
169 |
List<String> listOfExcludedValues = null;
|
178 |
List<String> listOfExcludedValues = null;
|
170 |
if (this.elt.getAttributeValue("valuesExpected") != null) {
|
179 |
if (this.elt.getAttributeValue("valuesExpected") != null) {
|
171 |
listOfExcludedValues = SQLRow.toList(this.elt.getAttributeValue("valuesExpected"));
|
180 |
listOfExcludedValues = SQLRow.toList(this.elt.getAttributeValue("valuesExpected"));
|
172 |
}
|
181 |
}
|
173 |
List<Element> excludeValue = this.elt.getChildren("exclude");
|
182 |
List<Element> excludeValue = this.elt.getChildren("exclude");
|
174 |
if (excludeValue != null && excludeValue.size() > 0) {
|
183 |
if (excludeValue != null && excludeValue.size() > 0) {
|
175 |
if (listOfExcludedValues == null) {
|
184 |
if (listOfExcludedValues == null) {
|
176 |
listOfExcludedValues = new ArrayList<String>();
|
185 |
listOfExcludedValues = new ArrayList<String>();
|
177 |
} else {
|
186 |
} else {
|
178 |
listOfExcludedValues = new ArrayList<String>(listOfExcludedValues);
|
187 |
listOfExcludedValues = new ArrayList<String>(listOfExcludedValues);
|
179 |
}
|
188 |
}
|
180 |
|
189 |
|
181 |
for (Element element : excludeValue) {
|
190 |
for (Element element : excludeValue) {
|
182 |
String attributeValue = element.getAttributeValue("value");
|
191 |
String attributeValue = element.getAttributeValue("value");
|
183 |
listOfExcludedValues.add(attributeValue);
|
192 |
listOfExcludedValues.add(attributeValue);
|
184 |
}
|
193 |
}
|
185 |
}
|
194 |
}
|
186 |
|
195 |
|
187 |
// Champ boolean
|
196 |
// Champ boolean
|
188 |
String condField = this.elt.getAttributeValue("conditionField");
|
197 |
String condField = this.elt.getAttributeValue("conditionField");
|
189 |
String condValue = this.elt.getAttributeValue("conditionExpValue");
|
198 |
String condValue = this.elt.getAttributeValue("conditionExpValue");
|
190 |
|
199 |
|
191 |
boolean bIsCondValid = condValue == null || !this.row.getObject(condField).toString().equalsIgnoreCase(condValue);
|
200 |
boolean bIsCondValid = condValue == null || !this.row.getObject(condField).toString().equalsIgnoreCase(condValue);
|
192 |
if (condValue == null) {
|
201 |
if (condValue == null) {
|
193 |
boolean bIsBooleanCondValid = false;
|
202 |
boolean bIsBooleanCondValid = false;
|
194 |
if (condField == null) {
|
203 |
if (condField == null) {
|
195 |
bIsBooleanCondValid = true;
|
204 |
bIsBooleanCondValid = true;
|
196 |
} else {
|
205 |
} else {
|
197 |
if (this.row.getTable().getField(condField).getType().getJavaType() == Boolean.class) {
|
206 |
if (this.row.getTable().getField(condField).getType().getJavaType() == Boolean.class) {
|
198 |
final Boolean boolean1 = this.row.getBoolean(condField);
|
207 |
final Boolean boolean1 = this.row.getBoolean(condField);
|
199 |
if (boolean1 != null && boolean1) {
|
208 |
if (boolean1 != null && boolean1) {
|
200 |
bIsBooleanCondValid = true;
|
209 |
bIsBooleanCondValid = true;
|
201 |
}
|
210 |
}
|
202 |
}
|
211 |
}
|
203 |
}
|
212 |
}
|
204 |
bIsCondValid = bIsCondValid && bIsBooleanCondValid;
|
213 |
bIsCondValid = bIsCondValid && bIsBooleanCondValid;
|
205 |
} else {
|
214 |
} else {
|
206 |
System.err.println();
|
215 |
System.err.println();
|
207 |
}
|
216 |
}
|
208 |
if (bIsCondValid) {
|
217 |
if (bIsCondValid) {
|
209 |
|
218 |
|
210 |
// Type du champ
|
219 |
// Type du champ
|
211 |
Object o = getSpecialValue(typeComp);
|
220 |
Object o = getSpecialValue(typeComp);
|
212 |
|
221 |
|
213 |
String stringValue;
|
222 |
String stringValue;
|
214 |
String scale = this.elt.getAttributeValue("decimalScale");
|
223 |
String scale = this.elt.getAttributeValue("decimalScale");
|
215 |
if (o != null) {
|
224 |
if (o != null) {
|
216 |
|
225 |
|
217 |
if (o != null && scale != null && scale.trim().length() > 0) {
|
226 |
if (o != null && scale != null && scale.trim().length() > 0) {
|
218 |
|
227 |
|
219 |
o = ((BigDecimal) o).setScale(Integer.valueOf(scale), RoundingMode.HALF_UP);
|
228 |
o = ((BigDecimal) o).setScale(Integer.valueOf(scale), RoundingMode.HALF_UP);
|
220 |
}
|
229 |
}
|
221 |
if (this.elt.getAttributeValue("upperCase") != null) {
|
230 |
if (this.elt.getAttributeValue("upperCase") != null) {
|
222 |
o = o.toString().toUpperCase();
|
231 |
o = o.toString().toUpperCase();
|
223 |
}
|
232 |
}
|
224 |
stringValue = o.toString();
|
233 |
stringValue = o.toString();
|
225 |
} else {
|
234 |
} else {
|
- |
|
235 |
if (!this.row.getTable().contains(field)) {
|
- |
|
236 |
throw new InvalidTemplateException("Le champ " + field + " n'existe pas dans la table " + this.row.getTable().getName());
|
- |
|
237 |
}
|
226 |
Object o2 = this.row.getObject(field);
|
238 |
Object o2 = this.row.getObject(field);
|
227 |
|
239 |
|
228 |
if (o2 != null && scale != null && scale.trim().length() > 0) {
|
240 |
if (o2 != null && scale != null && scale.trim().length() > 0) {
|
229 |
|
241 |
|
230 |
o2 = ((BigDecimal) o2).setScale(Integer.valueOf(scale), RoundingMode.HALF_UP);
|
242 |
o2 = ((BigDecimal) o2).setScale(Integer.valueOf(scale), RoundingMode.HALF_UP);
|
231 |
}
|
243 |
}
|
232 |
|
244 |
|
233 |
stringValue = (o2 == null) ? "" : o2.toString();
|
245 |
stringValue = (o2 == null) ? "" : o2.toString();
|
234 |
}
|
246 |
}
|
235 |
|
247 |
|
236 |
// on ne fait rien si le champ n'est pas à afficher
|
248 |
// on ne fait rien si le champ n'est pas à afficher
|
237 |
if (listOfExcludedValues == null || ((!listOfExcludedValues.contains(stringValue)) && stringValue.trim().length() > 0)) {
|
249 |
if (listOfExcludedValues == null || ((!listOfExcludedValues.contains(stringValue)) && stringValue.trim().length() > 0)) {
|
238 |
String prefix = this.elt.getAttributeValue("prefix");
|
250 |
String prefix = this.elt.getAttributeValue("prefix");
|
239 |
String suffix = this.elt.getAttributeValue("suffix");
|
251 |
String suffix = this.elt.getAttributeValue("suffix");
|
240 |
String display = this.elt.getAttributeValue("display");
|
252 |
String display = this.elt.getAttributeValue("display");
|
241 |
// FIXME attribut cellSize à mettre sur l'element
|
253 |
// FIXME attribut cellSize à mettre sur l'element
|
242 |
String cellSize = this.elt.getAttributeValue("cellSize");
|
254 |
String cellSize = this.elt.getAttributeValue("cellSize");
|
243 |
if (prefix != null || suffix != null) {
|
255 |
if (prefix != null || suffix != null) {
|
244 |
|
256 |
|
245 |
String result = "";
|
257 |
String result = "";
|
246 |
if (prefix != null) {
|
258 |
if (prefix != null) {
|
247 |
if (prefix.contains("#n")) {
|
259 |
if (prefix.contains("#n")) {
|
248 |
prefix = prefix.replaceAll("#n", "\n");
|
260 |
prefix = prefix.replaceAll("#n", "\n");
|
249 |
}
|
261 |
}
|
250 |
result += prefix;
|
262 |
result += prefix;
|
251 |
}
|
263 |
}
|
252 |
|
264 |
|
253 |
if (display == null || !display.equalsIgnoreCase("false")) {
|
265 |
if (display == null || !display.equalsIgnoreCase("false")) {
|
254 |
result += stringValue;
|
266 |
result += stringValue;
|
255 |
}
|
267 |
}
|
256 |
if (suffix != null) {
|
268 |
if (suffix != null) {
|
257 |
result += suffix;
|
269 |
result += suffix;
|
258 |
}
|
270 |
}
|
259 |
if (cellSize != null && cellSize.trim().length() != 0) {
|
271 |
if (cellSize != null && cellSize.trim().length() != 0) {
|
260 |
result = splitStringCell(cellSize, result);
|
272 |
result = splitStringCell(cellSize, result);
|
261 |
}
|
273 |
}
|
262 |
return result;
|
274 |
return result;
|
263 |
} else {
|
275 |
} else {
|
264 |
if (display == null || !display.equalsIgnoreCase("false")) {
|
276 |
if (display == null || !display.equalsIgnoreCase("false")) {
|
265 |
if (cellSize != null && cellSize.trim().length() != 0 && o != null) {
|
277 |
if (cellSize != null && cellSize.trim().length() != 0 && o != null) {
|
266 |
return splitStringCell(cellSize, o.toString());
|
278 |
return splitStringCell(cellSize, o.toString());
|
267 |
} else {
|
279 |
} else {
|
268 |
return (o == null) ? "" : o;
|
280 |
return (o == null) ? "" : o;
|
269 |
}
|
281 |
}
|
270 |
} else {
|
282 |
} else {
|
271 |
return "";
|
283 |
return "";
|
272 |
}
|
284 |
}
|
273 |
}
|
285 |
}
|
274 |
}
|
286 |
}
|
275 |
}
|
287 |
}
|
276 |
}
|
288 |
}
|
277 |
}
|
289 |
}
|
278 |
|
290 |
|
279 |
return null;
|
291 |
return null;
|
280 |
|
292 |
|
281 |
}
|
293 |
}
|
282 |
|
294 |
|
283 |
protected String splitStringCell(String cellSize, String result) {
|
295 |
protected String splitStringCell(String cellSize, String result) {
|
284 |
try {
|
296 |
try {
|
285 |
int nbCar = Integer.parseInt(cellSize);
|
297 |
int nbCar = Integer.parseInt(cellSize);
|
286 |
result = StringUtils.splitString(result, nbCar);
|
298 |
result = StringUtils.splitString(result, nbCar);
|
287 |
} catch (NumberFormatException e) {
|
299 |
} catch (NumberFormatException e) {
|
288 |
e.printStackTrace();
|
300 |
e.printStackTrace();
|
289 |
}
|
301 |
}
|
290 |
return result;
|
302 |
return result;
|
291 |
}
|
303 |
}
|
292 |
|
304 |
|
293 |
protected Object getSpecialValue(String typeComp) {
|
305 |
protected Object getSpecialValue(String typeComp) {
|
294 |
|
306 |
|
295 |
SpreadSheetCellValueProvider provider = SpreadSheetCellValueProviderManager.get(typeComp);
|
307 |
SpreadSheetCellValueProvider provider = SpreadSheetCellValueProviderManager.get(typeComp);
|
296 |
if (provider != null) {
|
308 |
if (provider != null) {
|
297 |
final SpreadSheetCellValueContext context = new SpreadSheetCellValueContext(this.row);
|
309 |
final SpreadSheetCellValueContext context = new SpreadSheetCellValueContext(this.row);
|
298 |
List<Attribute> attrs = this.elt.getAttributes();
|
310 |
List<Attribute> attrs = this.elt.getAttributes();
|
299 |
for (Attribute attr : attrs) {
|
311 |
for (Attribute attr : attrs) {
|
300 |
context.put(attr.getName(), attr.getValue());
|
312 |
context.put(attr.getName(), attr.getValue());
|
301 |
}
|
313 |
}
|
302 |
return provider.getValue(context);
|
314 |
return provider.getValue(context);
|
303 |
}
|
315 |
}
|
304 |
|
316 |
|
305 |
String field = this.elt.getAttributeValue("name");
|
317 |
String field = this.elt.getAttributeValue("name");
|
306 |
final Object result = this.row.getObject(field);
|
318 |
final Object result = this.row.getObject(field);
|
307 |
|
319 |
|
308 |
// Liste des valeurs à ne pas afficher
|
320 |
// Liste des valeurs à ne pas afficher
|
309 |
List<String> listOfExpectedValues = null;
|
321 |
List<String> listOfExpectedValues = null;
|
310 |
if (this.elt.getAttributeValue("valuesExpected") != null) {
|
322 |
if (this.elt.getAttributeValue("valuesExpected") != null) {
|
311 |
listOfExpectedValues = SQLRow.toList(this.elt.getAttributeValue("valuesExpected"));
|
323 |
listOfExpectedValues = SQLRow.toList(this.elt.getAttributeValue("valuesExpected"));
|
312 |
}
|
324 |
}
|
313 |
|
325 |
|
314 |
if (typeComp != null && typeComp.trim().length() > 0) {
|
326 |
if (typeComp != null && typeComp.trim().length() > 0) {
|
315 |
|
327 |
|
316 |
// Type spécial
|
328 |
// Type spécial
|
317 |
|
329 |
|
318 |
// Devise en Long transformée en double
|
330 |
// Devise en Long transformée en double
|
319 |
if (typeComp.equalsIgnoreCase("NumeroEcheance")) {
|
331 |
if (typeComp.equalsIgnoreCase("NumeroEcheance")) {
|
320 |
SQLSelect sel = new SQLSelect(this.row.getTable().getBase());
|
332 |
SQLSelect sel = new SQLSelect(this.row.getTable().getBase());
|
321 |
sel.addSelect(this.row.getTable().getKey(), "COUNT");
|
333 |
sel.addSelect(this.row.getTable().getKey(), "COUNT");
|
322 |
Where w = new Where(this.row.getTable().getField("DATE"), "<=", this.row.getDate("DATE").getTime());
|
334 |
Where w = new Where(this.row.getTable().getField("DATE"), "<=", this.row.getDate("DATE").getTime());
|
323 |
sel.setWhere(w);
|
335 |
sel.setWhere(w);
|
324 |
return this.row.getTable().getBase().getDataSource().executeScalar(sel.asString());
|
336 |
return this.row.getTable().getBase().getDataSource().executeScalar(sel.asString());
|
325 |
} else if (typeComp.equalsIgnoreCase("Devise")) {
|
337 |
} else if (typeComp.equalsIgnoreCase("Devise")) {
|
326 |
if (result == null) {
|
338 |
if (result == null) {
|
327 |
return "";
|
339 |
return "";
|
328 |
}
|
340 |
}
|
329 |
Number prix = (Number) result;
|
341 |
Number prix = (Number) result;
|
330 |
if (listOfExpectedValues != null) {
|
342 |
if (listOfExpectedValues != null) {
|
331 |
for (String string : listOfExpectedValues) {
|
343 |
for (String string : listOfExpectedValues) {
|
332 |
Long l = Long.parseLong(string);
|
344 |
Long l = Long.parseLong(string);
|
333 |
if (l.longValue() == prix.longValue()) {
|
345 |
if (l.longValue() == prix.longValue()) {
|
334 |
return "";
|
346 |
return "";
|
335 |
}
|
347 |
}
|
336 |
}
|
348 |
}
|
337 |
}
|
349 |
}
|
338 |
if (result instanceof Long) {
|
350 |
if (result instanceof Long) {
|
339 |
return new Double(GestionDevise.currencyToString(prix.longValue(), false));
|
351 |
return new Double(GestionDevise.currencyToString(prix.longValue(), false));
|
340 |
} else {
|
352 |
} else {
|
341 |
String scale = this.elt.getAttributeValue("decimalScale");
|
353 |
String scale = this.elt.getAttributeValue("decimalScale");
|
342 |
|
354 |
|
343 |
if (result != null && scale != null && scale.trim().length() > 0) {
|
355 |
if (result != null && scale != null && scale.trim().length() > 0) {
|
344 |
|
356 |
|
345 |
return ((BigDecimal) result).setScale(Integer.valueOf(scale), RoundingMode.HALF_UP);
|
357 |
return ((BigDecimal) result).setScale(Integer.valueOf(scale), RoundingMode.HALF_UP);
|
346 |
}
|
358 |
}
|
347 |
|
359 |
|
348 |
return result;
|
360 |
return result;
|
349 |
}
|
361 |
}
|
350 |
} else if (typeComp.equalsIgnoreCase("cumulPaye")) {
|
362 |
} else if (typeComp.equalsIgnoreCase("cumulPaye")) {
|
351 |
assertNonNull(typeComp, result, field, this.row);
|
363 |
assertNonNull(typeComp, result, field, this.row);
|
352 |
double val = ((Number) result).doubleValue();
|
364 |
double val = ((Number) result).doubleValue();
|
353 |
double valC;
|
365 |
double valC;
|
354 |
if (this.row.getTable().getFieldsName().contains("ID_CUMULS_PAYE")) {
|
366 |
if (this.row.getTable().getFieldsName().contains("ID_CUMULS_PAYE")) {
|
355 |
valC = ((Number) this.row.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
|
367 |
valC = ((Number) this.row.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
|
356 |
} else {
|
368 |
} else {
|
357 |
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
|
369 |
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
|
358 |
valC = ((Number) refRow.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
|
370 |
valC = ((Number) refRow.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
|
359 |
}
|
371 |
}
|
360 |
return new Double(val + valC);
|
372 |
return new Double(val + valC);
|
361 |
} else if (typeComp.equalsIgnoreCase("cumulConges")) {
|
373 |
} else if (typeComp.equalsIgnoreCase("cumulConges")) {
|
362 |
assertNonNull(typeComp, result, field, this.row);
|
374 |
assertNonNull(typeComp, result, field, this.row);
|
363 |
double val = ((Number) result).doubleValue();
|
375 |
double val = ((Number) result).doubleValue();
|
364 |
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
|
376 |
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
|
365 |
double valC = ((Number) refRow.getObject("CONGES_ACQUIS")).doubleValue();
|
377 |
double valC = ((Number) refRow.getObject("CONGES_ACQUIS")).doubleValue();
|
366 |
return new Double(val + valC);
|
378 |
return new Double(val + valC);
|
367 |
} else if (typeComp.equalsIgnoreCase("globalAcompte")) {
|
379 |
} else if (typeComp.equalsIgnoreCase("globalAcompte")) {
|
368 |
assertNonNull(typeComp, result, field, this.row);
|
380 |
assertNonNull(typeComp, result, field, this.row);
|
369 |
Long prix = (Long) result;
|
381 |
Long prix = (Long) result;
|
370 |
int pourcent = this.row.getInt("POURCENT_ACOMPTE");
|
382 |
int pourcent = this.row.getInt("POURCENT_ACOMPTE");
|
371 |
long l = Math.round(prix.longValue() / (pourcent / 100.0));
|
383 |
long l = Math.round(prix.longValue() / (pourcent / 100.0));
|
372 |
return new Double(GestionDevise.currencyToString(l, false));
|
384 |
return new Double(GestionDevise.currencyToString(l, false));
|
373 |
} else if (typeComp.equalsIgnoreCase("DatePaye")) {
|
385 |
} else if (typeComp.equalsIgnoreCase("DatePaye")) {
|
374 |
|
386 |
|
375 |
SQLRowAccessor rowRegl = row.getForeign("ID_REGLEMENT_PAYE");
|
387 |
SQLRowAccessor rowRegl = row.getForeign("ID_REGLEMENT_PAYE");
|
376 |
Calendar c = Calendar.getInstance();
|
388 |
Calendar c = Calendar.getInstance();
|
377 |
|
389 |
|
378 |
c.set(Calendar.MONTH, this.row.getInt("ID_MOIS") - 2);
|
390 |
c.set(Calendar.MONTH, this.row.getInt("ID_MOIS") - 2);
|
379 |
c.set(Calendar.YEAR, Integer.parseInt(this.row.getString("ANNEE")));
|
391 |
c.set(Calendar.YEAR, Integer.parseInt(this.row.getString("ANNEE")));
|
380 |
|
392 |
|
381 |
if (rowRegl.getInt("LE") != 31) {
|
393 |
if (rowRegl.getInt("LE") != 31) {
|
382 |
|
394 |
|
383 |
c.set(Calendar.MONTH, c.get(Calendar.MONTH) + 1);
|
395 |
c.set(Calendar.MONTH, c.get(Calendar.MONTH) + 1);
|
384 |
}
|
396 |
}
|
385 |
|
397 |
|
386 |
int max = c.getActualMaximum(Calendar.DAY_OF_MONTH);
|
398 |
int max = c.getActualMaximum(Calendar.DAY_OF_MONTH);
|
387 |
int day = Math.min(rowRegl.getInt("LE"), max);
|
399 |
int day = Math.min(rowRegl.getInt("LE"), max);
|
388 |
|
400 |
|
389 |
c.set(Calendar.DAY_OF_MONTH, day);
|
401 |
c.set(Calendar.DAY_OF_MONTH, day);
|
390 |
return c.getTime();
|
402 |
return c.getTime();
|
391 |
} else if (typeComp.equalsIgnoreCase("CumulPrec")) {
|
403 |
} else if (typeComp.equalsIgnoreCase("CumulPrec")) {
|
392 |
|
404 |
|
393 |
final long cumulPrecedent = getCumulPrecedent(this.row);
|
405 |
final long cumulPrecedent = getCumulPrecedent(this.row);
|
394 |
return new Double(GestionDevise.currencyToString(cumulPrecedent, false));
|
406 |
return new Double(GestionDevise.currencyToString(cumulPrecedent, false));
|
395 |
} else if (typeComp.equalsIgnoreCase("DeviseLettre")) {
|
407 |
} else if (typeComp.equalsIgnoreCase("DeviseLettre")) {
|
396 |
assertNonNull(typeComp, result, field, this.row);
|
408 |
assertNonNull(typeComp, result, field, this.row);
|
397 |
// Devise exprimée en lettre
|
409 |
// Devise exprimée en lettre
|
398 |
Long prix = (Long) result;
|
410 |
Long prix = (Long) result;
|
399 |
String deviseLabel = this.elt.getAttributeValue("deviseLabel");
|
411 |
String deviseLabel = this.elt.getAttributeValue("deviseLabel");
|
400 |
if (deviseLabel == null || deviseLabel.trim().length() == 0) {
|
412 |
if (deviseLabel == null || deviseLabel.trim().length() == 0) {
|
401 |
deviseLabel = " euros";
|
413 |
deviseLabel = " euros";
|
402 |
}
|
414 |
}
|
403 |
String deviseCentLabel = this.elt.getAttributeValue("deviseCentLabel");
|
415 |
String deviseCentLabel = this.elt.getAttributeValue("deviseCentLabel");
|
404 |
if (deviseCentLabel == null || deviseCentLabel.trim().length() == 0) {
|
416 |
if (deviseCentLabel == null || deviseCentLabel.trim().length() == 0) {
|
405 |
deviseCentLabel = " cents";
|
417 |
deviseCentLabel = " cents";
|
406 |
}
|
418 |
}
|
407 |
return getLettreFromDevise(prix.longValue(), Nombre.FR, Tuple2.create(deviseLabel, deviseCentLabel));
|
419 |
return getLettreFromDevise(prix.longValue(), Nombre.FR, Tuple2.create(deviseLabel, deviseCentLabel));
|
408 |
} else if (typeComp.equalsIgnoreCase("DeviseLettreEng")) {
|
420 |
} else if (typeComp.equalsIgnoreCase("DeviseLettreEng")) {
|
409 |
assertNonNull(typeComp, result, field, this.row);
|
421 |
assertNonNull(typeComp, result, field, this.row);
|
410 |
Long prix = (Long) result;
|
422 |
Long prix = (Long) result;
|
411 |
return getDeviseLettre(prix, Nombre.EN);
|
423 |
return getDeviseLettre(prix, Nombre.EN);
|
412 |
} else if (typeComp.equalsIgnoreCase("DeviseLettrePL")) {
|
424 |
} else if (typeComp.equalsIgnoreCase("DeviseLettrePL")) {
|
413 |
assertNonNull(typeComp, result, field, this.row);
|
425 |
assertNonNull(typeComp, result, field, this.row);
|
414 |
Long prix = (Long) result;
|
426 |
Long prix = (Long) result;
|
415 |
return getDeviseLettre(prix, Nombre.PL);
|
427 |
return getDeviseLettre(prix, Nombre.PL);
|
416 |
} else if (typeComp.equalsIgnoreCase("DeviseLettreES")) {
|
428 |
} else if (typeComp.equalsIgnoreCase("DeviseLettreES")) {
|
417 |
assertNonNull(typeComp, result, field, this.row);
|
429 |
assertNonNull(typeComp, result, field, this.row);
|
418 |
Long prix = (Long) result;
|
430 |
Long prix = (Long) result;
|
419 |
return getDeviseLettre(prix, Nombre.ES);
|
431 |
return getDeviseLettre(prix, Nombre.ES);
|
420 |
} else if (typeComp.equalsIgnoreCase("VilleFull")) {
|
432 |
} else if (typeComp.equalsIgnoreCase("VilleFull")) {
|
421 |
return this.row.getString("CODE_POSTAL") + " " + this.row.getString("VILLE");
|
433 |
return this.row.getString("CODE_POSTAL") + " " + this.row.getString("VILLE");
|
422 |
} else if (typeComp.equalsIgnoreCase("Ville")) {
|
434 |
} else if (typeComp.equalsIgnoreCase("Ville")) {
|
423 |
String stringValue = (result == null) ? "" : result.toString();
|
435 |
String stringValue = (result == null) ? "" : result.toString();
|
424 |
return stringValue;
|
436 |
return stringValue;
|
425 |
} else if (typeComp.equalsIgnoreCase("Traduction")) {
|
437 |
} else if (typeComp.equalsIgnoreCase("Traduction")) {
|
426 |
return getTraduction();
|
438 |
return getTraduction();
|
427 |
} else if (typeComp.equalsIgnoreCase("VilleCP")) {
|
439 |
} else if (typeComp.equalsIgnoreCase("VilleCP")) {
|
428 |
if (this.row.getTable().contains("CODE_POSTAL")) {
|
440 |
if (this.row.getTable().contains("CODE_POSTAL")) {
|
429 |
// Code postal de la ville
|
441 |
// Code postal de la ville
|
430 |
return this.row.getString("CODE_POSTAL");
|
442 |
return this.row.getString("CODE_POSTAL");
|
431 |
} else {
|
443 |
} else {
|
432 |
Ville v = Ville.getVilleFromVilleEtCode(this.row.getString(field));
|
444 |
Ville v = Ville.getVilleFromVilleEtCode(this.row.getString(field));
|
433 |
if (v != null) {
|
445 |
if (v != null) {
|
434 |
return v.getCodepostal();
|
446 |
return v.getCodepostal();
|
435 |
}
|
447 |
}
|
436 |
return null;
|
448 |
return null;
|
437 |
}
|
449 |
}
|
438 |
} else if (typeComp.equalsIgnoreCase("DateEcheance")) {
|
450 |
} else if (typeComp.equalsIgnoreCase("DateEcheance")) {
|
439 |
// Retourne la date d'échéance
|
451 |
// Retourne la date d'échéance
|
440 |
int idModeReglement = this.row.getInt("ID_MODE_REGLEMENT");
|
452 |
int idModeReglement = this.row.getInt("ID_MODE_REGLEMENT");
|
441 |
Date d = (Date) this.row.getObject("DATE");
|
453 |
Date d = (Date) this.row.getObject("DATE");
|
442 |
return getDateEcheance(idModeReglement, d, this.elt.getAttributeValue("datePattern"));
|
454 |
return getDateEcheance(idModeReglement, d, this.elt.getAttributeValue("datePattern"));
|
443 |
} else if (typeComp.equalsIgnoreCase("Jour")) {
|
455 |
} else if (typeComp.equalsIgnoreCase("Jour")) {
|
444 |
int day = this.row.getInt(field);
|
456 |
int day = this.row.getInt(field);
|
445 |
String stringValue = "le " + String.valueOf(day);
|
457 |
String stringValue = "le " + String.valueOf(day);
|
446 |
if (day == 31) {
|
458 |
if (day == 31) {
|
447 |
return "fin de mois";
|
459 |
return "fin de mois";
|
448 |
} else if (day == 0) {
|
460 |
} else if (day == 0) {
|
449 |
return "Date de facture";
|
461 |
return "Date de facture";
|
450 |
} else {
|
462 |
} else {
|
451 |
return stringValue;
|
463 |
return stringValue;
|
452 |
}
|
464 |
}
|
453 |
} else if (typeComp.equalsIgnoreCase("Date")) {
|
465 |
} else if (typeComp.equalsIgnoreCase("Date")) {
|
454 |
|
466 |
|
455 |
String datePattern = this.elt.getAttributeValue("datePattern");
|
467 |
String datePattern = this.elt.getAttributeValue("datePattern");
|
456 |
if (datePattern == null || datePattern.trim().length() == 0) {
|
468 |
if (datePattern == null || datePattern.trim().length() == 0) {
|
457 |
datePattern = "dd/MM/yyyy";
|
469 |
datePattern = "dd/MM/yyyy";
|
458 |
}
|
470 |
}
|
459 |
SimpleDateFormat format = new SimpleDateFormat(datePattern);
|
471 |
SimpleDateFormat format = new SimpleDateFormat(datePattern);
|
460 |
if (result != null) {
|
472 |
if (result != null) {
|
461 |
Date d = (Date) result;
|
473 |
Date d = (Date) result;
|
462 |
return format.format(d);
|
474 |
return format.format(d);
|
463 |
} else {
|
475 |
} else {
|
464 |
return "";
|
476 |
return "";
|
465 |
}
|
477 |
}
|
466 |
} else if (typeComp.equalsIgnoreCase("initiale")) {
|
478 |
} else if (typeComp.equalsIgnoreCase("initiale")) {
|
467 |
String stringValue = (result == null) ? "" : result.toString();
|
479 |
String stringValue = (result == null) ? "" : result.toString();
|
468 |
if (stringValue.trim().length() > 0) {
|
480 |
if (stringValue.trim().length() > 0) {
|
469 |
stringValue = String.valueOf(stringValue.charAt(0));
|
481 |
stringValue = String.valueOf(stringValue.charAt(0));
|
470 |
}
|
482 |
}
|
471 |
return stringValue;
|
483 |
return stringValue;
|
472 |
} else if (typeComp.equalsIgnoreCase("initiale2")) {
|
484 |
} else if (typeComp.equalsIgnoreCase("initiale2")) {
|
473 |
String stringValue = (result == null) ? "" : result.toString();
|
485 |
String stringValue = (result == null) ? "" : result.toString();
|
474 |
if (stringValue.trim().length() > 0) {
|
486 |
if (stringValue.trim().length() > 0) {
|
475 |
stringValue = String.valueOf(stringValue.substring(0, 2));
|
487 |
stringValue = String.valueOf(stringValue.substring(0, 2));
|
476 |
}
|
488 |
}
|
477 |
return stringValue;
|
489 |
return stringValue;
|
478 |
}
|
490 |
}
|
479 |
|
491 |
|
480 |
}
|
492 |
}
|
481 |
|
493 |
|
482 |
return (result == null) ? "" : result;
|
494 |
return (result == null) ? "" : result;
|
483 |
}
|
495 |
}
|
484 |
|
496 |
|
485 |
private void assertNonNull(String type, Object result, String field, SQLRowAccessor row) {
|
497 |
private void assertNonNull(String type, Object result, String field, SQLRowAccessor row) {
|
486 |
if (result == null) {
|
498 |
if (result == null) {
|
487 |
throw new IllegalArgumentException("null value for " + type + " for field " + field + " in row : " + row.asRowValues().toString());
|
499 |
throw new IllegalArgumentException("null value for " + type + " for field " + field + " in row : " + row.asRowValues().toString());
|
488 |
}
|
500 |
}
|
489 |
}
|
501 |
}
|
490 |
|
502 |
|
491 |
private Object getDeviseLettre(Long prix, int country) {
|
503 |
private Object getDeviseLettre(Long prix, int country) {
|
492 |
String deviseLabel = this.elt.getAttributeValue("deviseLabel");
|
504 |
String deviseLabel = this.elt.getAttributeValue("deviseLabel");
|
493 |
if (deviseLabel == null || deviseLabel.trim().length() == 0) {
|
505 |
if (deviseLabel == null || deviseLabel.trim().length() == 0) {
|
494 |
deviseLabel = " euros";
|
506 |
deviseLabel = " euros";
|
495 |
}
|
507 |
}
|
496 |
String deviseCentLabel = this.elt.getAttributeValue("deviseCentLabel");
|
508 |
String deviseCentLabel = this.elt.getAttributeValue("deviseCentLabel");
|
497 |
if (deviseCentLabel == null || deviseCentLabel.trim().length() == 0) {
|
509 |
if (deviseCentLabel == null || deviseCentLabel.trim().length() == 0) {
|
498 |
deviseCentLabel = " centimes";
|
510 |
deviseCentLabel = " centimes";
|
499 |
}
|
511 |
}
|
500 |
Tuple2<String, String> defaultTuple = Tuple2.create(deviseLabel, deviseCentLabel);
|
512 |
Tuple2<String, String> defaultTuple = Tuple2.create(deviseLabel, deviseCentLabel);
|
501 |
// Devise exprimée en lettre
|
513 |
// Devise exprimée en lettre
|
502 |
|
514 |
|
503 |
SQLRowAccessor tarif = this.row.getForeign("ID_TARIF");
|
515 |
SQLRowAccessor tarif = this.row.getForeign("ID_TARIF");
|
504 |
if (tarif.isUndefined()) {
|
516 |
if (tarif.isUndefined()) {
|
505 |
return getLettreFromDevise(prix.longValue(), country, defaultTuple);
|
517 |
return getLettreFromDevise(prix.longValue(), country, defaultTuple);
|
506 |
} else {
|
518 |
} else {
|
507 |
SQLRowAccessor rowDevise = tarif.getForeign("ID_DEVISE");
|
519 |
SQLRowAccessor rowDevise = tarif.getForeign("ID_DEVISE");
|
508 |
if (rowDevise.isUndefined()) {
|
520 |
if (rowDevise.isUndefined()) {
|
509 |
return getLettreFromDevise(prix.longValue(), country, defaultTuple);
|
521 |
return getLettreFromDevise(prix.longValue(), country, defaultTuple);
|
510 |
} else {
|
522 |
} else {
|
511 |
return getLettreFromDevise(prix.longValue(), country, Tuple2.create(" " + rowDevise.getString("LIBELLE") + " ", " " + rowDevise.getString("LIBELLE_CENT") + " "));
|
523 |
return getLettreFromDevise(prix.longValue(), country, Tuple2.create(" " + rowDevise.getString("LIBELLE") + " ", " " + rowDevise.getString("LIBELLE_CENT") + " "));
|
512 |
}
|
524 |
}
|
513 |
}
|
525 |
}
|
514 |
}
|
526 |
}
|
515 |
|
527 |
|
516 |
private Object getTraduction() {
|
528 |
private Object getTraduction() {
|
517 |
if (this.rowLanguage == null || this.rowLanguage.isUndefined()) {
|
529 |
if (this.rowLanguage == null || this.rowLanguage.isUndefined()) {
|
518 |
return null;
|
530 |
return null;
|
519 |
}
|
531 |
}
|
520 |
int id = ReferenceArticleSQLElement.getIdForCNM(row.asRowValues(), false);
|
532 |
int id = ReferenceArticleSQLElement.getIdForCNM(row.asRowValues(), false);
|
521 |
SQLTable table = Configuration.getInstance().getBase().getTable("ARTICLE_DESIGNATION");
|
533 |
SQLTable table = Configuration.getInstance().getBase().getTable("ARTICLE_DESIGNATION");
|
522 |
SQLSelect sel = new SQLSelect(table.getBase());
|
534 |
SQLSelect sel = new SQLSelect(table.getBase());
|
523 |
sel.addSelectStar(table);
|
535 |
sel.addSelectStar(table);
|
524 |
Where w = new Where(table.getField("ID_ARTICLE"), "=", id);
|
536 |
Where w = new Where(table.getField("ID_ARTICLE"), "=", id);
|
525 |
w = w.and(new Where(table.getField("ID_LANGUE"), "=", this.rowLanguage.getID()));
|
537 |
w = w.and(new Where(table.getField("ID_LANGUE"), "=", this.rowLanguage.getID()));
|
526 |
sel.setWhere(w);
|
538 |
sel.setWhere(w);
|
527 |
List<SQLRow> rows = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
|
539 |
List<SQLRow> rows = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
|
528 |
if (rows != null && rows.size() > 0) {
|
540 |
if (rows != null && rows.size() > 0) {
|
529 |
return rows.get(0).getString(this.elt.getAttributeValue("name"));
|
541 |
return rows.get(0).getString(this.elt.getAttributeValue("name"));
|
530 |
} else {
|
542 |
} else {
|
531 |
return this.row.getObject(this.elt.getAttributeValue("name"));
|
543 |
return this.row.getObject(this.elt.getAttributeValue("name"));
|
532 |
}
|
544 |
}
|
533 |
}
|
545 |
}
|
534 |
|
546 |
|
535 |
public boolean isValid() {
|
547 |
public boolean isValid() {
|
536 |
String condField = this.elt.getAttributeValue("conditionField");
|
548 |
String condField = this.elt.getAttributeValue("conditionField");
|
537 |
String condValue = this.elt.getAttributeValue("conditionExpValue");
|
549 |
String condValue = this.elt.getAttributeValue("conditionExpValue");
|
538 |
boolean bIsBooleanCondValid = condField == null || this.row.getTable().getField(condField).getType().getJavaType() == Boolean.class && this.row.getBoolean(condField);
|
550 |
boolean bIsBooleanCondValid = condField == null || this.row.getTable().getField(condField).getType().getJavaType() == Boolean.class && this.row.getBoolean(condField);
|
539 |
boolean bIsCondValid = condValue == null || this.row.getObject(condField).toString().equalsIgnoreCase(condValue);
|
551 |
boolean bIsCondValid = condValue == null || this.row.getObject(condField).toString().equalsIgnoreCase(condValue);
|
540 |
return bIsBooleanCondValid || !bIsCondValid;
|
552 |
return bIsBooleanCondValid || !bIsCondValid;
|
541 |
}
|
553 |
}
|
542 |
|
554 |
|
543 |
private static long getCumulPrecedent(SQLRowAccessor rowFact) {
|
555 |
private static long getCumulPrecedent(SQLRowAccessor rowFact) {
|
544 |
|
556 |
|
545 |
long cumul = 0;
|
557 |
long cumul = 0;
|
546 |
|
558 |
|
547 |
SQLRowAccessor rowAff = rowFact.getForeign("ID_AFFAIRE");
|
559 |
SQLRowAccessor rowAff = rowFact.getForeign("ID_AFFAIRE");
|
548 |
Calendar date = rowFact.getDate("DATE");
|
560 |
Calendar date = rowFact.getDate("DATE");
|
549 |
if (rowAff != null && !rowAff.isUndefined()) {
|
561 |
if (rowAff != null && !rowAff.isUndefined()) {
|
550 |
if (rowAff.getBoolean("CCI")) {
|
562 |
if (rowAff.getBoolean("CCI")) {
|
551 |
|
563 |
|
552 |
List<SQLRow> rows = rowAff.asRow().getReferentRows(rowFact.getTable());
|
564 |
List<SQLRow> rows = rowAff.asRow().getReferentRows(rowFact.getTable());
|
553 |
for (SQLRow sqlRow : rows) {
|
565 |
for (SQLRow sqlRow : rows) {
|
554 |
if (sqlRow.getID() != rowFact.getID() && sqlRow.getDate("DATE").before(date)) {
|
566 |
if (sqlRow.getID() != rowFact.getID() && sqlRow.getDate("DATE").before(date)) {
|
555 |
cumul += sqlRow.getLong("T_HT");
|
567 |
cumul += sqlRow.getLong("T_HT");
|
556 |
}
|
568 |
}
|
557 |
}
|
569 |
}
|
558 |
}
|
570 |
}
|
559 |
} else {
|
571 |
} else {
|
560 |
|
572 |
|
561 |
// On recupere les missions associées
|
573 |
// On recupere les missions associées
|
562 |
SQLTable tableElt = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
574 |
SQLTable tableElt = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
563 |
Collection<? extends SQLRowAccessor> factElts = rowFact.getReferentRows(tableElt);
|
575 |
Collection<? extends SQLRowAccessor> factElts = rowFact.getReferentRows(tableElt);
|
564 |
|
576 |
|
565 |
for (SQLRowAccessor row : factElts) {
|
577 |
for (SQLRowAccessor row : factElts) {
|
566 |
|
578 |
|
567 |
final SQLRowAccessor foreign = row.getForeign("ID_MISSION");
|
579 |
final SQLRowAccessor foreign = row.getForeign("ID_MISSION");
|
568 |
if (foreign.getID() > 1) {
|
580 |
if (foreign.getID() > 1) {
|
569 |
Collection<? extends SQLRowAccessor> rowsElt = foreign.getReferentRows(tableElt);
|
581 |
Collection<? extends SQLRowAccessor> rowsElt = foreign.getReferentRows(tableElt);
|
570 |
for (SQLRowAccessor row2 : rowsElt) {
|
582 |
for (SQLRowAccessor row2 : rowsElt) {
|
571 |
SQLRowAccessor rowFacture = row2.getForeign("ID_SAISIE_VENTE_FACTURE");
|
583 |
SQLRowAccessor rowFacture = row2.getForeign("ID_SAISIE_VENTE_FACTURE");
|
572 |
if (rowFacture.getDate("DATE").before(date)) {
|
584 |
if (rowFacture.getDate("DATE").before(date)) {
|
573 |
cumul += row2.getLong("T_PV_HT");
|
585 |
cumul += row2.getLong("T_PV_HT");
|
574 |
}
|
586 |
}
|
575 |
}
|
587 |
}
|
576 |
}
|
588 |
}
|
577 |
}
|
589 |
}
|
578 |
}
|
590 |
}
|
579 |
|
591 |
|
580 |
return cumul;
|
592 |
return cumul;
|
581 |
}
|
593 |
}
|
582 |
|
594 |
|
583 |
private static long getMontantGlobal(SQLRowAccessor rowFact) {
|
595 |
private static long getMontantGlobal(SQLRowAccessor rowFact) {
|
584 |
|
596 |
|
585 |
long cumul = 0;
|
597 |
long cumul = 0;
|
586 |
final BigDecimal cent = new BigDecimal(100);
|
598 |
final BigDecimal cent = new BigDecimal(100);
|
587 |
|
599 |
|
588 |
// On recupere les missions associées
|
600 |
// On recupere les missions associées
|
589 |
SQLTable tableElt = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
601 |
SQLTable tableElt = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
590 |
Collection<? extends SQLRowAccessor> factElts = rowFact.getReferentRows(tableElt);
|
602 |
Collection<? extends SQLRowAccessor> factElts = rowFact.getReferentRows(tableElt);
|
591 |
|
603 |
|
592 |
for (SQLRowAccessor row : factElts) {
|
604 |
for (SQLRowAccessor row : factElts) {
|
593 |
BigDecimal p0 = row.getBigDecimal("MONTANT_INITIAL");
|
605 |
BigDecimal p0 = row.getBigDecimal("MONTANT_INITIAL");
|
594 |
Long l0 = (Long) row.getObject("INDICE_0");
|
606 |
Long l0 = (Long) row.getObject("INDICE_0");
|
595 |
Long lN = (Long) row.getObject("INDICE_N");
|
607 |
Long lN = (Long) row.getObject("INDICE_N");
|
596 |
final BigDecimal o = row.getBigDecimal("POURCENT_ACOMPTE");
|
608 |
final BigDecimal o = row.getBigDecimal("POURCENT_ACOMPTE");
|
597 |
final BigDecimal o2 = row.getBigDecimal("POURCENT_REMISE");
|
609 |
final BigDecimal o2 = row.getBigDecimal("POURCENT_REMISE");
|
598 |
double lA = (o == null) ? 0 : ((BigDecimal) o).doubleValue();
|
610 |
double lA = (o == null) ? 0 : ((BigDecimal) o).doubleValue();
|
599 |
BigDecimal lremise = (o2 == null) ? BigDecimal.ZERO : o2;
|
611 |
BigDecimal lremise = (o2 == null) ? BigDecimal.ZERO : o2;
|
600 |
BigDecimal p;
|
612 |
BigDecimal p;
|
601 |
if (l0 != 0) {
|
613 |
if (l0 != 0) {
|
602 |
BigDecimal d;
|
614 |
BigDecimal d;
|
603 |
double coeff = ((double) lN) / ((double) l0);
|
615 |
double coeff = ((double) lN) / ((double) l0);
|
604 |
d = new BigDecimal("0.15").add(new BigDecimal("0.85").multiply(new BigDecimal(coeff), DecimalUtils.HIGH_PRECISION));
|
616 |
d = new BigDecimal("0.15").add(new BigDecimal("0.85").multiply(new BigDecimal(coeff), DecimalUtils.HIGH_PRECISION));
|
605 |
p = d.multiply(p0, DecimalUtils.HIGH_PRECISION);
|
617 |
p = d.multiply(p0, DecimalUtils.HIGH_PRECISION);
|
606 |
} else {
|
618 |
} else {
|
607 |
p = p0;
|
619 |
p = p0;
|
608 |
}
|
620 |
}
|
609 |
// if (lA >= 0 && lA != 100) {
|
621 |
// if (lA >= 0 && lA != 100) {
|
610 |
// p = Math.round(p * (lA / 100.0));
|
622 |
// p = Math.round(p * (lA / 100.0));
|
611 |
// }
|
623 |
// }
|
612 |
if (lremise.signum() != 0 && lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(cent) < 100) {
|
624 |
if (lremise.signum() != 0 && lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(cent) < 100) {
|
613 |
p = p.multiply(cent.subtract(lremise).movePointLeft(2), DecimalUtils.HIGH_PRECISION);
|
625 |
p = p.multiply(cent.subtract(lremise).movePointLeft(2), DecimalUtils.HIGH_PRECISION);
|
614 |
}
|
626 |
}
|
615 |
cumul += p.setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
|
627 |
cumul += p.setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
|
616 |
}
|
628 |
}
|
617 |
|
629 |
|
618 |
// Echantillons
|
630 |
// Echantillons
|
619 |
SQLTable tableEchElt = Configuration.getInstance().getRoot().findTable("ECHANTILLON_ELEMENT");
|
631 |
SQLTable tableEchElt = Configuration.getInstance().getRoot().findTable("ECHANTILLON_ELEMENT");
|
620 |
Collection<? extends SQLRowAccessor> echElts = rowFact.getReferentRows(tableEchElt);
|
632 |
Collection<? extends SQLRowAccessor> echElts = rowFact.getReferentRows(tableEchElt);
|
621 |
for (SQLRowAccessor sqlRowAccessor : echElts) {
|
633 |
for (SQLRowAccessor sqlRowAccessor : echElts) {
|
622 |
cumul += sqlRowAccessor.getBigDecimal("T_PV_HT").setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
|
634 |
cumul += sqlRowAccessor.getBigDecimal("T_PV_HT").setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
|
623 |
}
|
635 |
}
|
624 |
return cumul;
|
636 |
return cumul;
|
625 |
}
|
637 |
}
|
626 |
|
638 |
|
627 |
|
639 |
|
628 |
private static List<Integer> getListId(Collection<SQLRow> rowFactElts) {
|
640 |
private static List<Integer> getListId(Collection<SQLRow> rowFactElts) {
|
629 |
return getListId(rowFactElts, null);
|
641 |
return getListId(rowFactElts, null);
|
630 |
}
|
642 |
}
|
631 |
|
643 |
|
632 |
private static List<Integer> getListId(Collection<SQLRow> rowFactElts, String field) {
|
644 |
private static List<Integer> getListId(Collection<SQLRow> rowFactElts, String field) {
|
633 |
List<Integer> l = new ArrayList<Integer>();
|
645 |
List<Integer> l = new ArrayList<Integer>();
|
634 |
|
646 |
|
635 |
for (SQLRow row : rowFactElts) {
|
647 |
for (SQLRow row : rowFactElts) {
|
636 |
if (field == null) {
|
648 |
if (field == null) {
|
637 |
l.add(row.getID());
|
649 |
l.add(row.getID());
|
638 |
} else {
|
650 |
} else {
|
639 |
l.add(row.getInt(field));
|
651 |
l.add(row.getInt(field));
|
640 |
}
|
652 |
}
|
641 |
}
|
653 |
}
|
642 |
return l;
|
654 |
return l;
|
643 |
}
|
655 |
}
|
644 |
|
656 |
|
645 |
|
657 |
|
646 |
/**
|
658 |
/**
|
647 |
* transforme une devise exprimée en chiffres en lettres
|
659 |
* transforme une devise exprimée en chiffres en lettres
|
648 |
*
|
660 |
*
|
649 |
* @param value
|
661 |
* @param value
|
650 |
* @return la devise exprimée en lettres
|
662 |
* @return la devise exprimée en lettres
|
651 |
*/
|
663 |
*/
|
652 |
private String getLettreFromDevise(long value, int langue, Tuple2<String, String> deviseName) {
|
664 |
private String getLettreFromDevise(long value, int langue, Tuple2<String, String> deviseName) {
|
653 |
|
665 |
|
654 |
StringBuffer result = new StringBuffer();
|
666 |
StringBuffer result = new StringBuffer();
|
655 |
|
667 |
|
656 |
if (this.op != null && this.op.trim().length() > 0) {
|
668 |
if (this.op != null && this.op.trim().length() > 0) {
|
657 |
String field2 = this.elt.getAttributeValue("name2");
|
669 |
String field2 = this.elt.getAttributeValue("name2");
|
658 |
|
670 |
|
659 |
Number o2;
|
671 |
Number o2;
|
660 |
if (field2 != null && field2.trim().length() > 0) {
|
672 |
if (field2 != null && field2.trim().length() > 0) {
|
661 |
o2 = (Number) this.row.getObject(field2);
|
673 |
o2 = (Number) this.row.getObject(field2);
|
662 |
} else {
|
674 |
} else {
|
663 |
o2 = Double.parseDouble(this.elt.getAttributeValue("number"));
|
675 |
o2 = Double.parseDouble(this.elt.getAttributeValue("number"));
|
664 |
}
|
676 |
}
|
665 |
|
677 |
|
666 |
value = calcul(value, o2, this.op).setScale(0, RoundingMode.HALF_UP).longValue();
|
678 |
value = calcul(value, o2, this.op).setScale(0, RoundingMode.HALF_UP).longValue();
|
667 |
}
|
679 |
}
|
668 |
|
680 |
|
669 |
Long decimal = Long.valueOf(value % 100);
|
681 |
Long decimal = Long.valueOf(value % 100);
|
670 |
Long entier = Long.valueOf(value / 100);
|
682 |
Long entier = Long.valueOf(value / 100);
|
671 |
|
683 |
|
672 |
Nombre n1 = new Nombre(entier.intValue(), langue);
|
684 |
Nombre n1 = new Nombre(entier.intValue(), langue);
|
673 |
Nombre n2 = new Nombre(decimal.intValue(), langue);
|
685 |
Nombre n2 = new Nombre(decimal.intValue(), langue);
|
674 |
|
686 |
|
675 |
// 2.51 -> deux euros et cinquante et un centimes
|
687 |
// 2.51 -> deux euros et cinquante et un centimes
|
676 |
result.append(n1.getText() + " " + deviseName.get0().trim());
|
688 |
result.append(n1.getText() + " " + deviseName.get0().trim());
|
677 |
if (decimal.intValue() > 0) {
|
689 |
if (decimal.intValue() > 0) {
|
678 |
result.append(" " + n1.getSeparateurLabel() + " " + n2.getText() + deviseName.get1());
|
690 |
result.append(" " + n1.getSeparateurLabel() + " " + n2.getText() + deviseName.get1());
|
679 |
}
|
691 |
}
|
680 |
if (result != null && result.length() > 0) {
|
692 |
if (result != null && result.length() > 0) {
|
681 |
return result.toString().replaceFirst(String.valueOf(result.charAt(0)), String.valueOf(result.charAt(0)).toUpperCase());
|
693 |
return result.toString().replaceFirst(String.valueOf(result.charAt(0)), String.valueOf(result.charAt(0)).toUpperCase());
|
682 |
}
|
694 |
}
|
683 |
return "";
|
695 |
return "";
|
684 |
}
|
696 |
}
|
685 |
|
697 |
|
686 |
private static BigDecimal calcul(Object o1, Object o2, String op) {
|
698 |
private static BigDecimal calcul(Object o1, Object o2, String op) {
|
687 |
|
699 |
|
688 |
BigDecimal d1;
|
700 |
BigDecimal d1;
|
689 |
if (o1 != null && o1 instanceof BigDecimal) {
|
701 |
if (o1 != null && o1 instanceof BigDecimal) {
|
690 |
d1 = (BigDecimal) o1;
|
702 |
d1 = (BigDecimal) o1;
|
691 |
} else {
|
703 |
} else {
|
692 |
d1 = (o1 == null) ? BigDecimal.ZERO : new BigDecimal(o1.toString());
|
704 |
d1 = (o1 == null) ? BigDecimal.ZERO : new BigDecimal(o1.toString());
|
693 |
}
|
705 |
}
|
694 |
|
706 |
|
695 |
BigDecimal d2;
|
707 |
BigDecimal d2;
|
696 |
if (o2 != null && o2 instanceof BigDecimal) {
|
708 |
if (o2 != null && o2 instanceof BigDecimal) {
|
697 |
d2 = (BigDecimal) o2;
|
709 |
d2 = (BigDecimal) o2;
|
698 |
} else {
|
710 |
} else {
|
699 |
d2 = (o2 == null) ? BigDecimal.ZERO : new BigDecimal(o2.toString());
|
711 |
d2 = (o2 == null) ? BigDecimal.ZERO : new BigDecimal(o2.toString());
|
700 |
}
|
712 |
}
|
701 |
// Exemple cmdcliet.total - cmdclient.acompte
|
713 |
// Exemple cmdcliet.total - cmdclient.acompte
|
702 |
if (o1 != null && o1 instanceof Long && o2 != null && o2 instanceof BigDecimal) {
|
714 |
if (o1 != null && o1 instanceof Long && o2 != null && o2 instanceof BigDecimal) {
|
703 |
d2 = d2.movePointRight(2);
|
715 |
d2 = d2.movePointRight(2);
|
704 |
}
|
716 |
}
|
705 |
if (op.equalsIgnoreCase("+")) {
|
717 |
if (op.equalsIgnoreCase("+")) {
|
706 |
return d1.add(d2, DecimalUtils.HIGH_PRECISION);
|
718 |
return d1.add(d2, DecimalUtils.HIGH_PRECISION);
|
707 |
} else {
|
719 |
} else {
|
708 |
if (op.equalsIgnoreCase("-")) {
|
720 |
if (op.equalsIgnoreCase("-")) {
|
709 |
return d1.subtract(d2, DecimalUtils.HIGH_PRECISION);
|
721 |
return d1.subtract(d2, DecimalUtils.HIGH_PRECISION);
|
710 |
} else {
|
722 |
} else {
|
711 |
if (op.equalsIgnoreCase("*")) {
|
723 |
if (op.equalsIgnoreCase("*")) {
|
712 |
return d1.multiply(d2, DecimalUtils.HIGH_PRECISION);
|
724 |
return d1.multiply(d2, DecimalUtils.HIGH_PRECISION);
|
713 |
} else {
|
725 |
} else {
|
714 |
if (op.equalsIgnoreCase("/") && d2.compareTo(BigDecimal.ZERO) != 0) {
|
726 |
if (op.equalsIgnoreCase("/") && d2.compareTo(BigDecimal.ZERO) != 0) {
|
715 |
return d1.divide(d2, DecimalUtils.HIGH_PRECISION);
|
727 |
return d1.divide(d2, DecimalUtils.HIGH_PRECISION);
|
716 |
}
|
728 |
}
|
717 |
}
|
729 |
}
|
718 |
}
|
730 |
}
|
719 |
}
|
731 |
}
|
720 |
return BigDecimal.ZERO;
|
732 |
return BigDecimal.ZERO;
|
721 |
}
|
733 |
}
|
722 |
|
734 |
|
723 |
}
|
735 |
}
|