Commit b6dda8dd authored by manohar's avatar manohar

quantity validation for other lines in current transaction bug fixing


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91297 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7dc30938
...@@ -483,6 +483,11 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -483,6 +483,11 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
double unconfQtyDbl = Double.parseDouble(unconfQty); double unconfQtyDbl = Double.parseDouble(unconfQty);
double confQtyDbl = Double.parseDouble(confQty); double confQtyDbl = Double.parseDouble(confQty);
// 14/06/10 manoharan to consider lines other than current in which
// the same sales order line is used
// end 14/06/10 manoharan
if( qtyDbl > ( saleQtyDbl - saleRetQtyDbl - unconfQtyDbl - confQtyDbl ) ) if( qtyDbl > ( saleQtyDbl - saleRetQtyDbl - unconfQtyDbl - confQtyDbl ) )
{ {
errString =itmDBAccessEJB.getErrorString("quantity","VTINVQUANT",userId); errString =itmDBAccessEJB.getErrorString("quantity","VTINVQUANT",userId);
...@@ -1439,12 +1444,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1439,12 +1444,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
if (currentColumn.trim().equals("item_code")) if (currentColumn.trim().equals("item_code"))
{ {
itmchgData = getItemChgdata( dom, dom1, conn ); itmchgData = getItemChgdata( dom, dom1, dom2, conn ); // 14/06/10 manoharan dom2 added
valueXmlString.append( itmchgData ); valueXmlString.append( itmchgData );
} }
if (currentColumn.trim().equals("lot_no")) if (currentColumn.trim().equals("lot_no"))
{ {
itmchgData = getItemChgdata( dom, dom1, conn ); itmchgData = getItemChgdata( dom, dom1, dom2, conn ); // 14/06/10 manoharan dom2 added
valueXmlString.append( itmchgData ); valueXmlString.append( itmchgData );
} }
if (currentColumn.trim().equals("quantity")) if (currentColumn.trim().equals("quantity"))
...@@ -1616,12 +1621,14 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1616,12 +1621,14 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
return fldValue; return fldValue;
} }
private String getItemChgdata( Document dom, Document dom1, Connection conn ) throws RemoteException,ITMException private String getItemChgdata( Document dom, Document dom1, Document dom2, Connection conn ) throws RemoteException,ITMException
{ {
StringBuffer itmChangeString = new StringBuffer(""); StringBuffer itmChangeString = new StringBuffer("");
String sql = ""; String sql = "";
ResultSet rs = null; ResultSet rs = null;
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
String tempQty = "0", tempLotNo = "", tempItemCode = "", tempLineNo;
double dTempQty = 0;
try try
{ {
String itemDescr = ""; String itemDescr = "";
...@@ -1910,20 +1917,26 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1910,20 +1917,26 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
// 14/06/10 manoharan not to consider current transaction, current transaction quantity to be calculated separately
if (tranId == null)
{
tranId = "@@@";
}
sql = "select sum(case when b.quantity is null then 0 else b.quantity end) as unconfQty " sql = "select sum(case when b.quantity is null then 0 else b.quantity end) as unconfQty "
+" from charge_back a, charge_back_det b " +" from charge_back a, charge_back_det b "
+" where a.tran_id = b.tran_id " +" where a.tran_id = b.tran_id "
+" and a.tran_id <> ? " // 14/06/10 manoharan not to consider current transaction quantity
+" and a.cust_code = ? " +" and a.cust_code = ? "
+" and a.site_code = ? " +" and a.site_code = ? "
+" and (case when a.confirmed is null then 'N' else a.confirmed end) = 'N' " +" and (case when a.confirmed is null then 'N' else a.confirmed end) = 'N' "
+" and b.item_code = ? " +" and b.item_code = ? "
+" and b.lot_no = ? "; +" and b.lot_no = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode); pStmt.setString(1, tranId); // 14/06/10 manoharan not to consider current transaction quantity
pStmt.setString(2, siteCode); pStmt.setString(2, custCode);
pStmt.setString(3, itemCode); pStmt.setString(3, siteCode);
pStmt.setString(4, lotNo); pStmt.setString(4, itemCode);
pStmt.setString(5, lotNo);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if( rs.next() )
{ {
...@@ -1933,7 +1946,97 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1933,7 +1946,97 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
/////////////////////////////////////////////////////////////////////////////////////////////////////
// 27/05/10 manoharan bill_no, bill_date and discount to be carried forward
NodeList detail2List = null;
Node detailNode = null;
NodeList childDetilList = null;
Node chidDetailNode = null;
double curQty = 0;
detail2List = dom2.getElementsByTagName("Detail2");
System.out.println("manohar unconfirm quantity abefore [" + unconfQty + "] detail2List.getLength() [" + detail2List.getLength() + "]");
if (detail2List.getLength() > 1)
{
for(int detCtr =0; detCtr < detail2List.getLength(); detCtr++ )
{
detailNode = detail2List.item(detCtr);
childDetilList = detailNode.getChildNodes();
tempQty = "0";
tempLotNo = "";
tempItemCode = "";
tempLineNo = "";
dTempQty = 0;
for(int p =0; p < childDetilList.getLength(); p++ )
{
chidDetailNode = childDetilList.item(p);
System.out.println("manohar current child node [" + chidDetailNode.getNodeName() + "]");
if(chidDetailNode.getNodeName().equalsIgnoreCase("item_code") )
{
//System.out.println("discount_per node found >>>>>" + chidDetailNode.getNodeName());
if(chidDetailNode.getFirstChild() != null )
{
tempItemCode = chidDetailNode.getFirstChild().getNodeValue();
if(tempItemCode == null || tempItemCode.trim().length() == 0)
{
tempItemCode = "";
}
}
}
if(chidDetailNode.getNodeName().equalsIgnoreCase("lot_no") )
{
//System.out.println("discount_per_unit node found >>>>>" + chidDetailNode.getNodeName());
if(chidDetailNode.getFirstChild() != null )
{
tempLotNo = chidDetailNode.getFirstChild().getNodeValue();
if(tempLotNo == null )
{
tempLotNo = "";
}
}
}
if(chidDetailNode.getNodeName().equalsIgnoreCase("quantity") )
{
//System.out.println("porder_no node found >>>>>" + chidDetailNode.getNodeName());
if(chidDetailNode.getFirstChild() != null )
{
tempQty = chidDetailNode.getFirstChild().getNodeValue();
if(tempQty == null || tempQty.trim().length() == 0)
{
tempQty = "0";
}
}
}
if(chidDetailNode.getNodeName().equalsIgnoreCase("line_no") )
{
//System.out.println("porder_no node found >>>>>" + chidDetailNode.getNodeName());
if(chidDetailNode.getFirstChild() != null )
{
tempLineNo = chidDetailNode.getFirstChild().getNodeValue();
if(tempLineNo == null || tempLineNo.trim().length() == 0)
{
tempLineNo = "0";
}
}
}
}
// compare the item_code and lot_no if matches add to the current quantity
System.out.println("manohar comparing line_no [ " + tempLineNo + "] item [" + tempItemCode + "] lot [" + tempLotNo + "]");
if (lotNo.trim().equals(tempLotNo.trim()) || itemCode.trim().equals(tempItemCode.trim()) || !tempLineNo.equals(lineNo) )
{
dTempQty = Double.parseDouble(tempQty);
curQty += dTempQty;
System.out.println("manohar line_no [ " + tempLineNo + "] item [" + tempItemCode + "] lot [" + tempLotNo + "] qty ["+ dTempQty+ "]");
}
//
}
}
unconfQty += curQty;
System.out.println("manohar unconfirm quantity after [" + unconfQty + "]");
/////////////////////////////////////////////////////////////////////////////////////////////////////
/* sql = "select ('"+unconfQty+"' - (case when b.quantity is null then 0 else b.quantity end)) as unconfQty " /* sql = "select ('"+unconfQty+"' - (case when b.quantity is null then 0 else b.quantity end)) as unconfQty "
+" from charge_back a, charge_back_det b " +" from charge_back a, charge_back_det b "
+" where a.tran_id = b.tran_id " +" where a.tran_id = b.tran_id "
...@@ -1965,8 +2068,8 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1965,8 +2068,8 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
itmChangeString.append("<rate__sell>").append("<![CDATA["+ rate + "]]>").append("</rate__sell>"); itmChangeString.append("<rate__sell>").append("<![CDATA["+ rate + "]]>").append("</rate__sell>");
itmChangeString.append("<sale_qty>").append("<![CDATA["+ saleQty + "]]>").append("</sale_qty>"); itmChangeString.append("<sale_qty>").append("<![CDATA["+ saleQty + "]]>").append("</sale_qty>");
itmChangeString.append("<sale_ret_qty>").append("<![CDATA["+ saleRetQty + "]]>").append("</sale_ret_qty>"); itmChangeString.append("<sale_ret_qty>").append("<![CDATA["+ saleRetQty + "]]>").append("</sale_ret_qty>");
itmChangeString.append("<conf_claimed>").append("<![CDATA["+ confQty + "]]>").append("</conf_claimed>"); itmChangeString.append("<conf_claimed>").append("<![CDATA["+ getRequiredDecimal(confQty,3) + "]]>").append("</conf_claimed>");
itmChangeString.append("<unconf_claimed>").append("<![CDATA["+ unconfQty + "]]>").append("</unconf_claimed>"); itmChangeString.append("<unconf_claimed>").append("<![CDATA["+ getRequiredDecimal(unconfQty,3) + "]]>").append("</unconf_claimed>");
} }
} }
catch(Exception e) catch(Exception e)
...@@ -2024,11 +2127,11 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -2024,11 +2127,11 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
netAmt = amount + discAmt + taxAmtDbl; netAmt = amount + discAmt + taxAmtDbl;
discPerUnit = (rate * discPerDbl) / 100; discPerUnit = (rate * discPerDbl) / 100;
itmChangeString.append("<discount_amt>").append("<![CDATA["+ discAmt + "]]>").append("</discount_amt>"); itmChangeString.append("<discount_amt>").append("<![CDATA["+ getRequiredDecimal(discAmt, 3) + "]]>").append("</discount_amt>");
itmChangeString.append("<amount>").append("<![CDATA["+ amount + "]]>").append("</amount>"); itmChangeString.append("<amount>").append("<![CDATA["+ getRequiredDecimal(amount, 3) + "]]>").append("</amount>");
itmChangeString.append("<net_amt>").append("<![CDATA["+ netAmt + "]]>").append("</net_amt>"); itmChangeString.append("<net_amt>").append("<![CDATA["+ getRequiredDecimal(netAmt, 3) + "]]>").append("</net_amt>");
itmChangeString.append("<discount_per_unit>").append("<![CDATA["+ discPerUnit + "]]>").append("</discount_per_unit>"); itmChangeString.append("<discount_per_unit>").append("<![CDATA["+ getRequiredDecimal(discPerUnit, 3) + "]]>").append("</discount_per_unit>");
itmChangeString.append("<rate__diff>").append("<![CDATA["+ rateDiff + "]]>").append("</rate__diff>"); itmChangeString.append("<rate__diff>").append("<![CDATA["+ getRequiredDecimal(rateDiff, 3) + "]]>").append("</rate__diff>");
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -2037,4 +2140,15 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -2037,4 +2140,15 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
return itmChangeString.toString(); return itmChangeString.toString();
} }
String getRequiredDecimal(double actVal, int prec)
{
NumberFormat numberFormat = NumberFormat.getIntegerInstance ();
Double DoubleValue = new Double (actVal);
numberFormat.setMaximumFractionDigits(prec);
String strValue = numberFormat.format(DoubleValue);
strValue = strValue.replaceAll(",","");
//double reqVal = Double.parseDouble(strValue);
return strValue; //reqVal;
}
} }
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