Commit 64255a5f authored by dpawar's avatar dpawar

dynamic error message shown


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94227 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 625369ae
...@@ -7,6 +7,7 @@ import ibase.webitm.ejb.ValidatorEJB; ...@@ -7,6 +7,7 @@ import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.MiscDrCrRcpConf; import ibase.webitm.ejb.fin.MiscDrCrRcpConf;
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 java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
...@@ -17,19 +18,25 @@ import java.sql.Statement; ...@@ -17,19 +18,25 @@ import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import javax.ejb.Stateless; import javax.ejb.Stateless;
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;
import com.sun.jmx.snmp.Timestamp; import com.sun.jmx.snmp.Timestamp;
@Stateless @Stateless
public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote
{ {
ArrayList<String> podRemainInvIDList=new ArrayList<String>(); String siteCodeG="",invTypeG="";
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{ {
...@@ -74,10 +81,12 @@ public String process() throws RemoteException,ITMException ...@@ -74,10 +81,12 @@ public String process() throws RemoteException,ITMException
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException
{ {
System.out.println("enter in process(dom) "); System.out.println("enter in process(dom) ");
ArrayList <String>inv45dayList=new ArrayList<String>(); ArrayList <String>inv45dayList=new ArrayList<String>();
ArrayList<String> podProcessInvIDList=new ArrayList<String>(); ArrayList<String> podProcessInvIDList=new ArrayList<String>();
ArrayList<String> podNotConfList=new ArrayList<String>(); ArrayList<String> podNotConfList=new ArrayList<String>();
ArrayList<String> podTraceInvList=new ArrayList<String>();
ArrayList<String> miscDrCrInvList=new ArrayList<String>();
Connection conn = null; Connection conn = null;
ConnDriver connDriver = null; ConnDriver connDriver = null;
GenericUtility genericUtility = null; GenericUtility genericUtility = null;
...@@ -172,9 +181,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -172,9 +181,11 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
} }
} }
if(custCodeFrm.length() > 0 && custCodeTo.length() > 0 && siteCode.length() > 0){ if(custCodeFrm.length() > 0 && custCodeTo.length() > 0 && siteCode.length() > 0){
siteCodeG=siteCode;
invTypeG=invType;
sql="select invoice_id from invoice where cust_code__bil between ? and ? and site_code = ? " sql="select invoice_id from invoice where cust_code__bil between ? and ? and site_code = ? "
+ "and sysdate - conf_date > 517"; + "and sysdate - conf_date > 570";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, custCodeFrm); pstmt.setString(1, custCodeFrm);
pstmt.setString(2, custCodeTo); pstmt.setString(2, custCodeTo);
...@@ -224,11 +235,44 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -224,11 +235,44 @@ public String process(Document dom, Document dom2, String windowName, String xtr
} }
} }
podProcessInvIDList.clear(); //remove on final----------------------------7826464876---------------- //Need to be discussion. ------------------------------------------@@@@@@@@@@@@@@
/*podProcessInvIDList.clear();
podProcessInvIDList.add("618ID00036");
podProcessInvIDList.add("618ID00037");
podProcessInvIDList.add("618ID00038");
podProcessInvIDList.add("618ID00039");*/
podTraceInvList=getDoneInvoiceIDFromPodTrace(conn);
System.out.println("podTraceInvList---->>["+podTraceInvList+"]");
if(podTraceInvList.size() > 0){
for(String podPrcId : podProcessInvIDList){
if(podTraceInvList.contains(podPrcId)){
podProcessInvIDList.remove(podPrcId);
}
}
}
System.out.println("podProcessInvIDList-->>["+podProcessInvIDList+"]");
miscDrCrInvList=getDoneInvoiceIDFromMiscDrCrRcp(conn);
System.out.println("miscDrCrInvList---->>["+miscDrCrInvList+"]");
Iterator<String> it = podProcessInvIDList.iterator();
if(miscDrCrInvList.size() > 0){
while (it.hasNext()) {
String podPrcId=it.next();
if(miscDrCrInvList.contains(podPrcId)){
System.out.println("---in misc arrayList------");
it.remove();
podProcessInvIDList.remove(podPrcId);
}
}
}
//podProcessInvIDList.clear(); //remove on final----------------------------7826464876----------------
podProcessInvIDList.add("618ID00032"); //podProcessInvIDList.add("618ID00044");
podProcessInvIDList.add("618ID00033");
podProcessInvIDList.add("618ID00044");
System.out.println("Final invoice Id ready for debit note---->>["+podProcessInvIDList+"]"); System.out.println("Final invoice Id ready for debit note---->>["+podProcessInvIDList+"]");
...@@ -241,35 +285,10 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -241,35 +285,10 @@ public String process(Document dom, Document dom2, String windowName, String xtr
return errorString; return errorString;
} }
//Check in invoice_trace if item_code_ord (scheme_code) is available or not. //Check in invoice_trace if item_code_ord (scheme_code) is available or not.
//if yes then checked in bomdet.if scheme code found then for that particular item scheme is apply. //if yes then checked in bomdet.if scheme code found then for that particular item scheme is apply.
errorString=generateDebitNote(conn, podProcessInvIDList,priceList,xtraParams,siteCode,invType); errorString=generateDebitNote(conn, podProcessInvIDList,priceList,xtraParams,siteCode,invType);
System.out.println("Return string from generateDebitNote----->>["+errorString+"]"); System.out.println("Return string from generateDebitNote----->>["+errorString+"]");
if("ITEMNOTACTIVE".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTITMCNAC"; //Item code not active
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("Error".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTPRCNCP";
errorString =itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("Success".equalsIgnoreCase(errorString)){
conn.commit();
errCode="VTPRCCSF";
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("PRICELIST".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTPRCLNE";
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("SCHEME".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTSCHME";//scheme is expired for particular item,please check in bomdet
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
} }
}//end try }//end try
...@@ -298,24 +317,31 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -298,24 +317,31 @@ public String process(Document dom, Document dom2, String windowName, String xtr
private String generateDebitNote(Connection conn,ArrayList<String> podProcessInvIDListL,String priceListL,String xtraParams,String siteCode,String invType) private String generateDebitNote(Connection conn,ArrayList<String> podProcessInvIDListL,String priceListL,String xtraParams,String siteCode,String invType)
{ {
ResultSet rs=null; ResultSet rs=null;
Connection conn1=null;
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ProofOfDelivery pod=null; ProofOfDelivery pod=null;
ProofOfDeliveryConf podC=null; ProofOfDeliveryConf podC=null;
Map<String,String> invoiceDetailsMap=null; Map<String,String> invoiceDetailsMap=null;
HashMap<String,String> podTraceMap=new HashMap(); HashMap<String,String> podTraceMap=new HashMap();
Map<String,Double> schemeQty=null; HashMap<String,String> schemeMap=new HashMap();
ArrayList<String> confList=new ArrayList(); HashMap<String,String> partialMap=new HashMap();
Map<String,Double> schemeQty=null;
String sql="",lotNo="",lotSl="",itemCode="",itemCodeOrd="",itemActive="",detail2xmlString="",errString=""; String sql="",lotNo="",lotSl="",itemCode="",itemCodeOrd="",itemActive="",detail2xmlString="",errString="";
String custCode="",currCode="",partial="N",QtyInvTrace="",scheme="N"; String custCode="",currCode="",partial="N",QtyInvTrace="",scheme="N",errCode="";
double invRate=0,invQty=0,discount=0,priceListRate=0,detail3Amt=0,detail3AmtT=0,debitNoteAmtDetail=0; double invRate=0,invQty=0,discount=0,priceListRate=0,detail3Amt=0,detail3AmtT=0,debitNoteAmtDetail=0;
double debitNoteAmtHdr=0,ExchRate=0,actualRate=0,chargQty=0,freeQty=0,netPTS=0; double debitNoteAmtHdr=0,ExchRate=0,actualRate=0,chargQty=0,freeQty=0,netPTS=0;
int lineNotrace=0,lineNo=0,noOfInvoicePrc=0,totalInvoice=0; int lineNotrace=0,lineNo=0,noOfInvoicePrc=0,totalInvoice=0;
pod=ProofOfDelivery.getInstance(); pod=ProofOfDelivery.getInstance();
podC=ProofOfDeliveryConf.getInstance(); podC=ProofOfDeliveryConf.getInstance();
ITMDBAccessEJB itmdbAccess1=new ITMDBAccessEJB();
ConnDriver connDriver1 = new ConnDriver();
try{ try{
conn1 = connDriver1.getConnectDB("DriverITM");
connDriver1 = null;
System.out.println("priceListL123------>>["+priceListL+"]"); System.out.println("priceListL123------>>["+priceListL+"]");
totalInvoice=podProcessInvIDListL.size(); totalInvoice=podProcessInvIDListL.size();
System.out.println("total invoice for process------>>["+totalInvoice+"]"); System.out.println("total invoice for process------>>["+totalInvoice+"]");
if(totalInvoice > 0){
for(String invoiceId :podProcessInvIDListL) for(String invoiceId :podProcessInvIDListL)
{ {
detail2xmlString=""; detail2xmlString="";
...@@ -359,25 +385,31 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -359,25 +385,31 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
System.out.println("Actual inv qty in inv trace---->>["+invQty+"]"); System.out.println("Actual inv qty in inv trace---->>["+invQty+"]");
System.out.println("inv. qty done in POD screen---->>["+pod.partialQty+"]"); System.out.println("inv. qty done in POD screen---->>["+pod.partialQty+"]");
invQty = invQty - pod.partialQty; invQty = invQty - pod.partialQty;
partial="Y"; partial="Y";
partialMap.put(invoiceId+","+itemCode, scheme);
System.out.println("Actual inv qty---->>["+invQty+"]"); System.out.println("Actual inv qty---->>["+invQty+"]");
} }
partialMap.put(invoiceId+","+itemCode, partial);
//------------Mehod-----------------------------//
//Check if item code Active or not."N" or null then return error message. //Check if item code Active or not."N" or null then return error message.
itemActive=pod.getColumnDescr(conn,"active","item","item_code",itemCode); itemActive=pod.getColumnDescr(conn,"active","item","item_code",itemCode);
itemActive=itemActive==null ? "" :itemActive.trim(); itemActive=itemActive==null ? "" :itemActive.trim();
if(itemActive.equalsIgnoreCase("N") || itemActive.length()<=0) if(itemActive.equalsIgnoreCase("N") || itemActive.length()<=0)
{ {
return "ITEMNOTACTIVE"; // item code not active errCode="VTITMCNAC"; //Item code not active
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString; // item code not active
} }
java.util.Date tranDate=new Date(); java.util.Date tranDate=new Date();
priceListRate=getPriceListRate(priceListL, tranDate,itemCode,lotNo,"", conn); priceListRate=getPriceListRate(priceListL, tranDate,itemCode,lotNo,"", conn);
System.out.println("priceListRate----->>["+priceListRate+"]"); System.out.println("priceListRate----->>["+priceListRate+"]");
if(priceListRate <= 0) if(priceListRate <= 0)
{ {
return "PRICELIST"; errCode="VTPRCLNE";
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString;
} }
//check if scheme is apply or not //check if scheme is apply or not
...@@ -388,13 +420,20 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -388,13 +420,20 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
System.out.println("schemeQty map---->>["+schemeQty+"]"); System.out.println("schemeQty map---->>["+schemeQty+"]");
if(schemeQty.size() > 0){ if(schemeQty.size() > 0){
if(schemeQty.get("success") < 0){ if(schemeQty.get("success") < 0){
return "Error"; // Scheme related error or sql error. errCode="VTPRCNCP"; // Scheme related error or sql error.
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString;
} }
else if(schemeQty.get("success") == 0){ else if(schemeQty.get("success") == 0){
return "SCHEME"; errCode="VTSCHME"; //scheme is expired for particular item,please check in bomdet
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString;
} }
else if(schemeQty.get("success") == 1){ else if(schemeQty.get("success") == 1){
scheme="Y"; scheme="Y";
schemeMap.put(invoiceId+","+itemCode, scheme);
chargQty=schemeQty.get("charge_qty"); chargQty=schemeQty.get("charge_qty");
freeQty=schemeQty.get("free_qty"); freeQty=schemeQty.get("free_qty");
...@@ -408,10 +447,8 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -408,10 +447,8 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
} }
} }
}else{ }else{
System.out.println("-------Scheme not apply -----------"); System.out.println("-------Scheme not apply -----------");
schemeMap.put(invoiceId+","+itemCode, scheme);
//debitNoteAmtDetail=podC.getDebitNoteAmount(invRate,invQty);
//debitNoteAmtHdr=debitNoteAmtHdr+debitNoteAmtDetail;
actualRate=priceListRate - invRate; actualRate=priceListRate - invRate;
detail3Amt= actualRate * invQty; detail3Amt= actualRate * invQty;
...@@ -422,26 +459,7 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -422,26 +459,7 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
detail2xmlString=detail2xmlString + podC.getDetailsXmlString(conn,invoiceId,lineNotrace,lineNo,actualRate,invQty,lotNo,lotSl,itemCode, detail3Amt); detail2xmlString=detail2xmlString + podC.getDetailsXmlString(conn,invoiceId,lineNotrace,lineNo,actualRate,invQty,lotNo,lotSl,itemCode, detail3Amt);
} //end isSchemeApply } //end isSchemeApply
//insert into podTrace table entry....
podTraceMap.put("line_no", Integer.toString(lineNo));
podTraceMap.put("inv_id", invoiceId);
podTraceMap.put("site_code", siteCode);
podTraceMap.put("item_code", itemCode);
podTraceMap.put("inv_type", invType);
podTraceMap.put("db_qty", Double.toString(invQty));
podTraceMap.put("db_rate", Double.toString(actualRate));
podTraceMap.put("db_amount", Double.toString(detail3AmtT));
podTraceMap.put("partial",partial);
podTraceMap.put("scheme",scheme);
int podTrace=insertDataInPodTrace(conn, podTraceMap);
System.out.println("Return podTrace from insert---->>["+podTrace+"]");
if(podTrace < 0){
return "Error";
}
} //end while invoice trace } //end while invoice trace
rs.close(); rs.close();
...@@ -449,10 +467,10 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -449,10 +467,10 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
pstmt.close(); pstmt.close();
pstmt=null; pstmt=null;
System.out.println("Detail2 xml-------->>[["+detail2xmlString+"]"); System.out.println("Detail2 xml-------->>[["+detail2xmlString+"]");
if(detail3AmtT > 0){
invoiceDetailsMap=pod.getDetailsFromInvoice(conn, invoiceId); invoiceDetailsMap=pod.getDetailsFromInvoice(conn, invoiceId);
custCode=invoiceDetailsMap.get("cust_code").toString(); custCode=invoiceDetailsMap.get("cust_code").toString();
currCode =pod.checkNull(invoiceDetailsMap.get("curr_code")); currCode =pod.checkNull(invoiceDetailsMap.get("curr_code")); //xmlStringAll
ExchRate=Double.parseDouble(invoiceDetailsMap.get("exch_rate")); ExchRate=Double.parseDouble(invoiceDetailsMap.get("exch_rate"));
errString=podC.genDebitNote("PRC",invoiceId,custCode,siteCode,xtraParams,currCode,ExchRate,detail2xmlString,detail3AmtT,conn); errString=podC.genDebitNote("PRC",invoiceId,custCode,siteCode,xtraParams,currCode,ExchRate,detail2xmlString,detail3AmtT,conn);
System.out.println("------Error string after DN save--->>["+errString+"]"); System.out.println("------Error string after DN save--->>["+errString+"]");
...@@ -464,56 +482,122 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -464,56 +482,122 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
System.out.println("Error String on DB Confirmation: "+errString); System.out.println("Error String on DB Confirmation: "+errString);
if((errString != null ) && errString.indexOf("CONFSUCCES") > -1) if((errString != null ) && errString.indexOf("CONFSUCCES") > -1)
{ {
int count=checkPODDoneAlready(conn,invoiceId); int cnt=insertDataInPodTrace(conn1, invoiceId, podC.xmlStringAll, schemeMap, partialMap,"Y");
if(count > 0){
continue;
}else if(count < 0){
return "Error";
}
noOfInvoicePrc++; noOfInvoicePrc++;
confList.add(invoiceId); if(noOfInvoicePrc==totalInvoice){
System.out.println("noOfInvoicePrc----------------"+noOfInvoicePrc); errCode="VTPRCCSF";
if(noOfInvoicePrc==totalInvoice) errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
return "Success"; return errString;
else{ }
System.out.println("in continue----------------"); if(cnt > 0){
continue; conn1.commit();
} }
conn.commit();
/*errCode="VTPRCCSF";
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
return errString; */
//return "Success"; //return "Success";
}else }else{
return "Error"; conn.rollback();
}else{ int cnt=insertDataInPodTrace(conn1, invoiceId, podC.xmlStringAll, schemeMap, partialMap,"N");
//itmdbAccess.getErrorString("", "VTNCONFT", "", "", conn); if(cnt > 1)
return "Error"; conn1.commit();
errString=newErrorMessage(errString, invoiceId);
return errString;
}
}else{
conn.rollback();
int cnt=insertDataInPodTrace(conn1, invoiceId, podC.xmlStringAll, schemeMap, partialMap,"N");
if(cnt > 1)
conn1.commit();
errString=newErrorMessage(errString, invoiceId);
return errString;
}
}else {// end detail3AmtT > 0 condition
System.out.println("Debit note gennerated for Rs.0- Invoice ID----->> ["+invoiceId+"]");
} }
} //end invoice id for loop } //end invoice id for loop
System.out.println("invoice id confirmed-------->>"+confList); }else{
errCode="VTDNFFP"; //No data found for processing
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
return errString;
}
}catch(Exception e) }catch(Exception e)
{ {
System.out.println("Exception : "); System.out.println("Exception : ");
e.printStackTrace(); e.printStackTrace();
return "Error"; return "Error";
} }
finally{
if(conn1!=null){
try{
conn1.close();
conn1=null;
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
return errString; return errString;
} }
private int checkPODDoneAlready (Connection conn,String invoiceIdL) private int checkPODDoneAlready (Connection conn,String invoiceIdL)
{ {
ResultSet rs=null; ResultSet rs=null,rs1=null;
PreparedStatement pstmt=null; PreparedStatement pstmt=null,pstmt1=null;
String sql=""; String sql="",remarks="",invID="",itemCodeMisc="",itemCodeInv;
int count=0; double invQty=0,miscQty=0;
int count=0,lineInvT=0,lineMiscInvT=0;
try{ try{
sql="select count(*) from podtrace where invoice_id = ?"; sql="SELECT d.item_code,d.quantity,h.remarks,d.line_no__invtrace FROM misc_drcr_rcp h, misc_drcr_rdet d "
pstmt=conn.prepareStatement(sql); + "where remarks like 'Auto%POD%' and h.tran_id=d.tran_id";
pstmt.setString(1, invoiceIdL); //sql="SELECT remarks FROM misc_drcr_rcp where remarks like 'Auto%POD%'";
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
if(rs.next()){ while(rs.next()){
count=rs.getInt(1); itemCodeMisc=rs.getString(1);
miscQty=rs.getDouble(2);
remarks=rs.getString(3).trim();
lineMiscInvT=rs.getInt(4);
itemCodeMisc=itemCodeMisc==null ? "" :itemCodeMisc.trim();
invID=remarks.substring(46, remarks.length());
System.out.println("Invoice id after subString----->>["+invID+"]");
if(invID.equalsIgnoreCase(invoiceIdL.trim())){
sql="select invoice_id,inv_line_no,item_code,quantity from invoice_trace where invoice_id = ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, invID.trim());
rs1=pstmt1.executeQuery();
while(rs1.next()){
lineInvT=rs1.getInt(2);
itemCodeInv=rs1.getString(3);
invQty=rs1.getDouble(4);
itemCodeInv=itemCodeInv==null ? "" :itemCodeInv.trim();
System.out.println("itemCodeMisc--->>["+itemCodeMisc+" itemCodeInv-->>["+itemCodeInv+"]");
System.out.println("lineMiscInvT--->>["+lineMiscInvT+" lineInvT-->>["+lineInvT+"]");
if(itemCodeMisc.equalsIgnoreCase(itemCodeInv) && lineMiscInvT == lineInvT){
if(invQty == miscQty){
return 1;
}
}
}
}
} }
rs.close(); rs.close();
rs=null; rs=null;
...@@ -563,7 +647,29 @@ private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn) ...@@ -563,7 +647,29 @@ private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn)
return podNotConfListL; return podNotConfListL;
} }
private int updatePodTraceSuccess(Connection conn,String success,String invID)
{
String sql="";
int lineNo=0,count=0;
double dbAmt=0.0,debitNoteHeaderL=0;
PreparedStatement pstmt=null;
try{
sql="update podtrace set success = ? where invoice_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,success);
pstmt.setString(2, invID);
count=pstmt.executeUpdate();
}//end try
catch(Exception e){
e.printStackTrace();
return 0;
}
System.out.println("update updatePodTraceSuccess@@@----->>["+count+"]");
return count;
}
private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> inv45dayListL) private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> inv45dayListL)
{ {
System.out.println("--------------checkPODDoneOrNot method------------------"); System.out.println("--------------checkPODDoneOrNot method------------------");
...@@ -599,7 +705,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> ...@@ -599,7 +705,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
pstmt=null; pstmt=null;
if(inv45dayListL.size() > 0 && podDoneInvIDList.size() > 0){ if(inv45dayListL.size() > 0 && podDoneInvIDList.size() > 0){
System.out.println("---both arraylist contains elements-----------"); System.out.println("---both arraylist contains elements-----------");
for (String invId : inv45dayListL) { //required to check if invoice id partially done in POD HDR for (String invId : inv45dayListL) {
if(!(podDoneInvIDList.contains(invId))){ if(!(podDoneInvIDList.contains(invId))){
podProcessInvIDListL.add(invId); podProcessInvIDListL.add(invId);
...@@ -608,6 +714,8 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> ...@@ -608,6 +714,8 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
} }
}else{
return inv45dayListL;
} }
System.out.println("podProcessInvIDList----->>[["+podProcessInvIDListL+"]"); System.out.println("podProcessInvIDList----->>[["+podProcessInvIDListL+"]");
...@@ -743,58 +851,216 @@ private Map<String,Double> schemeApply(Connection conn,String invoiceID,String i ...@@ -743,58 +851,216 @@ private Map<String,Double> schemeApply(Connection conn,String invoiceID,String i
} }
return schemeQtyMap; return schemeQtyMap;
} }
private int insertDataInPodTrace(Connection conn,Map<String,String>podTraceMapL) private int insertDataInPodTrace(Connection conn,String invID,String xmlDataAll,Map<String,String> schemeMapL,Map<String,String> partialMapL,String success)
{
PreparedStatement pstmt=null;
ResultSet rs=null;
String sql="",itemCode="",quantity="",rate="",amount="",scheme="",partial="",lineNoS="";
int count=0;
long tranID=0;
invID=invID==null ? "" :invID.trim();
try{
//DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
//DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = new ValidatorEJB ().parseString(xmlDataAll);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("Detail2");
System.out.println("in continue----------------"+nList.getLength());
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
itemCode=eElement.getElementsByTagName("item_code").item(0).getTextContent();
quantity=eElement.getElementsByTagName("quantity").item(0).getTextContent();
rate=eElement.getElementsByTagName("rate").item(0).getTextContent();
amount=eElement.getElementsByTagName("amount").item(0).getTextContent();
lineNoS=eElement.getElementsByTagName("line_no").item(0).getTextContent();
scheme=schemeMapL.get(invID+","+itemCode.trim());
partial=partialMapL.get(invID+","+itemCode.trim());
System.out.println("scheme in insert pod trace---->>["+scheme+"]");
sql="select tran_id from podtrace order by tran_id DESC";
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
if(rs.next()){
tranID=Long.parseLong(rs.getString(1).trim());
}else{
tranID=10000;
}
rs.close();rs=null;
pstmt.close();
pstmt=null;
sql="insert into podtrace (tran_id,line_no,tran_date,invoice_id,site_code,item_code,inv_type,db_qty,"
+ "db_rate,debit_note_amt,partial,scheme,chg_date,chg_user,chg_term,success) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, Long.toString(++tranID));
pstmt.setInt(2, Integer.parseInt(lineNoS));
pstmt.setTimestamp(3, new java.sql.Timestamp(new java.util.Date().getTime()) );
pstmt.setString(4, invID);
pstmt.setString(5, siteCodeG);
pstmt.setString(6,itemCode);
pstmt.setString(7, invTypeG);
pstmt.setDouble(8, Double.parseDouble(quantity));
pstmt.setDouble(9, Double.parseDouble(rate));
pstmt.setDouble(10, Double.parseDouble(amount));
pstmt.setString(11, partial);
pstmt.setString(12, scheme);
pstmt.setTimestamp(13, new java.sql.Timestamp(new java.util.Date().getTime()) );
pstmt.setString(14, "BASE");
pstmt.setString(15, "System");
pstmt.setString(16, success);
count=pstmt.executeUpdate();
pstmt.close();
}//end if
} //end for
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in insertDataInPodTrace method----");
return -1;
}
return count;
}
private ArrayList<String> getDoneInvoiceIDFromPodTrace(Connection conn)
{ {
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ResultSet rs=null;
String sql=""; String sql="";
int count=0; HashSet<String> unqInvID=new HashSet <String>();
long tranID=0; ArrayList<String> InvIDList=new ArrayList <String>();
try{ try{
sql="select tran_id from podtrace order by tran_id DESC"; sql="select invoice_id from podtrace where success = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y");
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
if(rs.next()){ while(rs.next()){
tranID=Long.parseLong(rs.getString(1).trim()); InvIDList.add(rs.getString(1).trim());
}else{
tranID=10000;
} }
rs.close();rs=null; if(InvIDList.size() > 0){
pstmt.close(); unqInvID.addAll(InvIDList);
pstmt=null; InvIDList.clear();
sql="insert into podtrace (tran_id,line_no,tran_date,invoice_id,site_code,item_code,inv_type,db_qty," InvIDList.addAll(unqInvID);
+ "db_rate,debit_note_amt,partial,scheme,chg_date,chg_user,chg_term) " }
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; }
catch(Exception e)
{
e.printStackTrace();
}
return InvIDList;
}
private ArrayList<String> getDoneInvoiceIDFromMiscDrCrRcp(Connection conn)
{
PreparedStatement pstmt=null,pstmt1=null;
ResultSet rs=null,rs1=null;
String sql="",remarks="",subInvId="";
double sumQuantityMisc=0,sumQuantityInv=0;
HashSet<String> unqInvID=new HashSet <String>();
ArrayList<String> tranIDList=new ArrayList <String>();
ArrayList<String> InvIDList=new ArrayList <String>();
ArrayList<String> InvIDFinalList=new ArrayList <String>();
try{
sql="select tran_id,remarks from misc_drcr_rcp where remarks like 'Auto%POD%'";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, Long.toString(++tranID));
pstmt.setInt(2, Integer.parseInt(podTraceMapL.get("line_no")));
pstmt.setTimestamp(3, new java.sql.Timestamp(new java.util.Date().getTime()) );
pstmt.setString(4, podTraceMapL.get("inv_id"));
pstmt.setString(5, podTraceMapL.get("site_code"));
pstmt.setString(6, podTraceMapL.get("item_code"));
pstmt.setString(7, podTraceMapL.get("inv_type"));
pstmt.setDouble(8, Double.parseDouble(podTraceMapL.get("db_qty")));
pstmt.setDouble(9, Double.parseDouble(podTraceMapL.get("db_rate")));
pstmt.setDouble(10, Double.parseDouble(podTraceMapL.get("db_amount")));
pstmt.setString(11, podTraceMapL.get("partial"));
pstmt.setString(12, podTraceMapL.get("scheme"));
pstmt.setTimestamp(13, new java.sql.Timestamp(new java.util.Date().getTime()) );
pstmt.setString(14, "BASE");
pstmt.setString(15, "System");
count=pstmt.executeUpdate();
pstmt.close();
rs=pstmt.executeQuery();
while(rs.next()){
tranIDList.add(rs.getString(1));
remarks=rs.getString(2);
subInvId=remarks.substring(46, remarks.length());
InvIDList.add(subInvId);
}
if(InvIDList.size() > 0){
unqInvID.addAll(InvIDList);
InvIDList.clear();
InvIDList.addAll(unqInvID);
}
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception in insertDataInPodTrace method----");
return -1;
} }
return count; return InvIDList;
}
private String newErrorMessage(String errString,String invid)
{
System.out.println("In newErrorMessage method--->>["+errString+"]");
String trace="",message="",desc="",redirect="",domID="";
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
StringBuffer newStr=new StringBuffer();
try{
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = new ValidatorEJB ().parseString(errString);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList parentNodeList = doc.getElementsByTagName("error");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
System.out.println("childNodeList length----------------"+parentNodeList.getLength());
for (int i = 0; i < childNodeList.getLength(); i++) {
childNode = childNodeList.item(i);
if(childNode ==null){
System.out.println("child Node is null..............");
}
// System.out.println("ChildNode Name--->>"+childNode.getFirstChild().getTextContent());
if ("message".equalsIgnoreCase(childNode.getNodeName())) {
message=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("description".equalsIgnoreCase(childNode.getNodeName())) {
desc=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("trace".equalsIgnoreCase(childNode.getNodeName())) {
trace=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("redirect".equalsIgnoreCase(childNode.getNodeName())) {
redirect=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("detailDomId".equalsIgnoreCase(childNode.getNodeName())) {
domID=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
}
trace=trace+ " Invoice Id : "+invid;
newStr.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
+ "<Errors><error column_name=\"acct_code\" id=\"VMACCT1\" type=\"E\">"
+ "<message><![CDATA["+message+"]]></message>"
+ "<description><![CDATA["+desc+"]]></description>");
newStr.append("<trace><![CDATA["+trace +"]]></trace>");
newStr.append("<redirect><![CDATA["+redirect+"]]></redirect>");
newStr.append("<detailDomId><![CDATA["+domID+"]]></detailDomId>");
newStr.append("</error></Errors>");
System.out.println("Final xml in newErrorMessage--->>[["+newStr.toString()+"]]");
}
catch(Exception e){
e.printStackTrace();
}
return newStr.toString();
} }
public double getPriceListRate(String priceList, java.util.Date tranDate, String itemCode, String lotNo, String type, Connection connectionObject) throws RemoteException,ITMException public double getPriceListRate(String priceList, java.util.Date tranDate, String itemCode, String lotNo, String type, Connection connectionObject) throws RemoteException,ITMException
{ {
......
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