Skip to content

Commit 07ff632

Browse files
author
Open Lowcode SAS
committed
Close #204
1 parent 17f6536 commit 07ff632

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

src/org/openlowcode/design/data/DecimalField.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public class DecimalField
3333
implements
3434
FormulaDefinitionElement {
3535
private int length;
36-
private int precision;
36+
private int scale;
3737
private int indextype;
3838
private ArrayList<CalculatedFieldTriggerPath> alltriggers;
3939
private DecimalFormatter decimalformatter;
4040
private StoredElement plainfield;
4141

4242
public int getPrecision() {
43-
return this.precision;
43+
return this.scale;
4444
}
4545

4646
public static int INDEXTYPE_NONE = 0;
@@ -56,16 +56,16 @@ public int getPrecision() {
5656
* @param tooltip roll-over tip
5757
* @param length total number of digits of the number (e.g. 533.33 is 5
5858
* digits)
59-
* @param precision (digits to the right of decimal point (e.g. 533.33 has
60-
* precision on 2)
59+
* @param scale (digits to the right of decimal point (e.g. 533.33 has
60+
* scale on 2)
6161
*/
62-
public DecimalField(String name, String displayname, String tooltip, int length, int precision, int indextype) {
62+
public DecimalField(String name, String displayname, String tooltip, int length, int scale, int indextype) {
6363

6464
super(name, displayname, tooltip);
6565
this.length = length;
66-
this.precision = precision;
66+
this.scale = scale;
6767
this.indextype = indextype;
68-
plainfield = new DecimalStoredElement("", length, precision);
68+
plainfield = new DecimalStoredElement("", length, scale);
6969
if (this.indextype == StringField.INDEXTYPE_RAWINDEX) {
7070
this.addIndex(new Index("RAWSEARCH", plainfield, false));
7171
}
@@ -81,7 +81,7 @@ public DecimalField(String name, String displayname, String tooltip, int length,
8181
* @param tooltip roll-over tip
8282
* @param length total number of digits of the number (e.g. 533.33 is 5
8383
* digits)
84-
* @param precision (digits to the right of decimal point (e.g. 533.33 has
84+
* @param scale (digits to the right of decimal point (e.g. 533.33 has
8585
* precision on 2)
8686
* @param indextype type of index (one of the static int of this class
8787
* @param displaypriority a number strictly between -1000 and 1000
@@ -91,10 +91,10 @@ public DecimalField(
9191
String displayname,
9292
String tooltip,
9393
int length,
94-
int precision,
94+
int scale,
9595
int indextype,
9696
int displaypriority) {
97-
this(name, displayname, tooltip, length, precision, indextype);
97+
this(name, displayname, tooltip, length, scale, indextype);
9898
this.setDisplayPriority(displaypriority);
9999
}
100100

@@ -108,8 +108,8 @@ public DecimalField(
108108
* @param tooltip roll-over tip
109109
* @param length total number of digits of the number (e.g. 533.33 is
110110
* 5 digits)
111-
* @param precision (digits to the right of decimal point (e.g. 533.33
112-
* has precision on 2)
111+
* @param scale (digits to the right of decimal point (e.g. 533.33
112+
* has scale on 2)
113113
* @param indextype type of index (one of the static int of this class
114114
* @param displaypriority a number strictly between -1000 and 1000
115115
* @param decimalformatter
@@ -119,11 +119,11 @@ public DecimalField(
119119
String displayname,
120120
String tooltip,
121121
int length,
122-
int precision,
122+
int scale,
123123
int indextype,
124124
int displaypriority,
125125
DecimalFormatter decimalformatter) {
126-
this(name, displayname, tooltip, length, precision, indextype);
126+
this(name, displayname, tooltip, length, scale, indextype);
127127
this.setDisplayPriority(displaypriority);
128128
this.decimalformatter = decimalformatter;
129129
}
@@ -137,7 +137,7 @@ public String getDataObjectFieldName() {
137137
@Override
138138
public String getDataObjectConstructorAttributes() {
139139
return "\"" + this.getName() + "\",\"" + this.getDisplayname() + "\",\"" + this.getTooltip() + "\","
140-
+ this.length + "," + this.precision + "," + this.isNoUserEdition() + ",false,false,"
140+
+ this.length + "," + this.scale + "," + this.isNoUserEdition() + ",false,false,"
141141
+ (decimalformatter != null ? decimalformatter.generateDefinition()
142142
: "null" + "," + this.getDisplayPriority());
143143
}
@@ -197,20 +197,21 @@ public StoredElement getMainStoredElementForCompositeIndex() {
197197
@Override
198198
public Field copy(String newname, String newdisplaylabel) {
199199
return new DecimalField((newname != null ? newname : this.getName()),
200-
(newdisplaylabel != null ? newdisplaylabel : this.getDisplayname()), this.getTooltip(), length,
201-
precision, indextype, this.getDisplayPriority(), this.decimalformatter);
200+
(newdisplaylabel != null ? newdisplaylabel : this.getDisplayname()), this.getTooltip(), length, scale,
201+
indextype, this.getDisplayPriority(), this.decimalformatter);
202202
}
203-
203+
204204
@Override
205205
public String writeCellExtractor() {
206-
return "(a,b)->(DecimalDataObjectFieldFlatFileLoaderColumn.getContentFromCell( a,"+length+","+precision+" ,b, 0,null))";
206+
return "(a,b)->(DecimalDataObjectFieldFlatFileLoaderColumn.getContentFromCell( a," + scale + "," + length
207+
+ " ,b, 0,null))";
207208
}
208209

209210
@Override
210211
public String writeCellFiller() {
211212
return "(a,b)->DecimalDataObjectFieldFlatFileLoaderColumn.putContentInCell(a,b,null)";
212213
}
213-
214+
214215
@Override
215216
public String writePayloadFiller() {
216217
return "Not yet implemented";

src/org/openlowcode/server/data/DecimalDataObjectFieldFlatFileLoaderColumn.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public int getSpecialTreatment() {
6262
/**
6363
* creates a decimal parser
6464
*
65-
* @param scale total number of digits of the number (e.g. 533.33 is 5
66-
* digits)
67-
* @param precision (digits to the right of decimal point (e.g. 533.33 has
65+
* @param scale digits to the right of decimal point (e.g. 533.33 has
6866
* precision on 2)
67+
* @param precision total number of digits of the number (e.g. 533.33 is 5
68+
* digits)
6969
* @param locale locale if CSV import
7070
*/
7171
public DecimalParser(
@@ -260,7 +260,8 @@ public static <F extends FieldChoiceDefinition<F>> boolean putContentInCell(
260260
BigDecimal value,
261261
String multiplier) {
262262
BigDecimal multiplierforexport = parsemultiplierForExport(multiplier);
263-
if (value!=null) cell.setCellValue(value.multiply(multiplierforexport).doubleValue());
263+
if (value != null)
264+
cell.setCellValue(value.multiply(multiplierforexport).doubleValue());
264265
if (multiplierforexport.equals(new BigDecimal("0.01"))) {
265266
CellStyle percentagecellstyle = FlatFileExtractor.createBorderedStyle(cell.getSheet().getWorkbook());
266267
percentagecellstyle.setDataFormat(cell.getSheet().getWorkbook().createDataFormat().getFormat("0.0%"));
@@ -274,8 +275,10 @@ public static <F extends FieldChoiceDefinition<F>> boolean putContentInCell(
274275
* gets a BigDecimal from cell
275276
*
276277
* @param value value to parse
277-
* @param scale scale
278-
* @param precision precision
278+
* @param scale number of digits right of the decimal point (e.g.
279+
* 533.33 is 2 digits
280+
* @param precision total number of digits of the number (e.g. 533.33 is 5
281+
* digits)
279282
* @param locale locale for import from text (comma or dot as decimal)
280283
* @param modifier String modifier in the sense of
281284
* DecimalDataObjectFieldFlatFileLoader

0 commit comments

Comments
 (0)