Commit f0b8dfca authored by nsawalakhe's avatar nsawalakhe

changes in SQL for BILL status


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98738 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8937a130
package ibase.dashboard.ssc.ejb;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
......@@ -8,16 +7,14 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
/**
* Session Bean implementation class SalesPersonSales
......
......@@ -8,7 +8,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
......@@ -42,16 +42,21 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
try
{
if(loginCode!=null && loginCode.trim().length()>0)
{
gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
convrtToTimStmDate = new SimpleDateFormat(genericUtility.getDBDateFormat());
System.out.println(" Inside PendingPurcOrder for getPendingPO Method Data Soruc Name ="+dataSourceName+" loginCode is =" + loginCode);
System.out.println(" Inside PendingPurcOrder for getPendingPO Method Data Soruc Name ="+dataSourceName+" loginCode comming from seesion =" + loginCode);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
int count = 0;
sql = " select m.tran_id,m.tran_date, m.net_amt,m.ref_no,m. bank_code,b.bank_name from misc_payment m inner join bank b on m.bank_code=b.bank_code " +
" where Rownum <= 5 and m.sundry_type = 'S'and m.net_amt>0 " +
" and m.sundry_code in (select entity_code from entity_contact where entity_type = 'S' and User_id__portal = '"+loginCode+"' ) "+
" and m.sundry_code in (select entity_code from entity_contact where entity_type = 'S' " +
" and User_id__portal = '"+loginCode+"' ) "+
" and tran_date >= (select fr_date from acctprd where to_date(sysdate) " +
" between fr_date and to_date) and confirmed = 'Y'order by tran_date desc ";
......@@ -77,6 +82,9 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
......@@ -123,7 +131,10 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
try
{
System.out.println(" Inside PendingPurcOrderEJB for getPOValueData Method Data Soruc Name ="+dataSourceName+" logincode is =" + loginCode);
System.out.println(" Inside PendingPurcOrderEJB for getPOValueData Method Data Soruc Name ="+dataSourceName+" logincode comming from session =" + loginCode);
if(loginCode!=null && loginCode.trim().length()>0)
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
......@@ -131,7 +142,8 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
" from porder where ORD_DATE >= (SELECT ADD_MONTHS(SYSDATE,-5) FROM DUAL ) "+
" and case when confirmed is null then 'N' else confirmed end = 'Y' "+
" and case when status is null then 'O' else status end <> 'X' "+
" and supp_code in (select entity_code from entity_contact where entity_type = 'S' and User_id__portal ='"+loginCode+"')"+
" and supp_code in (select entity_code from entity_contact where entity_type = 'S' " +
" and User_id__portal ='"+loginCode+"')"+
" group by to_char(ORD_DATE, 'MON-YY') ,to_char(ORD_DATE,'MMYY') "+
" order by to_char(ORD_DATE,'MMYY') asc ";
pstmt = conn.prepareStatement(sql);
......@@ -147,6 +159,7 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
......@@ -179,63 +192,120 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
}
@SuppressWarnings("unchecked")
public JSONObject getPendingInvoice(String loginCode, String dataSourceName) throws RemoteException, ITMException
public JSONObject getPendingInvoice(String loginCode,String fromDate,String toDate, String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataPOValueDet = new JSONObject();
JSONObject rawDataPendingInvoice = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
Calendar calendar=null;
String currentDate="";
String varValue="";
String[] lotNoList=null;
try
{
System.out.println(" Inside PendingPurcOrder for getPendingInvoice Method Data Soruc Name ="+dataSourceName+" logincode is =" + loginCode);
System.out.println(" Inside PendingPurcOrder for getPendingInvoice Method Data Soruc Name ="+dataSourceName+" logincode is =" + loginCode+"fromDate==="+fromDate+"ToDate==="+toDate);
if(loginCode!=null && loginCode.trim().length()>0)
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
sql = " select o.purc_order,o.ord_date, o.tot_amt, sum(r.amount) as receipt, " +
" t.descr as warehouse from porder o, porcp r, site s, station t " +
" where r.purc_order = o.purc_order and s.site_code = o.site_code__dlv " +
" and t.stan_code = s.stan_code and not exists (select b.bill_no " +
" from supplier_bill b where b.porder_no = o.purc_order " +
" and (b.bill_no = r.dc_no or b.bill_no = r.invoice_no)) " +
" and o.supp_code in (select entity_code from entity_contact " +
" where entity_type = 'S' and User_id__portal = '"+loginCode+"')" +
" and case when o.confirmed is null then 'N' else o.confirmed end = 'Y' " +
" and case when o.status is null then 'O' else o.status end not in ('X','C')" +
" group by t.descr,o.purc_order,o.ord_date, o.tot_amt ";
// This is old sql for pending invoice detail.Changes by Birendra Pandey on dated :13/10/2015
sql ="select var_value from disparm where prd_code = '999999' and var_name = 'BILL_STATUS_REAS'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
String ord_date="";
gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
convrtToTimStmDate = new SimpleDateFormat(genericUtility.getDBDateFormat());
while (rs.next())
if (rs.next())
{
rowData = new JSONObject();
rowData.put("purc_order", checkNull(rs.getString("purc_order")));
ord_date = checkNull(rs.getString("ord_date"));
if(ord_date.trim().length()>0)
varValue = rs.getString("var_value");
}
System.out.println(" Inside PendingPurcOrder for getPendingInvoice Method Data var_value ="+varValue);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
String lotNoIssueTemp = "";
if (varValue != null && varValue.trim().length() > 0)
{
lotNoList = varValue.split(",");
varValue = "";
for(int ctr = 0;ctr < lotNoList.length;ctr++)
{
rowData.put("ord_date", gridDateFormat.format((convrtToTimStmDate.parse(ord_date))));
lotNoIssueTemp = lotNoList[ctr];
if (varValue.trim().length() > 0)
{
varValue = varValue + ",'".concat(lotNoIssueTemp).concat("'");
}
else
{
rowData.put("ord_date",checkNull(rs.getString("ord_date")));
varValue = varValue + "'".concat(lotNoIssueTemp).concat("'");
}
rowData.put("tot_amt", rs.getDouble("tot_amt"));
rowData.put("receipt", checkNull (rs.getString("receipt")));
rowData.put("warehouse", checkNull(rs.getString("warehouse")));
rawDataPOValueDet.put(count, rowData);
}
}
System.out.println("varValue after ["+varValue + "]");
//SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMM-yyyy");
if((fromDate==null) ||(fromDate.equals("")) && (toDate==null) || (toDate.equals("")))
{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
calendar = Calendar.getInstance();
currentDate = simpleDateFormat.format(calendar.getTime());
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
toDate = simpleDateFormat.format(calendar.getTime());
calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
fromDate = simpleDateFormat.format(calendar.getTime());
System.out.println("get default date ,when user not entering date from GUI:"+"currentDate="+currentDate+"fromDate="+fromDate+"toDate="+toDate);
}
// end date utility block
/*sql= " SELECT SB.SUPP_CODE , S.SUPP_NAME , SUM(Case When SB.Reas_Codes IN ("+varValue+") " +
" Then 1 else 0 end ) as Hard_Copy_Not_Recd, SUM(Case When SB.Status !='Y' And SB.Voucher_No Is Null And SB.Reas_Codes Is Null Then 1 else 0 end) as In_Process, SUM( case when (select count(1) from misc_paydet where TRAN_SER = 'VOUCH' and VOUCH_NO = SB.Voucher_No ) = 0 then 1 else 0 end ) as Complete FROM SUPPLIER_BILL SB INNER JOIN SUPPLIER S ON S.SUPP_CODE = SB.SUPP_CODE " +
" WHERE TO_CHAR(SB.TRAN_DATE,'DD/MM/YY') >= '"+fromDate+"'" +
" AND TO_CHAR(SB.TRAN_DATE,'DD/MM/YY') <= '"+toDate+"' " +
" AND SB.supp_code in (select entity_code from entity_contact WHERE ENTITY_TYPE = 'S'" +
" AND USER_ID__PORTAL = 'CPATIL') " +
" GROUP BY SB.SUPP_CODE,S.SUPP_NAME " +
" ORDER BY S.SUPP_NAME ";*/
sql = "SELECT SB.SUPP_CODE , S.SUPP_NAME , SUM(CASE WHEN SB.REAS_CODES IN ("+varValue+") " +
"THEN 1 ELSE 0 END ) AS HARD_COPY_NOT_RECD, " +
"SUM(CASE WHEN SB.STATUS !='Y' And SB.Voucher_No Is Null And SB.Reas_Codes Is Null Then 1 else 0 end) as In_Process, " +
"SUM( case when (select count(1) FROM MISC_PAYDET WHERE TRAN_SER in ('VOUCH','P-IBCA','P-IBC1','P-IBC2','P-IBC3') AND VOUCH_NO = SB.VOUCHER_NO ) = 0 THEN 1 ELSE 0 END ) AS COMPLETE " +
"FROM SUPPLIER_BILL SB INNER JOIN SUPPLIER S ON S.SUPP_CODE = SB.SUPP_CODE " +
"WHERE TO_CHAR(SB.TRAN_DATE,'DD/MM/YY') >= '"+fromDate+"' " +
"AND TO_CHAR(SB.TRAN_DATE,'DD/MM/YY') <= '"+toDate+"' " +
"AND SB.SUPP_CODE IN (SELECT ENTITY_CODE FROM ENTITY_CONTACT WHERE ENTITY_TYPE = 'S' " +
"AND USER_ID__PORTAL = '"+loginCode+"') " +
"GROUP BY SB.SUPP_CODE,S.SUPP_NAME ORDER BY S.SUPP_NAME ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
rowData.put("supplier_code", checkNull (rs.getString("SUPP_CODE")));
rowData.put("supplier_name", checkNull (rs.getString("SUPP_NAME")));
rowData.put("hard_copy_not_recd", checkNull (rs.getString("HARD_COPY_NOT_RECD")));
rowData.put("in_process", checkNull (rs.getString("In_Process")));
rowData.put("complete", checkNull (rs.getString("COMPLETE")));
rawDataPendingInvoice.put(count, rowData);
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
......@@ -264,7 +334,7 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
throw new ITMException(d);
}
}
return rawDataPOValueDet;
return rawDataPendingInvoice;
}
//POOrderSummary Method
@SuppressWarnings("unchecked")
......@@ -277,11 +347,13 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String processOrder="",completed="",open="";
//String processOrder="",completed="",open="";
try
{
gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
convrtToTimStmDate = new SimpleDateFormat(genericUtility.getDBDateFormat());
if(loginCode!=null && loginCode.trim().length()>0)
{
System.out.println(" Inside PendingPurcOrder for getPendingPOSummary Method Data Soruc Name ="+dataSourceName+" loginCode is =" + loginCode);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
......@@ -290,7 +362,8 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
+" from porder where ORD_DATE >= (SELECT ADD_MONTHS(SYSDATE,-5) FROM DUAL ) "
+" and case when confirmed is null then 'N' else confirmed end = 'N' "
+" and case when status is null then 'O' else status end not in ('X','C') "
+" and supp_code in (select entity_code from entity_contact where entity_type = 'S' and User_id__portal = '"+loginCode+"') ";
+" and supp_code in (select entity_code from entity_contact where entity_type = 'S' "
+" and User_id__portal = '"+loginCode+"') ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
......@@ -312,7 +385,8 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
+" from porder where ORD_DATE >= (SELECT ADD_MONTHS(SYSDATE,-5) FROM DUAL ) "
+" and case when confirmed is null then 'N' else confirmed end = 'Y' "
+" and case when status is null then 'O' else status end = 'C' "
+" and supp_code in (select entity_code from entity_contact where entity_type = 'S' and User_id__portal = '"+loginCode+"') ";
+" and supp_code in (select entity_code from entity_contact where entity_type = 'S' "
+"and User_id__portal = '"+loginCode+"') ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
......@@ -333,7 +407,8 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
+" from porder where ORD_DATE >= (SELECT ADD_MONTHS(SYSDATE,-5) FROM DUAL ) "
+" and case when confirmed is null then 'N' else confirmed end = 'Y' "
+" and case when status is null then 'O' else status end not in ('X','C') "
+" and supp_code in (select entity_code from entity_contact where entity_type = 'S' and User_id__portal = '"+loginCode+"' ) ";
+" and supp_code in (select entity_code from entity_contact where entity_type = 'S'"
+" and User_id__portal = '"+loginCode+"' ) ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
......@@ -346,8 +421,8 @@ public class PendingPurcOrder extends ValidatorEJB implements PendingPurcOrderRe
rawDataPaymentDet.put(count, rowData);
count++;
}
}
}//close if block
}//close try block
catch (Exception e)
{
e.printStackTrace();
......
......@@ -16,7 +16,7 @@ public interface PendingPurcOrderLocal extends ValidatorLocal
public JSONObject getPendingPO(String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingPOValue(String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingInvoice(String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingInvoice(String loginCode,String frmdate,String todate, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingPOSummary(String prdCode, String dataSourceName) throws RemoteException, ITMException;
}
......@@ -16,7 +16,7 @@ public interface PendingPurcOrderRemote extends ValidatorRemote
public JSONObject getPendingPO(String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingPOValue(String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingInvoice(String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingInvoice(String loginCode,String frmdate,String todate, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingPOSummary(String prdCode, String dataSourceName) throws RemoteException, ITMException;
}
......@@ -30,6 +30,8 @@ public class PendingInvoiceServlet extends HttpServlet
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String loginId = "";
String fromDate = "";
String toDate = "";
try
{
......@@ -38,24 +40,22 @@ public class PendingInvoiceServlet extends HttpServlet
HttpSession session = request.getSession(true);
ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
loginId = userInfo.getLoginCode();
/*if(loginId==null ||loginId=="" )
{
loginId="CPATIL";
}*/
dataSourceName =request.getParameter("dataSourceName");
System.out.println( "loginId is =" + loginId );
fromDate =request.getParameter("fromDate");
toDate =request.getParameter("toDate");
System.out.println( "login code comming from session =" + loginId );
context = new InitialContext(appConnectParm.getProperty());
pendingPurcOrdRemote = (PendingPurcOrderRemote)context.lookup("ibase/PendingPurcOrder/remote");
JSONObject jsonObjData = (JSONObject)pendingPurcOrdRemote.getPendingInvoice(loginId,dataSourceName);
JSONObject jsonObjData = (JSONObject)pendingPurcOrdRemote.getPendingInvoice(loginId,fromDate,toDate, dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for PendingInvoiceServlet build the Graph is===" + jsonObjData);
System.out.println(" Final data set for PendingInvoiceServlet build for Graph ===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : PendingInvoiceServlet :" + e);
System.out.println("Exception : PendingInvoiceServlet :" + e.getMessage());
try
{
throw new ITMException(e);
......
......@@ -45,18 +45,16 @@ public class PendingPOServlet extends HttpServlet
System.out.println( "loginId is =" + loginId );
context = new InitialContext(appConnectParm.getProperty());
pendingPurcOrderRemote = (PendingPurcOrderRemote)context.lookup("ibase/PendingPurcOrder/remote");
//JSONObject jsonObjData = (JSONObject)pendingPurcOrderRemote.getLastFivePaymentsDetail(loginId,dataSourceName);
JSONObject jsonObjData = (JSONObject)pendingPurcOrderRemote.getPendingPO(loginId,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for PendingPurcOrderServlet build the Graph is===" + jsonObjData);
System.out.println(" Final data set for PendingPOServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : PendingPurcOrderServlet :" + e);
System.out.println("Exception : PendingPOServlet :" + e.getMessage());
try
{
throw new ITMException(e);
......
......@@ -44,22 +44,20 @@ public class PendingPOSummaryServlet extends HttpServlet
loginId="CPATIL";
}*/
dataSourceName =request.getParameter("dataSourceName");
System.out.println( "loginId is =" + loginId );
context = new InitialContext(appConnectParm.getProperty());
custInfoRemote = (PendingPurcOrderRemote)context.lookup("ibase/PendingPurcOrder/remote");
//JSONObject jsonObjData = (JSONObject)custInfoRemote.getPOrderSummary(loginId,dataSourceName);
JSONObject jsonObjData = (JSONObject)custInfoRemote.getPendingPOSummary(loginId,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for POrderSummaryServlet build the Graph is===" + jsonObjData);
System.out.println(" Final data set for PendingPOSummaryServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : POrderSummaryServlet :" + e);
System.out.println("Exception : PendingPOSummaryServlet :" + e.getMessage());
try
{
throw new ITMException(e);
......
......@@ -48,17 +48,16 @@ public class PendingPOValueServlet extends HttpServlet
context = new InitialContext(appConnectParm.getProperty());
pendingPurcOrderRemote = (PendingPurcOrderRemote)context.lookup("ibase/PendingPurcOrder/remote");
//JSONObject jsonObjData = (JSONObject)pendingPurcOrderRemote.getPOValueDetail(loginId,dataSourceName);
JSONObject jsonObjData = (JSONObject)pendingPurcOrderRemote.getPendingPOValue(loginId,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for PendingPurcOrderValServlet build the Graph is===" + jsonObjData);
System.out.println(" Final data set for PendingPOValueServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : PendingPurcOrderValServlet :" + e);
System.out.println("Exception : PendingPOValueServlet :" + e.getMessage());
try
{
throw new ITMException(e);
......
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