Commit 0173fabd authored by pphate's avatar pphate

Added new requirements related points on 09-10-18

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191779 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c4e7a78c
...@@ -7,12 +7,6 @@ ...@@ -7,12 +7,6 @@
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.rmi.RemoteException; import java.rmi.RemoteException;
...@@ -39,19 +33,25 @@ import javax.xml.transform.Transformer; ...@@ -39,19 +33,25 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import org.apache.poi.hssf.record.formula.functions.Int;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
// added for ejb3 // added for ejb3
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless // added for ejb3 @Stateless // added for ejb3
public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposalLocal, SalesQuotProposalRemote public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposalLocal, SalesQuotProposalRemote
{ {
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
ArrayList<String> itemCodeArr = new ArrayList<String>(); ArrayList<String> itemCodeArr = new ArrayList<String>();
ArrayList<String> itemCodeArr2 = new ArrayList<String>();
NumberFormat formatter = new DecimalFormat("#0.00"); NumberFormat formatter = new DecimalFormat("#0.00");
private int globalNo = 0; private int globalNo = 0;
...@@ -122,12 +122,12 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -122,12 +122,12 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
ArrayList <String> errList = new ArrayList<String>(); ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> (); ArrayList <String>errFields = new ArrayList <String> ();
String errorType = ""; String errorType = "";
String custCode= "", validUptoStr = "",effFromStr = "", fromDtStr = "", toDtStr = ""; String custCode= "", currAppdateStr ="", validUptoStr = "",effFromStr = "", fromDtStr = "", toDtStr = "";
double discount = 0, commPerc = 0, newRate = 0; double discount = 0, commPerc = 0, newRate = 0;
Timestamp toDate = null, fromDate = null, validUptoDate = null, effFromDate = null; Timestamp currentDate = null, toDate = null, fromDate = null, validUptoDate = null, effFromDate = null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
//Added by AMOL START //Added by AMOL START
StringBuffer formatedInvIds = new StringBuffer(); //StringBuffer formatedInvIds = new StringBuffer();
int count2 = 0; int count2 = 0;
Node node = null; Node node = null;
Element element = null; Element element = null;
...@@ -138,6 +138,13 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -138,6 +138,13 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
conn = getConnection(); conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("SalesQuotProposal userId:- " + userId); System.out.println("SalesQuotProposal userId:- " + userId);
java.sql.Timestamp currDate = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdateStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate).toString();
currentDate = Timestamp.valueOf(genericUtility.getValidDateString(currAppdateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
System.out.println("####### currAppdate : "+currentDate);
if(objContext != null && objContext.trim().length()>0) if(objContext != null && objContext.trim().length()>0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
...@@ -249,10 +256,17 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -249,10 +256,17 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
break; break;
} }
if(effFromDate.before(currentDate))
{
errCode = "EFCDTPST";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
} }
}
//Commented on 05-10-18 START
//Added by AMOL START //Added by AMOL START
try /*try
{ {
if( E12GenericUtility.checkNull(custCode).length() > 0 && E12GenericUtility.checkNull(fromDtStr).length() > 0 if( E12GenericUtility.checkNull(custCode).length() > 0 && E12GenericUtility.checkNull(fromDtStr).length() > 0
&& E12GenericUtility.checkNull(toDtStr).length() > 0) && E12GenericUtility.checkNull(toDtStr).length() > 0)
...@@ -275,8 +289,9 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -275,8 +289,9 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
{ {
System.out.println("#### Exception in WFValDate Invoice_ID "+e); System.out.println("#### Exception in WFValDate Invoice_ID "+e);
e.printStackTrace(); e.printStackTrace();
} }*/
//Added by AMOL END //Added by AMOL END
//Commented on 05-10-18 END
} }
} }
...@@ -287,7 +302,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -287,7 +302,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
int parentNodeListLen = parentNodeList.getLength(); int parentNodeListLen = parentNodeList.getLength();
System.out.println("##### Number of node in parentNodeListLen : "+parentNodeListLen); System.out.println("##### Number of node in parentNodeListLen : "+parentNodeListLen);
//Added by AMOL[If no record selected] START //Added by AMOL[If no record selected] START
/*for(int ctr2 = 0; ctr2 < parentNodeListLen; ctr2++ ) for(int ctr2 = 0; ctr2 < parentNodeListLen; ctr2++ )
{ {
node = parentNodeList.item(ctr); node = parentNodeList.item(ctr);
childNodeName = node.getNodeName(); childNodeName = node.getNodeName();
...@@ -304,7 +319,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -304,7 +319,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
errList.add(errCode); errList.add(errCode);
errFields.add("selectbox"); errFields.add("selectbox");
} }
count2 = 0;*/ count2 = 0;
//Added by AMOL[If no record selected] END //Added by AMOL[If no record selected] END
if(parentNodeListLen == 0) if(parentNodeListLen == 0)
...@@ -519,8 +534,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -519,8 +534,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
java.sql.Timestamp currDate = null; java.sql.Timestamp currDate = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ; currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
/*sordformId = checkNull(genericUtility.getColumnValue("SORDFORM_ID", dom, "1")).trim();
System.out.println("sordformId : "+sordformId);*/
InetAddress ownIP=InetAddress.getLocalHost(); InetAddress ownIP=InetAddress.getLocalHost();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
siteCode = getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"); siteCode = getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
...@@ -541,7 +555,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -541,7 +555,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
String effDateStr = genericUtility.getColumnValue("eff_date", dom1); String effDateStr = genericUtility.getColumnValue("eff_date", dom1);
String validUptoStr = genericUtility.getColumnValue("valid_upto", dom1); String validUptoStr = genericUtility.getColumnValue("valid_upto", dom1);
System.out.println("#### currAppdate ["+currAppdate+"]"); System.out.println("#### currAppdate ["+currAppdate+"]");
System.out.println("#### fromDateStr ["+fromDateStr); System.out.println("#### fromDateStr ["+fromDateStr);
System.out.println("#### toDateStr ["+toDateStr); System.out.println("#### toDateStr ["+toDateStr);
...@@ -557,7 +570,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -557,7 +570,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valueXmlString.append("<cust_code><![CDATA["+custCode+"]]></cust_code>"); valueXmlString.append("<cust_code><![CDATA["+custCode+"]]></cust_code>");
valueXmlString.append("<from_date><![CDATA["+fromDateStr+"]]></from_date>"); valueXmlString.append("<from_date><![CDATA["+fromDateStr+"]]></from_date>");
valueXmlString.append("<to_date><![CDATA["+toDateStr+"]]></to_date>"); valueXmlString.append("<to_date><![CDATA["+toDateStr+"]]></to_date>");
valueXmlString.append("<eff_date><![CDATA["+effDateStr+"]]></eff_date>"); //valueXmlString.append("<eff_date><![CDATA["+effDateStr+"]]></eff_date>");
valueXmlString.append("<eff_date><![CDATA["+currAppdate+"]]></eff_date>");
valueXmlString.append("<valid_upto><![CDATA["+validUptoStr+"]]></valid_upto>"); valueXmlString.append("<valid_upto><![CDATA["+validUptoStr+"]]></valid_upto>");
//<<<<<<<<<<<<<<<<<<<<<<<<<<< Make SURE additional_fees added in sales_quot TABLE >>> //<<<<<<<<<<<<<<<<<<<<<<<<<<< Make SURE additional_fees added in sales_quot TABLE >>>
valueXmlString.append("<addl_chrg ><![CDATA["+getAdditionalCost(conn)+"]]></addl_chrg >"); valueXmlString.append("<addl_chrg ><![CDATA["+getAdditionalCost(conn)+"]]></addl_chrg >");
...@@ -643,6 +657,131 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -643,6 +657,131 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
invoiceIdArr = getInvoiceDetail(conn, custCode, fromDate, toDate, valueXmlString,siteCode,discountType); invoiceIdArr = getInvoiceDetail(conn, custCode, fromDate, toDate, valueXmlString,siteCode,discountType);
} }
} }
//START 08-10-18
else if(currentColumn.trim().equalsIgnoreCase("itm_default_add"))
{
try
{
//globalNo = globalNo +1;
//String newSrNo = getSrNo(dom2);
//System.out.println("#### New SrNo ");
valueXmlString.append("<Detail2 domID=\""+""+"\" selected=\"N\" > \r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append("<quot_no/>");
valueXmlString.append( "<line_no protect='1'><![CDATA[" ).append("").append( "]]></line_no>\r\n" );
valueXmlString.append("<sr_no><![CDATA[" ).append("").append( "]]></sr_no>\r\n" );
valueXmlString.append("<item_code><![CDATA[" ).append("").append( "]]></item_code>\r\n" );
valueXmlString.append("<item_descr><![CDATA[" ).append("").append( "]]></item_descr>\r\n" );
valueXmlString.append("<unit><![CDATA[" ).append("").append( "]]></unit>\r\n" );
valueXmlString.append("<qty_per_month><![CDATA[" ).append("").append( "]]></qty_per_month>\r\n" );
valueXmlString.append("<rate><![CDATA[" ).append("").append( "]]></rate>\r\n" );
valueXmlString.append("<discount><![CDATA[" ).append("").append( "]]></discount>\r\n" );
valueXmlString.append("<gross_rate><![CDATA[" ).append("").append( "]]></gross_rate>\r\n" );
valueXmlString.append("<comm_perc><![CDATA[" ).append("").append( "]]></comm_perc>\r\n" );
valueXmlString.append("<comm_per_unit><![CDATA[" ).append("").append( "]]></comm_per_unit>\r\n" );
valueXmlString.append("<rate__new><![CDATA[" ).append("").append( "]]></rate__new>\r\n" );
valueXmlString.append("<basic_dist_price><![CDATA[" ).append("").append( "]]></basic_dist_price>\r\n" );
valueXmlString.append("<cost_rate><![CDATA[" ).append("").append( "]]></cost_rate>\r\n" );
valueXmlString.append("<profit><![CDATA[" ).append("").append( "]]></profit>\r\n" );
valueXmlString.append("<profit_on_goods><![CDATA[" ).append("").append( "]]></profit_on_goods>\r\n" );
valueXmlString.append("<final_price><![CDATA[" ).append("").append( "]]></final_price >\r\n" );
valueXmlString.append("<perc_profit><![CDATA[" ).append("").append( "]]></perc_profit>\r\n" );
valueXmlString.append("<available_stock><![CDATA[" ).append("").append( "]]></available_stock>\r\n" );
valueXmlString.append("</Detail2>");
}
catch (Exception e)
{
System.out.println("@@@@ Exception ON ITEMCHANGE ==> itm_default_add : "+e);
}
}
else if(currentColumn.trim().equalsIgnoreCase("item_code"))
{
Map<String, String> itemDetailMap = new HashMap<String, String>();
try
{
StringBuffer valXmlStr = new StringBuffer();
String currDomStr = genericUtility.serializeDom(dom);
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
itemDetailMap = getItemData(itemCode, conn);
double actualCost = getCostRate(conn, itemCode);
double availblStock = getStockDetails(conn,itemCode);
valXmlStr.append("<quot_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("quot_no",dom)) +"]]>").append("</quot_no>");
valXmlStr.append("<sr_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("sr_no",dom)) +"]]>").append("</sr_no>");
valXmlStr.append("<line_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("sr_no",dom)) +"]]>").append("</line_no>");
valXmlStr.append("<item_code protect='1'><![CDATA[" ).append(itemCode).append( "]]></item_code>\r\n" );
valXmlStr.append("<item_descr><![CDATA[" ).append(itemDetailMap.get("descr")).append( "]]></item_descr>\r\n" );
valXmlStr.append("<unit><![CDATA[" ).append(itemDetailMap.get("unit")).append( "]]></unit>\r\n" );
valXmlStr.append("<cost_rate><![CDATA[" ).append(getCommaSep (actualCost)).append( "]]></cost_rate>\r\n" );
valXmlStr.append("<available_stock><![CDATA[" ).append( getCommaSep(availblStock)).append( "]]></available_stock>\r\n" );
valXmlStr.append("</Detail2>");
currDomStr = currDomStr.replace("</Detail2>",valXmlStr.toString());
valueXmlString.append(currDomStr);
}
catch(Exception e)
{
System.out.println("@@@@ Exception ON ITEMCHANGE ==> ITEM_CODE : "+e);
}
}
/*else if(currentColumn.trim().equalsIgnoreCase("qty_per_month"))
{
String currDomStr = genericUtility.serializeDom(dom);
StringBuffer valueXmlStr = new StringBuffer();
try
{
qtyMonth = checkNull(genericUtility.getColumnValue("qty_per_month",dom));
rate = checkNull(genericUtility.getColumnValue("rate",dom));
discount = checkNull(genericUtility.getColumnValue("discount",dom));
grossRate = checkNull(genericUtility.getColumnValue("gross_rate",dom));
commission = checkNull(genericUtility.getColumnValue("comm_perc",dom));
commissionPerUnit = checkNull(genericUtility.getColumnValue("comm_per_unit",dom));
newCostRate = (getDoubleValue(checkNull(genericUtility.getColumnValue("rate__new",dom))));
profit = (getDoubleValue(checkNull(genericUtility.getColumnValue("profit",dom))));
newGrossRate = (getDoubleValue(grossRate));
String profitParse = String.format("%.2f", profit);
profitOnGoods = (getDoubleValue(profitParse) * getDoubleValue(qtyMonth));
finalPrice = (newCostRate * getDoubleValue(qtyMonth));
percProfit = ((profitOnGoods / finalPrice) * 100);
if( percProfit.isNaN() || percProfit.isInfinite())
{
percProfit = 0.0;
}
valueXmlStr.append("<quot_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("quot_no",dom)) +"]]>").append("</quot_no>");
valueXmlStr.append("<line_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("line_no",dom)) +"]]>").append("</line_no>");
valueXmlStr.append("<qty_per_month><![CDATA[" ).append( qtyMonth).append( "]]></qty_per_month>\r\n" );
valueXmlStr.append("<profit><![CDATA[" ).append( getCommaSep(profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append( getCommaSep(profitOnGoods) ).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append( getCommaSep(finalPrice) ).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append( getCommaSep(percProfit) ).append( "]]></perc_profit>\r\n" );
valueXmlStr.append("</Detail2>");
currDomStr = currDomStr.replace("</Detail2>", valueXmlStr.toString());
valueXmlString.append(currDomStr);
}
catch (Exception e)
{
System.out.println("@@@@ Exception ON ITEMCHANGE ==> qty_per_month :"+e);
}
}*/
//END 08-10-18
//valueXmlString.append("</Root>");
} }
else if("sale_quotitems".equals(formName) || "3".equalsIgnoreCase(objContext)) else if("sale_quotitems".equals(formName) || "3".equalsIgnoreCase(objContext))
{ {
...@@ -682,9 +821,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -682,9 +821,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valueXmlString.append("<Detail3 domID=\""+ctr+"\" selected=\"Y\" > \r\n"); valueXmlString.append("<Detail3 domID=\""+ctr+"\" selected=\"Y\" > \r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n"); valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
//Added by AMOL TO Resovle issues occured in SalesQuotProp.jsp [To Remove OLD DATA] START
valueXmlString.append("<Record>"+globalNo+"</Record>");
//Added by AMOL TO Resovle issues occured in SalesQuotProp.jsp [To Remove OLD DATA] END
valueXmlString.append(str11); valueXmlString.append(str11);
} }
} }
...@@ -750,12 +886,18 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -750,12 +886,18 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valueXmlStr.append("<gross_rate><![CDATA[" ).append(String.format ("%.2f", newGrossRate)).append( "]]></gross_rate>\r\n" ); valueXmlStr.append("<gross_rate><![CDATA[" ).append(String.format ("%.2f", newGrossRate)).append( "]]></gross_rate>\r\n" );
valueXmlStr.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f", commPerUnit)).append( "]]></comm_per_unit>\r\n" ); valueXmlStr.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f", commPerUnit)).append( "]]></comm_per_unit>\r\n" );
valueXmlStr.append("<rate__new><![CDATA[" ).append(Math.round(newGrossRate)).append( "]]></rate__new>\r\n" ); valueXmlStr.append("<rate__new><![CDATA[" ).append(Math.round(newGrossRate)).append( "]]></rate__new>\r\n" );
valueXmlStr.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" ); //valueXmlStr.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" );
valueXmlStr.append("<cost_rate><![CDATA[" ).append(String.format ("%.2f", costRate)).append( "]]></cost_rate>\r\n" ); //valueXmlStr.append("<cost_rate><![CDATA[" ).append(String.format ("%.2f", costRate)).append( "]]></cost_rate>\r\n" );
valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" ); valueXmlStr.append("<basic_dist_price><![CDATA[" ).append( getCommaSep(newCostRate) ).append( "]]></basic_dist_price>\r\n" );
valueXmlStr.append("<cost_rate><![CDATA[" ).append( getCommaSep(costRate)).append( "]]></cost_rate>\r\n" );
/*valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" ); valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" ); valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" ); valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" );*/
valueXmlStr.append("<profit><![CDATA[" ).append( getCommaSep(profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append( getCommaSep(profitOnGoods) ).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append( getCommaSep(finalPrice) ).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append( getCommaSep(percProfit) ).append( "]]></perc_profit>\r\n" );
valueXmlStr.append("</Detail3>"); valueXmlStr.append("</Detail3>");
currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString()); currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString());
//valueXmlStr.append("</Root>"); //valueXmlStr.append("</Root>");
...@@ -798,11 +940,15 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -798,11 +940,15 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valueXmlStr.append("<quot_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("quot_no",dom)) +"]]>").append("</quot_no>"); valueXmlStr.append("<quot_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("quot_no",dom)) +"]]>").append("</quot_no>");
valueXmlStr.append("<line_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("line_no",dom)) +"]]>").append("</line_no>"); valueXmlStr.append("<line_no>").append("<![CDATA["+ checkNull(genericUtility.getColumnValue("line_no",dom)) +"]]>").append("</line_no>");
valueXmlStr.append("<qty_per_month><![CDATA[" ).append(qtyMonth).append( "]]></qty_per_month>\r\n" ); valueXmlStr.append("<qty_per_month><![CDATA[" ).append( qtyMonth).append( "]]></qty_per_month>\r\n" );
valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" ); /*valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" ); valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" ); valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" ); valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" );*/
valueXmlStr.append("<profit><![CDATA[" ).append( getCommaSep(profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append( getCommaSep(profitOnGoods) ).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append( getCommaSep(finalPrice) ).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append( getCommaSep(percProfit) ).append( "]]></perc_profit>\r\n" );
valueXmlStr.append("</Detail3>"); valueXmlStr.append("</Detail3>");
currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString()); currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString());
//valueXmlStr.append("</Root>"); //valueXmlStr.append("</Root>");
...@@ -870,12 +1016,18 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -870,12 +1016,18 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valueXmlStr.append("<gross_rate><![CDATA[" ).append(String.format ("%.2f", newGrossRate)).append( "]]></gross_rate>\r\n" ); valueXmlStr.append("<gross_rate><![CDATA[" ).append(String.format ("%.2f", newGrossRate)).append( "]]></gross_rate>\r\n" );
valueXmlStr.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f", commPerUnit)).append( "]]></comm_per_unit>\r\n" ); valueXmlStr.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f", commPerUnit)).append( "]]></comm_per_unit>\r\n" );
valueXmlStr.append("<rate__new><![CDATA[" ).append(Math.round(newGrossRate)).append( "]]></rate__new>\r\n" ); valueXmlStr.append("<rate__new><![CDATA[" ).append(Math.round(newGrossRate)).append( "]]></rate__new>\r\n" );
valueXmlStr.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" ); //valueXmlStr.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" );
valueXmlStr.append("<cost_rate><![CDATA[" ).append(String.format ("%.2f", costRate)).append( "]]></cost_rate>\r\n" ); //valueXmlStr.append("<cost_rate><![CDATA[" ).append(String.format ("%.2f", costRate)).append( "]]></cost_rate>\r\n" );
valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" ); valueXmlStr.append("<basic_dist_price><![CDATA[" ).append( getCommaSep(newCostRate)).append( "]]></basic_dist_price>\r\n" );
valueXmlStr.append("<cost_rate><![CDATA[" ).append(getCommaSep(costRate)).append( "]]></cost_rate>\r\n" );
/*valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" ); valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" ); valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" ); valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" );*/
valueXmlStr.append("<profit><![CDATA[" ).append( getCommaSep(profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append( getCommaSep(profitOnGoods) ).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append( getCommaSep(finalPrice) ).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append( getCommaSep(percProfit) ).append( "]]></perc_profit>\r\n" );
valueXmlStr.append("</Detail3>"); valueXmlStr.append("</Detail3>");
currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString()); currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString());
//valueXmlStr.append("</Root>"); //valueXmlStr.append("</Root>");
...@@ -920,11 +1072,16 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -920,11 +1072,16 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valueXmlStr.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f", commPerUnit)).append( "]]></comm_per_unit>\r\n" ); valueXmlStr.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f", commPerUnit)).append( "]]></comm_per_unit>\r\n" );
valueXmlStr.append("<rate__new><![CDATA[" ).append(Math.round(newGrossRate)).append( "]]></rate__new>\r\n" ); valueXmlStr.append("<rate__new><![CDATA[" ).append(Math.round(newGrossRate)).append( "]]></rate__new>\r\n" );
valueXmlStr.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" ); valueXmlStr.append("<basic_dist_price><![CDATA[" ).append( getCommaSep(newCostRate)).append( "]]></basic_dist_price>\r\n" );
valueXmlStr.append("<profit><![CDATA[" ).append( getCommaSep(profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append( getCommaSep(profitOnGoods) ).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append( getCommaSep(finalPrice) ).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append( getCommaSep(percProfit) ).append( "]]></perc_profit>\r\n" );
/*valueXmlStr.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" );
valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" ); valueXmlStr.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" );
valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" ); valueXmlStr.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" );
valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" ); valueXmlStr.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price>\r\n" );
valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" ); valueXmlStr.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" );*/
valueXmlStr.append("</Detail3>"); valueXmlStr.append("</Detail3>");
currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString()); currDomStr = currDomStr.replace("</Detail3>", valueXmlStr.toString());
//valueXmlStr.append("</Root>"); //valueXmlStr.append("</Root>");
...@@ -997,8 +1154,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -997,8 +1154,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valXmlStr.append("<item_code protect='1'><![CDATA[" ).append(itemCode).append( "]]></item_code>\r\n" ); valXmlStr.append("<item_code protect='1'><![CDATA[" ).append(itemCode).append( "]]></item_code>\r\n" );
valXmlStr.append("<item_descr><![CDATA[" ).append(itemDetailMap.get("descr")).append( "]]></item_descr>\r\n" ); valXmlStr.append("<item_descr><![CDATA[" ).append(itemDetailMap.get("descr")).append( "]]></item_descr>\r\n" );
valXmlStr.append("<unit><![CDATA[" ).append(itemDetailMap.get("unit")).append( "]]></unit>\r\n" ); valXmlStr.append("<unit><![CDATA[" ).append(itemDetailMap.get("unit")).append( "]]></unit>\r\n" );
valXmlStr.append("<cost_rate><![CDATA[" ).append(String.format ("%.2f", actualCost)).append( "]]></cost_rate>\r\n" ); valXmlStr.append("<cost_rate><![CDATA[" ).append(getCommaSep (actualCost)).append( "]]></cost_rate>\r\n" );
valXmlStr.append("<available_stock><![CDATA[" ).append(String.format ("%.2f", availblStock)).append( "]]></available_stock>\r\n" ); valXmlStr.append("<available_stock><![CDATA[" ).append( getCommaSep(availblStock)).append( "]]></available_stock>\r\n" );
valXmlStr.append("</Detail3>"); valXmlStr.append("</Detail3>");
currDomStr = currDomStr.replace("</Detail3>",valXmlStr.toString()); currDomStr = currDomStr.replace("</Detail3>",valXmlStr.toString());
//currDomStr = currDomStr.replace("</Detail3>",valXmlStr.toString()+"</Detail3>"); //currDomStr = currDomStr.replace("</Detail3>",valXmlStr.toString()+"</Detail3>");
...@@ -1115,7 +1272,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1115,7 +1272,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
} }
return msgType; return msgType;
} }
//Not Using ....
public boolean preDomExists(Document dom, String currentFormNo) throws ITMException public boolean preDomExists(Document dom, String currentFormNo) throws ITMException
{ {
NodeList parentList = null; NodeList parentList = null;
...@@ -1566,7 +1723,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1566,7 +1723,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
Iterator<Map.Entry<String, Double>> itr = map.entrySet().iterator(); Iterator<Map.Entry<String, Double>> itr = map.entrySet().iterator();
DistCommon distCommon = new DistCommon(); //DistCommon distCommon = new DistCommon();
int srNo = 0; int srNo = 0;
...@@ -1577,14 +1734,17 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1577,14 +1734,17 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
srNo++; srNo++;
Map.Entry<String, Double> entry = itr.next(); Map.Entry<String, Double> entry = itr.next();
String itemCode = entry.getKey(); String itemCode = E12GenericUtility.checkNull(entry.getKey());
itemCodeArr.add(itemCode); itemCodeArr.add(itemCode);
double maxValue = entry.getValue(); double maxValue = entry.getValue();
itemDetailMap = getItemData(itemCode, conn); itemDetailMap = getItemData(itemCode, conn);
double discount = (distCommon.pickRate(disPriceList, eventDateStr, entry.getKey(), conn)); /*double discount = (distCommon.pickRate(disPriceList, eventDateStr, entry.getKey(), conn));
double rate = (distCommon.pickRate(priceList, eventDateStr, entry.getKey(), conn));*/
double rate = (distCommon.pickRate(priceList, eventDateStr, entry.getKey(), conn)); System.out.println("##### Setting Discount disPriceList "+disPriceList);
double discount = getRate(conn, disPriceList, itemCode);
System.out.println("##### Setting rate priceList "+priceList);
double rate = getRate(conn, priceList, itemCode);
Double grossRate = ((rate - ((rate * discount) / 100))); Double grossRate = ((rate - ((rate * discount) / 100)));
if(grossRate.isNaN() || grossRate.isInfinite()) if(grossRate.isNaN() || grossRate.isInfinite())
...@@ -1615,7 +1775,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1615,7 +1775,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
{ {
percProfit = 0.0; percProfit = 0.0;
} }
System.out.println("#### Item Code :: "+itemCode); /*System.out.println("#### Item Code :: "+itemCode);
System.out.println("#### OLD Rate :: "+rate); System.out.println("#### OLD Rate :: "+rate);
System.out.println("#### Discount :: "+discount); System.out.println("#### Discount :: "+discount);
System.out.println("#### comm :: "+comm); System.out.println("#### comm :: "+comm);
...@@ -1626,7 +1786,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1626,7 +1786,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
System.out.println("#### Formated Profit "+profitParse); System.out.println("#### Formated Profit "+profitParse);
System.out.println("#### qtyMonth : "+maxValue); System.out.println("#### qtyMonth : "+maxValue);
System.out.println("#### finalPrice : "+finalPrice); System.out.println("#### finalPrice : "+finalPrice);
System.out.println("#### percProfit : "+percProfit); System.out.println("#### percProfit : "+percProfit);*/
valueXmlString.append("<Detail2 domID=\""+srNo+"\" selected=\"N\" > \r\n"); valueXmlString.append("<Detail2 domID=\""+srNo+"\" selected=\"N\" > \r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n"); valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
...@@ -1638,20 +1799,27 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1638,20 +1799,27 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
valueXmlString.append("<unit><![CDATA[" ).append(itemDetailMap.get("unit")).append( "]]></unit>\r\n" ); valueXmlString.append("<unit><![CDATA[" ).append(itemDetailMap.get("unit")).append( "]]></unit>\r\n" );
valueXmlString.append("<qty_per_month><![CDATA[" ).append(maxValue).append( "]]></qty_per_month>\r\n" ); valueXmlString.append("<qty_per_month><![CDATA[" ).append(maxValue).append( "]]></qty_per_month>\r\n" );
valueXmlString.append("<rate><![CDATA[" ).append(String.format ("%.2f", rate)).append( "]]></rate>\r\n" ); valueXmlString.append("<rate><![CDATA[" ).append(String.format ("%.2f", rate)).append( "]]></rate>\r\n" );
valueXmlString.append("<discount_type><![CDATA[" ).append(discountType).append( "]]></discount_type>\r\n" );
valueXmlString.append("<discount><![CDATA[" ).append(String.format ("%.2f", discount)).append( "]]></discount>\r\n" ); valueXmlString.append("<discount><![CDATA[" ).append(String.format ("%.2f", discount)).append( "]]></discount>\r\n" );
valueXmlString.append("<gross_rate><![CDATA[" ).append(String.format ("%.2f", grossRate)).append( "]]></gross_rate>\r\n" ); valueXmlString.append("<gross_rate><![CDATA[" ).append(String.format ("%.2f", grossRate)).append( "]]></gross_rate>\r\n" );
valueXmlString.append("<comm_perc><![CDATA[" ).append(String.format ("%.2f", comm)).append( "]]></comm_perc>\r\n" ); valueXmlString.append("<comm_perc><![CDATA[" ).append(String.format ("%.2f", comm)).append( "]]></comm_perc>\r\n" );
valueXmlString.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f", commPerUnit)).append( "]]></comm_per_unit>\r\n" ); valueXmlString.append("<comm_per_unit><![CDATA[" ).append(String.format ("%.2f",commPerUnit)).append( "]]></comm_per_unit>\r\n" );
valueXmlString.append("<rate__new><![CDATA[" ).append(Math.round(rate)).append( "]]></rate__new>\r\n" ); //valueXmlString.append("<rate__new><![CDATA[" ).append(Math.round(rate)).append( "]]></rate__new>\r\n" );//Changed on 04-10-18 Having Confusion
valueXmlString.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" ); valueXmlString.append("<rate__new><![CDATA[" ).append(Math.round(grossRate)).append( "]]></rate__new>\r\n" );
valueXmlString.append("<cost_rate><![CDATA[" ).append(String.format ("%.2f", costRate)).append( "]]></cost_rate>\r\n" ); //valueXmlString.append("<basic_dist_price><![CDATA[" ).append(String.format ("%.2f", newCostRate)).append( "]]></basic_dist_price>\r\n" );
valueXmlString.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" ); //valueXmlString.append("<cost_rate><![CDATA[" ).append(String.format ("%.2f", costRate)).append( "]]></cost_rate>\r\n" );
valueXmlString.append("<basic_dist_price><![CDATA[" ).append(getCommaSep(newCostRate)).append( "]]></basic_dist_price>\r\n" );
valueXmlString.append("<cost_rate><![CDATA[" ).append( getCommaSep(costRate)).append( "]]></cost_rate>\r\n" );
/*valueXmlString.append("<profit><![CDATA[" ).append(String.format ("%.2f", profit)).append( "]]></profit>\r\n" );
valueXmlString.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" ); valueXmlString.append("<profit_on_goods><![CDATA[" ).append(String.format ("%.2f", profitOnGoods)).append( "]]></profit_on_goods>\r\n" );
valueXmlString.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price >\r\n" ); valueXmlString.append("<final_price><![CDATA[" ).append(String.format ("%.2f", finalPrice)).append( "]]></final_price >\r\n" );
valueXmlString.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" ); valueXmlString.append("<perc_profit><![CDATA[" ).append(String.format ("%.2f", percProfit)).append( "]]></perc_profit>\r\n" );
valueXmlString.append("<available_stock><![CDATA[" ).append(String.format ("%.2f", availblStock)).append( "]]></available_stock>\r\n" ); valueXmlString.append("<available_stock><![CDATA[" ).append(String.format ("%.2f", availblStock)).append( "]]></available_stock>\r\n" );*/
valueXmlString.append("<discount_type><![CDATA[" ).append(discountType).append( "]]></discount_type>\r\n" ); valueXmlString.append("<profit><![CDATA[" ).append( getCommaSep(profit) ).append( "]]></profit>\r\n" );
valueXmlString.append("<profit_on_goods><![CDATA[" ).append( getCommaSep( profitOnGoods ) ).append( "]]></profit_on_goods>\r\n" );
valueXmlString.append("<final_price><![CDATA[" ).append( getCommaSep( finalPrice ) ).append( "]]></final_price >\r\n" );
valueXmlString.append("<perc_profit><![CDATA[" ).append( getCommaSep( percProfit ) ).append( "]]></perc_profit>\r\n" );
valueXmlString.append("<available_stock><![CDATA[" ).append( getCommaSep( availblStock ) ).append( "]]></available_stock>\r\n" );
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
} }
...@@ -1661,10 +1829,18 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1661,10 +1829,18 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
private double getCommision(String commTable, Timestamp currDate, Connection conn, String itemCode) private double getCommision(String commTable, Timestamp currDate, Connection conn, String itemCode)
{ {
System.out.println("#### In getCommision....");
System.out.println("#### commTable ["+commTable+"]");
System.out.println("#### currDate ["+currDate+"]");
System.out.println("#### itemCode ["+itemCode+"]");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
String sql1 = "";
String sql2 = "";
double commision = 0; double commision = 0;
Timestamp maxValid = null;
if(commTable != null) if(commTable != null)
{ {
try { try {
...@@ -1678,17 +1854,90 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -1678,17 +1854,90 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
{ {
commision = rs.getDouble("COMM_PERC"); commision = rs.getDouble("COMM_PERC");
} }
pstmt.close(); close(rs,pstmt);
rs = null; if( commision == 0 )
pstmt = null; {
maxValid = getMaxValidity(conn,commTable,itemCode);
if( maxValid != null)
{
sql1 = "SELECT COMM_PERC FROM COMM_DET WHERE COMM_TABLE = ? AND ITEM_CODE = ? AND VALID_UPTO = ?";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,commTable);
pstmt.setString(2,itemCode);
pstmt.setTimestamp(3,maxValid);
rs = pstmt.executeQuery();
while(rs.next())
{
commision = rs.getDouble("COMM_PERC");
}
close(rs,pstmt);
}
}
} catch (SQLException e) } catch (SQLException e)
{ {
System.out.println("#### Exception in SalesQuotProposal :: getCommision :"+e); System.out.println("#### Exception in SalesQuotProposal :: getCommision :"+e);
e.printStackTrace(); e.printStackTrace();
} }
} }
System.out.println("##### getCommision :: Commision "+commision);
return commision; return commision;
} }
private Timestamp getMaxValidity(Connection conn, String comm,String itemCode)
{
Timestamp validDate = null;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
if(itemCode != null)
{
sql = "SELECT MAX(VALID_UPTO) AS VALID_UPTO FROM COMM_DET WHERE COMM_TABLE = ? AND ITEM_CODE = ? ";
try
{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, comm);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
validDate = rs.getTimestamp("VALID_UPTO");
System.out.println("####### IN IF COMMISION VALID_UPTO "+validDate);
}
close(rs,pstmt);
} catch (SQLException e)
{
e.printStackTrace();
}
}
else
{
sql = "SELECT MAX(VALID_UPTO) AS VALID_UPTO FROM COMM_DET WHERE COMM_TABLE = ?";
try
{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, comm);
rs = pstmt.executeQuery();
if(rs.next())
{
validDate = rs.getTimestamp("VALID_UPTO");
System.out.println("####### IN IF COMMISION VALID_UPTO "+validDate);
}
close(rs,pstmt);
}
catch (SQLException e)
{
e.printStackTrace();
}
}
System.out.println("####### COMMISION VALID_UPTO "+validDate);
return validDate;
}
public String getFormattedCustId(String custId) public String getFormattedCustId(String custId)
{ {
StringBuffer custIdStrBuff = new StringBuffer(); StringBuffer custIdStrBuff = new StringBuffer();
...@@ -2132,12 +2381,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2132,12 +2381,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
{ {
slabNo = resultSet.getInt("SLAB_NO"); slabNo = resultSet.getInt("SLAB_NO");
} }
// close(resultSet); close(resultSet,pStmt);
// close(pStmt);
resultSet.close();
resultSet = null;
pStmt.close();
pStmt = null;
String validUptoSql = "SELECT * FROM PRICELIST WHERE PRICE_LIST = ? AND ITEM_CODE = ? AND UNIT = ? and slab_no = ?"; String validUptoSql = "SELECT * FROM PRICELIST WHERE PRICE_LIST = ? AND ITEM_CODE = ? AND UNIT = ? and slab_no = ?";
sPstmt = connection.prepareStatement(validUptoSql); sPstmt = connection.prepareStatement(validUptoSql);
...@@ -2164,12 +2409,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2164,12 +2409,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
refNo = sRst.getString("REF_NO"); refNo = sRst.getString("REF_NO");
refOldNo = sRst.getString("REF_NO_OLD"); refOldNo = sRst.getString("REF_NO_OLD");
} }
// close(sRst); close(sRst,sPstmt);
// close(sPstmt);
sRst.close();
sRst = null;
sPstmt.close();
sPstmt = null;
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
...@@ -2193,10 +2433,12 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2193,10 +2433,12 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
updatePreStmt.setInt(5, slabNo); updatePreStmt.setInt(5, slabNo);
int updatedCnt = updatePreStmt.executeUpdate(); int updatedCnt = updatePreStmt.executeUpdate();
System.out.println("SalesQuotProposal.updatePriceList() updatedCnt : "+updatedCnt); System.out.println("SalesQuotProposal.updatePriceList() updatedCnt : "+updatedCnt);
// close(updatePreStmt);
updatePreStmt.close();
updatePreStmt = null;
if(updatePreStmt != null)
{
updatePreStmt.close();
updatePreStmt =null;
}
String insertPriceListSql = "INSERT INTO PRICELIST(PRICE_LIST,ITEM_CODE,UNIT,LIST_TYPE,SLAB_NO,EFF_FROM,VALID_UPTO,LOT_NO__FROM,LOT_NO__TO,MIN_QTY,MAX_QTY,RATE,RATE_TYPE,MIN_RATE,CHG_DATE, CHG_USER, CHG_TERM, MAX_RATE, ORDER_TYPE,CHG_REF_NO,PRICE_LIST__PARENT,CALC_BASIS,REF_NO,REF_NO_OLD)" String insertPriceListSql = "INSERT INTO PRICELIST(PRICE_LIST,ITEM_CODE,UNIT,LIST_TYPE,SLAB_NO,EFF_FROM,VALID_UPTO,LOT_NO__FROM,LOT_NO__TO,MIN_QTY,MAX_QTY,RATE,RATE_TYPE,MIN_RATE,CHG_DATE, CHG_USER, CHG_TERM, MAX_RATE, ORDER_TYPE,CHG_REF_NO,PRICE_LIST__PARENT,CALC_BASIS,REF_NO,REF_NO_OLD)"
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement insertPstmt = connection.prepareStatement(insertPriceListSql); PreparedStatement insertPstmt = connection.prepareStatement(insertPriceListSql);
...@@ -2228,14 +2470,21 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2228,14 +2470,21 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
int insertUpdate = insertPstmt.executeUpdate(); int insertUpdate = insertPstmt.executeUpdate();
System.out.println("SalesQuotProposal.updatePriceList() L insertUpdate" +insertUpdate); System.out.println("SalesQuotProposal.updatePriceList() L insertUpdate" +insertUpdate);
// close(insertPstmt);
insertPstmt.close(); /* if(updatePreStmt != null)
insertPstmt = null; {
updatePreStmt.close();
updatePreStmt = null;
}*/
if(updatedCnt >= 0 || insertUpdate >= 0 ) if(updatedCnt >= 0 || insertUpdate >= 0 )
{ {
//connection.commit(); //connection.commit();
} }
if(insertPstmt != null)
{
insertPstmt.close();
insertPstmt = null;
}
} catch (SQLException e) } catch (SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
...@@ -2247,20 +2496,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2247,20 +2496,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
} }
/*private void close(AutoCloseable autoCloseable)
{
if(autoCloseable != null )
{
try
{
autoCloseable.close();
} catch (Exception e)
{
System.out.println("SalesQuotProposal.close() : "+e);
}
}
}*/
private String getCommission(String custCode, Connection connection) private String getCommission(String custCode, Connection connection)
{ {
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
...@@ -2280,12 +2515,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2280,12 +2515,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
commTable = resultSet.getString("COMM_TABLE__3"); commTable = resultSet.getString("COMM_TABLE__3");
} }
} }
// close(resultSet); close(resultSet,pStmt);
// close(pStmt);
resultSet.close();
resultSet = null;
pStmt.close();
pStmt = null;
} }
catch (SQLException e) catch (SQLException e)
{ {
...@@ -2332,12 +2563,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2332,12 +2563,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
{ {
additionalCost = rs.getString("VAR_VALUE"); additionalCost = rs.getString("VAR_VALUE");
} }
// close(rs); close(rs,pstmt);
// close(pstmt);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -2346,4 +2573,904 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal ...@@ -2346,4 +2573,904 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
return additionalCost; return additionalCost;
} }
/*
* This method take double value as a input.
* Apply format as provided then converted into double value.
* At last it return the value as a decimal format
*/
private String getCommaSep(double num)
{
String str = String.format("%.2f", num);
double doubleVal = Double.parseDouble(str);
System.out.println("@@@@@@@@@@@@@ Formated String ["+str);
DecimalFormat dbf = new DecimalFormat();
return dbf.format(doubleVal);
}
private double getRate(Connection conn, String priceList,String itemCode) throws ITMException, SQLException
{
double rate = 0.0;
String listType = "";
String sql ="";
String siteCode = "";
String locCode = "";
String lotSl = "";
PreparedStatement pstmt = null;
PreparedStatement pstmt2 = null;
ResultSet rs = null;
ResultSet rs2 = null;
ResultSet rs3 = null;
String priceListParent = "";
System.out.println("##### Calling getRate priceList "+priceList);
String sqlStr = "SELECT LIST_TYPE FROM PRICELIST_MST WHERE PRICE_LIST = ?";
try
{
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, priceList);
rs = pstmt.executeQuery();
while(rs.next())
{
listType = rs.getString(1);
}
close(rs,pstmt);
if(listType != null)
{
//String slabNo = "SELECT MAX(SLAB_NO) FROM PRICELIST WHERE PRICE_LIST = "+priceList+" and ITEM_CODE = "+itemCode+" AND LIST_TYPE = "+listType+"";
int slabNo = getMaxSlabNo(conn, priceList, itemCode, listType);
if(listType.trim().equals("L"))
{
try
{
String sqlQuery = "SELECT RATE FROM PRICELIST WHERE PRICE_LIST = ? and ITEM_CODE = ? AND LIST_TYPE = ? AND SLAB_NO = ?";
pstmt = conn.prepareStatement(sqlQuery);
pstmt.setString(1, priceList);
pstmt.setString(2, itemCode);
pstmt.setString(3, listType);
pstmt.setInt(4, slabNo);
rs = pstmt.executeQuery();
if( rs.next())
{
rate = rs.getDouble("RATE");
close(rs,pstmt);
}
else
{
close(rs,pstmt);
String sqlStr2 = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) FROM pricelist_mst WHERE PRICE_LIST = ?";
pstmt = conn.prepareStatement(sqlStr2);
pstmt.setString(1, priceList);
rs = pstmt.executeQuery();
while(rs.next())
{
priceListParent = rs.getString(1) == null ? "" : rs
.getString(1);
if (priceListParent.trim().length() > 0)
{
try
{
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent + "' "
+ "AND ITEM_CODE = '" + itemCode
+ "' " + "AND LIST_TYPE = ? "
+ "AND SLAB_NO <= ? ";
pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1, listType);
pstmt.setInt(2, slabNo);
rs2 = pstmt2.executeQuery();
if (rs2.next())
{
rate = rs2.getDouble(1);
System.out.println("#### 2552 Rate" + rate);
close(rs2,pstmt);
}
else
{
close(rs2,pstmt);
return -1;
}
if (rate > 0)
{
priceList = priceListParent;
}
else
{
priceList = priceListParent;
priceListParent = "";
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
}
close(rs,pstmt);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
else if(listType.trim().equals("F"))
{
try
{
sql = "SELECT RATE FROM PRICELIST " + "WHERE PRICE_LIST = '"
+ priceList + "' " + "AND ITEM_CODE = '" + itemCode
+ "' " + "AND LIST_TYPE = ? " + "AND SLAB_NO =?";
close(rs,pstmt);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
System.out.println("#### Rate" + rate);
close(rs2,pstmt);
}
else
{
try
{
close(rs2,pstmt);
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
priceListParent = rs.getString(1);
}
close(rs,pstmt);
if ((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
return -1;
}
if (priceListParent.trim().length() > 0)
{
try
{
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = ? "
+ "AND SLAB_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
rate = rs2.getDouble(1);
close(rs2,pstmt);
}
else
{
close(rs2,pstmt);
return -1;
}
}
catch (Exception e)
{
System.out.println("#### Exception...[getRate] "
+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
}
catch (Exception e)
{
System.out.println("#### Exception...[getRate] " + sql+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
close(rs,pstmt);
}
catch (Exception e)
{
System.out.println("#### Exception...[getRate] " + sql+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
else if(listType.trim().equals("D"))
{
try
{
sql = "SELECT RATE FROM PRICELIST " + "WHERE PRICE_LIST = '"
+ priceList + "' " + "AND ITEM_CODE = '" + itemCode
+ "' " + "AND LIST_TYPE = ? " + "AND SLAB_NO = ? ";
close(rs,pstmt);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
close(rs,pstmt);
}
else
{
try
{
close(rs,pstmt);
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
System.out.println("The priceListParent is .... "
+ priceListParent);
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
if ((priceListParent == null) || (priceListParent.trim().length() == 0)) {
priceListParent = "";
return -1;
}
if (priceListParent.trim().length() > 0)// 1
{
try
{
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = ? "
+ "AND SLAB_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs2 = pstmt.executeQuery();
if (rs2.next()) {
rate = rs2.getDouble(1);
System.out.println("#### 2688 Rate:" + rate);
close(rs2,pstmt);
}
else
{
try
{
close(rs2,pstmt);
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceList + "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = ? "
+ "AND SLAB_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
rate = rs2.getDouble(1);
close(rs2,pstmt);
} else {
try {
close(rs2,pstmt);
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "' ";
pstmt = conn
.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if (rs2.next()) {
priceListParent = rs2
.getString(1);
}
close(rs2,pstmt);
if ((priceListParent == null)
|| (priceListParent
.trim()
.length() == 0)) {
priceListParent = "";
return -1;
}
if (priceListParent.trim()
.length() > 0)
{
try {
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = ? "
+ "AND SLAB_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,listType);
pstmt.setInt(2, slabNo);
rs3 = pstmt.executeQuery();
if (rs3.next())
{
rate = rs3.getDouble(1);
close(rs3,pstmt);
} else
{
close(rs3,pstmt);
return -1;
}
} catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
close(rs,pstmt);
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
else if(listType.trim().equals("B"))
{
rate = 0;
try
{
sql = "SELECT RATE FROM PRICELIST " + "WHERE PRICE_LIST = '"
+ priceList + "' " + "AND ITEM_CODE = '" + itemCode
+ "' " + "AND LIST_TYPE = ? "
+ "AND SLAB_NO = ? ";
close(rs,pstmt);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
close(rs,pstmt);
}
else
{
try
{
close(rs,pstmt);
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
close(rs,pstmt);
if ((priceListParent == null)
|| (priceListParent.trim().length() == 0))
{
priceListParent = "";
}
if (priceListParent.trim().length() > 0)
{
try
{
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent + "' "
+ "AND ITEM_CODE = '" + itemCode
+ "' "
+ "AND LIST_TYPE = ? "
+ "AND SLAB_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
rate = rs2.getDouble(1);
close(rs2,pstmt);
}
else
{
close(rs2,pstmt);
return -1;
}
if (rate > 0)
{
priceList = priceListParent;
}
else
{
priceList = priceListParent;
priceListParent = "";
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
}
else
{
close(rs,pstmt);
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
close(rs,pstmt);
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
else if((listType.trim().equals("M")) || (listType.trim().equals("N")))
{
System.out.println("Inside type ::-<M><N>-::");
try
{
sql = "SELECT RATE FROM PRICELIST " + "WHERE PRICE_LIST = '"
+ priceList + "' " + "AND ITEM_CODE = '" + itemCode
+ "' " + "AND LIST_TYPE = ? "+ "AND SLAB_NO = ? " ;
close(rs,pstmt);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
close(rs,pstmt);
} else
{
try
{
close(rs,pstmt);
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
priceListParent = rs.getString(1);
}
close(rs,pstmt);
if ((priceListParent == null) || (priceListParent.trim().length() == 0))
{
priceListParent = "";
return -1;
}
if (priceListParent.trim().length() > 0)
{
sql = "SELECT LIST_TYPE FROM PRICELIST_MST WHERE PRICE_LIST = '"
+ priceListParent + "' ";
pstmt = conn.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
listType = rs2.getString(1);
close(rs2,pstmt);
}
try
{
sql = "SELECT RATE FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent + "' "
+ "AND ITEM_CODE = '" + itemCode
+ "' "
+ "AND LIST_TYPE = ? "
+ "AND SLAB_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listType);
pstmt.setInt(2, slabNo);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
rate = rs2.getDouble(1);
close(rs2,pstmt);
}
else
{
close(rs2,pstmt);
return -1;
}
}
catch (Exception e)
{
System.out.println("@@@@@@ Exception getRate : "+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
} catch (Exception e)
{
System.out.println("@@@@@@ Exception getRate : " + sql+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
} catch (Exception e)
{
System.out.println("@@@@@@@ Exception getRate " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
else if(listType.trim().equals("I"))
{
if ((lotSl == null) || (lotSl.trim().length() == 0))
{
System.out.println("Inside type ::-<I>-::");
try
{
sql = "SELECT RATE FROM STOCK " + "WHERE ITEM_CODE = '"
+ itemCode + "' " + "AND SITE_CODE = '" + siteCode + "' " + "AND LOC_CODE = '" + locCode + "' ";
close(rs,pstmt);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
System.out.println("Rate is .*...." + rate);
}
close(rs,pstmt);
}
catch (Exception e)
{
System.out.println("Exception...[getRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
else
{
try
{
sql = "SELECT RATE FROM STOCK " + "WHERE ITEM_CODE = '"
+ itemCode + "' " + "AND SITE_CODE = '" + siteCode
+ "' " + "AND LOC_CODE = '" + locCode + "' "
+ "AND LOT_SL = '" + lotSl + "'";
close(rs,pstmt);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
}
close(rs,pstmt);
} catch (Exception e)
{
System.out.println("Exception...[getRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
}
}
} catch (SQLException e)
{
System.out.println("@@@@@ Exception in getRate "+e);
}
return rate;
}
private int getMaxSlabNo(Connection conn, String priceList, String itemCode, String listType)
{
int slabNo = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT MAX(SLAB_NO) AS SLAB_NO FROM PRICELIST WHERE PRICE_LIST = ? AND ITEM_CODE = ? AND LIST_TYPE = ?";
try
{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,priceList);
pstmt.setString(2,itemCode);
pstmt.setString(3,listType);
rs = pstmt.executeQuery();
if( rs.next())
{
slabNo = rs.getInt("SLAB_NO");
System.out.println("####### IN IF SLAB NO "+slabNo);
}
close(rs,pstmt);
}
catch (SQLException e)
{
e.printStackTrace();
}
close(rs,pstmt);
System.out.println("####### SLAB NO "+slabNo);
return slabNo;
}
private void close(ResultSet rs,PreparedStatement pstmt)
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if( pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
//Added on 09-10-18 To calculate Total Summary.Below code get data for form no2 START
private List<Double> finalPriceList = null;
public List<Double> getGoodsProfitList(String custCode,String fromDateStr,String toDateStr)
{
List<Double> profitOnGoodsList = new ArrayList<Double>();
finalPriceList = new ArrayList<Double>();
Connection conn = null;
ConnDriver connDriver = null;
try {
connDriver = new ConnDriver();
conn = getConnection();
Timestamp toDate = null, fromDate = null;
toDate = Timestamp.valueOf(genericUtility.getValidDateString(toDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(fromDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
ResultSet rs = null;
ResultSet rs1 = null;
String custmerBill = "";
ArrayList<String> invoiceArr = new ArrayList<String>();
Map<String, Double> map = new HashMap<String, Double>();
String disPriceList = E12GenericUtility.checkNull(getDBColumnValue("CUSTOMER", "PRICE_LIST__DISC", "CUST_CODE = '"+custCode+"'", conn));
String priceList = E12GenericUtility.checkNull(getDBColumnValue("CUSTOMER", "PRICE_LIST", "CUST_CODE = '"+custCode+"'", conn));
String commTable = getCommission(custCode, conn);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String eventDateStr = "";
Calendar calObj1 = Calendar.getInstance();
calObj1.setTime(new java.util.Date());
java.util.Date dateFrom = calObj1.getTime();
eventDateStr = sdf.format(dateFrom);
String currDateStr = genericUtility.getValidDateString(eventDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
String qq = genericUtility.getValidDateTimeString(eventDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
Timestamp currDate = java.sql.Timestamp.valueOf(currDateStr + " 00:00:00");
custmerBill = "SELECT * FROM INVOICE WHERE CUST_CODE = ? AND TRAN_DATE >= ? AND TRAN_DATE <= ? AND INV_TYPE NOT IN ('DF','EF')";
try
{
pstmt = conn.prepareStatement(custmerBill);
pstmt.setString(1, custCode);
pstmt.setTimestamp(2, fromDate);
pstmt.setTimestamp(3, toDate);
rs = pstmt.executeQuery();
while(rs.next())
{
String invoiceId = checkNull(rs.getString("invoice_id")).trim();
//System.out.println("#### INVOICE ID :: "+invoiceId);
String invocieData = "SELECT * FROM INVOICE_TRACE WHERE INVOICE_ID = ? ";
try {
pstmt1 = conn.prepareStatement(invocieData);
pstmt1.setString(1, invoiceId);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
if(map.containsKey(rs1.getString("item_code")))
{
double i = map.put(rs1.getString("item_code"), Double.parseDouble(rs1.getString("quantity")));
System.out.println(i);
map.put(rs1.getString("item_code"), i + Double.parseDouble(rs1.getString("quantity")) );
}
else
{
map.put(rs1.getString("item_code"), Double.parseDouble(rs1.getString("quantity")));
}
}
close(rs1,pstmt1);
} catch (Exception e)
{
System.out.println("@@@@@ Exception in SalesQuotProposal :: getInvoiceId() : "+e);
}
invoiceArr.add(invoiceId);
}
close(rs,pstmt);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("SalesQuotProposal.getInvoiceId() "+e);
throw new ITMException(e);
}
String domID = "1";
Iterator<Map.Entry<String, Double>> itr = map.entrySet().iterator();
int srNo = 0;
Map<String, String> itemDetailMap = new HashMap<String, String>();
while(itr.hasNext())
{
srNo++;
Map.Entry<String, Double> entry = itr.next();
String itemCode = E12GenericUtility.checkNull(entry.getKey());
itemCodeArr2.add(itemCode);
double maxValue = entry.getValue();
itemDetailMap = getItemData(itemCode, conn);
double discount = getRate(conn, disPriceList, itemCode);
double rate = getRate(conn, priceList, itemCode);
Double grossRate = ((rate - ((rate * discount) / 100)));
if(grossRate.isNaN() || grossRate.isInfinite())
{
grossRate = 0.0;
}
double comm = 0;
try
{
comm = getCommision(commTable,currDate,conn,itemCode);
}
catch(Exception e)
{
comm = 0;
}
double commPerUnit = (((grossRate * comm) / 100));
double newCostRate = ((grossRate - commPerUnit));
double costRate = getCostRate(conn, itemCode);
//double availblStock = getStockDetails(conn,itemCode);
double profit = (newCostRate - costRate);
String profitParse = String.format("%.2f", profit);
double profitOnGoods = (Double.parseDouble(profitParse) * maxValue);
double finalPrice = (grossRate * maxValue);
String str = String.format("%.2f", profitOnGoods);
double doubleVal = Double.parseDouble(str);
profitOnGoodsList.add(doubleVal);
String str2 = String.format("%.2f", finalPrice);
double doubleVal2 = Double.parseDouble(str2);
finalPriceList.add(doubleVal2);
System.out.println("@@@@@@@@ profitOnGoods ["+doubleVal+"] finalPrice["+doubleVal2+"]");
}
} catch (Exception e)
{
e.printStackTrace();
}
System.out.println("@@@@@@@ profitOnGoodsList ["+profitOnGoodsList+"]");
return profitOnGoodsList;
}
public List<Double> getFinalPriceList()
{
System.out.println("@@@@@@ finalPriceList ["+finalPriceList+"]");
return finalPriceList;
}
//Added on 09-10-18 To calculate Total Summary.Below code get data for form no2 END
} }
\ 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