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 ...@@ -1918,11 +1918,13 @@ public class InvAcct
public String stkAdjust(String tranId, Connection conn)throws ITMException public String stkAdjust(String tranId, Connection conn)throws ITMException
{ {
System.out.println(">>>>>>>>>>>>>>>>>><<<sdsd<<<<<<<<<<<<chk"); System.out.println(">>>>>>>>>>>>>>>>>><<<sdsd<<<<<<<<<<<<chk");
String siteCode="",itemCode ="",locCode="",lotNo="",lotSl="",itemSer="",acctCode="",cctrCode=""; String siteCode="",itemCode ="",locCode="",lotNo="",lotSl="",itemSer="",acctCode="",cctrCode="";
String getAcctCctr="",errString=""; String getAcctCctr="",errString="";
String[] values; String[] values;
double Rate,oldRate,amt,amt_old; double Rate,oldRate,amt,amt_old,diffAmt;
HashMap updateAcctMap =new HashMap(); HashMap updateAcctMap =new HashMap();
ResultSet rs=null,rs1=null; ResultSet rs=null,rs1=null;
String confirmed = ""; String confirmed = "";
...@@ -1936,11 +1938,12 @@ public class InvAcct ...@@ -1936,11 +1938,12 @@ public class InvAcct
String currCodeBase="",currCode="",finEntity=""; String currCodeBase="",currCode="",finEntity="";
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
java.sql.Timestamp tranDate = null, effDate = null; java.sql.Timestamp tranDate = null, effDate = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try{ 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 = ?"; + "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=conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
...@@ -1964,15 +1967,9 @@ public class InvAcct ...@@ -1964,15 +1967,9 @@ public class InvAcct
tranType = checkNull(rs.getString(15)); tranType = checkNull(rs.getString(15));
tranDate = rs.getTimestamp(16); tranDate = rs.getTimestamp(16);
effDate = rs.getTimestamp(17); 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",Double.toString(Rate));
updateAcctMap.put("rate__old",Double.toString(oldRate)); updateAcctMap.put("rate__old",Double.toString(oldRate));
...@@ -1991,6 +1988,7 @@ public class InvAcct ...@@ -1991,6 +1988,7 @@ public class InvAcct
updateAcctMap.put("ref_type", ""); updateAcctMap.put("ref_type", "");
updateAcctMap.put("ref_id", tranId); 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 = ?"; 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 = conn.prepareStatement(sql1);
pstmt1.setString(1,siteCode); pstmt1.setString(1,siteCode);
...@@ -2022,7 +2020,7 @@ public class InvAcct ...@@ -2022,7 +2020,7 @@ public class InvAcct
updateAcctMap.put("curr_code",currCode); updateAcctMap.put("curr_code",currCode);
updateAcctMap.put("fin_entity",finEntity); updateAcctMap.put("fin_entity",finEntity);
analysis = AcctAnalysisType( itemCode,"S-INV", tranType, "CR", conn); analysis = AcctAnalysisType( itemCode,"STKVAT", tranType, "CR", conn);
analysisStr = analysis.split("@"); analysisStr = analysis.split("@");
int len = analysisStr.length-1; int len = analysisStr.length-1;
...@@ -2052,7 +2050,7 @@ public class InvAcct ...@@ -2052,7 +2050,7 @@ public class InvAcct
analysis3__cr =""; analysis3__cr ="";
} }
analysis = AcctAnalysisType( itemCode, "S-INV", tranType, "DR", conn); analysis = AcctAnalysisType( itemCode, "STKVAT", tranType, "DR", conn);
System.out.println("@@@@DR return analysis["+analysis+"]"); System.out.println("@@@@DR return analysis["+analysis+"]");
//analysisStr = analysis.split("@@@@@@2 analysis::["+analysis+"]"); //analysisStr = analysis.split("@@@@@@2 analysis::["+analysis+"]");
...@@ -2090,18 +2088,18 @@ public class InvAcct ...@@ -2090,18 +2088,18 @@ public class InvAcct
{ {
/*updateAcctMap.put("acct_code__inv",acctCdInv); /*updateAcctMap.put("acct_code__inv",acctCdInv);
updateAcctMap.put("cctr_code__inv",cctrCdInv);*/ 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("acct_code",acctCdInv);
updateAcctMap.put("cctr_code",cctrCdInv); updateAcctMap.put("cctr_code",cctrCdInv);
updateAcctMap.put("analysis1",analysis1__dr); updateAcctMap.put("analysis1",analysis1__dr);
updateAcctMap.put("analysis2",analysis2__dr); updateAcctMap.put("analysis2",analysis2__dr);
updateAcctMap.put("analysis3",analysis3__dr); updateAcctMap.put("analysis3",analysis3__dr);
updateAcctMap.put("dr_amt", amt); updateAcctMap.put("dr_amt", diffAmt);
updateAcctMap.put("cr_amt", 0); updateAcctMap.put("cr_amt", 0);
errString = finCommon.glTraceUpdate(updateAcctMap,conn); errString = finCommon.glTraceUpdate(updateAcctMap,conn);
updateAcctMap = null; updateAcctMap.clear();
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
break; break;
...@@ -2110,6 +2108,7 @@ public class InvAcct ...@@ -2110,6 +2108,7 @@ public class InvAcct
} }
else else
{ {
System.out.println("stk credit"+diffAmt);
/*updateAcctMap.put("acct_code__inrev",acctCdInvR); /*updateAcctMap.put("acct_code__inrev",acctCdInvR);
updateAcctMap.put("cctr_code__inrev",cctrCdInvR);*/ updateAcctMap.put("cctr_code__inrev",cctrCdInvR);*/
updateAcctMap.put("acct_code",acctCdInvR); updateAcctMap.put("acct_code",acctCdInvR);
...@@ -2119,10 +2118,10 @@ public class InvAcct ...@@ -2119,10 +2118,10 @@ public class InvAcct
updateAcctMap.put("analysis3",analysis3__cr); updateAcctMap.put("analysis3",analysis3__cr);
updateAcctMap.put("dr_amt", 0); updateAcctMap.put("dr_amt", 0);
updateAcctMap.put("cr_amt", amt); updateAcctMap.put("cr_amt", diffAmt);
errString = finCommon.glTraceUpdate(updateAcctMap,conn); errString = finCommon.glTraceUpdate(updateAcctMap,conn);
updateAcctMap = null; updateAcctMap.clear();
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
break; break;
...@@ -2130,6 +2129,66 @@ public class InvAcct ...@@ -2130,6 +2129,66 @@ public class InvAcct
//inrev cred //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 ...@@ -2139,9 +2198,7 @@ public class InvAcct
} }
return errString; return errString;
} }
......
...@@ -14,6 +14,7 @@ import java.sql.Statement; ...@@ -14,6 +14,7 @@ import java.sql.Statement;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Map;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction; import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction;
...@@ -66,9 +67,12 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca ...@@ -66,9 +67,12 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
String sql = ""; String sql = "";
String userId="",siteCode = "",errCode="",itemser="",pricelist="",reasCode="",remarks="",amtOld="",cctrCodeInv="",cctrCodeInvrev=""; String userId="",siteCode = "",errCode="",itemser="",pricelist="",reasCode="",remarks="",amtOld="",cctrCodeInv="",cctrCodeInvrev="";
String tranId = "",keyFlag="",tranDate = "",effDate="",itemCode="",locCode="",lotNo="",lotSl="",quantity="",acctCodeInv="",acctCodeInvrev=""; String tranId = "",keyFlag="",tranDate = "",effDate="",itemCode="",locCode="",lotNo="",lotSl="",quantity="",acctCodeInv="",acctCodeInvrev="";
double conquan,getquan = 0;
int cnt=0; int cnt=0;
int currentFormNo=0; int currentFormNo=0;
int childNodeListLength; int childNodeListLength;
String oRate="";
double rate =0;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
try try
...@@ -518,14 +522,56 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca ...@@ -518,14 +522,56 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
else if(childNodeName.equalsIgnoreCase("quantity")) else if(childNodeName.equalsIgnoreCase("quantity"))
{ {
quantity = genericUtility.getColumnValue("quantity",dom); quantity = checkNull(genericUtility.getColumnValue("quantity",dom));
conquan = Double.parseDouble(quantity);
if (quantity == null || quantity.trim().length() == 0 ) if (quantity.length() == 0)
{ {
errCode = "STKVALQUAN"; errCode = "STKVALQUAN";
errString = getErrorString("quantity",errCode,userId); errString = getErrorString("quantity",errCode,userId);
break; 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 ...@@ -753,10 +799,10 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
String siteCode = "",sql="",sitedesc="",priclit=""; String siteCode = "",sql="",sitedesc="",priclit="";
int currentFormNo =0; int currentFormNo =0;
String columnValue="",chgTerm="",chgUser="",priceList="",tranDate="",listType=""; String columnValue="",chgTerm="",chgUser="",priceList="",tranDate="",listType="",oRate="";
String itemCode="",locCode="",lotNo="",lotsl="",oldRate="",quantity="",itmdesc="",loginSite=""; String itemCode="",locCode="",lotNo="",lotsl="",quantity="",itmdesc="",loginSite="";
Date utranDate; Date utranDate;
double rate = 0,conquan,conOldRate,oldAmount,amount,amtdiff; double rate = 0,conquan,conOldRate,oldAmount,amount,amtdiff,oldRate=0;
try try
{ {
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
...@@ -819,22 +865,9 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca ...@@ -819,22 +865,9 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
siteCode = siteCode.trim(); siteCode = siteCode.trim();
if(siteCode != null && siteCode.trim().length()>0 ) if(siteCode != null && siteCode.trim().length()>0 )
{ {
sql = "select descr from site where site_code = ?"; sitedesc=getColumnDescr(conn,"descr","site","site_code",siteCode);
pstmt=conn.prepareStatement(sql); valueXmlString.append("<site_descr>").append("<![CDATA[" + sitedesc + "]]>").append("</site_descr>");
pstmt.setString(1,siteCode); }else{
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
{
valueXmlString.append("<site_descr>").append("<![CDATA[]]>").append("</site_descr>"); valueXmlString.append("<site_descr>").append("<![CDATA[]]>").append("</site_descr>");
} }
} }
...@@ -867,77 +900,21 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca ...@@ -867,77 +900,21 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
System.out.println("item code >>>>"+itemCode); System.out.println("item code >>>>"+itemCode);
if(itemCode != null && itemCode.length()>0 ) if(itemCode != null && itemCode.length()>0 )
{ {
sql = "select descr from item where item_code = ?"; itmdesc=getColumnDescr(conn,"descr","item","item_code",itemCode);
pstmt=conn.prepareStatement(sql); valueXmlString.append("<item_descr>").append("<![CDATA["+itmdesc+"]]>").append("</item_descr>");
pstmt.setString(1,itemCode); }else{
rs = pstmt.executeQuery(); valueXmlString.append("<item_descr>").append("<![CDATA[]]>").append("</item_descr>");
if(rs.next())
{
itmdesc = rs.getString(1) == null ? "":rs.getString(1);
} }
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0) if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0)
{ {
oldRate=getRateFromStock(conn, siteCode, itemCode, locCode, lotNo, lotsl);
sql = "select rate from stock where site_code = ? and item_code = ? and loc_code = ? and lot_no = ? and lot_sl = ?"; System.out.println("Old Rate in item code----->>["+oldRate);
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); rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, "", conn);
if(rate == 0.0 || rate == 0 || rate == -1) valueXmlString.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>");
{ valueXmlString.append("<rate>").append("<![CDATA["+rate+"]]>").append("</rate>");
rate = 0;
}
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 ...@@ -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 (currentColumn.trim().equals("lot_no"))
{ {
if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0) 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 = ?"; oldRate=getRateFromStock(conn, siteCode, itemCode, locCode, lotNo, lotsl);
pstmt=conn.prepareStatement(sql); System.out.println("Old Rate in lot_noe----->>["+oldRate);
pstmt.setString(1,siteCode); rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, "", conn);
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); if(rate == -1)
System.out.println(">>>rate"+rate);
if(rate == 0.0 || rate == 0 || 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>").append("<![CDATA["+rate+"]]>").append("</rate>");
}else }else
{ {
valueXmlString.append("<rate__old>").append("<![CDATA[]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA[]]>").append("</rate>"); valueXmlString.append("<rate>").append("<![CDATA[]]>").append("</rate>");
} }
} }
if (currentColumn.trim().equals("lot_sl")) if (currentColumn.trim().equals("lot_sl"))
{ {
if(itemCode.length() > 0 && locCode.length() > 0 && lotNo.length() > 0 && lotsl.length() > 0) 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 = ?"; oldRate=getRateFromStock(conn, siteCode, itemCode, locCode, lotNo, lotsl);
pstmt=conn.prepareStatement(sql); System.out.println("Old Rate in lot_sl----->>["+oldRate);
pstmt.setString(1,siteCode); rate = getPriceListRate(priceList, utranDate, itemCode, lotNo, "", conn);
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;
if(rate == -1)
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)
{ {
rate = 0; System.out.println("CODE RATE ERROR-----------------------------------------");
} }
valueXmlString.append("<rate__old>").append("<![CDATA[" + oldRate + "]]>").append("</rate__old>"); valueXmlString.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>");
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>"); valueXmlString.append("<rate>").append("<![CDATA["+rate+"]]>").append("</rate>");
}else }else
{ {
valueXmlString.append("<rate__old>").append("<![CDATA[]]>").append("</rate__old>"); valueXmlString.append("<rate__old>").append("<![CDATA[]]>").append("</rate__old>");
...@@ -1165,30 +978,32 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca ...@@ -1165,30 +978,32 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
if (currentColumn.trim().equals("quantity")) if (currentColumn.trim().equals("quantity"))
{ {
String oldRateS="";
quantity = checkNull(genericUtility.getColumnValue("quantity",dom)); quantity = checkNull(genericUtility.getColumnValue("quantity",dom));
System.out.println(">>>>>oldRate"+oldRate); oldRateS = checkNull(genericUtility.getColumnValue("rate__old",dom));
oldRate = checkNull(genericUtility.getColumnValue("rate__old",dom)); oRate = checkNull(genericUtility.getColumnValue("rate",dom));
conquan = Double.parseDouble(quantity);
System.out.println(">>>>>conquan"+conquan); System.out.println("oldRateS----->>["+oldRateS+"]");
conOldRate = Double.parseDouble(oldRate); System.out.println("oRate----->>["+oRate+"]");
System.out.println(">>>>>conOldRate"+conOldRate);
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; oldAmount = conquan * conOldRate;
amount = conquan * rate; 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>").append("<![CDATA[" + amount + "]]>").append("</amount>");
valueXmlString.append("<amount__diff>").append("<![CDATA[" + amtdiff + "]]>").append("</amount__diff>"); 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__old>").append("<![CDATA[]]>").append("</amount__old>");
valueXmlString.append("<amount>").append("<![CDATA[]]>").append("</amount>"); valueXmlString.append("<amount>").append("<![CDATA[]]>").append("</amount>");
valueXmlString.append("<amount__diff>").append("<![CDATA[]]>").append("</amount__diff>"); valueXmlString.append("<amount__diff>").append("<![CDATA[]]>").append("</amount__diff>");
...@@ -1398,6 +1213,69 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca ...@@ -1398,6 +1213,69 @@ public class StockValAdjTran extends ValidatorEJB implements StockValAdjTranLoca
} }
return input.trim(); 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) // 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 ...@@ -57,7 +57,7 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj
{ {
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverValidator"); conn = connDriver.getConnectDB("DriverITM");
loginEmpCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"); loginEmpCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
loginEmpCode=loginEmpCode==null ? "" :loginEmpCode.trim(); loginEmpCode=loginEmpCode==null ? "" :loginEmpCode.trim();
System.out.println("loginEmpCode---->>["+loginEmpCode+"]"); System.out.println("loginEmpCode---->>["+loginEmpCode+"]");
...@@ -115,16 +115,25 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj ...@@ -115,16 +115,25 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj
updateStockMap.put("lot_no",lotNo); updateStockMap.put("lot_no",lotNo);
updateStockMap.put("lot_sl",lotSl); updateStockMap.put("lot_sl",lotSl);
count=updateStockRateAsPerPriceListRate(conn, updateStockMap);
count=updateStockValAdj(conn, loginEmpCode, tranId);
System.out.println("updateStockRateAsPerPriceListRate count-->["+count+"]"); System.out.println("updateStockRateAsPerPriceListRate count-->["+count+"]");
if(count > 0){ if(count > 0){
System.out.println("654321"); System.out.println("654321");
System.out.println("123456"); System.out.println("123456");
String errCall = inv.stkAdjust(tranId, conn); String errCall = inv.stkAdjust(tranId, conn);
System.out.println(">>>>>>> errCall"+errCall); 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+"]"); System.out.println("updateStockValAdj-->>["+count+"]");
if(count > 0){ if(count > 0){
//confirmed messages show............. //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