Commit de0c9d16 authored by asant's avatar asant

WorkFlow eff, valid upto dates changes

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192733 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e6635c37
......@@ -119,7 +119,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException
{
System.out.println(" ########### SalesQuotProposal **********wfValData 3333 (Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams)***********" );
System.out.println(" #### SalesQuotProposal :: wfValData 3333 (Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams)***********" );
NodeList parentNodeList = null;NodeList childNodeList = null;
Node parentNode = null;Node childNode = null;
String childNodeName = null,cildNodeValue = null;
......@@ -136,15 +136,13 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
double discount = 0, commPerc = 0, newRate = 0;
Timestamp currentDate = null, toDate = null, fromDate = null, validUptoDate = null, effFromDate = null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
//Added by AMOL START
//StringBuffer formatedInvIds = new StringBuffer();
int count2 = 0;
Node node = null;
Element element = null;
//Added by AMOL END
String srNoStr = "", itemCodeStr = "", quantityStr = "", rateStr = "";
String newRateStr = "";
try
{
connDriver = null;
......@@ -277,34 +275,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
break;
}
}
//Commented on 05-10-18 START
//Added by AMOL START
/*try
{
if( E12GenericUtility.checkNull(custCode).length() > 0 && E12GenericUtility.checkNull(fromDtStr).length() > 0
&& E12GenericUtility.checkNull(toDtStr).length() > 0)
{
System.out.println("#### WFValData From Date :"+fromDtStr);
System.out.println("#### WFValData To Date :"+toDtStr);
formatedInvIds = new SalesQuotRevision().getInvoiceIds(formatedInvIds,custCode,fromDtStr,toDtStr,conn);
System.out.println("#### Formatted IDs ["+formatedInvIds+"]");
System.out.println("#### formatedInvIds.length ["+formatedInvIds.length()+"]");
if(formatedInvIds.length() == 2 || formatedInvIds == null)
{
errCode = "VTNORECFND";
errList.add(errCode);
errFields.add("to_date");
break;
}
}
}
catch(Exception e)
{
System.out.println("#### Exception in WFValDate Invoice_ID "+e);
e.printStackTrace();
}*/
//Added by AMOL END
//Commented on 05-10-18 END
}
}
......@@ -391,7 +362,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
}
}
} catch (Exception e)
{
......@@ -408,7 +378,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
count2 = 0 ;
}
else if("sale_quotitems".equalsIgnoreCase(formName))
{
......@@ -427,14 +396,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("#### Detail 3 Name [ "+childNodeName+"]");
/*childElem = (Element) childNode;
System.out.println("#### item(0) ["+childElem.getElementsByTagName("item_code").item(0)+"]");
if(childElem.getElementsByTagName("item_code").item(0)!= null)
{
System.out.println("#### VALUE ==>"+childElem.getElementsByTagName("item_code").item(0).getFirstChild().getNodeValue());
}*/
//cildNodeValue = childNode.getFirstChild().getNodeValue();
//System.out.println("#### Detail3 Value [ "+childNode.getFirstChild().getNodeValue()+"]");
if(childNodeName.equalsIgnoreCase("sr_no"))
{
srNoStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("sr_no", dom));
......@@ -495,15 +457,397 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
break;
}
}
/*else if (childNodeName.equalsIgnoreCase("discount"))
}
}
}
int errListSize = errList.size();
cnt =0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
System.out.println("Inside errList >"+errList);
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String)errList.get(cnt);
System.out.println("errCode :"+errCode);
int pos = errCode.indexOf("~");
System.out.println("pos :"+pos);
if(pos>-1)
{
errCode=errCode.substring(0,pos);
}
System.out.println("##### error code is :"+errCode);
errFldName = (String)errFields.get(cnt);
System.out.println("##### cnt [" + cnt + "] errCode [" + errCode + "] errFldName [" + errFldName + "]");
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
System.out.println("errorType :"+errorType);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") +
8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString +
errString.substring(errString.indexOf("</trace>") +
8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
}//END TRY
catch(Exception e)
{
//System.out.println("Exception ::"+e);
e.printStackTrace();
errString=e.getMessage();
throw new ITMException( e );
}
finally
{
try
{
if(conn!=null)
{
if(rs != null )rs.close();
if(rs1 != null )rs.close();
rs = null;
rs1 = null;
if(pstmt != null )pstmt.close();
pstmt =null;
conn.close();
}
conn = null;
}catch(Exception d)
{
d.printStackTrace();
throw new ITMException( d );
}
}
System.out.println("ErrString ::[ "+errStringXml.toString()+" ]");
return errStringXml.toString();
}
//END OF VALIDATION
//START preValData
public String preValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
System.out.println("###### preValData xmlString2["+xmlString2+"]");
errString = preValData(dom,dom1,dom2,objContext,editFlag,xtraParams, formName);
}
catch(Exception e)
{
throw new ITMException( e );
}
return (errString);
}
public String preValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException
{
System.out.println(" ########### SalesQuotProposal ********** preValData 3333 " );
NodeList parentNodeList = null;NodeList childNodeList = null;
Node parentNode = null;Node childNode = null;
String childNodeName = null,cildNodeValue = null;
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null , rs1 = null;
int cnt = 0, currentFormNo=0,childNodeListLength ,ctr=0;
ConnDriver connDriver = new ConnDriver();
String errString = "", errCode = "",userId = "";
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> ();
String errorType = "";
String custCode= "", currAppdateStr ="", validUptoStr = "",effFromStr = "", fromDtStr = "", toDtStr = "";
double discount = 0, commPerc = 0, newRate = 0;
Timestamp currentDate = null, toDate = null, fromDate = null, validUptoDate = null, effFromDate = null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
int count2 = 0;
Node node = null;
Element element = null;
String srNoStr = "", itemCodeStr = "", quantityStr = "", rateStr = "";
String newRateStr = "";
try
{
connDriver = null;
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
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");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
if("sale_quot".equalsIgnoreCase(formName))
{
parentNodeList = dom.getElementsByTagName("Detail1");
int parentNodeListLen = parentNodeList.getLength();
for ( int rowCnt=0; rowCnt < parentNodeListLen; rowCnt++ )
{
parentNode = parentNodeList.item(rowCnt);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("cust_code"))
{
srNoStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("discount", dom));
}*/
custCode = E12GenericUtility.checkNull(genericUtility.getColumnValue("cust_code", dom));
String str = "select count(1) from customer where cust_code = ?";
int count = 0;
pstmt = conn.prepareStatement(str);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(count == 0)
{
errCode = "VMREGCUST";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if (childNodeName.equalsIgnoreCase("from_date"))
{
fromDtStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("from_date", dom));
toDtStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("to_date", dom));
if(fromDtStr.length() <= 0 || toDtStr.length() <= 0)
{
errCode = "VTINVFTDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(fromDtStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
toDate = Timestamp.valueOf(genericUtility.getValidDateString(toDtStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
if(toDate == null || fromDate == null)
{
errCode = "VTINVFTDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
if(toDate.before(fromDate))
{
errCode = "VTINVFRDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if (childNodeName.equalsIgnoreCase("valid_upto"))
{
validUptoStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("valid_upto", dom));
effFromStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("eff_date", dom));
if(validUptoStr.length() <= 0 || effFromStr.length() <= 0)
{
errCode = "VTINVEVDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
validUptoDate = Timestamp.valueOf(genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
effFromDate = Timestamp.valueOf(genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
if(validUptoDate == null || effFromDate == null)
{
errCode = "VTINVEVDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
if(validUptoDate.before(effFromDate))
{
errCode = "VTINVEFDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
if(effFromDate.before(currentDate))
{
errCode = "EFCDTPST";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
/*else if (childNodeName.equalsIgnoreCase("comm_perc"))
}
}
}
else if("sale_quotdet".equalsIgnoreCase(formName))
{
parentNodeList = dom.getElementsByTagName("Detail2");
int parentNodeListLen = parentNodeList.getLength();
System.out.println("##### Number of node in parentNodeListLen : "+parentNodeListLen);
for ( int rowCnt=0; rowCnt < parentNodeListLen; rowCnt++ )
{
try {
parentNode = parentNodeList.item(rowCnt);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
srNoStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("comm_perc", dom));
}*/
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("#### Detail 2 Name [ "+childNodeName+"]");
if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCodeStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("item_code", dom));
System.out.println("###### item_code ["+itemCodeStr+"]");
if(itemCodeStr.isEmpty())
{
errCode = "INVITMCO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
else if("sale_quotitems".equalsIgnoreCase(formName))
{
System.out.println("##### PreValData :: sale_quotitems ");
parentNodeList = dom.getElementsByTagName("Detail3");
int parentNodeListLen = parentNodeList.getLength();
//Element childElem = null;
for ( int rowCnt=0; rowCnt < parentNodeListLen; rowCnt++ )
{
parentNode = parentNodeList.item(rowCnt);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("#### Detail 3 Name [ "+childNodeName+"]");
if(childNodeName.equalsIgnoreCase("sr_no"))
{
srNoStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("sr_no", dom));
System.out.println("###### srNoStr ["+srNoStr+"]");
if(srNoStr == null)
{
errCode = "INVSRNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if(childNodeName.equalsIgnoreCase("qty_per_month"))
{
quantityStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("qty_per_month", dom));
if(quantityStr.isEmpty())
{
errCode = "INVQTYPM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCodeStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("item_code", dom));
System.out.println("###### item_code ["+itemCodeStr+"]");
if(itemCodeStr.isEmpty())
{
errCode = "INVITMCO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if(childNodeName.equalsIgnoreCase("rate"))
{
rateStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("rate", dom));
System.out.println("###### rateStr ["+rateStr+"]");
if(rateStr.isEmpty())
{
errCode = "INVRATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if (childNodeName.equalsIgnoreCase("rate__new"))
{
newRateStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("rate__new", dom));
System.out.println("###### newRateStr ["+newRateStr+"]");
if(newRateStr.isEmpty())
{
errCode = "INVNEWRT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
......@@ -556,7 +900,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}//END TRY
catch(Exception e)
{
//System.out.println("Exception ::"+e);
e.printStackTrace();
errString=e.getMessage();
throw new ITMException( e );
......@@ -585,8 +928,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
System.out.println("ErrString ::[ "+errStringXml.toString()+" ]");
return errStringXml.toString();
}
//END OF VALIDATION
//END
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("xmlString...["+xmlString+"]");
......@@ -611,9 +953,9 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException
{
System.out.println("###### xmlString 0000 ["+xmlString+"]");
System.out.println("###### xmlString 1111 ["+xmlString1+"]");
System.out.println("###### xmlString 2222 ["+xmlString2+"]");
System.out.println("###### Current Form Data DOM ["+xmlString+"]");
System.out.println("###### Previuos Form Data DOM1 ["+xmlString1+"]");
System.out.println("###### ALL FORM Data DOM2 ["+xmlString2+"]");
System.out.println("###### formName["+formName+"]");
Document dom = null;
Document dom1 = null;
......@@ -734,7 +1076,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
else if(currentColumn.trim().equalsIgnoreCase("cust_code"))
{
custCode = checkNull(genericUtility.getColumnValue("cust_code",dom));
fromDateStr = checkNull(genericUtility.getColumnValue("from_date",dom));// Added by AMOL
toDateStr = checkNull(genericUtility.getColumnValue("to_date",dom)); //Added by AMOL
......@@ -800,8 +1142,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
firstFormDetailMap.put("ToDate", toDateStr);
System.out.println("#### preViousCustCode "+firstFormDetailMap.get("CustCode"));
System.out.println("#### preViousCustCode "+firstFormDetailMap.get("FromDate"));
System.out.println("#### preViousCustCode "+firstFormDetailMap.get("ToDate"));
System.out.println("#### previous fromDate "+firstFormDetailMap.get("FromDate"));
System.out.println("#### previous To date "+firstFormDetailMap.get("ToDate"));
toDate = Timestamp.valueOf(genericUtility.getValidDateString(toDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
......@@ -1813,6 +2155,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
public boolean preDomExists(Document dom, String currentFormNo) throws ITMException
{
System.out.println("##### Pre Dom Exist ALL DATA (DOM 2) "+dom);
NodeList parentList = null;
NodeList childList = null;
Node childNode = null;
......@@ -2702,6 +3045,9 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
totalValue = totalValue +(rate * quantity);
count++;
}
System.out.println("#### Actual Cost for Item Code "+itemCode);
System.out.println("#### Total Valuation "+totalValue);
System.out.println("#### Total Quant "+totalQuantity);
if(resultSet != null)
{
resultSet.close();
......@@ -2720,7 +3066,10 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
costRate = 0.0;
}
System.out.println("#### cost rate By totalValue/totalQuantity "+costRate);
additionalCost =((getDoubleValue(getAdditionalCost(conn))/costRate) * 100 );
//additionalCost =((getDoubleValue(getAdditionalCost(conn))/costRate) * 100 );
//Note : Additional cost is 4.5 % on above cost rate.
additionalCost =((getDoubleValue(getAdditionalCost(conn)) * costRate) /100 );
System.out.println("#### additionalCost ["+additionalCost+"]");
if(additionalCost.isNaN() || additionalCost.isInfinite())
{
additionalCost = 0.0;
......@@ -2739,6 +3088,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
{
ohdTablePost = E12GenericUtility.checkNull(resultSet.getString("OHD_TABLE__POST"));
}
System.out.println("#### PROCESS_OVERHEAD_DET => TABLE_NO "+ohdTablePost);
preparedStatement.close();
resultSet.close();
......@@ -2759,7 +3109,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
overHeadVal = Double.parseDouble(overHeadDetails);
overHeadValue = overHeadValue + overHeadVal;
}
System.out.println("#### overHeadValue " +overHeadValue);
System.out.println("#### Over Head Value " +overHeadValue);
preparedStatement.close();
resultSet.close();
}
......@@ -2772,7 +3122,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
{
costRate = 0.0;
}
System.out.println("#### costRate with overHeadValue "+costRate);
System.out.println("#### FINAL costRate "+costRate);
}
catch(SQLException ex)
......@@ -2818,9 +3168,11 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
//Wrkflw ....
@Override
public String approvePriceRate(String quotNo, String userInfo, String xmlData)
public String approvePriceRate(String quotNo, String userInfo, String xmlData,String effDate, String validUpto)
{
System.out.println("###### approvePriceRate .....");
System.out.println("###### effDate [ "+effDate);
System.out.println("###### validUpto ["+validUpto);
Document dom = null;
try
{
......@@ -2834,12 +3186,13 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
String itemCode = "", proposedRate = "", custCode = "", priceList = "", validUpto = "", unit = "", revisedRate = "";
String termID = "",chgUser = "", chgTerm = "";;
//String validUpto = "";
String itemCode = "", proposedRate = "", custCode = "", priceList = "", unit = "", revisedRate = "";
String termID = "",chgUser = "", chgTerm = "";
NodeList parentNodeList = null;NodeList childNodeList = null;
Node parentNode = null;Node childNode = null;
String childNodeName = null;
int cnt = 0, currentFormNo=0,childNodeListLength ,ctr=0;
int cnt = 0, currentFormNo=0,childNodeListLength = 0 ,ctr=0;
try
{
UserInfoBean userInfoBean = new UserInfoBean(userInfo);
......@@ -2909,7 +3262,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
}
System.out.println("####");
updatePriceList(priceList, itemCode, unit, revisedRate, chgTerm, chgUser, connection);
updatePriceList(priceList, itemCode, unit, revisedRate, chgTerm, chgUser, connection, effDate, validUpto);
}
}
......@@ -2932,7 +3285,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
//This method called through workflow
private void updatePriceList(String priceList, String itemCode, String unit, String revisedRate, String chgTerm, String chgUser, Connection connection)
private void updatePriceList(String priceList, String itemCode, String unit, String revisedRate, String chgTerm, String chgUser, Connection connection, String effDate, String validUpto)
{
System.out.println("#### updatePriceList .....");
PreparedStatement pStmt = null;
......@@ -2940,7 +3293,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
PreparedStatement sPstmt = null;
ResultSet sRst = null;
int slabNo = 0;
String listType = "", effFrom = "", validUpto = "", lotNoFrom = "", lotNoTo = "", rateType ="", priceListParent = "", calcBasis = "";
//String effFrom = "", validUpto = "";
String listType = "", lotNoFrom = "", lotNoTo = "", rateType ="", priceListParent = "", calcBasis = "";
String refNo = "", refOldNo = "", orderType = "", chgRefNo = "";
String minQty = "", maxQty = "", rate = "", maxRate = "", minRate ="";
Timestamp validDate = null;
......@@ -2958,6 +3312,10 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
close(resultSet,pStmt);
System.out.println("#### PRICE_LIST "+priceList);
System.out.println("#### itemCode "+itemCode);
System.out.println("#### unit "+unit);
System.out.println("#### MAX Slab No "+slabNo);
String validUptoSql = "SELECT * FROM PRICELIST WHERE PRICE_LIST = ? AND ITEM_CODE = ? AND UNIT = ? and slab_no = ?";
sPstmt = connection.prepareStatement(validUptoSql);
......@@ -2984,6 +3342,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
refNo = sRst.getString("REF_NO");
refOldNo = sRst.getString("REF_NO_OLD");
}
close(sRst,sPstmt);
......@@ -2997,7 +3356,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
cal.setTimeInMillis(validDate.getTime());
cal.add(Calendar.DAY_OF_MONTH, -1);
validDate = new Timestamp(cal.getTime().getTime());
System.out.println("validDate After: "+validDate);
System.out.println("#### validDate After: "+validDate);
String updateSql = "UPDATE PRICELIST SET VALID_UPTO = ? WHERE PRICE_LIST = ? AND ITEM_CODE = ? AND UNIT = ? and slab_no = ?";
PreparedStatement updatePreStmt = connection.prepareStatement(updateSql);
......@@ -3007,13 +3366,21 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
updatePreStmt.setString(4, unit);
updatePreStmt.setInt(5, slabNo);
int updatedCnt = updatePreStmt.executeUpdate();
System.out.println("SalesQuotProposal.updatePriceList() updatedCnt : "+updatedCnt);
System.out.println(" ##### updatedCnt : "+updatedCnt);
System.out.println(" ##### Update Query : "+updatePreStmt);
if(updatePreStmt != null)
{
updatePreStmt.close();
updatePreStmt =null;
}
Timestamp effDateTime = getDate(effDate);
Timestamp validUptoTime = getDate(validUpto);
System.out.println("###### Creating insert Query ");
System.out.println("###### effDateTime "+effDateTime);
System.out.println("###### validUptoTime "+validUptoTime);
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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement insertPstmt = connection.prepareStatement(insertPriceListSql);
......@@ -3022,8 +3389,8 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
insertPstmt.setString(3, unit);
insertPstmt.setString(4, listType);
insertPstmt.setInt(5, slabNo + 1);
insertPstmt.setString(6, effFrom);
insertPstmt.setString(7, validUpto);
insertPstmt.setTimestamp(6, effDateTime);//
insertPstmt.setTimestamp(7, validUptoTime);//
insertPstmt.setString(8, lotNoFrom);
insertPstmt.setString(9, lotNoTo);
insertPstmt.setString(10, minQty);
......@@ -3031,7 +3398,7 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
insertPstmt.setString(12, revisedRate);
insertPstmt.setString(13, rateType);
insertPstmt.setString(14, minRate);
insertPstmt.setString(15, validUpto);
insertPstmt.setTimestamp(15, validDate);// ?
insertPstmt.setString(16, chgTerm);
insertPstmt.setString(17, chgUser);
insertPstmt.setString(18, maxRate);
......@@ -3042,12 +3409,15 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
insertPstmt.setString(23, refNo);
insertPstmt.setString(24, refOldNo);
int insertUpdate = insertPstmt.executeUpdate();
System.out.println("SalesQuotProposal.updatePriceList() L insertUpdate" +insertUpdate);
int insertRecord = insertPstmt.executeUpdate();
System.out.println("###### No of record Inserted" +insertRecord);
System.out.println("###### Insert Query" +insertPstmt);
if(updatedCnt > 0 || insertUpdate > 0 )
if(updatedCnt > 0 || insertRecord > 0 )
{
connection.commit();//To commit [save] transcations.
System.out.println("##### Connection Commited...");
connection.commit();//To commit transactions.
}
if(insertPstmt != null)
{
......@@ -3056,7 +3426,6 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
}
} catch (SQLException e)
{
e.printStackTrace();
......@@ -4173,4 +4542,18 @@ public class SalesQuotProposal extends ValidatorEJB implements SalesQuotProposal
return "";
}
private Timestamp getDate(String date)
{
Timestamp timeDate = null;
try
{
timeDate = Timestamp.valueOf(genericUtility.getValidDateString(date,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())
+ " 00:00:00.0");
} catch (Exception e)
{
e.printStackTrace();
}
System.out.println("#### getDate ["+timeDate);
return timeDate;
}
}
\ No newline at end of file
......@@ -24,6 +24,6 @@ public interface SalesQuotProposalLocal extends ValidatorLocal
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException;
public String approvePriceRate(String quotNo, String userInfo, String xmlData);
public String approvePriceRate(String quotNo, String userInfo, String xmlData,String effDate, String validUpto);
}
......@@ -23,5 +23,5 @@ public interface SalesQuotProposalRemote extends ValidatorRemote
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException,ITMException;
public String approvePriceRate(String quotNo, String userInfo, String xmlData);
public String approvePriceRate(String quotNo, String userInfo, String xmlData,String effDate, String validUpto);
}
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