Commit 248b6bf8 authored by prahate's avatar prahate

When we confirm the charge back entry then records is inserted into scheme...

When we confirm the charge back entry then records is inserted into scheme balance master. At this time if same scheme name available in scheme balance then only free value  and free quantity, end period need to be updated.  

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194960 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 07652a98
......@@ -2252,15 +2252,15 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
settleMethod = E12GenericUtility.checkNull(genericUtility.getColumnValue("settle_mth", dom2, "1"));
System.out.println("settleMethod : "+settleMethod);
if(settleMethod.equalsIgnoreCase("V")|| settleMethod.equalsIgnoreCase("C"))
{
{
valueXmlString.append("<item_code__repl protect =\"1\"><![CDATA[").append(dummy).append("]]></item_code__repl>");
valueXmlString.append("<item_repl_descr protect =\"1\"><![CDATA[").append(dummy).append("]]></item_repl_descr>");
valueXmlString.append("<free_qty protect =\"1\"><![CDATA[").append(dummy).append("]]></free_qty>");
valueXmlString.append("<free_qty protect =\"1\"><![CDATA[").append(0).append("]]></free_qty>");
valueXmlString.append("<free_item_group protect =\"1\"><![CDATA[").append(dummy).append("]]></free_item_group>");
}
else if(settleMethod.equalsIgnoreCase("Q"))
{
valueXmlString.append("<free_value protect =\"1\"><![CDATA[").append(dummy).append("]]></free_value>");
valueXmlString.append("<free_value protect =\"1\"><![CDATA[").append(0).append("]]></free_value>");
}
}
if (currentColumn.trim().equals("itm_defaultedit"))
......@@ -2268,15 +2268,15 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
settleMethod = E12GenericUtility.checkNull(genericUtility.getColumnValue("settle_mth", dom2, "1"));
System.out.println("settleMethod : "+settleMethod);
if(settleMethod.equalsIgnoreCase("V")|| settleMethod.equalsIgnoreCase("C"))
{
{
valueXmlString.append("<item_code__repl protect =\"1\"><![CDATA[").append(dummy).append("]]></item_code__repl>");
valueXmlString.append("<item_repl_descr protect =\"1\"><![CDATA[").append(dummy).append("]]></item_repl_descr>");
valueXmlString.append("<free_qty protect =\"1\"><![CDATA[").append(dummy).append("]]></free_qty>");
valueXmlString.append("<free_qty protect =\"1\"><![CDATA[").append(0).append("]]></free_qty>");
valueXmlString.append("<free_item_group protect =\"1\"><![CDATA[").append(dummy).append("]]></free_item_group>");
}
else if(settleMethod.equalsIgnoreCase("Q"))
{
valueXmlString.append("<free_value protect =\"1\"><![CDATA[").append(dummy).append("]]></free_value>");
valueXmlString.append("<free_value protect =\"1\"><![CDATA[").append(0).append("]]></free_value>");
}
}
else if (currentColumn.trim().equals("item_code"))
......
......@@ -137,8 +137,9 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
ArrayList<String> valueStringList=new ArrayList<String>();
int countError = 0;
String chargeBakSql = "", secondarySchSql = "", schemeBalSql = "",drcrRcpSql="";
String custCode1 = "", itemCodeRepl = "", freeQty = "", freeVaule = "", confDateStr = "", settleMethod = "",
String custCode1 = "", itemCodeRepl = "", confDateStr = "", settleMethod = "", siteCode1 = "",
offer = "", vaildUpto = "";
int freeQty = 0, freeVaule = 0;
try
{
//Changes and Commented By Bhushan on 09-06-2016 :START
......@@ -775,8 +776,7 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
// For the charge_back
int updatedCount = 0;
System.out.println("tranId::[" + tranID + "]");
chargeBakSql = "SELECT CUST_CODE, SETTLE_MTH FROM CHARGE_BACK WHERE TRAN_ID=?";
System.out.println(chargeBakSql);
chargeBakSql = "SELECT CUST_CODE, SETTLE_MTH, SITE_CODE FROM CHARGE_BACK WHERE TRAN_ID=?";
PreparedStatement preparedStatement = null, preparedStatement1 = null;
ResultSet resultSet = null;
preparedStatement = conn.prepareStatement(chargeBakSql);
......@@ -784,9 +784,8 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
custCode1 = resultSet.getString("CUST_CODE");
System.out.println("customer code1::[" + custCode1 + "]");
settleMethod = resultSet.getString("SETTLE_MTH");
System.out.println("Settle method1::[" + settleMethod + "]");
siteCode1 = resultSet.getString("SITE_CODE");
}
if(resultSet != null)
{
......@@ -801,37 +800,24 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
// For the charge_back_repl
secondarySchSql = "SELECT ITEM_CODE__REPL,FREE_QTY,FREE_VALUE,OFFER FROM CHARGE_BACK_REPL WHERE TRAN_ID=?";
System.out.println(secondarySchSql);
preparedStatement1 = conn.prepareStatement(secondarySchSql);
preparedStatement1.setString(1, tranID);
rs = preparedStatement1.executeQuery();
while (rs.next())
{
itemCodeRepl = E12GenericUtility.checkNull(rs.getString("ITEM_CODE__REPL"));
System.out.println("item code replacement::[" + itemCodeRepl + "]");
freeQty = rs.getString("FREE_QTY");
System.out.println("free qty::[" + freeQty + "]");
freeVaule = rs.getString("FREE_VALUE");
System.out.println("free value::[" + freeVaule + "]");
freeQty = rs.getInt("FREE_QTY");
freeVaule = rs.getInt("FREE_VALUE");
offer = E12GenericUtility.checkNull(rs.getString("OFFER"));
System.out.println("offer::[" + offer + "]");
TransIDGenerator idGenerator = new TransIDGenerator("<Root></Root>", userId,getUserInfo().getTransDB());
String transId = idGenerator.generateTranSeqID("S-BAL", "TRAN_ID", "seq10", conn);
System.out.println("Tran Id for the scheme_balance::[" + transId + "]");
System.out.println("scheme code for the scheme_balance::" + offer + "]");
if (offer.length() <= 0)
{
offer = "DEFAULT";
}
System.out.println("scheme code for the scheme_balance::" + offer + "]");
System.out.println("Cust_code for the scheme_balance::[" + custCode1 + "]");
if (settleMethod.equalsIgnoreCase("V"))
{
itemCodeRepl = "X";
System.out.println("itemcode replacement in case of v:" + itemCodeRepl);
}
System.out.println("Item_code_repl for the scheme_balance::[" + itemCodeRepl + "]");
// effective from
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
Date confDate = new Date();
......@@ -839,66 +825,108 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
Timestamp effFrom1 = new Timestamp(confDate.getTime());
System.out.println("eff from is :" + effFrom1 + " confDate str is : " + confDateStr);
System.out.println("sdf1:" + sdf1);
Calendar calObj1 = Calendar.getInstance();
calObj1.setTime(new java.util.Date());
calObj1.add(Calendar.YEAR, 2);
java.util.Date dateFrom = calObj1.getTime();
System.out.println("date form:" + dateFrom);
Timestamp vaildUpto1 = new Timestamp(dateFrom.getTime());
System.out.println("vaild upto1:" + vaildUpto1);
System.out.println("vaild upto for the scheme balance::[" + vaildUpto1 + "]");
System.out.println("free_qty for the scheme_balance::[" + freeQty + "]");
System.out.println("free_value for the scheme_balance::[" + freeVaule + "]");
System.out.println("chg user for the scheme_balance::[" + userId + "]");
System.out.println("chg date for the scheme_balance::[" + confDateStr + "]");
System.out.println("chg term for the scheme_balance::[" + termId + "]");
// insert into scheme balance
System.out.println("settle method2::[" + settleMethod + "]");
if (settleMethod.equalsIgnoreCase("V") || settleMethod.equalsIgnoreCase("Q"))
{
//Added by saiprasad on 22-Nov-18 for replacement form. [START]
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)");
schemebalsb.append("VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
System.out.println("scheme balance query:" + schemebalsb.toString());
pstmt = conn.prepareStatement(schemebalsb.toString());
System.out.println("after prepareStatement");
pstmt.setString(1, transId);
pstmt.setString(2, offer);
pstmt.setString(3, custCode1);
pstmt.setString(4, itemCodeRepl);
System.out.println("For todays date" + effFrom1);
pstmt.setTimestamp(5, effFrom1);
System.out.println("for 2 years date:" + effFrom1);
pstmt.setTimestamp(6, vaildUpto1);
System.out.println("after inserted date of the 2 years later:" + vaildUpto1);
pstmt.setString(7, freeQty);
pstmt.setString(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");
updatedCount = pstmt.executeUpdate();
System.out.println("Data inserted:..." + updatedCount);
if (updatedCount > 0)
int noOfRecord = 0;
String recordExistSql = "SELECT COUNT(1) FROM SCHEME_BALANCE WHERE CUST_CODE = ? AND ITEM_CODE = ? AND SITE_CODE = ?";
preparedStatement = conn.prepareStatement(recordExistSql);
preparedStatement.setString(1, custCode1);
preparedStatement.setString(2, itemCodeRepl);
preparedStatement.setString(3, siteCode1);
resultSet = preparedStatement.executeQuery();
if(resultSet.next())
{
conn.commit();
}
else
noOfRecord = resultSet.getInt(1);
}
resultSet.close();
preparedStatement.close();
if(noOfRecord <= 0)
{
conn.rollback();
//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;
}
}
if(pstmt != null)
else
{
pstmt.close();
pstmt = null;
int freeBalQty = 0, freeBalVal = 0;
String getBalanceItem = "SELECT BALANCE_FREE_QTY, BALANCE_FREE_VALUE from SCHEME_BALANCE WHERE CUST_CODE = ? AND ITEM_CODE = ? AND SCHEME_CODE = ?";
preparedStatement = conn.prepareStatement(getBalanceItem);
preparedStatement.setString(1, custCode1);
preparedStatement.setString(2, itemCodeRepl);
preparedStatement.setString(3, offer);
resultSet = preparedStatement.executeQuery();
if(resultSet.next())
{
freeBalQty = resultSet.getInt("BALANCE_FREE_QTY");
freeBalVal = resultSet.getInt("BALANCE_FREE_VALUE");
}
resultSet.close();
preparedStatement.close();
freeBalQty = freeBalQty + freeQty;
freeBalVal = freeBalVal + freeVaule;
String updateScheme = "UPDATE SCHEME_BALANCE SET EFF_FROM = ?, VALID_UPTO = ?, BALANCE_FREE_QTY = ?, BALANCE_FREE_VALUE = ? WHERE CUST_CODE = ? "
+ "AND ITEM_CODE = ? AND SCHEME_CODE = ? ";
PreparedStatement pStmt = conn.prepareStatement(updateScheme);
pStmt.setTimestamp(1, effFrom1);
pStmt.setTimestamp(2, vaildUpto1);
pStmt.setInt(3, freeBalQty);
pStmt.setInt(4, freeBalVal);
pStmt.setString(5, custCode1);
pStmt.setString(6, itemCodeRepl);
pStmt.setString(7, offer);
int updatedCnt = pStmt.executeUpdate();
System.out.println(">>>>> updatedCnt : "+updatedCnt);
pStmt.close();
if(updatedCnt > 1)
{
conn.commit();
}
}
}
}
......@@ -912,18 +940,13 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
preparedStatement1.close();
preparedStatement1 = null;
}
//Added by Saiprasad G. END
returnString = itmDBAccessEJB.getErrorString("","TRANCONFSC",userId);
}
else
{
returnString = itmDBAccessEJB.getErrorString("","VTTRNCNFM2",userId,"",conn);
}
}
else
{
......
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