Commit b6737ab7 authored by pchavan's avatar pchavan

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195282 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 340183b8
......@@ -21,6 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -1076,7 +1077,8 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
rs=pstmt.executeQuery();
if(rs.next())
{
netAmt=rs.getDouble(1);
// netAmt = rs.getDouble(1);
netAmt =getUnroundDecimal(rs.getDouble(1), 3);
taxAmt=rs.getDouble(2);
commAmt=rs.getDouble(3);
discAmt=rs.getDouble(4);
......@@ -1126,6 +1128,8 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
{
netamt=geRndamt(netAmt,round,roundTo);
}
System.out.println("totTaxAmt [: netamt : " + netamt +" [ : ]" + netAmt);
//sql = "update invoice set net_amt=?,tax_amt=?,comm_amt=?,disc_amt=?,inv_amt=? where invoice_id=?";
sql = "update invoice set net_amt=?,tax_amt=?,comm_amt=?,disc_amt=?,inv_amt = ?,round_adj = ? where invoice_id=?";
//PriyankaC [End].
......@@ -1134,8 +1138,8 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt.setDouble(2,taxAmt);
pstmt.setDouble(3,commAmt);
pstmt.setDouble(4,discAmt);
pstmt.setDouble(5,(netamt+discAmt)-taxAmt);
pstmt.setDouble(6,(netamt - netAmt )); // Added By Priyankac 0n 28DEC2018.
pstmt.setDouble(5,getUnroundDecimal(((netamt+discAmt)-taxAmt),3)); //Added By PriyankaC
pstmt.setDouble(6,getUnroundDecimal((netamt - netAmt ),3)); // Added By Priyankac 0n 28DEC2018.
pstmt.setString(7,tranId);
pstmt.executeUpdate();
pstmt.close();
......@@ -1158,7 +1162,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
String sordNo="",soLineNo="",taxClass="",taxChap="",taxEnv="",itemCode="";
//double taxAmt=0,netAmt=0;
double totTaxAmt=0,totNetAmt=0;
double totTaxAmt=0,totNetAmt=0 ,roundNetamt=0;
//fos1.write(("Invoice successful for Dispatch id :- ["+despIdKey+"] TranId generated is:- [" + tranId +"]\n END \r\n\n").getBytes());
/*pstmt=conn.prepareStatement("update invoice_trace set net_amt=(quantity__stduom*rate__stduom) where invoice_id=? ");
......@@ -1221,7 +1225,9 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
netAmt=rs.getDouble(8);
totTaxAmt+=taxAmt;
totNetAmt+=netAmt;
totTaxAmt = getUnroundDecimal((totTaxAmt),3); //Changed By PriyankaC on 2JAN2019.
totNetAmt = getUnroundDecimal((totNetAmt),3); //Changed By PriyankaC on 2JAN2019.
System.out.println("totTaxAmt [: totNetAmt : " + totTaxAmt +" [ : ]" + totNetAmt);
/*sql="update invdet set tax_class=?,tax_chap=?,tax_env=?,tax_amt=tax_amt+?,net_amt=net_amt+?+?"
+ " where invoice_id=? "
......@@ -1256,14 +1262,59 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt.close();
pstmt=null;
// Added PriyankaC for update invoice
sql="select round, case when round_to is null then 0.001 else round_to end as round_to " +
" from customer where cust_code = ?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1, invDespMap.get("cust_code") );
rs2=pstmt2.executeQuery();
if(rs2.next())
{
round =rs2.getString("round");
roundTo =rs2.getDouble("round_to");
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
if(round ==null || round.trim().length()==0)
{
sql="select round_inv_to from itemser where item_ser = ?" ;
pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1, invDespMap.get("item_ser") );
rs2=pstmt2.executeQuery();
if(rs2.next())
{
roundInvTo =rs2.getString("round_inv_to");
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
if(roundInvTo ==null)
{
retString = "VTRND";
return retString;
}else
{
roundNetamt= Math.round(totNetAmt);
}
}else
{
roundNetamt=geRndamt(totNetAmt,round,roundTo);
}
System.out.println("totTaxAmtBfrUdt [: roundNetamt : " + roundNetamt +" [ : ]" + totNetAmt);
sql="update invoice set tax_amt=?,net_amt=?,inv_amt=? where invoice_id=? ";
// Added PriyankaC for update invoice [END]
sql = "update invoice set tax_amt=?,net_amt=?,inv_amt=? , round_adj = ? where invoice_id=? " ;
//sql="update invoice set tax_amt=?,net_amt=?,inv_amt=? where invoice_id=? ";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, totTaxAmt);
//pstmt.setDouble(2, totTaxAmt);
pstmt.setDouble(2, totNetAmt);
pstmt.setDouble(3, ((totNetAmt+discAmt)-totTaxAmt));
pstmt.setString(4,tranId);
pstmt.setDouble(2, roundNetamt);
pstmt.setDouble(3, getUnroundDecimal(((roundNetamt+discAmt)-totTaxAmt),3)); //Added By Priyankac to round the decimal.
pstmt.setDouble(4, getUnroundDecimal((roundNetamt-totNetAmt),3)); //Added By Priyankac to round the decimal.
pstmt.setString(5,tranId);
pstmt.executeUpdate();
pstmt.close();
pstmt=null;
......@@ -4532,5 +4583,27 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
}
return input;
}
//Added BY PriyanaC on 02JAN2018
public double getUnroundDecimal(double actVal, int prec)
{
String fmtStr = "############0";
String strValue = null;
double retVal = 0;
if (prec > 0)
{
fmtStr = fmtStr + "." + "000000000".substring(0, prec + 1);
}
System.out.println("fmtStr value [" + fmtStr + "]");
DecimalFormat decFormat = new DecimalFormat(fmtStr);
strValue = decFormat.format(actVal);
System.out.println(" actVal [" + actVal + "] integer [" + strValue.substring(0,strValue.indexOf(".") +1) + "]");
System.out.println("decimal [" + strValue.substring(strValue.indexOf(".") + 1, strValue.indexOf(".") + prec + 1) + "]");
retVal = Double.parseDouble( strValue.substring(0,strValue.indexOf(".") +1) + strValue.substring(strValue.indexOf(".") + 1, strValue.indexOf(".") + prec + 1));
System.out.println("rounded value [" + retVal + "]");
return retVal;
}
//Added BY PriyanaC on 02JAN2018
}
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