Commit f643f368 authored by manohar's avatar manohar

min rate history selling rate made proper


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91313 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6ea937da
......@@ -1383,7 +1383,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
// 20/07/10 manoharan initialisation done
if (tranId == null)
{
tranId = "";
tranId = "@@@";
}
// end 20/07/10 manoharan initialisation done
pStmt.setString(5, tranId);
......@@ -1426,12 +1426,17 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
//saleRetQty = Math.abs(saleRetQty);
// 20/07/10 manoharan consider quantity entered for the same paramter other than the current line
System.out.println("manohar unconfQty before [" + unconfQty + "]");
unconfQty = unconfQty + getCurTranQty(lineNo, itemCode, lotNo, dom2 );
System.out.println("manohar unconfQty after [" + unconfQty + "]");
// 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_ret_qty>").append("<![CDATA["+ saleRetQty + "]]>").append("</sale_ret_qty>");
valueXmlString.append("<conf_claimed>").append("<![CDATA["+ confQty + "]]>").append("</conf_claimed>");
valueXmlString.append("<unconf_claimed>").append("<![CDATA["+ unconfQty + "]]>").append("</unconf_claimed>");
rate = getMinRate(dom, dom1, "lot_no", conn);
//saleRetQty = Math.abs(saleRetQty);
valueXmlString.append("<rate__sell>").append("<![CDATA["+ rate + "]]>").append("</rate__sell>");
}
if( rateSell != null && rateSell.trim().length() > 0 )
......@@ -1457,11 +1462,13 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
itmchgData = getItemChgdata( dom, dom1, dom2, conn ); // 14/06/10 manoharan dom2 added
valueXmlString.append( itmchgData );
}
if (currentColumn.trim().equals("lot_no"))
/*if (currentColumn.trim().equals("lot_no"))
{
itmchgData = getItemChgdata( dom, dom1, dom2, conn ); // 14/06/10 manoharan dom2 added
valueXmlString.append( itmchgData );
}
}*/
if (currentColumn.trim().equals("quantity"))
{
itmchgData = getCalculations( dom );
......@@ -1783,7 +1790,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} */
if( lotNo != null && lotNo.trim().length() > 0 )
{
sql = "Select min(eff_cost) as rate from min_rate_history "
/*sql = "Select min(eff_cost) as rate from min_rate_history "
+" where item_code = ? "
+" and lot_no = ? "
+" and cust_code = ? "
......@@ -1856,7 +1863,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt.close();
pStmt = null;
}
*/
sql = "select sum(b.quantity) as saleQty from invoice a, invoice_trace b "
+" where a.invoice_id = b.invoice_id "
+" and a.cust_code = ? "
......@@ -2078,7 +2085,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
rs = null;
pStmt.close();
pStmt = null; */
rate = getMinRate(dom, dom1, "lot_no", conn);
//saleRetQty = Math.abs(saleRetQty);
itmChangeString.append("<rate__sell>").append("<![CDATA["+ rate + "]]>").append("</rate__sell>");
itmChangeString.append("<sale_qty>").append("<![CDATA["+ saleQty + "]]>").append("</sale_qty>");
......@@ -2236,4 +2243,188 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
return curTranQty;
}
// end 20/07/10 manoharan to get the quantity for same lot other than current line
private double getMinRate(Document dom, Document dom1, String currCol, Connection conn) throws Exception
{
DistCommon distCommon = new DistCommon();
String invoiceId = null, retReplFlag = null, sql = "";
String itemCode = null;
String siteCode = null;
String lotNo = null;
String priceList = null;
double minRate = 0;
int noSchemeHist = 1;
String sNoSchemeHist = null;
String schemeKey = null;
String varValue = null;
String col[] = new String[500];
boolean dynamicCol = true;
boolean colMatch = false;
String tranDate = null;
String unitRate = null;
double qtyStdUom = 0;
String unitStd = null;
String colName = null;
String docKey = null;
String docValue = null;
int pos;
String strToken;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
/*
invoiceId = genericUtility.getColumnValue("invoice_id",dom1);
System.out.println( "invoiceId :: " + invoiceId );
if (invoiceId != null && invoiceId.trim().length() > 0 )
{
return sBuff;
}
retReplFlag = genericUtility.getColumnValue("ret_rep_flag",dom);
System.out.println( "retReplFlag :: " + retReplFlag );
if (!"R".equals(retReplFlag) )
{
System.out.println( "return 1");
return sBuff;
}
*/
sNoSchemeHist = distCommon.getDisparams("999999","SCHEME_HIST_NUM",conn);
System.out.println( "sNoSchemeHist :: " + sNoSchemeHist );
if ( "NULLFOUND".equals( sNoSchemeHist ) )
{
col[0] = "site_code";
col[1] = "item_code";
col[2] = "lot_no";
noSchemeHist = 1;
dynamicCol = false;
}
else
{
int colFound = 0;
noSchemeHist = Integer.parseInt( sNoSchemeHist );
for (int ctr = 1; ctr <= noSchemeHist; ctr++)
{
schemeKey = "SCHEME_HIST_KEY" + ctr ;
varValue = distCommon.getDisparams("999999",schemeKey,conn);
System.out.println( "currCol :: " + currCol );
System.out.println( "varValue :: " + varValue );
if (varValue.indexOf(currCol) > -1 )
{
colMatch = true;
colFound = 1;
break;
}
}
if (!colMatch)
{
System.out.println( "return 2");
return 0;
}
}
priceList = genericUtility.getColumnValue("price_list",dom1);
itemCode = genericUtility.getColumnValue("item_code",dom);
lotNo = genericUtility.getColumnValue("lot_no",dom);
tranDate = genericUtility.getColumnValue("tran_date",dom1);
String qtyStdUomStr = genericUtility.getColumnValue("quantity",dom);
if (qtyStdUomStr == null)
{
qtyStdUomStr = "0";
}
qtyStdUom = Double.parseDouble(qtyStdUomStr);
for (int ctr = 1; ctr <= noSchemeHist ; ctr++)
{
docKey = null;
int colCount = -1;
if (dynamicCol)
{
colCount = -1;
schemeKey = "SCHEME_HIST_KEY" + ctr ;
varValue = distCommon.getDisparams("999999",schemeKey,conn);
if ("NULLFOUND".equals( varValue ))
{
System.out.println( "return 3");
return 0;
}
else
{
varValue = varValue.trim();
while (varValue.trim().length()>0)
{
colCount++;
pos = varValue.indexOf(",");
if (pos > -1)
{
strToken = distCommon.getToken( varValue, "," );
col[colCount] = strToken ;
varValue = varValue.substring(pos+1);
}
else
{
col[colCount] = varValue;
break;
}
} // populate column list
}
}
else
{
colCount = 2;
}
for (int colCtr = 0; colCtr <= colCount; colCtr++)
{
colName = col[colCtr];
if ( "site_code".equalsIgnoreCase(colName.trim()) || "invoice_id".equalsIgnoreCase(colName.trim()) || "cust_code".equalsIgnoreCase(colName.trim()) )
{
docValue = genericUtility.getColumnValue(colName.trim(),dom1);
}
else
{
docValue = genericUtility.getColumnValue(colName.trim(),dom);
}
if (docKey != null && docKey.trim().length() > 0)
{
docKey = docKey + "," + ( docValue == null || docValue.trim().length() == 0 ? "" : docValue.trim() ); // 13/05/10 manoharan docValue trim() added
}
else
{
docKey = docValue;
}
}
sql = " select eff_cost from min_rate_history where doc_key = ?" ;
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,docKey);
rs = pstmt.executeQuery();
if(rs.next())
{
minRate = rs.getDouble(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if (minRate > 0)
{
break;
}
}
if (minRate == 0)
{
tranDate = tranDate == null ? ( genericUtility.getValidDateString( new Timestamp( System.currentTimeMillis() ).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat() ) ).toString() : tranDate;
itemCode = itemCode == null ? "" : itemCode;
lotNo = lotNo == null ? "" : lotNo;
minRate = distCommon.pickRate(priceList,tranDate,itemCode,lotNo,"D",qtyStdUom, conn);
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException( e );
}
return minRate ;
}
}
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