Commit 44224593 authored by sgadve's avatar sgadve

Updated bussiness logic for the charge back

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195971 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 212650fb
......@@ -111,7 +111,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
String prdCode = "",frDateStr="",toDateStr="";
java.sql.Timestamp tranDateTs = null, tempTst = null,frDate=null,toDate=null;
Date bllDate = null;
String blDate="";
String blDate="",varValue="";
String freeQty="",freeValue=""; //Added by saiprasad on 22-Nov-18
System.out.println("IN VALIDATION wfValData()");
......@@ -990,9 +990,34 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
else if (settlemth.equalsIgnoreCase("C"))
{
System.out.println("settle method in third form for the credit note:"+settlemth);
errList.add("VMINVTHIRD");
errFields.add(childNodeName.toLowerCase());
errList.add("VMINVTHIRD");
errFields.add(childNodeName.toLowerCase());
}
//Added by saiprasad G. on[17-1-19] START
String limitAmt=genericUtility.getColumnValue("limit_amt", dom);
String sqlDisparm="select VAR_VALUE from disparm where VAR_NAME='SCH_BUDGET_APR'";
pStmt=conn.prepareStatement(sqlDisparm);
rs=pStmt.executeQuery();
if(rs.next())
{
varValue=rs.getString("VAR_VALUE");
System.out.println("varValue:"+varValue);
}
pStmt.close();
pStmt = null;
rs.close();
rs = null;
if(varValue.equalsIgnoreCase("T"))
{
Double limitAmount=Double.parseDouble(limitAmt);
Double freeValue1=Double.parseDouble(freeValue);
if(freeValue1>limitAmount)
{
errList.add("MAXFREEVAL");
errFields.add(childNodeName.toLowerCase());
}
}
//Added by saiprasad G. on[17-1-19] END
}
else if(childNodeName.equalsIgnoreCase("free_qty"))
{
......@@ -2369,6 +2394,31 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
valueXmlString.append("<item_code__repl><![CDATA[").append(dummy).append("]]></item_code__repl>");
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"))
{
Double totalAmount=0.0;
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=?";
System.out.println("sqlofSchAprv:"+sqlofSchAprv);
pStmt=conn.prepareStatement(sqlofSchAprv);
pStmt.setString(1, offer);
rs=pStmt.executeQuery();
while(rs.next())
{
Double amount=rs.getDouble("amount");
totalAmount=totalAmount+amount;
System.out.println("amount:"+amount);
System.out.println("total amountL:"+totalAmount);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<limit_amt><![CDATA[").append(totalAmount.toString()).append("]]></limit_amt>");
}
//Added by Saiprasad G. on[17-1-19]END
valueXmlString.append("</Detail3>");
// //////////////
}// END OF TRY
......
......@@ -136,10 +136,12 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
String valueString="";
ArrayList<String> valueStringList=new ArrayList<String>();
int countError = 0;
String chargeBakSql = "", secondarySchSql = "", schemeBalSql = "",drcrRcpSql="";
String custCode1 = "", itemCodeRepl = "", confDateStr = "", settleMethod = "", siteCode1 = "",
String chargeBakSql = "", secondarySchSql = "", schemeBalSql = "",drcrRcpSql="",customerSql="",customerSql1="",validUpto="";
String custCode1 = "", itemCodeRepl = "", confDateStr = "", settleMethod = "", siteCode1 = "",custCode2="",siteCode2="",
offer = "", vaildUpto = "";
int freeQty = 0, freeVaule = 0;
Map<String, String> map1=new HashMap<>();
Map<String, String> map2=new HashMap<>();
try
{
//Changes and Commented By Bhushan on 09-06-2016 :START
......@@ -798,6 +800,43 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
preparedStatement = null;
}
customerSql="SELECT CUST_CODE FROM CUSTOMER WHERE SITE_CODE=? AND CHANNEL_PARTNER=?";
preparedStatement=conn.prepareStatement(customerSql);
preparedStatement.setString(1, siteCode1);
preparedStatement.setString(2, "Y");
resultSet=preparedStatement.executeQuery();
if(resultSet.next())
{
custCode2=resultSet.getString("CUST_CODE");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(preparedStatement != null)
{
preparedStatement.close();
preparedStatement = null;
}
customerSql1="SELECT SITE_CODE__PBUS FROM CUSTOMER WHERE CUST_CODE=?";
preparedStatement=conn.prepareStatement(customerSql1);
preparedStatement.setString(1, custCode2);
resultSet=preparedStatement.executeQuery();
while(resultSet.next())
{
siteCode2=resultSet.getString("SITE_CODE__PBUS");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(preparedStatement != null)
{
preparedStatement.close();
preparedStatement = null;
}
// For the charge_back_repl
secondarySchSql = "SELECT ITEM_CODE__REPL,FREE_QTY,FREE_VALUE,OFFER FROM CHARGE_BACK_REPL WHERE TRAN_ID=?";
preparedStatement1 = conn.prepareStatement(secondarySchSql);
......@@ -830,7 +869,9 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
calObj1.add(Calendar.YEAR, 2);
java.util.Date dateFrom = calObj1.getTime();
Timestamp vaildUpto1 = new Timestamp(dateFrom.getTime());
Date validUptoDate=new Date(vaildUpto1.getTime());
validUpto=sdf1.format(validUptoDate);
// insert into scheme balance
System.out.println("settle method2::[" + settleMethod + "]");
if (settleMethod.equalsIgnoreCase("V") || settleMethod.equalsIgnoreCase("Q"))
......@@ -850,46 +891,17 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
resultSet.close();
preparedStatement.close();
String freeQty1=String.valueOf(freeQty);
String freeValue1=String.valueOf(freeVaule);
if(noOfRecord <= 0)
{
//Added by saiprasad on 22-Nov-18 for replacement form. [START]
TransIDGenerator idGenerator = new TransIDGenerator("<Root></Root>", userId,getUserInfo().getTransDB());
String transId = idGenerator.generateTranSeqID("S-BAL", "TRAN_ID", "seq10", conn);
StringBuilder schemebalsb = new StringBuilder();
schemebalsb.append("INSERT INTO SCHEME_BALANCE(TRAN_ID,SCHEME_CODE,CUST_CODE,ITEM_CODE,EFF_FROM,VALID_UPTO,BALANCE_FREE_QTY,");
schemebalsb.append("BALANCE_FREE_VALUE,USED_FREE_QTY,USED_FREE_VALUE,CHG_USER,CHG_DATE,CHG_TERM,ENTRY_SOURCE, SITE_CODE)");
schemebalsb.append("VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pstmt = conn.prepareStatement(schemebalsb.toString());
pstmt.setString(1, transId);
pstmt.setString(2, offer);
pstmt.setString(3, custCode1);
pstmt.setString(4, itemCodeRepl);
pstmt.setTimestamp(5, effFrom1);
pstmt.setTimestamp(6, vaildUpto1);
pstmt.setInt(7, freeQty);
pstmt.setInt(8, freeVaule);
pstmt.setString(9, "0");
pstmt.setString(10, "0");
pstmt.setString(11, userId);
pstmt.setTimestamp(12, effFrom1);
pstmt.setString(13, termId);
pstmt.setString(14, "A");
pstmt.setString(15, siteCode1);
updatedCount = pstmt.executeUpdate();
if (updatedCount > 0)
{
conn.commit();
}
else
{
conn.rollback();
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added by saiprasad on 17-JAN-19 for replacement form. [START]
map1=getStockiestData(offer, custCode1, itemCodeRepl, confDateStr, validUpto, freeQty1, freeValue1, "0", "0", userId, confDateStr, termId, "A", siteCode1);
insertDataInSchemeBal(map1);
map2=getStockiestData(offer, custCode2, itemCodeRepl, confDateStr, validUpto, freeQty1, freeValue1, "0", "0", userId, confDateStr, termId, "A", siteCode2);
insertDataInSchemeBal(map2);
//Added by saiprasad on 17-JAN-19 for replacement form. [END]
}
else
{
......@@ -3908,6 +3920,111 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
return xmlInEditMode;
}
public void insertDataInSchemeBal(Map<String,String> map)
{
System.out.println("ChrgBckLocConf.insertDataInSchemeBal() : "+map);
PreparedStatement pStmt=null;
ResultSet rs=null;
Connection conn=null;
int updatedCount;
try
{
conn=getConnection();
String currentDate1=map.get("currentdate");
SimpleDateFormat sdf=new SimpleDateFormat(genericUtility.getDBDateFormat());
Date currentdate1=sdf.parse(currentDate1);
Timestamp currentDateTs = new Timestamp(currentdate1.getTime());
String vaildUpto1=map.get("validUpto");
Date validUptoDate=sdf.parse(vaildUpto1);
Timestamp validUptoTs=new Timestamp(validUptoDate.getTime());
TransIDGenerator idGenerator = new TransIDGenerator("<Root></Root>", userId,getUserInfo().getTransDB());
String transId = idGenerator.generateTranSeqID("S-BAL", "TRAN_ID", "seq10", conn);
StringBuilder schemebalsb = new StringBuilder();
schemebalsb.append("INSERT INTO SCHEME_BALANCE(TRAN_ID,SCHEME_CODE,CUST_CODE,ITEM_CODE,EFF_FROM,VALID_UPTO,BALANCE_FREE_QTY,");
schemebalsb.append("BALANCE_FREE_VALUE,USED_FREE_QTY,USED_FREE_VALUE,CHG_USER,CHG_DATE,CHG_TERM,ENTRY_SOURCE, SITE_CODE)");
schemebalsb.append("VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pStmt = conn.prepareStatement(schemebalsb.toString());
pStmt.setString(1, transId);
System.out.println(">>>>"+map.get("offer"));
pStmt.setString(2, map.get("offer"));
pStmt.setString(3, map.get("custCode"));
pStmt.setString(4, map.get("itemCodeRepl"));
pStmt.setTimestamp(5, currentDateTs);
pStmt.setTimestamp(6, validUptoTs);
pStmt.setString(7, map.get("freeQty"));
pStmt.setString(8, map.get("freeVaule"));
pStmt.setString(9, map.get("balanceFreeValue"));
pStmt.setString(10,map.get("balanceFreeQty"));
pStmt.setString(11, map.get("chgUser"));
pStmt.setTimestamp(12, currentDateTs);
pStmt.setString(13, map.get("ChgTerm"));
pStmt.setString(14, map.get("entrySource"));
pStmt.setString(15, map.get("siteCode"));
updatedCount = pStmt.executeUpdate();
if(pStmt!=null)
{
pStmt.close();
pStmt = null;
}
System.out.println("updated row:"+updatedCount);
if (updatedCount > 0)
{
conn.commit();
}
else
{
conn.rollback();
}
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
try
{
if(conn!=null)
{
conn.close();
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
public Map<String,String> getStockiestData(String offer,String custCode1,String itemCodeRepl,String currentDate,String validUpto,String freeQty,String freeVaule,String balanceFreeValue,String balanceFreeQty,String userId,String currDate,String termId,String entrySource,String siteCode)
{
HashMap<String,String> map=new HashMap<>();
map.put("offer", offer);
map.put("custCode", custCode1);
map.put("itemCodeRepl",itemCodeRepl);
map.put("currentdate", currentDate);
map.put("validUpto", validUpto);
map.put("freeQty", freeQty);
map.put("freeVaule", freeVaule);
map.put("balanceFreeValue", balanceFreeValue);
map.put("balanceFreeQty", balanceFreeQty);
map.put("chgUser", userId);
map.put("currDate", currDate);
map.put("ChgTerm", termId);
map.put("entrySource",entrySource);
map.put("siteCode",siteCode);
return map;
}
}
\ 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