Commit f7f3fad6 authored by dpawar's avatar dpawar

update java source as per new requirement


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93569 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9e26a804
...@@ -134,26 +134,26 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -134,26 +134,26 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
} }
status=getNameOrDescrForCode(conn, "spl_sales_por_hdr", "wf_status", "invoice_id", invoiceID); status=getNameOrDescrForCode(conn, "spl_sales_por_hdr", "wf_status", "invoice_id", invoiceID);
status=status==null ? "" : status.trim(); status=status==null ? "" : status.trim();
System.out.println("Status for reject ---->>["+status+"]"); System.out.println("Status for reject ---->>$$$$["+status+"]");
if (!(editFlag.equals("E"))) if (!(editFlag.equals("E")))
{ {
if(!(status.equals("R"))) if(!(status.equals("R")))
{ {
if(isPartialyInvoiceChkHdr(conn,invoiceID))
if(cnt1 > 0 && (!isPartialyInvoiceChk(conn,invoiceID)))
{ {
//system has unconfirmed POD transaction for this invoice. //If POD for invoiceID already exist in spl_sales_por_hdr then show error
System.out.println("--------in partialy check condition--------"); errCode = "VTINVIDAC";
errCode = "VTINVDUNF";
errList.add( errCode ); errList.add( errCode );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
else if(cnt1 > 0 && (!isPartialyInvoiceChk(conn,invoiceID))) else if(isPartialyInvoiceChkHdr(conn,invoiceID))
{ {
//If POD for invoiceID already exist in spl_sales_por_hdr then show error //system has unconfirmed POD transaction for this invoice.
System.out.println("-----IN 121212"); System.out.println("--------Unconfirmed POD transaction--------");
errCode = "VTINVIDAC"; errCode = "VTINVDUNF";
errList.add( errCode ); errList.add( errCode );
errFields.add( childNodeName.toLowerCase() ); errFields.add( childNodeName.toLowerCase() );
} }
...@@ -251,6 +251,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -251,6 +251,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
if(sreturnItemCode.trim().equalsIgnoreCase(itemCodeSret)) if(sreturnItemCode.trim().equalsIgnoreCase(itemCodeSret))
{ {
qtyInvD=qtyInvD - sreturnQuantity; qtyInvD=qtyInvD - sreturnQuantity;
qtyResalD=qtyResalD+getTotalAmountPodQty(conn,str);
System.out.println("Total POD qty with new entry value---------->>"+qtyResalD);
System.out.println("Actual quantity after sales return---->>["+qtyInvD+"]"); System.out.println("Actual quantity after sales return---->>["+qtyInvD+"]");
if(qtyResalD > qtyInvD) //VTSLRETER if(qtyResalD > qtyInvD) //VTSLRETER
{ {
...@@ -267,46 +269,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -267,46 +269,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
{*/ {*/
System.out.println("in isPartialyInvoiceChk condition------------ "); System.out.println("in isPartialyInvoiceChk condition------------ ");
sql1="select tran_id from spl_sales_por_hdr where invoice_id = ?"; sql1="select tran_id from spl_sales_por_hdr where invoice_id = ?";
totalInvQty=getTotalAmountPodQty(conn,str);
try
{
int count =1;
pstmt=conn.prepareStatement(sql1);
pstmt.setString(1, str);
rs = pstmt.executeQuery();
while(rs.next())
{
tranID=rs.getString(1);
tranID=tranID==null ? "" :tranID.trim();
System.out.println("No. of tran id travals [count]---->>: "+count+" TranID : "+tranID);
if(tranID.length() > 0)
{
sql1="";
sql1="select line_no,item_code,quantity__inv,quantity__resale from spl_sales_por_det where tran_id = ?";
pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1, tranID);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
quantyInvD=rs1.getDouble(3);
podInvD=rs1.getDouble(4);
System.out.println("Line no-->["+rs1.getInt(1)+"Item code -->["+rs1.getString(2));
System.out.println("quantyInvD -->["+quantyInvD+"] podInvD-->["+podInvD+"]");
totalInvQty=totalInvQty+podInvD;
}
System.out.println("----------Closing re1 and pstmt1 ----[totalInvQty]------["+totalInvQty+"]");
rs1.close();rs1=null;
pstmt1.close();pstmt1=null;
}
count++;
}
}
catch(Exception e)
{
System.out.println("");
e.printStackTrace();
}
//} //}
/*else /*else
...@@ -314,7 +278,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -314,7 +278,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
System.out.println("in isPartialyInvoiceChk [else] condition------------ "); System.out.println("in isPartialyInvoiceChk [else] condition------------ ");
}*/ }*/
totalInvQty=totalInvQty+qtyResaleD;
System.out.println("qtyInvD---->> "+qtyInvD+" qtyResaleD : "+qtyResaleD); System.out.println("qtyInvD---->> "+qtyInvD+" qtyResaleD : "+qtyResaleD);
System.out.println("Final totalInvQty ----->"+totalInvQty ); System.out.println("Final totalInvQty ----->"+totalInvQty );
if ( totalInvQty > qtyInvD) if ( totalInvQty > qtyInvD)
...@@ -716,24 +680,100 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -716,24 +680,100 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
return count; return count;
} }
/* This function check the partial invoice resell quantity if there is partial then return true
otherwise false. if any invoice not confirmed then return false */ private double getTotalAmountPodQty(Connection conn,String invID)
private boolean isPartialyInvoiceChk(Connection conn,String invID)
{ {
System.out.println("---in method isPartialyInvoiceChk ------invoice ID :["+invID+"]"); System.out.println("---in method getTotalAmountPodQty ------invoice ID :["+invID+"]");
PreparedStatement pstmt2 = null,pstmt1=null ; PreparedStatement pstmt2 = null,pstmt1=null ;
ResultSet rs2 = null,rs1=null; ResultSet rs2 = null,rs1=null;
String sql1="",tranID="",confirmed=""; String sql1="",tranID="",confirmed="";
int lineNo=0,count=1; int lineNo=0,count=1;
invID=invID==null ? "" : invID.trim();
if (invID.length() <= 0) double qtyInv=0.0,podQty=0.0,totalPodQty=0.0;
sql1="select tran_id,confirmed from spl_sales_por_hdr where invoice_id = ? and confirmed = ?";
try
{ {
return false; pstmt2=conn.prepareStatement(sql1);
pstmt2.setString(1, invID);
pstmt2.setString(2, "Y");
rs2 = pstmt2.executeQuery();
while(rs2.next())
{
tranID=rs2.getString(1);
confirmed=rs2.getString(2);
tranID=tranID==null ? "" : tranID.trim();
System.out.println("Confirmed POD---->["+confirmed+"]");
System.out.println("tran id counter ------->"+count);
if(tranID.length() > 0 )
{
count++;
sql1="";
sql1="select line_no,item_code,quantity__inv,quantity__resale from spl_sales_por_det where tran_id = ?";
pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1, tranID);
rs1=pstmt1.executeQuery();
while(rs1.next())
{
lineNo=rs1.getInt(1);
qtyInv=rs1.getDouble(3);
podQty=rs1.getDouble(4);
System.out.println("Line no ---->"+lineNo+ " qtyInv-->>"+qtyInv+" podQty->>"+podQty);
totalPodQty=totalPodQty + podQty;
/*if( podQty < qtyInv)
return true; */
}
System.out.println("Total POD quantity --------->>"+totalPodQty);
rs1.close();rs1=null;
pstmt1.close();pstmt1=null;
}
}
System.out.println("TranID in isPartialyInvoiceChk --->>["+tranID+"] confirmed -->["+confirmed+"]");
/*if (confirmed.equalsIgnoreCase("Y"))
return false;*/
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try{
if (rs2!=null)
{
rs2.close();
rs2=null;
}
if(pstmt2!=null)
{
pstmt2.close();
pstmt2=null;
}
}
catch(Exception e)
{
System.out.println("Exception : In finally block ");
e.printStackTrace();
}
} }
double qtyInv=0.0,podQty=0.0;
sql1="select tran_id,confirmed from spl_sales_por_hdr where invoice_id = ?"; return totalPodQty;
}
private boolean isPartialyInvoiceChk(Connection conn,String invID)
{
System.out.println("---in method isPartialyInvoiceChk ------invoice ID :["+invID+"]");
PreparedStatement pstmt2 = null,pstmt1=null ;
ResultSet rs2 = null,rs1=null;
String sql1="",tranID="",confirmed="";
int lineNo=0,count=1;
double qtyInv=0.0,podQty=0.0,totalPodQty=0.0;
sql1="select tran_id,confirmed from spl_sales_por_hdr where invoice_id = ? order by confirmed";
try try
{ {
pstmt2=conn.prepareStatement(sql1); pstmt2=conn.prepareStatement(sql1);
...@@ -745,7 +785,6 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -745,7 +785,6 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
confirmed=rs2.getString(2); confirmed=rs2.getString(2);
tranID=tranID==null ? "" : tranID.trim(); tranID=tranID==null ? "" : tranID.trim();
confirmed=confirmed==null ? "" :confirmed.trim(); confirmed=confirmed==null ? "" :confirmed.trim();
System.out.println("Confirmed POD---->["+confirmed+"]");
System.out.println("tran id counter ------->"+count); System.out.println("tran id counter ------->"+count);
...@@ -763,12 +802,18 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -763,12 +802,18 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
qtyInv=rs1.getDouble(3); qtyInv=rs1.getDouble(3);
podQty=rs1.getDouble(4); podQty=rs1.getDouble(4);
System.out.println("Line no ---->"+lineNo+ " qtyInv-->>"+qtyInv+" podQty->>"+podQty); System.out.println("Line no ---->"+lineNo+ " qtyInv-->>"+qtyInv+" podQty->>"+podQty);
totalPodQty=totalPodQty + podQty;
if( podQty < qtyInv) if( podQty < qtyInv)
return true; return true;
} }
System.out.println("Total POD quantity --------->>"+totalPodQty);
System.out.println("Confirmed POD---->["+confirmed+"]");
rs1.close();rs1=null; rs1.close();rs1=null;
pstmt1.close();pstmt1=null; pstmt1.close();pstmt1=null;
} }
if (confirmed.equalsIgnoreCase("N"))
return true;
} }
System.out.println("TranID in isPartialyInvoiceChk --->>["+tranID+"] confirmed -->["+confirmed+"]"); System.out.println("TranID in isPartialyInvoiceChk --->>["+tranID+"] confirmed -->["+confirmed+"]");
...@@ -803,8 +848,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -803,8 +848,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
} }
return false; return false;
}
}
private String errorType( Connection conn , String errorCode ) private String errorType( Connection conn , String errorCode )
{ {
...@@ -919,33 +964,10 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -919,33 +964,10 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
return descr; return descr;
} }
private void getStockistPercentage(String allowPercentage,double rateInvoice,double qtyInvoice,double podRate,double podQty)
{
System.out.println("-------- in getDebitNoteAmount method -------------");
double allowPercentageD=0.0,invoiceAmt=0.0,stockistAmt=0.0,actualAllowAmt=0.0,percentageAmtInv=0.0,debitNoteCaclAmount=0.0;
allowPercentage=allowPercentage==null ? "0.0" :allowPercentage;
allowPercentageD=Double.parseDouble(allowPercentage);
invoiceAmt= rateInvoice * qtyInvoice;//10 *100
percentageAmtInv= invoiceAmt * allowPercentageD/100; //1000 * 10/100
actualAllowAmt= invoiceAmt + percentageAmtInv; //1100
System.out.println("percentageAmtInv------>>"+percentageAmtInv);
System.out.println("getDebitNoteAmount -->> actualAllowAmt---------->>"+actualAllowAmt);
stockistAmt= podRate * podQty; //12 * 100 = 1200
if(stockistAmt > actualAllowAmt)
debitNoteCaclAmount= stockistAmt - actualAllowAmt; //1200 -1100 =100
else
debitNoteCaclAmount=0.0;
System.out.println("--------debitNoteCaclAmount------ :Debit note amount "+debitNoteCaclAmount);
/* This function check the partial invoice resell quantity if there is partial then return true
} otherwise false. if any invoice not confirmed then return false */
private boolean isPartialyInvoiceChkHdr(Connection conn,String invID) private boolean isPartialyInvoiceChkHdr(Connection conn,String invID)
{ {
System.out.println("---in method isPartialyInvoiceChkHdr ------invoice ID :["+invID+"]"); System.out.println("---in method isPartialyInvoiceChkHdr ------invoice ID :["+invID+"]");
...@@ -961,7 +983,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -961,7 +983,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
} }
double qtyInv=0.0,podQty=0.0; double qtyInv=0.0,podQty=0.0;
sql1="select tran_id,confirmed from spl_sales_por_hdr where invoice_id = ?"; sql1="select tran_id,confirmed from spl_sales_por_hdr where invoice_id = ? and wf_status <> 'R' order by confirmed";
try try
{ {
pstmt2=conn.prepareStatement(sql1); pstmt2=conn.prepareStatement(sql1);
......
...@@ -83,6 +83,12 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli ...@@ -83,6 +83,12 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
rs.close(); rs.close();
rs = null; rs = null;
} }
if( wfStatus != null && wfStatus.equalsIgnoreCase("O") )
{
//Opened transaction can not confirm
errString = itmdbAccess.getErrorString("", "VTOPCCONF", "", "", conn);
return errString;
}
if( wfStatus != null && wfStatus.equalsIgnoreCase("R") ) if( wfStatus != null && wfStatus.equalsIgnoreCase("R") )
{ {
//Rejected transaction can not confirm //Rejected transaction can not confirm
......
...@@ -59,7 +59,7 @@ public class ProofOfDeliveryReject extends ActionHandlerEJB implements ProofOfDe ...@@ -59,7 +59,7 @@ public class ProofOfDeliveryReject extends ActionHandlerEJB implements ProofOfDe
if( rs.next() ) if( rs.next() )
{ {
confirmed =rs.getString(1)==null ? "N":rs.getString(1); confirmed =rs.getString(1)==null ? "N":rs.getString(1);
wfStatus =rs.getString(1)==null ? "O":rs.getString(1); wfStatus =rs.getString(2)==null ? "O":rs.getString(2);
} }
if( pstmt != null ) if( pstmt != null )
{ {
...@@ -71,6 +71,13 @@ public class ProofOfDeliveryReject extends ActionHandlerEJB implements ProofOfDe ...@@ -71,6 +71,13 @@ public class ProofOfDeliveryReject extends ActionHandlerEJB implements ProofOfDe
rs.close(); rs.close();
rs = null; rs = null;
} }
System.out.println("Transaction Status------->>["+wfStatus+"]");
if( wfStatus != null && wfStatus.equalsIgnoreCase("O") )
{
//Opened Transaction cannot be rejected
errString = itmDBAccess.getErrorString("", "VTOPTCRJ", "", "", conn);
return errString;
}
if( confirmed != null && confirmed.equalsIgnoreCase("Y") ) if( confirmed != null && confirmed.equalsIgnoreCase("Y") )
{ {
//Confirmed Transaction can not be rejected //Confirmed Transaction can not be rejected
...@@ -79,6 +86,7 @@ public class ProofOfDeliveryReject extends ActionHandlerEJB implements ProofOfDe ...@@ -79,6 +86,7 @@ public class ProofOfDeliveryReject extends ActionHandlerEJB implements ProofOfDe
} }
if( wfStatus != null && wfStatus.equalsIgnoreCase("R") ) if( wfStatus != null && wfStatus.equalsIgnoreCase("R") )
{ {
//Already rejected
errString = itmDBAccess.getErrorString("", "VTALREJ", "", "", conn); errString = itmDBAccess.getErrorString("", "VTALREJ", "", "", conn);
return errString; return errString;
} }
......
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