Commit e63d28b2 authored by ngadkari's avatar ngadkari

CHANGES IN VALIDATION and itemChange for doc key changes

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191997 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2874d71f
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
Author: manoharan Author: manoharan
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
...@@ -3361,7 +3360,7 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales ...@@ -3361,7 +3360,7 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
custCode = genericUtility.getColumnValue("cust_code", dom1); custCode = genericUtility.getColumnValue("cust_code", dom1);
slineNo = genericUtility.getColumnValue("line_no", dom); slineNo = genericUtility.getColumnValue("line_no", dom);
lineNo = Integer.parseInt(slineNo); //lineNo = Integer.parseInt(slineNo);
sql = " SELECT MRH.INVOICE_ID,MRH.QUANTITY, MRH.CUST_CODE, MRH.ITEM_CODE, MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE," sql = " SELECT MRH.INVOICE_ID,MRH.QUANTITY, MRH.CUST_CODE, MRH.ITEM_CODE, MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE,"
+ " SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) AS QTY_ADJ, MRH.EFF_COST" + " SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) AS QTY_ADJ, MRH.EFF_COST"
...@@ -3402,19 +3401,19 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales ...@@ -3402,19 +3401,19 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
// Changes by Nandkumar Gadkari on 14/09/18--------[Start]--------- // Changes by Nandkumar Gadkari on 14/09/18--------[Start]---------
// minRateDocKey = generateDocKey(dom1, dom, invoiceId, conn); commented by Nandkumar Gadkari on 14/09/18 // minRateDocKey = generateDocKey(dom1, dom, invoiceId, conn); commented by Nandkumar Gadkari on 14/09/18
// dokkeyList = new ArrayList<String>(); // dokkeyList = new ArrayList<String>();
if ("M".equalsIgnoreCase(sreturnAdjOpt)) /*if ("M".equalsIgnoreCase(sreturnAdjOpt))
{ {
dokkeyList = generateDocKey(dom1, dom," ", conn); dokkeyList = generateDocKey(dom1, dom," ", conn);
} }
else { else {*/
dokkeyList= generateDocKey(dom1, dom, invoiceId, conn); dokkeyList= generateDocKey(dom1, dom, invoiceId, conn);
} //}
int size = dokkeyList.size(); int size = dokkeyList.size();
System.out.println("dokkk key size: " +size); System.out.println("dokkk key size: " +size);
for(int i=0;i<=size-1;i++) /*for(int i=0;i<=size-1;i++)
{ {*/
minRateDocKey = dokkeyList.get(i); minRateDocKey = dokkeyList.get(0);
/*if(lineNo > 1) /*if(lineNo > 1)
{ {
*/ //Changed by Santosh on 16/05/2017 as invoiceId is not set on itemchange */ //Changed by Santosh on 16/05/2017 as invoiceId is not set on itemchange
...@@ -3450,12 +3449,104 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales ...@@ -3450,12 +3449,104 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
} }
} }
/*}
if (tempInvoiceId != null && tempInvoiceId.trim().length() > 0)
{
break;
}*/// // commented by Nandkumar Gadkari on 15/10/18
// Changes by Nandkumar Gadkari on 14/09/18--------[end]---------
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
//-----------Nandkumar Gadkari on 15/10/18------------------------------[start]--------------------------------
if (tempInvoiceId == null || tempInvoiceId.trim().length() == 0)
{
sql = " SELECT MRH.INVOICE_ID,MRH.QUANTITY, MRH.CUST_CODE, MRH.ITEM_CODE, MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE,"
+ " SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) AS QTY_ADJ, MRH.EFF_COST"
+ " FROM MIN_RATE_HISTORY MRH, SRETURNDET SRDET"
+ " WHERE MRH.DOC_KEY =SRDET.DOC_KEY(+) AND MRH.CUST_CODE = ?"
+ " AND MRH.ITEM_CODE = ? AND MRH.LOT_NO = ?"
+ " AND MRH.SITE_CODE = ? "
+ " AND MRH.QUANTITY IS NOT NULL"
+ " GROUP BY MRH.INVOICE_ID, MRH.QUANTITY, MRH.EFF_COST,MRH.CUST_CODE,MRH.ITEM_CODE,MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE "
//+ " HAVING MRH.QUANTITY-SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) > 0"
+ orderByStr;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
while(rs.next())
{
invoiceId = checkNull(rs.getString("INVOICE_ID"));
invoiceQty = checkNull(rs.getString("QUANTITY"));
adjQty = checkNull(rs.getString("QTY_ADJ"));
rate = rs.getDouble("EFF_COST");
curRecordItemLotHMap.put("cust_code", checkNull(rs.getString("CUST_CODE")));
curRecordItemLotHMap.put("item_code", checkNull(rs.getString("ITEM_CODE")));
curRecordItemLotHMap.put("lot_no", checkNull(rs.getString("LOT_NO")));
curRecordItemLotHMap.put("site_code", checkNull(rs.getString("SITE_CODE")));
curRecordItemLotHMap.put("quantity", invoiceQty);
dokkeyList= generateDocKey(dom1, dom, invoiceId, conn);
int size = dokkeyList.size();
System.out.println("dokkk key size: " +size);
for(int i=1;i<=size-1;i++)
{
minRateDocKey = dokkeyList.get(i);
sql1 = "SELECT COUNT(*) FROM MIN_RATE_HISTORY WHERE DOC_KEY =? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, minRateDocKey);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
cnt = rs1.getInt(1);
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(cnt > 0)
{
invoiceId = getAvailableInvId(dom,dom2, curFormItemLotHMap, curRecordItemLotHMap, invoiceId, minRateDocKey, adjQty);// current dom added to parameters by Nandkumar Gadkari on 14/09/18
//}
tempInvoiceId=invoiceId;
if( invoiceId != null && invoiceId.trim().length() > 0)
{
break;
}
}
} }
if (tempInvoiceId != null && tempInvoiceId.trim().length() > 0) if (tempInvoiceId != null && tempInvoiceId.trim().length() > 0)
{ {
break; break;
} }
// Changes by Nandkumar Gadkari on 14/09/18--------[end]---------
} }
if(pstmt != null) if(pstmt != null)
{ {
...@@ -3467,6 +3558,8 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales ...@@ -3467,6 +3558,8 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
rs.close(); rs.close();
rs = null; rs = null;
} }
}
//-----------Nandkumar Gadkari on 15/10/18------------------------------[end]--------------------------------
if( invoiceId != null && invoiceId.trim().length() > 0 ) if( invoiceId != null && invoiceId.trim().length() > 0 )
{ {
...@@ -5843,40 +5936,147 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales ...@@ -5843,40 +5936,147 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
else if (currentColumn.trim().equals( "invoice_ref" )) else if (currentColumn.trim().equals( "invoice_ref" ))
{ {
System.out.println("inside invoice ref : " );
String invRef = checkNull(genericUtility.getColumnValue( "invoice_ref", dom )); //Nandkumar Gadkari on 11/10/18--------------------------------------------(Start)---------------------------------
invoiceId = genericUtility.getColumnValue("invoice_id", dom1);
if((invoiceId == null || "null".equals(invoiceId)|| invoiceId.trim().length() == 0 )&& (invRef.trim().length() > 0 || invRef != null ) ) System.out.println(">>>>>>>>>>In IC lot_no:");
priceList = genericUtility.getColumnValue("price_list", dom1);
priceListClg = genericUtility.getColumnValue("price_list__clg", dom1);
fullRet = genericUtility.getColumnValue("full_ret", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
tranDate = genericUtility.getColumnValue("tran_date", dom1);
siteCode = genericUtility.getColumnValue("site_code", dom1);
invoiceId = genericUtility.getColumnValue("invoice_ref", dom);
unitRate = genericUtility.getColumnValue("unit__rate", dom);
unitRate = unitRate == null ? "" : unitRate;
unitStd = genericUtility.getColumnValue("unit__std", dom);
retReplFlag = genericUtility.getColumnValue("ret_rep_flag", dom);
String iValStr = genericUtility.getColumnValue("line_no__inv", dom);
if (iValStr != null && iValStr.indexOf(".") > 0)
{ {
sqlStr = "select tran_date from invoice where INVOICE_ID = ? "; //trim(:ls_itemcode); iValStr = iValStr.substring(0,iValStr.indexOf("."));
pstmt = conn.prepareStatement( sqlStr ); }
pstmt.setString( 1, invRef );
sreturnAdjOpt = distCommon.getDisparams("999999", "SRETURN_ADJ_OPT", conn);
System.out.println("sreturnAdjOpt:::["+sreturnAdjOpt+"]");
if ("M".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " ORDER BY MRH.EFF_COST ";
}
else if("E".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " ORDER BY MRH.INVOICE_DATE ASC,MRH.INVOICE_ID ASC ";
}
else if("L".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " ORDER BY MRH.INVOICE_DATE DESC,MRH.INVOICE_ID DESC ";
}
if( !"NULLFOUND".equalsIgnoreCase(sreturnAdjOpt))
{
if(invoiceId != null && invoiceId.trim().length()>0)
{
dokkeyList= generateDocKey(dom1, dom, invoiceId, conn);
curFormItemLotHMap.put("cust_code", genericUtility.getColumnValue("cust_code", dom1));
curFormItemLotHMap.put("item_code", itemCode);
curFormItemLotHMap.put("lot_no", lotNo);
curFormItemLotHMap.put("site_code", siteCode);
curFormItemLotHMap.put("quantity", genericUtility.getColumnValue("quantity", dom));
custCode = genericUtility.getColumnValue("cust_code", dom1);
slineNo = genericUtility.getColumnValue("line_no", dom);
//lineNo = Integer.parseInt(slineNo);
/*int size = dokkeyList.size();
for(int i=0;i<=size-1;i++)
{*/
minRateDocKey = dokkeyList.get(0);
System.out.println("@@@@@@@minRateDocKey .......... test 123 [" + minRateDocKey+"]");
System.out.println("@@@@@@@count1 .......... test 123");
sql = " SELECT MRH.INVOICE_ID,MRH.QUANTITY, MRH.CUST_CODE, MRH.ITEM_CODE, MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE,"
+ " SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) AS QTY_ADJ, MRH.EFF_COST"
+ " FROM MIN_RATE_HISTORY MRH, SRETURNDET SRDET"
+ " WHERE MRH.DOC_KEY =SRDET.DOC_KEY(+) AND MRH.CUST_CODE = ?"
+ " AND MRH.ITEM_CODE = ? AND MRH.LOT_NO = ?"
+ " AND MRH.SITE_CODE = ? AND MRH.QUANTITY - CASE WHEN MRH.QUANTITY_ADJ IS NULL THEN 0 ELSE MRH.QUANTITY_ADJ END > 0"
+ " AND MRH.QUANTITY IS NOT NULL AND MRH.INVOICE_ID= ? "
+ " GROUP BY MRH.INVOICE_ID, MRH.QUANTITY, MRH.EFF_COST,MRH.CUST_CODE,MRH.ITEM_CODE,MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE"
+ " HAVING MRH.QUANTITY-SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) > 0"
+ orderByStr;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo);
pstmt.setString(4, siteCode);
pstmt.setString(5, invoiceId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) while (rs.next()) {
invoiceQty = checkNull(rs.getString("QUANTITY"));
adjQty = checkNull(rs.getString("QTY_ADJ"));
rate = rs.getDouble("EFF_COST");
curRecordItemLotHMap.put("cust_code", checkNull(rs.getString("CUST_CODE")));
curRecordItemLotHMap.put("item_code", checkNull(rs.getString("ITEM_CODE")));
curRecordItemLotHMap.put("lot_no", checkNull(rs.getString("LOT_NO")));
curRecordItemLotHMap.put("site_code", checkNull(rs.getString("SITE_CODE")));
curRecordItemLotHMap.put("quantity", invoiceQty);
System.out.println("@@@@@@@@@@@@ dokkeyList["+dokkeyList+"]");
invoiceId = getAvailableInvId(dom,dom2, curFormItemLotHMap, curRecordItemLotHMap,invoiceId, minRateDocKey, adjQty);
tempInvoiceId =invoiceId;
if (invoiceId != null && invoiceId.trim().length() > 0)
{ {
tranDate = checkNull(sdf.format(rs.getTimestamp("tran_date"))); break;
}
} }
System.out.println("tranDate : " +tranDate);
if( rs != null ) if (pstmt != null) {
rs.close();
rs = null;
if( pstmt != null )
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
}
if (rs != null) {
rs.close();
rs = null;
}
if((tranDate != null) && tranDate.trim().length() >0 ) //}
//Added by Nandkumar Gadkari on 14/09/18----------------[End]---------------------------------------
sql = "SELECT DOC_KEY,EFF_COST FROM MIN_RATE_HISTORY WHERE DOC_KEY = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, minRateDocKey);
rs = pstmt.executeQuery();
if(rs.next())
{ {
valueXmlString.append("<inv_ref_date>").append("<![CDATA["+ checkNullTrim(tranDate)+"]]>").append("</inv_ref_date>"); minRateDocKey = checkNull(rs.getString("DOC_KEY"));
rate = rs.getDouble("EFF_COST");
} }
else if(pstmt != null)
{ {
valueXmlString.append("<inv_ref_date>").append("<![CDATA[]]>").append("</inv_ref_date>"); pstmt.close();
pstmt = null;
} }
if(rs != null)
{
rs.close();
rs = null;
} }
/* else isMinHisRateSet = true;
if(minRateDocKey != null && minRateDocKey.trim().length() > 0 )
{ {
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
valueXmlString.append("<doc_key>").append("<![CDATA[" + minRateDocKey + "]]>").append("</doc_key>");
setNodeValue( dom, "doc_key", minRateDocKey );
}
String docKey = checkNull(genericUtility.getColumnValue( "doc_key", dom )); String docKey = checkNull(genericUtility.getColumnValue( "doc_key", dom ));
System.out.println(" dok key : " +docKey);
if(docKey.trim().length() > 0 || docKey != null ) if(docKey.trim().length() > 0 || docKey != null )
{ {
System.out.println("inside dok key : " +docKey); System.out.println("inside dok key : " +docKey);
...@@ -5896,26 +6096,569 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales ...@@ -5896,26 +6096,569 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(invRefId != null && invRefId.trim().length() >0)
{
valueXmlString.append("<invoice_ref>").append("<![CDATA["+ invRefId +"]]>").append("</invoice_ref>"); valueXmlString.append("<invoice_ref>").append("<![CDATA["+ invRefId +"]]>").append("</invoice_ref>");
}
if(invRefDate != null && invRefDate.trim().length() >0) if(invRefDate != null && invRefDate.trim().length() >0)
{ {
valueXmlString.append("<inv_ref_date>").append("<![CDATA["+ invRefDate+"]]>").append("</inv_ref_date>"); valueXmlString.append("<inv_ref_date>").append("<![CDATA["+ invRefDate+"]]>").append("</inv_ref_date>");
} }
} }
}*/
}
// Added By PriyankaC on 14JUNE2018 [END]
valueXmlString.append("</Detail2>"); invoiceId = null;
break; }
}
case 3: infoMap = new HashMap();
iValStr = iValStr == null || iValStr.trim().length() == 0 ? "0" : iValStr.trim();
lineNoInv = Integer.parseInt( getNumString( iValStr ) );
iValStr = genericUtility.getColumnValue( "quantity__stduom", dom);
qtyStdUom = Double.parseDouble( getNumString( iValStr ) );
parentNodeList = dom1.getElementsByTagName("Detail1"); lotSl = genericUtility.getColumnValue("lot_sl", dom);
parentNode = parentNodeList.item(0); locCode = genericUtility.getColumnValue("loc_code", dom);
winName = getObjName(parentNode); lineNoTrace = genericUtility.getColumnValue("line_no__invtrace", dom);
if (lineNoTrace != null )
{
if (lineNoTrace != null && lineNoTrace.indexOf(".") > 0)
{
lineNoTrace = lineNoTrace.substring(0,lineNoTrace.indexOf("."));
}
parentNodeList = dom.getElementsByTagName("Detail3"); iLineNoTrace = Integer.parseInt( lineNoTrace );
infoMap.put("line_no__invtrace",lineNoTrace);
}
quantity = qtyStdUom;
infoMap.put("ret_repl_flag",retReplFlag);
infoMap.put("item_code", itemCode);
infoMap.put("site_code", siteCode);
infoMap.put("loc_code",locCode);
infoMap.put("lot_no", lotNo);
infoMap.put("lot_sl", lotSl);
infoMap.put("tran_date", tranDate);
infoMap.put("invoice_id", invoiceId);
infoMap.put( "quantity__stduom", new Double( -1 * quantity ) );
costRate = getCostRate(infoMap, conn);
infoMap = null;
valueXmlString.append("<cost_rate>").append("<![CDATA[" + costRate + "]]>").append("</cost_rate>");
setNodeValue( dom, "cost_rate", Double.toString( costRate ) );
System.out.println( " invoiceId :1: " + invoiceId );
if (invoiceId != null && invoiceId.trim().length() > 0 && !"null".equalsIgnoreCase( invoiceId.trim() ) )
{
System.out.println( " retReplFlag :2: " + retReplFlag );
if (retReplFlag.equals("R"))
{
sql = "select sord_no, sord_line_no "
+ " from invoice_trace "
+ " where invoice_id = ? "
+ " and line_no = ? ";
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, invoiceId );
pstmt.setInt( 2, iLineNoTrace );
rs = pstmt.executeQuery();
if( rs.next() )
{
sorder = rs.getString(1);
sordLineNo = rs.getString(2);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
sql = "select count(1) from invoice_trace "
+ " where invoice_id = ? "
+ " and item_code = ? "
+ " and sord_no = ? "
+ " and sord_line_no = ? "
+ " and item_code <> item_code__ord " ;
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, invoiceId );
pstmt.setString( 2, itemCode );
pstmt.setString( 3, sorder );
pstmt.setString( 4, sordLineNo );
rs = pstmt.executeQuery();
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
System.out.println( " cnt :1: " + cnt );
if (cnt > 0)
{
sql = "select sum((case when quantity is null then 0 else quantity end) * "
+ " (case when rate is null then 0 else rate end)), "
+ " sum(case when quantity is null then 0 else quantity end) from invoice_trace "
+ " where invoice_id = ? "
+ " and item_code = ? "
+ " and sord_no = ? "
+ " and sord_line_no = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, invoiceId );
pstmt.setString( 2, itemCode );
pstmt.setString( 3, sorder );
pstmt.setString( 4, sordLineNo );
rs = pstmt.executeQuery();
cnt = 0;
if( rs.next() )
{
amount = rs.getDouble(1);
quantity = rs.getDouble(2);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
totFreeCost = 0;
sql = "select a.item_code, sum(a.quantity), a.item_code__ord "
+ " from sorditem a "
+ " where a.sale_order = ? "
+ " and a.line_no = ? "
+ " and a.item_code <> ? "
+ " and nature = 'F' "
+ " and not exists (select b.item_code from sorditem b "
+ " where b.sale_order = a.sale_order "
+ " and b.line_no= a.line_no "
+ " and a.item_code = b.item_code "
+ " and nature = 'C') "
+ " group by a.item_code, a.item_code__ord ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, sorder);
pstmt.setString( 2, sordLineNo);
pstmt.setString( 3, itemCode);
rs = pstmt.executeQuery();
cnt = 0;
while ( rs.next() )
{
freeItemCode = rs.getString(1);
freeQty = rs.getDouble(2);
itemCodeOrd = rs.getString(3);
effCostFree = 0;
sql = "select count(1), avg(eff_cost) "
+ " from bomdet "
+ " where bom_code = ? "
+ " and item_code = ? "
+ " and nature = 'F' ";
pstmt1 = conn.prepareStatement( sql );
pstmt1.setString( 1, itemCodeOrd);
pstmt1.setString( 2, itemCode);
rs1 = pstmt1.executeQuery();
cnt = 0;
if( rs1.next() )
{
cnt = rs1.getInt(1);
effCostFree = rs1.getDouble(2);
if (cnt > 0 )
{
totFreeCost += freeQty * effCostFree;
totFreeCost = getRequiredDecimal( totFreeCost, 4 );
}
}
rs1.close();
pstmt1.close();
pstmt1 = null;
rs1 = null;
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
amount = amount - totFreeCost;
sql = "select sum(case when a.drcr_flag = 'C' then "
+ " ((case when b.drcr_amt is null then 0 else b.drcr_amt end) * -1) else 0 End) "
+ " from drcr_rcp a, drcr_rdet b "
+ " where a.tran_id = b.tran_id "
+ " and b.invoice_id = ? "
+ " and b.item_code = ? "
+ " and a.sreturn_no is null" ;
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, invoiceId);
pstmt.setString( 2, itemCode);
rs = pstmt.executeQuery();
cnt = 0;
if ( rs.next() )
{
amtDrCr = rs.getDouble(1);
rate = (amount + amtDrCr) / quantity;
System.out.println( "rate calc db LOt NO :: " + rate );
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
else
{
System.out.println( "else 1 " );
sql = "select rate, discount, rate__clg "
+ " from invoice_trace "
+ " where invoice_id = ? "
+ " and line_no = ? ";
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, invoiceId);
pstmt.setInt( 2, iLineNoTrace);
rs = pstmt.executeQuery();
if( rs.next() )
{
rate = rs.getDouble(1);
discount = rs.getDouble(2);
rateClg = rs.getDouble(3);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
lineNoTrace = genericUtility.getColumnValue("line_no__invtrace", dom);
if (lineNoTrace != null )
{
if (lineNoTrace != null && lineNoTrace.indexOf(".") > 0)
{
lineNoTrace = lineNoTrace.substring(0,lineNoTrace.indexOf("."));
}
iLineNoTrace = Integer.parseInt( lineNoTrace );
}
sql = "select sum((case when quantity is null then 0 else quantity end) * "
+ " (case when rate is null then 0 else rate end)), "
+ " sum(case when quantity is null then 0 else quantity end) "
+ " from invoice_trace "
+ " where invoice_id = ? "
+ " and line_no = ? ";
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, invoiceId);
pstmt.setInt( 2, iLineNoTrace );
rs = pstmt.executeQuery();
if( rs.next() )
{
amount = rs.getDouble(1);
quantity = rs.getDouble(2);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
sql = "select sum(case when a.drcr_flag = 'C' then "
+ " ((case when b.drcr_amt is null then 0 else b.drcr_amt end) * -1) else 0 End) "
+ " from drcr_rcp a, drcr_rdet b "
+ " where a.tran_id = b.tran_id "
+ " and b.invoice_id = ? "
+ " and b.line_no__inv = ? "
+ " and a.sreturn_no is null" ;
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, invoiceId);
pstmt.setInt( 2, lineNoInv );
rs = pstmt.executeQuery();
amtDrCr = 0;
if( rs.next() )
{
amtDrCr = rs.getDouble(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
System.out.println( "amount lot :1: " + amount );
System.out.println( "quantity lot :1: " + quantity );
System.out.println( "amtDrCr :1: " + amtDrCr );
rate = (amount + amtDrCr) / quantity;
rate = getRequiredDecimal( rate, 4 );
System.out.println( "rate calc LOt NO :: " + rate );
}
}
else
{
System.out.println( "priceList :2 : " + priceList );
if (priceList != null && !priceList.equals("null") && priceList.trim().length() > 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;
rate = distCommon.pickRate(priceList,tranDate,itemCode,lotNo,"D",qtyStdUom, conn);
System.out.println( "rate pic rate LOt NO :: " + rate );
}
}
}
else
{
System.out.println( "retReplFlag :2 : " + retReplFlag );
if (retReplFlag != null && retReplFlag.equals("R") && !isMinHisRateSet)
{
System.out.println(">>>>>>>>>>>>>In lot_no before getMinRate @ 3313:");
StringBuffer minRateBuff = getMinRate( dom, dom1, "lot_no", valueXmlString, conn);
System.out.println( "minRateBuff2 :: " + minRateBuff.toString() );
String rateValStr = getTagValue( minRateBuff.toString(), "rate" );
System.out.println( "rateValStr LOt NO :: " + rateValStr );
rate = getRequiredDecimal( Double.parseDouble( getNumString( rateValStr ) ), 4 );
}
System.out.println( "rate before If :1: " + rate );
if (rate <= 0)
{
rate = 0;
if (priceList != null && !priceList.equals("null") && priceList.trim().length() > 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;
rate = distCommon.pickRate(priceList,tranDate,itemCode,lotNo,"D",qtyStdUom, conn);
System.out.println( "rate in If :1: " + rate );
}
}
}
pickLowerRate = distCommon.getDisparams("999999","PICK_LOWER_RATE", conn);
if (pickLowerRate.equals("NULLFOUND"))
{
pickLowerRate = "N";
}
if ( pickLowerRate != null && pickLowerRate.equals("Y"))
{
if (priceList !=null && priceList.trim().length() > 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;
priceListRate = distCommon.pickRate(priceList,tranDate,itemCode,lotNo,"D", quantity, conn);
System.out.println( "priceListRate LOt NO :: " + priceListRate );
if (priceListRate < rate && priceListRate > 0 )
{
rate = priceListRate;
System.out.println( "rate priceListRate < rate && priceListRate > 0 :1: " + rate );
}
}
}
System.out.println( "Rate LOt NO :: " + rate );
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
setNodeValue( dom, "rate", rate );
rateClg = sRateClg;
if (rateClg <= 0 )
{
if ( priceListClg != null && priceListClg.trim().length() > 0 && !"null".equalsIgnoreCase( priceListClg.trim() ) )
{
tranDate = tranDate == null ? ( genericUtility.getValidDateString( new Timestamp( System.currentTimeMillis() ).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat() ) ).toString() : tranDate;
itemCode = itemCode == null ? "" : itemCode;
lotNo = lotNo == null ? "" : lotNo;
rateClg = distCommon.pickRate(priceListClg,tranDate,itemCode,lotNo,"L", quantity, conn);
if (rateClg == -1)
{
rateClg = 0 ;
}
}
if (rateClg == 0 )
{
valueXmlString.append("<rate__clg>").append("<![CDATA[" + rate + "]]>").append("</rate__clg>");
setNodeValue( dom, "rate__clg", rate );
}
else
{
valueXmlString.append("<rate__clg>").append("<![CDATA[" + rateClg + "]]>").append("</rate__clg>");
setNodeValue( dom, "rate__clg", rateClg );
}
}
unit = genericUtility.getColumnValue( "unit", dom );
if ( unitRate != null && unit != null && unit.trim().equals( unitRate.trim() ) )
{
System.out.println("manohar rate__stduom 5 [" + rate + "]");
valueXmlString.append("<rate__stduom>").append("<![CDATA[" + rate + "]]>").append("</rate__stduom>");
setNodeValue( dom, "rate__stduom", rate );
valueXmlString.append("<conv__rtuom_stduom>").append("<![CDATA[1]]>").append("</conv__rtuom_stduom>");
setNodeValue( dom, "conv__rtuom_stduom", "1" );
}
else if ( unitRate != null && unit != null && !unit.trim().equals( unitRate.trim() ) )
{
System.out.println( "unit :: " + unit );
System.out.println( "unitRate :: " + unitRate );
System.out.println( "itemCode :: " + itemCode );
System.out.println( "rate :: " + rate );
System.out.println( "fact :: " + fact );
convAr = distCommon.getConvQuantityFact(unit, unitRate, itemCode, rate, (double) fact, conn);
convFact = Double.parseDouble( convAr.get(0).toString() );
rateStd = Double.parseDouble( convAr.get(1).toString() );
System.out.println("manohar rate__stduom 6 [" + rateStd + "]");
valueXmlString.append("<rate__stduom>").append("<![CDATA[" + rateStd + "]]>").append("</rate__stduom>");
setNodeValue( dom, "rate__stduom", rateStd );
valueXmlString.append("<conv__rtuom_stduom>").append("<![CDATA[" + convFact + "]]>").append("</conv__rtuom_stduom>");
setNodeValue( dom, "conv__rtuom_stduom", convFact );
}
sQuantity = Double.parseDouble( getNumString( genericUtility.getColumnValue("quantity", dom) ) );
quantity = sQuantity;
valueXmlString.append("<mrp_value>").append("<![CDATA[" + quantity * rateClg + "]]>").append("</mrp_value>");
setNodeValue( dom, "mrp_value", quantity * rateClg );
System.out.println("<<<<<<<<<<DISCOUNT>>>>>>>>>>= "+ discount);
System.out.println(">>>>>>>>>>>>>In lot_no before getMinRate @ 3421:");
String lslotsl="";
System.out.println("site_code is:"+siteCode);
System.out.println("lotNo is:"+lotNo);
System.out.println("locCode is:"+locCode);
System.out.println("itemCode is:"+itemCode);
sql="select lot_sl from stock where site_code = ? and " +
"lot_no = ? and item_code = ?";
pstmt= conn.prepareStatement( sql );//,,,
pstmt.setString( 1, siteCode);
pstmt.setString( 2, lotNo );
pstmt.setString( 3, itemCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
lslotsl = rs.getString(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
System.out.println("*********Lot sl is:"+lslotsl);
if (lslotsl == null || lslotsl.trim().length() == 0)
{
System.out.println("lslotsl is null in lot_no itemChanged"+lslotsl);
String lsSretLotsl="";
lsSretLotsl = distCommon.getDisparams( "999999", "SRETURN_DEFAULT_LOTSL", conn );
System.out.println("lsSretLotsl ["+lsSretLotsl+"] in lot_no Disparam Value");
if(lsSretLotsl == null || lsSretLotsl.trim().length()== 0 || "NULLFOUND".equalsIgnoreCase(lsSretLotsl))
{
valueXmlString.append("<lot_sl>").append("2S").append("</lot_sl>");
}
else
{
System.out.println("lsSretLotsl["+lsSretLotsl+"]");
valueXmlString.append("<lot_sl>").append("<![CDATA[" + lsSretLotsl + "]]>").append("</lot_sl>");
}
}
else
{
valueXmlString.append("<lot_sl>").append("<![CDATA[" + lslotsl + "]]>").append("</lot_sl>");
}
StringBuffer minRateBuff = null;
if(!isMinHisRateSet)
{
minRateBuff = getMinRate( dom, dom1, currentColumn.trim(), valueXmlString, conn );
System.out.println( "minRateBuff2 :: " + minRateBuff.toString() );
valueXmlString = minRateBuff;
}
System.out.println("lslotsl["+lslotsl+"]");
setNodeValue( dom, "lot_sl",lslotsl);
reStr = itemChanged(dom, dom1, dom2, objContext, "lot_sl", editFlag, xtraParams);
pos = reStr.indexOf("<Detail2>");
reStr = reStr.substring(pos + 9);
pos = reStr.indexOf("</Detail2>");
reStr = reStr.substring(0,pos);
valueXmlString.append(reStr);
//Nandkumar Gadkari on 11/10/18--------------------------------------------(end)---------------------------------
System.out.println("inside invoice ref : " );
String invRef = checkNull(genericUtility.getColumnValue( "invoice_ref", dom ));
invoiceId = genericUtility.getColumnValue("invoice_id", dom1);
if((invoiceId == null || "null".equals(invoiceId)|| invoiceId.trim().length() == 0 )&& (invRef.trim().length() > 0 || invRef != null ) )
{
sqlStr = "select tran_date from invoice where INVOICE_ID = ? "; //trim(:ls_itemcode);
pstmt = conn.prepareStatement( sqlStr );
pstmt.setString( 1, invRef );
rs = pstmt.executeQuery();
if( rs.next() )
{
tranDate = checkNull(sdf.format(rs.getTimestamp("tran_date")));
}
System.out.println("tranDate : " +tranDate);
if( rs != null )
rs.close();
rs = null;
if( pstmt != null )
pstmt.close();
pstmt = null;
if((tranDate != null) && tranDate.trim().length() >0 )
{
valueXmlString.append("<inv_ref_date>").append("<![CDATA["+ checkNullTrim(tranDate)+"]]>").append("</inv_ref_date>");
}
else
{
valueXmlString.append("<inv_ref_date>").append("<![CDATA[]]>").append("</inv_ref_date>");
}
}
/* else
{
String docKey = checkNull(genericUtility.getColumnValue( "doc_key", dom ));
if(docKey.trim().length() > 0 || docKey != null )
{
System.out.println("inside dok key : " +docKey);
sqlStr = " select INVOICE_ID , INVOICE_DATE from MIN_RATE_HISTORY where DOC_KEY = ? "; //trim(:ls_itemcode);
pstmt = conn.prepareStatement( sqlStr );
pstmt.setString( 1, docKey );
rs = pstmt.executeQuery();
if( rs.next() )
{
invRefId = checkNull(rs.getString( "INVOICE_ID" ));
invRefDate = checkNull(sdf.format( rs.getTimestamp( "INVOICE_DATE" )));
}
if( rs != null )
rs.close();
rs = null;
if( pstmt != null )
pstmt.close();
pstmt = null;
valueXmlString.append("<invoice_ref>").append("<![CDATA["+ invRefId +"]]>").append("</invoice_ref>");
if(invRefDate != null && invRefDate.trim().length() >0)
{
valueXmlString.append("<inv_ref_date>").append("<![CDATA["+ invRefDate+"]]>").append("</inv_ref_date>");
}
}
}*/
}
// Added By PriyankaC on 14JUNE2018 [END]
valueXmlString.append("</Detail2>");
break;
case 3:
parentNodeList = dom1.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
winName = getObjName(parentNode);
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
ctr = 0; ctr = 0;
...@@ -8324,6 +9067,35 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales ...@@ -8324,6 +9067,35 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
//if(lcQty - (qtyAdj+sdetQtyAdj+domTotalQty) <= 0) //if(lcQty - (qtyAdj+sdetQtyAdj+domTotalQty) <= 0)
//Changed by Santosh on 23/05/2017 to correct condition //Changed by Santosh on 23/05/2017 to correct condition
//if(lcQty > invoiceQty) //if(lcQty > invoiceQty)
//-------------NANDKUMAR GADKARI ON 15/10/18---------------START----------
String docKeyvalue="";
if (docKey.trim().length() > 0) {
/*cnt = 0;
do {
docKeyStr = distCommon.getToken(docKey, ",");
System.out.println( "docKeyStr :: " + docKeyStr );
cnt++;
} while (cnt <5);
System.out.println( "cnt :: " + cnt );*/
String[] docKeyStr = docKey.split(",");
for(int i=0; i<docKeyStr.length; i++)
{
//docKeyvalue = ;
System.out.println( "docKeyStr :: " + docKeyStr[i]);
System.out.println( "docKeyStrlength :: " + docKeyStr.length);
cnt++;
}
System.out.println( "cnt :: " + cnt );
if(cnt !=5)
{
isValidInvoiceId=false;
}
}
//-------------NANDKUMAR GADKARI ON 15/10/18---------------END ----------
if(isValidInvoiceId && (lcQty+(qtyAdj+sdetQtyAdj+domTotalQty)) > invoiceQty) if(isValidInvoiceId && (lcQty+(qtyAdj+sdetQtyAdj+domTotalQty)) > invoiceQty)
{ {
return getError((invoiceQty - (qtyAdj+sdetQtyAdj+domTotalQty)), "VTSPLTQTY", conn); return getError((invoiceQty - (qtyAdj+sdetQtyAdj+domTotalQty)), "VTSPLTQTY", conn);
......
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