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
......@@ -80,7 +80,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
String errCode = null;
String userId = null;
String custCode = null;
String itemCode = "";
String itemCode = "",itemCode1="";
String empCode = "";
String quantity = "";
String saleQty = "";
......@@ -105,7 +105,8 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
java.sql.Timestamp tranDateTs = null, tempTst = null,frDate=null,toDate=null;
Date bllDate = null;
String blDate="";
String freeQty="",freeValue=""; //Added by saiprasad on 22-Nov-18
System.out.println("IN VALIDATION wfValData()");
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
......@@ -707,6 +708,105 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
}
}// END FOR OF CASE2
break;
//Added by saiprasad on 22-Nov-18 for replacement form.
case 3:
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
System.out.println("child Node in third form:"+childNode);
childNodeName = childNode.getNodeName();
System.out.println("childnodename in 3 rd vaildation:"+childNodeName);
if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCode1= E12GenericUtility.checkNull(genericUtility.getColumnValue("item_code", dom));
System.out.println("Item code1 in vaildation:"+itemCode1);
if(E12GenericUtility.checkNull(itemCode1).length()<=0)
{
errCode = "VTITMNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
String str = "select count(1) from item where item_code = ?";
System.out.println("sql str"+str);
int count = 0;
pstmt = conn.prepareStatement(str);
pstmt.setString(1, itemCode1);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
System.out.println("count : "+count);
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(count == 0)
{
errCode = "VTINVITM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
String settleMethod=E12GenericUtility.checkNull(genericUtility.getColumnValue("settle_mth", dom2,"1"));
String itemCodeFormTwo=genericUtility.getColumnValue("item_code", dom2, "2");
System.out.println("item code of the second form:"+itemCodeFormTwo);
System.out.println("settmethod for vaildation"+settleMethod);
if(settleMethod.equalsIgnoreCase("V"))
{
freeValue=E12GenericUtility.checkNull(genericUtility.getColumnValue("free_value", dom));
if(E12GenericUtility.checkNull(freeValue).length()<=0)
{
errCode = "VTFREEVAl";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else if(itemCodeFormTwo!=null)
{
System.out.println("settlemethod in third form:"+settleMethod);
errList.add("VMNVSECOND");
errFields.add(childNodeName.toLowerCase());
}
}
else if(settleMethod.equalsIgnoreCase("Q"))
{
freeQty=E12GenericUtility.checkNull(genericUtility.getColumnValue("free_qty", dom));
if(E12GenericUtility.checkNull(freeQty).length()<=0)
{
errCode = "VTNFREEQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else if(itemCodeFormTwo!=null)
{
System.out.println("settlemethod in third form:"+settleMethod);
errList.add("VMNVSECOND");
errFields.add(childNodeName.toLowerCase());
}
}
/* if(settleMethod.equalsIgnoreCase("V") || settleMethod.equalsIgnoreCase("Q"))
{
}*/
if(settleMethod.equalsIgnoreCase("C"))
{
System.out.println("settle method in third form for the credit note:"+settleMethod);
errList.add("VMINVTHIRD");
errFields.add(childNodeName.toLowerCase());
}
}// End of for loop CASE3
break;
//Added by saiprasad on 22-Nov-18 for replacement form. [END]
}// END SWITCH
int errListSize = errList.size();
cnt = 0;
......@@ -876,7 +976,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
int childNodeListLength = 0;
int ctr = 0;
int cnt = 0;
String itemCode = "";
String itemCode = "",itemCode1=""; //Added by saiprasad on 22-Nov-18 for replacement form.
String siteCode = "";
String lotNo = "";
String rateSell = "";
......@@ -1449,7 +1549,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
//valueXmlString.append("</Root>"); //Added by saiprasad on 22-Nov-18 for replacement form.
break;
// /////////////
case 2:
......@@ -1839,40 +1939,160 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
}
valueXmlString.append("</Detail2>");
valueXmlString.append("</Root>");
// //////////////
//Added by saiprasad on 22-Nov-18 for replacement form. [START]
// valueXmlString.append("</Root>");
break;
case 3:
valueXmlString.append("<Detail3>");
System.out.println("In the third form itemchange");
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName:" + childNodeName);
if (childNodeName.equals(currentColumn)) {
if (childNode.getFirstChild() != null) {
columnValue = childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
} while (ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
String itemDescr1 = "",itemDescr2="",settleMethod="",dummy="",freeGroup="",itemCodeRepl="";
Double netAmt=0.0;
if (currentColumn.trim().equals("itm_default"))
{
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_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>");
}
}
if (currentColumn.trim().equals("itm_defaultedit"))
{
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_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>");
}
}
else if (currentColumn.trim().equals("item_code"))
{
itemCode1 = E12GenericUtility.checkNull(genericUtility.getColumnValue("item_code", dom));
System.out.println("item code1:" + itemCode1);
sql = "select descr from item where item_code=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, itemCode1);
rs = pStmt.executeQuery();
if (rs.next())
{
itemDescr1 = rs.getString("descr");
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
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>");
valueXmlString.append("<item_code__repl><![CDATA[").append(itemCode1).append("]]></item_code__repl>");
valueXmlString.append("<item_repl_descr><![CDATA[").append(itemDescr1).append("]]></item_repl_descr>");
}
else if(settleMethod.equalsIgnoreCase("V") || settleMethod.equalsIgnoreCase("C"))
{
valueXmlString.append("<item_descr><![CDATA[").append(itemDescr1).append("]]></item_descr>");
valueXmlString.append("<item_code__repl><![CDATA[").append(dummy).append("]]></item_code__repl>");
valueXmlString.append("<item_repl_descr><![CDATA[").append(dummy).append("]]></item_repl_descr>");
}
}
else if (currentColumn.trim().equals("rate") || currentColumn.trim().equals("quantity"))
{
String rate1 = genericUtility.getColumnValue("rate", dom);
double rateT = Double.parseDouble(rate1);
System.out.println("Rate of the third form:" + rate1);
String qty = genericUtility.getColumnValue("quantity", dom);
System.out.println("quantity of the third form:" + qty);
int qty1 = Integer.parseInt(qty);
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));
System.out.println("item code1:" + itemCodeRepl);
sql = "select descr from item where item_code=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, itemCodeRepl);
rs = pStmt.executeQuery();
if (rs.next()) {
itemDescr2 = rs.getString("descr");
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
System.out.println("item descr2:" + itemDescr2);
valueXmlString.append("<item_repl_descr><![CDATA[").append(itemDescr2).append("]]></item_repl_descr>");
}
else if (currentColumn.trim().equals("free_item_group"))
{
valueXmlString.append("<item_code__repl><![CDATA[").append(dummy).append("]]></item_code__repl>");
valueXmlString.append("<item_repl_descr><![CDATA[").append(dummy).append("]]></item_repl_descr>");
}
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
{
try
{
if (rs != null)
{
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null)
{
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
if (conn != null)
{
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e)
{
} catch (Exception e) {
System.out.println("Exception ::" + e);
e.printStackTrace();
throw new ITMException(e);
}
}
valueXmlString.append("</Root>");
System.out.println("valueXmlString : " + valueXmlString);
//Added by saiprasad on 22-Nov-18 for replacement form. [END]
return valueXmlString.toString();
}// END OF ITEMCHANGE
......
......@@ -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;
try
//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,8 +771,135 @@ 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);
returnString = itmDBAccessEJB.getErrorString("","TRANCONFSC",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