You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by su...@apache.org on 2020/06/05 07:44:19 UTC
[ofbiz-plugins] branch trunk updated: Improved: Enforce
noninstantiability to FinAccountHelper Class. (#22)
This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push:
new b08fa4a Improved: Enforce noninstantiability to FinAccountHelper Class. (#22)
b08fa4a is described below
commit b08fa4a9441f4f67b210b29ef424f0eaf6ff0433
Author: Suraj Khurana <64...@users.noreply.github.com>
AuthorDate: Fri Jun 5 13:14:11 2020 +0530
Improved: Enforce noninstantiability to FinAccountHelper Class. (#22)
(OFBIZ-11723)
Made class as final, added private constructor, also made data members as private, defined getter and changed related occurrences.
---
.../java/org/apache/ofbiz/pricat/AbstractPricatParser.java | 11 +++++++----
.../org/apache/ofbiz/pricat/sample/SamplePricatParser.java | 12 ++++++++----
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java
index 382d126..7ebe124 100644
--- a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java
+++ b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java
@@ -441,7 +441,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser {
String cellValue = formatter.formatCellValue(cell);
if (UtilValidate.isNotEmpty(cellValue)) {
if (cellType == CellType.FORMULA) {
- cellValue = BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding).toString();
+ cellValue = BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()).toString();
report.print(((i == 0)?"":", ") + cellValue, InterfaceReport.FORMAT_NOTE);
} else {
report.print(((i == 0)?"":", ") + cellValue, InterfaceReport.FORMAT_NOTE);
@@ -465,7 +465,8 @@ public abstract class AbstractPricatParser implements InterfacePricatParser {
cell.setCellType(CellType.STRING);
}
try {
- results.add(BigDecimal.valueOf(Double.parseDouble(cell.getStringCellValue())).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding));
+ results.add(BigDecimal.valueOf(Double.parseDouble(cell.getStringCellValue()))
+ .setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
@@ -492,14 +493,16 @@ public abstract class AbstractPricatParser implements InterfacePricatParser {
}
} else if (cell.getCellType() == CellType.NUMERIC) {
try {
- results.add(BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding));
+ results.add(BigDecimal.valueOf(cell.getNumericCellValue())
+ .setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
}
} else {
try {
- results.add(BigDecimal.valueOf(Double.valueOf(cellValue)).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding));
+ results.add(BigDecimal.valueOf(Double.valueOf(cellValue))
+ .setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java
index 827ffc1..cfa03b0 100644
--- a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java
+++ b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java
@@ -582,7 +582,8 @@ public class SamplePricatParser extends AbstractPricatParser {
if (UtilValidate.isNotEmpty(cellValue) && UtilValidate.isNotEmpty(cellValue.trim())) {
if (cellType == CellType.FORMULA) {
try {
- cellValue = BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding).toString();
+ cellValue = BigDecimal.valueOf(cell.getNumericCellValue())
+ .setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()).toString();
} catch (IllegalStateException e) {
try {
cellValue = cell.getStringCellValue();
@@ -617,7 +618,8 @@ public class SamplePricatParser extends AbstractPricatParser {
cell.setCellType(CellType.STRING);
}
try {
- results.add(BigDecimal.valueOf(Double.parseDouble(cell.getStringCellValue())).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding));
+ results.add(BigDecimal.valueOf(Double.parseDouble(cell.getStringCellValue()))
+ .setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
@@ -645,14 +647,16 @@ public class SamplePricatParser extends AbstractPricatParser {
}
} else if (cell.getCellType() == CellType.NUMERIC) {
try {
- results.add(BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding));
+ results.add(BigDecimal.valueOf(cell.getNumericCellValue())
+ .setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));
}
} else {
try {
- results.add(BigDecimal.valueOf(Double.valueOf(cellValue)).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding));
+ results.add(BigDecimal.valueOf(Double.valueOf(cellValue))
+ .setScale(FinAccountHelper.getDecimals(), FinAccountHelper.getRounding()));
} catch (NumberFormatException e) {
results.add(null);
errorMessages.put(new CellReference(cell), UtilProperties.getMessage(RESOURCE, "ErrorParseValueToNumeric", locale));