Commit 0cb90f1d authored by kshinde's avatar kshinde

Changed EJB code to Round of the amount


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@105300 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 78f150d8
......@@ -39,10 +39,12 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
String analysis1__dr="",analysis2__dr="",analysis3__dr="",analysis1__cr="",analysis2__cr="",analysis3__cr="";
String lsCctrCodeDis="",lsAcctCodeDis="",lsAcctSchemedet="",lsAcctCodePr="",lsCctrCodePr="",lsAcctCodeTax="",lsCctrCodeTax="";
String sql1="",lsTaxRecoCctr="",lsTaxRecoAcct="",lsAcctReco="",lsCctrReco="",lsAnalysis1="",lsAnalysis2="",lsAnalysis3="";
String custCode="",round="",roundInvTo="",ls_acct_code__radj="",ls_cctr_code__radj="",errString="";
double netamt=0.0,netamtr=0.0,roundTo=0.0,ln_amount_radj=0.0;
int detLineNo=0,iActCnt=0,uActCnt=0,schemeCount=0;
double detAmount=0.0,tempAmount=0.0,lnAmountDis=0.0,lcSchemeDiscount=0.0,lnAmountTax=0.0,lcRecoAmt=0.0,lnAmountSal=0.0;
PreparedStatement pstmt=null,pstmtU=null,pstmt1=null;
ResultSet rs=null,rs1=null;
PreparedStatement pstmt=null,pstmtU=null,pstmt1=null,pstmt2=null;
ResultSet rs=null,rs1=null,rs2=null;
boolean connFlag=false;
......@@ -75,6 +77,83 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
}
InvAcct invAcct=new InvAcct();
///Start of round code
sql="select cust_code,item_ser,net_amt from invoice where invoice_id=?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1,invoiceId );
rs2=pstmt2.executeQuery();
while(rs2.next())
{
custCode=rs2.getString("cust_code");
itemSer=rs2.getString("item_ser");
netamt=rs2.getDouble("net_amt");
}
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,custCode ) ;
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,itemSer);
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
{
//netamt= round(netamt,roundTo);
netamtr= Math.round(netamt);
sql="Update invoice set net_amt=?,round_adj=? where invoice_id=?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setDouble(1,netamtr);
pstmt2.setDouble(2,netamt-netamtr);
pstmt2.setString(3,invoiceId);
int count=pstmt2.executeUpdate();
System.out.println("count++++"+count);
//xmlBuff.append("<round_adj><![CDATA["+(netamt-netAmt)+"]]></round_adj>");
//xmlBuff.append("<net_amt><![CDATA["+netamt+"]]></net_amt>");
}
}else
{
netamtr=distCommon.getRndamt(netamt,round,roundTo);
sql="Update invoice set net_amt=?,round_adj=? where invoice_id=?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setDouble(1,netamtr);
pstmt2.setDouble(2,netamt-netamtr);
pstmt2.setString(3,invoiceId);
int count=pstmt2.executeUpdate();
System.out.println("count1++++"+count);
//xmlBuff.append("<round_adj><![CDATA["+(netamt-netamtr)+"]]></round_adj>");
//xmlBuff.append("<net_amt><![CDATA["+netamt+"]]></net_amt>");
}
///End of round code
/**
* Select from
* Invoice header
......@@ -788,6 +867,71 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
}//invoiceDetList FOR loop END
}
sql="select case when round_adj is null then 0 else round_adj end as round_adj from invoice where invoice_id=?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1,invoiceId );
rs2=pstmt2.executeQuery();
while(rs2.next())
{
ln_amount_radj=(rs2.getDouble("round_adj"));
System.out.println("ln_amount_radj+++++++"+ln_amount_radj);
}
ls_acct_code__radj =finCommon.getFinparams("999999","ROUND_ADJUST_ACCT", conn);
ls_cctr_code__radj = finCommon.getFinparams("999999","ROUND_ADJUST_CCTR", conn);
if( "NULLFOUND".equalsIgnoreCase(ls_acct_code__radj ))
{
ls_acct_code__radj=null;
}
else
{
ls_acct_code__radj=ls_acct_code__radj.trim();
}
if( "NULLFOUND".equalsIgnoreCase(ls_cctr_code__radj ))
{
ls_cctr_code__radj=null;
}
else
{
ls_cctr_code__radj=ls_acct_code__radj.trim();
}
if(ls_acct_code__radj==null || ls_acct_code__radj.trim().length()<=0)
{
retString = itmDBAccessEJB.getErrorString("","VTRNDACCT","","",conn);
}
if (ln_amount_radj != 0) // 07-dec-16 manoharan
{
System.out.println("Inside IF insert"+ln_amount_radj);
invAcctMap = new HashMap<String, String>();
invAcctMap.put("invoice_id", detInvId);
//invAcctMap.put("line_no",detLineNo);
invAcctMap.put("amount", ""+lnAmountTax);
invAcctMap.put("acct_code", ls_acct_code__radj);
invAcctMap.put("cctr_code", ls_cctr_code__radj);
invAcctMap.put("amount",""+ ln_amount_radj);
invAcctMap.put("analysis1", lsAnalysis1);
invAcctMap.put("analysis2", lsAnalysis2);
invAcctMap.put("analysis3", lsAnalysis3);
// System.out.println("@@@@@@@9 invAcctMap["+invAcctMap+"]");
//invAcctList.add(invAcctMap);
invAcctList = modifyinvAcctList(invAcctList,invAcctMap,lsAcctCodeTax,lsCctrCodeTax , lnAmountTax, checkNullSpace(hdrAnalCode) );
System.out.println("After Modify"+ln_amount_radj);
}
pstmt2.close();
pstmt2=null;
rs2.close();
rs2=null;
retString = insertInvAcctList( invAcctList,conn );
//System.out.println("@@@@@1032 retString["+retString+"]");
......
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