Commit 37086a26 authored by ssalve's avatar ssalve

Sarita: Done changes for add tax_env on 19JAN2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@178708 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ebf4fd01
......@@ -4,6 +4,9 @@ import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.SalesOrderIC;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
......@@ -12,6 +15,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
......@@ -215,15 +219,15 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
String sql = "";
String detCnt = "0";
int noOfDetails = 0;
Timestamp TranDateDet = null;
Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null ,rs1 = null;
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null;
ResultSet rs = null ,rs1 = null,rs2 = null;
int count = 0 , domID = 0;
String itemCode = "",schemeCode = "",itemDescription="",updateFlag="";
NodeList detailList = null;
Node currDetail = null;
String itmCode="",s = "",s1 = "",quantity="",schemeType="",schAllowence="",siteCode="",s12="",schemeDescr="";
Node currDetail = null, headerNode = null;
String itmCode="",s = "",s1 = "",quantity="",schemeType="",schAllowence="",siteCode="",s12="",schemeDescr="",dsp_date="";
double qty = 0.0;
double purcBase=0.0;
double schAllowence1=0.0,discount=0.0,purRate=0.0;
......@@ -240,13 +244,31 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
List<String> freeItemListApplcbleType2 = new ArrayList<String>();
List<String> finalFreeItems = new ArrayList<String>();
HashMap<String,List<String>> freeItemInfoMap = new HashMap<String,List<String>>();
HashMap<String,String> detai1ValueMap = new HashMap<String,String>();
List<String> schemeInfo = null;
String itemValues = "",itemCodeSchm = "",rate;
String itemValues = "",itemCodeSchm = "",rate = "",SaleOrder = "",schemeCode1 = "",siteCode1="";
double finRate =0.0;
try
{
String custcodedlv="",itemSer="",custCode="",orderDate="";
conn = getConnection();
headerNode = dom1.getElementsByTagName("Detail1").item(0);
custcodedlv = checkNull(genericUtility.getColumnValueFromNode("cust_code__dlv", headerNode));
itemSer = checkNull(genericUtility.getColumnValueFromNode("item_ser", headerNode));
dsp_date = checkNull(genericUtility.getColumnValueFromNode("due_date", headerNode));
custCode = checkNull(genericUtility.getColumnValueFromNode("cust_code", headerNode));
orderDate = checkNull(genericUtility.getColumnValueFromNode("order_date", headerNode));
siteCode1 = checkNull(genericUtility.getColumnValueFromNode("site_code", headerNode));
System.out.println("custcodedlv["+custcodedlv+"]" + "itemSer["+itemSer+"]" + "dsp_date["+dsp_date+"]" + "custCode["+custCode+"]" + "orderDate["+orderDate+"]" + "siteCode1["+siteCode1+"]");
detai1ValueMap.put("cust_code__dlv", custcodedlv);
detai1ValueMap.put("item_ser", itemSer);
detai1ValueMap.put("due_date", dsp_date);
detai1ValueMap.put("cust_code", custCode);
detai1ValueMap.put("order_date", orderDate);
detai1ValueMap.put("site_code", siteCode1);
detailList = dom1.getElementsByTagName("Detail2");
noOfDetails = detailList.getLength();
//updateFlag = getAttributeVal(dom1,"updateFlag"); //Added by sarita on 15JAN2018
......@@ -259,12 +281,21 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
itemCode = checkNull(genericUtility.getColumnValueFromNode("item_code__ord", currDetail));
quantity = checkNull(genericUtility.getColumnValueFromNode("quantity", currDetail));
siteCode = checkNull(genericUtility.getColumnValueFromNode("site_code", currDetail));
SaleOrder = checkNull(genericUtility.getColumnValueFromNode("sale_order", currDetail));
rate = checkNull(genericUtility.getColumnValueFromNode("rate", currDetail));
System.out.println("itemCode["+itemCode+"]" + "quantity["+quantity+"]" + "siteCode["+siteCode+"]" + "SaleOrder["+SaleOrder+"]" + "rate["+rate+"]");
//dsp_date = getDueDate(SaleOrder, conn);
/*TranDateDet = Timestamp.valueOf(genericUtility.getValidDateString(dsp_date,
(genericUtility.getDBDateFormat() + " 00:00:00.0"), genericUtility.getApplDateFormat())+" 00:00:00.0");*/
TranDateDet = getTimeStamp(dsp_date);
//Added by sarita on 19/JAN/2018
if(quantity != null && quantity.trim().length() > 0){
qty = Double.valueOf(checkDouble(quantity));}
if(rate != null && rate.trim().length() > 0){
purRate = Double.valueOf(checkDouble(rate));}
itemList.add(itemCode);
if(itemQuantityMap.containsKey(itemCode))
......@@ -303,28 +334,58 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next())
{
schemeCode = rs.getString("scheme_code");
getSchemeList.add(schemeCode);
{
schemeCode1 = rs.getString("scheme_code");
//getSchemeList.add(schemeCode);
itmCode = rs.getString("item_code");
//System.out.println("schemeCode["+schemeCode+"]" + "itmCode["+itmCode+"]" + "\t");
if(getSchemeItemList.containsKey(schemeCode))
System.out.println("Item Code is itmCode["+itmCode+"]");
sql = "select distinct(a.scheme_code) from scheme_applicability a,scheme_applicability_det b"
+ " where a.scheme_code = b.scheme_code"
+ " and a.prod_sch = 'Y'"
+ " and a.app_from<= ?" + " and a.valid_upto>= ?" + " and b.site_code=?"
+ " or b.state_code = ?" + " or b.count_code= ?";
pstmt2 = conn.prepareStatement(sql);
//pstmt2.setString(1, itmCode);
pstmt2.setTimestamp(1, TranDateDet);
pstmt2.setTimestamp(2, TranDateDet);
pstmt2.setString(3, siteCode);
pstmt2.setString(4, "");
pstmt2.setString(5, "");
rs2 = pstmt2.executeQuery();
while(rs2.next())
{
//System.out.println("Inside 1");
schemeInfo = getSchemeItemList.get(schemeCode);
schemeInfo.add(itmCode.trim());
getSchemeItemList.put(schemeCode,schemeInfo);
schemeCode = rs.getString("scheme_code");
getSchemeList.add(schemeCode);
System.out.println("getSchemeList ::::::::::"+getSchemeList);
System.out.println("schemeCode["+schemeCode+"]" + "itmCode["+itmCode+"]" + "\t");
if(getSchemeItemList.containsKey(schemeCode))
{
//System.out.println("Inside 1");
schemeInfo = getSchemeItemList.get(schemeCode);
schemeInfo.add(itmCode.trim());
getSchemeItemList.put(schemeCode,schemeInfo);
}
else
{
//System.out.println("Inside 2");
schemeInfo = new ArrayList<String>();
schemeInfo.add(itmCode.trim());
System.out.println("schemeInfo1"+schemeInfo);
getSchemeItemList.put(schemeCode,schemeInfo);
}
}
else
if(pstmt2 != null)
{
//System.out.println("Inside 2");
schemeInfo = new ArrayList<String>();
schemeInfo.add(itmCode.trim());
System.out.println("schemeInfo1"+schemeInfo);
getSchemeItemList.put(schemeCode,schemeInfo);
pstmt2.close();
pstmt2 = null;
}
if(rs2 != null)
{
rs2.close();
rs2 = null;
}
System.out.println("getSchemeItemList:::"+getSchemeItemList);
}
if(pstmt != null)
......@@ -339,6 +400,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
}
itr = getSchemeList.iterator();
while(itr.hasNext())
{
s1 = s1 + "'"+(String) itr.next() + "'"+",";
......@@ -431,7 +493,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
finalFreeItems = freeItemInfoMap.get(itemCodeSchm);
System.out.println("Final List of Free Items for ::::Scheme Type 0 is "+finalFreeItems);
//s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap);
System.out.println("***********"+s12);
valueXmlString.append(s12);
}
......@@ -496,7 +558,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
}
finalFreeItems = freeItemInfoMap.get(itemCodeSchm);
System.out.println("Final List of Free Items for ::::Scheme Type 1 is "+finalFreeItems);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap);
System.out.println("***********"+s12);
valueXmlString.append(s12);
}
......@@ -562,7 +624,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
}
finalFreeItems = freeItemInfoMap.get(itemCodeSchm);
System.out.println("Final List of Free Items for ::::Scheme Type 2 is "+finalFreeItems);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap);
System.out.println("***********"+s12);
valueXmlString.append(s12);
}
......@@ -716,16 +778,21 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
return AttribValue;
}
//Added by sarita on 15JAN2018
public String returnFinalFreeItemDataUsingList(List<String> list,Connection conn,String schemeType,String schemeCode,String schemeDescr,double discount,double freeQty,String itemValues)
public String returnFinalFreeItemDataUsingList(List<String> list,Connection conn,String schemeType,String schemeCode,String schemeDescr,double discount,double freeQty,String itemValues,HashMap<String,String> detai1ValueMap)
{
System.out.println("finalFreeItems :::"+list);
//System.out.println("finalFreeItems :::"+list.size());
StringBuffer valueXmlString = new StringBuffer();
String itemDescription = "",nature = "",sch_attr="Y";
DistCommon distCommon = new DistCommon();
SalesOrderIC salesOrderIC = new SalesOrderIC();
String itemDescription = "",nature = "",sch_attr="Y",taxChap="",taxClass="",taxEnv="",stationTo="",stationFrom="",SalesPriceList="",ContractNo="";
Set<String> listSet = null;
int domID = 0;
double newRate =0;
try
{
stationFrom = getStationFrom(detai1ValueMap.get("site_code"),conn);
stationTo = getStationTo(detai1ValueMap.get("cust_code"), conn);
if("0".equalsIgnoreCase(schemeType) || "1".equalsIgnoreCase(schemeType))
{
nature="F";
......@@ -749,10 +816,18 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
for(String item_Code : listSet)
{
System.out.println("Free Item in listSet are :::"+listSet);
domID++;
valueXmlString.append("<Detail domId='"+(domID)+"'>\r\n");
System.out.println("Free Items "+item_Code);
itemDescription = getItemDescr(item_Code,conn);
taxChap = (distCommon.getTaxChap(item_Code,detai1ValueMap.get("item_ser"), "C", detai1ValueMap.get("cust_code__dlv"),detai1ValueMap.get("site_code"), conn));
taxClass = (distCommon.getTaxClass("C", detai1ValueMap.get("cust_code__dlv"), item_Code, detai1ValueMap.get("site_code"), conn));
taxEnv = (distCommon.getTaxEnv(stationFrom, stationTo, taxChap, taxClass, detai1ValueMap.get("site_code"), conn));
ContractNo=salesOrderIC.getContract(detai1ValueMap.get("site_code"), detai1ValueMap.get("cust_code"), getTimeStamp(detai1ValueMap.get("order_date")), item_Code, "", "", conn);
SalesPriceList = distCommon.getSalesPriceList(detai1ValueMap.get("cust_code"),detai1ValueMap.get("cust_code__dlv"),detai1ValueMap.get("site_code"),ContractNo,item_Code,detai1ValueMap.get("order_date"),conn);
newRate = distCommon.getSalesRate(SalesPriceList,detai1ValueMap.get("site_code"),detai1ValueMap.get("cust_code"),detai1ValueMap.get("order_date"),detai1ValueMap.get("order_date"),"C",ContractNo,ContractNo,item_Code,0.0,conn);
System.out.println("taxChap["+taxChap+"]" + "taxClass["+taxClass+"]" + "taxEnv["+taxEnv+"]" + "ContractNo["+ContractNo+"]" + "SalesPriceList["+SalesPriceList+"]" + "newRate["+newRate+"]");
valueXmlString.append("<scheme_type>").append("<![CDATA[").append(schemeType).append("]]>").append("</scheme_type>\r\n");
valueXmlString.append("<applicable_scheme>").append("<![CDATA[").append(schemeCode).append("]]>").append("</applicable_scheme>\r\n");
//valueXmlString.append("<scheme_description visible = \"1\">").append("<![CDATA[").append(schemeDescr).append("]]>").append("</scheme_description>\r\n");//changes by sarita on 18JAN2018
......@@ -766,7 +841,12 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
valueXmlString.append("<discount>").append("<![CDATA[").append(discount).append("]]>").append("</discount>\r\n");
valueXmlString.append("<nature>").append("<![CDATA[").append(nature).append("]]>").append("</nature>\r\n");
valueXmlString.append("<sch_attr>").append("<![CDATA[").append(sch_attr).append("]]>").append("</sch_attr>\r\n");
valueXmlString.append("<rate>").append("<![CDATA[").append(0.0).append("]]>").append("</rate>\r\n");
valueXmlString.append("<rate>").append("<![CDATA[").append(newRate).append("]]>").append("</rate>\r\n");
valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code__ord>\r\n");
valueXmlString.append("<tax_chap>").append("<![CDATA[").append(taxChap).append("]]>").append("</tax_chap>\r\n");
valueXmlString.append("<tax_class>").append("<![CDATA[").append(taxClass).append("]]>").append("</tax_class>\r\n");
valueXmlString.append("<tax_env>").append("<![CDATA[").append(taxEnv).append("]]>").append("</tax_env>\r\n");
valueXmlString.append("<contract_no>").append("<![CDATA[").append(ContractNo).append("]]>").append("</contract_no>\r\n");
valueXmlString.append("</Detail>\r\n");
}
}
......@@ -861,4 +941,121 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
return str.trim() ;
}
}
private String getDueDate(String sale_order,Connection conn)
{
String dueDate = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = "select due_date from sorder where sale_order=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sale_order);
rs = pstmt.executeQuery();
if(rs.next())
{
dueDate = checkNull(rs.getString("due_date"));
System.out.println("Due Date is ======="+dueDate);
}
}
catch(Exception e)
{
System.out.println("Inside getDueDate() ---- "+e);
e.printStackTrace();
}
return dueDate;
}
private java.sql.Timestamp getTimeStamp(String dateStr) throws ITMException, Exception
{
String dbDateStr = "";
if(dateStr != null && !dateStr.equals(""))
{
if(dateStr.indexOf(":") != -1)
{
System.out.println("inside logic"+dateStr);
return java.sql.Timestamp.valueOf(dateStr);
}
else
{
System.out.println("inside ");
dbDateStr = genericUtility.getValidDateTimeString(dateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateTimeFormat());
return java.sql.Timestamp.valueOf(dbDateStr);
}
}
else
{
return null;
}
}
public String getStationFrom(String siteCode,Connection conn)
{
String sql = "",stationFrom="";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = " SELECT STAN_CODE FROM SITE WHERE SITE_CODE =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
stationFrom = checkNull(rs.getString("STAN_CODE"));
}
if(rs != null)
{
rs.close();rs = null;
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println(e);
}
return stationFrom;
}
public String getStationTo(String custCode,Connection conn)
{
String sql = "",stationTo="";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = " SELECT STAN_CODE FROM CUSTOMER WHERE CUST_CODE =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
stationTo = checkNull(rs.getString("STAN_CODE"));
}
if(rs != null)
{
rs.close();rs = null;
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
System.out.println("stationTo"+stationTo);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println(e);
}
return stationTo;
}
}
\ No newline at end of file
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