Commit 641e78ba authored by mjadhav's avatar mjadhav

add calculation for FRS for receipt and transit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98715 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b011e130
...@@ -110,15 +110,15 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -110,15 +110,15 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
java.util.Date tranDate = null; java.util.Date tranDate = null;
int ctr = 0,currentFormNo=0,cnt=0,countCustRef=0,refSerCnt=0,childNodeListLength=0,invCnt=0; int ctr = 0,currentFormNo=0,cnt=0,countCustRef=0,refSerCnt=0,childNodeListLength=0,invCnt=0;
double clStock=0.0,opStockDom=0.0,purRcpDom=0.0; double clStock=0.0,opStockDom=0.0,purRcpDom=0.0;
double opStock=0.0,purRcpQty=0.0,secSales=0.0,purcRetQty=0.0,priSales=0.0; double opStock=0.0,purRcpQty=0.0,secSales=0.0,purcRetQty=0.0,priSales=0.0,netAmt=0.0;
java.sql.Timestamp FromDate=null,ToDate=null,prdFrmDate=null,prdFrom=null,prdTo=null; java.sql.Timestamp FromDate=null,ToDate=null,prdFrmDate=null,prdFrom=null,prdTo=null,stmtDateTmstp=null;
String fromDateStr ="",toDateStr=""; String fromDateStr ="",toDateStr="";
// boolean dateFlag=false,dateFlagTodate=false,dateFlagFrmdate=false,dateFlagstmtDate=false; // boolean dateFlag=false,dateFlagTodate=false,dateFlagFrmdate=false,dateFlagstmtDate=false;
Node parentNode1 = null; Node parentNode1 = null;
Node childNode1 = null; Node childNode1 = null;
int parentNodeListLength = 0; int parentNodeListLength = 0,transitCnt=0;
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null,pstmt3 = null,pstmt4 = null,pstmt5 = null,pstmt6 = null; PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null,pstmt3 = null,pstmt4 = null,pstmt5 = null,pstmt6 = null;
...@@ -404,16 +404,20 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -404,16 +404,20 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("prdTo :"+prdTo); System.out.println("prdTo :"+prdTo);
System.out.println("FromDate :"+FromDate); System.out.println("FromDate :"+FromDate);
System.out.println("ToDate :"+ToDate); System.out.println("ToDate :"+ToDate);
System.out.println("custCode :"+custCode);
System.out.println("itemSer :"+itemSer);
System.out.println("orderType :"+orderType);
if(FromDate != null && ToDate != null && custCode != null && orderType != null && itemSer != null) if(FromDate != null && ToDate != null && custCode != null && orderType != null && itemSer != null)
{ {
sql = " SELECT count(*) as count FROM invoice invoice WHERE ( invoice.cust_code = ? ) " + //sql = " SELECT count(*) as count FROM invoice invoice WHERE ( invoice.cust_code = ? ) " +
sql = " SELECT distinct (invoice_id) FROM invoice invoice WHERE ( invoice.cust_code = ? ) " +
" and invoice.inv_type=? and invoice.item_ser=? and ( invoice.confirmed = 'Y' )" + " and invoice.inv_type=? and invoice.item_ser=? and ( invoice.confirmed = 'Y' )" +
" and ( (invoice.tran_date >= ? ) and (invoice.tran_date <= ? ) or " + " and ( (invoice.tran_date >= ? ) 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 " +
" WHERE cust_stock_inv.invoice_id = invoice.invoice_id and cust_stock_inv.dlv_flg = 'N' ))) ";*/ " WHERE cust_stock_inv.invoice_id = invoice.invoice_id and cust_stock_inv.dlv_flg = 'N' ))) ";
pstmt3 = conn.prepareStatement(sql); pstmt3 = conn.prepareStatement(sql);
pstmt3.setString(1,custCode.trim()); pstmt3.setString(1,custCode.trim());
pstmt3.setString(2,orderType.trim()); pstmt3.setString(2,orderType.trim());
...@@ -423,24 +427,50 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -423,24 +427,50 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
pstmt3.setTimestamp(6,prdFrom); pstmt3.setTimestamp(6,prdFrom);
pstmt3.setTimestamp(7,prdTo); pstmt3.setTimestamp(7,prdTo);
rs3 = pstmt3.executeQuery(); rs3 = pstmt3.executeQuery();
if (rs3.next()) while (rs3.next())
{ {
invCnt = rs3.getInt("count"); //invCnt = rs3.getInt("count");
invoiceId=rs3.getString("invoice_id");
System.out.println("invoiceId :"+invoiceId);
sql = "select net_amt from cust_stock_inv where invoice_id=? and DLV_FLG='Y'";
pstmt4 = conn.prepareStatement(sql);
pstmt4.setString(1,invoiceId.trim());
// pstmt4.setString(2,itemSer.trim());
rs4 = pstmt4.executeQuery();
if (rs4.next())
{
//transitCnt = rs4.getInt("transit_count");
netAmt=rs4.getDouble("net_amt");
} }
else
{
invCnt++;
}
rs4.close();
rs4 = null;
pstmt4.close();
pstmt4 = null;
}
rs3.close();
rs3 = null;
pstmt3.close();
pstmt3 = null;
System.out.println("invCnt :"+invCnt); System.out.println("invCnt :"+invCnt);
if (invCnt == 0) if (invCnt == 0)
{ {
System.out.println("Error :data not founf for invoice "); System.out.println("Error :data not founf for invoice ");
errCode = "VTINVDATA"; errCode = "VTINVDATA";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
rs3.close();
rs3 = null;
pstmt3.close();
pstmt3 = null;
} }
...@@ -501,7 +531,10 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -501,7 +531,10 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
{ {
ToDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(toDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); ToDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(toDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
} }
System.out.println(); if(stmtDateStr != null)
{
stmtDateTmstp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(stmtDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
...@@ -512,6 +545,15 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -512,6 +545,15 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
System.out.println("stmtDateTmstp :"+stmtDateTmstp);
System.out.println("currentDate :"+currentDate);
if(currentDate.before(stmtDateTmstp))
{
System.out.println("stmtDateTmstp < currentDate : "+stmtDateTmstp+" < "+currentDate);
errCode = "VTINVEFFDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
tranIdLast = checkNull(this.genericUtility.getColumnValue("tran_id",dom)); tranIdLast = checkNull(this.genericUtility.getColumnValue("tran_id",dom));
System.out.println("tranIdLast :"+tranIdLast); System.out.println("tranIdLast :"+tranIdLast);
...@@ -600,7 +642,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -600,7 +642,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
invoiceId = childNode1.getFirstChild().getNodeValue(); invoiceId = childNode1.getFirstChild().getNodeValue();
} }
System.out.println("invoiceId :"+invoiceId); System.out.println("invoiceId :"+invoiceId);
if(invoiceId == null) if(invoiceId.trim().length() == 0)
{ {
System.out.println("Error : No data found in invoice details"); System.out.println("Error : No data found in invoice details");
errCode = "VTEMTINV"; errCode = "VTEMTINV";
...@@ -1052,7 +1094,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1052,7 +1094,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
double transitQtyBon = 0.0,transitQtyFrs=0.0,returnBon=0.0,returnFrs=0.0,receiptBon=0.0,receiptFrs=0.0; double transitQtyBon = 0.0,transitQtyFrs=0.0,returnBon=0.0,returnFrs=0.0,receiptBon=0.0,receiptFrs=0.0;
String sretSiteCode = "",sretLocCode = "",sretLotNo="",sretLotSl="",retRepFlag="",selQuery="",invStat="",periodDt=""; String sretSiteCode = "",sretLocCode = "",sretLotNo="",sretLotSl="",retRepFlag="",selQuery="",invStat="",periodDt="";
double rcpQtmDom = 0.0,retQtyDom=0.0,opStkDom=0.0,transitQtyDom=0.0,salesQtyCal=0.0,clStockNew=0.0; double rcpQtmDom = 0.0,retQtyDom=0.0,opStkDom=0.0,transitQtyDom=0.0,salesQtyCal=0.0,clStockNew=0.0;
double retQtyAll=0.0,replQtyAll=0.0,primarySalesAll=0.0; double retQtyAll=0.0,replQtyAll=0.0,primarySalesAll=0.0,rcpFreeAll=0.0,rcpFree=0.0,transitQtyBonLast=0.0;
SimpleDateFormat sdf; SimpleDateFormat sdf;
ArrayList defData = null; ArrayList defData = null;
windowName = (new StringBuilder("w_")).append(getObjName(dom, objContext)).toString(); windowName = (new StringBuilder("w_")).append(getObjName(dom, objContext)).toString();
...@@ -1071,11 +1113,11 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1071,11 +1113,11 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
String selectedInvList =""; String selectedInvList ="";
String invoiceIdDom=""; String invoiceIdDom="";
String locality_code=""; String locality_code="";
String childNodeName = "",lineNoStrDom="",lineNoStr="",stockDlvFlg=""; String childNodeName = "",lineNoStrDom="",lineNoStr="",stockDlvFlg="",dlvFlagStock="";
String invoiceIdList = ""; String invoiceIdList = "",dlvFlagDom="";
double sretQtyAll=0.0,rateAll=0.0,sretQtyAllTot=0.0; double sretQtyAll=0.0,rateAll=0.0,sretQtyAllTot=0.0;
String sretSiteCodeAll="",sretLocCodeAll="",sretLotNoAll="",sretLotSlAll="",retRepFlagAll=""; String sretSiteCodeAll="",sretLocCodeAll="",sretLotNoAll="",sretLotSlAll="",retRepFlagAll="";
int invCnt=0; int invCnt=0,dlvFlgCnt=0;
try try
...@@ -1399,6 +1441,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1399,6 +1441,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<tran_id__last>").append("<![CDATA["+tranIdLast+"]]>").append("</tran_id__last>"); valueXmlString.append("<tran_id__last>").append("<![CDATA["+tranIdLast+"]]>").append("</tran_id__last>");
valueXmlString.append("<sordertype_descr protect='1'>").append("<![CDATA["+orderTypeName+"]]>").append("</sordertype_descr>"); 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("<stmt_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</stmt_date>");
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("</Detail2>\r\n"); valueXmlString.append("</Detail2>\r\n");
} }
...@@ -1421,6 +1466,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1421,6 +1466,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<tran_id__last>").append("<![CDATA["+tranIdLast+"]]>").append("</tran_id__last>"); valueXmlString.append("<tran_id__last>").append("<![CDATA["+tranIdLast+"]]>").append("</tran_id__last>");
valueXmlString.append("<sordertype_descr protect='1'>").append("<![CDATA["+orderTypeName+"]]>").append("</sordertype_descr>"); 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("<stmt_date>").append("<![CDATA["+sdf.format(currentDate)+"]]>").append("</stmt_date>");
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("</Detail2>\r\n"); valueXmlString.append("</Detail2>\r\n");
} }
...@@ -1521,7 +1569,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1521,7 +1569,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("lrDate (case 3):"+lrDate); System.out.println("lrDate (case 3):"+lrDate);
System.out.println("tranCode (case 3):"+tranCode); System.out.println("tranCode (case 3):"+tranCode);
tranName="";
sql= "select tran_name from transporter where tran_code=?"; sql= "select tran_name from transporter where tran_code=?";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranCode); pstmt1.setString(1, tranCode);
...@@ -1549,8 +1597,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1549,8 +1597,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<invoice_id>").append("<![CDATA["+invoiceId+"]]>").append("</invoice_id>"); valueXmlString.append("<invoice_id>").append("<![CDATA["+invoiceId+"]]>").append("</invoice_id>");
valueXmlString.append("<invoice_date>").append("<![CDATA["+sdf.format(invDate)+"]]>").append("</invoice_date>"); valueXmlString.append("<invoice_date>").append("<![CDATA["+sdf.format(invDate)+"]]>").append("</invoice_date>");
//valueXmlString.append("<lr_date>").append("<![CDATA["+invsiteCodeMap.get("lrDate@"+invDomid)+"]]>").append("</lr_date>"); //valueXmlString.append("<lr_date>").append("<![CDATA["+invsiteCodeMap.get("lrDate@"+invDomid)+"]]>").append("</lr_date>");
valueXmlString.append("<dlv_flg>").append("<![CDATA[Y]]>").append("</dlv_flg>"); //valueXmlString.append("<dlv_flg>").append("<![CDATA[Y]]>").append("</dlv_flg>");
//valueXmlString.append("<dlv_flg>").append("<![CDATA["+invMap.get("dlvFlag@"+i)+"]]>").append("</dlv_flg>"); valueXmlString.append("<dlv_flg>").append("<![CDATA["+invMap.get(invoiceId)+"]]>").append("</dlv_flg>");
valueXmlString.append("<net_amt>").append("<![CDATA["+netAmt+"]]>").append("</net_amt>"); valueXmlString.append("<net_amt>").append("<![CDATA["+netAmt+"]]>").append("</net_amt>");
valueXmlString.append("<lr_no>").append("<![CDATA["+lrNo+"]]>").append("</lr_no>"); valueXmlString.append("<lr_no>").append("<![CDATA["+lrNo+"]]>").append("</lr_no>");
...@@ -1663,10 +1711,10 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1663,10 +1711,10 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
" FROM invoice invoice WHERE ( invoice.cust_code = ? ) and invoice.site_code =? and invoice.inv_type=? and invoice.item_ser=? and " + " 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 >= ? ) " + " ( 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 " +
" WHERE cust_stock_inv.invoice_id = invoice.invoice_id and " + " WHERE cust_stock_inv.invoice_id = invoice.invoice_id and " +
" cust_stock_inv.dlv_flg = 'N' )))" +*/ " cust_stock_inv.dlv_flg = 'N' )))" +
" UNION " + " UNION " +
" SELECT distinct cinv.invoice_id ," + " SELECT distinct cinv.invoice_id ," +
" cinv.INVOICE_DATE,cinv.DLV_FLG ,cinv.net_amt FROM CUST_STOCK_INV cinv , " + " cinv.INVOICE_DATE,cinv.DLV_FLG ,cinv.net_amt FROM CUST_STOCK_INV cinv , " +
...@@ -1720,7 +1768,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1720,7 +1768,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("tranCode :"+tranCode); System.out.println("tranCode :"+tranCode);
tranName="";
sql= "select tran_name from transporter where tran_code=?"; sql= "select tran_name from transporter where tran_code=?";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranCode); pstmt1.setString(1, tranCode);
...@@ -1737,22 +1785,24 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1737,22 +1785,24 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
stockDlvFlg="N"; stockDlvFlg="N";
sql= "select dlv_flg from cust_stock_inv where invoice_id=? "; // 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); pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1, invoiceId); pstmt2.setString(1, invoiceId);
rs2 = pstmt2.executeQuery(); rs2 = pstmt2.executeQuery();
if(rs2.next()) if(rs2.next())
{ {
stockDlvFlg = checkNull(rs2.getString("dlv_flg")); //stockDlvFlg = checkNull(rs2.getString("dlv_flg"));
dlvFlgCnt=rs2.getInt("count");
} }
rs2.close(); rs2.close();
rs2 = null; rs2 = null;
pstmt2.close(); pstmt2.close();
pstmt2 = null; pstmt2 = null;
System.out.println("stockDlvFlg >>>>"+stockDlvFlg); System.out.println("dlvFlgCnt >>>>"+dlvFlgCnt);
if(!(stockDlvFlg.equalsIgnoreCase("Y"))) //if(!(stockDlvFlg.equalsIgnoreCase("Y")))
if(dlvFlgCnt == 0)
{ {
System.out.println("previous domID3 value :"+domID3); System.out.println("previous domID3 value :"+domID3);
domID3 = domID3 + 1; domID3 = domID3 + 1;
...@@ -1773,7 +1823,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1773,7 +1823,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
} }
invMap.put("netAmt@"+domID3, String.valueOf(netAmt)); invMap.put("netAmt@"+domID3, String.valueOf(netAmt));
//invMap.put("dlvFlag@"+domID3,dlvFlag); dlvFlagStock=GetDlvFlag(invoiceId,conn);
System.out.println("dlvFlagStock :"+dlvFlagStock);
invMap.put("dlvFlag@"+domID3,dlvFlagStock);
invMap.put("tranName@"+domID3, tranName); invMap.put("tranName@"+domID3, tranName);
System.out.println("tranName :"+tranName); System.out.println("tranName :"+tranName);
...@@ -1811,8 +1863,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1811,8 +1863,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<invoice_id>").append("<![CDATA["+invMap.get("invoiceId@"+invDomid)+"]]>").append("</invoice_id>"); valueXmlString.append("<invoice_id>").append("<![CDATA["+invMap.get("invoiceId@"+invDomid)+"]]>").append("</invoice_id>");
valueXmlString.append("<invoice_date>").append("<![CDATA["+invMap.get("invDate@"+invDomid)+"]]>").append("</invoice_date>"); valueXmlString.append("<invoice_date>").append("<![CDATA["+invMap.get("invDate@"+invDomid)+"]]>").append("</invoice_date>");
valueXmlString.append("<lr_date>").append("<![CDATA["+invMap.get("lrDate@"+invDomid)+"]]>").append("</lr_date>"); valueXmlString.append("<lr_date>").append("<![CDATA["+invMap.get("lrDate@"+invDomid)+"]]>").append("</lr_date>");
valueXmlString.append("<dlv_flg>").append("<![CDATA[Y]]>").append("</dlv_flg>"); //valueXmlString.append("<dlv_flg>").append("<![CDATA[Y]]>").append("</dlv_flg>");
//valueXmlString.append("<dlv_flg>").append("<![CDATA["+invMap.get("dlvFlag@"+i)+"]]>").append("</dlv_flg>"); valueXmlString.append("<dlv_flg>").append("<![CDATA["+invMap.get("dlvFlag@"+invDomid)+"]]>").append("</dlv_flg>");
valueXmlString.append("<net_amt>").append("<![CDATA["+invMap.get("netAmt@"+invDomid)+"]]>").append("</net_amt>"); valueXmlString.append("<net_amt>").append("<![CDATA["+invMap.get("netAmt@"+invDomid)+"]]>").append("</net_amt>");
valueXmlString.append("<lr_no>").append("<![CDATA["+invMap.get("lrNo@"+invDomid)+"]]>").append("</lr_no>"); valueXmlString.append("<lr_no>").append("<![CDATA["+invMap.get("lrNo@"+invDomid)+"]]>").append("</lr_no>");
...@@ -1871,7 +1923,10 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1871,7 +1923,10 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("[][process()][Detail3 invoiceIdDom:::]" +invoiceIdDom); System.out.println("Detail3 invoiceIdDom:::]" +invoiceIdDom);
System.out.println("dlvFlagDom : "+dlvFlagDom);
if(dlvFlagDom.equalsIgnoreCase("Y"))
{
if(childRow != (childNodeListLength1 - 1)) if(childRow != (childNodeListLength1 - 1))
{ {
invoiceIdList = invoiceIdList + "'"+invoiceIdDom.trim() + "',"; invoiceIdList = invoiceIdList + "'"+invoiceIdDom.trim() + "',";
...@@ -1880,10 +1935,21 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1880,10 +1935,21 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
{ {
invoiceIdList = invoiceIdList + "'"+invoiceIdDom.trim() + "'"; invoiceIdList = invoiceIdList + "'"+invoiceIdDom.trim() + "'";
} }
}
}
} }
if(childNodeName.equals("dlv_flg"))
{
if(childNode1.getFirstChild()!=null)
{
dlvFlagDom = childNode1.getFirstChild().getNodeValue();
System.out.println("dlvFlagDom :"+dlvFlagDom);
System.out.println("Invoice Id :"+invoiceIdDom);
} }
}
System.out.println("childRow :"+childRow); System.out.println("childRow :"+childRow);
System.out.println("childNodeListLength1 :"+childNodeListLength1); System.out.println("childNodeListLength1 :"+childNodeListLength1);
...@@ -1893,7 +1959,15 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -1893,7 +1959,15 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
} }
System.out.println("invoiceIdList :"+invoiceIdList); System.out.println("invoiceIdList :"+invoiceIdList);
if(invoiceIdList.trim().length() > 0)
{
selectedInvList = invoiceIdList.substring(0,invoiceIdList.length() - 1); selectedInvList = invoiceIdList.substring(0,invoiceIdList.length() - 1);
}
else
{
selectedInvList = "' '";
}
System.out.println("selectedInvList :"+selectedInvList); System.out.println("selectedInvList :"+selectedInvList);
/*------------------------------------------------------*/ /*------------------------------------------------------*/
...@@ -2059,6 +2133,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2059,6 +2133,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
receiptLast = GetRcpQty(selectedInvList,itemCodeLast,conn); receiptLast = GetRcpQty(selectedInvList,itemCodeLast,conn);
System.out.println("Receipt quantity cal for avaible transcation id :"+receiptLast); System.out.println("Receipt quantity cal for avaible transcation id :"+receiptLast);
rcpFree = GetBonQty(selectedInvList,itemCodeLast,conn) ;
System.out.println("rcpFree :"+rcpFree);
System.out.println("receiptLast :"+receiptLast); System.out.println("receiptLast :"+receiptLast);
System.out.println("custCodeHd :"+custCodeHd); System.out.println("custCodeHd :"+custCodeHd);
...@@ -2073,6 +2150,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2073,6 +2150,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
transitQty=GetTransitQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCodeLast,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,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("transitQty quantity cal for avaible transcation id :"+transitQty);
transitQtyBonLast=GetTransitBon(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCodeLast,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("transitQtyBonLast :"+transitQtyBonLast);
System.out.println("--cal rate for current transcation period"); System.out.println("--cal rate for current transcation period");
rateLast = getRate(custCodeHd,prdFrmDateTstmp,toDateTstmp,itemCodeLast,conn); rateLast = getRate(custCodeHd,prdFrmDateTstmp,toDateTstmp,itemCodeLast,conn);
System.out.println("rateLast :"+rateLast); System.out.println("rateLast :"+rateLast);
...@@ -2267,7 +2347,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2267,7 +2347,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<purc_rcp>").append("<![CDATA["+receiptLast+"]]>").append("</purc_rcp>"); valueXmlString.append("<purc_rcp>").append("<![CDATA["+receiptLast+"]]>").append("</purc_rcp>");
valueXmlString.append("<purc_rcp__repl>").append("<![CDATA[0]]>").append("</purc_rcp__repl>"); valueXmlString.append("<purc_rcp__repl>").append("<![CDATA[0]]>").append("</purc_rcp__repl>");
valueXmlString.append("<purc_rcp__free>").append("<![CDATA[0]]>").append("</purc_rcp__free>"); valueXmlString.append("<purc_rcp__free>").append("<![CDATA["+rcpFree+"]]>").append("</purc_rcp__free>");
valueXmlString.append("<purc_ret>").append("<![CDATA["+returnLast+"]]>").append("</purc_ret>"); valueXmlString.append("<purc_ret>").append("<![CDATA["+returnLast+"]]>").append("</purc_ret>");
valueXmlString.append("<purc_ret__repl>").append("<![CDATA["+replQty+"]]>").append("</purc_ret__repl>"); valueXmlString.append("<purc_ret__repl>").append("<![CDATA["+replQty+"]]>").append("</purc_ret__repl>");
...@@ -2280,7 +2360,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2280,7 +2360,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<transit_qty>").append("<![CDATA["+transitQty+"]]>").append("</transit_qty>"); valueXmlString.append("<transit_qty>").append("<![CDATA["+transitQty+"]]>").append("</transit_qty>");
valueXmlString.append("<transit_qty__repl>").append("<![CDATA[0]]>").append("</transit_qty__repl>"); valueXmlString.append("<transit_qty__repl>").append("<![CDATA[0]]>").append("</transit_qty__repl>");
valueXmlString.append("<transit_qty__free>").append("<![CDATA[0]]>").append("</transit_qty__free>"); valueXmlString.append("<transit_qty__free>").append("<![CDATA["+transitQtyBonLast+"]]>").append("</transit_qty__free>");
valueXmlString.append("<primary_sales>").append("<![CDATA["+primarySales+"]]>").append("</primary_sales>"); valueXmlString.append("<primary_sales>").append("<![CDATA["+primarySales+"]]>").append("</primary_sales>");
valueXmlString.append("</Detail4>"); valueXmlString.append("</Detail4>");
...@@ -2388,7 +2468,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2388,7 +2468,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("Receipt quantity for not available in last or current tranaction"+"itemCode :"+itemCode +"Receipt Quantity :"+rcpQty); 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) ; // rcpQtyBon = GetRcpFreeQty( custCodeHd,tranIdLast,orderType,prdFrmDateTstmp, toDateTstmp,itemCode,itemSerHd, conn) ;
// System.out.println("rcpQtyBon :"+rcpQtyBon); // System.out.println("rcpQtyBon :"+rcpQtyBon);
rcpFreeAll = GetBonQty(selectedInvList,itemCode,conn) ;
System.out.println("rcpFreeAll :"+rcpFreeAll);
// sretQty = GetRetQty(custCodeHd,frmDateTstmp,toDateTstmp,itemCode,siteCodeHd,itemSerHd,conn); // sretQty = GetRetQty(custCodeHd,frmDateTstmp,toDateTstmp,itemCode,siteCodeHd,itemSerHd,conn);
// System.out.println("sretQty ::"+sretQty); // System.out.println("sretQty ::"+sretQty);
...@@ -2507,6 +2588,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2507,6 +2588,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
transitQty=GetTransitQty(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCode,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,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); System.out.println("Transit quantity for not available in last or current tranaction"+"itemCode :"+itemCode +"Transit Quantity :"+transitQty);
transitQtyBon=GetTransitBon(custCodeHd,orderType,itemSerHd,siteCodeHd,selectedInvList,itemCode,frmDateTstmp,toDateTstmp,prdFrmDateTstmp,prdtoDateTstmp,conn);
System.out.println("/*--cal Rate for all item code which is not included for current or previous item code.---*/"); System.out.println("/*--cal Rate for all item code which is not included for current or previous item code.---*/");
rateAll = getRate(custCodeHd,prdFrmDateTstmp,toDateTstmp,itemCode,conn); rateAll = getRate(custCodeHd,prdFrmDateTstmp,toDateTstmp,itemCode,conn);
System.out.println("rateAll :"+rateAll); System.out.println("rateAll :"+rateAll);
...@@ -2521,7 +2605,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2521,7 +2605,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
itemMap.put("mopStk@"+lineNoItmCnt, String.valueOf(opStkItem)); itemMap.put("mopStk@"+lineNoItmCnt, String.valueOf(opStkItem));
//itemMap.put("mopStk@"+lineNoItmCnt, String.valueOf(opStkItem)); //itemMap.put("mopStk@"+lineNoItmCnt, String.valueOf(opStkItem));
itemMap.put("mquantRcp@"+lineNoItmCnt, String.valueOf(rcpQty)); itemMap.put("mquantRcp@"+lineNoItmCnt, String.valueOf(rcpQty));
itemMap.put("rcpQtyBon@"+lineNoItmCnt, String.valueOf(rcpQtyBon)); itemMap.put("rcpQtyBon@"+lineNoItmCnt, String.valueOf(rcpFreeAll));
itemMap.put("mquant@"+lineNoItmCnt, String.valueOf(sretQtyAllTot)); itemMap.put("mquant@"+lineNoItmCnt, String.valueOf(sretQtyAllTot));
itemMap.put("retQty@"+lineNoItmCnt, String.valueOf(retQtyAll)); itemMap.put("retQty@"+lineNoItmCnt, String.valueOf(retQtyAll));
itemMap.put("replQty@"+lineNoItmCnt, String.valueOf(replQtyAll)); itemMap.put("replQty@"+lineNoItmCnt, String.valueOf(replQtyAll));
...@@ -2583,7 +2667,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2583,7 +2667,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<purc_rcp>").append("<![CDATA["+itemMap.get("mquantRcp@"+itemDomId)+"]]>").append("</purc_rcp>"); valueXmlString.append("<purc_rcp>").append("<![CDATA["+itemMap.get("mquantRcp@"+itemDomId)+"]]>").append("</purc_rcp>");
valueXmlString.append("<purc_rcp__repl>").append("<![CDATA[0]]>").append("</purc_rcp__repl>"); valueXmlString.append("<purc_rcp__repl>").append("<![CDATA[0]]>").append("</purc_rcp__repl>");
valueXmlString.append("<purc_rcp__free>").append("<![CDATA[0]]>").append("</purc_rcp__free>"); valueXmlString.append("<purc_rcp__free>").append("<![CDATA["+itemMap.get("rcpQtyBon@"+itemDomId)+"]]>").append("</purc_rcp__free>");
valueXmlString.append("<purc_ret>").append("<![CDATA["+itemMap.get("mquant@"+itemDomId)+"]]>").append("</purc_ret>"); valueXmlString.append("<purc_ret>").append("<![CDATA["+itemMap.get("mquant@"+itemDomId)+"]]>").append("</purc_ret>");
...@@ -2592,7 +2676,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2592,7 +2676,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<sales>").append("<![CDATA["+itemMap.get("msalesQty@"+itemDomId)+"]]>").append("</sales>"); valueXmlString.append("<sales>").append("<![CDATA["+itemMap.get("msalesQty@"+itemDomId)+"]]>").append("</sales>");
valueXmlString.append("<transit_qty>").append("<![CDATA["+itemMap.get("transitQty@"+itemDomId)+"]]>").append("</transit_qty>"); valueXmlString.append("<transit_qty>").append("<![CDATA["+itemMap.get("transitQty@"+itemDomId)+"]]>").append("</transit_qty>");
valueXmlString.append("<transit_qty__free>").append("<![CDATA[0]]>").append("</transit_qty__free>"); valueXmlString.append("<transit_qty__free>").append("<![CDATA["+itemMap.get("transitQtyBon@"+itemDomId)+"]]>").append("</transit_qty__free>");
valueXmlString.append("<transit_qty__repl>").append("<![CDATA[0]]>").append("</transit_qty__repl>"); valueXmlString.append("<transit_qty__repl>").append("<![CDATA[0]]>").append("</transit_qty__repl>");
valueXmlString.append("<primary_sales>").append("<![CDATA["+itemMap.get("primarySales@"+itemDomId)+"]]>").append("</primary_sales>"); valueXmlString.append("<primary_sales>").append("<![CDATA["+itemMap.get("primarySales@"+itemDomId)+"]]>").append("</primary_sales>");
...@@ -2856,7 +2940,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2856,7 +2940,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
Node childNode = null; Node childNode = null;
String invoiceId = null; String invoiceId = null;
String dlvFlg = null ; String dlvFlg = null ;
double transitQty = 0, quantity = 0; double transitQty = 0, quantity = 0,dlvFlgTransit=0;
PreparedStatement pstmt = null,pstmt2 = null; PreparedStatement pstmt = null,pstmt2 = null;
ResultSet rs = null,rs2 = null; ResultSet rs = null,rs2 = null;
String sql = null; String sql = null;
...@@ -2915,7 +2999,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2915,7 +2999,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
" ( invoice.cust_code = ? ) and invoice.site_code =? and invoice.inv_type=? " + " ( invoice.cust_code = ? ) and invoice.site_code =? and invoice.inv_type=? " +
" and invoice.item_ser=? and ( invoice.confirmed = 'Y' ) " + " and invoice.item_ser=? and ( invoice.confirmed = 'Y' ) " +
"and ( (invoice.tran_date >=?) and (invoice.tran_date <= ? ) " + "and ( (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 WHERE cust_stock_inv.invoice_id = invoice.invoice_id and " +
" cust_stock_inv.dlv_flg = 'N' )) ) " +
"and invoice.invoice_id not in ("+selectedInvList+") " + "and invoice.invoice_id not in ("+selectedInvList+") " +
"UNION " + "UNION " +
" SELECT distinct cinv.invoice_id FROM CUST_STOCK_INV cinv , " + " SELECT distinct cinv.invoice_id FROM CUST_STOCK_INV cinv , " +
...@@ -2945,14 +3031,14 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2945,14 +3031,14 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
stockDlvFlg="N"; stockDlvFlg="N";
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); pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1, invoiceId); pstmt2.setString(1, invoiceId);
rs2 = pstmt2.executeQuery(); rs2 = pstmt2.executeQuery();
if(rs2.next()) if(rs2.next())
{ {
stockDlvFlg = checkNull(rs2.getString("dlv_flg")); //stockDlvFlg = checkNull(rs2.getString("dlv_flg"));
dlvFlgTransit=rs2.getInt("count");
} }
rs2.close(); rs2.close();
rs2 = null; rs2 = null;
...@@ -2960,7 +3046,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2960,7 +3046,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
pstmt2 = null; pstmt2 = null;
System.out.println("stockDlvFlg >>>>"+stockDlvFlg); System.out.println("stockDlvFlg >>>>"+stockDlvFlg);
if(!(stockDlvFlg.equalsIgnoreCase("Y"))) //if(!(stockDlvFlg.equalsIgnoreCase("Y")))
if(dlvFlgTransit == 0)
{ {
System.out.println("transit invoice :"+invoiceId); System.out.println("transit invoice :"+invoiceId);
quantity = rs.getDouble("QUANTITY__STDUOM"); quantity = rs.getDouble("QUANTITY__STDUOM");
...@@ -2987,6 +3074,164 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2987,6 +3074,164 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
/*-------------------------------------------------------------------------------------------------*/
private double GetTransitBon(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 bonusQty=0.0;
try
{
// transit quantity for those which are included in period also for dlv flag 'N'
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' )) ) " +
"and invoice.invoice_id not in ("+selectedInvList+") " +
"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' and " +
" cinv.invoice_id not in ("+selectedInvList+") ) ";
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");
stockDlvFlg="N";
sql= "select count(*) as count from cust_stock_inv where invoice_id=? and dlv_flg='Y' ";
pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1, invoiceId);
rs2 = pstmt2.executeQuery();
if(rs2.next())
{
//stockDlvFlg = checkNull(rs2.getString("dlv_flg"));
dlvFlgTransit=rs2.getInt("count");
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
System.out.println("stockDlvFlg >>>>"+stockDlvFlg);
//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("B"))
{
bonusQty = bonusQty + quantity;
System.out.println(bonusQty);
}
}
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("bonusQty for transit :"+bonusQty);
return bonusQty ;
}
/*-----------------------------------------------------------------------------------------------*/
private double GetTransitFreeQty(String tranId, String itemCode, Connection conn) throws Exception private double GetTransitFreeQty(String tranId, String itemCode, Connection conn) throws Exception
...@@ -3121,6 +3366,88 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3121,6 +3366,88 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
} }
/*------------------------------------------------------------------------------*/
private double GetBonQty(String selectedInvList,String itemCode, Connection conn) throws Exception
{
double quantity = 0.0;
double bonusQty = 0.0;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
String nature="";
String[] invoiceIdArray;
String invoiceId="",invoiceSep="";
try
{
System.out.println("------calculate bonus 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=?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,invoiceId );
pstmt.setString(2,itemCode );
rs = pstmt.executeQuery();
while( rs.next() )
{
quantity = rs.getDouble("quantity__stduom");
nature=rs.getString("nature");
System.out.println("nature :"+nature);
if(nature.equalsIgnoreCase("B"))
{
bonusQty = bonusQty + quantity;
System.out.println(bonusQty);
}
}
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("bonusQty :"+bonusQty);
return bonusQty ;
}
/*-------------------------------------------------------------------------------*/
private double GetRcpFreeQty(String custCode,String tranIdLast,String orderType, java.sql.Timestamp fromDate, java.sql.Timestamp toDate,String itemCode,String itemSer, Connection conn) throws Exception private double GetRcpFreeQty(String custCode,String tranIdLast,String orderType, java.sql.Timestamp fromDate, java.sql.Timestamp toDate,String itemCode,String itemSer, Connection conn) throws Exception
...@@ -3918,6 +4245,52 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3918,6 +4245,52 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
private String GetDlvFlag(String invoiceId, Connection conn) throws Exception
{
double quantity = 0.0;
double rcpQuantity = 0.0;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
String dlvFlag="";
try
{
sql = "select dlv_flg from cust_stock_inv where invoice_id=?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,invoiceId );
rs = pstmt.executeQuery();
if( rs.next() )
{
dlvFlag = rs.getString("dlv_flg");
System.out.println("dlvFlag :"+dlvFlag);
}
else
{
dlvFlag="Y";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("dlvFlag :"+dlvFlag);
}
catch(Exception exception)
{
exception.printStackTrace();
//System.out.println("Exception ::" + exception.getMessage());
throw new ITMException( exception );
}
return dlvFlag ;
}
private Timestamp getPreviousDate(java.sql.Timestamp FromDate, Connection conn) private Timestamp getPreviousDate(java.sql.Timestamp FromDate, Connection conn)
{ {
String varValueStr=""; String varValueStr="";
......
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