Commit 0c744eff authored by cshah's avatar cshah

DI90UNI059-update query change for depb table ,instead of adv_licence_exp the...

DI90UNI059-update query change for depb table ,instead of adv_licence_exp the update query is set for adv_licence tablejava-projects-ejb3/ibase/webitm-dis/ibase/webitm/ejb/dis


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91343 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ce814f53
......@@ -146,9 +146,15 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
return resultString;
}
sql = " select count(*) from benefit_trace where ref_ser = 'S-DSP' and ref_no = ? ";
/*
sql = " select count(*) from benefit_trace where ref_ser = 'S-DSP' and ref_no = ? ";
*/
//Benefit_type condition is Added in select query by Chandni Shah - 14/09/10 ---DI89UNI060
sql = " select count(*) from benefit_trace where benefit_type = ? and ref_ser = 'S-DSP' and ref_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId.trim());
pstmt.setString(1,benefitType.trim());
pstmt.setString(2,tranId.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -367,6 +373,8 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
return retStr;
}//END OF PROCESS (1)
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
......@@ -379,6 +387,9 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
String retString = "" ,errCode = "",tranId="";
String loginSiteCode="",empCode="",chgUser="",chgTerm="",loginCode="",termid = "";
String policyNo="",insCertNo="",agent_code="",invoiceId="";
String confirm ="";
String invId = "" ;
String conf = "";
int count =0,cnt =0;
String curr_code="",dayNo = "",shiftOfDay = "";
double exch_rate=0,netAmt=0;
......@@ -453,7 +464,8 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
int cntSec = 0,i=0;
// end of code
try
{
{
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
......@@ -470,294 +482,344 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
currAppdate = genericUtility.getValidDateString(currAppdate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
currDate = Timestamp.valueOf(currAppdate + " 00:00:00.00");
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
parentNodeListLength = parentNodeList.getLength();
benefitType = genericUtility.getColumnValue("benefit_type",headerDom);
benefitType = benefitType == null ? "" :benefitType.trim();
tranId = genericUtility.getColumnValue("tran_id",headerDom);
tranId = tranId == null ? "" :tranId.trim();
exchangeRate = genericUtility.getColumnValue("exchange_rate",headerDom);
exchangeRate = exchangeRate == null ? "1.000":exchangeRate.trim();
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("tran_id"))
{
if(childNode.getFirstChild()!=null)
{
// add on 14/10/09
//advLicMulTranId[selectedRow] = childNode.getFirstChild().getNodeValue();
String advLicMulTranIdStr = childNode.getFirstChild().getNodeValue();
advLicMulTranId.add(advLicMulTranIdStr);
//advLicMulTranId[selectedRow] = childNode.getFirstChild().getNodeValue();
// end of code on 14/10/09
System.out.println("advLicMulTranIdStr>>>>>"+advLicMulTranIdStr);
}
}
if (childNodeName.equals("exchange_rate"))
{
if(childNode.getFirstChild()!=null)
{
exchangeRate = childNode.getFirstChild().getNodeValue();
}
}
}//inner for loop] lotNoFromStr
if((exchangeRate==null || exchangeRate.length()==0 ) && benefitType.trim().equalsIgnoreCase("AL"))
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
exchangeRateStr = itmDBAccessEJB.getErrorString("","VTEXHEMTY",userId);
return exchangeRateStr ;
}
}// OUT FOR LOOP
////////////////////////code to be migrated for dispatch//////////////////
// all details is in site the
// changes by manazir on 30-05-09
/*StringTokenizer stringTokenizer = null;
stringTokenizer = new StringTokenizer(advLicMulTranId[0] ,",");
// actually this is tranId of follwing datawindow
int i=0;
while(stringTokenizer.hasMoreElements())
{
asAdvLic[i]= Double.parseDouble(stringTokenizer.nextToken());
i++;
}*/
// changes on 15/10/09
// asAdvLic = advLicMulTranId ;
System.out.println("advLicMulTranId.get(0)>>>"+advLicMulTranId.get(0));
// System.out.println("asAdvLic>>>"+asAdvLic[0]);
sql="select curr_code, exch_rate "
+" from despatch where desp_id = ? ";
exchangeRate = exchangeRate == null ? "1.000":exchangeRate.trim();
//-Added by Chandni Shah 26/08/10 ---DI89UNI060
//if selectd despatch is confirmed and invoice is generated then only the process is completed
sql="select confirmed from despatch where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
despCurrCode = rs.getString(1) == null ?"":rs.getString(1);
exchRate = rs.getString(2) == null ?"":rs.getString(2);
if(!("".equalsIgnoreCase(exchRate) && exchRate != null ))
{
exchRateDec = Double.parseDouble(exchRate );
}
else{exchRateDec=0;}
confirm = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
////////////////////////////////end of code////////////////////////
//s_pass1.mdecimal = exchRateDec
//Added By Jasmina 22/10/08 -DI89SUN109
//advLicTranId = gfGetSqlInString(asAdvLic);
// changes on the 15/10/09 as ArrayList pass to the function
advLicTranId = gfGetSqlInString(advLicMulTranId);
//ls_sql = ' '
//advLicTranId = asAdvLic[0];
System.out.println(" return value of String parameter advLicTranId>>>"+advLicTranId);
sql=" SELECT count(1) from "
+" (SELECT b.site_code,d.item_code,a.eff_from ,a.extend_upto, a.valid_upto, "
+" d.quantity,d.quantity_exp, a.ext_valid1, a.ext_valid2, a. ext_valid3 "
+" FROM adv_licence a,site b,finent c ,adv_licence_exp d "
+" where a.tran_id = d.tran_id and a.site_code = b.site_code and b.fin_entity = c.fin_entity and "
+" a.tran_id in (" +advLicTranId+ ") and d.quantity > d.quantity_exp and a.status = 'O' ) X, "
+"(select p.desp_id,s.item_code,eff_date, p.site_code from despatch p,site q,finent r, despatchdet s "
+" where p.desp_id = s.desp_id and p.site_code = q.site_code and q.fin_entity = r.fin_entity and "
+" p.desp_id = ? ) Y where x.eff_from <= y.eff_date "
+" and x.site_code = y.site_code and "
+"((x.valid_upto >= y.eff_date and x.valid_upto is not null ) "
+"OR (x.extend_upto >= y.eff_date and x.extend_upto is not null) "
+"OR (x.ext_valid1 >= y.eff_date and x.ext_valid1 is not null) "
+"OR (x.ext_valid2 >= y.eff_date and x.ext_valid2 is not null) "
+"OR (x.ext_valid3 >= y.eff_date and x.ext_valid3 is not null) ) "
+"and x.item_code in (select item_code from item where item_code__al = (select item_code__al from item where item_code = y.item_code)) ";
if ("Y".equalsIgnoreCase(confirm))
{
sql = "select invoice_id,confirmed from invoice where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
invId = rs.getString(1);
conf = rs.getString(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (invId != null && ("Y".equalsIgnoreCase(conf)) )
{
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("tran_id"))
{
if(childNode.getFirstChild()!=null)
{
// add on 14/10/09
//advLicMulTranId[selectedRow] = childNode.getFirstChild().getNodeValue();
String advLicMulTranIdStr = childNode.getFirstChild().getNodeValue();
advLicMulTranId.add(advLicMulTranIdStr);
//advLicMulTranId[selectedRow] = childNode.getFirstChild().getNodeValue();
// end of code on 14/10/09
System.out.println("advLicMulTranIdStr>>>>>"+advLicMulTranIdStr);
}
}
if (childNodeName.equals("exchange_rate"))
{
if(childNode.getFirstChild()!=null)
{
exchangeRate = childNode.getFirstChild().getNodeValue();
}
}
}//inner for loop] lotNoFromStr
if((exchangeRate==null || exchangeRate.length()==0 ) && benefitType.trim().equalsIgnoreCase("AL"))
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
exchangeRateStr = itmDBAccessEJB.getErrorString("","VTEXHEMTY",userId);
return exchangeRateStr ;
}
}// OUT FOR LOOP
/////////////code to be migrated for dispatch//////////////////
// all details is in site the
// changes by manazir on 30-05-09
/*StringTokenizer stringTokenizer = null;
stringTokenizer = new StringTokenizer(advLicMulTranId[0] ,",");
// actually this is tranId of follwing datawindow
int i=0;
while(stringTokenizer.hasMoreElements())
{
asAdvLic[i]= Double.parseDouble(stringTokenizer.nextToken());
i++;
}*/
// changes on 15/10/09 Chandni Shah
// asAdvLic = advLicMulTranId ;
System.out.println("advLicMulTranId.get(0)>>>"+advLicMulTranId.get(0));
// System.out.println("asAdvLic>>>"+asAdvLic[0]);
sql="select curr_code, exch_rate "
+" from despatch where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
despCurrCode = rs.getString(1) == null ?"":rs.getString(1);
exchRate = rs.getString(2) == null ?"":rs.getString(2);
if(!("".equalsIgnoreCase(exchRate) && exchRate != null ))
{
exchRateDec = Double.parseDouble(exchRate );
}
else{exchRateDec=0;}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt ==0)
/////////////////end of code////////////////////////
//s_pass1.mdecimal = exchRateDec
//Added By Jasmina 22/10/08 -DI89SUN109
//advLicTranId = gfGetSqlInString(asAdvLic);
// changes on the 15/10/09 as ArrayList pass to the function
advLicTranId = gfGetSqlInString(advLicMulTranId);
System.out.println(" advLicTranId ==============>>>>>>>>>>>>>>>>>>>>>"+advLicTranId);
// changes on 13/09/10 -- Chandni Shah ---DI89UNI060
// advLicTranId is only for benefit_type == 'AL'
if ("AL".equalsIgnoreCase(benefitType))
{
sqlSec=" SELECT count(1) FROM "
+" (SELECT b.site_code,d.item_code,a.eff_from ,a.extend_upto, a.valid_upto, "
+" d.quantity,d.quantity_exp, a.ext_valid1, a.ext_valid2, a. ext_valid3 "
+" FROM adv_licence a,site b,finent c ,adv_licence_exp d "
+" where a.tran_id = d.tran_id and a.site_code = b.site_code and b.fin_entity = c.fin_entity and "
+" a.tran_id in (" +advLicTranId+") and d.quantity > d.quantity_exp and a.status = 'O' ) X, "
+" (select p.desp_id,s.item_code,eff_date, p.site_code from despatch p,site q,finent r, despatchdet s "
+" where p.desp_id = s.desp_id and p.site_code = q.site_code and q.fin_entity = r.fin_entity and "
+" p.desp_id = ? ) Y where x.eff_from <= y.eff_date "
+" and ((x.valid_upto >= y.eff_date and x.valid_upto is not null ) "
+" OR (x.extend_upto >= y.eff_date and x.extend_upto is not null) "
+" OR (x.ext_valid1 >= y.eff_date and x.ext_valid1 is not null) "
+" OR (x.ext_valid2 >= y.eff_date and x.ext_valid2 is not null) "
+" OR (x.ext_valid3 >= y.eff_date and x.ext_valid3 is not null) ) "
+" and x.item_code in (select item_code from item where item_code__al = (select item_code__al from item where item_code = y.item_code)) ";
pstmtSec = conn.prepareStatement(sqlSec);
pstmtSec.setString(1,tranId.trim());
rs = pstmtSec.executeQuery();
if(rsSec.next())
{
cntSec = rsSec.getInt(1);
}
rsSec.close();
rsSec = null;
pstmtSec.close();
pstmtSec = null;
if(cntSec > 0)
{
sqlThr = "select msg_type "
+" from messages_level "
+ "where profile_id = ? " ////////////????????????????
+" and msg_no = 'VNOALSITE' "
+ "and UPPER(win_name) = 'W_DESPATCH' ";
pstmtThr = conn.prepareStatement(sqlThr);
pstmtThr.setString(1,chgUser.trim());
rsThr = pstmtThr.executeQuery();
if(rsThr.next())
//advLicTranId = gfGetSqlInString(advLicMulTranId);
//ls_sql = ' '
//advLicTranId = asAdvLic[0];
System.out.println(" return value of String parameter advLicTranId>>>"+advLicTranId);
sql=" SELECT count(1) from "
+" (SELECT b.site_code,d.item_code,a.eff_from ,a.extend_upto, a.valid_upto, "
+" d.quantity,d.quantity_exp, a.ext_valid1, a.ext_valid2, a. ext_valid3 "
+" FROM adv_licence a,site b,finent c ,adv_licence_exp d "
+" where a.tran_id = d.tran_id and a.site_code = b.site_code and b.fin_entity = c.fin_entity and "
+" a.tran_id in (" +advLicTranId+ ") and d.quantity > d.quantity_exp and a.status = 'O' ) X, "
+"(select p.desp_id,s.item_code,eff_date, p.site_code from despatch p,site q,finent r, despatchdet s "
+" where p.desp_id = s.desp_id and p.site_code = q.site_code and q.fin_entity = r.fin_entity and "
+" p.desp_id = ? ) Y where x.eff_from <= y.eff_date "
+" and x.site_code = y.site_code and "
+"((x.valid_upto >= y.eff_date and x.valid_upto is not null ) "
+"OR (x.extend_upto >= y.eff_date and x.extend_upto is not null) "
+"OR (x.ext_valid1 >= y.eff_date and x.ext_valid1 is not null) "
+"OR (x.ext_valid2 >= y.eff_date and x.ext_valid2 is not null) "
+"OR (x.ext_valid3 >= y.eff_date and x.ext_valid3 is not null) ) "
+"and x.item_code in (select item_code from item where item_code__al = (select item_code__al from item where item_code = y.item_code)) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
msgType = rsThr.getString(1) == null ?"":rsThr.getString(1);
cnt = rs.getInt(1);
}
rsThr.close();
rsThr = null;
pstmtThr.close();
pstmtThr = null;
if(msgType==null || msgType.trim().length()==0)
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt ==0)
{
sqlThr = "select msg_type "
+" from messages "
+ "where msg_no = 'VNOALSITE' " ;
pstmtThr = conn.prepareStatement(sqlThr);
rsThr = pstmtThr.executeQuery();
if(rsThr.next())
sqlSec=" SELECT count(1) FROM "
+" (SELECT b.site_code,d.item_code,a.eff_from ,a.extend_upto, a.valid_upto, "
+" d.quantity,d.quantity_exp, a.ext_valid1, a.ext_valid2, a. ext_valid3 "
+" FROM adv_licence a,site b,finent c ,adv_licence_exp d "
+" where a.tran_id = d.tran_id and a.site_code = b.site_code and b.fin_entity = c.fin_entity and "
+" a.tran_id in (" +advLicTranId+") and d.quantity > d.quantity_exp and a.status = 'O' ) X, "
+" (select p.desp_id,s.item_code,eff_date, p.site_code from despatch p,site q,finent r, despatchdet s "
+" where p.desp_id = s.desp_id and p.site_code = q.site_code and q.fin_entity = r.fin_entity and "
+" p.desp_id = ? ) Y where x.eff_from <= y.eff_date "
+" and ((x.valid_upto >= y.eff_date and x.valid_upto is not null ) "
+" OR (x.extend_upto >= y.eff_date and x.extend_upto is not null) "
+" OR (x.ext_valid1 >= y.eff_date and x.ext_valid1 is not null) "
+" OR (x.ext_valid2 >= y.eff_date and x.ext_valid2 is not null) "
+" OR (x.ext_valid3 >= y.eff_date and x.ext_valid3 is not null) ) "
+" and x.item_code in (select item_code from item where item_code__al = (select item_code__al from item where item_code = y.item_code)) ";
pstmtSec = conn.prepareStatement(sqlSec);
pstmtSec.setString(1,tranId.trim());
rsSec = pstmtSec.executeQuery();
if(rsSec.next())
{
msgType = rsThr.getString(1) == null ?"":rsThr.getString(1);
cntSec = rsSec.getInt(1);
}
rsThr.close();
rsThr = null;
pstmtThr.close();
pstmtThr = null;
}
if(msgType.equalsIgnoreCase("E"))
rsSec.close();
rsSec = null;
pstmtSec.close();
pstmtSec = null;
if(cntSec > 0)
{
sqlThr = "select msg_type "
+" from messages_level "
+ "where profile_id = ? " ////////////????????????????
+" and msg_no = 'VNOALSITE' "
+ "and UPPER(win_name) = 'W_DESPATCH' ";
pstmtThr = conn.prepareStatement(sqlThr);
pstmtThr.setString(1,chgUser.trim());
rsThr = pstmtThr.executeQuery();
if(rsThr.next())
{
msgType = rsThr.getString(1) == null ?"":rsThr.getString(1);
}
rsThr.close();
rsThr = null;
pstmtThr.close();
pstmtThr = null;
if(msgType==null || msgType.trim().length()==0)
{
sqlThr = "select msg_type "
+" from messages "
+ "where msg_no = 'VNOALSITE' " ;
pstmtThr = conn.prepareStatement(sqlThr);
rsThr = pstmtThr.executeQuery();
if(rsThr.next())
{
msgType = rsThr.getString(1) == null ?"":rsThr.getString(1);
}
rsThr.close();
rsThr = null;
pstmtThr.close();
pstmtThr = null;
}
if(msgType.equalsIgnoreCase("E"))
{
errString = itmDBAccessEJB.getErrorString("","VNOALSITE",userId);
resultString =errString ;
return resultString ;
}
}
else
{
errString = itmDBAccessEJB.getErrorString("","VNOAL",userId);
resultString =errString ;
return resultString ;
}
} // end of if cnt==0
// comment on 15/10/09
//for(i=0;i<asAdvLic.length ; i++)
for(i=0; i<advLicMulTranId.size(); i++)
{
errString = itmDBAccessEJB.getErrorString("","VNOALSITE",userId);
resultString =errString ;
return resultString ;
}
advLicStr = (String)advLicMulTranId.get(i);
System.out.println("advLicMulTranId.get(i) "+advLicMulTranId.get(i));
System.out.println("get From ArrayList "+advLicStr);
sql= "select curr_code, file_no "
+" from adv_licence where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,advLicStr);
rs = pstmt.executeQuery();
if(rs.next())
{
currCode = rs.getString("curr_code")==null ?"":rs.getString("curr_code");
fileNo = rs.getString("file_no")==null ?"":rs.getString("file_no");
}
pstmt.close();
pstmt =null;
rs.close();
rs=null;
// add on 15/10/09
//currCodeArry[i]=currCode;
currCodeArry.add(currCode);
fileNoArry.add(fileNo);
//fileNoArry[i] = fileNo;
//exchRateArry[i] = exchRateDec;
exchRateArry.add(new Double(exchRateDec));
// end of add on 15/10/09
//if(despCurrCode.equalsIgnoreCase(currCodeArry[i]))
//{
//}
/*if (ls_desp_curr_code) <> (las_curr_code[li_cnt]) then
s_pass1.mvar1 = asAdvLic[li_cnt]
s_pass1.mvar2 = las_file_no[li_cnt]
s_pass1.mvar3 = ls_desp_curr_code
s_pass1.mvar4 = las_curr_code[li_cnt]
openwithparm(w_benefit_trace,s_pass1)
s_pass2 = message.powerobjectparm
if s_pass2.mdecimal > 0 then
lcExchrate[li_cnt] = s_pass2.mdecimal
end if
end if
next*/
}
} // end of IF stmt for benefit_type = 'AL'
if(advLicTranId.trim().length() > 0 && benefitType.trim().equalsIgnoreCase("AL"))
{
// merrcode = advanceLicence(tranId ,asAdvLic, exchRateArry , conn);
System.out.println("call the advanceLicence() method ");
merrcode = advanceLicence(tranId ,advLicMulTranId, exchRateArry , conn);
System.out.println("Returned merrcode>>>>>>>>>>>>>>>>>>"+merrcode );
}
else
if(advLicTranId.trim().length() > 0 && benefitType.trim().equalsIgnoreCase("DP"))
{
System.out.println("call the wfDepb() method ");
merrcode = wfDepb(tranId,advLicMulTranId , conn);
System.out.println("Returned merrcode>>>>>>>>>>>>>>>>>>"+merrcode );
}
if ("Error".equalsIgnoreCase(merrcode))
{
errString = itmDBAccessEJB.getErrorString("","VNOAL",userId);
conn.rollback();
errString = itmDBAccessEJB.getErrorString("","VTERRNT",userId);
resultString =errString ;
return resultString ;
return resultString;
}
} // end of if cnt==0
// comment on 15/10/09
//for(i=0;i<asAdvLic.length ; i++)
for(i=0; i<advLicMulTranId.size(); i++)
{
advLicStr = (String)advLicMulTranId.get(i);
System.out.println("advLicMulTranId.get(i) "+advLicMulTranId.get(i));
System.out.println("get From ArrayList "+advLicStr);
sql= "select curr_code, file_no "
+" from adv_licence where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,advLicStr);
rs = pstmt.executeQuery();
if(rs.next())
if ("Success".equalsIgnoreCase(merrcode))
{
currCode = rs.getString("curr_code")==null ?"":rs.getString("curr_code");
fileNo = rs.getString("file_no")==null ?"":rs.getString("file_no");
}
pstmt.close();
pstmt =null;
rs.close();
rs=null;
// add on 15/10/09
//currCodeArry[i]=currCode;
currCodeArry.add(currCode);
fileNoArry.add(fileNo);
//fileNoArry[i] = fileNo;
//exchRateArry[i] = exchRateDec;
exchRateArry.add(new Double(exchRateDec));
// end of add on 15/10/09
//if(despCurrCode.equalsIgnoreCase(currCodeArry[i]))
//{
//}
/*if (ls_desp_curr_code) <> (las_curr_code[li_cnt]) then
s_pass1.mvar1 = asAdvLic[li_cnt]
s_pass1.mvar2 = las_file_no[li_cnt]
s_pass1.mvar3 = ls_desp_curr_code
s_pass1.mvar4 = las_curr_code[li_cnt]
openwithparm(w_benefit_trace,s_pass1)
s_pass2 = message.powerobjectparm
if s_pass2.mdecimal > 0 then
lcExchrate[li_cnt] = s_pass2.mdecimal
end if
end if
next*/
}
if(advLicTranId.trim().length() > 0 && benefitType.trim().equalsIgnoreCase("AL"))
{
// merrcode = advanceLicence(tranId ,asAdvLic, exchRateArry , conn);
System.out.println("call the advanceLicence() method ");
merrcode = advanceLicence(tranId ,advLicMulTranId, exchRateArry , conn);
System.out.println("Returned merrcode>>>>>>>>>>>>>>>>>>"+merrcode );
}
if(advLicTranId.trim().length() > 0 && benefitType.trim().equalsIgnoreCase("DP"))
{
System.out.println("call the wfDepb() method ");
merrcode = wfDepb(tranId,advLicMulTranId , conn);
System.out.println("Returned merrcode>>>>>>>>>>>>>>>>>>"+merrcode );
}
if ("Error".equalsIgnoreCase(merrcode))
{
conn.rollback();
errString = itmDBAccessEJB.getErrorString("","VTERRNT",userId);
resultString =errString ;
return resultString;
}
if ("Success".equalsIgnoreCase(merrcode))
{
errString = itmDBAccessEJB.getErrorString("","VTSUCCE",userId);
resultString =errString ;
conn.commit();
return resultString;
}
errString = itmDBAccessEJB.getErrorString("","VTSUCCE",userId);
resultString =errString ;
conn.commit();
return resultString;
}
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTINVN ",userId);
resultString =errString ;
return resultString ;
}
} // end of if stmt of confirmed
else
{
errString = itmDBAccessEJB.getErrorString("","VTCONFN ",userId);
resultString =errString ;
return resultString ;
}
}
catch(Exception e)
{
try{
conn.rollback();
}catch(Exception e1)
{e1.printStackTrace();}
try{
conn.rollback();
}catch(Exception e1)
{e1.printStackTrace();}
System.out.println("Exception in BenefitDisPrcEJB..."+e.getMessage());
e.printStackTrace();
errorString = e.getMessage();
throw new ITMException(e);
System.out.println("Exception in BenefitDisPrcEJB..."+e.getMessage());
e.printStackTrace();
errorString = e.getMessage();
throw new ITMException(e);
}
finally
......@@ -813,8 +875,9 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
double baseValue = 0.00;
String merrcode = "";
String sql ="";
PreparedStatement pstmt =null,pstmtSec = null,pstmtInsert=null ;
PreparedStatement pstmt =null,pstmtSec = null,pstmtInsert=null,pstmt1 = null ;
ResultSet rs = null;
ResultSet rs1 = null;
Timestamp tranDate = null;
tranDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp chgDate = null;
......@@ -897,36 +960,38 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
+" order by despatchdet.item_code ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,despId);
rs = pstmt.executeQuery();
if(rs.next())
rs1 = pstmt.executeQuery();
//if(rs.next())
while (rs1.next())
{
itemCode = rs.getString(1)==null ?"":rs.getString(1);
currCode =rs.getString(2)==null ?"":rs.getString(2);
exchRate = rs.getString(3)==null ?"":rs.getString(3);
siteCode =rs.getString(4)==null ?"":rs.getString(4);
quantity = rs.getString(5)==null ?"":rs.getString(5);
itemCode = rs1.getString(1)==null ?"":rs1.getString(1);
currCode =rs1.getString(2)==null ?"":rs1.getString(2);
exchRate = rs1.getString(3)==null ?"":rs1.getString(3);
siteCode =rs1.getString(4)==null ?"":rs1.getString(4);
quantity = rs1.getString(5)==null ?"":rs1.getString(5);
if(!("".equalsIgnoreCase(quantity)))
{
quantityDec = Double.parseDouble(quantity);
}
value = rs.getString(6)==null ?"":rs.getString(6);
value = rs1.getString(6)==null ?"":rs1.getString(6);
if(!("".equalsIgnoreCase(value)))
{
valueDec = Double.parseDouble(value);
}
despLineNo=rs.getString(7)==null ?"":rs.getString(7);
unit =rs.getString(8)==null ?"":rs.getString(8);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
despLineNo=rs1.getString(7)==null ?"":rs1.getString(7);
unit =rs1.getString(8)==null ?"":rs1.getString(8);
//}
//rs.close();
//rs = null;
//pstmt.close();
//pstmt = null;
despQtyBal = quantityDec;
System.out.println("lsAdvLic.size() "+lsAdvLic.size() );
for(int i=0; i<lsAdvLic.size() ; i++)
{
//for(int i=0; i<lsAdvLic.size() ; i++)
//{
//baseValue = valueDec * acAxchrate[i];
// added on 15/10/09
int i = 0;
baseValue = valueDec * ((Double)lcExchrate.get(i)).doubleValue();
// end of code on 15/10/09
sql=" select adv_licence.tran_id, adv_licence_exp.line_no, "
......@@ -941,11 +1006,12 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
+" from item where item_code = ? )) "
+" and (case when adv_licence_exp.quantity is null then 0 else adv_licence_exp.quantity end) - "
+" (case when adv_licence_exp.quantity_exp is null then 0 else adv_licence_exp.quantity_exp end) > 0 ";
pstmt = conn.prepareStatement(sql);
pstmt1 = conn.prepareStatement(sql);
//pstmt.setString(1,advLicMulTranId[i]);
pstmt.setString(1,(String)lsAdvLic.get(i));
pstmt.setString(2,itemCode);
rs = pstmt.executeQuery();
pstmt1.setString(1,(String)lsAdvLic.get(i));
pstmt1.setString(2,itemCode);
rs = pstmt1.executeQuery();
System.out.println("ITEM CODE ==============="+itemCode);
while(rs.next())
{
tranId = rs.getString(1) == null ?"":rs.getString(1);
......@@ -976,19 +1042,23 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
pstmtItemCodeAl = null;
sqlItem= "select trim(unit) from item "
+" where item_code = ? ";
pstmtItem = conn.prepareStatement(sqlItem);
pstmtItem.setString(1,itemCodeDeal);
rsItem = pstmtItem.executeQuery();
System.out.println(" UNIT ========"+unit);
if(rsItem.next())
{
unitAl = rsItem.getString(1) == null ?"" : rsItem.getString(1);
System.out.println(" UNITALLL11 ========"+unitAl);
}
rsItem.close();
rsItem = null;
pstmtItem.close();
pstmtItem = null;
System.out.println("unit.equalsIgnoreCase(unitAl)[[["+unit.equalsIgnoreCase(unitAl));
if(!(unit.equalsIgnoreCase(unitAl)))
System.out.println(" UNITALLL ========"+unitAl);
System.out.println("unit.equalsIgnoreCase(unitAl)[[[" +(unit.trim().equalsIgnoreCase(unitAl.trim())));
if(!(unit.trim().equalsIgnoreCase(unitAl.trim())))
{
// ??? despQtyBal = gf_conv_qty_fact(unit, unitAl, itemCode, despQtyBal, lcConv) ;
convQuantityFactArryList = distCommon.getConvQuantityFact(unit,unitAl,itemCode,despQtyBal,lcConv,conn);
......@@ -1020,8 +1090,12 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
//((Double)lcAlqtyexp.get(i)).doubleValue() = ((Double)lcAlqtyexp.get(i)).doubleValue() + updqty ;
System.out.println("break1");
lcAlqtyexp.add(i,new Double( ((Double)lcAlqtyexp.get(i)).doubleValue() + updqty ));
System.out.println("break22222222");
System.out.println("valueDec"+valueDec);
System.out.println("quantityDec" +quantityDec);
System.out.println("lcConv"+lcConv);
System.out.println("updqty"+updqty);
benefitValue = (valueDec / (quantityDec * lcConv)) * updqty ;
System.out.println("benefitValue"+benefitValue);
if(unitAl.equalsIgnoreCase(unit))
{
despQtyBal = despQtyBal/ lcConv ;
......@@ -1040,7 +1114,9 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
errorString = "Success";
if(errorString !=null && errorString.trim().length()>0)
{
System.out.println("break3");
System.out.println("break3" + lcExchrate.get(i));
sqlSec = "update adv_licence_exp "
+"SET quantity_exp = (case when quantity_exp is null then 0 else quantity_exp end) + ? , "
+"exp_obl_exp = (case when exp_obl_exp is null then 0 else exp_obl_exp end) + ( ? * ? ) "
......@@ -1120,9 +1196,16 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
} // end of while loop
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} // end of for loop
pstmt1.close();
pstmt1 = null;
//} // end of for loop
}
rs1.close();
rs1 = null;
pstmt.close();
pstmt = null;
}// try
catch(Exception e)
......@@ -1134,7 +1217,7 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
//valueXmlString.append("</Root>\r\n");
return errorString ;
} // end of advanceLicence
public String wfDepb(String lsTranId,ArrayList despId ,Connection conn ) throws RemoteException, ITMException
public String wfDepb(String despId,ArrayList lsTranId ,Connection conn ) throws RemoteException, ITMException
{
String keyString = "";
String alType = "";
......@@ -1144,7 +1227,16 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
String itemCode = "";
String currCode = "";
String exchRate = "";
String invoiceId ="";
double exchRateDec = 0.0;
String commAmt = "";
double commAmtDec = 0.00;
String exchangeRate = "";
double exeRateDec = 0.00;
String commAmtOc = "" ;
double commAmtOcDec = 0.00;
String invAmt = "";
double invAmtDec = 0.00;
String quantity = "";
double quantityDec = 0.00;
String value ="";
......@@ -1161,11 +1253,15 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
String creditPerc = "";
double creditPercDec = 0.00;
double depbvalue = 0.00;
double invoicevalue = 0.00;
double benefitValue = 0.00;
double invAmtRate = 0.00;
double invoiceAmt = 0.00;
String despLineNo ="";
String tranId = "";
String sql = "";
String merrcode = "";
PreparedStatement pstmt = null,pstmtSec = null,pstmtInsert=null,pstmtCrper=null;
PreparedStatement pstmt = null,pstmtSec = null,pstmtInsert=null,pstmtCrper=null,pstmtInv=null;
ResultSet rs = null , rsSec = null,rsCrper=null;
Timestamp tranDate = null;
tranDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
......@@ -1200,6 +1296,7 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
rs = null;
pstmt.close();
pstmt = null;
/* commented by Chandni Shah 26/08/10 ---DI89UNI060
sql= "select b.line_no,b.unit__std,b.item_code,d.curr_code,d.exch_rate, "
+" sum(b.quantity__stduom), sum(b.quantity__stduom * b.rate__stduom) "
+ " from depb a , despatchdet b ,despatch d "
......@@ -1208,23 +1305,46 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
+" and a.tran_id = ? "
+" group by b.line_no,b.unit__std,b.item_code, "
+" d.curr_code,d.exch_rate ";
*/
// Changes done by Chandni Shah 26/08/10 ---DI89UNI060
sql= " select distinct i.invoice_id,b.line_no,b.unit__std,b.item_code,d.curr_code,d.exch_rate, "
+" sum(b.quantity__stduom), sum(b.quantity__stduom * b.rate__stduom), "
+" i.comm_amt,i.exch_rate,i.comm_amt__oc,i.inv_amt"
+" from invoice i, depb a , despatchdet b ,despatch d "
+" where d.desp_id = b.desp_id "
+" and d.desp_id = i.desp_id "
+" and d.desp_id = ? "
+" and a.tran_id = ? "
+" group by i.inv_amt,i.invoice_id,b.line_no,b.unit__std,b.item_code, "
+" d.curr_code,d.exch_rate,i.exch_rate,i.comm_amt__oc,i.comm_amt ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,(String)despId.get(0));
pstmt.setString(2,lsTranId);
//pstmt.setString(1,(String)despId.get(0));
//pstmt.setString(2,lsTranId);
pstmt.setString(1,despId);
pstmt.setString(2,(String)lsTranId.get(0));
rs = pstmt.executeQuery();
while(rs.next())
{
despLineNo = rs.getString(1);
unit = rs.getString(2);
itemCode = rs.getString(3);
currCode = rs.getString(4);
exchRate = rs.getString(5);
invoiceId = rs.getString(1);
despLineNo = rs.getString(2);
unit = rs.getString(3);
itemCode = rs.getString(4);
currCode = rs.getString(5);
exchRate = rs.getString(6);
exchRateDec = Double.parseDouble(exchRate);
quantity = rs.getString(6);
quantity = rs.getString(7);
quantityDec = Double.parseDouble(quantity);
value = rs.getString(7);
value = rs.getString(8);
valueDec = Double.parseDouble(value);
commAmt = rs.getString(9);
commAmtDec = Double.parseDouble(commAmt);
exchangeRate = rs.getString(10);
exeRateDec = Double.parseDouble(exchangeRate);
commAmtOc = rs.getString(11);
commAmtOcDec = Double.parseDouble(commAmtOc);
invAmt = rs.getString(12);
invAmtDec = Double.parseDouble(invAmt);
sqlSec="select credit_perc "
+" from depb_rate where item_code__depb = ? "
......@@ -1246,17 +1366,111 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
{
errorString ="VTDEPBRT1" ;
}
depbvalue = valueDec * creditPercDec * 0.01 ;
depbvalue = valueDec * creditPercDec * 0.01 * exeRateDec ; //exeRateDec is Added ..
invoicevalue = (commAmtOcDec * exeRateDec); //Chandni Shah 26/08/10
benefitValue = (depbvalue - invoicevalue) + commAmtDec ;//Chandni Shah 06/09/10
invAmtRate = (invAmtDec * exeRateDec )* (12.5/100);//Added by Chandni Shah 06/09/10 as Y
invoiceAmt = (depbvalue - invoicevalue)+invAmtRate;
//commAmt = ()
rsCrper.close();
rsCrper = null;
sqlSec= "UPDATE depb "
+"SET amount_cr = (case when amount_cr is null "
+" then 0 else amount_cr end) + ( ? * 1.0 ) "
+" WHERE tran_id = ? ";
rsCrper = null;
//Chandni Shah 13/09/2010
//To check [ comm_amt__oc > (inv_amt*exh_rate*12.5%)]
System.out.println(" commAmtOCDec ========>>>>>>>>>" +invoicevalue);
System.out.println(" invAmtRate ========>>>>>>>>>" +invAmtRate);
System.out.println(" commAmtOCDec > invAmtRate ========>>>>>>>>>" +(invoicevalue > invAmtRate));
if (invoicevalue > invAmtRate)
{
sqlSec = "UPDATE depb "
+" SET amount_cr = (case when amount_cr is null "
+" then 0 else amount_cr end) + ? "
+" WHERE tran_id = ? ";
pstmtInv = conn.prepareStatement(sqlSec);
pstmtInv.setDouble(1,invoiceAmt);
pstmtInv.setString(2,(String)lsTranId.get(0));
rsCrper = pstmtInv.executeQuery();
rsCrper.close();
rsCrper = null;
pstmtInv.close();
pstmtInv = null;
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<tramn_date>"+tranDate+"</tramn_date>" ;
xmlValues = xmlValues + "</Detail1></Root>";
String genTranId = generateTranId("w_benefit_trace", xmlValues, conn);
System.out.println("genTranId >>>>>>>>>"+ genTranId);
sqlInsert = " INSERT INTO benefit_trace ( "
+" tran_id, tran_date, adj_type, "
+" benefit_type, benefit_no, line_no__benefit, "
+" ref_ser, ref_no, line_no__ref, "
+" item_code, unit, quantity, "
+" curr_code, exch_rate, benefit_value,"
+" status, chg_date, chg_user, "
+" chg_term, value__base, benefit_perc, "
+" exch_rate__base ) "
+" VALUES ( ?, ?,?, "
+" ?, ?, ?, "
+" ?, ?,?, "
+" ?, ?, ?, "
+" ?, ?, ?, "
+" ?, ?, ?, "
+" ?,?,?, "
+" ? ) " ;
pstmtInsert = conn.prepareStatement(sqlInsert);
pstmtInsert.setString(1, genTranId);
pstmtInsert.setTimestamp(2, tranDate);
pstmtInsert.setString(3, "P");
pstmtInsert.setString(4, "DP");
pstmtInsert.setString(5, (String)lsTranId.get(0));//
pstmtInsert.setInt(6, 0);
pstmtInsert.setString(7, "S-DSP");
pstmtInsert.setString(8, despId);//
pstmtInsert.setString(9, despLineNo);
//pstmtInsert.setString(9, ls_pocldet_line_no);
pstmtInsert.setString(10, itemCode);
pstmtInsert.setString(11, unit);
pstmtInsert.setDouble(12, quantityDec);
pstmtInsert.setString(13, currCode);
pstmtInsert.setDouble(14, exchRateDec);
//pstmtInsert.setDouble(15, depbvalue);
pstmtInsert.setDouble(15, invoiceAmt); //
pstmtInsert.setString(16, "O");
pstmtInsert.setTimestamp(17,tranDate);
pstmtInsert.setString(18, "BASE"); //chg USer
pstmtInsert.setString(19, "BASE"); // LoginCOde
//pstmtInsert.setDouble(20, depbvalue);
pstmtInsert.setDouble(20, invoiceAmt); //-----
pstmtInsert.setString(21, "0.000");
pstmtInsert.setDouble(22, exchRateDec);
pstmtInsert.executeUpdate();
}
else //To check [ comm_amt__oc <= (inv_amt*exh_rate*12.5%)] Chandni Shah 13/09/2010 ---DI89UNI060
{
//
/* Commented by Chandni Shah 26/08/10
sqlSec= "UPDATE depb "
+"SET amount_cr = (case when amount_cr is null "
+" then 0 else amount_cr end) + ( ? * 1.0 ) "
+" WHERE tran_id = ? ";
*/
// Changes done by Chandni Shah 26/08/10 ---DI89UNI060
sqlSec= "UPDATE depb "
+" SET amount_cr = (case when amount_cr is null "
+" then 0 else amount_cr end) + ? "
+" WHERE tran_id = ? ";
pstmtSec = conn.prepareStatement(sqlSec);
pstmtSec.setDouble(1,depbvalue);
pstmtSec.setString(2,lsTranId);
pstmtSec.executeUpdate();
pstmtSec.setDouble(1,benefitValue);
pstmtSec.setString(2,(String)lsTranId.get(0));
pstmtSec.executeUpdate();
pstmtSec.close();
pstmtSec = null;
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
......@@ -1281,40 +1495,43 @@ public class BenefitDisPrc extends ProcessEJB implements BenefitDisPrcLocal,Bene
+" ?, ?, ?, "
+" ?, ?, ?, "
+" ?,?,?, "
+" ?,?,?, "
+" ?,? ) " ;
+" ? ) " ;
pstmtInsert = conn.prepareStatement(sqlInsert);
pstmtInsert.setString(1, genTranId);
pstmtInsert.setTimestamp(2, tranDate);
pstmtInsert.setString(3, "P");
pstmtInsert.setString(4, "DP");
pstmtInsert.setString(5, lsTranId);
pstmtInsert.setString(5, (String)lsTranId.get(0));//
pstmtInsert.setInt(6, 0);
pstmtInsert.setString(7, "S-DSP");
pstmtInsert.setString(8, tranId);
pstmtInsert.setString(9, ls_pocldet_line_no);
pstmtInsert.setString(8, despId);//
pstmtInsert.setString(9, despLineNo);
//pstmtInsert.setString(9, ls_pocldet_line_no);
pstmtInsert.setString(10, itemCode);
pstmtInsert.setString(11, unit);
pstmtInsert.setDouble(12, quantityDec);
pstmtInsert.setString(13, currCode);
pstmtInsert.setDouble(14, exchRateDec);
pstmtInsert.setDouble(15, depbvalue);
//pstmtInsert.setDouble(15, depbvalue);
pstmtInsert.setDouble(15, benefitValue); //
pstmtInsert.setString(16, "O");
pstmtInsert.setTimestamp(17,tranDate);
pstmtInsert.setString(18, "BASE"); //chg USer
pstmtInsert.setString(19, "BASE"); // LoginCOde
pstmtInsert.setDouble(20, depbvalue);
//pstmtInsert.setDouble(20, depbvalue);
pstmtInsert.setDouble(20, benefitValue); //-----
pstmtInsert.setString(21, "0.000");
pstmtInsert.setDouble(22, exchRateDec);
pstmtInsert.setDouble(22, exchRateDec);
pstmtInsert.executeUpdate();
}
} // end of while code
pstmtCrper.close();
pstmtCrper = null;
pstmtInsert.close();
pstmtInsert = null;
pstmtSec.close();
pstmtSec = null;
//pstmtSec.close();
//pstmtSec = null;
rs.close();
rs = null;
pstmt.close();
......
......@@ -417,10 +417,16 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
errString = itmDBAccessEJB.getErrorString("","VTBENUL",userId);
resultString =errString ;
return resultString;
}
}
/*
sql = " select count(*) from benefit_trace where ref_ser = 'P-BE' and ref_no = ? ";
*/
//Benefit_type condition is Added in select query by Chandni Shah - 14/09/10 ---DI89UNI059
sql = " select count(*) from benefit_trace where benefit_type= ? and ref_ser = 'P-BE' and ref_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId.trim());
pstmt.setString(1,benefitType.trim());
pstmt.setString(2,tranId.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -442,7 +448,7 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
if(benefitType != null && benefitType.trim().equalsIgnoreCase("AL"))
{
sql = "select distinct x.tran_id,x.file_no,x.al_no, x.line_no__exp, x.item_code__exp from "
+ "(SELECT a.tran_id,a.file_no,d.item_code,a.al_no,a.site_code, "
+ "(SELECT a.tran_id,a.file_no,d.item_code,a.al_no,a.site_code, "
+"a.eff_from ,(case when a.extend_upto is null then a.valid_upto else a.extend_upto end) valid_upto, "
+" c.fin_entity,d.line_no__exp,d.item_code__exp FROM adv_licence a,site b,finent c , "
+" adv_licence_imp d where a.tran_id = d.tran_id and a.site_code = b.site_code "
......@@ -596,6 +602,8 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
double valueDec =0.00;
String qtyImp = "";
double qtyImpDec = 0.00;
String netAmount = "";
double netAmountDec = 0.00 ;
String amtImp = "";
double amtImpDec = 0.00;
String qty = "";
......@@ -608,6 +616,8 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
String ll_exp_lineno = "";
String ls_item_code = "";
String lc_exp = "";
String amt_imp ="";
String amt_impBc ="";
String sqlsec = "";
String noUpdate = "";
PreparedStatement pstmt =null,pstmtSec = null ,pstmtInsert = null ;
......@@ -655,7 +665,7 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
rs = null;
pstmt.close();
pstmt = null;
sql = " select a.line_no , d.line_no, d.unit, a.item_code, b.curr_code , b.exch_rate, "
sql = " select a.line_no , d.line_no, d.unit, a.item_code, b.curr_code , b.exch_rate, b.net_amt , "
+ "sum(case when d.quantity is null then 0 else d.quantity end), "
+" sum(case when d.asseable_amt is null then 0 else d.asseable_amt end),"
+ "(case when a.quantity_imp is null then 0 else a.quantity_imp end), "
......@@ -668,7 +678,7 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
+ "and d.tran_id = '"+tranId+"' "
+ "and a.tran_id = '"+ls_adv_lic+"' "
+ "group by a.line_no , d.line_no , d.unit , a.item_code , "
+" b.curr_code , b.exch_rate , a.quantity_imp , a.amount_imp_bc, "
+" b.curr_code , b.exch_rate ,b.net_amt, a.quantity_imp , a.amount_imp_bc, "
+"a.quantity , a.amount_bc ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
......@@ -681,17 +691,19 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
currCode = rs.getString(5);
exchRate = rs.getString(6);
exchRateDec = Double.parseDouble(exchRate);
quantity = rs.getString(7);
netAmount = rs.getString(7);
netAmountDec = Double.parseDouble(netAmount);
quantity = rs.getString(8);
quantityDec = Double.parseDouble(quantity);
value = rs.getString(8);
value = rs.getString(9);
valueDec = Double.parseDouble(value);
qtyImp = rs.getString(9);
qtyImp = rs.getString(10);
qtyImpDec = Double.parseDouble(qtyImp);
amtImp= rs.getString(10);
amtImp= rs.getString(11);
amtImpDec = Double.parseDouble(amtImp);
qty = rs.getString(11);
qty = rs.getString(12);
qtyDec = Double.parseDouble(qty);
amt = rs.getString(12);
amt = rs.getString(13);
amtDec = Double.parseDouble(amt);
System.out.println("exchRateDec>>>>>>>>>>"+exchRateDec);
System.out.println("quantityDec>>>>>>>>>>"+quantityDec);
......@@ -700,6 +712,8 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
System.out.println("amtImpDec>>>>>>>>>>"+amtImpDec);
System.out.println("qtyDec>>>>>>>>>>"+qtyDec);
System.out.println("amtDec>>>>>>>>>>"+amtDec);
System.out.println("netAmount>>>>>>>>>>"+netAmountDec);
System.out.println("returnExchRateDec>>>>>>>>>>"+returnExchRateDec);
baseValue = valueDec * returnExchRateDec ; //??lc_value * s_pass1.mdecimal consider s_pass1.mdecimal =returnExchRateDec;
System.out.println("valueDec * returnExchRateDec>>>>>>>>>>"+baseValue);
......@@ -764,18 +778,29 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
pstmtInsert.executeUpdate();
pstmtInsert.close();
pstmtInsert = null;
sqlSec="update adv_licence_imp "
/*
sqlSec="update adv_licence_imp "
+" SET quantity_imp = (case when quantity_imp is null then 0 else quantity_imp end ) + '"+quantityDec+"' , "
+"amount_imp = (case when amount_imp is null then 0 else amount_imp end) + '"+valueDec+"' , "
+" amount_imp_bc = (case when amount_imp_bc is null then 0 else amount_imp_bc end) + ('"+valueDec+"' * '"+returnExchRateDec+"' ) "
+ " WHERE tran_id = '"+ls_adv_lic+"' "
+" AND line_no = '"+ls_advlic_line_no+"' ";
*/
//Chandni Shah 14/09/10 ---DI89UNI059
sqlSec="update adv_licence_imp "
+" SET quantity_imp = (case when quantity_imp is null then 0 else quantity_imp end ) + '"+quantityDec+"' , "
+"amount_imp = (case when amount_imp is null then 0 else amount_imp end) + '"+netAmountDec+"' , "
+" amount_imp_bc = (case when amount_imp_bc is null then 0 else amount_imp_bc end) + ('"+netAmountDec+"' * '"+returnExchRateDec+"' ) "
+ " WHERE tran_id = '"+ls_adv_lic+"' "
+" AND line_no = '"+ls_advlic_line_no+"' ";
pstmtSec = conn.prepareStatement(sqlSec);
pstmtSec.executeUpdate();
pstmtSec.close();
pstmtSec = null;
}// end of whil e loop
}// end of while loop
rs.close();
rs = null;
pstmt.close();
......@@ -792,6 +817,11 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
rs = null;
pstmt.close();
pstmt = null;
/*
//chandni Shah ---> 14/09/2010 ---DI89UNI059
// instead of adv_licence_exp table ,adv_licence table is updated
sql= " select max((amount_imp/amount)*100) "
+" from adv_licence_imp "
+ "where tran_id = '"+ls_adv_lic+"' "
......@@ -813,6 +843,31 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
pstmtSec.close();
pstmtSec = null;
}
*/
//chandni Shah ---> 14/09/2010 ---DI89UNI059
sql= " select amount_imp,amount_imp_bc "
+" from adv_licence_imp "
+ "where tran_id = '"+ls_adv_lic+"' "
+ "and line_no__exp = '"+ll_exp_lineno+"' "
+" and item_code__exp = '"+ls_item_code+"' "
+"and amount > 0 ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
amt_imp = rs.getString(1) == null ? "" : rs.getString(1) ;
amt_impBc = rs.getString(2) == null ? "" : rs.getString(2) ;
// update query for adv_licence
sqlsec = "update adv_licence "
+" set import_amt = (case when import_amt is null then 0 else import_amt end ) + '"+ amt_imp +"' , "
+" import_amt__bc = (case when import_amt__bc is null then 0 else import_amt__bc end ) + '"+ amt_impBc +"' "
+"where tran_id = '"+ls_adv_lic+"' " ;
pstmtSec = conn.prepareStatement(sqlsec);
pstmtSec.executeUpdate();
pstmtSec.close();
pstmtSec = null;
}
if(merrcode.length()==0)
{
merrcode ="success";
......@@ -853,7 +908,9 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
String qty = "";
double qtyDec =0.00;
String amt = "";
double amtDec=0.0;
double amtDec=0.0;
String taxAmount = "";
double taxAmountDec = 0.00;
String sqlSec = "";
String creditPerc = "";
double creditPercDec = 0.00;
......@@ -901,13 +958,13 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
pstmt.close();
pstmt = null;
sql= " select b.line_no,b.unit,b.item_code,d.curr_code,d.exch_rate,"
+" sum(b.quantity), sum(b.asseable_amt)"
+" sum(b.quantity), sum(b.asseable_amt), d.tax_amt "
+" from depb a , po_clearance_det b ,po_clearance d "
+" where d.tran_id = b.tran_id "
+" and d.tran_id = '"+ ls_tran_id+"' "
+" and a.tran_id = '"+ls_depb_no+"' " //?? as_depb_no
+" group by b.line_no,b.unit,b.item_code, "
+" d.curr_code,d.exch_rate ";
+" d.curr_code,d.exch_rate,d.tax_amt ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next())
......@@ -923,6 +980,8 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
quantityDec = Double.parseDouble(quantity);
value = rs.getString(7);
valueDec = Double.parseDouble(value);
taxAmount = rs.getString(8);
taxAmountDec = Double.parseDouble(taxAmount);
sqlSec="select credit_perc "
+" from depb_rate where item_code__depb = '"+itemCode+"' ";
pstmtSec = conn.prepareStatement(sqlSec);
......@@ -947,6 +1006,7 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
System.out.println("valueDec>>>>>>>" + valueDec);
System.out.println("creditPercDec>>>>>>>" + creditPercDec);
System.out.println("depbvalue>>>>>>>" + depbvalue);
System.out.println ("taxAmount>>>>>>>>>>>"+taxAmountDec);
String genTranId = generateTranId("w_benefit_trace", "S-BTR", conn);
System.out.println("tranId>>>>>>>" + genTranId);
String sqlInsert = "INSERT INTO benefit_trace (tran_id, tran_date, adj_type, "
......@@ -970,12 +1030,12 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
pstmtInsert.setDouble(12, quantityDec);
pstmtInsert.setString(13, currCode);
pstmtInsert.setDouble(14, exchRateDec);
pstmtInsert.setDouble(15, valueDec);
pstmtInsert.setDouble(15, taxAmountDec);//
pstmtInsert.setString(16, "O");
pstmtInsert.setTimestamp(17, tranDate);
pstmtInsert.setString(18, "BASE");
pstmtInsert.setString(19, "");
pstmtInsert.setDouble(20, valueDec);
pstmtInsert.setDouble(20, taxAmountDec);//
pstmtInsert.setString(21, "0.000");
pstmtInsert.setDouble(22, exchRateDec);
pstmtInsert.executeUpdate();
......@@ -985,7 +1045,8 @@ public class BenefitPrc extends ProcessEJB implements BenefitPrcLocal,BenefitPrc
+" (case when amount_dr is null then 0 else amount_dr end) + (? * ?) "
+ " WHERE tran_id = ? " ;
pstmtInsert = conn.prepareStatement(sqlSec);
pstmtInsert.setDouble(1,depbvalue);
//pstmtInsert.setDouble(1,depbvalue);
pstmtInsert.setDouble(1,taxAmountDec);
pstmtInsert.setDouble(2,exchRateDec);
pstmtInsert.setString(3,ls_depb_no);
int i= pstmtInsert.executeUpdate();
......
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