Commit 0c2d4811 authored by manohar's avatar manohar

Bug fix current transaction quantity for same item_code and lot_no other than...

Bug fix current transaction quantity for same item_code and lot_no other than current line considered, confirm tran_id generation drcr_flag value set


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91303 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d98b3ed5
...@@ -631,7 +631,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -631,7 +631,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
double discPerc = 0.0; double discPerc = 0.0;
double saleRetQty = 0.0; double saleRetQty = 0.0;
double confQty = 0.0, rate = 0.0, discPerUnit = 0.0; double confQty = 0.0, rate = 0.0, discPerUnit = 0.0;
double unconfQty = 0.0, rateSellDbl = 0.0, discPerDbl = 0.0, rateContrDbl = 0.0; double unconfQty = 0.0, rateSellDbl = 0.0, discPerDbl = 0.0, rateContrDbl = 0.0,curTranQty = 0;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try try
...@@ -1379,6 +1379,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1379,6 +1379,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt.setString(2, siteCode); pStmt.setString(2, siteCode);
pStmt.setString(3, itemCode); pStmt.setString(3, itemCode);
pStmt.setString(4, lotNo); pStmt.setString(4, lotNo);
// 20/07/10 manoharan initialisation done
if (tranId == null)
{
tranId = "";
}
// end 20/07/10 manoharan initialisation done
pStmt.setString(5, tranId); pStmt.setString(5, tranId);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if( rs.next() )
...@@ -1418,6 +1424,9 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1418,6 +1424,9 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt = null; */ pStmt = null; */
//saleRetQty = Math.abs(saleRetQty); //saleRetQty = Math.abs(saleRetQty);
// 20/07/10 manoharan consider quantity entered for the same paramter other than the current line
unconfQty = unconfQty + getCurTranQty(lineNo, itemCode, lotNo, dom2 );
// end 20/07/10 manoharan consider quantity entered for the same paramter other than the current line
valueXmlString.append("<sale_qty>").append("<![CDATA["+ saleQty + "]]>").append("</sale_qty>"); valueXmlString.append("<sale_qty>").append("<![CDATA["+ saleQty + "]]>").append("</sale_qty>");
valueXmlString.append("<sale_ret_qty>").append("<![CDATA["+ saleRetQty + "]]>").append("</sale_ret_qty>"); valueXmlString.append("<sale_ret_qty>").append("<![CDATA["+ saleRetQty + "]]>").append("</sale_ret_qty>");
valueXmlString.append("<conf_claimed>").append("<![CDATA["+ confQty + "]]>").append("</conf_claimed>"); valueXmlString.append("<conf_claimed>").append("<![CDATA["+ confQty + "]]>").append("</conf_claimed>");
...@@ -2150,5 +2159,75 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -2150,5 +2159,75 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
//double reqVal = Double.parseDouble(strValue); //double reqVal = Double.parseDouble(strValue);
return strValue; //reqVal; return strValue; //reqVal;
} }
// 20/07/10 manoharan to get the quantity for same lot other than current line
private double getCurTranQty(String curLineNo, String itemCode, String lotNo, Document dom ) throws Exception
{
String updateFlag = null;
String fldValue = null;
String nodeName = null;
Node currNode = null;
Node currDet = null;
NodeList currNodes = null;
String lineNoStr = "0", qtyStr = "0", domLotNo = "", domItemCode = "";
int currNodeLen;
System.out.println("Checking quantity in current transaction");
NodeList detailNodes = dom.getElementsByTagName( "Detail2" );
int detLen = detailNodes.getLength();
double curTranQty = 0, domQty = 0;
try
{
for( int detIdx = 0; detIdx < detLen ; detIdx++ )
{
currDet = detailNodes.item( detIdx );
currNodes = currDet.getChildNodes();
currNodeLen = currNodes.getLength();
domQty = 0;
for(int curNodeIdx = 0; curNodeIdx < currNodeLen; curNodeIdx++ )
{
currNode = currNodes.item( curNodeIdx );
nodeName = currNode.getNodeName();
if ( nodeName.equalsIgnoreCase( "attribute" ) )
{
updateFlag = currNode.getAttributes().getNamedItem( "updateFlag" ).getNodeValue();
}
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "quantity" ) )
{
qtyStr = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : "0";
}
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "line_no" ) )
{
lineNoStr = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : "0";
}
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "item_code" ) )
{
domItemCode = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : "";
}
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "lot_no" ) )
{
domLotNo = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : "";
}
}
if( !"D".equalsIgnoreCase( updateFlag ) && (!lineNoStr.trim().equals( curLineNo.trim() )) && (domItemCode.trim().equalsIgnoreCase( itemCode.trim() )) && (domLotNo.trim().equalsIgnoreCase( lotNo.trim() )))
{
System.out.println("manohar found lineNoStr [" + lineNoStr + "] curLineNo [" + curLineNo+ "] domItemCode [" + domItemCode + "] domLotNo [" + domLotNo + "] qtyStr[" + qtyStr + "]");
if( qtyStr == null )
{
qtyStr = "0";
}
domQty = Double.parseDouble(qtyStr);
curTranQty += domQty;
}
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return curTranQty;
}
// end 20/07/10 manoharan to get the quantity for same lot other than current line
} }
...@@ -77,7 +77,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -77,7 +77,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
String custCode = ""; String custCode = "";
String empCode = ""; String empCode = "";
String confirmed = ""; String confirmed = "";
double cbNetAmt = 0;
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"); loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"); empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
...@@ -93,10 +92,8 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -93,10 +92,8 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null; connDriver = null;
//currDate = new Timestamp( System.currentTimeMillis() ); currDate = new Timestamp( System.currentTimeMillis() );
currDate = getCurrdateTSFormat(); sql = "select tran_id, tran_date, site_code, cust_code, confirmed "
System.out.println("****getCurrdateTSFormat****"+currDate);
sql = "select tran_id, tran_date, site_code, cust_code, confirmed, net_amt "
+" from charge_back " +" from charge_back "
+" where tran_id = ? "; +" where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -108,7 +105,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -108,7 +105,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
siteCode = rs.getString("site_code"); siteCode = rs.getString("site_code");
custCode = rs.getString("cust_code"); custCode = rs.getString("cust_code");
confirmed = rs.getString("confirmed"); confirmed = rs.getString("confirmed");
cbNetAmt = rs.getDouble("net_amt");
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -120,12 +116,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -120,12 +116,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
returnString = itmDBAccessEJB.getErrorString("",errStr,userId); returnString = itmDBAccessEJB.getErrorString("",errStr,userId);
return returnString; return returnString;
} }
if( cbNetAmt == 0 )
{
errStr = "VTNTAMTZRO";
returnString = itmDBAccessEJB.getErrorString("",errStr,userId);
return returnString;
}
sql = "update charge_back set " sql = "update charge_back set "
+" confirmed = 'Y', " +" confirmed = 'Y', "
...@@ -404,7 +394,7 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -404,7 +394,7 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
drcrAmt = claimAmt < netAmt ? claimAmt : netAmt; drcrAmt = claimAmt < netAmt ? claimAmt : netAmt;
} }
crNtTranId = generateTranId("W_MISC_DRCR_RCP_CR", getCurrdateInAppFormat(), loginSite, userId, tranType, conn ); crNtTranId = generateTranId("W_MISC_DRCR_RCP_CR", getCurrdateInAppFormat(), loginSite, userId, tranType );
//-----------------------Inserting into header----------------------------------- //-----------------------Inserting into header-----------------------------------
pstmtHdr.setString( 1, crNtTranId ); pstmtHdr.setString( 1, crNtTranId );
pstmtHdr.setString( 2, "MDRCRC" ); pstmtHdr.setString( 2, "MDRCRC" );
...@@ -622,11 +612,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -622,11 +612,6 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
{ {
try try
{ {
if( !errCode.equals("VTSUCC1") )
{
System.out.println("......connection rollback.......");
conn.rollback();
}
if(pstmt != null) if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
...@@ -668,7 +653,7 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -668,7 +653,7 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
{ {
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
//conn.setAutoCommit(false); conn.setAutoCommit(false);
methodName = "gbf_post"; methodName = "gbf_post";
actionURI = "http://NvoServiceurl.org/" + methodName; actionURI = "http://NvoServiceurl.org/" + methodName;
...@@ -757,29 +742,9 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -757,29 +742,9 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
} }
return (currAppdate); return (currAppdate);
} }
private Timestamp getCurrdateTSFormat() private String generateTranId(String windowName, String tranDate, String siteCode ,String signBy,String tranType)
{
String s = "";
Timestamp timestamp = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return timestamp;
}
private String generateTranId(String windowName, String tranDate, String siteCode ,String signBy,String tranType,Connection conn)
{ {
//Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String generateTranIdSql = null; String generateTranIdSql = null;
...@@ -791,8 +756,9 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -791,8 +756,9 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
String tranIdCol = ""; String tranIdCol = "";
try try
{ {
//ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB( "DriverITM" ); conn = connDriver.getConnectDB( "DriverITM" );
conn.setAutoCommit(false);
generateTranIdSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE UPPER(TRAN_WINDOW)= ?"; generateTranIdSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE UPPER(TRAN_WINDOW)= ?";
System.out.println("[ChargeBackLocConfEJB :: generateTranId : input Paramaters][windowName]["+windowName+"][tranDate]["+tranDate+"][siteCode]["+siteCode+"]"); System.out.println("[ChargeBackLocConfEJB :: generateTranId : input Paramaters][windowName]["+windowName+"][tranDate]["+tranDate+"][siteCode]["+siteCode+"]");
System.out.println( "[ChargeBackLocConfEJB : generateTranId : Tran generator Sql[" + generateTranIdSql+"]" ); System.out.println( "[ChargeBackLocConfEJB : generateTranId : Tran generator Sql[" + generateTranIdSql+"]" );
...@@ -820,12 +786,16 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -820,12 +786,16 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
xmlValuesBuff.append("<tran_date><![CDATA["+tranDate+"]]></tran_date>"); xmlValuesBuff.append("<tran_date><![CDATA["+tranDate+"]]></tran_date>");
xmlValuesBuff.append("<vouch_type><![CDATA[F]]></vouch_type>"); xmlValuesBuff.append("<vouch_type><![CDATA[F]]></vouch_type>");
xmlValuesBuff.append("<tran_type><![CDATA["+tranType+"]]></tran_type>"); xmlValuesBuff.append("<tran_type><![CDATA["+tranType+"]]></tran_type>");
// 20/07/10 manoharan drcr_flag added
xmlValuesBuff.append("<drcr_flag><![CDATA[C]]></drcr_flag>");
// end 20/07/10 manoharan drcr_flag added
xmlValuesBuff.append("</Detail1></Root>"); xmlValuesBuff.append("</Detail1></Root>");
xmlValues = xmlValuesBuff.toString(); xmlValues = xmlValuesBuff.toString();
System.out.println("xmlValues :[" + xmlValues + "]"); System.out.println("xmlValues :[" + xmlValues + "]");
TransIDGenerator tg = new TransIDGenerator(xmlValues,signBy, CommonConstants.DB_NAME); TransIDGenerator tg = new TransIDGenerator(xmlValues,signBy, CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(refSer, tranIdCol, keyString, conn); tranId = tg.generateTranSeqID(refSer, tranIdCol, keyString, conn);
System.out.println("tranId :"+tranId); System.out.println("tranId :"+tranId);
conn.commit();
} }
catch (SQLException ex) catch (SQLException ex)
{ {
...@@ -839,10 +809,10 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo ...@@ -839,10 +809,10 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
{ {
try try
{ {
/* if( conn != null ){ if( conn != null ){
conn.close(); conn.close();
conn = null; conn = null;
} */ }
if( rs != null ) if( rs != null )
{ {
rs.close(); rs.close();
......
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