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;
import java.rmi.RemoteException;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB;
......@@ -10,8 +8,6 @@ import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.ProofOfDelivery;
import java.rmi.RemoteException;
import java.sql.Connection;
......@@ -27,13 +23,8 @@ import java.util.Set;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class StockRevaluationAdjPrc extends ProcessEJB implements StockRevaluationAdjPrcLocal,StockRevaluationAdjPrcRemote{
......@@ -92,11 +83,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr
ValidatorEJB vdt=null;
PreparedStatement pstmt=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;
double quantityOld=0,rateOld=0;
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 headerXml="",detail2Xml="",locCode="";
try{
......@@ -141,14 +132,16 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString;
}else{
System.out.println("itemSerFrm--->>["+itemSerFrm+"]");
cnt=getDBRowCount(conn,"itemser","item_ser",itemSerFrm);
if(cnt == 0){
System.out.println("itemSerFrm not exist validation fire");
errCode = "VTISERFNE";
errorString = vdt.getErrorString("item_ser__from",errCode,userId);
return errorString;
}
if(!("00".equalsIgnoreCase(itemSerFrm))){
System.out.println("itemSerFrm--->>["+itemSerFrm+"]");
cnt=getDBRowCount(conn,"itemser","item_ser",itemSerFrm);
if(cnt == 0){
System.out.println("itemSerFrm not exist validation fire");
errCode = "VTISERFNE";
errorString = vdt.getErrorString("item_ser__from",errCode,userId);
return errorString;
}
}
}
//Validation for item series To
......@@ -157,7 +150,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errorString = vdt.getErrorString("item_ser__to",errCode,userId);
return errorString;
}else{
}else{
if(!("ZZ".equalsIgnoreCase(itemSerTo))){
System.out.println("itemSerTo --->>["+itemSerTo+"]");
cnt=getDBRowCount(conn,"itemser","item_ser",itemSerTo);
if(cnt == 0){
......@@ -166,6 +160,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errorString = vdt.getErrorString("item_ser__to",errCode,userId);
return errorString;
}
}
}
//Validation for item code from
......@@ -174,7 +169,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errorString = vdt.getErrorString("item_code__from",errCode,userId);
return errorString;
}else{
}else{
if(!("00".equalsIgnoreCase(itemCodeFrm))){
System.out.println("itemCodeFrm --->>["+itemCodeFrm+"]");
cnt=getDBRowCount(conn,"item","item_code",itemCodeFrm);
if(cnt == 0){
......@@ -182,7 +178,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errCode = "VTITMCFNE";
errorString = vdt.getErrorString("item_code__from",errCode,userId);
return errorString;
}
}
}
}
//Validation for item code To
......@@ -191,7 +188,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errorString = vdt.getErrorString("item_code_to",errCode,userId);
return errorString;
}else{
}else{
if(!("ZZ".equalsIgnoreCase(itemCodeTo))){
System.out.println("itemCodeTo --->>["+itemCodeTo+"]");
cnt=getDBRowCount(conn,"item","item_code",itemCodeTo);
if(cnt == 0){
......@@ -200,6 +198,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errorString = vdt.getErrorString("item_code_to",errCode,userId);
return errorString;
}
}
}
//Validation for Reason code
......@@ -208,7 +207,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
errorString = vdt.getErrorString("reason_code",errCode,userId);
return errorString;
}else{
cnt=getDBRowCount(conn,"gencodes","fld_name",reasonCode);
cnt=getDBRowCount(conn,"finparm","var_value",reasonCode);
if(cnt == 0){
errCode = "VTRESNCNE";
errorString = vdt.getErrorString("reason_code",errCode,userId);
......@@ -218,25 +217,28 @@ public String process(Document dom, Document dom2, String windowName, String xtr
}
//Validation FOR Price List
if(priceList.length() == 0){
priceList = genericUtility.getColumnValue("price_list",dom);
errCode = "VTPRCLNN";
errorString = vdt.getErrorString("price_list",errCode,userId);
return errorString;
}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.setString(1,siteCode);
rs=pstmt.executeQuery();
if(rs.next()){
priceListL=checkNull(rs.getString(1));
pstmt.setString(1,priceList);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
System.out.println("priceListL--->>["+priceListL+"]");
System.out.println("priceList--->>["+priceList+"]");
if(!(priceListL.equalsIgnoreCase(priceList))){
errCode = "VTPRCLNDS";
if(cnt == 0)
{
errCode = "STKVALPRAE";
errorString = vdt.getErrorString("price_list",errCode,userId);
return errorString;
}
if(rs!=null){
rs.close();
rs=null;
......@@ -253,22 +255,53 @@ public String process(Document dom, Document dom2, String windowName, String xtr
if(itemCodeFrm.length() > 0 && itemCodeTo.length() > 0){
System.out.println("in actual logic--------------");
sql="select item_ser from stock where site_code = ? and item_ser between ? and ? "
+ "and item_code between ? and ?";
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, itemSerFrm);
pstmt.setString(3, itemSerTo);
pstmt.setString(4, itemCodeFrm);
pstmt.setString(5, itemCodeTo);
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 ? "
+ "and item_code between ? and ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemSerFrm);
pstmt.setString(3, itemSerTo);
pstmt.setString(4, itemCodeFrm);
pstmt.setString(5, itemCodeTo);
}
rs=pstmt.executeQuery();
while (rs.next()){
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();
System.out.println("size of itemSerCount---->>["+itemSerCount+"]");
//recordProcess
System.out.println("size of itemSer Count---->>["+itemSerSet.size()+"]");
if(rs!=null){
rs.close();
rs=null;
......@@ -278,8 +311,17 @@ public String process(Document dom, Document dom2, String windowName, String xtr
pstmt=null;
}
for(String unqItemSer : itemSerSet){
serCount++;
recordProcess++;
System.out.println("recordProcess---------->>["+recordProcess+"]");
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 "
+ "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
pstmt.setString(2, unqItemSer);
pstmt.setString(3, itemCodeFrm);
pstmt.setString(4, itemCodeTo);
}
headerXml=getHeaderXml(conn,siteCode,unqItemSer,priceList,reasonCode);
rs=pstmt.executeQuery();
while (rs.next()){
lineNo++;
isRecordFound=true;
while (rs.next()){
lineNo++;
itemCode=checkNull(rs.getString(1));
quantityOld=rs.getDouble(2);
rateOld=rs.getDouble(3);
......@@ -320,7 +362,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
System.out.println("After Saving record errorString--->>["+errorString+"]");
if (errorString.indexOf("Success") > -1)
{
System.out.println("Record saved Successfully......");
conn.commit();
System.out.println("Record saved Successfully12......");
System.out.println("autoConfirm----->>["+autoConfirm+"]");
if("Y".equalsIgnoreCase(autoConfirm)){
StockValAdjTranConf objStockAdj=new StockValAdjTranConf();
......@@ -329,9 +372,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr
if(errorString!=null && errorString.indexOf("STKVACONF") > -1){
}else{
conn.commit();
return errorString;
}
}else{
conn.commit();
saveRecord=true;
}
}else{
......@@ -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
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+"]");
if(errorString!=null && errorString.indexOf("STKVACONF") > -1 || saveRecord){
conn.commit();
......@@ -555,7 +595,11 @@ private String getDetail2Xml(Connection conn,String itemSer,String siteCode,Stri
detail2xml.append("<rate__old>").append("<![CDATA["+oldRate+"]]>").append("</rate__old>");
java.util.Date tranDate=new Date();
newRate=getPriceListRate(priceList, tranDate, itemCode, lotNo, "", conn);
System.out.println("PriceList rate------->>["+newRate+"]");
newRate = newRate == -1 ? 0 : newRate;
/*if(newRate <= 0 ){
return "PRCERROR";
}*/
detail2xml.append("<rate>").append("<![CDATA["+newRate+"]]>").append("</rate>");
amountOld= oldRate * quantity;
......@@ -573,15 +617,23 @@ private String getDetail2Xml(Connection conn,String itemSer,String siteCode,Stri
acctCctrCode=getAcctCctrCodeFromStock(conn, siteCode, itemCode, locCodeL, lotNo, lotSl);
System.out.println("acctCctrCode----->>["+acctCctrCode+"]");
String acctCctrCodeL[]=acctCctrCode.split(":");
System.out.println("acctCctrCodeL length----->>["+acctCctrCodeL.length+"]");
acctCctrCodeInvRev=finCommonObj.getFromAcctDetr(itemCode,itemSer,"STKADJ", conn);
System.out.println("acctCctrCodeInvRev----->>["+acctCctrCodeInvRev+"]");
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("<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("<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("<cctr_code__inv>").append("<![CDATA[").append("]]></cctr_code__inv>\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