Commit d2279584 authored by asant's avatar asant

Added validation for customer end , added new field MRP in form3, get data for offer.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202966 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4888fe86
......@@ -4,6 +4,7 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
......@@ -444,6 +445,33 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
}
}
}
//Added by AMOL S on 01-JUL-2019 [D19CMES002] START
if(childNodeName.equalsIgnoreCase("cust_code__end"))
{
String custCodeEnd = genericUtility.getColumnValue("cust_code__end", dom,"1");
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String sqlQuery = "SELECT COUNT(*) FROM CUSTOMER WHERE CUST_CODE = ?";
int count = 0;
System.out.println("#### Item Code "+custCodeEnd);
if(custCodeEnd != null && custCodeEnd.trim().length() > 0)
{
preparedStatement = conn.prepareStatement(sqlQuery);
preparedStatement.setString(1, custCodeEnd);
resultSet = preparedStatement.executeQuery();
while(resultSet.next())
{
count = resultSet.getInt(1);
}
if((count < 1))
{
errCode = "VTCUSTCDEN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
//Added by AMOL S on 01-JUL-2019 [D19CMES002] END
}
// END OF CASE1
//Added by Saiprasad G. [When the settle_mth change in edit case] START
......@@ -1085,7 +1113,90 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
}
}
}
//Added by AMOL S on 01-JUL-2019 [D19CMES002] START
else if(childNodeName.equalsIgnoreCase("amount"))
{
settlemth = genericUtility.getColumnValue("settle_mth", dom2,"1");
if(settlemth.equalsIgnoreCase("Q"))
{
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
double amount = 0, schemAmt = 0;
int disparmVl = 0;
String schemAmount = "" ,sqlQuery = "",disparmVal = "";
String amountStr = E12GenericUtility.checkNull(genericUtility.getColumnValue("amount", dom));
if(amountStr.length() > 0)
{
amount = Double.parseDouble(amountStr);
}
String itemCodeRepl = E12GenericUtility.checkNull(genericUtility.getColumnValue("item_code__repl", dom));
try {
//Offer is always unique as per prashant K.
String offer = E12GenericUtility.checkNull(genericUtility.getColumnValue("offer", dom));
tranId = E12GenericUtility.checkNull(getSchmeAprDetTranId(offer,conn));
System.out.println("@@@@ tranId ["+tranId);
sqlQuery = "SELECT AMOUNT FROM SCHEME_APPRV_DET WHERE TRAN_ID = ?";
preparedStatement = conn.prepareStatement(sqlQuery);
preparedStatement.setString(1,tranId);
resultSet = preparedStatement.executeQuery();
while(resultSet.next())
{
schemAmount = resultSet.getString("amount");
if(schemAmount != null && schemAmount.trim().length() > 0)
{
schemAmt = Double.parseDouble(schemAmount);
}
}
System.out.println("@@@@ schemAmt ["+schemAmt);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
closeResources(preparedStatement,resultSet);
}
sqlQuery= "SELECT VAR_VALUE FROM DISPARM WHERE PRD_CODE = ? AND VAR_NAME = ?";
try
{
preparedStatement = conn.prepareStatement(sqlQuery);
preparedStatement.setString(1, "999999");
preparedStatement.setString(2, "ADJUST_AMOUNT");
resultSet = preparedStatement.executeQuery();
while(resultSet.next())
{
disparmVal = resultSet.getString("VAR_VALUE");
if(disparmVal != null && disparmVal.trim().length() > 0 )
{
disparmVl = Integer.parseInt(disparmVal);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
closeResources(preparedStatement,resultSet);
}
double difference = (schemAmt - amount);
System.out.println("#### (schemAmt - amount) difference ["+difference+"]");
System.out.println("#### Required Range ["+(-disparmVl)+" ~ "+disparmVl+"]");
if(difference < (-disparmVl) || difference > disparmVl)
{
errList.add("VTAMTDIF2");
errFields.add(childNodeName.toLowerCase());
}
}
}
//Added by AMOL S on 01-JUL-2019 [D19CMES002] END
}// End of for loop CASE3
//Added by Saiprasad G. [When the settle_mth change in edit case] START
......@@ -1402,7 +1513,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
}
ctr++;
} while (ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
System.out.println("#### currentColumn [" + currentColumn + "]#### Value ==> '" + columnValue + "'");
if (currentColumn.trim().equals("itm_default"))
{
if (loginSite != null || loginSite.trim().length() == 0)
......@@ -1503,7 +1614,9 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt = null;
}
}
valueXmlString.append("<cust_name_bat>").append("<![CDATA[" + (custName) + "]]>").append("</cust_name_bat>");
//Commented by AMOL S.
//valueXmlString.append("<cust_name_bat>").append("<![CDATA[" + (custName) + "]]>").append("</cust_name_bat>");
valueXmlString.append("<cust_name__end>").append("<![CDATA[" + (custName) + "]]>").append("</cust_name__end>");
/*
* String siteCodeEdit = getColumnValue("site_code",dom);
* String itemGrpEdit = getColumnValue("item_grp",dom);
......@@ -1641,7 +1754,8 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
{
type = genericUtility.getColumnValue("type", dom);
valueXmlString.append("<cust_code__end>").append("").append("</cust_code__end>");
valueXmlString.append("<cust_name_bat>").append("").append("</cust_name_bat>");
//valueXmlString.append("<cust_name_bat>").append("").append("</cust_name_bat>");//commented by AMOL
valueXmlString.append("<cust_name__end>").append("").append("</cust_name__end>");
/*
* if( type != null ) {
* valueXmlString.append("<cust_code__end protect=\"0\" >"
......@@ -1836,16 +1950,16 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
if (currentColumn.trim().equals("cust_code__end"))
{
custCode = genericUtility.getColumnValue("cust_code__end", dom);
custCode = E12GenericUtility.checkNull(genericUtility.getColumnValue("cust_code__end", dom));
type = genericUtility.getColumnValue("type", dom);
if (type != null)
if (type != null && custCode.length() > 0)
{
if (type.equals("R"))
{
sql = "select cust_name from customer " + " where cust_code = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode.trim());
pStmt.setString(1, custCode);
rs = pStmt.executeQuery();
if (rs.next())
{
......@@ -1859,7 +1973,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
{
sql = "Select first_name, middle_name, last_name from strg_customer " + " where sc_code = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode.trim());
pStmt.setString(1, custCode);
rs = pStmt.executeQuery();
if (rs.next())
{
......@@ -1874,7 +1988,9 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt = null;
}
}
valueXmlString.append("<cust_name_bat>").append("<![CDATA[" + (custName) + "]]>").append("</cust_name_bat>");
//Commented by AMOL S.
//valueXmlString.append("<cust_name_bat>").append("<![CDATA[" + (custName) + "]]>").append("</cust_name_bat>");
valueXmlString.append("<cust_name__end>").append("<![CDATA[" + (custName) + "]]>").append("</cust_name__end>");
}
if (currentColumn.trim().equals("curr_code"))
{
......@@ -2365,6 +2481,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
System.out.println("item descr1:" + itemDescr1);
settleMethod=genericUtility.getColumnValue("settle_mth", dom2, "1");
System.out.println("settlemethod:"+settleMethod);
if(settleMethod.equalsIgnoreCase("Q"))
{
valueXmlString.append("<item_descr><![CDATA[").append(itemDescr1).append("]]></item_descr>");
......@@ -2410,12 +2527,13 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
netAmt = rateT * qty1;
System.out.println("net amount of the third form:" + netAmt);
valueXmlString.append("<net_amt><![CDATA[").append(netAmt).append("]]></net_amt>");
}
else if (currentColumn.trim().equals("item_code__repl"))
{
itemCodeRepl = E12GenericUtility.checkNull(genericUtility.getColumnValue("item_code__repl", dom));
itemCodeRepl = E12GenericUtility.checkNull(genericUtility.getColumnValue("item_code__repl", dom));
System.out.println("item code1:" + itemCodeRepl);
sql = "select descr from item where item_code=?";
pStmt = conn.prepareStatement(sql);
......@@ -2430,6 +2548,9 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt = null;
System.out.println("item descr2:" + itemDescr2);
valueXmlString.append("<item_repl_descr><![CDATA[").append(itemDescr2).append("]]></item_repl_descr>");
//Added by AMOL S on 01-JUL-2019 [D19CMES002] START
valueXmlString = getCountRate(valueXmlString,conn,itemCodeRepl,dom);
//Added by AMOL S on 01-JUL-2019 [D19CMES002] END
}
else if (currentColumn.trim().equals("free_item_group"))
{
......@@ -2437,12 +2558,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
valueXmlString.append("<item_repl_descr><![CDATA[").append(dummy).append("]]></item_repl_descr>");
}
//Added by Saiprasad G. on[17-1-19]START
else if(currentColumn.trim().equals("offer"))
else if( currentColumn.trim().equals("offer") )
{
Double totalAmount=0.0;
String offer=E12GenericUtility.checkNull(genericUtility.getColumnValue("offer", dom));
String offer = E12GenericUtility.checkNull(genericUtility.getColumnValue("offer", dom));
System.out.println("Offer selected:"+offer);
String sqlofSchAprv="select amount from scheme_apprv where aprv_status='A' and scheme_code=?";
String sqlofSchAprv="select amount, tran_id from scheme_apprv where aprv_status='A' and scheme_code=?";
System.out.println("sqlofSchAprv:"+sqlofSchAprv);
pStmt=conn.prepareStatement(sqlofSchAprv);
pStmt.setString(1, offer);
......@@ -2450,6 +2571,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
while(rs.next())
{
Double amount=rs.getDouble("amount");
tranId = rs.getString("tran_id");//added by AMOL
totalAmount=totalAmount+amount;
System.out.println("amount:"+amount);
System.out.println("total amountL:"+totalAmount);
......@@ -2458,17 +2580,48 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<limit_amt protect =\"1\"><![CDATA[").append(totalAmount.toString()).append("]]></limit_amt>");
//Added by AMOL S on 01-JUL-2019 [D19CMES002] START
valueXmlString = getOfferData(valueXmlString,conn,tranId);
//Added by AMOL S on 01-JUL-2019 [D19CMES002] END
}
//Added by Saiprasad G. on[17-1-19]END
//Added by AMOL S on 01-JUL-2019 [D19CMES002] START
else if(currentColumn.trim().equalsIgnoreCase("free_qty"))
{
double countRate = 0, amount = 0, freeQunt = 0;
String freeQty = E12GenericUtility.checkNull(genericUtility.getColumnValue("free_qty", dom));
String mrp = E12GenericUtility.checkNull(genericUtility.getColumnValue("rate__count", dom));
if(freeQty.length() > 0)
{
freeQunt = Double.parseDouble(freeQty);
}
if(mrp.length() > 0)
{
countRate = Double.parseDouble(mrp);
}
amount = (freeQunt * countRate);
valueXmlString.append("<amount><![CDATA[").append(amount).append("]]></amount>");
}
//Added by AMOL S on 01-JUL-2019 [D19CMES002] END
//Form 3 END
valueXmlString.append("</Detail3>");
// //////////////
}// END OF TRY
} catch (Exception e) {
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
} finally {
}
finally
{
try {
if (rs != null) {
rs.close();
......@@ -2493,7 +2646,6 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
//Added by saiprasad on 22-Nov-18 for replacement form. [END]
return valueXmlString.toString();
}// END OF ITEMCHANGE
private String getCurrdateAppFormat() throws Exception, ITMException
{
String s = "";
......@@ -3232,5 +3384,205 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
}
return minRate;
}
//Added by AMOL S on 01-JUL-2019 [D19CMES002] START
private StringBuffer getCountRate(StringBuffer valueXmlString, Connection conn, String itemCodeRepl, Document dom)
{
double countRate = 0, amount = 0, freeQunt = 0;
try
{
String freeQty = E12GenericUtility.checkNull(genericUtility.getColumnValue("free_qty", dom));
if(freeQty != null && freeQty.trim().length() > 0)
{
freeQunt = Double.parseDouble(freeQty);
}
}
catch (ITMException e)
{
e.printStackTrace();
}
try
{
String priceList = E12GenericUtility.checkNull(getPriceList(conn));
countRate = getPriceListRate(priceList,itemCodeRepl,conn);
amount = (freeQunt * countRate);
}
catch (Exception e)
{
e.printStackTrace();
}
valueXmlString.append("<amount><![CDATA[").append(amount).append("]]></amount>");
valueXmlString.append("<rate__count><![CDATA[").append(countRate).append("]]></rate__count>"); //Added by AMOL
return valueXmlString;
}
private String getPriceList(Connection conn)
{
String priceList = "";
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String sqlQuery = "SELECT VAR_VALUE from DISPARM where VAR_NAME = ?";
try
{
preparedStatement = conn.prepareStatement(sqlQuery);
preparedStatement.setString(1, "MRP_GST");
resultSet = preparedStatement.executeQuery();
while(resultSet.next())
{
priceList = resultSet.getString("VAR_VALUE");
}
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
closeResources(preparedStatement, resultSet);
}
return priceList;
}
private double getPriceListRate(String priceList, String itemCodeRepl, Connection conn)
{
double countRate = 0;
String rate = "";
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String sqlQuery = "SELECT RATE from PRICELIST where PRICE_LIST = ? and ITEM_CODE = ? and SLAB_NO = (SELECT MAX(SLAB_NO) FROM PRICELIST WHERE ITEM_CODE = ?)";
try
{
preparedStatement = conn.prepareStatement(sqlQuery);
preparedStatement.setString(1, priceList);
preparedStatement.setString(2, itemCodeRepl);
preparedStatement.setString(3, itemCodeRepl);
resultSet = preparedStatement.executeQuery();
while(resultSet.next())
{
rate = resultSet.getString("RATE");
}
if(rate != null && rate.trim().length() > 0 )
{
countRate = Double.parseDouble(rate);
}
} catch (SQLException e)
{
e.printStackTrace();
}
finally
{
closeResources(preparedStatement, resultSet);
}
return countRate;
}
private StringBuffer getOfferData(StringBuffer valueXmlString, Connection conn, String tranId)
{
//offer means scheme_code
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String sqlQuery = "", itemCode = "", quantity ="", itemCodeRepl = "", freeQty = "", rateCount = "";
double amount = 0, freeQuntity = 0, rateCnt = 0;
sqlQuery ="SELECT ITEM_CODE,ITEM_CODE__REPL,QUANTITY,FREE_QTY,RATE FROM SCHEME_APPRV_DET WHERE TRAN_ID = ?";
try
{
preparedStatement = conn.prepareStatement(sqlQuery);
preparedStatement.setString(1, tranId);
resultSet = preparedStatement.executeQuery();
while( resultSet.next())
{
itemCode = resultSet.getString("ITEM_CODE");
itemCodeRepl = resultSet.getString("ITEM_CODE__REPL");
quantity = resultSet.getString("QUANTITY");
freeQty = resultSet.getString("FREE_QTY");
rateCount = resultSet.getString("RATE");
}
if(freeQty != null && freeQty.trim().length() > 0)
{
freeQuntity = Double.parseDouble(freeQty);
}
if(rateCount != null && rateCount.trim().length() > 0)
{
rateCnt = Double.parseDouble(rateCount);
}
} catch (SQLException e)
{
e.printStackTrace();
}
finally
{
closeResources(preparedStatement,resultSet);
}
amount = (freeQuntity * rateCnt);
valueXmlString.append("<item_code protect =\"1\"><![CDATA[").append(itemCode).append("]]></item_code>");
valueXmlString.append("<quantity protect =\"1\"><![CDATA[").append(quantity).append("]]></quantity>");
valueXmlString.append("<item_code__repl><![CDATA[").append(itemCodeRepl).append("]]></item_code__repl>");
valueXmlString.append("<rate><![CDATA[").append(0).append("]]></rate>");
valueXmlString.append("<free_qty><![CDATA[").append(freeQty).append("]]></free_qty>");
valueXmlString.append("<rate__count protect =\"1\"><![CDATA[").append(rateCount).append("]]></rate__count>");
valueXmlString.append("<amount protect =\"1\"><![CDATA[").append(amount).append("]]></amount>");
return valueXmlString;
}
private void closeResources(PreparedStatement preparedStatement, ResultSet resultSet)
{
if(preparedStatement != null)
{
try
{
preparedStatement.close();
} catch (SQLException e)
{
e.printStackTrace();
}
preparedStatement = null;
}
if(resultSet != null)
{
try
{
resultSet.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
resultSet = null;
}
}
private String getSchmeAprDetTranId(String offer, Connection conn)
{
String tranId = "";
PreparedStatement preparedStatement= null;
ResultSet resultSet = null;
String sqlQuery = "SELECT TRAN_ID FROM SCHEME_APPRV WHERE SCHEME_CODE = ?";
try
{
preparedStatement = conn.prepareStatement(sqlQuery);
preparedStatement.setString(1, offer);
resultSet = preparedStatement.executeQuery();
while( resultSet.next())
{
tranId = resultSet.getString("TRAN_ID");
}
closeResources(preparedStatement, resultSet);
} catch (SQLException e)
{
e.printStackTrace();
}
return tranId;
}
//Added by AMOL S on 01-JUL-2019 [D19CMES002] 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