Commit 9a43db64 authored by prane's avatar prane

changes done in getRndamt() to format the output before return, in...

changes done in getRndamt() to format the output before return, in getRequiredDecimal added maxfractionalDigit to  and expression based rounding are removed.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@212623 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6b392db2
...@@ -5668,13 +5668,25 @@ public class DistCommon { ...@@ -5668,13 +5668,25 @@ public class DistCommon {
System.out.println("lcMultiply[" + lcMultiply + "]"); System.out.println("lcMultiply[" + lcMultiply + "]");
newQty = newQty * lcMultiply; newQty = newQty * lcMultiply;
System.out.println("newQty * lcMultiply[" + newQty + "]"); System.out.println("newQty * lcMultiply[" + newQty + "]");
//Modified by Pavan Rane on 22NOV19[To format decimal places] start
if (roundTo == 1) {
newQty = getRequiredDecimal(newQty, 0);
} else if (roundTo == .1) {
newQty = getRequiredDecimal(newQty, 1);
} else if (roundTo == .01) {
newQty = getRequiredDecimal(newQty, 2);
} else if (roundTo == .001) {
newQty = getRequiredDecimal(newQty, 3);
} else if (roundTo == .0001) {
newQty = getRequiredDecimal(newQty, 4);
}
return newQty; return newQty;
} catch (Exception e) { } catch (Exception e) {
System.out.println("Exception :Conversion Qty ::" + e.getMessage() System.out.println("Exception :Conversion Qty ::" + e.getMessage()
+ ":"); + ":");
} }
if (roundTo == 1) { /*if (roundTo == 1) {
newQty = getRequiredDecimal(newQty, 0); newQty = getRequiredDecimal(newQty, 0);
} else if (roundTo == .1) { } else if (roundTo == .1) {
newQty = getRequiredDecimal(newQty, 1); newQty = getRequiredDecimal(newQty, 1);
...@@ -5684,7 +5696,8 @@ public class DistCommon { ...@@ -5684,7 +5696,8 @@ public class DistCommon {
newQty = getRequiredDecimal(newQty, 3); newQty = getRequiredDecimal(newQty, 3);
} else if (roundTo == .0001) { } else if (roundTo == .0001) {
newQty = getRequiredDecimal(newQty, 4); newQty = getRequiredDecimal(newQty, 4);
} }*/
//Modified by Pavan Rane on 22NOV19[To format decimal places] end
return newQty; return newQty;
} }
...@@ -5701,7 +5714,10 @@ public class DistCommon { ...@@ -5701,7 +5714,10 @@ public class DistCommon {
public double getRequiredDecimal(double actVal, int prec) { public double getRequiredDecimal(double actVal, int prec) {
NumberFormat numberFormat = NumberFormat.getIntegerInstance(); NumberFormat numberFormat = NumberFormat.getIntegerInstance();
Double DoubleValue = new Double(actVal); Double DoubleValue = new Double(actVal);
numberFormat.setMaximumFractionDigits(3); //Modified by Pavan Rane on 22NOV19[To format decimal places] start
//numberFormat.setMaximumFractionDigits(3);
numberFormat.setMaximumFractionDigits(6);
//Modified by Pavan Rane on 22NOV19[To format decimal places] start
String strValue = numberFormat.format(DoubleValue); String strValue = numberFormat.format(DoubleValue);
strValue = strValue.replaceAll(",", ""); strValue = strValue.replaceAll(",", "");
double reqVal = Double.parseDouble(strValue); double reqVal = Double.parseDouble(strValue);
...@@ -12172,6 +12188,12 @@ public class DistCommon { ...@@ -12172,6 +12188,12 @@ public class DistCommon {
String finalRate = ""; String finalRate = "";
//HashMap<String,String> sqlInputDataMap = new HashMap<String, String>(); //HashMap<String,String> sqlInputDataMap = new HashMap<String, String>();
GenericUtility genericUtility ; GenericUtility genericUtility ;
//Added by Pavan Rane on 22NOV19[Var decalred] start
String exprStr = "", expDecStr = "";
int decPlac = 0;
double finalRateD = 0.0;
boolean executeflag = false;
//Added by Pavan Rane on 22NOV19[Var decalred] end
try try
{ {
System.out.println("-----------------------------Inside calc method---------------------------"); System.out.println("-----------------------------Inside calc method---------------------------");
...@@ -12269,16 +12291,108 @@ public class DistCommon { ...@@ -12269,16 +12291,108 @@ public class DistCommon {
{ {
if( varExpr.indexOf("ROUND(") != -1 ) if( varExpr.indexOf("ROUND(") != -1 )
{ {
varExpr = varExpr.replaceAll("ROUND\\(", "Math.round("); //varExpr = varExpr.replaceAll("ROUND\\(", "Math.round(");
varExpr = varExpr.replaceAll("ROUND\\(", "");
System.out.println("in 1st if updated varExpr["+varExpr+"]"); System.out.println("in 1st if updated varExpr["+varExpr+"]");
//Modified by Pavan Rane on 22NOV19[Removed expre round and set format decimal places of rate] start
String varExpArr [] = varExpr.split(",");
if(varExpArr.length > 0)
{
exprStr = varExpArr[0];
//System.out.println("varExprMain:"+varExprMain.trim());
finalRate = String.valueOf(exprsEngine.eval(exprStr));
executeflag = true;
System.out.println("finalRate from exprStr :"+finalRate);
}
if(varExpArr.length > 1)
{
expDecStr = varExpArr[1];
//System.out.println("varExprDec"+expdecStr);
expDecStr = expDecStr.replaceAll("\\)", "");
decPlac = Integer.parseInt(expDecStr.trim());
System.out.println("expDecStr from exprStr :"+expDecStr);
}
if("NaN".equalsIgnoreCase(finalRate))
{
finalRateD = 0.0;
}
else {
finalRateD = Double.parseDouble(finalRate);
}
if(decPlac == 0)
{
finalRateD = getRndamt(finalRateD, "R", 1);
}else if(decPlac == 1)
{
finalRateD = getRndamt(finalRateD, "R", .1);
}else if(decPlac == 2)
{
finalRateD = getRndamt(finalRateD, "R", .01);
}
else if(decPlac == 3)
{
finalRateD = getRndamt(finalRateD, "R", .001);
}
else if(decPlac == 4)
{
finalRateD = getRndamt(finalRateD, "R", .0001);
}
finalRate = String.valueOf(finalRateD);
} }
else if( varExpr.indexOf("ROUND (") != -1 ) else if( varExpr.indexOf("ROUND (") != -1 )
{ {
varExpr = varExpr.replaceAll("ROUND \\(", "Math.round("); //varExpr = varExpr.replaceAll("ROUND \\(", "Math.round(");
varExpr = varExpr.replaceAll("ROUND \\(", "");
System.out.println("in 2nd if updated varExpr["+varExpr+"]"); System.out.println("in 2nd if updated varExpr["+varExpr+"]");
String varExpArr [] = varExpr.split(",");
if(varExpArr.length > 0)
{
exprStr = varExpArr[0];
//System.out.println("varExprMain:"+varExprMain.trim());
finalRate = String.valueOf(exprsEngine.eval(exprStr));
executeflag = true;
System.out.println("finalRate from exprStr :"+finalRate);
}
if(varExpArr.length > 1)
{
expDecStr = varExpArr[1];
//System.out.println("varExprDec"+expdecStr);
expDecStr = expDecStr.replaceAll("\\)", "");
decPlac = Integer.parseInt(expDecStr.trim());
System.out.println("expDecStr from exprStr :"+expDecStr);
}
if("NaN".equalsIgnoreCase(finalRate))
{
finalRateD = 0.0;
}
else {
finalRateD = Double.parseDouble(finalRate);
}
if(decPlac == 0)
{
finalRateD = getRndamt(finalRateD, "R", 1);
}else if(decPlac == 1)
{
finalRateD = getRndamt(finalRateD, "R", .1);
}else if(decPlac == 2)
{
finalRateD = getRndamt(finalRateD, "R", .01);
}
else if(decPlac == 3)
{
finalRateD = getRndamt(finalRateD, "R", .001);
}
else if(decPlac == 4)
{
finalRateD = getRndamt(finalRateD, "R", .0001);
}
finalRate = String.valueOf(finalRateD);
} }
finalRate = String.valueOf(exprsEngine.eval(varExpr)); if(!executeflag)
{
finalRate = String.valueOf(exprsEngine.eval(varExpr));
}
//Modified by Pavan Rane on 22NOV19[Removed expre round and set format decimal places of rate] end
System.out.println("inside E :::"+varName+"=["+finalRate+"]"); System.out.println("inside E :::"+varName+"=["+finalRate+"]");
if("NaN".equalsIgnoreCase(finalRate)) if("NaN".equalsIgnoreCase(finalRate))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment