Commit a1ccc3d1 authored by pchavan's avatar pchavan

Change the rounding method to round the decimal value.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191926 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5e9d9412
package ibase.webitm.ejb.fin; package ibase.webitm.ejb.fin;
import java.math.BigDecimal;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
...@@ -12548,42 +12549,71 @@ public class FinCommon ...@@ -12548,42 +12549,71 @@ public class FinCommon
*/ */
public String checkGlTranDrCr(String refSer,String refId,Connection conn) throws ITMException //Added by Jiten public String checkGlTranDrCr(String refSer,String refId,Connection conn) throws ITMException //Added by Jiten
{ {
Statement stmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
double drAmt = 0,crAmt = 0,exch = 0; double exch = 0 ;
double totDrAmt = 0,totCrAmt = 0,diffAmt = 0;
//Changed By PriyankaC on 3Oct2018.
// double drAmt = 0,crAmt = 0,exch = 0;
// double totDrAmt = 0,totCrAmt = 0,diffAmt = 0;
BigDecimal totDrB = new BigDecimal(0);
BigDecimal totCrB = new BigDecimal(0);
BigDecimal drAmt = new BigDecimal(0);
BigDecimal crAmt = new BigDecimal(0);
BigDecimal totDrAmt = new BigDecimal(0);
BigDecimal totCrAmt = new BigDecimal(0);
BigDecimal diffAmt = new BigDecimal(0);
String sql = "",errString = "",postOnLine = "",acct = "",cctr = ""; String sql = "",errString = "",postOnLine = "",acct = "",cctr = "";
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
// GenericUtility genericUtility = null; // GenericUtility genericUtility = null;
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
HashMap glTran = null; HashMap glTran = null;
try{ try{
stmt = conn.createStatement(); //pstmt = conn.PreparedStatement();
// genericUtility = new GenericUtility(); // genericUtility = new GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
sql = "select case when dr_amt is null then 0 else dr_amt end * exch_rate," + sql = "select case when dr_amt is null then 0 else dr_amt end * exch_rate," +
"case when cr_amt is null then 0 else cr_amt end * exch_rate " + "case when cr_amt is null then 0 else cr_amt end * exch_rate " +
"from gltrace where ref_ser = '"+refSer+"' and ref_id = '"+refId+"'"; "from gltrace where ref_ser = '"+refSer+"' and ref_id = '"+refId+"'";
pstmt = conn.prepareStatement(sql);
System.out.println("SQL :"+sql); System.out.println("SQL :"+sql);
rs = stmt.executeQuery(sql); rs = pstmt.executeQuery(sql);
while(rs.next()){ while(rs.next()){
drAmt = getRequiredDecimal(rs.getDouble(1), 2);
crAmt = getRequiredDecimal(rs.getDouble(2), 2);
totDrAmt = totDrAmt + drAmt; //Changed By PriyankaC on 3Oct2018. [Start]
totCrAmt = totCrAmt + crAmt; drAmt = BigDecimal.valueOf(rs.getDouble(1));
totDrAmt = getRequiredDecimal(totDrAmt, 2); crAmt = BigDecimal.valueOf(rs.getDouble(2));
totCrAmt = getRequiredDecimal(totCrAmt, 2);
//System.out.println("debitAmt----"+drAmt+"--creditAmt---"+crAmt+"---Total Debit Amt---"+totDrAmt+"---Total Credit Amt---"+totCrAmt); // drAmt = getRequiredDecimal(rs.getDouble(1), 2);
// crAmt = getRequiredDecimal(rs.getDouble(2), 2);
drAmt = rounded(drAmt, 2);
crAmt = rounded(crAmt, 2);
/*totDrAmt = totDrAmt + drAmt;
totCrAmt = totCrAmt + crAmt*/;
totDrAmt = totDrAmt.add(drAmt);
totCrAmt = totCrAmt.add(crAmt);
// totDrAmt = getRequiredDecimal(totDrAmt, 2);
// totCrAmt = getRequiredDecimal(totCrAmt, 2);
System.out.println("debitAmt----"+drAmt+"--creditAmt---"+crAmt+"---Total Debit Amt---"+totDrAmt+"---Total Credit Amt---"+totCrAmt);
//Changed By PriyankaC on 3Oct2018. [END]..
} }
rs.close(); rs.close();
if(totDrAmt == totCrAmt){ if(totDrAmt == totCrAmt)
{
return ""; return "";
} }
diffAmt = totDrAmt - totCrAmt; // diffAmt = totDrAmt - totCrAmt;
diffAmt=getRequiredDecimal(diffAmt, 2); diffAmt = totDrAmt.subtract(totCrAmt);//Changed By PriyankaC on 3Oct2018
System.out.println("Difference Amount----"+diffAmt); //diffAmt = diffAmt.abs();
// diffAmt=getRequiredDecimal(diffAmt, 2);
System.out.println("Difference Amount----- : "+diffAmt);
System.out.println("Difference Amount2---- : "+diffAmt.abs());
//Added by Manoj dtd 27/06/2014 to check coin differemce limit //Added by Manoj dtd 27/06/2014 to check coin differemce limit
String coinDiffLimit=getFinparams("999999", "COIN_DIFF_LIMIT", conn); String coinDiffLimit=getFinparams("999999", "COIN_DIFF_LIMIT", conn);
coinDiffLimit=coinDiffLimit==null?"":coinDiffLimit; coinDiffLimit=coinDiffLimit==null?"":coinDiffLimit;
...@@ -12591,11 +12621,14 @@ public class FinCommon ...@@ -12591,11 +12621,14 @@ public class FinCommon
{ {
coinDiffLimit = "1"; coinDiffLimit = "1";
} }
BigDecimal bigDecimalcoinDiffLimit=new BigDecimal(coinDiffLimit);
System.out.println("Converted String currency to bigDecimalCurrency: "+bigDecimalcoinDiffLimit);
// if(Math.abs(diffAmt) > 1){ // if(Math.abs(diffAmt) > 1){
//Changed by Manoj dtd 27/06/2014 to check coin differemce limit // Changed by Manoj dtd 27/06/2014 to check coin differemce limit
if(Math.abs(diffAmt) > Double.parseDouble(coinDiffLimit)) // if(Math.abs(diffAmt) > Double.parseDouble(coinDiffLimit))//PriyankaC on 3OCt2018
if(diffAmt.abs().compareTo(bigDecimalcoinDiffLimit) > 0 )
{ {
System.out.println("Compare The value " +diffAmt.abs() + " " +bigDecimalcoinDiffLimit);
errString = itmDBAccessEJB.getErrorString("","VCOINDIFF1","","",conn); errString = itmDBAccessEJB.getErrorString("","VCOINDIFF1","","",conn);
return errString; return errString;
} }
...@@ -12610,14 +12643,17 @@ public class FinCommon ...@@ -12610,14 +12643,17 @@ public class FinCommon
return errString; return errString;
} }
} }
if(postOnLine.equalsIgnoreCase("Y")){ if(postOnLine.equalsIgnoreCase("Y"))
{
acct = getFinparams("999999","COIN_ACCT",conn); acct = getFinparams("999999","COIN_ACCT",conn);
if(acct.equalsIgnoreCase("NULLFOUND")){ if(acct.equalsIgnoreCase("NULLFOUND"))
{
errString = itmDBAccessEJB.getErrorString("","VSENVAR1","","",conn); errString = itmDBAccessEJB.getErrorString("","VSENVAR1","","",conn);
return errString; return errString;
} }
cctr = getFinparams("999999","COIN_CCTR",conn); cctr = getFinparams("999999","COIN_CCTR",conn);
if(cctr.equalsIgnoreCase("NULLFOUND")){ if(cctr.equalsIgnoreCase("NULLFOUND"))
{
cctr = ""; cctr = "";
} }
...@@ -12653,11 +12689,20 @@ public class FinCommon ...@@ -12653,11 +12689,20 @@ public class FinCommon
glTran.put("proj_code",""); glTran.put("proj_code","");
glTran.put("dept_code",""); glTran.put("dept_code","");
if(diffAmt > 0){ // if(diffAmt > 0)
BigDecimal zeroValue = new BigDecimal("0.00"); //Changed By PriyankaC
if(diffAmt.compareTo(zeroValue) > 0) //Changed By PriyankaC
{
glTran.put("dr_amt","0"); glTran.put("dr_amt","0");
glTran.put("cr_amt",Double.toString(diffAmt)); // glTran.put("cr_amt",Double.toString(diffAmt)); //Changed By PriyankaC
glTran.put("cr_amt",diffAmt.toString());
}else{ }else{
glTran.put("dr_amt",Double.toString(0 - diffAmt));
//glTran.put("dr_amt",Double.toString(0 - diffAmt));
glTran.put("dr_amt",(zeroValue.subtract(diffAmt).toString()));
System.out.println("Difference Amount in else---- : "+zeroValue.subtract(diffAmt).toString());//Changed By PriyankaC
glTran.put("cr_amt","0"); glTran.put("cr_amt","0");
} }
glTran.put("ref_ser",refSer); glTran.put("ref_ser",refSer);
...@@ -12675,10 +12720,10 @@ public class FinCommon ...@@ -12675,10 +12720,10 @@ public class FinCommon
rs.close(); rs.close();
rs = null; rs = null;
} }
if(stmt != null) if(pstmt != null)
{ {
stmt.close(); pstmt.close();
stmt = null; pstmt = null;
} }
errString = glTranUpdate(glTran,conn); errString = glTranUpdate(glTran,conn);
} }
...@@ -12689,7 +12734,7 @@ public class FinCommon ...@@ -12689,7 +12734,7 @@ public class FinCommon
}finally{ }finally{
try{ try{
if(rs != null){rs.close();rs = null;} if(rs != null){rs.close();rs = null;}
if(stmt != null){stmt.close();stmt = null;} if(pstmt != null){pstmt.close();pstmt = null;}
}catch(Exception t){} }catch(Exception t){}
} }
System.out.println("Returning Strung :"+errString); System.out.println("Returning Strung :"+errString);
...@@ -16410,4 +16455,11 @@ public String nfCheckPeriod(String modCode, java.util.Date tranDate , String sit ...@@ -16410,4 +16455,11 @@ public String nfCheckPeriod(String modCode, java.util.Date tranDate , String sit
return count; return count;
} }
//Added by Anjali R. on[21/09/2018][Validate sundry code ][eND] //Added by Anjali R. on[21/09/2018][Validate sundry code ][eND]
//Added By PriyankaC to rounding the decimal.[Start]
private static BigDecimal rounded(BigDecimal aNumber, int prec)
{
return aNumber.setScale(prec, BigDecimal.ROUND_HALF_EVEN);
}
//Added By PriyankaC to rounding the decimal.[END]
} }
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