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;
import java.math.BigDecimal;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
......@@ -12548,42 +12549,71 @@ public class FinCommon
*/
public String checkGlTranDrCr(String refSer,String refId,Connection conn) throws ITMException //Added by Jiten
{
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
double drAmt = 0,crAmt = 0,exch = 0;
double totDrAmt = 0,totCrAmt = 0,diffAmt = 0;
double exch = 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 = "";
ITMDBAccessEJB itmDBAccessEJB = null;
// GenericUtility genericUtility = null;
SimpleDateFormat sdf = null;
HashMap glTran = null;
try{
stmt = conn.createStatement();
//pstmt = conn.PreparedStatement();
// genericUtility = new GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
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 " +
"from gltrace where ref_ser = '"+refSer+"' and ref_id = '"+refId+"'";
pstmt = conn.prepareStatement(sql);
System.out.println("SQL :"+sql);
rs = stmt.executeQuery(sql);
rs = pstmt.executeQuery(sql);
while(rs.next()){
drAmt = getRequiredDecimal(rs.getDouble(1), 2);
crAmt = getRequiredDecimal(rs.getDouble(2), 2);
//Changed By PriyankaC on 3Oct2018. [Start]
drAmt = BigDecimal.valueOf(rs.getDouble(1));
crAmt = BigDecimal.valueOf(rs.getDouble(2));
// 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 = getRequiredDecimal(totDrAmt, 2);
totCrAmt = getRequiredDecimal(totCrAmt, 2);
//System.out.println("debitAmt----"+drAmt+"--creditAmt---"+crAmt+"---Total Debit Amt---"+totDrAmt+"---Total Credit Amt---"+totCrAmt);
/*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();
if(totDrAmt == totCrAmt){
if(totDrAmt == totCrAmt)
{
return "";
}
diffAmt = totDrAmt - totCrAmt;
diffAmt=getRequiredDecimal(diffAmt, 2);
System.out.println("Difference Amount----"+diffAmt);
// diffAmt = totDrAmt - totCrAmt;
diffAmt = totDrAmt.subtract(totCrAmt);//Changed By PriyankaC on 3Oct2018
//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
String coinDiffLimit=getFinparams("999999", "COIN_DIFF_LIMIT", conn);
coinDiffLimit=coinDiffLimit==null?"":coinDiffLimit;
......@@ -12591,11 +12621,14 @@ public class FinCommon
{
coinDiffLimit = "1";
}
// if(Math.abs(diffAmt) > 1){
//Changed by Manoj dtd 27/06/2014 to check coin differemce limit
if(Math.abs(diffAmt) > Double.parseDouble(coinDiffLimit))
BigDecimal bigDecimalcoinDiffLimit=new BigDecimal(coinDiffLimit);
System.out.println("Converted String currency to bigDecimalCurrency: "+bigDecimalcoinDiffLimit);
// if(Math.abs(diffAmt) > 1){
// Changed by Manoj dtd 27/06/2014 to check coin differemce limit
// 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);
return errString;
}
......@@ -12610,16 +12643,19 @@ public class FinCommon
return errString;
}
}
if(postOnLine.equalsIgnoreCase("Y")){
acct = getFinparams("999999","COIN_ACCT",conn);
if(acct.equalsIgnoreCase("NULLFOUND")){
errString = itmDBAccessEJB.getErrorString("","VSENVAR1","","",conn);
return errString;
}
cctr = getFinparams("999999","COIN_CCTR",conn);
if(cctr.equalsIgnoreCase("NULLFOUND")){
cctr = "";
}
if(postOnLine.equalsIgnoreCase("Y"))
{
acct = getFinparams("999999","COIN_ACCT",conn);
if(acct.equalsIgnoreCase("NULLFOUND"))
{
errString = itmDBAccessEJB.getErrorString("","VSENVAR1","","",conn);
return errString;
}
cctr = getFinparams("999999","COIN_CCTR",conn);
if(cctr.equalsIgnoreCase("NULLFOUND"))
{
cctr = "";
}
//acct = acct.substring(0,10);
//cctr = cctr.substring(0,4);
......@@ -12653,34 +12689,43 @@ public class FinCommon
glTran.put("proj_code","");
glTran.put("dept_code","");
if(diffAmt > 0){
glTran.put("dr_amt","0");
glTran.put("cr_amt",Double.toString(diffAmt));
}else{
glTran.put("dr_amt",Double.toString(0 - diffAmt));
glTran.put("cr_amt","0");
}
glTran.put("ref_ser",refSer);
glTran.put("ref_id",refId);
// if(diffAmt > 0)
BigDecimal zeroValue = new BigDecimal("0.00"); //Changed By PriyankaC
if(diffAmt.compareTo(zeroValue) > 0) //Changed By PriyankaC
{
exch = 1;
glTran.put("dr_amt","0");
// glTran.put("cr_amt",Double.toString(diffAmt)); //Changed By PriyankaC
glTran.put("cr_amt",diffAmt.toString());
glTran.put("dr_amt_base",Double.toString(exch * Double.parseDouble(glTran.get("dr_amt").toString())));
glTran.put("cr_amt_base",Double.toString(exch * Double.parseDouble(glTran.get("cr_amt").toString())));
glTran.put("chg_user","BASE");
glTran.put("chg_term","SYSTEM");
//Added by Varsha V for closing resultset on 19-04-2018
if(rs != null)
{
rs.close();
rs = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
errString = glTranUpdate(glTran,conn);
}else{
//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("ref_ser",refSer);
glTran.put("ref_id",refId);
exch = 1;
glTran.put("dr_amt_base",Double.toString(exch * Double.parseDouble(glTran.get("dr_amt").toString())));
glTran.put("cr_amt_base",Double.toString(exch * Double.parseDouble(glTran.get("cr_amt").toString())));
glTran.put("chg_user","BASE");
glTran.put("chg_term","SYSTEM");
//Added by Varsha V for closing resultset on 19-04-2018
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
errString = glTranUpdate(glTran,conn);
}
}catch(Exception e){
System.out.println("Exception in checkGlTranDrCr [FinCommon]"+e);
......@@ -12689,7 +12734,7 @@ public class FinCommon
}finally{
try{
if(rs != null){rs.close();rs = null;}
if(stmt != null){stmt.close();stmt = null;}
if(pstmt != null){pstmt.close();pstmt = null;}
}catch(Exception t){}
}
System.out.println("Returning Strung :"+errString);
......@@ -16410,4 +16455,11 @@ public String nfCheckPeriod(String modCode, java.util.Date tranDate , String sit
return count;
}
//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