Commit c91fef98 authored by dsawant's avatar dsawant

updated for stock revaluation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94536 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d84e4e73
......@@ -1918,11 +1918,13 @@ public class InvAcct
public String stkAdjust(String tranId, Connection conn)throws ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>><<<sdsd<<<<<<<<<<<<chk");
String siteCode="",itemCode ="",locCode="",lotNo="",lotSl="",itemSer="",acctCode="",cctrCode="";
String getAcctCctr="",errString="";
String[] values;
double Rate,oldRate,amt,amt_old;
double Rate,oldRate,amt,amt_old,diffAmt;
HashMap updateAcctMap =new HashMap();
ResultSet rs=null,rs1=null;
String confirmed = "";
......@@ -1936,11 +1938,12 @@ public class InvAcct
String currCodeBase="",currCode="",finEntity="";
SimpleDateFormat sdf = null;
java.sql.Timestamp tranDate = null, effDate = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try{
sql="select h.site_code,d.rate,d.rate__old,d.amount,d.amount__old,d.item_code,d.loc_code,d.lot_no,d.lot_sl,h.item_ser,d.acct_code__inv,d.cctr_code__inv,d.acct_code__inrev,d.cctr_code__inrev,h.tran_type ,h.tran_date,h.eff_date "
sql="select h.site_code,d.rate,d.rate__old,d.amount,d.amount__old,d.item_code,d.loc_code,d.lot_no,d.lot_sl,h.item_ser,d.acct_code__inv,d.cctr_code__inv,d.acct_code__inrev,d.cctr_code__inrev,h.tran_type ,h.tran_date,h.eff_date,d.amount__diff "
+ "from stock_val_adj h,stock_val_adj_det d where h.tran_id=d.tran_id and d.tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranId);
......@@ -1964,15 +1967,9 @@ public class InvAcct
tranType = checkNull(rs.getString(15));
tranDate = rs.getTimestamp(16);
effDate = rs.getTimestamp(17);
diffAmt = rs.getDouble(18);
/* getAcctCctr = finCommon.getFromAcctDetr(itemCode, itemSer,"STKRADJ", conn);
values = getAcctCctr.split(",");
acctCode = values[0].trim();
cctrCode = values[1].trim();*/
// SimpleDateFormat simpleDateFormatObj = new SimpleDateFormat(genericUtility.getApplDateFormat());
// utranDate = simpleDateFormatObj.parse(tranDate);
// ueffDate = simpleDateFormatObj.parse(effDate);
updateAcctMap.put("rate",Double.toString(Rate));
updateAcctMap.put("rate__old",Double.toString(oldRate));
......@@ -1991,6 +1988,7 @@ public class InvAcct
updateAcctMap.put("ref_type", "");
updateAcctMap.put("ref_id", tranId);
updateAcctMap.put("ref_ser","STKVAT");
sql1 = "SELECT A.CURR_CODE AS CURR_CODE FROM FINENT A, SITE B WHERE B.FIN_ENTITY = A.FIN_ENTITY AND B.SITE_CODE = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,siteCode);
......@@ -2022,7 +2020,7 @@ public class InvAcct
updateAcctMap.put("curr_code",currCode);
updateAcctMap.put("fin_entity",finEntity);
analysis = AcctAnalysisType( itemCode,"S-INV", tranType, "CR", conn);
analysis = AcctAnalysisType( itemCode,"STKVAT", tranType, "CR", conn);
analysisStr = analysis.split("@");
int len = analysisStr.length-1;
......@@ -2052,7 +2050,7 @@ public class InvAcct
analysis3__cr ="";
}
analysis = AcctAnalysisType( itemCode, "S-INV", tranType, "DR", conn);
analysis = AcctAnalysisType( itemCode, "STKVAT", tranType, "DR", conn);
System.out.println("@@@@DR return analysis["+analysis+"]");
//analysisStr = analysis.split("@@@@@@2 analysis::["+analysis+"]");
......@@ -2090,18 +2088,18 @@ public class InvAcct
{
/*updateAcctMap.put("acct_code__inv",acctCdInv);
updateAcctMap.put("cctr_code__inv",cctrCdInv);*/
System.out.println("stk debit"+amt);
System.out.println("stk debit"+diffAmt);
updateAcctMap.put("acct_code",acctCdInv);
updateAcctMap.put("cctr_code",cctrCdInv);
updateAcctMap.put("analysis1",analysis1__dr);
updateAcctMap.put("analysis2",analysis2__dr);
updateAcctMap.put("analysis3",analysis3__dr);
updateAcctMap.put("dr_amt", amt);
updateAcctMap.put("dr_amt", diffAmt);
updateAcctMap.put("cr_amt", 0);
errString = finCommon.glTraceUpdate(updateAcctMap,conn);
updateAcctMap = null;
updateAcctMap.clear();
if(errString != null && errString.trim().length() > 0 )
{
break;
......@@ -2110,6 +2108,7 @@ public class InvAcct
}
else
{
System.out.println("stk credit"+diffAmt);
/*updateAcctMap.put("acct_code__inrev",acctCdInvR);
updateAcctMap.put("cctr_code__inrev",cctrCdInvR);*/
updateAcctMap.put("acct_code",acctCdInvR);
......@@ -2119,10 +2118,10 @@ public class InvAcct
updateAcctMap.put("analysis3",analysis3__cr);
updateAcctMap.put("dr_amt", 0);
updateAcctMap.put("cr_amt", amt);
updateAcctMap.put("cr_amt", diffAmt);
errString = finCommon.glTraceUpdate(updateAcctMap,conn);
updateAcctMap = null;
updateAcctMap.clear();
if(errString != null && errString.trim().length() > 0 )
{
break;
......@@ -2130,6 +2129,66 @@ public class InvAcct
//inrev cred
}
if(amt_old > amt)
{
/*updateAcctMap.put("acct_code__inv",acctCdInv);
updateAcctMap.put("cctr_code__inv",cctrCdInv);*/
System.out.println("stk debit1"+diffAmt+"{"+acctCdInv+"}{"+cctrCdInv+"");
updateAcctMap.put("acct_code",acctCdInv);
updateAcctMap.put("cctr_code",cctrCdInv);
updateAcctMap.put("analysis1",analysis1__dr);
updateAcctMap.put("analysis2",analysis2__dr);
updateAcctMap.put("analysis3",analysis3__dr);
updateAcctMap.put("dr_amt", diffAmt);
updateAcctMap.put("cr_amt", 0);
errString = finCommon.glTraceUpdate(updateAcctMap,conn);
updateAcctMap.clear();
if(errString != null && errString.trim().length() > 0 )
{
break;
}
// stk acct debit
}
else
{
System.out.println("stk credit1"+diffAmt);
/*updateAcctMap.put("acct_code__inrev",acctCdInvR);
updateAcctMap.put("cctr_code__inrev",cctrCdInvR);*/
updateAcctMap.put("acct_code",acctCdInvR);
updateAcctMap.put("cctr_code",cctrCdInvR);
updateAcctMap.put("analysis1",analysis1__cr);
updateAcctMap.put("analysis2",analysis2__cr);
updateAcctMap.put("analysis3",analysis3__cr);
updateAcctMap.put("dr_amt", 0);
updateAcctMap.put("cr_amt", diffAmt);
errString = finCommon.glTraceUpdate(updateAcctMap,conn);
updateAcctMap.clear();
if(errString != null && errString.trim().length() > 0 )
{
break;
}
//inrev cred
}
System.out.println();
errString=finCommon.checkGlTranDrCr("STKVAT", tranId, conn);
if(errString != null && errString.trim().length() > 0)
{
errString=itmDBAccessEJB.getErrorString("","VCOINDIFF1","");
return errString;
}
System.out.println("all correct");
}
......@@ -2139,9 +2198,7 @@ public class InvAcct
}
return errString;
}
......
......@@ -14,6 +14,7 @@ import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import javax.ejb.Stateless; // added for ejb3
import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction;
......@@ -66,9 +67,12 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
String sql = "";
String userId="",siteCode = "",errCode="",itemser="",pricelist="",reasCode="",remarks="",amtOld="",cctrCodeInv="",cctrCodeInvrev="";
String tranId = "",keyFlag="",tranDate = "",effDate="",itemCode="",locCode="",lotNo="",lotSl="",quantity="",acctCodeInv="",acctCodeInvrev="";
double conquan,getquan = 0;
int cnt=0;
int currentFormNo=0;
int childNodeListLength;
String oRate="";
double rate =0;
ConnDriver connDriver = new ConnDriver();
try
......@@ -518,14 +522,56 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
else if(childNodeName.equalsIgnoreCase("quantity"))
{
quantity = genericUtility.getColumnValue("quantity",dom);
if (quantity == null || quantity.trim().length() == 0 )
quantity = checkNull(genericUtility.getColumnValue("quantity",dom));
conquan = Double.parseDouble(quantity);
if (quantity.length() == 0)
{
errCode = "STKVALQUAN";
errString = getErrorString("quantity",errCode,userId);
break;
}
else
{
siteCode = genericUtility.getColumnValue("site_code",dom1);
sql = "select quantity from stock where site_code = ? and item_code = ? and loc_code = ? and lot_no = ? and lot_sl=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
rs = pstmt.executeQuery();
if(rs.next())
{
getquan = rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("conquan getquan"+conquan+"{"+getquan+"");
if(conquan > getquan)
{
errCode = "VTQUANGR";
errString = getErrorString("quantity",errCode,userId);
break;
}
oRate = checkNull(genericUtility.getColumnValue("rate",dom));
rate = Double.parseDouble(oRate);
System.out.println("rate is"+rate);
if(rate == -1)
{
errCode = "VTPRLINE";
errString = getErrorString("quantity",errCode,userId);
break;
}
}
}
......@@ -753,10 +799,10 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
ConnDriver connDriver = new ConnDriver();
String siteCode = "",sql="",sitedesc="",priclit="";
int currentFormNo =0;
String columnValue="",chgTerm="",chgUser="",priceList="",tranDate="",listType="";
String itemCode="",locCode="",lotNo="",lotsl="",oldRate="",quantity="",itmdesc="",loginSite="";
String columnValue="",chgTerm="",chgUser="",priceList="",tranDate="",listType="",oRate="";
String itemCode="",locCode="",lotNo="",lotsl="",quantity="",itmdesc="",loginSite="";
Date utranDate;
double rate = 0,conquan,conOldRate,oldAmount,amount,amtdiff;
double rate = 0,conquan,conOldRate,oldAmount,amount,amtdiff,oldRate=0;
try
{
conn = connDriver.getConnectDB("DriverITM");
......@@ -819,22 +865,9 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
siteCode = siteCode.trim();
if(siteCode != null && siteCode.trim().length()>0 )
{
sql = "select descr from site where site_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
sitedesc = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_descr>").append("<![CDATA[" + sitedesc + "]]>").append("</site_descr>");
}
else
{
sitedesc=getColumnDescr(conn,"descr","site","site_code",siteCode);
valueXmlString.append("<site_descr>").append("<![CDATA[" + sitedesc + "]]>").append("</site_descr>");
}else{
valueXmlString.append("<site_descr>").append("<![CDATA[]]>").append("</site_descr>");
}
}
......@@ -867,77 +900,21 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
System.out.println("item code >>>>"+itemCode);
if(itemCode != null && itemCode.length()>0 )
{
sql = "select descr from item where item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itmdesc = rs.getString(1) == null ? "":rs.getString(1);
itmdesc=getColumnDescr(conn,"descr","item","item_code",itemCode);
valueXmlString.append("<item_descr>").append("<![CDATA["+itmdesc+"]]>").append("</item_descr>");
}else{
valueXmlString.append("<item_descr>").append("<![CDATA[]]>").append("</item_descr>");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0)
{
sql = "select rate from stock where site_code = ? and item_code = ? and loc_code = ? and lot_no = ? and lot_sl = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotsl);
rs = pstmt.executeQuery();
if(rs.next())
{
oldRate = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
sql = "select list_type from pricelist where price_list = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
listType = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(listType.trim().length() == 0)
{
sql = "select list_type from pricelist_mst where price_list = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
listType = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
oldRate=getRateFromStock(conn, siteCode, itemCode, locCode, lotNo, lotsl);
System.out.println("Old Rate in item code----->>["+oldRate);
rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, listType, conn);
rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, "", conn);
if(rate == 0.0 || rate == 0 || rate == -1)
{
rate = 0;
}
valueXmlString.append("<rate__old>").append("<![CDATA[" + oldRate + "]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA[" + rate + " ]]>").append("</rate>");
valueXmlString.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA["+rate+"]]>").append("</rate>");
......@@ -948,213 +925,49 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
}
valueXmlString.append("<item_descr>").append("<![CDATA[" + itmdesc + "]]>").append("</item_descr>");
}
else
{
valueXmlString.append("<item_descr>").append("<![CDATA[]]>").append("</item_descr>");
}
}
// if (currentColumn.trim().equals("loc_code"))
// {
// if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0)
// {
// sql = "select rate from stock where site_code = ? and item_code = ? and loc_code = ? and lot_no = ? and lot_sl = ?";
// pstmt=conn.prepareStatement(sql);
// pstmt.setString(1,siteCode);
// pstmt.setString(2,itemCode);
// pstmt.setString(3,locCode);
// pstmt.setString(4,lotNo);
// pstmt.setString(5,lotsl);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// oldRate = rs.getString(1) == null ? "":rs.getString(1);
// }
// pstmt.close();
// rs.close();
// pstmt = null;
// rs = null;
//
//
// sql = "select list_type from pricelist where price_list = ?";
// pstmt=conn.prepareStatement(sql);
// pstmt.setString(1,siteCode);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// listType = rs.getString(1) == null ? "":rs.getString(1);
// }
// pstmt.close();
// rs.close();
// pstmt = null;
// rs = null;
//
// if(listType.trim().length() == 0)
// {
// sql = "select list_type from pricelist_mst where price_list = ?";
// pstmt=conn.prepareStatement(sql);
// pstmt.setString(1,siteCode);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// listType = rs.getString(1) == null ? "":rs.getString(1);
// }
// pstmt.close();
// rs.close();
// pstmt = null;
// rs = null;
// }
//
// rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, listType, conn);
//
// valueXmlString.append("<rate__old>").append("<![CDATA[" + oldRate + " ]]>").append("</rate__old>");
// valueXmlString.append("<rate>").append("<![CDATA[" + rate + " ]]>").append("</rate>");
//
//
// }else
// {
// valueXmlString.append("<rate__old>").append("<![CDATA[]]>").append("</rate__old>");
// valueXmlString.append("<rate>").append("<![CDATA[]]>").append("</rate>");
// }
// }
if (currentColumn.trim().equals("lot_no"))
{
if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0)
{
sql = "select rate from stock where site_code = ? and item_code = ? and loc_code = ? and lot_no = ? and lot_sl = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotsl);
rs = pstmt.executeQuery();
if(rs.next())
{
oldRate = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
sql = "select list_type from pricelist where price_list = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
listType = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(listType.trim().length() == 0)
{
sql = "select list_type from pricelist_mst where price_list = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
listType = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
oldRate=getRateFromStock(conn, siteCode, itemCode, locCode, lotNo, lotsl);
System.out.println("Old Rate in lot_noe----->>["+oldRate);
rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, "", conn);
rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, listType, conn);
System.out.println(">>>rate"+rate);
if(rate == 0.0 || rate == 0 || rate == -1)
if(rate == -1)
{
rate = 0;
System.out.println("CODE RATE ERROR-----------------------------------------");
}
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
valueXmlString.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA["+rate+"]]>").append("</rate>");
}else
{
valueXmlString.append("<rate__old>").append("<![CDATA[]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA[]]>").append("</rate>");
}
}
if (currentColumn.trim().equals("lot_sl"))
{
if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0)
{
sql = "select rate from stock where site_code = ? and item_code = ? and loc_code = ? and lot_no = ? and lot_sl = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotsl);
rs = pstmt.executeQuery();
if(rs.next())
{
oldRate = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
oldRate=getRateFromStock(conn, siteCode, itemCode, locCode, lotNo, lotsl);
System.out.println("Old Rate in lot_sl----->>["+oldRate);
rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, "", conn);
sql = "select list_type from pricelist where price_list = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
listType = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(listType.trim().length() == 0)
{
sql = "select list_type from pricelist_mst where price_list = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
listType = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, listType, conn);
if(rate == 0.0 || rate == 0 || rate == -1)
if(rate == -1)
{
rate = 0;
System.out.println("CODE RATE ERROR-----------------------------------------");
}
valueXmlString.append("<rate__old>").append("<![CDATA[" + oldRate + "]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
valueXmlString.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA["+rate+"]]>").append("</rate>");
}else
{
valueXmlString.append("<rate__old>").append("<![CDATA[]]>").append("</rate__old>");
......@@ -1165,30 +978,32 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
if (currentColumn.trim().equals("quantity"))
{
String oldRateS="";
quantity = checkNull(genericUtility.getColumnValue("quantity",dom));
System.out.println(">>>>>oldRate"+oldRate);
oldRate = checkNull(genericUtility.getColumnValue("rate__old",dom));
conquan = Double.parseDouble(quantity);
System.out.println(">>>>>conquan"+conquan);
conOldRate = Double.parseDouble(oldRate);
System.out.println(">>>>>conOldRate"+conOldRate);
oldRateS = checkNull(genericUtility.getColumnValue("rate__old",dom));
oRate = checkNull(genericUtility.getColumnValue("rate",dom));
System.out.println("oldRateS----->>["+oldRateS+"]");
System.out.println("oRate----->>["+oRate+"]");
conquan=Double.parseDouble(quantity);
System.out.println("Quantity----->>["+quantity+"]");
conOldRate = Double.parseDouble(oldRateS);
System.out.println("conOldRate----->>["+conOldRate+"]");
rate = Double.parseDouble(oRate);
if(quantity != null && quantity.length()>0 )
if(conquan > 0)
{
oldAmount = conquan * conOldRate;
amount = conquan * rate;
amtdiff = amount - oldAmount;
amtdiff = amount - oldAmount;
valueXmlString.append("<amount__old>").append("<![CDATA[" + oldAmount + "]]>").append("</amount__old>");
valueXmlString.append("<amount__old>").append("<![CDATA["+oldAmount +"]]>").append("</amount__old>");
valueXmlString.append("<amount>").append("<![CDATA[" + amount + "]]>").append("</amount>");
valueXmlString.append("<amount__diff>").append("<![CDATA[" + amtdiff + "]]>").append("</amount__diff>");
}
else
{
}else{
System.out.println("quantity,OldRate or newrate is zero--------------------");
valueXmlString.append("<amount__old>").append("<![CDATA[]]>").append("</amount__old>");
valueXmlString.append("<amount>").append("<![CDATA[]]>").append("</amount>");
valueXmlString.append("<amount__diff>").append("<![CDATA[]]>").append("</amount__diff>");
......@@ -1398,6 +1213,69 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
}
return input.trim();
}
public double getRateFromStock(Connection conn,String siteCode,String itemCode,String locCode,String lotNo,String lotSl){
ResultSet rs=null;
PreparedStatement pstmt=null;
String sql="";
int count=0;
double oldRate=0;
try{
sql = "select rate from stock where site_code = ? and item_code = ? and loc_code = ? and lot_no = ? and lot_sl = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
rs = pstmt.executeQuery();
if(rs.next())
{
oldRate =rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
catch(Exception e){
System.out.println("Exception in updateStockRateAsPerPriceListRate----------");
e.printStackTrace();
}
return oldRate;
}
protected String getColumnDescr(Connection conn, String columnName ,String tableName, String columnName2, String value)
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in getColumnDescr ");
e.printStackTrace();
}
System.out.println("returning String from getColumnDescr " + findValue);
return findValue;
}
// private double getRate(String siteCode,String itemCode,String locCode,String lotNo,String lotsl,Connection conn)
// {
......
......@@ -57,7 +57,7 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverValidator");
conn = connDriver.getConnectDB("DriverITM");
loginEmpCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
loginEmpCode=loginEmpCode==null ? "" :loginEmpCode.trim();
System.out.println("loginEmpCode---->>["+loginEmpCode+"]");
......@@ -115,16 +115,25 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj
updateStockMap.put("lot_no",lotNo);
updateStockMap.put("lot_sl",lotSl);
count=updateStockRateAsPerPriceListRate(conn, updateStockMap);
count=updateStockValAdj(conn, loginEmpCode, tranId);
System.out.println("updateStockRateAsPerPriceListRate count-->["+count+"]");
if(count > 0){
System.out.println("654321");
System.out.println("123456");
String errCall = inv.stkAdjust(tranId, conn);
System.out.println(">>>>>>> errCall"+errCall);
count=updateStockValAdj(conn, loginEmpCode, tranId);
if(errCall.trim().length() > 0)
{
errCall = errString;
return errString;
}
count=updateStockRateAsPerPriceListRate(conn, updateStockMap);
System.out.println("updateStockValAdj-->>["+count+"]");
if(count > 0){
//confirmed messages show.............
......
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