Commit fc78e6fc authored by steurwadkar's avatar steurwadkar

Changes to set doc_key for sales return with invoice id ref. and validating if already adjusted


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@43874 ce508802-f39f-4f6c-b175-0d175dae99d5
parent fd22197e
......@@ -3106,20 +3106,22 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
System.out.println("sreturnAdjOpt:::["+sreturnAdjOpt+"]");
if ("M".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " MRH.EFF_COST ";
orderByStr = " ORDER BY MRH.EFF_COST ";
}
else if("E".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " MRH.INVOICE_DATE ASC,MRH.INVOICE_ID ASC ";
orderByStr = " ORDER BY MRH.INVOICE_DATE ASC,MRH.INVOICE_ID ASC ";
}
else if("L".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " MRH.INVOICE_DATE DESC,MRH.INVOICE_ID DESC ";
orderByStr = " ORDER BY MRH.INVOICE_DATE DESC,MRH.INVOICE_ID DESC ";
}
//Changed by Santosh on 10/05/2017 to not set invoice id if SRETURN_ADJ_OPT is not defined
//if(invoiceId == null || invoiceId.trim().length() == 0)
if( (invoiceId == null || invoiceId.trim().length() == 0) && !"NULLFOUND".equalsIgnoreCase(sreturnAdjOpt))
//Changed by Santosh on 23/05/2017 to set rate and doc_key if SRETURN_ADJ_OPT is defined for invoice_id ref case
//if( (invoiceId == null || invoiceId.trim().length() == 0) && !"NULLFOUND".equalsIgnoreCase(sreturnAdjOpt))
if( !"NULLFOUND".equalsIgnoreCase(sreturnAdjOpt))
{
/*int noSchemeHist = 0;
String schemeKey = "", disParmVarValue = "", docKey = "", docValue = "";
......@@ -3229,6 +3231,10 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
rs.close();
rs = null;
}*/
//Added by Santosh on 23/05/2017 to check if invoice_id reference is available in Min_rate_history [Start]
if( checkNull(invoiceId).trim().length() == 0)
{
curFormItemLotHMap.put("cust_code", genericUtility.getColumnValue("cust_code", dom1));
curFormItemLotHMap.put("item_code", itemCode);
curFormItemLotHMap.put("lot_no", lotNo);
......@@ -3252,7 +3258,9 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
+ " 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"
+ " ORDER BY "+orderByStr;
//Changed by Santosh on 23/05/2017 to avoid sql exception if SRETURN_ADJ_OPT value is other than ('E', 'L', 'M')
//+ " ORDER BY "+orderByStr;
+ orderByStr;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemCode);
......@@ -3266,7 +3274,7 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
invoiceQty = checkNull(rs.getString("QUANTITY"));
adjQty = checkNull(rs.getString("QTY_ADJ"));
//Added by Santosh on 16/05/2017
rate = rs.getInt("EFF_COST");
rate = rs.getDouble("EFF_COST");
curRecordItemLotHMap.put("cust_code", checkNull(rs.getString("CUST_CODE")));
curRecordItemLotHMap.put("item_code", checkNull(rs.getString("ITEM_CODE")));
......@@ -3339,6 +3347,36 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
//Commented and changed by Santosh on 16/05/2017 to set invoice id in docKey only [End]
}
}
else if(invoiceId != null && invoiceId.trim().length()>0)
{
minRateDocKey = generateDocKey(dom1, dom, invoiceId, conn);
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())
{
minRateDocKey = checkNull(rs.getString("DOC_KEY"));
rate = rs.getDouble("EFF_COST");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
isMinHisRateSet = true;
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
valueXmlString.append("<doc_key>").append("<![CDATA[" + minRateDocKey + "]]>").append("</doc_key>");
invoiceId = null;
}
//Added by Santosh on 23/05/2017 to check if invoice_id reference is available in Min_rate_history [End]
}
//Added by Santosh on 06/12/2016 to append invoice id to itemChange retStr [End]
infoMap = new HashMap();
iValStr = iValStr == null || iValStr.trim().length() == 0 ? "0" : iValStr.trim();
......@@ -7677,6 +7715,8 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
//Added by Santosh on 10/05/2017
String sreturnAdjOpt = distCommon.getDisparams("999999", "SRETURN_ADJ_OPT", conn);
//Added by Santosh on 23/05/2017
boolean isValidInvoiceId = true;
//Added by Santosh on 02/12/2016 to split quantity in multiple line as per min_rate_history[Start]
//Changed by Santosh on 10/05/2017 to not to validate split quantity if SRETURN_ADJ_OPT is not defined
......@@ -7830,13 +7870,28 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
rs = null;
}
//Added by Santosh on 23/05/2017 to check if enetered inovice id is availbel for salesreturn[Start]
if(lsInvoiceId != null && lsInvoiceId.trim().length()>0)
{
if((qtyAdj+sdetQtyAdj+domTotalQty)>0)
{
errCode = "VTINVADJ";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
isValidInvoiceId = false;
}
}
//Added by Santosh on 23/05/2017 to check if enetered inovice id is availbel for salesreturn[End]
//Changed by Santosh on 17/05/2017
//if(lcQty > (invoiceQty - (qtyAdj+sdetQtyAdj+domTotalQty)))
//Changed by wasim on 17-MAY-17 corrected validation condition
//if(lcQty > (qtyAdj+sdetQtyAdj+domTotalQty))
//Changed by Santosh on 18/05/2017 to correct condition
//if(lcQty - (qtyAdj+sdetQtyAdj+domTotalQty) <= 0)
if(lcQty > invoiceQty)
//Changed by Santosh on 23/05/2017 to correct condition
//if(lcQty > invoiceQty)
if(isValidInvoiceId && (lcQty+(qtyAdj+sdetQtyAdj+domTotalQty)) > invoiceQty)
{
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