Commit 998b8215 authored by ssalve's avatar ssalve

Sarita : Done changes for quantity validation on 22 OCT 2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192201 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0cd740b1
...@@ -11,7 +11,9 @@ import java.util.Calendar; ...@@ -11,7 +11,9 @@ import java.util.Calendar;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
...@@ -1612,7 +1614,8 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal, ...@@ -1612,7 +1614,8 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
} }
if((tranIdRef.trim().length()>0 && (errCode.trim().length()==0 || errCode==null) ) ) if((tranIdRef.trim().length()>0 && (errCode.trim().length()==0 || errCode==null) ) )
{ {
NodeList detlList = dom2.getElementsByTagName("Detail2");//Added by sarita on 22 OCT 18
sql="select case when sum(quantity) is null then 0 else sum(quantity) end from porcpdet " + sql="select case when sum(quantity) is null then 0 else sum(quantity) end from porcpdet " +
" where tran_id=? and purc_order = ? and "+ " where tran_id=? and purc_order = ? and "+
" line_no__ord = ? "; " line_no__ord = ? ";
...@@ -1625,26 +1628,36 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal, ...@@ -1625,26 +1628,36 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
lc_rcp_qty = rs.getDouble(1); lc_rcp_qty = rs.getDouble(1);
//Added by sarita on 22 OCT 18 [START]
if (detlList != null)
{
for (int cntr = 0; cntr < detlList.getLength(); cntr++)
{
Element tblQty = dom2.createElement("table_qty");
tblQty.appendChild(dom2.createTextNode(String.valueOf(lc_rcp_qty)));
detlList.item(cntr).appendChild(tblQty);
}
}
//Added by sarita on 22 OCT 18 [END]
} }
System.out.println("lc_rcp_qty@@@["+lc_rcp_qty+"]");
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("lc_rcp_qty@@@["+lc_rcp_qty+"]");
//Added by sarita on 22 OCT 2018 -- if quantity changed by user --- [START] //Added by sarita on 22 OCT 18 [START]
System.out.println("123.... Quantity ["+qty+"] \t Purchase Order Det Quantity ["+lc_rcp_qty+"]"); Double det2Qty = getSumOfDetail2Quantity(dom2);
if(qty > lc_rcp_qty) Double tableQty = getSumOfTableQuantity(dom2);
System.out.println("Detail 2 Final Value is === " + det2Qty + "Table Quantity is " +tableQty);
if(det2Qty > tableQty)
{ {
errCode = "VTINVPQTY"; errCode = "VTINVPQTY";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
//Added by sarita on 22 OCT 2018 -- if quantity changed by user --- [END] //Added by sarita on 22 OCT 18 [END]
sql="select case when sum(porcpdet.quantity) is null then 0 else sum(porcpdet.quantity) end " + sql="select case when sum(porcpdet.quantity) is null then 0 else sum(porcpdet.quantity) end " +
"from porcp,porcpdet " + "from porcp,porcpdet " +
"where porcp.tran_id = porcpdet.tran_id "+ "where porcp.tran_id = porcpdet.tran_id "+
...@@ -7402,5 +7415,81 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal, ...@@ -7402,5 +7415,81 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
System.out.println("Packing COde || site_code :[" + lsmfgsite + "]"); System.out.println("Packing COde || site_code :[" + lsmfgsite + "]");
return lsmfgsite; return lsmfgsite;
} }
//Added by sarita to get Detail2 total quantity on 22 OCT 2018 [START]
private double getSumOfDetail2Quantity(Document dom2) throws ITMException
{
double quantity = 0.0 ,qtyDet = 0.0 ,tblQtyVal = 0.0,tblQty = 0.0;
NodeList detlList = null;
int cntr = 0;
try
{
System.out.println("ABCD ["+genericUtility.serializeDom(dom2)+"]");
detlList = dom2.getElementsByTagName("Detail2");
if (detlList != null)
{
for (cntr = 0; cntr < detlList.getLength(); cntr++)
{
qtyDet = Double.parseDouble(genericUtility.getColumnValueFromNode("quantity", detlList.item(cntr)));
quantity = quantity + qtyDet;
}
}
System.out.println("Value of qtyDet ["+quantity+"] + counter is ["+cntr+"]");
}
catch(Exception e)
{
System.out.println("[Inside getSumOfDetail2Quantity]" + e);
throw new ITMException(e);
}
return quantity;
}
private double getSumOfTableQuantity(Document dom2) throws ITMException
{
double quantity = 0.0 ,qtyDet = 0.0 ,tblQtyVal = 0.0,tblQty = 0.0;
NodeList detlList = null;
int cntr = 0;
try
{
System.out.println("ABCD ["+genericUtility.serializeDom(dom2)+"]");
detlList = dom2.getElementsByTagName("Detail2");
if (detlList != null)
{
for (cntr = 0; cntr < detlList.getLength(); cntr++)
{
tblQtyVal = Double.parseDouble(genericUtility.getColumnValueFromNode("table_qty", detlList.item(cntr)));
tblQty = tblQty + tblQtyVal;
}
}
System.out.println("Value tblQtyVal ["+tblQty+"] + counter is ["+cntr+"]");
}
catch(Exception e)
{
System.out.println("[Inside getSumOfDetail2Quantity]" + e);
throw new ITMException(e);
}
return tblQty;
}
private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception
{
Node tempNode = dom.getElementsByTagName( nodeName ).item(0);
System.out.println("tempNode is ["+tempNode+"]");
if( tempNode != null )
{
if( tempNode.getFirstChild() == null )
{
CDATASection cDataSection = dom.createCDATASection( nodeVal );
tempNode.appendChild( cDataSection );
System.out.println("tempNode is 1["+tempNode+"]");
}
else
{
tempNode.getFirstChild().setNodeValue(nodeVal);
System.out.println("tempNode is 2["+tempNode+"]");
}
}
tempNode = null;
}
//Added by sarita to get Detail2 total quantity on 22 OCT 2018 [END]
} }
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