Commit 4b32df34 authored by cpandey's avatar cpandey

CHANGES DONE BY CHITRANJAN FOR UDATION OF CUSTOMER_SERIES TABLE


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91562 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 22f2e9ee
......@@ -57,26 +57,27 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
}
//END
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
//variable declaration
String sql = "";
String sql = "";
String sqlquery = "";
String errString = "";
String custCode = "";
String crTerm = "";
double crLimit = 0.0;
String crLimit = "";
String nwProdCrTerm = "";
double businessLimit = 0.0;
double discPerc = 0.0;
double commPerc = 0.0;
double commPerc1 = 0.0;
double commPerc2 = 0.0;
double creditPrd = 0.0;
int ignoreDays = 0;
double ignoreCredit = 0.0;
//end of varible declaration
String businessLimit = "";
String discPerc = "";
String commPerc = "";
String commPerc1 = "";
String commPerc2 = "";
String creditPrd = "";
String ignoreDays = "";
String ignoreCredit = "";
boolean sqlstr = false ;
//end of variable declaration
Connection conn = null;
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null;
......@@ -89,6 +90,7 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
{
System.out.println("*********inside try block*******");
ConnDriver connDriver = new ConnDriver();
StringBuffer strqry = new StringBuffer();
//get connection
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
......@@ -97,27 +99,71 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
custCode = genericUtility.getColumnValue("cust_code", headerDom)==null?"null":genericUtility.getColumnValue("cust_code", headerDom);
System.out.println("custCode--------"+custCode);
crTerm = genericUtility.getColumnValue("cr_term", headerDom)==null?"X":genericUtility.getColumnValue("cr_term", headerDom);
crTerm = genericUtility.getColumnValue("cr_term", headerDom);
if(crTerm!=null && crTerm.length()!=0 )
{
strqry.append("cr_term = '"+crTerm+"',");
}
System.out.println("crTerm--------"+crTerm);
crLimit = Double.valueOf(genericUtility.getColumnValue("credit_lmt", headerDom)==null?"0.0":genericUtility.getColumnValue("credit_lmt", headerDom)) ;
crLimit = genericUtility.getColumnValue("credit_lmt", headerDom);
if(crLimit!=null && crLimit.length()!=0 )
{
strqry.append("credit_lmt = '"+crLimit+"',");
}
System.out.println("crLimit--------"+crLimit);
nwProdCrTerm = genericUtility.getColumnValue("cr_term__np", headerDom)==null?"X":genericUtility.getColumnValue("cr_term__np", headerDom) ;
nwProdCrTerm = genericUtility.getColumnValue("cr_term__np", headerDom);
if( nwProdCrTerm!=null && nwProdCrTerm.length()!=0 )
{
strqry.append("cr_term__np = '"+nwProdCrTerm+"',");
}
System.out.println("nwProdCrTerm--------"+nwProdCrTerm);
businessLimit = Double.valueOf(genericUtility.getColumnValue("busi_limit", headerDom)==null?"0.0":genericUtility.getColumnValue("busi_limit", headerDom)) ;
businessLimit = genericUtility.getColumnValue("busi_limit", headerDom);
if( businessLimit!=null && businessLimit.length()!=0 )
{
strqry.append("busi_limit = '"+businessLimit+"',");
}
System.out.println("businessLimit--------"+businessLimit);
discPerc = Double.valueOf(genericUtility.getColumnValue("disc_perc", headerDom)==null?"0.0":genericUtility.getColumnValue("disc_perc", headerDom)) ;
discPerc = genericUtility.getColumnValue("disc_perc", headerDom);
if( discPerc!=null && discPerc.length()!=0 )
{
strqry.append("disc_perc = '"+discPerc+"',");
}
System.out.println("discPerc--------"+discPerc);
commPerc = Double.valueOf(genericUtility.getColumnValue("comm_perc", headerDom)==null?"0.0":genericUtility.getColumnValue("comm_perc", headerDom)) ;
commPerc = genericUtility.getColumnValue("comm_perc", headerDom);
if( commPerc!=null && commPerc.length()!=0 )
{
strqry.append("comm_perc = '"+commPerc+"',");
}
System.out.println("commPerc--------"+commPerc);
commPerc1 = Double.valueOf(genericUtility.getColumnValue("comm_perc__1", headerDom)==null?"0.0":genericUtility.getColumnValue("comm_perc__1", headerDom));
commPerc1 = genericUtility.getColumnValue("comm_perc__1", headerDom);
if( commPerc1!=null && commPerc1.length()!=0 )
{
strqry.append("comm_perc__1 = '"+commPerc1+"',");
}
System.out.println("commPerc1--------"+commPerc1);
commPerc2 = Double.valueOf(genericUtility.getColumnValue("comm_perc__2", headerDom)==null?"0.0":genericUtility.getColumnValue("comm_perc__2", headerDom)) ;//
commPerc2 = genericUtility.getColumnValue("comm_perc__2", headerDom);//
if( commPerc2!=null && commPerc2.length()!=0 )
{
strqry.append("comm_perc__2 = '"+commPerc2+"',");
}
System.out.println("commPerc2--------"+commPerc2);
ignoreDays = Integer.valueOf(genericUtility.getColumnValue("ignore_days", headerDom) ==null?"0":genericUtility.getColumnValue("ignore_days", headerDom));
ignoreDays = genericUtility.getColumnValue("ignore_days", headerDom) ;
if( ignoreDays!=null && ignoreDays.length()!=0 )
{
strqry.append("ignore_days = '"+ignoreDays+"',");
}
System.out.println("ignoreDays--------"+ignoreDays);
ignoreCredit = Double.valueOf(genericUtility.getColumnValue("ignore_credit", headerDom)==null?"0.0":genericUtility.getColumnValue("ignore_credit", headerDom)) ;
ignoreCredit = genericUtility.getColumnValue("ignore_credit", headerDom);
if( ignoreCredit!=null && ignoreCredit.length()!=0 )
{
strqry.append("ignore_credit = '"+ignoreCredit+"',");
}
System.out.println("ignoreCredit--------"+ignoreCredit);
creditPrd = Double.valueOf(genericUtility.getColumnValue("credit_prd", headerDom)==null?"0.0":genericUtility.getColumnValue("credit_prd", headerDom)) ;
creditPrd = genericUtility.getColumnValue("credit_prd", headerDom);
if( creditPrd!=null && creditPrd.length()!=0 )
{
strqry.append("credit_prd = '"+creditPrd+"',");
}
System.out.println("credit period-------"+creditPrd);
//IF CUSTOMER CODE IS NOT NULL THEN IT SHOULD BE EXIST IN CUSTOMER TABLE
if(custCode!=null)
......@@ -128,7 +174,7 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
rs = pstmt1.executeQuery();
while( rs.next() )
{
System.out.println("count1----"+rs.getInt(1));
System.out.println("count1----"+rs.getInt(1));
count = rs.getInt(1);
}
System.out.println("count----"+count);
......@@ -144,29 +190,27 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
}
else
{
sql = "SELECT COUNT(*) FROM CUSTOMER_SERIES WHERE CUST_CODE = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, custCode );
rs = pstmt1.executeQuery();
while( rs.next() )
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt1.close();
pstmt1 = null;
if(count == 0)
{
System.out.println("customer code in Customer Series master ");
errString = itmDBAccessEJB.getErrorString("","VTINVCUSCO","","",conn);
return errString;
}
sql = "SELECT COUNT(*) FROM CUSTOMER_SERIES WHERE CUST_CODE = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, custCode );
rs = pstmt1.executeQuery();
while( rs.next() )
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt1.close();
pstmt1 = null;
if(count == 0)
{
System.out.println("customer code in Customer Series master ");
errString = itmDBAccessEJB.getErrorString("","VTINVCUSCO","","",conn);
return errString;
}
}
}
if(!crTerm.equals("X"))
if(crTerm!=null && crTerm.trim().length()!=0 )
{
sql = "SELECT COUNT(*) FROM CRTERM WHERE CR_TERM = ?";
pstmt1 = conn.prepareStatement(sql);
......@@ -187,9 +231,9 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
return errString;
}
}
if(!nwProdCrTerm.equals("X"))
if(nwProdCrTerm!=null && nwProdCrTerm.trim().length()!=0 )
{
sql = "SELECT COUNT(*) FROM CRTERM WHERE CR_TERM = ?";
pstmt1 = conn.prepareStatement(sql);
......@@ -210,36 +254,55 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
return errString;
}
}
//update customer _series table against customer code (cust_code)
sql="update customer_series set cr_term = ( case when '"+crTerm+"' = 'X' then cr_term else '"+crTerm+"' end)" +
", credit_lMT = ( case when "+crLimit+" = 0.0 then credit_lmt else "+crLimit+" end)" +
",cr_term__np = ( case when '"+nwProdCrTerm+"' = 'X' then cr_term__np else '"+nwProdCrTerm+"' end)"+
",busi_limit = ( case when "+businessLimit+" = 0.0 then busi_limit else "+businessLimit+" end)"+
",disc_perc = ( case when "+discPerc+" = 0.0 then disc_perc else "+discPerc+" end) "+
",comm_perc = ( case when "+commPerc+" = 0.0 then comm_perc else "+commPerc+" end) "+
",comm_perc__1 = ( case when "+commPerc1+" = 0.0 then comm_perc__1 else "+commPerc1+" end) "+
",comm_perc__2 = ( case when "+commPerc2+" = 0.0 then comm_perc__2 else "+commPerc2+" end) "+
",ignore_days = ( case when "+ignoreDays+" = 0 then ignore_days else "+ignoreDays+" end) "+
",ignore_credit = ( case when "+ignoreCredit+" = 0.0 then ignore_credit else "+ignoreCredit+" end)"+
",credit_prd = ( case when "+creditPrd+" = 0.0 then credit_prd else "+creditPrd+" end)"+
" where cust_code =?";
System.out.println("sql-------"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
count = pstmt.executeUpdate();
pstmt.close();
if(count > 0)
//if string buffer is not null then convert sql string to to string
if(strqry.length()!=0)
{
sqlquery= strqry.toString();
System.out.println("SQL QUERY FOR BUFER ---["+sqlquery+"]");
sql = sqlquery.substring(0,sqlquery.lastIndexOf(','));
System.out.println("SQL FOR INDEX------["+sql+"]");
sqlstr = true;
}
if(strqry.length()==0)
{
System.out.println("update row "+count);
errString = itmDBAccessEJB.getErrorString("","VTPRCOMPLT","","",conn);
//return errString;
System.out.println("no updation for customer series table ");
errString = itmDBAccessEJB.getErrorString("","VTPRCOMPIU","","",conn);
sqlstr = false;
}
if(sqlstr)
{
sql="update customer_series set "+sql+
" where cust_code =?";
System.out.println("SQL FOR UPDATION ["+sql+"]");
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
count = pstmt.executeUpdate();
pstmt.close();
if(count > 0)
{
System.out.println("update row "+count);
errString = itmDBAccessEJB.getErrorString("","VTPRCOMPLT","","",conn);
//return errString;
}
System.out.println("SQL STATEMENT "+sql);
}
//update customer _series table against customer code (cust_code)
// sql="update customer_series set cr_term = ( case when '"+crTerm+"' = 'X' then cr_term else '"+crTerm+"' end)" +
// ", credit_lMT = ( case when '"+crLimit+"' = 'X' then credit_lmt else "+crLimit+" end)" +
// ",cr_term__np = ( case when '"+nwProdCrTerm+"' = 'X' then cr_term__np else '"+nwProdCrTerm+"' end)"+
// ",busi_limit = ( case when '"+businessLimit+"' = 'X' then busi_limit else "+businessLimit+" end)"+
// ",disc_perc = ( case when '"+discPerc+"' = 'X' then disc_perc else "+discPerc+" end) "+
// ",comm_perc = ( case when '"+commPerc+"' = 'X' then comm_perc else "+commPerc+" end) "+
// ",comm_perc__1 = ( case when '"+commPerc1+"' = 'X' then comm_perc__1 else "+commPerc1+" end) "+
// ",comm_perc__2 = ( case when '"+commPerc2+"' = 'X' then comm_perc__2 else "+commPerc2+" end) "+
// ",ignore_days = ( case when '"+ignoreDays+"' = 'X' then ignore_days else "+ignoreDays+" end) "+
// ",ignore_credit = ( case when '"+ignoreCredit+"' = 'X' then ignore_credit else "+ignoreCredit+" end)"+
// ",credit_prd = ( case when '"+creditPrd+"' = 'X' then credit_prd else "+creditPrd+" end)"+
// " where cust_code =?";
}
catch(Exception se)
......@@ -299,8 +362,8 @@ public class CustSeriesPrcEjb extends ProcessEJB implements CustSeriesPrcEjbLoc
@Override
public void remove() {
// TODO Auto-generated method stub
}
}
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