Commit 0898e2b0 authored by dpawar's avatar dpawar

changes in code for pending qty


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95233 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 65da8abd
......@@ -84,7 +84,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
PreparedStatement pstmt;
ResultSet rs=null;
int cnt=0;
int currentFormNo=0;
int currentFormNo=0,miscCount=0;
int childNodeListLength;
ConnDriver connDriver = new ConnDriver();
//ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
......@@ -146,8 +146,15 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
}
status=getNameOrDescrForCode(conn, "spl_sales_por_hdr", "wf_status", "invoice_id", invoiceID);
status=status==null ? "" : status.trim();
System.out.println("Status for reject ---->>$$$$["+status+"]");
System.out.println("Status for reject2 ---->>$$$$["+status+"]");
// check if selected invoice id already generated debit note
if(isRecordPresentInMiscDrCrRcp(conn,invoiceID))
{
errCode = "VTPODARI"; //Proof of Delivery already received for this invoice ID
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
//end check
if (!(editFlag.equals("E")))
{
......@@ -179,6 +186,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
errFields.add( childNodeName.toLowerCase() );
}
}
}
if (childNodeName.equalsIgnoreCase("site_code"))
{
......@@ -870,13 +879,22 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
System.out.println("------------in itm_default--------->");
String confirm="N",wfStatus="O";
String confirm="N",wfStatus="O",loginSite="",siteDescr1="";
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat simpleDateFormatObj = new SimpleDateFormat(genericUtility.getApplDateFormat());
String tranDate = simpleDateFormatObj.format(currentDate.getTime());
valueXmlString.append("<tran_date>").append("<![CDATA[" + tranDate + "]]>").append("</tran_date>");
valueXmlString.append("<confirmed>").append("<![CDATA[" + confirm + "]]>").append("</confirmed>");
valueXmlString.append("<wf_status>").append("<![CDATA[" + wfStatus + "]]>").append("</wf_status>");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginSite=loginSite==null ? "" :loginSite.trim();
System.out.println("loginSite ----->>["+loginSite+"]");
if(loginSite.length() > 0){
siteDescr1=getNameOrDescrForCode(conn, "SITE", "DESCR", "SITE_CODE", loginSite);
}
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr1 + "]]>").append("</site_descr>");
}
if((currentColumn.trim().equalsIgnoreCase("invoice_id")))
......@@ -984,28 +1002,59 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
if (currentColumn.trim().equals("quantity__resale"))
{
System.out.println("-------item chnage quantity__resale-------------");
String rateResale="",podQty="",aprvRate="";
double rateResaleD=0.0,podQtyD=0.0;
double debitNoteAmt=0,aprvRateD=0;
String rateResale="",podQty="",aprvRate="",invQtyS="",pendQtyS="",pendTempS="";
double rateResaleD=0.0,podQtyD=0.0,debitNoteAmt=0,aprvRateD=0,invQtyD=0,
pendQtyD=0,tempQty=0,pendTempD=0;
aprvRate=genericUtility.getColumnValue("aprv_rate",dom);
rateResale=genericUtility.getColumnValue("rate__resale",dom);
podQty=genericUtility.getColumnValue("quantity__resale",dom);
invQtyS=genericUtility.getColumnValue("quantity__inv",dom);
pendQtyS=genericUtility.getColumnValue("pend_qty",dom);
pendTempS=genericUtility.getColumnValue("pend_temp",dom);
rateResaleD=Double.parseDouble(checkSpaceNull(rateResale));
podQtyD=Double.parseDouble(checkSpaceNull(podQty));
aprvRateD=Double.parseDouble(checkSpaceNull(aprvRate));
invQtyD=Double.parseDouble(checkSpaceNull(invQtyS));
pendQtyD=Double.parseDouble(checkSpaceNull(pendQtyS));
pendTempD=Double.parseDouble(checkSpaceNull(pendTempS));
System.out.println("aprvRate ------>>"+aprvRateD);
System.out.println("rateResaleD ------>>"+rateResaleD);
System.out.println("qty resale ------>>"+podQtyD);
System.out.println("Invoice Qty ------>>"+invQtyD);
System.out.println("qty resale(POD) ------>>"+podQtyD);
System.out.println("pending Qty------>>"+pendQtyD);
System.out.println("qty pend_temp ------>>"+pendTempD);
/*tempQty =invQtyD - pendQtyD;// 200 - 80 =120 // 0
tempQty=tempQty + podQtyD;//120 + 30 = 150//120
pendQtyD=invQtyD - tempQty; //200 -150 =50 */
if(pendQtyD > 0){
System.out.println("Pending qty greater than zero..........");
tempQty= invQtyD - pendTempD; //200 -80 =120
tempQty=tempQty + podQtyD; //120 +30 =150
pendQtyD=invQtyD - tempQty; // 200 -150 =50
}else{
System.out.println("Pending qty less than zero..........");
pendQtyD=invQtyD - podQtyD; // 200 -150 =50
}
System.out.println("pendQty ------>>"+pendQtyD);
if(rateResaleD > 0.0 && podQtyD > 0.0)
{
debitNoteAmt=(rateResaleD - aprvRateD) * podQtyD;
}
valueXmlString.append("<pend_qty>").append("<![CDATA["+pendQtyD+"]]>").append("</pend_qty>");
System.out.println("debitNoteAmt ------>>"+debitNoteAmt);
if(debitNoteAmt > 0)
valueXmlString.append("<debit_note_amt>").append("<![CDATA["+debitNoteAmt+"]]>").append("</debit_note_amt>");
......@@ -1643,6 +1692,124 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
return findValue;
}
protected boolean isRecordPresentInMiscDrCrRcp(Connection conn,String invoiceID)
{
ResultSet rs=null,rs1=null;
PreparedStatement pstmt=null,pstmt1=null;
String sql="",itemCodeT="",lotNoT="",lotSlT="",lineNoT="",itemCodeM="",lotNoM="",lotSlM="",lineNoM="";
double quantityT=0,quantityM=0;
int count =0,noOfRecordMatched=0,noOfRecords=0;
try{
sql="select count(*) from invoice_trace where invoice_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
rs=pstmt.executeQuery();
if(rs.next()){
noOfRecords=rs.getInt(1);
}
if(rs!=null){
rs.close();
rs=null;
}
if(pstmt!=null){
pstmt.close();
pstmt=null;
}
System.out.println("NoOfRecords---->>["+noOfRecords+"]");
sql="select sum(quantity),item_code,lot_no,lot_sl,inv_line_no from invoice_trace "
+ "where invoice_id = ? group by item_code,lot_no,lot_sl,inv_line_no";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
rs=pstmt.executeQuery();
while(rs.next()){
count++;
quantityT=rs.getDouble(1);
itemCodeT=rs.getString(2);
lotNoT=rs.getString(3);
lotSlT=rs.getString(4);
lineNoT=rs.getString(5);
itemCodeT=itemCodeT==null ? "" :itemCodeT.trim();
lotNoT=lotNoT==null ? "" :lotNoT.trim();
lotSlT=lotSlT==null ? "" :lotSlT.trim();
lineNoT=lineNoT==null ? "" :lineNoT.trim();
System.out.println("count--------------->>["+count+"]");
System.out.println("itemCodeT-->["+itemCodeT+"] lotNoT->["+lotNoT+"]");
System.out.println("lotSlT-->["+lotSlT+"] lineNoT->["+lineNoT+"]");
//checked in misc_drcr_rcp
sql="select sum(d.quantity) as Quantity,d.item_code,d.lot_no,d.lot_sl,d.line_no__invtrace from misc_drcr_rcp h,misc_drcr_rdet d "
+ "where h.tran_id = d.tran_id and h.remarks like ? and quantity is not null "
+ "group by d.item_code,d.lot_no,d.lot_sl,d.line_no__invtrace";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, "%POD%"+invoiceID);
rs1=pstmt1.executeQuery();
while(rs1.next()){
quantityM=rs1.getDouble(1);
itemCodeM=rs1.getString(2);
lotNoM=rs1.getString(3);
lotSlM=rs1.getString(4);
lineNoM=rs1.getString(5);
itemCodeM=itemCodeT==null ? "" :itemCodeT.trim();
lotNoM=lotNoM==null ? "" :lotNoM.trim();
lotSlM=lotSlM==null ? "" :lotSlM.trim();
lineNoM=lineNoM==null ? "" :lineNoM.trim();
System.out.println("QuantityT----->>["+quantityT+"]");
System.out.println("QuantityM----->>["+quantityM+"]");
System.out.println("itemCodeM-->["+itemCodeM+"] lotNoM-->["+lotNoM+"]");
System.out.println("lotSlM-->["+lotSlM+"] lineNoM-->["+lineNoM+"]");
if(itemCodeT.equalsIgnoreCase(itemCodeM) && lotNoT.equalsIgnoreCase(lotNoM)){
if(lotSlT.equalsIgnoreCase(lotSlM) && lineNoT.equalsIgnoreCase(lineNoM)){
if(quantityT == quantityM )
{
System.out.println("record matched........at count "+count);
noOfRecordMatched++;
}
}
}
} //inner while end
if(rs1!=null){
rs1.close();
rs1=null;
}
if(pstmt1!=null){
pstmt1.close();
pstmt1=null;
}
}//end main while
System.out.println("noOfRecords End----->>["+noOfRecords+"]");
System.out.println("noOfRecordMatched----->>["+noOfRecordMatched+"]");
if(noOfRecords == noOfRecordMatched)
{
return true;
}
if(rs!=null){
rs.close();
rs=null;
}
if(pstmt!=null){
pstmt.close();
pstmt=null;
}
}
catch(Exception e)
{
System.out.println("Exception : checkInMiscDrCrRcp : "+e.getMessage());
e.printStackTrace();
}
return false;
}
protected String getSalesReturnTranID(Connection conn, String table_name, String tranID,String whrCondCol, String whrCondVal)
{
......
......@@ -67,11 +67,12 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
ConnDriver ConnDriver = new ConnDriver();
PreparedStatement pstmt=null;
String errString="",sql="",loginSite="",wfStatus="",itemCode="",regulatedPrice="",itemActive="";
String itmCodeDt2="",lotNo="",lotSl="", detail2xmlString="";
String itmCodeDt2="",lotNo="",lotSl="", detail2xmlString="",invoiceID="";
double aprvRate=0.0,PODrate=0.0,PODqty=0.0,allowedAmt=0.0,stockistAmt=0.0,debitNoteAmtDetail=0.0;
double debitNoteAmtHdr=0;
int updCnt=0,lineNo=0,lineNotrace=0;
ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB();
ProofOfDelivery podObj=null;
HashMap<Integer,Double> mapDebitNoteAmt=new HashMap<Integer,Double>();
try
{
......@@ -80,7 +81,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
conn = connDriver.getConnectDB("DriverValidator");
conn.setAutoCommit(false);
String confirmed="";
sql = "select confirmed,wf_status from spl_sales_por_hdr WHERE tran_id = ?";
sql = "select confirmed,wf_status,invoice_id from spl_sales_por_hdr WHERE tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
......@@ -88,6 +89,7 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
{
confirmed =rs.getString(1)==null ? "N":rs.getString(1);
wfStatus=rs.getString(2)==null ? "O" : rs.getString(2);
invoiceID=rs.getString(3);
}
if( pstmt != null )
{
......@@ -117,6 +119,14 @@ public class ProofOfDeliveryConf extends ActionHandlerEJB implements ProofOfDeli
errString = itmdbAccess.getErrorString("", "VTALCONF", "", "", conn);
return errString;
}
//check in misc_drcr_rcp POD already received or not
podObj=new ProofOfDelivery();
if(podObj.isRecordPresentInMiscDrCrRcp(conn, invoiceID))
{
errString = itmdbAccess.getErrorString("", "VTPODARI", "", "", conn);
return errString;
}
System.out.println("-------wfStatus before confirm -------"+wfStatus);
//Only submitted transaction allowed to confirm
if(wfStatus.trim().equalsIgnoreCase("S"))
......
This diff is collapsed.
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