Commit 5e553c01 authored by dpawar's avatar dpawar

added code for partial


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94321 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9b64a5bd
...@@ -21,6 +21,7 @@ import java.util.HashMap; ...@@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
...@@ -37,7 +38,9 @@ import com.sun.jmx.snmp.Timestamp; ...@@ -37,7 +38,9 @@ import com.sun.jmx.snmp.Timestamp;
public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote
{ {
String siteCodeG="",invTypeG=""; String siteCodeG="",invTypeG="";
ArrayList<String> partialInvHDR = new ArrayList <String>();
Map <String,Double>partialInvMap=new HashMap<String,Double>();
//in that map only partial invoice id,line_no_trace added with actual qty less partial qty
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
{ {
...@@ -184,12 +187,13 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -184,12 +187,13 @@ public String process(Document dom, Document dom2, String windowName, String xtr
if(custCodeFrm.length() > 0 && custCodeTo.length() > 0 && siteCode.length() > 0){ if(custCodeFrm.length() > 0 && custCodeTo.length() > 0 && siteCode.length() > 0){
siteCodeG=siteCode; siteCodeG=siteCode;
invTypeG=invType; 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 confirmed = ?"
+ "and sysdate - conf_date > 45"; + "and sysdate - conf_date > 45 and inv_type IN('DM','IS')";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, custCodeFrm); pstmt.setString(1, custCodeFrm);
pstmt.setString(2, custCodeTo); pstmt.setString(2, custCodeTo);
pstmt.setString(3, siteCode); pstmt.setString(3, siteCode);
pstmt.setString(4, "Y");
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while(rs.next()){ while(rs.next()){
...@@ -201,9 +205,10 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -201,9 +205,10 @@ public String process(Document dom, Document dom2, String windowName, String xtr
rs=null; rs=null;
pstmt.close(); pstmt.close();
pstmt=null; pstmt=null;
System.out.println("Size of arrayList inv45dayList----->>["+inv45dayList.size()+"]"); System.out.println("Size of arrayList inv45dayList----->>["+inv45dayList.size()+"]");
podProcessInvIDList=getDoneInvoiceIdHDR( conn, inv45dayList); if(inv45dayList.size() > 0){
System.out.println("Data found for process---------------");
podProcessInvIDList=getDoneInvoiceIdHDR( conn, inv45dayList);
if(podProcessInvIDList.contains("Error")){ if(podProcessInvIDList.contains("Error")){
//handle error if array list contain error. //handle error if array list contain error.
errCode="VTPRCNCP"; errCode="VTPRCNCP";
...@@ -225,36 +230,28 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -225,36 +230,28 @@ public String process(Document dom, Document dom2, String windowName, String xtr
//if present then remove from podProcessInvIDList. //if present then remove from podProcessInvIDList.
if(podNotConfList.size() > 0 && podProcessInvIDList.size() > 0) if(podNotConfList.size() > 0 && podProcessInvIDList.size() > 0)
{ {
for(String id : podNotConfList) Iterator<String> it = podProcessInvIDList.iterator();
{ while (it.hasNext()) {
if(podProcessInvIDList.contains(id)) String id=it.next();
if(podNotConfList.contains(id))
{ {
System.out.println("id removed------>>["+id+"]"); System.out.println("id removed------>>["+id+"]");
it.remove();
podProcessInvIDList.remove(id); podProcessInvIDList.remove(id);
} }
} }
} }
podTraceInvList=getDoneInvoiceIDFromPodTrace(conn);
System.out.println("podTraceInvList---->>["+podTraceInvList+"]");
Iterator<String> it = podProcessInvIDList.iterator();
if(podTraceInvList.size() > 0){
while (it.hasNext()) {
String podPrcId=it.next();
if(podTraceInvList.contains(podPrcId)){
it.remove();
podProcessInvIDList.remove(podPrcId);
}
}
}
System.out.println("podProcessInvIDList-->>["+podProcessInvIDList+"]"); System.out.println("podProcessInvIDList-->>["+podProcessInvIDList+"]");
miscDrCrInvList=getDoneInvoiceIDFromMiscDrCrRcp(conn); miscDrCrInvList=getDoneInvoiceIDFromMiscDrCrRcp(conn);
System.out.println("miscDrCrInvList---->>["+miscDrCrInvList+"]"); System.out.println("miscDrCrInvList123---->>["+miscDrCrInvList+"]");
Iterator<String> it1 = podProcessInvIDList.iterator(); Iterator<String> it1 = podProcessInvIDList.iterator();
if(miscDrCrInvList.size() > 0){ if(miscDrCrInvList.size() > 0){
while (it1.hasNext()) { while (it1.hasNext()) {
String podPrcId=it1.next(); String podPrcId=it1.next();
if(miscDrCrInvList.contains(podPrcId)){ if(miscDrCrInvList.contains(podPrcId) && !(podObject.isPartialyInvoiceChk(conn, podPrcId, "PRC"))){
System.out.println("---in misc arrayList------"); System.out.println("---in misc arrayList------"+podPrcId);
it1.remove(); it1.remove();
podProcessInvIDList.remove(podPrcId); podProcessInvIDList.remove(podPrcId);
...@@ -263,7 +260,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -263,7 +260,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
} }
} }
//podProcessInvIDList.clear(); //podProcessInvIDList.clear();
System.out.println("Final invoice Id ready for debit note---->>["+podProcessInvIDList+"]"); System.out.println("Final invoice Id ready for debit note12---->>["+podProcessInvIDList+"]");
priceList=podObject.getNameOrDescrForCode(conn, "site", "price_list", "site_code", siteCode); priceList=podObject.getNameOrDescrForCode(conn, "site", "price_list", "site_code", siteCode);
...@@ -278,9 +275,14 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -278,9 +275,14 @@ public String process(Document dom, Document dom2, String windowName, String xtr
//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+"]");
}
else{
errCode="VTDNFIN"; //Data not found
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
return errorString;
}// inv45dayList.size end
}
}
}//end try }//end try
catch(Exception e) catch(Exception e)
{ {
...@@ -306,20 +308,21 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -306,20 +308,21 @@ 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,rs1=null;
Connection conn1=null; Connection conn1=null;
PreparedStatement pstmt=null; PreparedStatement pstmt=null,pstmt1=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();
HashMap<String,String> schemeMap=new HashMap(); HashMap<String,String> schemeMap=new HashMap();
HashMap<String,String> partialMap=new HashMap(); HashMap<String,String> partialMap=new HashMap();
Set<String> splitPartial=new HashSet<String>();
Map<String,Double> schemeQty=null; 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",errCode=""; String custCode="",currCode="",partial="N",QtyInvTrace="",scheme="N",errCode="",sreturnTranID="",sql1="";
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,sreturnQuantity=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();
...@@ -327,6 +330,12 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -327,6 +330,12 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
ConnDriver connDriver1 = new ConnDriver(); ConnDriver connDriver1 = new ConnDriver();
try{ try{
conn1 = connDriver1.getConnectDB("DriverITM"); conn1 = connDriver1.getConnectDB("DriverITM");
for(String key : partialInvMap.keySet())
{
String id[]=key.split(":");
splitPartial.add(id[0]);
}
podProcessInvIDListL.addAll(splitPartial);
connDriver1 = null; connDriver1 = null;
System.out.println("priceListL123------>>["+priceListL+"]"); System.out.println("priceListL123------>>["+priceListL+"]");
totalInvoice=podProcessInvIDListL.size(); totalInvoice=podProcessInvIDListL.size();
...@@ -366,6 +375,31 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv ...@@ -366,6 +375,31 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
invRate=invRate - (invRate * discount/100); invRate=invRate - (invRate * discount/100);
System.out.println("Discount for invoice id--->>["+invoiceId+"]"+"inv Rate-->>["+invRate+"]"); System.out.println("Discount for invoice id--->>["+invoiceId+"]"+"inv Rate-->>["+invRate+"]");
} }
//check if any sales return
sreturnTranID=pod.getSalesReturnTranID(conn, "sreturn", "tran_id", "invoice_id", invoiceId);
sreturnTranID=sreturnTranID==null ? "" : sreturnTranID.trim();
if(sreturnTranID.length() > 0)
{
System.out.println("-----Got sales return tran id-----------");
sql1="select item_code,quantity from sreturndet where tran_id = ? and item_code = ? ";
pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1, sreturnTranID);
pstmt1.setString(2, itemCode);
rs1=pstmt1.executeQuery();
if(rs1.next()){
sreturnQuantity=rs.getDouble(2);
}
if(rs1!=null){
rs1.close();
rs1=null;
}
if(pstmt!=null){
pstmt1.close();
pstmt1=null;
}
System.out.println("Sales return------>>["+sreturnQuantity+"]");
invQty=invQty-sreturnQuantity;
}
//check if any partially entry exist in POD HDR or not. //check if any partially entry exist in POD HDR or not.
//if yes then minus from actual invoice qty. //if yes then minus from actual invoice qty.
partial="N"; partial="N";
...@@ -604,7 +638,8 @@ private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn) ...@@ -604,7 +638,8 @@ private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn)
{ {
ArrayList<String> podNotConfListL=new ArrayList<String>(); ArrayList<String> podNotConfListL=new ArrayList<String>();
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ProofOfDelivery podL=ProofOfDelivery.getInstance();
ResultSet rs=null,rs1=null;
String sql="",invID=""; String sql="",invID="";
try try
{ {
...@@ -618,7 +653,7 @@ private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn) ...@@ -618,7 +653,7 @@ private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn)
invID=invID==null ? "" :invID.trim(); invID=invID==null ? "" :invID.trim();
podNotConfListL.add(invID); podNotConfListL.add(invID);
} }
System.out.println("Invoice id Not confirmed in HDR table--->>[["+podNotConfListL+"]]"); System.out.println("Invoice id Not confirmed in HDR table--->>[["+podNotConfListL+"]]");
rs.close(); rs.close();
rs=null; rs=null;
pstmt.close(); pstmt.close();
...@@ -659,8 +694,9 @@ private int updatePodTraceSuccess(Connection conn,String success,String invID) ...@@ -659,8 +694,9 @@ private int updatePodTraceSuccess(Connection conn,String success,String invID)
} }
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("--------------getDoneInvoiceIdHDR method------------------");
System.out.println("ArrayList invIdList--->>[["+inv45dayListL+"]]"); System.out.println("ArrayList invIdList--->>[["+inv45dayListL+"]]");
ProofOfDelivery podObjL=ProofOfDelivery.getInstance();
ArrayList<String> podDoneInvIDList=new ArrayList<String>(); ArrayList<String> podDoneInvIDList=new ArrayList<String>();
ArrayList<String> podProcessInvIDListL=new ArrayList<String>(); ArrayList<String> podProcessInvIDListL=new ArrayList<String>();
...@@ -697,13 +733,26 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> ...@@ -697,13 +733,26 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
if(!(podDoneInvIDList.contains(invId))){ if(!(podDoneInvIDList.contains(invId))){
podProcessInvIDListL.add(invId); podProcessInvIDListL.add(invId);
}else{ //partial check
if(podObjL.isPartialyInvoiceChk(conn, invId, "PRC")){
//partialInvMap.put(invId+":"+podObjL.lineNoTrace, podObjL.remainQty);
}
} }
/*System.out.println("size of Map partialInvMap-->>["+partialInvMap.size()+"]");
if(partialInvMap.size() > 0){
for(String key :partialInvMap.keySet())
{
String invID[]=key.split(":");
podProcessInvIDListL.add(invID[0]);
}
}*/
} }//end for loop
}else{ }else{
return inv45dayListL; return inv45dayListL;
} }
System.out.println("podProcessInvIDList----->>[["+podProcessInvIDListL+"]"); System.out.println("podProcessInvIDList----->>[["+podProcessInvIDListL+"]");
System.out.println("podProcessInvIDList----->>[["+podProcessInvIDListL.size()+"]"); System.out.println("podProcessInvIDList----->>[["+podProcessInvIDListL.size()+"]");
...@@ -735,7 +784,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> ...@@ -735,7 +784,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
e.printStackTrace(); e.printStackTrace();
} }
} }
return podProcessInvIDListL; return inv45dayListL; //podProcessInvIDListL;
} }
private boolean isSchemeApply(Connection conn,String itemCodeL) private boolean isSchemeApply(Connection conn,String itemCodeL)
...@@ -937,6 +986,7 @@ private ArrayList<String> getDoneInvoiceIDFromPodTrace(Connection conn) ...@@ -937,6 +986,7 @@ private ArrayList<String> getDoneInvoiceIDFromPodTrace(Connection conn)
} }
return InvIDList; return InvIDList;
} }
private ArrayList<String> getDoneInvoiceIDFromMiscDrCrRcp(Connection conn) private ArrayList<String> getDoneInvoiceIDFromMiscDrCrRcp(Connection conn)
{ {
PreparedStatement pstmt=null,pstmt1=null; PreparedStatement pstmt=null,pstmt1=null;
...@@ -948,13 +998,14 @@ private ArrayList<String> getDoneInvoiceIDFromMiscDrCrRcp(Connection conn) ...@@ -948,13 +998,14 @@ private ArrayList<String> getDoneInvoiceIDFromMiscDrCrRcp(Connection conn)
ArrayList<String> InvIDList=new ArrayList <String>(); ArrayList<String> InvIDList=new ArrayList <String>();
ArrayList<String> InvIDFinalList=new ArrayList <String>(); ArrayList<String> InvIDFinalList=new ArrayList <String>();
try{ try{
sql="select tran_id,remarks from misc_drcr_rcp where remarks like 'Auto%POD%'"; sql="select tran_id,remarks from misc_drcr_rcp where remarks like 'Auto%POD%' and confirmed = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y");
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while(rs.next()){ while(rs.next()){
tranIDList.add(rs.getString(1)); tranIDList.add(rs.getString(1));
remarks=rs.getString(2); remarks=rs.getString(2) ==null ? "" :rs.getString(2).trim();
subInvId=remarks.substring(46, remarks.length()); subInvId=remarks.substring(46, remarks.length());
InvIDList.add(subInvId); InvIDList.add(subInvId);
......
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