Commit db70d2fc authored by caluka's avatar caluka

CAL_CRIT_ITEMSER disparam itemseries condition added for quantity and bonus


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@103387 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 10afa757
...@@ -2764,8 +2764,47 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2764,8 +2764,47 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
} }
System.out.println("FromDate case3 :"+FromDate); System.out.println("FromDate case2 :"+FromDate);
System.out.println("ToDate case 3:"+ToDate); System.out.println("ToDate case 2:"+ToDate);
//Start added by chandrashekar on 19-Sep-2016
loginEmpCode= genericUtility.getColumnValue("emp_code", dom1);
System.out.println("loginEmpCode>>>"+loginEmpCode);
calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn);
System.out.println("calCriItemSerStr.." + calCriItemSerStr);
if (("NULLFOUND".equalsIgnoreCase(calCriItemSerStr) || calCriItemSerStr == null || calCriItemSerStr.trim().length() == 0) )
{
isItemSer=false;
}else
{
ArrayList calCriItemSerList=new ArrayList();
String[] arrStr =calCriItemSerStr.split(",");
int len =arrStr.length;
for(int i =0;i<len;i++)
{
calCriItemSerList.add(arrStr[i].trim());
}
sql= "select item_ser from sales_pers where sales_pers=?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, loginEmpCode );
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
salesItemSer=checkNull(rs1.getString("item_ser")).trim();
System.out.println("salesItemSer >>> :"+salesItemSer);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if(calCriItemSerList.contains(salesItemSer.trim()))
{
isItemSer=true;
}
}
System.out.println("isItemSer@@@@@@@>>>>"+isItemSer);
//End added by chandrashekar on 19-Sep-2016
sql= " SELECT TRAN_ID FROM CUST_STOCK WHERE CUST_CODE = ? AND status ='O' " + sql= " SELECT TRAN_ID FROM CUST_STOCK WHERE CUST_CODE = ? AND status ='O' " +
" AND ITEM_SER = ? and order_type=? and from_date =? and to_date = ?"; " AND ITEM_SER = ? and order_type=? and from_date =? and to_date = ?";
...@@ -2903,11 +2942,19 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2903,11 +2942,19 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
{ {
sql= "select SUM(sdet.eff_net_amt) as net_amt from sreturn srn,sreturndet sdet,item itm" + sql= "select SUM(sdet.eff_net_amt) as net_amt from sreturn srn,sreturndet sdet,item itm" +
" where srn.tran_id=sdet.tran_id and sdet.item_code=itm.item_code " + " where srn.tran_id=sdet.tran_id and sdet.item_code=itm.item_code " +
" and ( itm.item_ser in ("+resultItemSer+") OR((itm.item_ser,itm.ITEM_CODE) " + //" and ( itm.item_ser in ("+resultItemSer+") OR((itm.item_ser,itm.ITEM_CODE) " +
" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+"))) )" + //" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+"))) )" +
" and srn.tran_date >= ? and srn.tran_date <= ? " + " and srn.tran_date >= ? and srn.tran_date <= ? " +
" and sdet.ret_rep_flag in ('R','P') and srn.cust_code=? " + " and sdet.ret_rep_flag in ('R','P') and srn.cust_code=? " +
" and srn.confirmed='Y' and sdet.tran_id =? "; " and srn.confirmed='Y' and sdet.tran_id =? ";
if(isItemSer)
{
sql=sql+" and ( itm.item_ser in ("+resultItemSer+") OR((itm.item_ser,itm.ITEM_CODE) " +
" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+"))) )" ;
}else
{
sql=sql+" and ( itm.item_ser in ("+resultItemSer+")) ";
}
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setTimestamp(1, FromDate); pstmt1.setTimestamp(1, FromDate);
pstmt1.setTimestamp(2, ToDate); pstmt1.setTimestamp(2, ToDate);
...@@ -3078,13 +3125,21 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3078,13 +3125,21 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
sql = " SELECT distinct invoice.invoice_id invoice_id, " + sql = " SELECT distinct invoice.invoice_id invoice_id, " +
" invoice.tran_date as invoice_date ,'N' as DLV_FLG ,invoice.net_amt,'' as tran_id " + " invoice.tran_date as invoice_date ,'N' as DLV_FLG ,invoice.net_amt,'' as tran_id " +
" FROM invoice invoice,invoice_trace itrace WHERE invoice.invoice_id=itrace.invoice_id " + " FROM invoice invoice,invoice_trace itrace WHERE invoice.invoice_id=itrace.invoice_id " +
" and ( invoice.cust_code = ? ) " + " and ( invoice.cust_code = ? ) " ;
//"and invoice.site_code =? " + //"and invoice.site_code =? " +
//"and invoice.inv_type=?" + //"and invoice.inv_type=?" +
//" and itrace.item_ser__prom in ("+resultItemSer+") " + //" and itrace.item_ser__prom in ("+resultItemSer+") " +
" and( itrace.item_ser__prom in ("+resultItemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) " + if(isItemSer)
" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+") )) ) "+ {
" and ( invoice.confirmed = 'Y' ) and ( (invoice.tran_date >= ? ) " + sql =sql+" and( itrace.item_ser__prom in ("+resultItemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) " +
" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+") )) ) ";
}else
{
sql =sql+" and( itrace.item_ser__prom in ("+resultItemSer+")) ";
}
//" and( itrace.item_ser__prom in ("+resultItemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) " +
//" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+") )) ) "+
sql=sql+" and ( invoice.confirmed = 'Y' ) and ( (invoice.tran_date >= ? ) " +
" and (invoice.tran_date <= ? ) or " + " and (invoice.tran_date <= ? ) or " +
" ((invoice.tran_date >= ? ) and (invoice.tran_date <= ? ) ) " + " ((invoice.tran_date >= ? ) and (invoice.tran_date <= ? ) ) " +
" and(exists (SELECT cust_stock_inv.invoice_id FROM cust_stock_inv cust_stock_inv " + " and(exists (SELECT cust_stock_inv.invoice_id FROM cust_stock_inv cust_stock_inv " +
...@@ -3095,20 +3150,37 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3095,20 +3150,37 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
" cinv.INVOICE_DATE,cinv.DLV_FLG ,cinv.net_amt ,'' as tran_id FROM CUST_STOCK_INV cinv , " + " cinv.INVOICE_DATE,cinv.DLV_FLG ,cinv.net_amt ,'' as tran_id FROM CUST_STOCK_INV cinv , " +
" invoice invoice,invoice_trace itrace WHERE cinv.invoice_id=invoice.invoice_id and " + " invoice invoice,invoice_trace itrace WHERE cinv.invoice_id=invoice.invoice_id and " +
" itrace.invoice_id=cinv.invoice_id and " + " itrace.invoice_id=cinv.invoice_id and " +
" invoice.cust_code = ? and itrace.item_ser__prom in ("+resultItemSer+") " + " invoice.cust_code = ? " ;
if(isItemSer)
{
sql =sql+" and( itrace.item_ser__prom in ("+resultItemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) " +
" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+") )) ) ";
}else
{
sql =sql+" and( itrace.item_ser__prom in ("+resultItemSer+")) ";
}
//" and itrace.item_ser__prom in ("+resultItemSer+") " +
//" and invoice.inv_type=? " + //" and invoice.inv_type=? " +
" and invoice.confirmed = 'Y'" + sql=sql+" and invoice.confirmed = 'Y'" +
" and CASE WHEN cinv.dlv_flg IS NULL THEN 'N' ELSE cinv.dlv_flg END='N' "+ " and CASE WHEN cinv.dlv_flg IS NULL THEN 'N' ELSE cinv.dlv_flg END='N' "+
" UNION "+ " UNION "+
"select '' as invoice_id ,srn.tran_date,'N' as DLV_FLG,srn.net_amt,sdet.tran_id as tran_id " + "select '' as invoice_id ,srn.tran_date,'N' as DLV_FLG,srn.net_amt,sdet.tran_id as tran_id " +
"from sreturn srn,sreturndet sdet,item itm where srn.tran_id=sdet.tran_id " + "from sreturn srn,sreturndet sdet,item itm where srn.tran_id=sdet.tran_id " +
//"and srn.site_code= ? " + //"and srn.site_code= ? " +
//"and srn.item_ser in ("+resultItemSer+") " + //"and srn.item_ser in ("+resultItemSer+") " +
" and sdet.item_code=itm.item_code "+ " and sdet.item_code=itm.item_code ";
//"and itm.item_ser in ("+resultItemSer+") " + //"and itm.item_ser in ("+resultItemSer+") " +
" and ( itm.item_ser in ("+resultItemSer+") OR((itm.item_ser,itm.ITEM_CODE) " + if(isItemSer)
" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+"))) ) "+ {
"and srn.tran_date >= ? and srn.tran_date <= ? " + sql=sql+" and ( itm.item_ser in ("+resultItemSer+") OR((itm.item_ser,itm.ITEM_CODE) " +
" IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+"))) ) ";
}else
{
sql=sql+" and ( itm.item_ser in ("+resultItemSer+")) ";
}
// " and ( itm.item_ser in ("+resultItemSer+") OR((itm.item_ser,itm.ITEM_CODE) " +
// " IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN ("+resultItemSer+"))) ) "+
sql=sql+"and srn.tran_date >= ? and srn.tran_date <= ? " +
"and sdet.ret_rep_flag in ('R','P') and srn.cust_code=? and srn.confirmed='Y' ORDER BY invoice_date"; "and sdet.ret_rep_flag in ('R','P') and srn.cust_code=? and srn.confirmed='Y' ORDER BY invoice_date";
...@@ -3236,11 +3308,19 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3236,11 +3308,19 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
sql = "select SUM(sdet.eff_net_amt) as net_amt from sreturn srn,sreturndet sdet,item itm" sql = "select SUM(sdet.eff_net_amt) as net_amt from sreturn srn,sreturndet sdet,item itm"
+ " where srn.tran_id=sdet.tran_id and sdet.item_code=itm.item_code " + " where srn.tran_id=sdet.tran_id and sdet.item_code=itm.item_code "
+ " and ( itm.item_ser in (" + resultItemSer + ") OR((itm.item_ser,itm.ITEM_CODE) " //+ " and ( itm.item_ser in (" + resultItemSer + ") OR((itm.item_ser,itm.ITEM_CODE) "
+ " IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN (" + resultItemSer + "))) )" //+ " IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN (" + resultItemSer + "))) )"
+ " and srn.tran_date >= ? and srn.tran_date <= ? " + " and srn.tran_date >= ? and srn.tran_date <= ? "
+ " and sdet.ret_rep_flag in ('R','P') and srn.cust_code=? " + " and sdet.ret_rep_flag in ('R','P') and srn.cust_code=? "
+ " and srn.confirmed='Y' and sdet.tran_id =? "; + " and srn.confirmed='Y' and sdet.tran_id =? ";
if(isItemSer)
{
sql=sql+ " and ( itm.item_ser in (" + resultItemSer + ") OR((itm.item_ser,itm.ITEM_CODE) "
+ " IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN (" + resultItemSer + "))) ) " ;
}else
{
sql=sql+" and ( itm.item_ser in (" + resultItemSer + ")) ";
}
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setTimestamp(1, FromDate); pstmt1.setTimestamp(1, FromDate);
pstmt1.setTimestamp(2, ToDate); pstmt1.setTimestamp(2, ToDate);
...@@ -3522,7 +3602,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3522,7 +3602,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("todate (case 3):"+todate); System.out.println("todate (case 3):"+todate);
loginEmpCode = genericUtility.getColumnValue("emp_code",dom1); loginEmpCode = genericUtility.getColumnValue("emp_code",dom1);
System.out.println("loginEmpCode (case 3):"+loginEmpCode); System.out.println("loginEmpCode (case 3):"+loginEmpCode);
/*
//Start added by chandrashekar on 29-mar-2016 //Start added by chandrashekar on 29-mar-2016
calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn); calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn);
System.out.println("calCriItemSerStr.." + calCriItemSerStr); System.out.println("calCriItemSerStr.." + calCriItemSerStr);
...@@ -3531,6 +3611,14 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3531,6 +3611,14 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
isItemSer=false; isItemSer=false;
}else }else
{ {
ArrayList calCriItemSerList=new ArrayList();
String[] arrStr =calCriItemSerStr.split(",");
int len =arrStr.length;
for(int i =0;i<len;i++)
{
calCriItemSerList.add(arrStr[i].trim());
}
sql= "select item_ser from sales_pers where sales_pers=?"; sql= "select item_ser from sales_pers where sales_pers=?";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, loginEmpCode ); pstmt1.setString(1, loginEmpCode );
...@@ -3545,6 +3633,11 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3545,6 +3633,11 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
pstmt1.close(); pstmt1.close();
pstmt1 = null; pstmt1 = null;
if(calCriItemSerList.contains(salesItemSer.trim()))
{
isItemSer=true;
}
if(calCriItemSerStr.trim().equalsIgnoreCase(salesItemSer.trim())) if(calCriItemSerStr.trim().equalsIgnoreCase(salesItemSer.trim()))
{ {
isItemSer=true; isItemSer=true;
...@@ -3552,6 +3645,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3552,6 +3645,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
} }
System.out.println("isItemSer@@@@@@@>>>>"+isItemSer); System.out.println("isItemSer@@@@@@@>>>>"+isItemSer);
//End added by chandrashekar on 29-mar-2016 //End added by chandrashekar on 29-mar-2016
*/
editFlag = (editFlag != null) ? editFlag : genericUtility.getColumnValue("edit_status", dom1); editFlag = (editFlag != null) ? editFlag : genericUtility.getColumnValue("edit_status", dom1);
System.out.println("editFlag case 3>>>>"+editFlag); System.out.println("editFlag case 3>>>>"+editFlag);
...@@ -7301,11 +7395,18 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -7301,11 +7395,18 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
sql = "select distinct item_code,descr from(SELECT distinct invoice.invoice_id invoice_id," + sql = "select distinct item_code,descr from(SELECT distinct invoice.invoice_id invoice_id," +
"item.item_code,item.descr descr FROM invoice invoice ," + "item.item_code,item.descr descr FROM invoice invoice ," +
"invoice_trace itrace,item item WHERE invoice.invoice_id=itrace.invoice_id and " + "invoice_trace itrace,item item WHERE invoice.invoice_id=itrace.invoice_id and " +
"itrace.item_code=item.item_code and invoice.cust_code = ? " + "itrace.item_code=item.item_code and invoice.cust_code = ? " ;
//" and invoice.site_code =? " + //" and invoice.site_code =? " +
//"and invoice.inv_type=? " + //"and invoice.inv_type=? " +
" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) )" + if(isItemSer)
" and ( invoice.confirmed = 'Y' ) and" + {
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) )" ;
}else
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+")) ";
}
//" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) )" +
sql=sql+" and ( invoice.confirmed = 'Y' ) and" +
" ( (invoice.tran_date >=?) and (invoice.tran_date <= ? ) " + " ( (invoice.tran_date >=?) and (invoice.tran_date <= ? ) " +
"or ((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,invoice invoice " + "and(exists (SELECT cust_stock_inv.invoice_id FROM cust_stock_inv cust_stock_inv,invoice invoice " +
...@@ -7315,10 +7416,17 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -7315,10 +7416,17 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
" SELECT distinct cinv.invoice_id,item.item_code,item.descr descr FROM CUST_STOCK_INV cinv ," + " SELECT distinct cinv.invoice_id,item.item_code,item.descr descr FROM CUST_STOCK_INV cinv ," +
" invoice invoice,invoice_trace invtrace ,item item WHERE cinv.invoice_id=invoice.invoice_id " + " invoice invoice,invoice_trace invtrace ,item item WHERE cinv.invoice_id=invoice.invoice_id " +
" and invtrace.invoice_id=cinv.invoice_id and " + " and invtrace.invoice_id=cinv.invoice_id and " +
" invoice.cust_code = ? and invtrace.item_code=item.item_code " + " invoice.cust_code = ? and invtrace.item_code=item.item_code " ;
if(isItemSer)
{
sql=sql+" and ( invtrace.item_ser__prom in ("+itemSer+") OR((invtrace.item_ser__prom,invtrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) )" ;
}else
{
sql=sql+" and ( invtrace.item_ser__prom in ("+itemSer+")) ";
}
//" and invoice.inv_type = ? " + //" and invoice.inv_type = ? " +
" and invtrace.item_ser__prom in ("+itemSer+") " + //" and invtrace.item_ser__prom in ("+itemSer+") " +
"and invoice.confirmed = 'Y' and CASE WHEN cinv.dlv_flg IS NULL " + sql=sql+" and invoice.confirmed = 'Y' and CASE WHEN cinv.dlv_flg IS NULL " +
"THEN 'N' ELSE cinv.dlv_flg END='N') " + "THEN 'N' ELSE cinv.dlv_flg END='N') " +
"UNION "+ "UNION "+
"select distinct sdet.item_code,item.descr as descr " + "select distinct sdet.item_code,item.descr as descr " +
...@@ -7328,9 +7436,16 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -7328,9 +7436,16 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
//"and srn.site_code= ? " + //"and srn.site_code= ? " +
//" and srn.item_ser in ("+itemSer+") " + //" and srn.item_ser in ("+itemSer+") " +
"and srn.tran_date >= ? " + "and srn.tran_date >= ? " +
"and srn.tran_date <= ? and srn.confirmed='Y' " + "and srn.tran_date <= ? and srn.confirmed='Y' " ;
"and ( item.item_ser in ("+itemSer+") OR((item.item_ser,item.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " + if(isItemSer)
"and sdet.ret_rep_flag in('R','P') " + {
sql=sql+" and ( item.item_ser in ("+itemSer+") OR((item.item_ser,item.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ;
}else
{
sql=sql+" and ( item.item_ser in ("+itemSer+")) ";
}
//"and ( item.item_ser in ("+itemSer+") OR((item.item_ser,item.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " +
sql=sql+" and sdet.ret_rep_flag in('R','P') " +
"and srn.cust_code=? "; "and srn.cust_code=? ";
...@@ -8131,22 +8246,35 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -8131,22 +8246,35 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
//" and invoice.site_code = ? " + //" and invoice.site_code = ? " +
//" and invoice.inv_type=? " + //" and invoice.inv_type=? " +
//" and itrace.item_ser__prom in("+itemSer+") "+ //" and itrace.item_ser__prom in("+itemSer+") "+
" and ( itrace.item_ser__prom in("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) "+ //" and ( itrace.item_ser__prom in("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) "+
//" and invoice.tran_date between ? and ? " + //" and invoice.tran_date between ? and ? " +
" AND itrace.RATE__STDUOM>0.001 " " AND itrace.RATE__STDUOM>0.001 "
+ " and itrace.item_code = ? and itrace.invoice_id in("+selectedInvList+") " ; + " and itrace.item_code = ? and itrace.invoice_id in("+selectedInvList+") " ;
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) ";
}else
{
sql=sql+" and itrace.item_ser__prom in("+itemSer+") ";
}
}else if("T".equalsIgnoreCase(quantityFlag)) }else if("T".equalsIgnoreCase(quantityFlag))
{ {
sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" + sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" +
" invoice invoice,invoice_trace itrace " + " invoice invoice,invoice_trace itrace " +
" where invoice.invoice_id=itrace.invoice_id AND invoice.cust_code = ? " + " where invoice.invoice_id=itrace.invoice_id AND invoice.cust_code = ? "
//" and invoice.site_code = ? " + //" and invoice.site_code = ? " +
//" and invoice.inv_type=? " + //" and invoice.inv_type=? " +
" and ( itrace.item_ser__prom in("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " // +" and ( itrace.item_ser__prom in("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) "
+ //" and invoice.tran_date between ? and ? " + + //" and invoice.tran_date between ? and ? " +
" AND itrace.RATE__STDUOM>0.001 " " AND itrace.RATE__STDUOM>0.001 "
+ " and itrace.item_code = ? and itrace.invoice_id in("+transitInvList+") " ; + " and itrace.item_code = ? and itrace.invoice_id in("+transitInvList+") " ;
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) ";
}else
{
sql=sql+" and itrace.item_ser__prom in("+itemSer+") ";
}
} }
pstmt = conn.prepareStatement( sql ); pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, custCode ); pstmt.setString( 1, custCode );
...@@ -8318,11 +8446,18 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -8318,11 +8446,18 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
+ " AND A.CUST_CODE = ? " + " AND A.CUST_CODE = ? "
+ " AND A.TRAN_DATE >= ? " + " AND A.TRAN_DATE >= ? "
+ " AND A.TRAN_DATE <= ? " + " AND A.TRAN_DATE <= ? "
+ " AND B.ITEM_CODE = ? " + " AND B.ITEM_CODE = ? ";
//+ " AND A.SITE_CODE = ? " //+ " AND A.SITE_CODE = ? "
//+" and a.item_ser in ("+itemSer+") "; //+" and a.item_ser in ("+itemSer+") ";
//+ " and ( A.item_ser in ("+itemSer+") OR((A.item_ser,B.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ; //+ " and ( A.item_ser in ("+itemSer+") OR((A.item_ser,B.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ;
+ " and ( ITEM.item_ser in ("+itemSer+") OR((ITEM.item_ser,B.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ; if(isItemSer)
{
sql=sql+" and ( ITEM.item_ser in ("+itemSer+") OR((ITEM.item_ser,B.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ;
}else
{
sql=sql+" and ( ITEM.item_ser in ("+itemSer+"))";
}
//+ " and ( ITEM.item_ser in ("+itemSer+") OR((ITEM.item_ser,B.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode); pstmt.setString(1,custCode);
pstmt.setTimestamp(2,fromDate ); pstmt.setTimestamp(2,fromDate );
...@@ -8464,25 +8599,39 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -8464,25 +8599,39 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
{ {
sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" + sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" +
" invoice invoice,invoice_trace itrace " + " invoice invoice,invoice_trace itrace " +
" where invoice.invoice_id=itrace.invoice_id AND invoice.cust_code = ? " + " where invoice.invoice_id=itrace.invoice_id AND invoice.cust_code = ? "
//" and invoice.site_code = ? " + //" and invoice.site_code = ? " +
//" and invoice.inv_type=? " + //" and invoice.inv_type=? " +
" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " //" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) "
+ " and invoice.tran_date between ? and ? AND itrace.RATE__STDUOM>0 " + " and invoice.tran_date between ? and ? AND itrace.RATE__STDUOM>0 "
+ " and itrace.item_code = ? and itrace.invoice_id in("+selectedInvList+") " ; + " and itrace.item_code = ? and itrace.invoice_id in("+selectedInvList+") " ;
// "group by itrace.RATE__STDUOM "; // "group by itrace.RATE__STDUOM ";
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) ";
}else
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+"))";
}
}else if("T".equalsIgnoreCase(quantityFlag)) }else if("T".equalsIgnoreCase(quantityFlag))
{ {
sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" + sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" +
" invoice invoice,invoice_trace itrace " + " invoice invoice,invoice_trace itrace " +
" where invoice.invoice_id=itrace.invoice_id AND invoice.cust_code = ? " + " where invoice.invoice_id=itrace.invoice_id AND invoice.cust_code = ? "
//" and invoice.site_code = ? " + //" and invoice.site_code = ? " +
//" and invoice.inv_type=? " + //" and invoice.inv_type=? " +
" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " //" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) "
+ " and invoice.tran_date between ? and ? AND itrace.RATE__STDUOM>0 " + " and invoice.tran_date between ? and ? AND itrace.RATE__STDUOM>0 "
+ " and itrace.item_code = ? and itrace.invoice_id in("+transitInvList+") " ; + " and itrace.item_code = ? and itrace.invoice_id in("+transitInvList+") " ;
// "group by itrace.RATE__STDUOM "; // "group by itrace.RATE__STDUOM ";
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) ";
}else
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+"))";
}
} }
/*sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" + /*sql = " SELECT (itrace.QUANTITY__STDUOM) QUANTITY__STDUOM, itrace.RATE__STDUOM RATE__STDUOM FROM" +
...@@ -8557,15 +8706,32 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -8557,15 +8706,32 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
" (select invoice_id,sum(quantity) totfreeQty,sum(rate),sum(quantity)*sum(rate) as totFreeValue " + " (select invoice_id,sum(quantity) totfreeQty,sum(rate),sum(quantity)*sum(rate) as totFreeValue " +
"from ( select invoice.invoice_id as invoice_id,0 quantity, max(rate__stduom) " + "from ( select invoice.invoice_id as invoice_id,0 quantity, max(rate__stduom) " +
"rate from invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id " + "rate from invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id " +
"and invoice.invoice_id in("+selectedInvList+") and item_code='"+itemCode+"' and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " + "and invoice.invoice_id in("+selectedInvList+") and item_code='"+itemCode+"' " ;
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ;
}else
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+"))";
}
//" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " +
//" and invoice.inv_type='"+orderType+"' " + //" and invoice.inv_type='"+orderType+"' " +
" and rate__stduom>0.001 group by invoice.invoice_id " + sql=sql+" and rate__stduom>0.001 group by invoice.invoice_id " +
"union all" + "union all" +
" select invoice.invoice_id as invoice_id,quantity__stduom quantity, 0 rate from " + " select invoice.invoice_id as invoice_id,quantity__stduom quantity, 0 rate from " +
"invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id and " + "invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id and " +
"invoice.invoice_id in("+selectedInvList+") and item_code='"+itemCode+"' and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " + "invoice.invoice_id in("+selectedInvList+") and item_code='"+itemCode+"' " ;
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) ";
}else
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+"))";
}
//" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " +
//" and invoice.inv_type='"+orderType+"' " + //" and invoice.inv_type='"+orderType+"' " +
" and rate__stduom<=0.001 ) group by invoice_id ) HAVING sum(totFreeValue) >0 AND sum(totfreeQty)>0 " ; sql=sql+" and rate__stduom<=0.001 ) group by invoice_id ) HAVING sum(totFreeValue) >0 AND sum(totfreeQty)>0 " ;
}else if("T".equalsIgnoreCase(quantityFlag)) }else if("T".equalsIgnoreCase(quantityFlag))
{ {
...@@ -8574,15 +8740,31 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String ...@@ -8574,15 +8740,31 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
" (select invoice_id,sum(quantity) totfreeQty,sum(rate),sum(quantity)*sum(rate) as totFreeValue " + " (select invoice_id,sum(quantity) totfreeQty,sum(rate),sum(quantity)*sum(rate) as totFreeValue " +
"from ( select invoice.invoice_id as invoice_id,0 quantity, max(rate__stduom) " + "from ( select invoice.invoice_id as invoice_id,0 quantity, max(rate__stduom) " +
"rate from invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id " + "rate from invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id " +
"and invoice.invoice_id in("+transitInvList+") and item_code='"+itemCode+"' and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " + "and invoice.invoice_id in("+transitInvList+") and item_code='"+itemCode+"' " ;
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ;
}else
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+"))";
}
//" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " +
//" and invoice.inv_type='"+orderType+"' " + //" and invoice.inv_type='"+orderType+"' " +
" and rate__stduom>0.001 group by invoice.invoice_id " + sql=sql+ " and rate__stduom>0.001 group by invoice.invoice_id " +
"union all" + "union all" +
" select invoice.invoice_id as invoice_id,quantity__stduom quantity, 0 rate from " + " select invoice.invoice_id as invoice_id,quantity__stduom quantity, 0 rate from " +
"invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id and " + "invoice invoice,invoice_trace itrace where invoice.invoice_id= Itrace.invoice_id and " +
"invoice.invoice_id in("+transitInvList+") and item_code='"+itemCode+"' and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " + "invoice.invoice_id in("+transitInvList+") and item_code='"+itemCode+"' " ;
if(isItemSer)
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " ;
}else
{
sql=sql+" and ( itrace.item_ser__prom in ("+itemSer+"))";
}
//" and ( itrace.item_ser__prom in ("+itemSer+") OR((itrace.item_ser__prom,itrace.ITEM_CODE) IN (select item_ser,item_code from item_credit_perc WHERE item_ser NOT IN("+itemSer+") )) ) " +
//" and invoice.inv_type='"+orderType+"' " + //" and invoice.inv_type='"+orderType+"' " +
" and rate__stduom<=0.001 ) group by invoice_id ) HAVING sum(totFreeValue) >0 AND sum(totfreeQty)>0 " ; sql=sql+" and rate__stduom<=0.001 ) group by invoice_id ) HAVING sum(totFreeValue) >0 AND sum(totfreeQty)>0 " ;
} }
......
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