Commit 73ae6fb0 authored by mjadhav's avatar mjadhav

changes done for quantity calculation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98749 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9984d9de
......@@ -1477,6 +1477,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<sordertype_descr protect='1'>").append("<![CDATA["+orderTypeName+"]]>").append("</sordertype_descr>");
valueXmlString.append("<stmt_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</stmt_date>");
valueXmlString.append("<status>").append("<![CDATA[N]]>").append("</status>");
valueXmlString.append("<prd_code>").append("<![CDATA["+periodDt+"]]>").append("</prd_code>");
valueXmlString.append("<chg_user>").append("<![CDATA["+chgUser+"]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA["+chgTerm+"]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</chg_date>");
......@@ -1503,6 +1504,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<sordertype_descr protect='1'>").append("<![CDATA["+orderTypeName+"]]>").append("</sordertype_descr>");
valueXmlString.append("<stmt_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</stmt_date>");
valueXmlString.append("<status>").append("<![CDATA[N]]>").append("</status>");
valueXmlString.append("<prd_code>").append("<![CDATA["+periodDt+"]]>").append("</prd_code>");
valueXmlString.append("<chg_user>").append("<![CDATA["+chgUser+"]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA["+chgTerm+"]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</chg_date>");
......@@ -1822,6 +1824,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
stockDlvFlg="N";
dlvFlgCnt=0;
// sql= "select dlv_flg from cust_stock_inv where invoice_id=? ";
sql= "select count(*) as count from cust_stock_inv where invoice_id=? and dlv_flg='Y' ";
pstmt2 = conn.prepareStatement(sql);
......@@ -1836,7 +1839,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
rs2 = null;
pstmt2.close();
pstmt2 = null;
System.out.println("dlvFlgCnt >>>>"+dlvFlgCnt);
System.out.println("dlvFlgCnt ####"+dlvFlgCnt);
//if(!(stockDlvFlg.equalsIgnoreCase("Y")))
if(dlvFlgCnt == 0)
......@@ -2036,8 +2039,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
todate = genericUtility.getColumnValue("to_date",dom2);
//todate = sdf.format(currentDate).toString();
System.out.println("todate (case 4):"+todate);
tranDateStr=sdf.format(currentDate).toString();
tranDate=java.sql.Timestamp.valueOf(genericUtility.getValidDateString(tranDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");;
//tranDateStr=sdf.format(currentDate).toString();
//tranDate=java.sql.Timestamp.valueOf(genericUtility.getValidDateString(tranDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");;
/*---calculate previous month from input value period,start---*/
......@@ -2046,7 +2049,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("frmDateTstmp :"+frmDateTstmp);
toDateTstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(todate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("toDateTstmp :"+toDateTstmp);
tranDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(tranDateHd, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDate :"+tranDate);
prdFrom = getPreviousDate(frmDateTstmp,conn);
System.out.println("prdFrom :"+prdFrom);
......@@ -2150,7 +2154,10 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("-------calculate Receipt quantity for availble transcaion Id--------");
receiptLast=0.0;
//receiptLast = GetRcpQty(selectedInvList,itemCodeLast,conn);
receiptLast = GetRcpQty(custCodeHd,itemCodeLast,itemSerHd,orderType,siteCodeHd,frmDateTstmp,toDateTstmp,conn);
//receiptLast = GetRcpQty(custCodeHd,itemCodeLast,itemSerHd,orderType,siteCodeHd,frmDateTstmp,toDateTstmp,conn);
receiptLast = GetRcpQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCodeLast,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("Receipt quantity cal for avaible transcation id :"+receiptLast);
//rcpBonLast = GetRcpBonQty(selectedInvList,itemCodeLast,conn) ;
......@@ -2158,7 +2165,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("-------calculate Receipt Frees quantity for availble transcaion Id--------");
rcpFreesLast=0.0;
//rcpFreesLast=GetFreeQty(selectedInvList,itemCodeLast,conn);
rcpFreesLast = GetFreeQty(custCodeHd,itemCodeLast,itemSerHd,orderType,frmDateTstmp,toDateTstmp,conn);
//rcpFreesLast = GetFreeQty(custCodeHd,itemCodeLast,itemSerHd,orderType,frmDateTstmp,toDateTstmp,conn);
rcpFreesLast = GetFreeQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCodeLast,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("rcpFreesLast :"+rcpFreesLast);
......@@ -2175,12 +2183,12 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("-------calculate Transit quantity for availble transcaion Id--------");
transitQty=0.0;
transitQty=GetTransitQty(tranIdLast,itemCodeLast,conn);
//transitQty=GetTransitQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCodeLast,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
//transitQty=GetTransitQty(tranIdLast,itemCodeLast,conn);
transitQty=GetTransitQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCodeLast,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("transitQty quantity cal for avaible transcation id :"+transitQty);
System.out.println("receiptLast :"+receiptLast);
System.out.println("transitQty :"+transitQty);
totReceiptLast=receiptLast + transitQty;
//totReceiptLast=receiptLast + transitQty;
System.out.println("totReceiptLast :"+totReceiptLast);
// transitQtyBonLast=GetTransitBon(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCodeLast,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
......@@ -2191,7 +2199,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("transitQtyFreesLast :"+transitQtyFreesLast);
////getRate(String custCode, Timestamp fromDate,Timestamp toDate, String itemCode,String siteCode,String itemSer,String orderType,Connection conn)
System.out.println("tranDate :"+tranDate);
System.out.println("-------calculate Rate for availble transcaion Id--------");
rateLast=0.0;
rateLast = getRate(custCodeHd,tranDate,itemCodeLast,conn);
......@@ -2394,7 +2402,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<rate>").append("<![CDATA["+rateLast+"]]>").append("</rate>");
valueXmlString.append("<op_stock protect='1'>").append("<![CDATA["+opStockLast+"]]>").append("</op_stock>");
valueXmlString.append("<purc_rcp>").append("<![CDATA["+totReceiptLast+"]]>").append("</purc_rcp>");
valueXmlString.append("<purc_rcp>").append("<![CDATA["+receiptLast+"]]>").append("</purc_rcp>");
valueXmlString.append("<purc_rcp__repl>").append("<![CDATA["+rcpFreesLast+"]]>").append("</purc_rcp__repl>");
valueXmlString.append("<purc_rcp__free>").append("<![CDATA[0.0]]>").append("</purc_rcp__free>");
......@@ -2411,6 +2419,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<transit_qty__repl>").append("<![CDATA["+transitQtyFreesLast+"]]>").append("</transit_qty__repl>");
valueXmlString.append("<transit_qty__free>").append("<![CDATA[0.0]]>").append("</transit_qty__free>");
valueXmlString.append("<primary_sales>").append("<![CDATA["+primarySales+"]]>").append("</primary_sales>");
valueXmlString.append("<chg_user>").append("<![CDATA["+chgUser+"]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA["+chgTerm+"]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</chg_date>");
valueXmlString.append("</Detail4>");
System.out.println("Detail4 cal for avaible transcation id :"+valueXmlString);
......@@ -2441,16 +2452,16 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("FromDate form 3 : "+FromDate);*/
tranDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(tranDateHd, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
//frmDateTstmp=FromDate;
//toDateTstmp=ToDate;
orderDtTstmp=java.sql.Timestamp.valueOf(genericUtility.getValidDateString(tranDateHd, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
// String custCode, String itemSer,String siteCode, String orderType,java.sql.Timestamp frmDateTstmp, java.sql.Timestamp toDateTstmp,java.sql.Timestamp prdFrDateTstmp, java.sql.Timestamp prdToDateTstmp,String lastTranId,String newTranId,String selectedInvList, Connection conn
System.out.println("------retrive Item data which is not exist in last month or current moth transcation !!!!");
defData = getItemFromCust(custCodeHd,itemSerHd,tranIdLast,tranIdNew,selectedInvList,conn);
defData = getItemFromCust(custCodeHd,itemSerHd,siteCodeHd,orderType,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,tranIdLast,tranIdNew,selectedInvList,conn);
itemResLen = defData.size();
......@@ -2522,7 +2533,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
// rcpQty = GetRcpQty(selectedInvList,itemCode,conn);
System.out.println("frmDateTstmp :"+frmDateTstmp);
System.out.println("toDateTstmp :"+toDateTstmp);
rcpQty = GetRcpQty(custCodeHd,itemCode,itemSerHd,orderType,siteCodeHd,frmDateTstmp,toDateTstmp,conn);
//rcpQty = GetRcpQty(custCodeHd,itemCode,itemSerHd,orderType,siteCodeHd,frmDateTstmp,toDateTstmp,conn);
rcpQty = GetRcpQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCode,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("Receipt quantity for not available in last or current tranaction"+"itemCode :"+itemCode +"Receipt Quantity :"+rcpQty);
// rcpQtyBon = GetRcpFreeQty( custCodeHd,tranIdLast,orderType,prdFrmDateTstmp, toDateTstmp,itemCode,itemSerHd, conn) ;
// System.out.println("rcpQtyBon :"+rcpQtyBon);
......@@ -2532,7 +2545,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("-- calculate Recipt Frees quantity which is not available for last or current month transcation !!!");
rcpFreesAll=0.0;
//rcpFreesAll = GetFreeQty(selectedInvList,itemCode,conn) ;
rcpFreesAll = GetFreeQty(custCodeHd,itemCode,itemSerHd,orderType,frmDateTstmp,toDateTstmp,conn);
//rcpFreesAll = GetFreeQty(custCodeHd,itemCode,itemSerHd,orderType,frmDateTstmp,toDateTstmp,conn);
rcpFreesAll = GetFreeQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCode,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("rcpFreesAll :"+rcpFreesAll);
// sretQty = GetRetQty(custCodeHd,frmDateTstmp,toDateTstmp,itemCode,siteCodeHd,itemSerHd,conn);
......@@ -2662,8 +2676,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("--calculate Transit Quantoty which is not included for current or previous month transcation------");
transitQty=0.0;
transitQty=GetTransitQty(tranIdLast,itemCode,conn);
//transitQty=GetTransitQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCode,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
//transitQty=GetTransitQty(tranIdLast,itemCode,conn);
transitQty=GetTransitQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCode,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("Transit quantity for not available in last or current tranaction"+"itemCode :"+itemCode +"Transit Quantity :"+transitQty);
//transitQtyBon=0.0;
......@@ -2680,7 +2694,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("transitQty :"+transitQty);
totRcpQtyAll =rcpQty + transitQty;
System.out.println("totRcpQtyAll :"+totRcpQtyAll);
System.out.println("tranDate :"+tranDate);
rateAll=0.0;
rateAll = getRate(custCodeHd,tranDate,itemCode,conn);
System.out.println("rateAll :"+rateAll);
......@@ -2694,7 +2708,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
itemMap.put("mlType@"+lineNoItmCnt, locTypeItem);
itemMap.put("mopStk@"+lineNoItmCnt, String.valueOf(opStkItem));
//itemMap.put("mopStk@"+lineNoItmCnt, String.valueOf(opStkItem));
itemMap.put("mquantRcp@"+lineNoItmCnt, String.valueOf(totRcpQtyAll));
itemMap.put("mquantRcp@"+lineNoItmCnt, String.valueOf(rcpQty));
itemMap.put("rcpQtyBon@"+lineNoItmCnt, String.valueOf(rcpBonAll));
itemMap.put("rcpFreesAll@"+lineNoItmCnt, String.valueOf(rcpFreesAll));
itemMap.put("mquant@"+lineNoItmCnt, String.valueOf(sretQtyAllTot));
......@@ -2752,7 +2766,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<item_ser>").append("<![CDATA["+itemMap.get("mItemSer@"+itemDomId)+"]]>").append("</item_ser>");
valueXmlString.append("<descr>").append("<![CDATA["+itemMap.get("mDescr@"+itemDomId)+"]]>").append("</descr>");
valueXmlString.append("<unit>").append("<![CDATA["+itemMap.get("mUnit@"+itemDomId)+"]]>").append("</unit>");
//valueXmlString.append("<loc_type>").append("<![CDATA["+itemMap.get("mlType@"+i)+"]]>").append("</loc_type>");
valueXmlString.append("<loc_type>").append("<![CDATA["+itemMap.get("mlType@"+itemDomId)+"]]>").append("</loc_type>");
valueXmlString.append("<rate>").append("<![CDATA["+itemMap.get("rate@"+itemDomId)+"]]>").append("</rate>");
valueXmlString.append("<op_stock protect='1'>").append("<![CDATA["+itemMap.get("mopStk@"+itemDomId)+"]]>").append("</op_stock>");
valueXmlString.append("<cl_stock protect='0'>").append("<![CDATA["+itemMap.get("mopStk@"+itemDomId)+"]]>").append("</cl_stock>");
......@@ -2770,6 +2784,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<transit_qty>").append("<![CDATA["+itemMap.get("transitQty@"+itemDomId)+"]]>").append("</transit_qty>");
valueXmlString.append("<transit_qty__free>").append("<![CDATA[0.0]]>").append("</transit_qty__free>");
valueXmlString.append("<transit_qty__repl>").append("<![CDATA["+itemMap.get("transitQtyFrees@"+itemDomId)+"]]>").append("</transit_qty__repl>");
valueXmlString.append("<chg_user>").append("<![CDATA["+chgUser+"]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA["+chgTerm+"]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</chg_date>");
valueXmlString.append("<primary_sales>").append("<![CDATA["+itemMap.get("primarySales@"+itemDomId)+"]]>").append("</primary_sales>");
valueXmlString.append("</Detail4>");
......@@ -2894,7 +2911,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
PreparedStatement pstmt = null;
ResultSet rs = null;
String priceList = "",selQuery="";
java.sql.Timestamp invTranDate = null,retTranDate=null,tranDate=null;
java.sql.Timestamp invTranDate = null,retTranDate=null;
double rate = 0.0;
try
{
......@@ -2912,6 +2929,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
pstmt.close();
pstmt = null;
System.out.println("trandate :"+trandate);
selQuery = "select max(rate) as rate from pricelist " +
" where price_list = ? and " +
......@@ -2922,8 +2940,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
pstmt = conn.prepareStatement(selQuery);
pstmt.setString( 1, priceList );
pstmt.setString( 2, itemCode );
pstmt.setTimestamp(3,tranDate);
pstmt.setTimestamp(4,tranDate);
pstmt.setTimestamp(3,trandate);
pstmt.setTimestamp(4,trandate);
rs = pstmt.executeQuery( );
if( rs.next() )
{
......@@ -3024,7 +3042,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
}
return invoiceListString ;
}
/*private double GetTransitQty(String custCode, String orderType, String itemSer,String siteCode,String selectedInvList,String itenmCode,java.sql.Timestamp fromDate, java.sql.Timestamp toDate,java.sql.Timestamp prdFrom, java.sql.Timestamp prdTo, Connection conn) throws Exception
private double GetTransitQty(String custCode, String orderType, String itemSer,String siteCode,String selectedInvList,String itenmCode,java.sql.Timestamp fromDate, java.sql.Timestamp toDate,java.sql.Timestamp prdFrom, java.sql.Timestamp prdTo, Connection conn) throws Exception
{
NodeList parentNodeList=null;
NodeList childList = null;
......@@ -3126,11 +3144,11 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
return transitQty ;
}
*/
/*
private double GetTransitQty(String tranId, String itemCode, Connection conn) throws Exception
{
NodeList parentNodeList=null;
......@@ -3184,7 +3202,7 @@ private double GetTransitQty(String tranId, String itemCode, Connection conn) th
}
*/
......@@ -3570,7 +3588,7 @@ private double GetTransitQty(String tranId, String itemCode, Connection conn) th
//private double GetRcpQty(String custCode,String tranIdLast,String orderType,String selectedInvList, java.sql.Timestamp fromDate, java.sql.Timestamp toDate,String itemCode,String itemSer, Connection conn) throws Exception
/*
private double GetRcpQty(String custCode,String itemCode,String itemSer,String orderType,String siteCode, java.sql.Timestamp fromDate, java.sql.Timestamp toDate,Connection conn) throws Exception
{
String invoiceId="",selQuery="";
......@@ -3630,9 +3648,97 @@ private double GetRcpQty(String custCode,String itemCode,String itemSer,String o
}
return rcpQuantity ;
}
*/
/*---------------------------------------------------------------------------------------------*/
private double GetRcpQty(String custCode, String orderType, String itemSer,String siteCode,String selectedInvList,String itenmCode,java.sql.Timestamp fromDate, java.sql.Timestamp toDate,java.sql.Timestamp prdFrom, java.sql.Timestamp prdTo, Connection conn) throws Exception
{
NodeList parentNodeList=null;
NodeList childList = null;
Node parentNode=null;
Node childNode = null;
String invoiceId = null;
String dlvFlg = null ;
double rcpQuantity = 0, quantity = 0,dlvFlgTransit=0;
PreparedStatement pstmt = null,pstmt2 = null;
ResultSet rs = null,rs2 = null;
String sql = null;
String stockDlvFlg="";
try
{
System.out.println("calculate receipt quantity!!!!!!!!!!");
sql = " select idet.QUANTITY__STDUOM,idet.invoice_id,idet.item_code from " +
"invdet idet where idet.item_code= ? and idet.invoice_id in " +
" ( SELECT distinct invoice.invoice_id invoice_id FROM invoice invoice WHERE " +
" ( invoice.cust_code = ? ) and invoice.site_code =? and invoice.inv_type=? " +
" and invoice.item_ser=? and ( invoice.confirmed = 'Y' ) " +
"and ( (invoice.tran_date >=?) and (invoice.tran_date <= ? ) " +
"or ((invoice.tran_date >=? ) and (invoice.tran_date <= ? ) ) and(exists (SELECT cust_stock_inv.invoice_id " +
" FROM cust_stock_inv cust_stock_inv WHERE cust_stock_inv.invoice_id = invoice.invoice_id and " +
" cust_stock_inv.dlv_flg = 'N' )) ) " +
"UNION " +
" SELECT distinct cinv.invoice_id FROM CUST_STOCK_INV cinv , " +
" invoice invoice WHERE cinv.invoice_id=invoice.invoice_id and invoice.cust_code = ? " +
" and invoice.item_ser= ? and invoice.confirmed = 'Y' and " +
"CASE WHEN cinv.dlv_flg IS NULL THEN 'N' ELSE cinv.dlv_flg END='N' ) " ;
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, itenmCode);
pstmt.setString(2, custCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, orderType);
pstmt.setString(5, itemSer);
pstmt.setTimestamp(6, fromDate );
pstmt.setTimestamp(7, toDate );
pstmt.setTimestamp(8, prdFrom );
pstmt.setTimestamp(9, prdTo );
pstmt.setString(10, custCode );
pstmt.setString(11, itemSer);
rs = pstmt.executeQuery();
while( rs.next() )
{
invoiceId = rs.getString("invoice_id");
quantity = rs.getDouble("QUANTITY__STDUOM");
System.out.println("inv qty :"+quantity);
rcpQuantity = rcpQuantity + quantity;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception exception)
{
exception.printStackTrace();
//System.out.println("Exception ::" + exception.getMessage());
throw new ITMException( exception );
}
System.out.println("rcpQuantity :"+rcpQuantity);
return rcpQuantity ;
}
/*------------------------------------------------------------------------------------------------*/
/*private double GetRcpQty(String selectedInvList,String itemCode, Connection conn) throws Exception
{
String invoiceId="";
......@@ -3834,7 +3940,7 @@ private double GetRcpQty(String custCode,String itemCode,String itemSer,String o
}*/
/*
private double GetFreeQty(String custCode,String itemCode,String itemSer,String orderType, java.sql.Timestamp fromDate, java.sql.Timestamp toDate,Connection conn) throws Exception
{
String invoiceId="",nature="";
......@@ -3917,6 +4023,146 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
return freesQty ;
}
*/
private double GetFreeQty(String custCode, String orderType, String itemSer,String siteCode,String selectedInvList,String itemCode,java.sql.Timestamp fromDate, java.sql.Timestamp toDate,java.sql.Timestamp prdFrom, java.sql.Timestamp prdTo, Connection conn) throws Exception
{
NodeList parentNodeList=null;
NodeList childList = null;
Node parentNode=null;
Node childNode = null;
String invoiceId = null;
String dlvFlg = null ;
double transitQty = 0, quantity = 0,dlvFlgTransit=0;
PreparedStatement pstmt = null,pstmt2 = null,pstmt3 = null;
ResultSet rs = null,rs2 = null,rs3 = null;
String sql = null;
String stockDlvFlg="";
String invoiceIdArray[];
String invoiceSep="",nature="";
double freesQty=0.0;
try
{
// transit quantity for those which are included in period also for dlv flag 'N'
System.out.println("----calculate Transit Frees Quantity------------------");
sql = " select idet.QUANTITY__STDUOM,idet.invoice_id,idet.item_code from " +
"invdet idet where idet.item_code= ? and idet.invoice_id in " +
" ( SELECT distinct invoice.invoice_id invoice_id FROM invoice invoice WHERE " +
" ( invoice.cust_code = ? ) and invoice.site_code =? and invoice.inv_type=? " +
" and invoice.item_ser=? and ( invoice.confirmed = 'Y' ) " +
"and ( (invoice.tran_date >=?) and (invoice.tran_date <= ? ) " +
"or ((invoice.tran_date >=? ) and (invoice.tran_date <= ? ) ) and(exists (SELECT cust_stock_inv.invoice_id " +
" FROM cust_stock_inv cust_stock_inv WHERE cust_stock_inv.invoice_id = invoice.invoice_id and " +
" cust_stock_inv.dlv_flg = 'N' )) ) " +
"UNION " +
" SELECT distinct cinv.invoice_id FROM CUST_STOCK_INV cinv , " +
" invoice invoice WHERE cinv.invoice_id=invoice.invoice_id and invoice.cust_code = ? " +
" and invoice.item_ser= ? and invoice.confirmed = 'Y' and " +
"CASE WHEN cinv.dlv_flg IS NULL THEN 'N' ELSE cinv.dlv_flg END='N' ) " ;
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, itemCode);
pstmt.setString(2, custCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, orderType);
pstmt.setString(5, itemSer);
pstmt.setTimestamp(6, fromDate );
pstmt.setTimestamp(7, toDate );
pstmt.setTimestamp(8, prdFrom );
pstmt.setTimestamp(9, prdTo );
pstmt.setString(10, custCode );
pstmt.setString(11, itemSer);
rs = pstmt.executeQuery();
while( rs.next() )
{
invoiceId = rs.getString("invoice_id");
System.out.println("invoiceId :"+invoiceId);
//if(!(stockDlvFlg.equalsIgnoreCase("Y")))
/*if(dlvFlgTransit == 0)
{*/
/*System.out.println("transit invoice :"+invoiceId);
quantity = rs.getDouble("QUANTITY__STDUOM");
System.out.println("inv qty :"+quantity);
transitQty = transitQty + quantity;*/
/* if(selectedInvList.trim().length() > 0)
{
invoiceIdArray = selectedInvList.split(",");
*/
/*for (int i = 0; i < invoiceIdArray.length ;i++)
{
System.out.println(invoiceIdArray[i]);
invoiceSep = invoiceIdArray[i];
invoiceId = invoiceSep.replace("'", "");
System.out.println(invoiceId);*/
sql = "select nature,quantity__stduom from sorddet where sale_order " +
" =(select sale_order from invoice where invoice_id=?) and item_code=?";
pstmt3 = conn.prepareStatement( sql );
pstmt3.setString(1,invoiceId );
pstmt3.setString(2,itemCode );
rs3 = pstmt3.executeQuery();
while( rs3.next() )
{
quantity = rs3.getDouble("quantity__stduom");
nature=rs3.getString("nature");
System.out.println("nature :"+nature);
if(nature.equalsIgnoreCase("F"))
{
freesQty = freesQty + quantity;
System.out.println(freesQty);
}
}
rs3.close();
rs3 = null;
pstmt3.close();
pstmt3 = null;
//}
//}
//}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception exception)
{
exception.printStackTrace();
//System.out.println("Exception ::" + exception.getMessage());
throw new ITMException( exception );
}
System.out.println("transitFreesQty for transit :"+freesQty);
return freesQty ;
}
......@@ -4428,7 +4674,7 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
private ArrayList getItemFromCust( String custCode, String itemSer, String lastTranId,String newTranId,String selectedInvList, Connection conn )
private ArrayList getItemFromCust( String custCode, String itemSer,String siteCode, String orderType,java.sql.Timestamp frmDateTstmp, java.sql.Timestamp toDateTstmp,java.sql.Timestamp prdFrDateTstmp, java.sql.Timestamp prdToDateTstmp,String lastTranId,String newTranId,String selectedInvList, Connection conn )
{
long llCount = 0, llRowNum = 0;
String lsErrCode = null, lsCode = null, lsDescr = null, lsUnit = null, lsLocType = null,lsOpStock=null,
......@@ -4519,17 +4765,52 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
pstmt = null;
/*------------List if Item which are generated for new invoice for new itemcode----------------*/
System.out.println("--List if Item which are generated for new invoice for new itemcode-----");
System.out.println("------List if Item which are generated for new invoice for new itemcode-----");
/*sql = "select item_code from invdet where " +
"invoice_id in ("+selectedInvList+") ";*/
sql = "select distinct item_code from invdet where " +
" invoice_id in( SELECT distinct invoice.invoice_id invoice_id " +
" FROM invoice invoice WHERE ( invoice.cust_code = ? )" +
" and invoice.site_code =? and invoice.inv_type=? and " +
"invoice.item_ser=? and ( invoice.confirmed = 'Y' ) and" +
" ( (invoice.tran_date >=?) and (invoice.tran_date <= ? ) " +
"or ((invoice.tran_date >=? ) and (invoice.tran_date <= ? ) ) " +
"and(exists (SELECT cust_stock_inv.invoice_id FROM cust_stock_inv cust_stock_inv " +
" WHERE cust_stock_inv.invoice_id = invoice.invoice_id and " +
" cust_stock_inv.dlv_flg = 'N' )) ) " +
" UNION " +
" SELECT distinct cinv.invoice_id FROM CUST_STOCK_INV cinv ," +
" invoice invoice WHERE cinv.invoice_id=invoice.invoice_id and " +
" invoice.cust_code = ? and invoice.item_ser= ? " +
"and invoice.confirmed = 'Y' and CASE WHEN cinv.dlv_flg IS NULL " +
"THEN 'N' ELSE cinv.dlv_flg END='N')";
sql = "select item_code from invdet where " +
"invoice_id in ("+selectedInvList+") ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, custCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, orderType);
pstmt.setString(4, itemSer);
pstmt.setTimestamp(5, frmDateTstmp);
pstmt.setTimestamp(6, toDateTstmp);
pstmt.setTimestamp(7, prdFrDateTstmp);
pstmt.setTimestamp(8, prdToDateTstmp);
pstmt.setString(9, custCode);
pstmt.setString(10, itemSer);
rs = pstmt.executeQuery();
while( rs.next() )
{
invItemCode=rs.getString("item_code");
System.out.println("invItemCode :"+invItemCode);
System.out.println("invItemCode other than cust_stock_det :"+invItemCode);
if(!(itemList.contains(invItemCode)))
{
......
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