Commit 66763b6e authored by dpawar's avatar dpawar

added code for '00' and 'ZZ' and confirmation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94582 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ef5a720a
package ibase.webitm.ejb.fin; package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import ibase.system.config.AppConnectParm; import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
...@@ -10,8 +8,6 @@ import ibase.webitm.ejb.ProcessEJB; ...@@ -10,8 +8,6 @@ import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.ProofOfDelivery;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
...@@ -27,13 +23,8 @@ import java.util.Set; ...@@ -27,13 +23,8 @@ import java.util.Set;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless @Stateless
public class StockRevaluationAdjPrc extends ProcessEJB implements StockRevaluationAdjPrcLocal,StockRevaluationAdjPrcRemote{ public class StockRevaluationAdjPrc extends ProcessEJB implements StockRevaluationAdjPrcLocal,StockRevaluationAdjPrcRemote{
...@@ -92,11 +83,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -92,11 +83,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr
ValidatorEJB vdt=null; ValidatorEJB vdt=null;
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ResultSet rs=null;
int cnt=0,lineNo=0,itemSerCount=0,serCount=0; int cnt=0,lineNo=0,recordProcess=0,serCount=0;
boolean isRecordFound=false; boolean isRecordFound=false;
double quantityOld=0,rateOld=0; double quantityOld=0,rateOld=0;
Set<String> itemSerSet=new HashSet<String>(); Set<String> itemSerSet=new HashSet<String>();
String siteCode="",itemSerFrm="",itemSerTo="",itemCodeFrm="",itemCodeTo="",errorString="",errCode=""; String siteCode="",itemSerFrm="",itemSerTo="",itemCodeFrm="",itemCodeTo="",errorString="",errCode="",pricelist="";
String sql="",autoConfirm="",priceList="",reasonCode="",userId="",itemCode="",itemSeries="",lotNo="",lotSl=""; String sql="",autoConfirm="",priceList="",reasonCode="",userId="",itemCode="",itemSeries="",lotNo="",lotSl="";
String headerXml="",detail2Xml="",locCode=""; String headerXml="",detail2Xml="",locCode="";
try{ try{
...@@ -141,6 +132,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -141,6 +132,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
}else{ }else{
if(!("00".equalsIgnoreCase(itemSerFrm))){
System.out.println("itemSerFrm--->>["+itemSerFrm+"]"); System.out.println("itemSerFrm--->>["+itemSerFrm+"]");
cnt=getDBRowCount(conn,"itemser","item_ser",itemSerFrm); cnt=getDBRowCount(conn,"itemser","item_ser",itemSerFrm);
if(cnt == 0){ if(cnt == 0){
...@@ -150,6 +142,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -150,6 +142,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
} }
} }
}
//Validation for item series To //Validation for item series To
if (itemSerTo.length() == 0 ){ if (itemSerTo.length() == 0 ){
...@@ -158,6 +151,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -158,6 +151,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
}else{ }else{
if(!("ZZ".equalsIgnoreCase(itemSerTo))){
System.out.println("itemSerTo --->>["+itemSerTo+"]"); System.out.println("itemSerTo --->>["+itemSerTo+"]");
cnt=getDBRowCount(conn,"itemser","item_ser",itemSerTo); cnt=getDBRowCount(conn,"itemser","item_ser",itemSerTo);
if(cnt == 0){ if(cnt == 0){
...@@ -167,6 +161,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -167,6 +161,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
} }
} }
}
//Validation for item code from //Validation for item code from
if (itemCodeFrm.length() == 0 ){ if (itemCodeFrm.length() == 0 ){
...@@ -175,6 +170,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -175,6 +170,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
}else{ }else{
if(!("00".equalsIgnoreCase(itemCodeFrm))){
System.out.println("itemCodeFrm --->>["+itemCodeFrm+"]"); System.out.println("itemCodeFrm --->>["+itemCodeFrm+"]");
cnt=getDBRowCount(conn,"item","item_code",itemCodeFrm); cnt=getDBRowCount(conn,"item","item_code",itemCodeFrm);
if(cnt == 0){ if(cnt == 0){
...@@ -184,6 +180,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -184,6 +180,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
} }
} }
}
//Validation for item code To //Validation for item code To
if (itemCodeTo.length() == 0 ){ if (itemCodeTo.length() == 0 ){
...@@ -192,6 +189,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -192,6 +189,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
}else{ }else{
if(!("ZZ".equalsIgnoreCase(itemCodeTo))){
System.out.println("itemCodeTo --->>["+itemCodeTo+"]"); System.out.println("itemCodeTo --->>["+itemCodeTo+"]");
cnt=getDBRowCount(conn,"item","item_code",itemCodeTo); cnt=getDBRowCount(conn,"item","item_code",itemCodeTo);
if(cnt == 0){ if(cnt == 0){
...@@ -201,6 +199,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -201,6 +199,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
} }
} }
}
//Validation for Reason code //Validation for Reason code
if (reasonCode.length() == 0 ){ if (reasonCode.length() == 0 ){
...@@ -208,7 +207,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -208,7 +207,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errorString = vdt.getErrorString("reason_code",errCode,userId); errorString = vdt.getErrorString("reason_code",errCode,userId);
return errorString; return errorString;
}else{ }else{
cnt=getDBRowCount(conn,"gencodes","fld_name",reasonCode); cnt=getDBRowCount(conn,"finparm","var_value",reasonCode);
if(cnt == 0){ if(cnt == 0){
errCode = "VTRESNCNE"; errCode = "VTRESNCNE";
errorString = vdt.getErrorString("reason_code",errCode,userId); errorString = vdt.getErrorString("reason_code",errCode,userId);
...@@ -218,25 +217,28 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -218,25 +217,28 @@ public String process(Document dom, Document dom2, String windowName, String xtr
} }
//Validation FOR Price List //Validation FOR Price List
if(priceList.length() == 0){ if(priceList.length() == 0){
priceList = genericUtility.getColumnValue("price_list",dom);
errCode = "VTPRCLNN"; errCode = "VTPRCLNN";
errorString = vdt.getErrorString("price_list",errCode,userId); errorString = vdt.getErrorString("price_list",errCode,userId);
return errorString; return errorString;
}else{ }else{
String priceListL="";
sql="select price_list from site where site_code=?"; sql = "select count(1) from pricelist where price_list = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode); pstmt.setString(1,priceList);
rs=pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()){ if(rs.next())
priceListL=checkNull(rs.getString(1)); {
cnt = rs.getInt(1);
} }
System.out.println("priceListL--->>["+priceListL+"]");
System.out.println("priceList--->>["+priceList+"]"); if(cnt == 0)
if(!(priceListL.equalsIgnoreCase(priceList))){ {
errCode = "VTPRCLNDS"; errCode = "STKVALPRAE";
errorString = vdt.getErrorString("price_list",errCode,userId); errorString = vdt.getErrorString("price_list",errCode,userId);
return errorString; return errorString;
} }
if(rs!=null){ if(rs!=null){
rs.close(); rs.close();
rs=null; rs=null;
...@@ -253,6 +255,27 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -253,6 +255,27 @@ public String process(Document dom, Document dom2, String windowName, String xtr
if(itemCodeFrm.length() > 0 && itemCodeTo.length() > 0){ if(itemCodeFrm.length() > 0 && itemCodeTo.length() > 0){
System.out.println("in actual logic--------------"); System.out.println("in actual logic--------------");
if("00".equalsIgnoreCase(itemCodeFrm) && "ZZ".equalsIgnoreCase(itemCodeTo))
{
sql="select item_ser from stock where site_code = ? and item_ser between ? and ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemSerFrm);
pstmt.setString(3, itemSerTo);
}else if("00".equalsIgnoreCase(itemSerFrm) && "ZZ".equalsIgnoreCase(itemSerTo)){
sql="select item_ser from stock where site_code = ? and item_code between ? and ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCodeFrm);
pstmt.setString(3, itemCodeTo);
}else if("00".equalsIgnoreCase(itemSerFrm) && "ZZ".equalsIgnoreCase(itemSerTo) &&
"00".equalsIgnoreCase(itemCodeFrm) && "ZZ".equalsIgnoreCase(itemCodeTo)){
sql="select item_ser from stock where site_code = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
}else{
sql="select item_ser from stock where site_code = ? and item_ser between ? and ? " sql="select item_ser from stock where site_code = ? and item_ser between ? and ? "
+ "and item_code between ? and ?"; + "and item_code between ? and ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
...@@ -261,14 +284,24 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -261,14 +284,24 @@ public String process(Document dom, Document dom2, String windowName, String xtr
pstmt.setString(3, itemSerTo); pstmt.setString(3, itemSerTo);
pstmt.setString(4, itemCodeFrm); pstmt.setString(4, itemCodeFrm);
pstmt.setString(5, itemCodeTo); pstmt.setString(5, itemCodeTo);
}
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while (rs.next()){ while (rs.next()){
itemSerSet.add(rs.getString(1)); itemSerSet.add(rs.getString(1));
isRecordFound=true;
}
System.out.println("isRecordFound--->>["+isRecordFound+"]");
if(! isRecordFound){
conn.rollback();
errCode = "VTDNFIN";// data not found
errorString = vdt.getErrorString("",errCode,userId);
return errorString;
} }
itemSerCount=itemSerSet.size(); //recordProcess
System.out.println("size of itemSerCount---->>["+itemSerCount+"]"); System.out.println("size of itemSer Count---->>["+itemSerSet.size()+"]");
if(rs!=null){ if(rs!=null){
rs.close(); rs.close();
rs=null; rs=null;
...@@ -278,8 +311,17 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -278,8 +311,17 @@ public String process(Document dom, Document dom2, String windowName, String xtr
pstmt=null; pstmt=null;
} }
for(String unqItemSer : itemSerSet){ for(String unqItemSer : itemSerSet){
serCount++; recordProcess++;
System.out.println("recordProcess---------->>["+recordProcess+"]");
lineNo=0; lineNo=0;
if("00".equalsIgnoreCase(itemCodeFrm) && "ZZ".equalsIgnoreCase(itemCodeTo))
{
sql="select item_code,quantity,rate,item_ser,lot_no,lot_sl,loc_code from stock "
+ "where site_code = ? and item_ser = ? and quantity > 0 and lot_no is not null and lot_no <> ' ' ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, unqItemSer);
}else{
sql="select item_code,quantity,rate,item_ser,lot_no,lot_sl,loc_code from stock " sql="select item_code,quantity,rate,item_ser,lot_no,lot_sl,loc_code from stock "
+ "where site_code = ? and item_ser = ? and item_code between ? and ? and quantity > 0 and lot_no is not null and lot_no <> ' ' "; + "where site_code = ? and item_ser = ? and item_code between ? and ? and quantity > 0 and lot_no is not null and lot_no <> ' ' ";
...@@ -288,13 +330,13 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -288,13 +330,13 @@ public String process(Document dom, Document dom2, String windowName, String xtr
pstmt.setString(2, unqItemSer); pstmt.setString(2, unqItemSer);
pstmt.setString(3, itemCodeFrm); pstmt.setString(3, itemCodeFrm);
pstmt.setString(4, itemCodeTo); pstmt.setString(4, itemCodeTo);
}
headerXml=getHeaderXml(conn,siteCode,unqItemSer,priceList,reasonCode); headerXml=getHeaderXml(conn,siteCode,unqItemSer,priceList,reasonCode);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while (rs.next()){ while (rs.next()){
lineNo++; lineNo++;
isRecordFound=true;
itemCode=checkNull(rs.getString(1)); itemCode=checkNull(rs.getString(1));
quantityOld=rs.getDouble(2); quantityOld=rs.getDouble(2);
rateOld=rs.getDouble(3); rateOld=rs.getDouble(3);
...@@ -320,7 +362,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -320,7 +362,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
System.out.println("After Saving record errorString--->>["+errorString+"]"); System.out.println("After Saving record errorString--->>["+errorString+"]");
if (errorString.indexOf("Success") > -1) if (errorString.indexOf("Success") > -1)
{ {
System.out.println("Record saved Successfully......"); conn.commit();
System.out.println("Record saved Successfully12......");
System.out.println("autoConfirm----->>["+autoConfirm+"]"); System.out.println("autoConfirm----->>["+autoConfirm+"]");
if("Y".equalsIgnoreCase(autoConfirm)){ if("Y".equalsIgnoreCase(autoConfirm)){
StockValAdjTranConf objStockAdj=new StockValAdjTranConf(); StockValAdjTranConf objStockAdj=new StockValAdjTranConf();
...@@ -329,9 +372,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -329,9 +372,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr
if(errorString!=null && errorString.indexOf("STKVACONF") > -1){ if(errorString!=null && errorString.indexOf("STKVACONF") > -1){
}else{ }else{
conn.commit();
return errorString; return errorString;
} }
}else{ }else{
conn.commit();
saveRecord=true; saveRecord=true;
} }
}else{ }else{
...@@ -342,19 +387,14 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -342,19 +387,14 @@ public String process(Document dom, Document dom2, String windowName, String xtr
} }
if(! isRecordFound){
conn.rollback();
errCode = "VTDNFIN";// data not found
errorString = vdt.getErrorString("",errCode,userId);
return errorString;
}
} //end for loop of set } //end for loop of set
System.out.println("No of Item series process--->>"+serCount+"]"); System.out.println("No of Item series process--->>"+serCount+"]");
System.out.println("End of process errorString--->>"+serCount+"]"); System.out.println("End of process errorString--->>"+errorString+"]");
System.out.println("saveRecord--->>"+saveRecord+"]"); System.out.println("saveRecord--->>"+saveRecord+"]");
if(errorString!=null && errorString.indexOf("STKVACONF") > -1 || saveRecord){ if(errorString!=null && errorString.indexOf("STKVACONF") > -1 || saveRecord){
conn.commit(); conn.commit();
...@@ -555,7 +595,11 @@ private String getDetail2Xml(Connection conn,String itemSer,String siteCode,Stri ...@@ -555,7 +595,11 @@ private String getDetail2Xml(Connection conn,String itemSer,String siteCode,Stri
detail2xml.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>"); detail2xml.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>");
java.util.Date tranDate=new Date(); java.util.Date tranDate=new Date();
newRate=getPriceListRate(priceList, tranDate, itemCode, lotNo, "", conn); newRate=getPriceListRate(priceList, tranDate, itemCode, lotNo, "", conn);
System.out.println("PriceList rate------->>["+newRate+"]");
newRate = newRate == -1 ? 0 : newRate; newRate = newRate == -1 ? 0 : newRate;
/*if(newRate <= 0 ){
return "PRCERROR";
}*/
detail2xml.append("<rate>").append("<![CDATA["+newRate+"]]>").append("</rate>"); detail2xml.append("<rate>").append("<![CDATA["+newRate+"]]>").append("</rate>");
amountOld= oldRate * quantity; amountOld= oldRate * quantity;
...@@ -573,15 +617,23 @@ private String getDetail2Xml(Connection conn,String itemSer,String siteCode,Stri ...@@ -573,15 +617,23 @@ private String getDetail2Xml(Connection conn,String itemSer,String siteCode,Stri
acctCctrCode=getAcctCctrCodeFromStock(conn, siteCode, itemCode, locCodeL, lotNo, lotSl); acctCctrCode=getAcctCctrCodeFromStock(conn, siteCode, itemCode, locCodeL, lotNo, lotSl);
System.out.println("acctCctrCode----->>["+acctCctrCode+"]"); System.out.println("acctCctrCode----->>["+acctCctrCode+"]");
String acctCctrCodeL[]=acctCctrCode.split(":"); String acctCctrCodeL[]=acctCctrCode.split(":");
System.out.println("acctCctrCodeL length----->>["+acctCctrCodeL.length+"]");
acctCctrCodeInvRev=finCommonObj.getFromAcctDetr(itemCode,itemSer,"STKADJ", conn); acctCctrCodeInvRev=finCommonObj.getFromAcctDetr(itemCode,itemSer,"STKADJ", conn);
System.out.println("acctCctrCodeInvRev----->>["+acctCctrCodeInvRev+"]"); System.out.println("acctCctrCodeInvRev----->>["+acctCctrCodeInvRev+"]");
String acctCctrCodeS[]=acctCctrCodeInvRev.split(","); String acctCctrCodeS[]=acctCctrCodeInvRev.split(",");
if (acctCctrCodeL.length > 0 && acctCctrCodeS.length > 0) { System.out.println("acctCctrCodeS length----->>["+acctCctrCodeS.length+"]");
if (acctCctrCodeL.length ==2 && acctCctrCodeS.length == 2) {
detail2xml.append("<acct_code__inv>").append("<![CDATA[").append(acctCctrCodeL[0].trim()).append("]]></acct_code__inv>\r\n"); detail2xml.append("<acct_code__inv>").append("<![CDATA[").append(acctCctrCodeL[0].trim()).append("]]></acct_code__inv>\r\n");
detail2xml.append("<cctr_code__inv>").append("<![CDATA[").append(acctCctrCodeL[1].trim()).append("]]></cctr_code__inv>\r\n"); detail2xml.append("<cctr_code__inv>").append("<![CDATA[").append(acctCctrCodeL[1].trim()).append("]]></cctr_code__inv>\r\n");
detail2xml.append("<acct_code__inrev>").append("<![CDATA[").append(acctCctrCodeS[0].trim()).append("]]></acct_code__inrev>\r\n"); detail2xml.append("<acct_code__inrev>").append("<![CDATA[").append(acctCctrCodeS[0].trim()).append("]]></acct_code__inrev>\r\n");
detail2xml.append("<cctr_code__inrev>").append("<![CDATA[").append(acctCctrCodeS[1].trim()).append("]]></cctr_code__inrev>\r\n"); detail2xml.append("<cctr_code__inrev>").append("<![CDATA[").append(acctCctrCodeS[1].trim()).append("]]></cctr_code__inrev>\r\n");
} else { } else if (acctCctrCodeL.length ==1 && acctCctrCodeS.length == 1) {
detail2xml.append("<acct_code__inv>").append("<![CDATA[").append(acctCctrCodeL[0].trim()).append("]]></acct_code__inv>\r\n");
detail2xml.append("<cctr_code__inv>").append("<![CDATA[").append(" ").append("]]></cctr_code__inv>\r\n");
detail2xml.append("<acct_code__inrev>").append("<![CDATA[").append(acctCctrCodeS[0].trim()).append("]]></acct_code__inrev>\r\n");
detail2xml.append("<cctr_code__inrev>").append("<![CDATA[").append(" ").append("]]></cctr_code__inrev>\r\n");
}else{
detail2xml.append("<acct_code__inv>").append("<![CDATA[").append("]]></acct_code__inv>\r\n"); detail2xml.append("<acct_code__inv>").append("<![CDATA[").append("]]></acct_code__inv>\r\n");
detail2xml.append("<cctr_code__inv>").append("<![CDATA[").append("]]></cctr_code__inv>\r\n"); detail2xml.append("<cctr_code__inv>").append("<![CDATA[").append("]]></cctr_code__inv>\r\n");
detail2xml.append("<acct_code__inrev>").append("<![CDATA[").append("]]></acct_code__inrev>\r\n"); detail2xml.append("<acct_code__inrev>").append("<![CDATA[").append("]]></acct_code__inrev>\r\n");
......
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