Commit be29f035 authored by manohar's avatar manohar

Changes to disable calculation if cust_stock_mode is other than S, C and A,...

Changes to disable calculation if cust_stock_mode is other than S, C and A, also change in porcp and transit calculation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91108 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c5e99198
......@@ -1106,7 +1106,7 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
String custCode = null,rSiteCode = null, locCode = null, lotNo = null, lotSl = null, retRepFlag = null;
java.sql.Timestamp preFromDate = null, preToDate = null;
java.sql.Timestamp invFromDate = null, invToDate = null;
ibase.webitm.ejb.sys.UtilMethods utilMethods = null;
try
{
ibase.webitm.utility.GenericUtility genericUtility = ibase.webitm.utility.GenericUtility.getInstance();
......@@ -1639,7 +1639,7 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
stmt = conn.prepareStatement( selQuery );
stmt.setTimestamp( 1, java.sql.Timestamp.valueOf( genericUtility.getValidDateString( columnValue , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" ) );
stmt.setTimestamp( 1, java.sql.Timestamp.valueOf( genericUtility.getValidDateString( columnValue , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" ) );
stmt.setTimestamp( 2, java.sql.Timestamp.valueOf( genericUtility.getValidDateString( columnValue , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" ) );
rs = stmt.executeQuery();
if (rs.next())
{
......@@ -1928,7 +1928,7 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
//// 31/01/09 manoharan commented and aded new code as per ITM
//// 31/01/09 manoharan ITM changes ////////////////////////////////////////////////////////////////////////////////////////////////////
ibase.webitm.ejb.sys.UtilMethods utilMethods = ibase.webitm.ejb.sys.UtilMethods.getInstance();
utilMethods = ibase.webitm.ejb.sys.UtilMethods.getInstance();
custCode = genericUtility.getColumnValue("cust_code" , dom1);
siteCode = genericUtility.getColumnValue("site_code" , dom1);
tranDate = genericUtility.getColumnValue("tran_date" , dom1 );
......@@ -1958,7 +1958,9 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
pstmt.close();
rs = null;
pstmt = null;
//
if ("S".equals(stockMode.trim()) || "A".equals(stockMode.trim()) || "C".equals(stockMode.trim()) )
{
String fromDate = genericUtility.getColumnValue("from_date" , dom1 );
java.sql.Timestamp tsfromDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( fromDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" );
......@@ -2020,22 +2022,22 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
String toDate = genericUtility.getColumnValue("to_date" , dom1 );
java.sql.Timestamp tsToDate = java.sql.Timestamp.valueOf( genericUtility.getValidDateString( toDate , getApplDateFormat() , getDBDateFormat()) + " 00:00:00.000" );
preFromDate = tsFromDate;
preToDate = tsToDate;
//preFromDate = tsFromDate;
//preToDate = tsToDate;
//check if there is record in cust_stock_inv
int custInvCount = 0;
selQuery = " select count( 1 ) cnt "
+" from cust_stock_inv inv "
+" where inv.tran_id = ? "
+" and inv.DLV_FLG = 'Y' "
+" and inv.INVOICE_DATE between ? and ? ";
+" where inv.tran_id = ? ";
// +" and inv.DLV_FLG = 'Y' "
// +" and inv.INVOICE_DATE between ? and ? ";
pstmt = conn.prepareStatement( selQuery );
pstmt.setString( 1, tranId );
pstmt.setTimestamp( 2, invFromDate );
pstmt.setTimestamp( 3, invToDate );
// pstmt.setTimestamp( 2, invFromDate );
// pstmt.setTimestamp( 3, invToDate );
rs = pstmt.executeQuery();
if (rs.next())
{
......@@ -2055,36 +2057,11 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
+ " AND A.CUST_CODE = ? "
+ " AND B.ITEM_CODE = ? "
+ " AND A.TRAN_DATE >= ? AND A.TRAN_DATE <= ? ";
}
else
{
selQuery = "SELECT SUM(B.QUANTITY__STDUOM) PURC_RCP FROM INVOICE A, INVDET B "
+ " WHERE A.INVOICE_ID = B.INVOICE_ID "
+ " AND A.CUST_CODE = ? "
+ " AND B.ITEM_CODE = ? "
+ " AND A.INVOICE_ID IN ( select inv.invoice_id "
+ " from cust_stock_inv inv "
+ " where inv.tran_id = ? "
+ " and inv.DLV_FLG = 'Y' "
+ " and inv.INVOICE_DATE between ? and ? ) ";
}
pstmt = conn.prepareStatement( selQuery );
if ( custInvCount == 0 )
{
pstmt.setString(1,custCode);
pstmt.setString(2,itemCode);
pstmt.setTimestamp(3,tsFromDate);
pstmt.setTimestamp(4,tsToDate);
}
else
{
pstmt.setString( 1, custCode );
pstmt.setString( 2, itemCode );
pstmt.setString( 3, tranId );
pstmt.setTimestamp( 4, invFromDate );
pstmt.setTimestamp( 5, invToDate );
}
rs = pstmt.executeQuery();
if (rs.next())
{
......@@ -2100,6 +2077,82 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
pstmt.close();
rs = null;
pstmt = null;
}
else
{
//selQuery = "SELECT SUM(B.QUANTITY__STDUOM) PURC_RCP FROM INVOICE A, INVDET B "
// + " WHERE A.INVOICE_ID = B.INVOICE_ID "
// + " AND A.CUST_CODE = ? "
// + " AND B.ITEM_CODE = ? "
// + " AND A.INVOICE_ID IN ( select inv.invoice_id "
// + " from cust_stock_inv inv "
// + " where inv.tran_id = ? "
// + " and inv.DLV_FLG = 'Y' "
// + " and inv.INVOICE_DATE between ? and ? ) ";
selQuery = "SELECT SUM(QUANTITY__STDUOM) PURC_RCP FROM INVDET "
+ " where invoice_id in "
+ " (select invoice_id from invoice where cust_code = ? "
+ " and tran_date between ? and ? "
+ " and invoice_id not in ( select invoice_id "
+ " from cust_stock_inv "
+ " where tran_id = ? ) "
+ " ) and item_code = ? ";
pstmt = conn.prepareStatement( selQuery );
pstmt.setString( 1, custCode );
pstmt.setTimestamp( 2, tsFromDate );
pstmt.setTimestamp( 3, tsToDate );
pstmt.setString( 4, tranId );
pstmt.setString( 5, itemCode );
rs = pstmt.executeQuery();
double rcpCur =0, rcpPre = 0, totRcp = 0;
if (rs.next())
{
rcpCur = rs.getDouble("PURC_RCP");
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
selQuery = "SELECT SUM(QUANTITY__STDUOM) PURC_RCP FROM INVDET "
+ " where invoice_id in "
+ " ( select invoice_id "
+ " from cust_stock_inv "
+ " where tran_id = ? "
+ " and DLV_FLG = 'Y' "
+ " and INVOICE_DATE between ? and ? "
+ " union all "
+ " select preinv.invoice_id "
+ " from cust_stock_inv preinv "
+ " where preinv.tran_id = ? "
+ " and preinv.DLV_FLG = 'N' ) "
+ " and item_code = ? ";
pstmt = conn.prepareStatement( selQuery );
pstmt.setString( 1, tranId );
pstmt.setTimestamp( 2, invFromDate );
pstmt.setTimestamp( 3, invToDate );
pstmt.setString( 4, tranIdLast);
pstmt.setString( 5, itemCode );
rs = pstmt.executeQuery();
if (rs.next())
{
rcpPre = rs.getDouble("PURC_RCP");
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
utilMethods = ibase.webitm.ejb.sys.UtilMethods.getInstance();
totRcp = rcpCur + rcpPre;
purcRcp = utilMethods.getReqDecString(totRcp,2);
utilMethods = null;
purReceipt = purcRcp;
valueXmlString.append("<purc_rcp>").append(purcRcp).append("</purc_rcp>\r\n");
}
//System.out.println("purcRcp [" +purcRcp+ "]");
selQuery = "SELECT B.QUANTITY__STDUOM QUANTITY, B.ITEM_CODE ITEM_CODE, "
+ " A.SITE_CODE SITE_CODE, B.LOC_CODE LOC_CODE, "
......@@ -2232,6 +2285,7 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
pstmt = null;
/////End 31/01/09 manoharan ///////////////////////////////////////////////////////////
}
}
else if (currentColumn.trim().equalsIgnoreCase("op_stock"))
{
......@@ -2285,6 +2339,9 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
//genericUtility.serializeDom( dom );
//genericUtility.serializeDom( dom1 );
//genericUtility.serializeDom( dom2 );
if ("S".equals(stockMode.trim()) || "A".equals(stockMode.trim()) || "C".equals(stockMode.trim()) )
{
System.out.println( "This is the changed jar at 08/04/09 2:09 pm" );
DecimalFormat df = new DecimalFormat();
......@@ -2477,6 +2534,8 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
valueXmlString.append("<cl_value>").append(clValue).append("</cl_value>\r\n");
valueXmlString.append("<sales_value>").append(salesValue).append("</sales_value>\r\n");
valueXmlString.append("<pur_value>").append(purValue).append("</pur_value>\r\n");
}
valueXmlString.append("</Detail>\r\n");
break;
}//switch (currentFormNo)
......
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