Commit be0c131b authored by ngadkari's avatar ngadkari

In sales return Set exp_date ,mfg_Date and Cost_rate from item_lot_info table...

In  sales return Set exp_date ,mfg_Date and Cost_rate from item_lot_info table on lot no item Change and added validation 1. on cost rate column Cost Rate should not be negative or null 2.on lot_no column  if lot no not found in item_lot_info for that item then system not allow to save transaction

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@193141 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1ce580e0
......@@ -17,15 +17,12 @@ import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.sys.UtilMethods;
import java.util.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Date;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import java.text.SimpleDateFormat;
import java.text.DecimalFormat;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
......@@ -3822,8 +3819,31 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
}
quantity = qtyStdUom;
// Changes by Nandkumar Gadkari on 16/11/18------------Start-----------to set the cost rate from item_lot_info table
sql = "select rate "
+ " from item_lot_info "
+ " where item_code = ? "
+ " and lot_no = ? ";
cntItemLotInfo=0;
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, itemCode);
pstmt.setString( 2, lotNo);
rs = pstmt.executeQuery();
if( rs.next() )
{
cntItemLotInfo++;
costRate = rs.getDouble(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if(cntItemLotInfo==0)
{
infoMap.put("ret_repl_flag",retReplFlag);
infoMap.put("item_code", itemCode);
infoMap.put("site_code", siteCode);
......@@ -3833,8 +3853,11 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
infoMap.put("tran_date", tranDate);
infoMap.put("invoice_id", invoiceId);
infoMap.put( "quantity__stduom", new Double( -1 * quantity ) );
costRate = getCostRate(infoMap, conn);
}
infoMap = null;
// Changes by Nandkumar Gadkari on 16/11/18------------end-----------to set the cost rate from item_lot_info table
valueXmlString.append("<cost_rate>").append("<![CDATA[" + costRate + "]]>").append("</cost_rate>");
setNodeValue( dom, "cost_rate", Double.toString( costRate ) );
System.out.println( " invoiceId :1: " + invoiceId );
......@@ -4268,6 +4291,12 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
valueXmlString = minRateBuff;
}
//Changed by Santosh on 16/05/2017 to not to set rate if already set from min_rate_history [End]
//added by nandkumar Gadkari on 16/11/18--------------Start--------to set mfg date an exp date from ite_lot_info
valueXmlString = (gbfIcExpMfgDate(valueXmlString, dom, dom1, dom2, editFlag, xtraParams, objContext,
conn));
//added by nandkumar Gadkari on 16/11/18--------------end--------to set mfg date an exp date from ite_lot_info
System.out.println("lslotsl["+lslotsl+"]");
setNodeValue( dom, "lot_sl",lslotsl);
reStr = itemChanged(dom, dom1, dom2, objContext, "lot_sl", editFlag, xtraParams);
......@@ -4280,6 +4309,10 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
} // end of lot_no
else if (currentColumn.trim().equals("lot_sl") )
{
//added by nandkumar Gadkari on 16/11/18--------------Start--------to set mfg date an exp date from ite_lot_info
valueXmlString = (gbfIcExpMfgDate(valueXmlString, dom, dom1, dom2, editFlag, xtraParams, objContext,
conn));
//added by nandkumar Gadkari on 16/11/18--------------end--------to set mfg date an exp date from ite_lot_info
siteCode = genericUtility.getColumnValue("site_code", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
locCode = genericUtility.getColumnValue("loc_code", dom);
......@@ -4303,7 +4336,6 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
+ " from item_lot_info "
+ " where item_code = ? "
+ " and lot_no = ? ";
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, itemCode);
......@@ -4385,24 +4417,28 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
rs = null;
if (cnt == 0 )
{
valueXmlString.append("<exp_date protect =\"0\">").append("<![CDATA[" + ( expDate != null ? new SimpleDateFormat(genericUtility.getApplDateFormat()).format(expDate).toString() : "" ) + "]]>").append("</exp_date>");
//expDate commented by Nandkumar gadkari on 16/11/18 to set the date from item_lot_info table
//valueXmlString.append("<exp_date protect =\"0\">").append("<![CDATA[" + ( expDate != null ? new SimpleDateFormat(genericUtility.getApplDateFormat()).format(expDate).toString() : "" ) + "]]>").append("</exp_date>");
valueXmlString.append("<pack_code protect =\"0\">").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<site_code__mfg protect =\"0\">").append("<![CDATA[" + siteCodeMfg + "]]>").append("</site_code__mfg>");
}
else
{
//Added & Commented by sarita on 29 JUN 18 [START][if exp_date available against lot_no , lot_sl , item_code and site_code in stock then system should not allow to change exp_date]
if(expDate != null)
/*if(expDate != null)
{
valueXmlString.append("<exp_date protect =\"1\">").append("<![CDATA[" + new SimpleDateFormat(genericUtility.getApplDateFormat()).format(expDate).toString() + "]]>").append("</exp_date>");
}
else
{
valueXmlString.append("<exp_date protect =\"0\">").append("<![CDATA[]]>").append("</exp_date>");
}
}*///expDate commented by Nandkumar gadkari on 16/11/18 to set the date from item_lot_info table
//valueXmlString.append("<exp_date protect =\"0\">").append("<![CDATA[" + ( expDate != null ? new SimpleDateFormat(genericUtility.getApplDateFormat()).format(expDate).toString() : "" ) + "]]>").append("</exp_date>");
//Added & Commented by sarita on 29 JUN 18 [END] [START][if exp_date available against lot_no , lot_sl , item_code and site_code in stock then system should not allow to change exp_date]
valueXmlString.append("<mfg_date protect =\"0\">").append("<![CDATA[" + ( mfgDate != null ? new SimpleDateFormat(genericUtility.getApplDateFormat()).format(mfgDate).toString() : "" ) + "]]>").append("</mfg_date>");
//mfgDate commented by Nandkumar gadkari on 16/11/18 to set the date from item_lot_info table
// valueXmlString.append("<mfg_date protect =\"0\">").append("<![CDATA[" + ( mfgDate != null ? new SimpleDateFormat(genericUtility.getApplDateFormat()).format(mfgDate).toString() : "" ) + "]]>").append("</mfg_date>");
valueXmlString.append("<pack_code protect =\"1\">").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<site_code__mfg protect =\"1\">").append("<![CDATA[" + siteCodeMfg + "]]>").append("</site_code__mfg>");
}
......@@ -6164,7 +6200,31 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
}
quantity = qtyStdUom;
// Changes by Nandkumar Gadkari on 16/11/18------------Start-----------to set the cost rate from item_lot_info table
sql = "select rate "
+ " from item_lot_info "
+ " where item_code = ? "
+ " and lot_no = ? ";
cntItemLotInfo=0;
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, itemCode);
pstmt.setString( 2, lotNo);
rs = pstmt.executeQuery();
if( rs.next() )
{
cntItemLotInfo++;
costRate = rs.getDouble(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if(cntItemLotInfo==0)
{
infoMap.put("ret_repl_flag",retReplFlag);
infoMap.put("item_code", itemCode);
......@@ -6176,7 +6236,9 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
infoMap.put("invoice_id", invoiceId);
infoMap.put( "quantity__stduom", new Double( -1 * quantity ) );
costRate = getCostRate(infoMap, conn);
}
infoMap = null;
// Changes by Nandkumar Gadkari on 16/11/18------------end-----------to set the cost rate from item_lot_info table
valueXmlString.append("<cost_rate>").append("<![CDATA[" + costRate + "]]>").append("</cost_rate>");
setNodeValue( dom, "cost_rate", Double.toString( costRate ) );
System.out.println( " invoiceId :1: " + invoiceId );
......@@ -6602,6 +6664,8 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
valueXmlString = minRateBuff;
}
System.out.println("lslotsl["+lslotsl+"]");
setNodeValue( dom, "lot_sl",lslotsl);
reStr = itemChanged(dom, dom1, dom2, objContext, "lot_sl", editFlag, xtraParams);
......@@ -8723,6 +8787,34 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
errFields.add( childNodeName.toLowerCase() );
}
}
//validation added by Nandkumar gadkari on 19/11/18-------------------------Start---------------------
itemCode = checkNull(genericUtility.getColumnValue( "item_code", dom ));
llCount=0;
sqlStr = "select count(*) ll_count "
+ " from item_lot_info "
+ " where item_code = ? "
+ " and lot_no = ? ";
pstmt = conn.prepareStatement( sqlStr );
pstmt.setString( 1, itemCode );
pstmt.setString( 2, lsLotNo );
rs = pstmt.executeQuery();
if( rs.next() )
{
llCount = rs.getInt( "ll_count" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( llCount == 0 )
{
errCode = "VTIVLOTINF";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
//validation added by Nandkumar gadkari on 19/11/18-------------------------end---------------------
}
}
if( childNodeName.equalsIgnoreCase( "lot_sl" ) )
......@@ -9468,6 +9560,28 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
}
}
}
//validation added by Nandkumar gadkari on 16/11/18-------------------------Start---------------------
else if( childNodeName.equalsIgnoreCase( "cost_rate" ) )
{
String lcRateStr = genericUtility.getColumnValue( "cost_rate", dom );
if(lcRateStr==null || "null".equalsIgnoreCase(lcRateStr.trim()) || lcRateStr.trim().length()==0)
{
errCode = "VTITCOSTR";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
else
{
lcRate = Double.parseDouble( lcRateStr == null || lcRateStr.trim().length() == 0 ? "0" : lcRateStr.trim() );
}
if( lcRate < 0 )
{
errCode = "VTITCOSTR";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
////validation added by Nandkumar gadkari on 16/11/18-------------------------end---------------------
} // end for
break;
......@@ -11196,8 +11310,95 @@ public class SalesReturn extends ValidatorEJB implements SalesReturnLocal, Sales
}
//Added by Santosh on 16/05/2017 to generate minRateDocKey [End]
// added by Nandkumar Gadkari on 16/11/18 ------------------start----------------------------------
private StringBuffer gbfIcExpMfgDate(StringBuffer valueXmlString, Document dom, Document dom1, Document dom2,
String editFlag, String xtraParams, String objContext, Connection conn) {
// TODO Auto-generated method stub
String siteCode = "", itemCode = "",lotNo= "", lotSl= "", sql= "";
PreparedStatement pstmt = null;
Timestamp mfgDate=null,expDate=null;
ResultSet rs = null;
int cntItemLotInfo = 0;
try {
siteCode = genericUtility.getColumnValue("site_code", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
if (lotSl == null || lotSl.equals("null"))
{
lotSl = " ";
}
sql = "select mfg_date, exp_date "
+ " from item_lot_info "
+ " where item_code = ? "
+ " and lot_no = ? ";
cntItemLotInfo=0;
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, itemCode);
pstmt.setString( 2, lotNo);
rs = pstmt.executeQuery();
if( rs.next() )
{
cntItemLotInfo++;
mfgDate = rs.getTimestamp(1);
expDate = rs.getTimestamp(2);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
/*if(cntItemLotInfo==0)
{
sql = "select a.mfg_date, a.exp_date"
+ " from stock a "
+ " where a.item_code = ? "
+ " and a.site_code = ? "
+ " and a.lot_no = ? "
+ " and a.lot_sl = ? ";
pstmt= conn.prepareStatement( sql );
pstmt.setString( 1, itemCode);
pstmt.setString( 2, siteCode);
pstmt.setString( 3, lotNo);
pstmt.setString( 4, lotSl);
rs = pstmt.executeQuery();
if( rs.next() )
{
mfgDate = rs.getTimestamp(1);
expDate = rs.getTimestamp(2);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}*/
if(expDate != null)
{
valueXmlString.append("<exp_date protect =\"1\">").append("<![CDATA[" + new SimpleDateFormat(genericUtility.getApplDateFormat()).format(expDate).toString() + "]]>").append("</exp_date>");
}
else
{
valueXmlString.append("<exp_date protect =\"0\">").append("<![CDATA[]]>").append("</exp_date>");
}
valueXmlString.append("<mfg_date protect =\"0\">").append("<![CDATA[" + ( mfgDate != null ? new SimpleDateFormat(genericUtility.getApplDateFormat()).format(mfgDate).toString() : "" ) + "]]>").append("</mfg_date>");
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return valueXmlString;
}
// added by Nandkumar Gadkari on 16/11/18 ------------------end----------------------------------
}// END OF MAIN CLASS
\ No newline at end of file
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