Commit e6cebb3f authored by prahate's avatar prahate

Changes done for Charge back replacement.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@193280 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3649d6ce
......@@ -22,6 +22,7 @@ import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
......@@ -135,12 +136,16 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
String valueString="";
ArrayList<String> valueStringList=new ArrayList<String>();
int countError = 0;
//Added by saiprasad on 22-Nov-18 for replacement form. [START]
StringBuilder schemebalsb = new StringBuilder();
String chargeBakSql = "", secondarySchSql = "", schemeBalSql = "",drcrRcpSql="";
String custCode1 = "", itemCodeRepl = "", freeQty = "", freeVaule = "", confDateStr = "", settleMethod = "",
offer = "", vaildUpto = "";
try
{
//Changes and Commented By Bhushan on 09-06-2016 :START
conn = connDriver.getConnectDB("DriverITM");
//conn = getConnection();
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); //Added by saiprasad on 22-Nov-18 for replacement form.
//Changes and Commented By Bhushan on 09-06-2016 :END
conn.setAutoCommit(false);
connDriver = null;
......@@ -680,6 +685,7 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
System.out.println("MDRDIdList["+MDRDIdList+"]");
System.out.println("CRNIdList["+CRNIdList+"]");
System.out.println("DRNIdList["+DRNIdList+"]");
System.out.println("isError : ["+isError+"]");
if(!isError)
{
generatedId="";
......@@ -765,6 +771,133 @@ public class ChrgBckLocConf extends ActionHandlerEJB implements ChrgBckLocConfLo
//}
}
// Added by saiprasad G.START [When the settlement method is "value replacement"
// & "quantity replacement" in charge back then data inserted into scheme
// balance table]
// For the charge_back
System.out.println("tranId::[" + tranID + "]");
chargeBakSql = "SELECT CUST_CODE, SETTLE_MTH FROM CHARGE_BACK WHERE TRAN_ID=?";
System.out.println(chargeBakSql);
pstmt = conn.prepareStatement(chargeBakSql);
pstmt.setString(1, tranID);
rs = pstmt.executeQuery();
if (rs.next()) {
custCode1 = rs.getString("CUST_CODE");
System.out.println("customer code1::[" + custCode1 + "]");
settleMethod = rs.getString("SETTLE_MTH");
System.out.println("Settle method1::[" + settleMethod + "]");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// 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);
pstmt = conn.prepareStatement(secondarySchSql);
pstmt.setString(1, tranID);
rs = pstmt.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 + "]");
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();
confDateStr = sdf1.format(confDate);
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"))
{
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");
int i = pstmt.executeUpdate();
System.out.println("Data inserted:" + i);
if (i > 0)
{
conn.commit();
}
else
{
conn.rollback();
}
pstmt.close();
pstmt = null;
}
else if(settleMethod.equalsIgnoreCase("C"))
{
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//Added by Saiprasad G. END
returnString = itmDBAccessEJB.getErrorString("","TRANCONFSC",userId,"",conn);
......
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