Commit 68e82065 authored by apal's avatar apal

Group scheme validation

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@176501 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 50945bce
...@@ -20,6 +20,7 @@ import java.util.Date; ...@@ -20,6 +20,7 @@ import java.util.Date;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
import org.apache.poi.hssf.record.cont.ContinuableRecord;
import org.w3c.dom.CDATASection; import org.w3c.dom.CDATASection;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
...@@ -1780,10 +1781,10 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -1780,10 +1781,10 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
ordDtStr=genericUtility.getColumnValue("order_date", dom); ordDtStr=genericUtility.getColumnValue("order_date", dom);
if(prmDtStr!=null && prmDtStr.trim().length()>0) if(prmDtStr!=null && prmDtStr.trim().length()>0)
{ {
// promDate = Timestamp.valueOf((genericUtility.getColumnValue("prom_date", dom))); comment by Abhijit // promDate = Timestamp.valueOf((genericUtility.getColumnValue("prom_date", dom))); comment by Abhijit
promDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("prom_date", dom), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");// Added By Abhijit Gaikwad promDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("prom_date", dom), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");// Added By Abhijit Gaikwad
System.out.println("promDate["+promDate+"]"); System.out.println("promDate["+promDate+"]");
// orderDate = Timestamp.valueOf((genericUtility.getColumnValue("order_date", dom))); // orderDate = Timestamp.valueOf((genericUtility.getColumnValue("order_date", dom)));
orderDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("order_date", dom), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); orderDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("order_date", dom), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("orderDate["+orderDate+"]"); System.out.println("orderDate["+orderDate+"]");
} }
...@@ -2213,7 +2214,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -2213,7 +2214,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
if(applicableOrdTypes.contains(orderType.trim())) if(applicableOrdTypes.contains(orderType.trim()))
{ {
lbProceed=true; lbProceed=true;
// break; // break;
} }
if(!lbProceed) if(!lbProceed)
{ {
...@@ -2741,9 +2742,13 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -2741,9 +2742,13 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
} }
} }
System.out.println("lbOrdFlag["+lbOrdFlag+"]"); System.out.println("lbOrdFlag["+lbOrdFlag+"]");
System.out.println("errCode<<<<<<"+errCode+"]"+"schemeCode"+schemeCode+"]"+"nature"+nature+"]");
if(errCode==null || errCode.trim().length()==0) if(errCode==null || errCode.trim().length()==0)
{ {
nature=checkNull(genericUtility.getColumnValue("nature", dom)); nature=checkNull(genericUtility.getColumnValue("nature", dom));
System.out.println(" after get nature"+nature+"]");
if(("F".equalsIgnoreCase(nature) || "B".equalsIgnoreCase(nature) || "S".equalsIgnoreCase(nature) )&& (!lbOrdFlag)) if(("F".equalsIgnoreCase(nature) || "B".equalsIgnoreCase(nature) || "S".equalsIgnoreCase(nature) )&& (!lbOrdFlag))
{ {
schemeCode=getSchemeCode(dom, dom1, dom2, "quantity", conn); schemeCode=getSchemeCode(dom, dom1, dom2, "quantity", conn);
...@@ -2764,18 +2769,25 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -2764,18 +2769,25 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
if("Q".equalsIgnoreCase(schemeFlag)) if("Q".equalsIgnoreCase(schemeFlag))
{ {
errCode=valDataGroupScheme(dom, dom1, dom2, "quantity", objContext, editFlag, nature, conn); errCode=valDataGroupScheme(dom, dom1, dom2, "quantity", objContext, editFlag, nature, conn);
System.out.println("Quantity AFTER errCode1111111"+errCode+"]");
if(errCode!=null && errCode.trim().length()>0)
{
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}
else else
{ {
errCode=valDataGroupScheme(dom, dom1, dom2, "quantity", objContext, editFlag, nature, conn); errCode=valDataGroupScheme(dom, dom1, dom2, "quantity", objContext, editFlag, nature, conn);
System.out.println("Value AFTER errCode1111111"+errCode+"]");
if(errCode!=null && errCode.trim().length()>0)
{
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} }
}
if("Y".equalsIgnoreCase(isContractYn)) if("Y".equalsIgnoreCase(isContractYn))
{ {
contractNo=checkNull(genericUtility.getColumnValue("contract_no", dom1)); contractNo=checkNull(genericUtility.getColumnValue("contract_no", dom1));
...@@ -3517,6 +3529,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -3517,6 +3529,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
errCode = gf_check_conv_fact(itemCode, unitStd,unit, convRtuomStduom, conn); errCode = gf_check_conv_fact(itemCode, unitStd,unit, convRtuomStduom, conn);
if (errCode != null && errCode.trim().length() > 0) if (errCode != null && errCode.trim().length() > 0)
{ {
// errCode = "VTUCON1"; //16-12-17
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
...@@ -9822,7 +9835,11 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -9822,7 +9835,11 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
{ {
lsItemDesc = mDescr1; lsItemDesc = mDescr1;
} }
////////////// added by aru pal 13-12-17
String schAttr = checkNull(genericUtility.getColumnValue("sch_attr", dom));
//if(!("Y").equalsIgnoreCase(schAttr))
// {
valueXmlString.append("<item_descr>").append("<![CDATA[" + lsItemDesc + "]]>").append("</item_descr>"); valueXmlString.append("<item_descr>").append("<![CDATA[" + lsItemDesc + "]]>").append("</item_descr>");
setNodeValue( dom, "item_descr", getAbsString( lsItemDesc)); setNodeValue( dom, "item_descr", getAbsString( lsItemDesc));
valueXmlString.append("<unit>").append("<![CDATA[" + uom + "]]>").append("</unit>"); valueXmlString.append("<unit>").append("<![CDATA[" + uom + "]]>").append("</unit>");
...@@ -9834,7 +9851,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -9834,7 +9851,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
setNodeValue( dom, "unit__std", getAbsString( uom)); setNodeValue( dom, "unit__std", getAbsString( uom));
valueXmlString.append("<unit__rate>").append("<![CDATA[" + uom + "]]>").append("</unit__rate>"); valueXmlString.append("<unit__rate>").append("<![CDATA[" + uom + "]]>").append("</unit__rate>");
setNodeValue( dom, "unit__rate", getAbsString( uom)); setNodeValue( dom, "unit__rate", getAbsString( uom));
// }
reStr=itemChangedDet(dom, dom1, dom2, objContext, "unit", editFlag, xtraParams); reStr=itemChangedDet(dom, dom1, dom2, objContext, "unit", editFlag, xtraParams);
pos = reStr.indexOf("<Detail2>"); pos = reStr.indexOf("<Detail2>");
reStr = reStr.substring(pos + 9); reStr = reStr.substring(pos + 9);
...@@ -11682,7 +11699,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -11682,7 +11699,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
/* if (dlvTerm == null || dlvTerm.trim().length() == 0) /* if (dlvTerm == null || dlvTerm.trim().length() == 0)
{ {
dlvTerm = "NA"; dlvTerm = "NA";
}*/ }*/
...@@ -11930,7 +11947,9 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -11930,7 +11947,9 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
int pos=0; int pos=0;
try try
{ {
mCode = checkNull(genericUtility.getColumnValue("nature", dom1)); mCode = checkNull(genericUtility.getColumnValue("nature", dom));
System.out.println(" value of mCode rate "+mCode+"]");
if ("F".equalsIgnoreCase(mCode) || "B".equalsIgnoreCase(mCode) || "S".equalsIgnoreCase(mCode)) if ("F".equalsIgnoreCase(mCode) || "B".equalsIgnoreCase(mCode) || "S".equalsIgnoreCase(mCode))
{ {
valueXmlString.append("<rate>").append("<![CDATA[" + '0' + "]]>").append("</rate>"); valueXmlString.append("<rate>").append("<![CDATA[" + '0' + "]]>").append("</rate>");
...@@ -12578,7 +12597,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -12578,7 +12597,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
String lsCurscheme = "", lsItemCodeParent = "", lsApplyCustList = "", lsNoapplyCustList = "", lsApplicableOrdTypes = "", lsSchemeCode = "", lsPrevscheme = ""; String lsCurscheme = "", lsItemCodeParent = "", lsApplyCustList = "", lsNoapplyCustList = "", lsApplicableOrdTypes = "", lsSchemeCode = "", lsPrevscheme = "";
String lsCustSchemeCode = "", lsItemStru = "", lsDisPobOrdTypeList = "", lsSchemeEdit = "", lsUnit = "", lsRefNo = "", lsSiteCodeShip = "", mSlabOn = "", lsDescr = ""; String lsCustSchemeCode = "", lsItemStru = "", lsDisPobOrdTypeList = "", lsSchemeEdit = "", lsUnit = "", lsRefNo = "", lsSiteCodeShip = "", mSlabOn = "", lsDescr = "";
String lsSalesOrd = "", lsQuotNo = "",reStr="",ldtDateStr=""; String lsSalesOrd = "", lsQuotNo = "",reStr="",ldtDateStr="";
int llNoOfArt = 0, cnt = 0, llPlcount = 0, llNoOfArt1 = 0, llNoOfArt2 = 0,pos=0,schecnt= 0; int llNoOfArt = 0, cnt = 0,cnt1 = 0 ,llPlcount = 0, llNoOfArt1 = 0, llNoOfArt2 = 0,pos=0,schecnt= 0;
Timestamp ldPlistDate = null, mTranDate = null; Timestamp ldPlistDate = null, mTranDate = null;
Timestamp mOrderDate=null,ldtPlDate=null; Timestamp mOrderDate=null,ldtPlDate=null;
boolean lsDiscFalg = false, lbProceed = false, lbOrdFlag = false; boolean lsDiscFalg = false, lbProceed = false, lbOrdFlag = false;
...@@ -12745,10 +12764,13 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -12745,10 +12764,13 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
if (!"C".equalsIgnoreCase(lstype)) if (!"C".equalsIgnoreCase(lstype))
{ {
sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b" sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b"
+ " where a.scheme_code= b.scheme_code and a.item_code= ? and a.app_from<= ? and a.valid_upto>= ?" + " where a.scheme_code= b.scheme_code and (a.item_code= ? or prod_sch='Y')" // chnages by 16-12-17
+ " and a.app_from<= ? and a.valid_upto>= ? "
+ " and (b.site_code= ? or b.state_code= ? or b.count_code =? )"; + " and (b.site_code= ? or b.state_code= ? or b.count_code =? )";
//or (a.item_code in (select (case when product_code is null then ' ' else product_code end ) from item where item_code = ? )))"
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, lsItemCodeOrd); pstmt1.setString(1, lsItemCodeOrd);
//pstmt1.setString(2, lsItemCodeOrd);
pstmt1.setTimestamp(2, mTranDate); pstmt1.setTimestamp(2, mTranDate);
pstmt1.setTimestamp(3, mTranDate); pstmt1.setTimestamp(3, mTranDate);
pstmt1.setString(4, mSiteCode); pstmt1.setString(4, mSiteCode);
...@@ -12757,6 +12779,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -12757,6 +12779,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
while (rs1.next()) while (rs1.next())
{ {
lsCurscheme = rs1.getString("scheme_code"); lsCurscheme = rs1.getString("scheme_code");
if (lsCurscheme != null || lsCurscheme.trim().length() == 0) if (lsCurscheme != null || lsCurscheme.trim().length() == 0)
...@@ -12794,6 +12817,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -12794,6 +12817,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
break; break;
} }
} }
sql = "Select count(1) as cnt From scheme_applicability A, bom b Where A.scheme_code = b.bom_code And B.bom_code= ?" + " And(? between case when b.min_qty is null then 0 else b.min_qty end" + " And case when b.max_qty is null then 0 else b.max_qty end) and B.promo_term is null"; sql = "Select count(1) as cnt From scheme_applicability A, bom b Where A.scheme_code = b.bom_code And B.bom_code= ?" + " And(? between case when b.min_qty is null then 0 else b.min_qty end" + " And case when b.max_qty is null then 0 else b.max_qty end) and B.promo_term is null";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsCurscheme); pstmt.setString(1, lsCurscheme);
...@@ -12809,7 +12833,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -12809,7 +12833,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
pstmt = null; pstmt = null;
if(cnt == 0)continue; if(cnt == 0)continue;
/* if (cnt == 0) /* if (cnt == 0)
{ {
// Goto Nextrec // Goto Nextrec
}*/ }*/
...@@ -12843,7 +12867,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -12843,7 +12867,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
{ {
System.out.println("lbProceed"+lbProceed); System.out.println("lbProceed"+lbProceed);
lbProceed = true; lbProceed = true;
// break; // break;
} }
if (!lbProceed) if (!lbProceed)
{ {
...@@ -12936,6 +12960,150 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -12936,6 +12960,150 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
lsSchemeCode = ""; lsSchemeCode = "";
} }
} }
/////////////// 09-12-17 start arun for
System.out.println("lsSchemeCode before "+lsSchemeCode+"]");
if(lsSchemeCode != null && lsSchemeCode.trim().length() > 0)// arun
{
System.out.println("lsSchemeCode after inside 121 "+lsSchemeCode+"]");
sql = "SELECT COUNT(*) AS CNT FROM SCHEME_APPLICABILITY WHERE SCHEME_CODE = ? AND PROD_SCH='Y' ";
//"AND ((ITEM_CODE IN (SELECT (CASE WHEN PRODUCT_CODE IS NULL THEN ' ' ELSE PRODUCT_CODE END ) FROM ITEM WHERE ITEM_CODE = ? )) or (ITEM_CODE IN (SELECT (CASE WHEN PRODUCT_CODE IS NULL THEN ' ' ELSE PRODUCT_CODE END ) FROM ITEM WHERE ITEM_CODE = ? )) ) ";
pstmt1 = conn.prepareStatement(sql);
//System.out.println("lsItemCodeOrd in side @@@@111"+lsItemCodeOrd+"]"+"lsSchemeCode in side @@@@2222"+lsSchemeCode+"]");
pstmt1.setString(1, lsSchemeCode);
//pstmt1.setString(2, lsItemCodeOrd);
//System.out.println("lsItemCodeOrd in side @@@@"+sql+"]");
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
cnt = rs1.getInt("cnt");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("prod_sch@@@@@@@["+sql+"]");
System.out.println("lsSchemeCode before "+lsSchemeCode+"]");
if(cnt>0)
{
System.out.println("lsCurscheme"+lsCurscheme+"]");
/*if (rs.next())
{*/
System.out.println(" in side while prod_sch@@@@@@@["+sql+"]");
System.out.println("lsCurscheme"+lsCurscheme+"]");
//lsCurscheme = rs.getString("scheme_code");
System.out.println("lsCurscheme"+lsCurscheme+"]");
sql = "Select count(*) as cnt From scheme_applicability A,bom b "
+ "Where A.scheme_code = b.bom_code And B.bom_code= ?"
+" And (? between case when b.min_qty is null then 0 else b.min_qty end"
+ " And case when b.max_qty is null then 0 else b.max_qty end)"
+ " and B.promo_term is null"
+ " and prod_sch='Y'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsCurscheme);
pstmt.setDouble(2, mQty);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("before cnt1 "+cnt+"]");
if(cnt > 0)
{
sql ="select count (*) as cnt from sch_pur_items where SCHEME_CODE =? and item_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSchemeCode);
pstmt.setString(2, lsItemCodeOrd);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt1 = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
////////
if(cnt1==0)
{
sql ="select count (*) as cnt from SCH_OFFER_ITEMS where SCHEME_CODE =? and item_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSchemeCode);
pstmt.setString(2, lsItemCodeOrd);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt1 = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
////////////
if(cnt1>0)
{
System.out.println(" after if cnt1 "+cnt+"]");
valueXmlString.append("<sch_attr>").append("<![CDATA[" + 'Y' + "]]>").append("</sch_attr>");
setNodeValue( dom, "sch_attr", getAbsString("Y"));
String descr="";
//lsSchemeCode = checkNull(genericUtility.getColumnValue("item_code", dom));
sql = "select DESCR FROM SCH_GROUP_DEF where SCHEME_CODE=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsSchemeCode);
rs = pstmt.executeQuery();
descr="";
if (rs.next())
{
descr = rs.getString("DESCR");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<sch_descr>").append("<![CDATA[" + descr + "]]>").append("</sch_descr>");
setNodeValue( dom, "sch_descr", getAbsString( descr ) );
// valueXmlString.append("<item_code>").append("<![CDATA[" + lsSchemeCode + "]]>").append("</item_code>");
// setNodeValue( dom, "item_code", getAbsString(lsSchemeCode));
System.out.println("descr SCH_GROUP_DEF"+descr+"]");
/*valueXmlString.append("<SCH_ATTR>").append("<![CDATA[" + "Y" + "]]>").append("</SCH_ATTR>");
setNodeValue( dom, "SCH_ATTR", getAbsString("Y"));
*/
lsSchemeCode = "";
schecnt=0;
}
}
//sql = "select (case when apply_cust_list is null then ' ' else apply_cust_list end) as ls_apply_cust_list," + " (case when noapply_cust_list is null then ' ' else noapply_cust_list end) as ls_noapply_cust_list,order_type" + " from scheme_applicability where scheme_code =?";
/*pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsCurscheme);
rs = pstmt.executeQuery()*/
}
}
else
{
valueXmlString.append("<sch_attr>").append("<![CDATA[" + 'N' + "]]>").append("</sch_attr>");
setNodeValue( dom, "sch_attr", getAbsString("N"));
}
sql = "select (case when item_stru is null then 'S' else item_stru end) as ls_item_stru from item where item_code =?"; sql = "select (case when item_stru is null then 'S' else item_stru end) as ls_item_stru from item where item_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -13022,8 +13190,12 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -13022,8 +13190,12 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
} }
else if (!"F".equalsIgnoreCase(lsItemStru) && lsSchemeCode.trim().length() > 0) else if (!"F".equalsIgnoreCase(lsItemStru) && lsSchemeCode.trim().length() > 0)
{ {
///////////////////// arun
// if(cnt1==0)
// {
valueXmlString.append("<item_flg>").append("<![CDATA[" + 'B' + "]]>").append("</item_flg>"); valueXmlString.append("<item_flg>").append("<![CDATA[" + 'B' + "]]>").append("</item_flg>");
setNodeValue( dom, "item_flg", getAbsString("B")); setNodeValue( dom, "item_flg", getAbsString("B"));
// }
System.out.println("lsSchemeCode:::::::7"+lsSchemeCode); System.out.println("lsSchemeCode:::::::7"+lsSchemeCode);
System.out.println("F.equalsIgnoreCase(lsItemStru) && lsSchemeCode.trim().length() > 0 lsSchemeCode"+lsSchemeCode); System.out.println("F.equalsIgnoreCase(lsItemStru) && lsSchemeCode.trim().length() > 0 lsSchemeCode"+lsSchemeCode);
valueXmlString.append("<item_code protect = \"1\">").append("<![CDATA[" + lsSchemeCode + "]]>").append("</item_code>"); valueXmlString.append("<item_code protect = \"1\">").append("<![CDATA[" + lsSchemeCode + "]]>").append("</item_code>");
...@@ -13055,9 +13227,11 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -13055,9 +13227,11 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
{ {
System.out.println("F.equalsIgnoreCase(lsItemStru) && lsSchemeCode.trim().length() == 0 lsSchemeCode"+lsSchemeCode); System.out.println("F.equalsIgnoreCase(lsItemStru) && lsSchemeCode.trim().length() == 0 lsSchemeCode"+lsSchemeCode);
System.out.println("lsSchemeCode:::::::10"+lsSchemeCode); System.out.println("lsSchemeCode:::::::10"+lsSchemeCode);
// if(cnt1==0)
// {
valueXmlString.append("<item_code protect = \"1\">").append("<![CDATA[" + lsSchemeCode + "]]>").append("</item_code>"); valueXmlString.append("<item_code protect = \"1\">").append("<![CDATA[" + lsSchemeCode + "]]>").append("</item_code>");
setNodeValue( dom, "item_code", getAbsString(lsSchemeCode)); setNodeValue( dom, "item_code", getAbsString(lsSchemeCode));
// }
if (schecnt >= 1) if (schecnt >= 1)
{ {
valueXmlString.append("<item_flg>").append("<![CDATA[" + 'B' + "]]>").append("</item_flg>"); valueXmlString.append("<item_flg>").append("<![CDATA[" + 'B' + "]]>").append("</item_flg>");
...@@ -13070,8 +13244,11 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -13070,8 +13244,11 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
valueXmlString.append("<item_flg>").append("<![CDATA[" + 'I' + "]]>").append("</item_flg>"); valueXmlString.append("<item_flg>").append("<![CDATA[" + 'I' + "]]>").append("</item_flg>");
setNodeValue( dom, "item_flg", getAbsString("I")); setNodeValue( dom, "item_flg", getAbsString("I"));
System.out.println("lsSchemeCode:::::::12"+lsSchemeCode); System.out.println("lsSchemeCode:::::::12"+lsSchemeCode);
// if(cnt1==0)
// {
valueXmlString.append("<item_code protect = \"1\">").append("<![CDATA[" + lsItemCodeOrd + "]]>").append("</item_code>"); valueXmlString.append("<item_code protect = \"1\">").append("<![CDATA[" + lsItemCodeOrd + "]]>").append("</item_code>");
setNodeValue( dom, "item_code", getAbsString(lsItemCodeOrd)); setNodeValue( dom, "item_code", getAbsString(lsItemCodeOrd));
// }
} }
reStr=itemChangedDet(dom, dom1, dom2, objContext, "item_code", editFlag, xtraParams); reStr=itemChangedDet(dom, dom1, dom2, objContext, "item_code", editFlag, xtraParams);
pos = reStr.indexOf("<Detail2>"); pos = reStr.indexOf("<Detail2>");
...@@ -13813,17 +13990,22 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -13813,17 +13990,22 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
String sql = ""; String sql = "";
Date orderDate = null; //Date orderDate = null;
String itemCodeOrd = "", siteCode = "", custCode = "", ordDate = "", priceList = "", orderType = "", stateCodeDlv = "", itemCodeParent = "", schemeCode = "", countCode = ""; Timestamp orderDate = null;
String itemCodeOrd = "", siteCode = "", custCode = "", priceList = "", orderType = "", stateCodeDlv = "", itemCodeParent = "", schemeCode = "", countCode = "";
int cnt = 0; int cnt = 0;
Timestamp ordDate=null ;
try try
{ {
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
itemCodeOrd = checkNull(genericUtility.getColumnValue("item_code__ord", dom2)); itemCodeOrd = checkNull(genericUtility.getColumnValue("item_code__ord", dom2));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1)); siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1));
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
ordDate = checkNull(genericUtility.getColumnValue("order_date", dom1)); //ordDate = checkNull(genericUtility.getColumnValue("order_date", dom1));
orderDate = sdf.parse(ordDate); ordDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("order_date", dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
orderDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("order_date", dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
//orderDate = sdf.parse(ordDate);
priceList = checkNull(genericUtility.getColumnValue("price_list", dom1)); priceList = checkNull(genericUtility.getColumnValue("price_list", dom1));
orderType = checkNull(genericUtility.getColumnValue("order_type", dom1)); orderType = checkNull(genericUtility.getColumnValue("order_type", dom1));
stateCodeDlv = checkNull(genericUtility.getColumnValue("state_code__dlv", dom1)); stateCodeDlv = checkNull(genericUtility.getColumnValue("state_code__dlv", dom1));
...@@ -13877,7 +14059,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -13877,7 +14059,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
} }
// gbf_check_scheme // gbf_check_scheme
public String getCheckScheme(String itemCode, String orderType, String custCode, String siteCode, String stateCode, String countCode, Date orderDate) throws ITMException public String getCheckScheme(String itemCode, String orderType, String custCode, String siteCode, String stateCode, String countCode, Timestamp orderDate) throws ITMException
{ {
Connection conn = null; Connection conn = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
...@@ -13911,11 +14093,16 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -13911,11 +14093,16 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
{ {
countCode = ""; countCode = "";
} }
/*java.util.Date utilDate = new java.util.Date(orderDate.toString());
java.sql.Timestamp sq = new java.sql.Timestamp(utilDate.getTime());
*/
System.out.println("sq @@@@@@<<<<<"+orderDate+"]");
sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b " + "where a.scheme_code = b.scheme_code and a.item_code =? " + " and a.app_from <= ? and a.valid_upto >= ? and" + " (b.site_code = ? or b.state_code = ? or b.count_code =? )"; sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b " + "where a.scheme_code = b.scheme_code and a.item_code =? " + " and a.app_from <= ? and a.valid_upto >= ? and" + " (b.site_code = ? or b.state_code = ? or b.count_code =? )";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode); pstmt.setString(1, itemCode);
pstmt.setDate(2, (java.sql.Date) orderDate); pstmt.setTimestamp(2, orderDate);
pstmt.setDate(3, (java.sql.Date) orderDate); pstmt.setTimestamp(3, orderDate);
pstmt.setString(4, siteCode); pstmt.setString(4, siteCode);
pstmt.setString(5, stateCode); pstmt.setString(5, stateCode);
pstmt.setString(6, countCode); pstmt.setString(6, countCode);
...@@ -14025,15 +14212,17 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14025,15 +14212,17 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
String itemCodeOrd = "", siteCode = "", custCode = "", ordDate = "", priceList = "", orderType = "", stateCodeDlv = "", itemCodeParent = ""; String itemCodeOrd = "", siteCode = "", custCode = "", ordDate = "", priceList = "", orderType = "", stateCodeDlv = "", itemCodeParent = "";
String countCodeDlv = "", saleOrder = "", schemeCode = "", applyCustList = "", noApplyCustList = "", appOrderType = "", lsToken = "", round = ""; String countCodeDlv = "", saleOrder = "", schemeCode = "", applyCustList = "", noApplyCustList = "", appOrderType = "", lsToken = "", round = "";
String prevScheme = "", schemeCode1 = "", applyCust = "", custSchemeCode = "", lineNo = "", browItemCode = "", currLineNo = "", itemCodeParentCurr = ""; String prevScheme = "", schemeCode1 = "", applyCust = "", custSchemeCode = "", lineNo = "", browItemCode = "", currLineNo = "", itemCodeParentCurr = "";
String errString = ""; String errString = "",productCodeCurr="",productCode="";
String errCode = ""; String errCode = "";
String errorType = ""; String errorType = "",schAttr="",prodCodeOff="",prodCodePur="";
String childNodeName = null; String childNodeName = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String childNodeName1=null;
int childNodeListLength; int childNodeListLength;
int ctr = 0; int ctr = 0, cnt1=0;
int currentFormNo = 0; int currentFormNo = 0,purcBase=0,schAllowence=0;
int schemeType=0;
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
...@@ -14042,7 +14231,9 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14042,7 +14231,9 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
int cnt = 0; int cnt = 0;
double qty = 0; double qty = 0;
long schCnt = 0; long schCnt = 0;
Date orderDate = null, appFrom = null, validUpto = null; //Date appFrom = null, validUpto = null;
Timestamp orderDate=null,appFrom = null, validUpto = null;
//Date orderDate = null;
boolean lbParent = false, lbProceed = false; boolean lbParent = false, lbProceed = false;
; ;
try try
...@@ -14055,10 +14246,12 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14055,10 +14246,12 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
} }
itemCodeOrd = checkNull(genericUtility.getColumnValue("item_code__ord", dom2)); itemCodeOrd = checkNull(genericUtility.getColumnValue("item_code__ord", dom2));
System.out.println("itemCodeOrd ");
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1)); siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1));
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
ordDate = checkNull(genericUtility.getColumnValue("order_date", dom1)); ordDate = checkNull(genericUtility.getColumnValue("order_date", dom1));
orderDate = sdf.parse(ordDate); orderDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("order_date", dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
//orderDate = sdf.parse(ordDate);
qty = checkIntNull(genericUtility.getColumnValue("quantity", dom2)); qty = checkIntNull(genericUtility.getColumnValue("quantity", dom2));
orderType = checkNull(genericUtility.getColumnValue("order_type", dom1)); orderType = checkNull(genericUtility.getColumnValue("order_type", dom1));
stateCodeDlv = checkNull(genericUtility.getColumnValue("state_code__dlv", dom1)); stateCodeDlv = checkNull(genericUtility.getColumnValue("state_code__dlv", dom1));
...@@ -14073,8 +14266,20 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14073,8 +14266,20 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
System.out.println("orderType==" + orderType); System.out.println("orderType==" + orderType);
System.out.println("stateCodeDlv==" + stateCodeDlv); System.out.println("stateCodeDlv==" + stateCodeDlv);
System.out.println("countCodeDlv==" + countCodeDlv); System.out.println("countCodeDlv==" + countCodeDlv);
System.out.println("dom @@@@12"+dom+"]");
System.out.println("dom @@@@13"+dom1+"]");
System.out.println("dom @@@@14"+dom2+"]");
System.out.println("saleOrder==" + saleOrder); System.out.println("saleOrder==" + saleOrder);
System.out.println("schAttr value of 10"+schAttr+"]");
schAttr = checkNull(genericUtility.getColumnValue("sch_attr", dom));
System.out.println("dom @@@@"+dom+"]");
System.out.println("schAttr value of 20"+schAttr+"]");
if(!("Y").equalsIgnoreCase(schAttr))
{
System.out.println("schAttr value of 30"+schAttr+"]");
sql = "select item_code__parent from item where item_code = ? and item_code__parent is not null"; sql = "select item_code__parent from item where item_code = ? and item_code__parent is not null";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCodeOrd); pstmt.setString(1, itemCodeOrd);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -14142,8 +14347,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14142,8 +14347,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b where a.scheme_code= b.scheme_code and a.item_code= ? and a.app_from <= ? and a.valid_upto>= ? and (b.site_code= ? or b.state_code = ? or b.count_code= ?)"; sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b where a.scheme_code= b.scheme_code and a.item_code= ? and a.app_from <= ? and a.valid_upto>= ? and (b.site_code= ? or b.state_code = ? or b.count_code= ?)";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCodeOrd); pstmt.setString(1, itemCodeOrd);
pstmt.setDate(2, (java.sql.Date) orderDate); pstmt.setTimestamp(2, orderDate);
pstmt.setDate(3, (java.sql.Date) orderDate); pstmt.setTimestamp(3, orderDate);
pstmt.setString(4, siteCode); pstmt.setString(4, siteCode);
pstmt.setString(5, stateCodeDlv); pstmt.setString(5, stateCodeDlv);
pstmt.setString(6, countCodeDlv); pstmt.setString(6, countCodeDlv);
...@@ -14170,14 +14375,14 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14170,14 +14375,14 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
} else if (appOrderType != null && appOrderType.trim().length() > 0) } else if (appOrderType != null && appOrderType.trim().length() > 0)
{ {
lbProceed = false; lbProceed = false;
do /* do
{ {
lsToken = distCommon.getToken(appOrderType, ","); lsToken = distCommon.getToken(appOrderType, ",");
if (orderType.trim().length() == lsToken.trim().length()) if (orderType.trim().length() == lsToken.trim().length())
{ {
lbProceed = true; lbProceed = true;
} }
} while (appOrderType.trim().length() > 0); } while (appOrderType.trim().length() > 0);*/
} }
prevScheme = schemeCode1; prevScheme = schemeCode1;
schemeCode1 = schemeCode; schemeCode1 = schemeCode;
...@@ -14242,8 +14447,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14242,8 +14447,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
appFrom = rs.getDate("app_from"); appFrom = rs.getTimestamp("app_from");
validUpto = rs.getDate("valid_upto"); validUpto = rs.getTimestamp("valid_upto");
} }
pstmt.close(); pstmt.close();
rs.close(); rs.close();
...@@ -14256,7 +14461,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14256,7 +14461,7 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
pstmt.setString(2, custCode); pstmt.setString(2, custCode);
pstmt.setString(3, itemCodeParent); pstmt.setString(3, itemCodeParent);
pstmt.setString(4, schemeCode1); pstmt.setString(4, schemeCode1);
pstmt.setDate(5, (java.sql.Date) orderDate); pstmt.setTimestamp(5, orderDate);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
...@@ -14300,8 +14505,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14300,8 +14505,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2, custCode); pstmt.setString(2, custCode);
pstmt.setString(3, saleOrder); pstmt.setString(3, saleOrder);
pstmt.setDate(4, (java.sql.Date) orderDate); pstmt.setTimestamp(4, orderDate);
pstmt.setDate(5, (java.sql.Date) orderDate); pstmt.setTimestamp(5, orderDate);
pstmt.setString(6, itemCodeParent); pstmt.setString(6, itemCodeParent);
pstmt.setString(7, nature); pstmt.setString(7, nature);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -14324,8 +14529,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14324,8 +14529,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2, custCode); pstmt.setString(2, custCode);
pstmt.setString(3, saleOrder); pstmt.setString(3, saleOrder);
pstmt.setDate(4, (java.sql.Date) orderDate); pstmt.setTimestamp(4, orderDate);
pstmt.setDate(5, (java.sql.Date) orderDate); pstmt.setTimestamp(5, orderDate);
pstmt.setString(6, itemCodeParent); pstmt.setString(6, itemCodeParent);
pstmt.setString(7, nature); pstmt.setString(7, nature);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -14362,8 +14567,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14362,8 +14567,8 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2, custCode); pstmt.setString(2, custCode);
pstmt.setString(3, saleOrder); pstmt.setString(3, saleOrder);
pstmt.setDate(4, (java.sql.Date) orderDate); pstmt.setTimestamp(4, orderDate);
pstmt.setDate(5, (java.sql.Date) orderDate); pstmt.setTimestamp(5, orderDate);
pstmt.setString(6, itemCodeParent); pstmt.setString(6, itemCodeParent);
pstmt.setString(7, itemCodeParent); pstmt.setString(7, itemCodeParent);
pstmt.setString(8, nature); pstmt.setString(8, nature);
...@@ -14551,16 +14756,1146 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal ...@@ -14551,16 +14756,1146 @@ public class SalesOrderIC extends ValidatorEJB implements SalesOrderICLocal, Sal
} }
} }
} }
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} }
return errCode; else {
try
{
System.out.println("Arun pal testing : currentFormNo :" + currentFormNo);
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("Priyanka testing : currentFormNo :" + currentFormNo);
} }
// gbf_get_scheme_code itemCodeOrd = checkNull(genericUtility.getColumnValue("item_code__ord", dom2));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1));
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
ordDate = checkNull(genericUtility.getColumnValue("order_date", dom1));
//orderDate = sdf.parse(ordDate);
//ordDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("order_date", dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
orderDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("order_date", dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
qty = checkIntNull(genericUtility.getColumnValue("quantity", dom2));
orderType = checkNull(genericUtility.getColumnValue("order_type", dom1));
stateCodeDlv = checkNull(genericUtility.getColumnValue("state_code__dlv", dom1));
countCodeDlv = checkNull(genericUtility.getColumnValue("count_code__dlv", dom1));
saleOrder = checkNull(genericUtility.getColumnValue("sale_order", dom2));
System.out.println("itemCodeOrd==" + itemCodeOrd);
System.out.println("siteCode==" + siteCode);
System.out.println("custCode==" + custCode);
System.out.println("ordDate==" + ordDate);
System.out.println("orderDate==" + orderDate);
System.out.println("qty==" + qty);
System.out.println("orderType==" + orderType);
System.out.println("stateCodeDlv==" + stateCodeDlv);
System.out.println("countCodeDlv==" + countCodeDlv);
System.out.println("saleOrder==" + saleOrder);
sql = "select product_code from item where item_code = ? and product_code is not null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCodeOrd);
rs = pstmt.executeQuery();
if (rs.next())
{
itemCodeParent = rs.getString("product_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (itemCodeParent == null || itemCodeParent.trim().length() == 0)
{
sql = "select product_code from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCodeOrd);
rs = pstmt.executeQuery();
if (rs.next())
{
itemCodeParent = rs.getString("product_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (itemCodeParent == null || itemCodeParent.trim().length() > 0)
{
sql = "select count(1) from item where product_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCodeOrd);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0)
{
itemCodeParent = itemCodeOrd;
lbParent = true;
}
}
}
if (itemCodeParent.trim().length() > 0)
{
if (orderType == null)
{
orderType = "";
}
if (siteCode == null)
{
siteCode = "";
}
if (stateCodeDlv == null)
{
stateCodeDlv = "";
}
if (countCodeDlv == null)
{
countCodeDlv = "";
}
schAttr = checkNull(genericUtility.getColumnValue("sch_attr", dom1));
/* if(("Y").equalsIgnoreCase(schAttr))
{*/
sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b where a.scheme_code= b.scheme_code and (a.item_code= ? or prod_sch='Y') and a.app_from <= ? and a.valid_upto>= ? and (b.site_code= ? or b.state_code = ? or b.count_code= ?)";// and prod_sch='Y'";
pstmt = conn.prepareStatement(sql);
//pstmt.setString(1, itemCodeParent);
pstmt.setString(1, itemCodeOrd);
/*pstmt.setDate(2, (java.sql.Date) orderDate);
pstmt.setDate(3, (java.sql.Date) orderDate);*/
pstmt.setTimestamp(2, orderDate);
pstmt.setTimestamp(3, orderDate);
pstmt.setString(4, siteCode);
pstmt.setString(5, stateCodeDlv);
pstmt.setString(6, countCodeDlv);
rs=pstmt.executeQuery();
while (rs.next())
{
schemeCode = rs.getString("scheme_code");
String sql1 = "select (case when apply_cust_list is null then ' ' else apply_cust_list end) as apply_cust_list, (case when noapply_cust_list is null then ' ' else noapply_cust_list end)as noapply_cust_list,order_type from scheme_applicability where scheme_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, schemeCode);
rs1 = pstmt1.executeQuery();
System.out.println("schemeCode excute query "+schemeCode+']');
if (rs1.next())
{
applyCustList = rs1.getString("apply_cust_list");
noApplyCustList = rs1.getString("noapply_cust_list");
appOrderType = rs1.getString("order_type");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("apply_cust_list"+applyCustList+"noapply_cust_list"+noApplyCustList+"appOrderType");
if (orderType.trim() == "NE" && (appOrderType == null || appOrderType.trim().length() == 0))
{
break;
} else if (appOrderType != null && appOrderType.trim().length() > 0)
{ System.out.println(" inside while apply_cust_list"+applyCustList+"noapply_cust_list"+noApplyCustList+"appOrderType");
lbProceed = false;
lsToken = distCommon.getToken(appOrderType, ",");
if(orderType.contains(lsToken))
{
System.out.println("lbProceed"+lbProceed);
lbProceed = true;
// break;
}
if (!lbProceed)
{
System.out.println("Inside lbproceed");
continue;
// goto Nextrec
}
/*lsToken = distCommon.getToken(appOrderType, ",");
if (orderType.trim().length() == lsToken.trim().length())
{
lbProceed = true;
}
} while (appOrderType.trim().length() > 0);*/
}
System.out.println("prevScheme"+prevScheme+"schemeCode1"+schemeCode1+"schemeCode1"+schemeCode1+"schemeCode+"+schemeCode+"]");
prevScheme = schemeCode1;
schemeCode1 = schemeCode;
if (applyCustList.trim().length() > 0)
{
System.out.println("prevScheme"+prevScheme+"applyCustList"+applyCustList+"]");
schemeCode1 = "";
applyCust = distCommon.getToken(applyCustList, ",");
System.out.println("applyCust"+applyCust+"]");
System.out.println("custCode"+custCode+"]");
if(applyCust.contains(custCode))
{
System.out.println("applyCust"+applyCust+"]");
schemeCode1 = schemeCode;
custSchemeCode = schemeCode;
System.out.println("lbProceed"+lbProceed);
lbProceed = true;
break;
// break;
}
if (!lbProceed)
{
System.out.println("Inside lbproceed");
continue;
}
/*do
{
applyCust = distCommon.getToken(applyCustList, ",");
if (applyCust.trim().length() == custCode.trim().length())
{
schemeCode1 = schemeCode;
custSchemeCode = schemeCode;
break;
}
} while (applyCustList.trim().length() > 0);*/
}
if (noApplyCustList.trim().length() > 0 && schemeCode != null)
{
applyCust = distCommon.getToken(noApplyCustList, ",");
if(noApplyCustList.contains(custCode))
{
schemeCode1 = "";
// break;
}
if (!lbProceed)
{
System.out.println("Inside lbproceed");
continue;
}
/*do
{
applyCust = distCommon.getToken(noApplyCustList, ",");
if (noApplyCustList.trim().length() == custCode.trim().length())
{
schemeCode1 = "";
}
} while (noApplyCustList.trim().length() > 0);*/
}
if (schemeCode1 != null)
{
schCnt++;
} else if (schCnt == 1)
{
System.out.println("schemeCode11515"+schemeCode1);
schemeCode1 = prevScheme;
}
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (schCnt == 0)
{
errCode = "VTFREEQTY";// Scheme is not applicable for the
// entered item code
errList.add(errCode);
errFields.add(checkNull(" ".toLowerCase()));
//errFields.add(checkNull(childNodeName.toLowerCase()));
System.out.println("Scheme is not applicable for the entered item code");
} else if (schCnt > 1)
{
errCode = "VTITEM10";// Item cannot have more than one
// scheme applicable for same period.
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Item cannot have more than one scheme applicable for same period.");
} else if (custSchemeCode.trim().length() > 0)
{
schemeCode = custSchemeCode;
}
/////////14-DEC-2017
String sql1 ="select count (*) as cnt from SCH_OFFER_ITEMS where SCHEME_CODE =? and item_code=?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, schemeCode);
pstmt1.setString(2, itemCodeOrd);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
cnt1 = rs1.getInt("cnt");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if(cnt1==0)
{
errCode = "VTINFEEQTY";// Scheme is not applicable for the
// entered item code
errList.add(errCode);
System.out.println("errList"+errList+"]");
//errFields.add(childNodeName.toLowerCase());
System.out.println("invalid free quantity for this item code ");
}
///////// 14-DEC-2017
sql1 = "select app_from, valid_upto from scheme_applicability where scheme_code =?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, schemeCode1);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
appFrom = rs1.getTimestamp("app_from");
validUpto = rs1.getTimestamp("valid_upto");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
sql1 = "select tot_charge_qty, tot_free_qty " +
//"tot_sample_qty,tot_bonus_qty " +
" from prd_scheme_trace where site_code= ? and cust_code =? " +
" and item_code = ? and scheme_code= ? and ? between eff_from and valid_upto";
System.out.println("Toatal charge qty1"+totChargeQty);
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, custCode);
pstmt1.setString(3, itemCodeParent);
pstmt1.setString(4, schemeCode1);
pstmt1.setTimestamp(5, orderDate);
//pstmt.setTimestamp(3, orderDate);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
totChargeQty = rs1.getDouble("tot_charge_qty");
totFreeQty = rs1.getDouble("tot_free_qty");
//totSampleQty = rs.getDouble("tot_sample_qty");
//totBonusQty = rs.getDouble("tot_bonus_qty");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
if (totChargeQty == 0)
{
totChargeQty = 0;
}
if (totFreeQty == 0)
{
totFreeQty = 0;
}
/*if (totSampleQty == 0)
{
totSampleQty = 0;
}
if (totBonusQty == 0)
{
totBonusQty = 0;
}
*/ if (minQty == 0)
{
minQty = 0;
}
if (saleOrder == null)
{
saleOrder = "";
}
if (lbParent == false)
{
sql1= " select sum(case when nature ='F' then quantity else 0 end) as unconfirmFreeQty " +
//"sum(case when nature ='B' then quantity else 0 end)as unconfirmBonusQty, " +
//"sum(case when nature ='S' then quantity else 0 end)as unconfirmSampleQty " +
" from sorder a,sorddet b where a.sale_order = b.sale_order and a.site_code = ? " +
" and a.cust_code = ? and a.sale_order <> ? and a.order_date between ? and ?" +
" and b.item_code__ord in (select item_code from item where product_code = ?)" +
" and (case when a.confirmed is null then 'N' else a.confirmed end )= 'N' and b.nature in ('F')";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, custCode);
pstmt1.setString(3, saleOrder);
pstmt1.setTimestamp(4, orderDate);
pstmt1.setTimestamp(5, orderDate);
//pstmt1.setTimestamp(4, appFrom);
//pstmt1.setTimestamp(5, validUpto);
pstmt1.setString(6, itemCodeParent);
//pstmt1.setString(7, nature);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
//unConfTotChargeQty = rs1.getDouble("unconfirmChargeQty");
unConfTotFreeQty = rs1.getDouble("unconfirmFreeQty");
System.out.println("unConfTotFreeQty separte free"+unConfTotFreeQty);
//unConfTotSampleQty = rs.getDouble("unconfirmSampleQty");
//unConfTotBonusQty = rs.getDouble("unconfirmBonusQty");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
sql1 = "select sum(case when nature ='C' then quantity else 0 end) as unconfirmChargeQty " +
//"sum(case when nature ='B' then quantity else 0 end)as unconfirmBonusQty, " +
//"sum(case when nature ='S' then quantity else 0 end)as unconfirmSampleQty " +
" from sorder a,sorddet b where a.sale_order = b.sale_order and a.site_code = ? " +
" and a.cust_code = ? and a.sale_order <> ? and a.order_date between ? and ?" +
" and b.item_code__ord in (select item_code from item where product_code = ?)" +
" and (case when a.confirmed is null then 'N' else a.confirmed end )= 'N' and b.nature in ('C')";
/* sql1 = "select sum(case when nature ='C' then quantity else 0 end) as unconfirmChargeQty ," +
" sum(case when nature ='F' then quantity else 0 end) as unconfirmFreeQty " +
//"sum(case when nature ='B' then quantity else 0 end)as unconfirmBonusQty, " +
//"sum(case when nature ='S' then quantity else 0 end)as unconfirmSampleQty " +
" from sorder a,sorddet b where a.sale_order = b.sale_order and a.site_code = ? " +
" and a.cust_code = ? and a.sale_order <> ? and a.order_date between ? and ?" +
" and b.item_code__ord in (select item_code from item where product_code = ?)" +
" and (case when a.confirmed is null then 'N' else a.confirmed end )= 'N' and b.nature in ('C' ,?)";*/
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, custCode);
pstmt1.setString(3, saleOrder);
pstmt1.setTimestamp(4, orderDate);
pstmt1.setTimestamp(5, orderDate);
//pstmt1.setTimestamp(4, appFrom);
//pstmt1.setTimestamp(5, validUpto);
pstmt1.setString(6, itemCodeParent);
// pstmt1.setString(7, nature);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
unConfTotChargeQty = rs1.getDouble("unconfirmChargeQty");
// unConfTotFreeQty = rs1.getDouble("unconfirmFreeQty");
System.out.println("unConfTotChargeQty separte "+unConfTotChargeQty);
//unConfTotSampleQty = rs.getDouble("unconfirmSampleQty");
//unConfTotBonusQty = rs.getDouble("unconfirmBonusQty");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
} else
{
sql1 = "select sum(case when nature ='C' then quantity else 0 end) as unconfirmChargeQty " +
//" sum(case when nature ='F' then quantity else 0 end) as unconfirmFreeQty " +
//"sum(case when nature ='B' then quantity else 0 end)as unconfirmBonusQty, " +
//"sum(case when nature ='S' then quantity else 0 end)as unconfirmSampleQty " +
" from sorder a,sorddet b where a.sale_order = b.sale_order and a.site_code = ? " +
" and a.cust_code = ? and a.sale_order <> ? and a.order_date between ? and ? " +
" and b.item_code__ord in (select item_code from item where product_code = ?)" +
" and (case when a.confirmed is null then 'N' else a.confirmed end )= 'N' and b.nature in ('C')";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, custCode);
pstmt1.setString(3, saleOrder);
pstmt1.setTimestamp(4, appFrom);
pstmt1.setTimestamp(5, validUpto);
pstmt1.setString(6, itemCodeParent);
//pstmt1.setString(7, nature);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
unConfTotChargeQty = rs1.getDouble("unconfirmChargeQty");
//unConfTotFreeQty = rs1.getDouble("unconfirmFreeQty");
System.out.println("Toatal charge qty3"+totChargeQty);
//unConfTotSampleQty = rs.getDouble("unconfirmSampleQty");
//unConfTotBonusQty = rs.getDouble("unconfirmBonusQty");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
sql1 = " select sum(case when nature ='F' then quantity else 0 end) as unconfirmFreeQty " +
//"sum(case when nature ='B' then quantity else 0 end)as unconfirmBonusQty, " +
//"sum(case when nature ='S' then quantity else 0 end)as unconfirmSampleQty " +
" from sorder a,sorddet b where a.sale_order = b.sale_order and a.site_code = ? " +
" and a.cust_code = ? and a.sale_order <> ? and a.order_date between ? and ? " +
" and b.item_code__ord in (select item_code from item where product_code = ?)" +
" and (case when a.confirmed is null then 'N' else a.confirmed end )= 'N' and b.nature in ('F')";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, custCode);
pstmt1.setString(3, saleOrder);
pstmt1.setTimestamp(4, appFrom);
pstmt1.setTimestamp(5, validUpto);
pstmt1.setString(6, itemCodeParent);
//pstmt1.setString(7, nature);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
// unConfTotChargeQty = rs1.getDouble("unconfirmChargeQty");
unConfTotFreeQty = rs1.getDouble("unconfirmFreeQty");
System.out.println("Toatal charge qty3"+totChargeQty);
//unConfTotSampleQty = rs.getDouble("unconfirmSampleQty");
//unConfTotBonusQty = rs.getDouble("unconfirmBonusQty");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
}
if (unConfTotChargeQty == 0)
{
unConfTotChargeQty = 0;
}
if (unConfTotFreeQty == 0)
{
unConfTotFreeQty = 0;
}
/*if (unConfTotSampleQty == 0)
{
unConfTotSampleQty = 0;
}
if (unConfTotBonusQty == 0)
{
unConfTotBonusQty = 0;
}
*/
sql1 = "select sum(case when nature ='C' then quantity else 0 end) - sum(case when nature ='C' then qty_desp else 0 end)as confirmChargeQty," +
" sum(case when nature ='F' then quantity else 0 end)- sum(case when nature ='F' then qty_desp else 0 end) as confirmFreeQty" +
//" sum(case when nature ='B' then quantity else 0 end)- sum(case when nature ='B' then qty_desp else 0 end) as confirmBonusQty," +
//" sum(case when nature ='S' then quantity else 0 end)- sum(case when nature ='S' then qty_desp else 0 end) as confirmSampleQty " +
" from sorditem ,SORDER where sorditem.sale_order = SORDER.SALE_ORDER AND sorditem.site_code = ? AND SORDER.cust_code =? " +
" and sorditem.sale_order <> ? and sorditem.line_type <> 'B' and sorditem.order_date between ? and ? " +
" and (sorditem.item_code in (select item_code from item where product_code =?) OR sorditem.item_code = ?)" +
" and sorditem.nature in ('C' ,?) ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, custCode);
pstmt1.setString(3, saleOrder);
//pstmt1.setTimestamp(4, appFrom);
//pstmt1.setTimestamp(5, validUpto);
pstmt1.setTimestamp(4, orderDate);
pstmt1.setTimestamp(5, orderDate);
pstmt1.setString(6, itemCodeParent);
pstmt1.setString(7, itemCodeParent);
pstmt1.setString(8, nature);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
System.out.println("Toatal charge qty4"+totChargeQty);
ConfTotChargeQty = rs1.getDouble("confirmChargeQty");
ConfTotFreeQty = rs1.getDouble("confirmFreeQty");
//ConfTotSampleQty = rs.getDouble("unconfirmSampleQty");
//ConfTotBonusQty = rs.getDouble("unconfirmBonusQty");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
if (ConfTotChargeQty == 0)
{
ConfTotChargeQty = 0;
}
if (ConfTotFreeQty == 0)
{
ConfTotFreeQty = 0;
}
/*if (ConfTotSampleQty == 0)
{
ConfTotSampleQty = 0;
}
if (ConfTotBonusQty == 0)
{
ConfTotBonusQty = 0;
}
*/
/*System.out.println("currLineNo 15-DEC-17"+currLineNo+"");
currLineNo = checkNull(genericUtility.getColumnValue("line_no", dom));
prvChargeQty = 0;
prvFreeQty = 0;
prvBonusQty = 0;
prvSampleQty = 0;
parentNodeList = dom.getElementsByTagName("Detail2");
//parentNode = parentNodeList.item(0);
int parentNodeListLength = parentNodeList.getLength();
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("currLineNo 12121"+currLineNo+"");
for (ctr = 0; ctr < parentNodeListLength; ctr++)
{
System.out.println("parentNodeListLength"+parentNodeListLength+"");
parentNode = parentNodeList.item(ctr);
//childNode = childNodeList.item(ctr);
//childNodeName = childNode.getNodeName();
lineNo = checkNull(genericUtility.getColumnValue("line_no", dom2));
nature = checkNull(genericUtility.getColumnValue("nature", dom2));
browItemCode = checkNull(genericUtility.getColumnValue("item_code", dom2));
if (currLineNo != lineNo)
{
cnt = 0;
sql = "select product_code from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, browItemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemCodeParentCurr = rs.getString("product_code");
System.out.println("itemCodeParentCurr: ====" + productCodeCurr);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (itemCodeParentCurr == null || itemCodeParentCurr.trim().length() == 0)
{
sql = "select count(1) from item where product_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, browItemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt > 0)
{
itemCodeParentCurr = browItemCode;
}
}
if (itemCodeParentCurr.trim() == itemCodeParentCurr.trim())
{
quantity = checkDoubleNull(genericUtility.getColumnValue("quantity", dom2));
if (nature.equals("F"))
{
prvFreeQty = prvFreeQty + quantity;
} else if (nature.equals("B"))
{
prvBonusQty = prvBonusQty + quantity;
} else if (nature.equals("S"))
{
prvSampleQty = prvSampleQty + quantity;
} else
{
prvChargeQty = prvChargeQty + quantity;
}
}
}
}
*/
double rate = checkDoubleNull(genericUtility.getColumnValue("rate", dom));
System.out.println("schemeCode1 type @>>>>>>>>PS2"+rate+"]");
sql="select scheme_type,purc_base, sch_allowence,PROD_CODE__OFF,PROD_CODE__PUR from sch_group_def where scheme_code=? ";
//"and product_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, schemeCode);
//pstmt.setInt(1, itemCodeParent);
rs = pstmt.executeQuery();
if (rs.next())
{
schemeType = rs.getInt("scheme_type");
purcBase = rs.getInt("purc_base");
schAllowence = rs.getInt("sch_allowence");
prodCodeOff = rs.getString("PROD_CODE__OFF");
prodCodePur = rs.getString("PROD_CODE__PUR");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
Node currDetail1=null;
prvChargeQty = 0;
prvFreeQty = 0;
prvBonusQty = 0;
prvSampleQty = 0;
int count=0;
currLineNo = checkNull(genericUtility.getColumnValue("line_no", dom));
NodeList detailList1 = dom2.getElementsByTagName("Detail2");
//System.out.println("Dom print"+genericUtility.serializeDom(dom2));
//System.out.println("current dom print"+genericUtility.serializeDom(dom));
int noOfDetails = detailList1.getLength();
//System.out.println("noOfDetails"+noOfDetails);
for(int ctr1 = 0; ctr1 < noOfDetails; ctr1++)
{
currDetail1 = detailList1.item(ctr1);
// System.out.println("noOfDetails inside for loop"+noOfDetails);
/* System.out.println("detItemCode:"+genericUtility.getColumnValueFromNode("line_no", currDetail1));
System.out.println("detItemCode:"+genericUtility.getColumnValueFromNode("nature", currDetail1));
System.out.println("detItemCode:"+genericUtility.getColumnValueFromNode("item_code", currDetail1));
*/
//parentNode = parentNodeList.item(ctr);
//childNode = childNodeList.item(ctr);
//childNodeName = childNode.getNodeName();
lineNo = checkNull(genericUtility.getColumnValueFromNode("line_no", currDetail1));
nature = checkNull(genericUtility.getColumnValueFromNode("nature", currDetail1));
browItemCode = checkNull(genericUtility.getColumnValueFromNode("item_code", currDetail1));
quantity = checkDoubleNull(genericUtility.getColumnValueFromNode("quantity", currDetail1));
System.out.println("currLineNo: ====" + currLineNo+"]lineNo"+lineNo+"");
if (!currLineNo.equalsIgnoreCase(lineNo))
{
System.out.println("Inside if 00000" );
cnt = 0;
sql1 = "select product_code from item where item_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, browItemCode);
System.out.println("browItemCode"+browItemCode+"]");
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
itemCodeParentCurr = rs1.getString("product_code");
System.out.println("itemCodeParentCurr: ====" + itemCodeParentCurr);
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
///////////
/* System.out.println("itemCodeParentCurr444: ====" + itemCodeParentCurr+"]");
if (itemCodeParentCurr == null || itemCodeParentCurr.trim().length() == 0)
{
sql1 = "select count(1) from item where product_code = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, browItemCode);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
cnt = rs1.getInt(1);
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
if (cnt > 0)
{
itemCodeParentCurr = browItemCode;
}*/
// }
System.out.println("itemCodeParentCurr444: ====" + itemCodeParentCurr+"]prodCodeOff"+prodCodeOff+"");
if (itemCodeParentCurr.trim().equalsIgnoreCase(prodCodeOff.trim()))
{
System.out.println("insideitemCodeParentCurr555: ====" + itemCodeParentCurr+"]prodCodeOff"+prodCodeOff+"");
if (nature.equals("F"))
{
prvFreeQty = prvFreeQty + quantity;
}
System.out.println("prvFreeQty insdie F"+prvFreeQty+"prvChargeQty"+prvChargeQty+"]");
}
System.out.println("itemCodeParentCurr666: ====" + itemCodeParentCurr+"]prodCodePur"+prodCodeOff+"");
if (itemCodeParentCurr.trim().equalsIgnoreCase( prodCodePur.trim()))
{
System.out.println("insideitemCodeParentCurr777: ====" + itemCodeParentCurr+"]prodCodeOff"+prodCodeOff+"");
if (nature.equals("C"))
{
prvChargeQty = prvChargeQty + quantity;
}
System.out.println("prvChargeQty insdie c"+prvChargeQty+"prvFreeQty"+prvFreeQty+"]");
}
}
}
System.out.println("final prvChargeQty insdie c"+prvChargeQty+"prvFreeQty"+prvFreeQty+"]");
////////////////////////////////start by arun for scheme group validation
System.out.println("Scheme type @<<<<<<<"+quantity+"]");
System.out.println("schemeCode1 type @>>>>>>>>"+schemeCode1+"]");
sql = "select count(1) from SCH_OFFER_ITEMS where scheme_code=? and item_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, schemeCode);
pstmt.setString(2, itemCodeOrd);
// pstmt.setDouble(3, chargeQty);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt == 0)
{
errCode = "VTFREEQTY";// Chargeable quantity of group of
// items is not eligible for the free
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Chargeable quantity of group of items is not eligible for the free quantity");
}
System.out.println("schemeCode1 type @>>>>>>>>PS1"+schemeCode1+"]");
System.out.println("unConfTotChargeQty "+unConfTotChargeQty+ "prvChargeQty "+prvChargeQty+"totChargeQty "+totChargeQty+ "ConfTotChargeQty "+ConfTotChargeQty+"]");
System.out.println("chargeQty["+chargeQty+"]");
System.out.println("Scheme type validation <<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>> start");
if(schemeType==0)
{
System.out.println("Scheme type validation type 0 start");
System.out.println("schemeType condition 1"+schemeType+"]"+"itemCodeOrd "+itemCodeOrd+"itemCodeParentCurr "+itemCodeParentCurr+"]");
////////////////////// ended by arun pal
System.out.println("chargeQty"+chargeQty+"]");
chargeQty = unConfTotChargeQty + prvChargeQty + totChargeQty + ConfTotChargeQty;
/* sql = "Select count(1) From bom Where bom_code = ? And ? between case when min_qty is null then 0 else min_qty end" +
" And case when max_qty is null then 0 else max_qty end";*/
sql = "select count(1) from SCH_OFFER_ITEMS where scheme_code=? and item_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, schemeCode);
pstmt.setString(2, itemCodeOrd);
//pstmt.setDouble(3, chargeQty);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt == 0)
{
System.out.println("chargeQty1"+chargeQty+"]");
errCode = "VTFREEQTY";// Chargeable quantity of group of
// items is not eligible for the free
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("@@@@@@@@@@@@Chargeable quantity of group of items is not eligible for the free quantity");
}
/* sql = "select bom.batch_qty,bomdet.qty_per,bomdet.min_qty ,bomdet.app_min_qty,bomdet.app_max_qty,bomdet.round ,bomdet.round_to from bom, bomdet where bom.bom_code = bomdet.bom_code and bomdet.bom_code = ? and bomdet.nature = ?";
pstmt.setString(1, schemeCode1);
pstmt.setString(1, nature);
rs = pstmt.executeQuery();
if (rs.next())
{
batQty = rs.getDouble("batch_qty");
qtyPer = rs.getDouble("qty_per");
minQty = rs.getDouble("min_qty");
appMinQty = rs.getDouble("app_min_qty");
appMaxQty = rs.getDouble("app_max_qty");
round = rs.getString("round");
roundTo = rs.getDouble("round_to");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;*/
sql = "select purc_base, sch_allowence from sch_group_def where scheme_code = ? and scheme_type = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, schemeCode);
pstmt.setInt(2, schemeType);
rs = pstmt.executeQuery();
if (rs.next())
{
purcBase = rs.getInt("purc_base");
schAllowence = rs.getInt("sch_allowence");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (chargeQty > 0)
{
freeQty = (chargeQty * schAllowence / purcBase);
}
System.out.println("chargeQty after code excuting "+chargeQty+"]");
System.out.println("Calcurate free Qty "+freeQty+"]");
if (freeQty == 0)
{
freeQty = 0;
}
if (freeQty > 0)
{
if (round != null && roundTo != 0)
{
freeQty = distCommon.getRndamt(freeQty, round, roundTo);
}
}
System.out.println("qty "+qty+ "totFreeQty "+totFreeQty+"unConfTotFreeQty "+unConfTotFreeQty+ "prvFreeQty "+prvFreeQty+"]"+"ConfTotFreeQty"+ConfTotFreeQty+"]");
System.out.println("inside scheme type @@@@@@@@0000000000");
if (nature.equals("F"))
{
if ((qty + totFreeQty + unConfTotFreeQty + prvFreeQty + ConfTotFreeQty) > freeQty)
{
errCode = "VTFREEQTY1";// Entered free quantity is
// greater than scheme's free
// quantity
System.out.println("before ....errList.."+errList);
errList.add(errCode);
System.out.println("after ....errList.."+errList);
System.out.println("errFields..["+errFields+"]["+childNodeName+"]");
errFields.add(checkNull(" ".toLowerCase()));
//errFields.add(checkNull(childNodeName.toLowerCase()));
System.out.println("Entered free quantity is greater than scheme's free quantity"+errFields);
}
}
if (nature.equals("S"))
{
if ((qty + totSampleQty + unConfTotSampleQty + prvSampleQty + ConfTotSampleQty) > freeQty)
{
errCode = "VTSAMPQTY1";// Entered Sample quantity is
// greater than scheme's Sample
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Entered Sample quantity is greater than scheme's Sample quantity");
}
}
}
else if (schemeType==1)
{
chargeQty = unConfTotChargeQty + prvChargeQty + totChargeQty + ConfTotChargeQty;
/* sql = "Select count(1) From bom Where bom_code = ? And ? between case when min_qty is null then 0 else min_qty end" +
" And case when max_qty is null then 0 else max_qty end";*/
sql = "select count(1) from SCH_OFFER_ITEMS where scheme_code=? and item_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, schemeCode);
pstmt.setString(2, itemCodeOrd);
// pstmt.setDouble(3, chargeQty);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt == 0)
{
errCode = "VTFREEQTY";// Chargeable quantity of group of
// items is not eligible for the free
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Chargeable quantity of group of items is not eligible for the free quantity");
}
sql = "select purc_base, sch_allowence from sch_group_def where scheme_code=?";
pstmt.setString(1, schemeCode);
// pstmt.setInt(2, schemeType);
rs = pstmt.executeQuery();
if (rs.next())
{
purcBase = rs.getInt("purc_base");
schAllowence = rs.getInt("sch_allowence");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (chargeQty > 0)
{
freeQty = (chargeQty * rate* schAllowence / purcBase);
}
System.out.println("chargeQty after code excuting "+chargeQty+"]");
System.out.println("Calcurate free Qty "+freeQty+"]");
/*if (chargeQty >= purcBase && chargeQty <= schAllowence)
{
freeQty = roundValue(chargeQty / schAllowence, 0) * purcBase;
} else
{
freeQty = 0;
}*/
if (freeQty == 0)
{
freeQty = 0;
}
if (freeQty > 0)
{
if (round != null && roundTo != 0)
{
freeQty = distCommon.getRndamt(freeQty, round, roundTo);
}
}
if (nature.equals("F"))
{
if ((qty + totFreeQty + unConfTotFreeQty + prvFreeQty + ConfTotFreeQty) > freeQty)
{
errCode = "VTFREEQTY1";// Entered free quantity is
// greater than scheme's free
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Entered free quantity is greater than scheme's free quantity");
}
}
if (nature.equals("S"))
{
if ((qty + totSampleQty + unConfTotSampleQty + prvSampleQty + ConfTotSampleQty) > freeQty)
{
errCode = "VTSAMPQTY1";// Entered Sample quantity is
// greater than scheme's Sample
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Entered Sample quantity is greater than scheme's Sample quantity");
}
}
}
else if (schemeType==2)
{
chargeQty = unConfTotChargeQty + prvChargeQty + totChargeQty + ConfTotChargeQty;
/* sql = "Select count(1) From bom Where bom_code = ? And ? between case when min_qty is null then 0 else min_qty end" +
" And case when max_qty is null then 0 else max_qty end";*/
sql = "select count(1) from SCH_OFFER_ITEMS where scheme_code=? and item_code ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, schemeCode);
pstmt.setString(2, itemCodeOrd);
//pstmt.setDouble(3, chargeQty);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt == 0)
{
errCode = "VTFREEQTY";// Chargeable quantity of group of
// items is not eligible for the free
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Chargeable quantity of group of items is not eligible for the free quantity");
}
sql = "select purc_base, sch_allowence from sch_group_def where scheme_code=? and scheme_type=?";
pstmt.setString(1, schemeCode1);
pstmt.setInt(2, schemeType);
rs = pstmt.executeQuery();
if (rs.next())
{
batQty = rs.getDouble("batch_qty");
qtyPer = rs.getDouble("qty_per");
minQty = rs.getDouble("min_qty");
appMinQty = rs.getDouble("app_min_qty");
appMaxQty = rs.getDouble("app_max_qty");
round = rs.getString("round");
roundTo = rs.getDouble("round_to");
purcBase = rs.getInt("purc_base");
schAllowence = rs.getInt("sch_allowence");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (chargeQty >= purcBase && chargeQty <= schAllowence)
{
freeQty = roundValue(chargeQty / purcBase, 0) * schAllowence;
} else
{
freeQty = 0;
}
if (freeQty == 0)
{
freeQty = 0;
}
if (freeQty > 0)
{
if (round != null && roundTo != 0)
{
freeQty = distCommon.getRndamt(freeQty, round, roundTo);
}
}
if (nature.equals("F"))
{
if ((qty + totFreeQty + unConfTotFreeQty + prvFreeQty + ConfTotFreeQty) > freeQty)
{
errCode = "VTFREEQTY1";// Entered free quantity is
// greater than scheme's free
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Entered free quantity is greater than scheme's free quantity");
}
}
if (nature.equals("S"))
{
if ((qty + totSampleQty + unConfTotSampleQty + prvSampleQty + ConfTotSampleQty) > freeQty)
{
errCode = "VTSAMPQTY1";// Entered Sample quantity is
// greater than scheme's Sample
// quantity
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Entered Sample quantity is greater than scheme's Sample quantity");
}
}
}
// }
/////////////////added 13-DEC-17 arun
}
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
/////////////////////////// added arun 13-DEC-17
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return errCode;
}
// gbf_get_scheme_code
public String priceListDiscount(String siteCode, String custCode, Connection conn) throws ITMException public String priceListDiscount(String siteCode, String custCode, Connection conn) throws ITMException
{ {
......
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