Commit e18cf75c authored by dpawar's avatar dpawar

confirmed transaction saved in podtrace table


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94209 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 061e3de2
...@@ -4,6 +4,7 @@ import ibase.system.config.ConnDriver; ...@@ -4,6 +4,7 @@ import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB; import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
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;
...@@ -15,9 +16,15 @@ import java.sql.SQLException; ...@@ -15,9 +16,15 @@ import java.sql.SQLException;
import java.sql.Statement; 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.Map;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import com.sun.jmx.snmp.Timestamp;
@Stateless @Stateless
public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote
{ {
...@@ -75,7 +82,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -75,7 +82,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
ConnDriver connDriver = null; ConnDriver connDriver = null;
GenericUtility genericUtility = null; GenericUtility genericUtility = null;
ProofOfDelivery podObject=null; ProofOfDelivery podObject=null;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmdbAccess = null;
ValidatorEJB vdt=null; ValidatorEJB vdt=null;
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ResultSet rs=null;
...@@ -85,7 +92,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -85,7 +92,7 @@ public String process(Document dom, Document dom2, String windowName, String xtr
String sql="",invoiceId="",priceList="",currCode=""; String sql="",invoiceId="",priceList="",currCode="";
try{ try{
genericUtility = GenericUtility.getInstance(); genericUtility = GenericUtility.getInstance();
itmDBAccessEJB = new ITMDBAccessEJB(); itmdbAccess=new ITMDBAccessEJB();
podObject=ProofOfDelivery.getInstance(); podObject=ProofOfDelivery.getInstance();
vdt=new ValidatorEJB(); vdt=new ValidatorEJB();
connDriver = new ConnDriver(); connDriver = new ConnDriver();
...@@ -107,64 +114,64 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -107,64 +114,64 @@ public String process(Document dom, Document dom2, String windowName, String xtr
System.out.println("invType--->>["+invType+"]"); System.out.println("invType--->>["+invType+"]");
//Validation for Site code //Validation for Site code
if (siteCode.length() == 0 ) if (siteCode.length() == 0 ){
{
errCode = "VTSITECNE"; errCode = "VTSITECNE";
errorString = vdt.getErrorString("site_code",errCode,userId); errorString = vdt.getErrorString("site_code",errCode,userId);
return errorString; return errorString;
}else }else{
{
cnt=podObject.getDBRowCount(conn,"site","site_code",siteCode); cnt=podObject.getDBRowCount(conn,"site","site_code",siteCode);
if(cnt == 0) if(cnt == 0){
{
System.out.println("site_code not exist validation fire"); System.out.println("site_code not exist validation fire");
errCode = "VTSITENEX"; errCode = "VTSITENEX";
errorString = vdt.getErrorString("site_code",errCode,userId); errorString = vdt.getErrorString("site_code",errCode,userId);
return errorString; return errorString;
} }
} }
//Validation for Customer Code From //Validation for Customer Code From
if (custCodeFrm.length() == 0 ) if (custCodeFrm.length() == 0 ){
{
errCode = "VTCUSTCNE"; errCode = "VTCUSTCNE";
errorString = vdt.getErrorString("cust_code_from",errCode,userId); errorString = vdt.getErrorString("cust_code_from",errCode,userId);
return errorString; return errorString;
}else }else{
{
cnt=podObject.getDBRowCount(conn,"customer","cust_code",custCodeFrm); cnt=podObject.getDBRowCount(conn,"customer","cust_code",custCodeFrm);
if(cnt == 0) if(cnt == 0){
{
System.out.println("custCodeFrom not exist validation fire"); System.out.println("custCodeFrom not exist validation fire");
errCode = "VTCUSTNEX"; errCode = "VTCUSTNEX";
errorString = vdt.getErrorString("cust_code_from",errCode,userId); errorString = vdt.getErrorString("cust_code_from",errCode,userId);
return errorString; return errorString;
} }
} }
//Validation for Customer Code To //Validation for Customer Code To
if (custCodeTo.length() == 0 ) if (custCodeTo.length() == 0 ){
{
errCode = "VTCUSTCNE"; errCode = "VTCUSTCNE";
errorString = vdt.getErrorString("cust_code_to",errCode,userId); errorString = vdt.getErrorString("cust_code_to",errCode,userId);
return errorString; return errorString;
}else }else{
{
cnt=podObject.getDBRowCount(conn,"customer","cust_code",custCodeTo); cnt=podObject.getDBRowCount(conn,"customer","cust_code",custCodeTo);
if(cnt == 0) if(cnt == 0){
{
System.out.println("custCodeTo not exist validation fire"); System.out.println("custCodeTo not exist validation fire");
errCode = "VTCUSTNEX"; errCode = "VTCUSTNEX";
errorString = vdt.getErrorString("cust_code_to",errCode,userId); errorString = vdt.getErrorString("cust_code_to",errCode,userId);
return errorString; return errorString;
} }
}
//Validation for invoice type. only DM or IS invoice type allowed.
if(invType.length() == 0){
errCode = "VTINVTNN";
errorString = vdt.getErrorString("inv_type",errCode,userId);
return errorString;
}else{
if(!("DM".equalsIgnoreCase(invType) || "IS".equalsIgnoreCase(invType))){
errCode = "VTINVTI";
errorString = vdt.getErrorString("inv_type",errCode,userId);
return errorString;
}
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(custCodeFrm.length() > 0 && custCodeTo.length() > 0 && siteCode.length() > 0){ if(custCodeFrm.length() > 0 && custCodeTo.length() > 0 && siteCode.length() > 0){
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 > 517";
...@@ -174,12 +181,10 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -174,12 +181,10 @@ public String process(Document dom, Document dom2, String windowName, String xtr
pstmt.setString(3, siteCode); pstmt.setString(3, siteCode);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while(rs.next()) while(rs.next()){
{
invoiceId=rs.getString(1); invoiceId=rs.getString(1);
invoiceId=invoiceId==null ? "" :invoiceId.trim(); invoiceId=invoiceId==null ? "" :invoiceId.trim();
inv45dayList.add(invoiceId); inv45dayList.add(invoiceId);
} }
rs.close(); rs.close();
rs=null; rs=null;
...@@ -188,19 +193,23 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -188,19 +193,23 @@ public String process(Document dom, Document dom2, String windowName, String xtr
System.out.println("Size of arrayList inv45dayList----->>["+inv45dayList.size()+"]"); System.out.println("Size of arrayList inv45dayList----->>["+inv45dayList.size()+"]");
podProcessInvIDList=getDoneInvoiceIdHDR( conn, inv45dayList); 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";
errorString =itmdbAccess.getErrorString("", errCode, "", "", conn);
return errorString;
} }
System.out.println("podProcessInvIDList---->>["+podProcessInvIDList+"]"); System.out.println("podProcessInvIDList---->>["+podProcessInvIDList+"]");
System.out.println("Size of podProcessInvIDList---->>["+podProcessInvIDList.size()+"]"); System.out.println("Size of podProcessInvIDList---->>["+podProcessInvIDList.size()+"]");
podNotConfList=getNotConfirmedInvIdFromHdr(conn); podNotConfList=getNotConfirmedInvIdFromHdr(conn);
if(podNotConfList.contains("Error")) if(podNotConfList.contains("Error")){
{ errCode="VTPRCNCP";
//handle error if array list contain error. errorString =itmdbAccess.getErrorString("", errCode, "", "", conn);
return errorString;
} }
System.out.println("podNotConfList---->>["+podNotConfList+"]"); System.out.println("podNotConfList---->>["+podNotConfList+"]");
System.out.println("Size of podNotConfList---->>["+podNotConfList.size()+"]"); System.out.println("Size of podNotConfList---->>["+podNotConfList.size()+"]");
//check in podNotConfList if invoice id in podProcessInvIDList present or not. //check in podNotConfList if invoice id in podProcessInvIDList present or not.
//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)
...@@ -215,21 +224,52 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -215,21 +224,52 @@ public String process(Document dom, Document dom2, String windowName, String xtr
} }
} }
podProcessInvIDList.clear(); podProcessInvIDList.clear(); //remove on final----------------------------7826464876----------------
podProcessInvIDList.add("618ID00040");
podProcessInvIDList.add("618ID00032");
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+"]");
priceList=podObject.getNameOrDescrForCode(conn, "site", "price_list", "site_code", siteCode); priceList=podObject.getNameOrDescrForCode(conn, "site", "price_list", "site_code", siteCode);
priceList=priceList==null ? "" :priceList.trim(); priceList=priceList==null ? "" :priceList.trim();
System.out.println("priceList----->>["+priceList+"]"); System.out.println("priceList----->>["+priceList+"]");
if(priceList.length() <= 0){
errCode="VTPRCLND"; //Price list not define in site master.
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
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.
String str=schemeApply(conn, podProcessInvIDList,priceList,xtraParams,siteCode); errorString=generateDebitNote(conn, podProcessInvIDList,priceList,xtraParams,siteCode,invType);
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
...@@ -255,24 +295,33 @@ public String process(Document dom, Document dom2, String windowName, String xtr ...@@ -255,24 +295,33 @@ public String process(Document dom, Document dom2, String windowName, String xtr
} }
private String schemeApply(Connection conn,ArrayList<String> podProcessInvIDListL,String priceListL,String xtraParams,String siteCode) private String generateDebitNote(Connection conn,ArrayList<String> podProcessInvIDListL,String priceListL,String xtraParams,String siteCode,String invType)
{ {
ResultSet rs=null; ResultSet rs=null;
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ProofOfDelivery pod=null; ProofOfDelivery pod=null;
ProofOfDeliveryConf podC=null; ProofOfDeliveryConf podC=null;
String sql="",lotNo="",lotSl="",itemCode="",itemCodeOrd="",itemActive="",detail2xmlString=""; Map<String,String> invoiceDetailsMap=null;
HashMap<String,String> podTraceMap=new HashMap();
Map<String,Double> schemeQty=null;
ArrayList<String> confList=new ArrayList();
String sql="",lotNo="",lotSl="",itemCode="",itemCodeOrd="",itemActive="",detail2xmlString="",errString="";
String custCode="",currCode="",partial="N",QtyInvTrace="",scheme="N";
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; double debitNoteAmtHdr=0,ExchRate=0,actualRate=0,chargQty=0,freeQty=0,netPTS=0;
int lineNotrace=0,lineNo=0; int lineNotrace=0,lineNo=0,noOfInvoicePrc=0,totalInvoice=0;
pod=ProofOfDelivery.getInstance(); pod=ProofOfDelivery.getInstance();
podC=ProofOfDeliveryConf.getInstance(); podC=ProofOfDeliveryConf.getInstance();
try{ try{
System.out.println("priceListL------>>["+priceListL+"]"); System.out.println("priceListL123------>>["+priceListL+"]");
totalInvoice=podProcessInvIDListL.size();
System.out.println("total invoice for process------>>["+totalInvoice+"]");
for(String invoiceId :podProcessInvIDListL) for(String invoiceId :podProcessInvIDListL)
{ {
detail2xmlString="";
sql="select rate,quantity,lot_no,lot_sl,item_code,inv_line_no,discount,item_code__ord " + lineNo=0;
System.out.println("invoice ID in for loop------->>["+invoiceId+"]");
sql="select rate,quantity,lot_no,lot_sl,item_code,inv_line_no,discount,item_code__ord,invoice_id " +
"from invoice_trace where invoice_id = ? order by inv_line_no"; "from invoice_trace where invoice_id = ? order by inv_line_no";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invoiceId); pstmt.setString(1, invoiceId);
...@@ -293,7 +342,7 @@ private String schemeApply(Connection conn,ArrayList<String> podProcessInvIDList ...@@ -293,7 +342,7 @@ private String schemeApply(Connection conn,ArrayList<String> podProcessInvIDList
lotSl=lotSl==null ? "" :lotSl.trim(); lotSl=lotSl==null ? "" :lotSl.trim();
itemCode=itemCode==null ? "" :itemCode.trim(); itemCode=itemCode==null ? "" :itemCode.trim();
itemCodeOrd=itemCodeOrd==null ? "" :itemCodeOrd.trim(); itemCodeOrd=itemCodeOrd==null ? "" :itemCodeOrd.trim();
QtyInvTrace=Double.toHexString(invQty);
//Discount need discussion -----------------@@@@@-------- //Discount need discussion -----------------@@@@@--------
if(discount > 0) if(discount > 0)
...@@ -301,6 +350,20 @@ private String schemeApply(Connection conn,ArrayList<String> podProcessInvIDList ...@@ -301,6 +350,20 @@ private String schemeApply(Connection conn,ArrayList<String> podProcessInvIDList
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 partially entry exist in POD HDR or not.
//if yes then minus from actual invoice qty.
partial="N";
scheme="N";
if(pod.isPartialyInvoiceChk(conn, invoiceId,"PRC")){
System.out.println("@#@#partial condition found for invoice id----->>["+invoiceId+"]");
System.out.println("Actual inv qty in inv trace---->>["+invQty+"]");
System.out.println("inv. qty done in POD screen---->>["+pod.partialQty+"]");
invQty = invQty - pod.partialQty;
partial="Y";
System.out.println("Actual inv qty---->>["+invQty+"]");
}
//------------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);
...@@ -309,59 +372,161 @@ private String schemeApply(Connection conn,ArrayList<String> podProcessInvIDList ...@@ -309,59 +372,161 @@ private String schemeApply(Connection conn,ArrayList<String> podProcessInvIDList
{ {
return "ITEMNOTACTIVE"; // item code not active return "ITEMNOTACTIVE"; // item code not active
} }
java.util.Date tranDate=new Date();
priceListRate=getPriceListRate(priceListL, tranDate,itemCode,lotNo,"", conn);
System.out.println("priceListRate----->>["+priceListRate+"]");
if(priceListRate <= 0)
{
return "PRICELIST";
}
//check if scheme is apply or not //check if scheme is apply or not
if(isSchemeApply(conn,itemCode)) if(isSchemeApply(conn,itemCode)){
{
//java code if scheme is apply //java code if scheme is apply
System.out.println("-------Scheme is apply -----------"); System.out.println("-------Scheme is apply -----------");
schemeQty=schemeApply(conn,invoiceId,itemCode);
System.out.println("schemeQty map---->>["+schemeQty+"]");
if(schemeQty.size() > 0){
if(schemeQty.get("success") < 0){
return "Error"; // Scheme related error or sql error.
} }
else{ else if(schemeQty.get("success") == 0){
System.out.println("-------Scheme not apply -----------"); return "SCHEME";
if(priceListL.length() <=0)
{
return "PRICELIST"; //priceList not define or zero in site master.
} }
else{ else if(schemeQty.get("success") == 1){
java.util.Date tranDate=new Date(); scheme="Y";
priceListRate=getPriceListRate(priceListL, tranDate,itemCode,lotNo,"", conn); chargQty=schemeQty.get("charge_qty");
System.out.println("priceListRate----->>["+priceListRate+"]"); freeQty=schemeQty.get("free_qty");
if(priceListRate < 0)
{ netPTS=chargQty / (chargQty - freeQty) * priceListRate;
// return error messages
System.out.println("Net PTS rate----->>["+netPTS+"]");
actualRate=netPTS - invRate;
detail3Amt= actualRate * invQty;
lineNo++;
detail2xmlString=detail2xmlString + podC.getDetailsXmlString(conn,invoiceId,lineNotrace,lineNo,actualRate,invQty,lotNo,lotSl,itemCode, detail3Amt);
} }
else }
{ }else{
debitNoteAmtDetail=podC.getDebitNoteAmount(invRate,invQty); System.out.println("-------Scheme not apply -----------");
debitNoteAmtHdr=debitNoteAmtHdr+debitNoteAmtDetail;
detail3Amt= (priceListRate - invRate) * invQty; //debitNoteAmtDetail=podC.getDebitNoteAmount(invRate,invQty);
//debitNoteAmtHdr=debitNoteAmtHdr+debitNoteAmtDetail;
actualRate=priceListRate - invRate;
detail3Amt= actualRate * invQty;
System.out.println("Debit note amount-------->>["+detail3Amt+"]"); System.out.println("Debit note amount-------->>["+detail3Amt+"]");
System.out.println("Actual rate after deducting inv rate-------->>["+detail3Amt+"]");
detail3AmtT=detail3AmtT + detail3Amt; detail3AmtT=detail3AmtT + detail3Amt;
lineNo++; lineNo++;
//detail2xmlString=detail2xmlString + podC.getDetailsXmlString(invoiceId,lineNotrace,lineNo,invRate,invQty,lotNo,lotSl,itemCode, detail3Amt); detail2xmlString=detail2xmlString + podC.getDetailsXmlString(conn,invoiceId,lineNotrace,lineNo,actualRate,invQty,lotNo,lotSl,itemCode, detail3Amt);
} //end isSchemeApply
} //insert into podTrace table entry....
} //end priceListL if 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);
} //end isSchemeApply
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=null;
pstmt.close();
pstmt=null;
System.out.println("Detail2 xml-------->>[["+detail2xmlString+"]");
invoiceDetailsMap=pod.getDetailsFromInvoice(conn, invoiceId);
custCode=invoiceDetailsMap.get("cust_code").toString();
currCode =pod.checkNull(invoiceDetailsMap.get("curr_code"));
ExchRate=Double.parseDouble(invoiceDetailsMap.get("exch_rate"));
errString=podC.genDebitNote("PRC",invoiceId,custCode,siteCode,xtraParams,currCode,ExchRate,detail2xmlString,detail3AmtT,conn);
System.out.println("------Error string after DN save--->>["+errString+"]");
if (errString.indexOf("Success") > -1)
{
System.out.println("Tran id for Misc. debit note------->>["+(podC.debitNoteTranID).trim()+"]");
MiscDrCrRcpConf confDebitNote=new MiscDrCrRcpConf();
errString=confDebitNote.confirm((podC.debitNoteTranID).trim(),xtraParams,"",conn);
System.out.println("Error String on DB Confirmation: "+errString);
if((errString != null ) && errString.indexOf("CONFSUCCES") > -1)
{
int count=checkPODDoneAlready(conn,invoiceId);
if(count > 0){
continue;
}else if(count < 0){
return "Error";
}
noOfInvoicePrc++;
confList.add(invoiceId);
System.out.println("noOfInvoicePrc----------------"+noOfInvoicePrc);
if(noOfInvoicePrc==totalInvoice)
return "Success";
else{
System.out.println("in continue----------------");
continue;
}
//return "Success";
}else
return "Error";
}else{
//itmdbAccess.getErrorString("", "VTNCONFT", "", "", conn);
return "Error";
}
System.out.println("Final detail2xmlString----->>["+detail2xmlString+"]");
System.out.println("Final debitNoteAmtHdr---------->> : "+debitNoteAmtHdr);
System.out.println("Final detail3AmtT in debit note table---------->> : "+detail3AmtT);
//errString=genDebitNote(tranId,invoiceId,custCode,siteCode,xtraParams,0,currCode,ExchRate,detail2xmlString,debitNoteAmtHdr,detail3AmtT,conn);
} //end invoice id for loop } //end invoice id for loop
System.out.println("invoice id confirmed-------->>"+confList);
}catch(Exception e) }catch(Exception e)
{ {
System.out.println("Exception : "); System.out.println("Exception : ");
e.printStackTrace(); e.printStackTrace();
return "Error";
} }
return ""; return errString;
}
private int checkPODDoneAlready (Connection conn,String invoiceIdL)
{
ResultSet rs=null;
PreparedStatement pstmt=null;
String sql="";
int count=0;
try{
sql="select count(*) from podtrace where invoice_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invoiceIdL);
rs=pstmt.executeQuery();
if(rs.next()){
count=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
catch(Exception e){
System.out.println("----Exception in checkPODDoneAlready----");
e.printStackTrace();
return -1;
}
return count;
} }
// Return array list whoes invoice id not confirmed in spl_sales_por_hdr table. // Return array list whoes invoice id not confirmed in spl_sales_por_hdr table.
private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn) private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn)
...@@ -416,6 +581,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> ...@@ -416,6 +581,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y"); pstmt.setString(1, "Y");
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
while(rs.next()) while(rs.next())
{ {
tranIdL=rs.getString(1); tranIdL=rs.getString(1);
...@@ -433,7 +599,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> ...@@ -433,7 +599,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) { for (String invId : inv45dayListL) { //required to check if invoice id partially done in POD HDR
if(!(podDoneInvIDList.contains(invId))){ if(!(podDoneInvIDList.contains(invId))){
podProcessInvIDListL.add(invId); podProcessInvIDListL.add(invId);
...@@ -511,6 +677,125 @@ private boolean isSchemeApply(Connection conn,String itemCodeL) ...@@ -511,6 +677,125 @@ private boolean isSchemeApply(Connection conn,String itemCodeL)
return false; return false;
} }
private Map<String,Double> schemeApply(Connection conn,String invoiceID,String itemCode)
{
ResultSet rs=null;
PreparedStatement pstmt=null;
HashMap <String,Double>schemeQtyMap=new HashMap<String,Double>();
String sql="",nature="";
int count=0;
double quantity=0;
try{
sql="select count(*) from bomdet where item_code= ? and eff_from <= sysdate and "
+ "valid_upto >= sysdate order by nature";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs=pstmt.executeQuery();
if(rs.next()){
count=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
if(count > 0){
sql="select qty_per,nature from bomdet where item_code= ? and eff_from <= sysdate and "
+ "valid_upto >= sysdate order by nature";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs=pstmt.executeQuery();
while(rs.next()){
quantity=rs.getDouble(1);
nature=rs.getString(2);
if("C".equalsIgnoreCase(nature.trim())){
schemeQtyMap.put("charge_qty", quantity);
System.out.println("charge qty added in map------>>["+schemeQtyMap.get("charge_qty")+"]");
}
if("F".equalsIgnoreCase(nature.trim())){
schemeQtyMap.put("free_qty", quantity);
System.out.println("free qty added in map------>>["+schemeQtyMap.get("free_qty")+"]");
}
} //end while
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}else{
System.out.println("----data not found in bomdet---------");
schemeQtyMap.put("success", new Double(0));
}
schemeQtyMap.put("success", new Double(1));
}
catch(Exception e)
{
System.out.println("Exception in scheme apply ---------");
e.printStackTrace();
schemeQtyMap.put("success", new Double(-1));
return schemeQtyMap;
}
return schemeQtyMap;
}
private int insertDataInPodTrace(Connection conn,Map<String,String>podTraceMapL)
{
PreparedStatement pstmt=null;
ResultSet rs=null;
String sql="";
int count=0;
long tranID=0;
try{
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) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
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();
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in insertDataInPodTrace method----");
return -1;
}
return count;
}
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
{ {
double rate = 0; double rate = 0;
...@@ -579,7 +864,7 @@ public double getPriceListRate(String priceList, java.util.Date tranDate, String ...@@ -579,7 +864,7 @@ public double getPriceListRate(String priceList, java.util.Date tranDate, String
} }
catch(SQLException ie) catch(SQLException ie)
{ {
System.out.println("Exception: DistDiscountEJB: pickRate: type D: ==>"+ie); System.out.println("Exception: PODProcess: getPriceListRate: type D: ==>"+ie);
ie.printStackTrace(); ie.printStackTrace();
return -1; return -1;
} }
...@@ -615,12 +900,7 @@ public double getPriceListRate(String priceList, java.util.Date tranDate, String ...@@ -615,12 +900,7 @@ public double getPriceListRate(String priceList, java.util.Date tranDate, String
} }
else if (type.equalsIgnoreCase("I")) // Inventory else if (type.equalsIgnoreCase("I")) // Inventory
{ {
/* ------------------Code not transferred, it's calling an external function
siteCode =
locCode =
lotNo =
lotSl =
-------------------*/
rate = 0; rate = 0;
// To check is lot no is null or not and fetch accordingly // To check is lot no is null or not and fetch accordingly
if (lotSl.trim().length() == 0 || lotSl.length() == 0) if (lotSl.trim().length() == 0 || lotSl.length() == 0)
......
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