Commit 671f7793 authored by Ajit Deshmukh's avatar Ajit Deshmukh

Resolved the issues reported regarding the Value field item change and

validation for competitors details.
parent 305fea3a
package ibase.webitm.ejb.dis;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.BaseException;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.utility.GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class ReqForQuotationIC extends ValidatorEJB {
E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag,
String xtraParams) throws RemoteException, ITMException {
BaseLogger.log("3", getUserInfo(), null,
">>>>>>>>>>>>>>>>>>ReqForQuotationIC validation called>>>>>>>>>>>>>>>>>>>:::");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
BaseLogger.log("3", null, null, "xmlString ReqForQuotationIC [" + xmlString + "]");
BaseLogger.log("3", null, null, "xmlString1 ReqForQuotationIC [" + xmlString1 + "]");
BaseLogger.log("3", null, null, "xmlString2 ReqForQuotationIC [" + xmlString2 + "]");
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
BaseLogger.log("3", null, null, "ErrString: " + errString);
} catch (Exception e) {
System.out.println("Exception: ReqForQuotationIC: wfValData(String xmlString): " + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
}
BaseLogger.log("3", null, null, "Returning from ReqForQuotationIC wfValData");
return (errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag,
String xtraParams) throws RemoteException, ITMException {
BaseLogger.log("3", getUserInfo(), null, "9>>>>>>>>>>>>>>>>>>ReqForQuotationIC validation called >>>>>>>>>>>>>>>>>>>");
BaseLogger.log("3", null, null, "Inside ReqForQuotationIC validation");
GenericUtility genericUtility = GenericUtility.getInstance();
try {
BaseLogger.log("3", getUserInfo(), null, "dom case2*>>>> Elements>>["+genericUtility.serializeDom(dom).toString()+"]");//added for testing
BaseLogger.log("3", getUserInfo(), null, "dom2 case2*>>>> Elements>>["+genericUtility.serializeDom(dom2).toString()+"]");//added for testing
BaseLogger.log("3", getUserInfo(), null, "dom1 case2*>>>> Elements>>["+genericUtility.serializeDom(dom1).toString()+"]");
} catch (BaseException e1) {
e1.printStackTrace();
}
String userId = "";
String requestId = "";
String sql="";
String errString = "";
Connection connection = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
int noOfChilds = 0;
int currentFormNo = 0;
try
{
SimpleDateFormat DOB = new SimpleDateFormat(getApplDateFormat());
connection = getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch ( currentFormNo )
{
case 1:
{
parentList = dom.getElementsByTagName("Detail"+ currentFormNo);
int parentNodeListLength = parentList.getLength();
System.out.println("parentNodeListLength["+parentNodeListLength+"]");
for (int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++ )
{
parentNode = parentList.item(prntCtr);
System.out.println("value of parentNode"+parentNode);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
System.out.println("value of noOfChilds"+noOfChilds);
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
System.out.println("childNode"+childNode);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
childNodeName = childNode.getNodeName();
if( childNodeName.equalsIgnoreCase("cust_code") )
{
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC custCode wfValData case 1 [" + custCode + "]");
String checkCustCodeSql = "select count(cust_code) as custCodeCount from customer where cust_code = ? and cust_type = 'R'";
PreparedStatement checkCustCodePs = connection.prepareStatement(checkCustCodeSql);
checkCustCodePs.setString(1, custCode);
ResultSet checkCustCodeRs = checkCustCodePs.executeQuery();
while(checkCustCodeRs.next()) {
int custCodeCont = checkCustCodeRs.getInt("custCodeCount");
BaseLogger.log("3", null, null, "ReqForQuotationIC custCode wfValData case 1 custCodeCont::[" + custCodeCont + "]");
if(custCodeCont<=0) {
errString = getErrorString("cust_code", "VTCUST1", userId);
break;
}
}
if(checkCustCodeRs != null)
{
checkCustCodeRs.close();
checkCustCodeRs = null;
}
if(checkCustCodePs != null)
{
checkCustCodePs.close();
checkCustCodePs = null;
}
}
if( childNodeName.equalsIgnoreCase("quot_type") )
{
String customerCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
String quotationtype = checkNull(genericUtility.getColumnValue("quot_type", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC quotationtype wfValData case 1 [" + quotationtype + "]");
if (quotationtype.equalsIgnoreCase("G"))
{
// String groupCode = "select group_code from customer where cust_code= ?";
// PreparedStatement quotationcodePs = connection.prepareStatement(groupCode);
// quotationcodePs.setString(1, quotationcode);
// ResultSet quotationcodeRs = quotationcodePs.executeQuery();
String quotationtypeSql = "select count(group_code) as customergroupcount from customer where group_code= ?";
PreparedStatement quotationtypePs = connection.prepareStatement(quotationtypeSql);
quotationtypePs.setString(1, customerCode);
ResultSet quotationtypeRs = quotationtypePs.executeQuery();
while(quotationtypeRs.next())
{
int customergroupcount = quotationtypeRs.getInt("customergroupcount");
BaseLogger.log("3", null, null, "ReqForQuotationIC group_count wfValData case 1 quotationtypeRs::[" + customergroupcount + "]");
if(customergroupcount<=1)
{
errString = getErrorString("cust_code", "INVCG", userId);
break;
}
}
if(quotationtypeRs != null)
{
quotationtypeRs.close();
quotationtypeRs = null;
}
if(quotationtypePs != null)
{
quotationtypePs.close();
quotationtypePs = null;
}
}
}
if( childNodeName.equalsIgnoreCase("sales_pers") )
{
String salesPerson = checkNull(genericUtility.getColumnValue("sales_pers", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC salesPerson wfValData case 1 [" + salesPerson + "]");
String salesPersonSql = "select count(SALES_PERS) as salesPersonCount from SALES_PERS where SALES_PERS = ?";
PreparedStatement salesPersonPs = connection.prepareStatement(salesPersonSql);
salesPersonPs.setString(1, salesPerson);
ResultSet salesPersonRs = salesPersonPs.executeQuery();
while(salesPersonRs.next()) {
int salesPersonCount = salesPersonRs.getInt("salesPersonCount");
BaseLogger.log("3", null, null, "ReqForQuotationIC sales_pers wfValData case 1 salesPersonRs::[" + salesPersonCount + "]");
if(salesPersonCount<=0) {
errString = getErrorString("sales_pers", "VTSALPER", userId);
break;
}
}
if(salesPersonRs != null)
{
salesPersonRs.close();
salesPersonRs = null;
}
if(salesPersonPs != null)
{
salesPersonPs.close();
salesPersonPs = null;
}
}
if( childNodeName.equalsIgnoreCase("valid_upto") )
{
String validUptoStr = checkNull(genericUtility.getColumnValue("valid_upto", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC validUptoStr wfValData case 1 [" + validUptoStr + "]");
if(isDateInvalid(validUptoStr))
{
errString = getErrorString("valid_upto", "VTINUPTO", userId);
break;
}
}
if( childNodeName.equalsIgnoreCase("site_code") )
{
String siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC siteCode wfValData case 1 [" + siteCode + "]");
String checkSiteCodeSql = "select count(site_code) as siteCodeCount from site where site_code = ?";
PreparedStatement checkSiteCodePs = connection.prepareStatement(checkSiteCodeSql);
checkSiteCodePs.setString(1, siteCode);
ResultSet checkSiteCodeRs = checkSiteCodePs.executeQuery();
while(checkSiteCodeRs.next()) {
int siteCodeCont = checkSiteCodeRs.getInt("siteCodeCount");
BaseLogger.log("3", null, null, "ReqForQuotationIC siteCode wfValData case 1 siteCodeCont::[" + siteCodeCont + "]");
if(siteCodeCont<=0) {
errString = getErrorString("site_code", "VTSITCD1", userId);
break;
}
}
if(checkSiteCodeRs != null)
{
checkSiteCodeRs.close();
checkSiteCodeRs = null;
}
if(checkSiteCodePs != null)
{
checkSiteCodePs.close();
checkSiteCodePs = null;
}
}
if( childNodeName.equalsIgnoreCase("item_ser") )
{
String itemSerStr = checkNull(genericUtility.getColumnValue("item_ser", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC itemSerStr wfValData case 1 [" + itemSerStr + "]");
if (itemSerStr != null && itemSerStr.length() > 0) {
String[] itemSerArr = itemSerStr.split(",");
for (String itemSer : itemSerArr) {
BaseLogger.log("3", null, null, "ReqForQuotationIC item_ser wfValData case 1 itemSer [" + itemSer + "]");
sql = "SELECT count(1) FROM itemser WHERE item_ser = ?";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, itemSer.trim());
rs = pstmt.executeQuery();
long count = 0;
if (rs.next()) {
count = rs.getLong(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (count == 0) {
errString = getErrorString("item_ser", "VTITEMSER1", userId);
break;
}
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
}
}
break;
}
case 2:
{
parentList = dom.getElementsByTagName("Detail"+ currentFormNo);
int parentNodeListLength = parentList.getLength();
System.out.println("parentNodeListLength["+parentNodeListLength+"]");
for (int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++ )
{
parentNode = parentList.item(prntCtr);
System.out.println("value of parentNode"+parentNode);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
System.out.println("value of noOfChilds"+noOfChilds);
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
System.out.println("childNode"+childNode);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
childNodeName = childNode.getNodeName();
if( childNodeName.equalsIgnoreCase("item_code") )
{
String[] itemSerArr = null;
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom1));
BaseLogger.log("3", null, null, "ReqForQuotationIC itemCode wfValData case 1 itemSer:[" + itemSer + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC itemCode wfValData case 1 [" + itemCode + "]");
if(itemSer != null && itemSer.trim().length() > 0)
{
itemSerArr = itemSer.split(",");
}
StringBuilder checkItemCodeSql = new StringBuilder(
"select count(item_code) as itemCodeCount from item where item_code = ?"
);
if(itemSerArr != null && itemSerArr.length > 0) {
checkItemCodeSql.append(" and item_ser IN (");
for(int i = 0; i < itemSerArr.length; i++) {
checkItemCodeSql.append("?");
if(i < itemSerArr.length - 1) {
checkItemCodeSql.append(",");
}
}
checkItemCodeSql.append(")");
}
String checkItemCodeSql1 = checkItemCodeSql.toString();
PreparedStatement checkItemCodePs = connection.prepareStatement(checkItemCodeSql1);
// 🔹 Set first parameter (item_code)
int paramIndex = 1;
checkItemCodePs.setString(paramIndex++, itemCode);
// 🔹 Set IN clause parameters (item_ser)
if(itemSerArr != null && itemSerArr.length > 0) {
for(String ser : itemSerArr) {
checkItemCodePs.setString(paramIndex++, ser.trim());
}
}
ResultSet checkItemCodeRs = checkItemCodePs.executeQuery();
while(checkItemCodeRs.next()) {
int itemCodeCont = checkItemCodeRs.getInt("itemCodeCount");
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 1 itemCodeCont::[" + itemCodeCont + "]");
if(itemCodeCont<=0) {
errString = getErrorString("item_code", "STKVALITNE", userId);
break;
}
}
if(checkItemCodeRs != null)
{
checkItemCodeRs.close();
checkItemCodeRs = null;
}
if(checkItemCodePs != null)
{
checkItemCodePs.close();
checkItemCodePs = null;
}
}
if( childNodeName.equalsIgnoreCase("ptr_flag") )
{
String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
String rateQuot = checkNull(genericUtility.getColumnValue("rate_quot", dom));
String competitorRate = checkNull(genericUtility.getColumnValue("competitor_rate", dom));
String competitorItem = checkNull(genericUtility.getColumnValue("competitor_item", dom));
String competitorName = checkNull(genericUtility.getColumnValue("competitor_name", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC ptrFlag wfValData [" + ptrFlag + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC rateQuot wfValData [" + rateQuot + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC competitorRate wfValData [" + competitorRate + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC competitorItem wfValData [" + competitorItem + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC competitorNane wfValData [" + competitorName + "]");
if (ptrFlag.equalsIgnoreCase("N") || ptrFlag.trim().isEmpty()) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition ptrFlag wfValData::: [" + ptrFlag + "]");
if(rateQuot==null || rateQuot.trim().length()<=0) {
errString = getErrorString("rate_quot", "INVQR", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in competitor details null errString:: [" + errString + "]");
break;
}
// Check if any of the competitor fields are null or blank
if ((competitorRate == null || competitorRate.trim().isEmpty())
|| (competitorItem == null || competitorItem.trim().isEmpty())
|| (competitorName == null || competitorName.trim().isEmpty())) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in competitor details null [" + ptrFlag + "]");
errString = getErrorString("ptr_flag", "COMPDETM", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in competitor details null errString:: [" + errString + "]");
break;
}
}
}
if( childNodeName.equalsIgnoreCase("rate_quot") )
{
String phyAttrVal = "";
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String quotedRate = checkNull(genericUtility.getColumnValue("rate_quot", dom));
int quotedRateInt = 0;
if(quotedRate!=null && quotedRate.trim().length()>0) {
double quotedRateDouble = Double.parseDouble(quotedRate);
quotedRateInt = (int) quotedRateDouble;
// quotedRateInt = Integer.parseInt(quotedRate);
if(quotedRateInt<=0) {
errString = getErrorString("rate_quot", "INVQR", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in PHY_ATTRIB_19 details null errString:: [" + errString + "]");
break;
}
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition itemCode wfValData quotedRate::: [" + quotedRate + "]");
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition itemCode wfValData itemCode::: [" + itemCode + "]");
String phyAttrValSql = "select PHY_ATTRIB_19 from item where item_code = ?";
PreparedStatement phyAttrValPs = connection.prepareStatement(phyAttrValSql);
phyAttrValPs.setString(1, itemCode);
ResultSet phyAttrValRs = phyAttrValPs.executeQuery();
while(phyAttrValRs.next()) {
phyAttrVal = checkNull(phyAttrValRs.getString("PHY_ATTRIB_19"));
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition itemCode wfValData phyAttrVal::: [" + phyAttrVal + "]");
if(phyAttrVal.equalsIgnoreCase("SRNA")) {
errString = getErrorString("rate_quot", "INEFSR", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in PHY_ATTRIB_19 details null errString:: [" + errString + "]");
break;
}
if(phyAttrValPs != null)
{
phyAttrValPs.close();
phyAttrValPs = null;
}
if(phyAttrValRs != null)
{
phyAttrValRs.close();
phyAttrValRs = null;
}
}
//Added changes on 25-March-26 by Ajit [Start]
if( childNodeName.equalsIgnoreCase("unit") )
{
int unitCount = 0;
String unit = checkNull(genericUtility.getColumnValue("unit", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition unit wfValData unit::: [" + unit + "]");
String unitCountSql = "select count(unit) as unitCount from uom where unit = ?";
PreparedStatement unitCountPs = connection.prepareStatement(unitCountSql);
unitCountPs.setString(1, unit);
ResultSet unitCountRs = unitCountPs.executeQuery();
while(unitCountRs.next()) {
unitCount = unitCountRs.getInt("unitCount");
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition unitCount::: [" + unitCount + "]");
if(unitCount <= 0) {
errString = getErrorString("unit", "VTITEMUNIT", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in UNIT not present in master errString:: [" + errString + "]");
break;
}
if(unitCountPs != null)
{
unitCountPs.close();
unitCountPs = null;
}
if(unitCountRs != null)
{
unitCountRs.close();
unitCountRs = null;
}
}
if( childNodeName.equalsIgnoreCase("pack_code") )
{
int packCodeCount = 0;
String packCode = checkNull(genericUtility.getColumnValue("pack_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition unit wfValData packCode::: [" + packCode + "]");
String packCodeCountSql = "select count(pack_code) as packCodeCount from packing where pack_code = ?";
PreparedStatement packCodeCountPs = connection.prepareStatement(packCodeCountSql);
packCodeCountPs.setString(1, packCode);
ResultSet packCodeCountRs = packCodeCountPs.executeQuery();
while(packCodeCountRs.next()) {
packCodeCount = packCodeCountRs.getInt("packCodeCount");
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition unitCount::: [" + packCodeCount + "]");
if(packCodeCount <= 0) {
errString = getErrorString("pack_code", "VTPCKCDM", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in UNIT not present in master errString:: [" + errString + "]");
break;
}
if(packCodeCountPs != null)
{
packCodeCountPs.close();
packCodeCountPs = null;
}
if(packCodeCountRs != null)
{
packCodeCountRs.close();
packCodeCountRs = null;
}
}
//Added changes on 25-March-26 by Ajit [End]
//End elseif
}//End for loop
}//End for loop
break;
}//case1
}//switch
}//try
catch (Exception e)
{
System.out.println ("Exception: wfValData(Document dom): " + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(connection != null)
{
connection.close();
connection = null;
}
}
catch(Exception e)
{
errString = genericUtility.createErrorString(e);
}
}
return (errString);
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext,
String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException {
BaseLogger.log("3", getUserInfo(), null,
">>>>>>>>>>>>>>>>>> ReqForQuotationIC itemchange called Ajit>>>>>>>>>>>>>>>>>>>");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom2 = genericUtility.parseString(xmlString2);
}
BaseLogger.log("3", null, null, "xmlString ReqForQuotationIC [" + xmlString + "]");
BaseLogger.log("3", null, null, "xmlString1 ReqForQuotationIC [" + xmlString1 + "]");
BaseLogger.log("3", null, null, "xmlString2 ReqForQuotationIC [" + xmlString2 + "]");
errString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
BaseLogger.log("3", null, null, "ErrString :" + errString);
} catch (Exception e) {
BaseLogger.log("3", null, null, "Exception :ReqForQuotationIC :itemChanged(String,String):" + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
}
BaseLogger.log("3", null, null, "returning from ReqForQuotationIC itemChanged");
return errString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException, ITMException {
BaseLogger.log("3", getUserInfo(), null, ">>>>>>>>>>>>>>>>>> ReqForQuotationIC itemchange called Ajit>>>>>>>>>>>>>>>>>>>");
System.out.println("Inside itemchange");
Connection con = null;
PreparedStatement psSiteCustomer = null;
PreparedStatement psCustomer = null;
PreparedStatement psPriceList = null;
PreparedStatement psFinEntity = null;
String reStr = "";
ResultSet rs = null;
StringBuffer valueXmlString = null;
int currentFormNo = 0;
String userId = "";
String sql = "";
String priceList = "";
int rate= 0;
String finEntity = "";
List<String> itemCodeList = new ArrayList<>();
try {
UserInfoBean userInfo = getUserInfo();
String siteCode = checkNull(userInfo.getSiteCode());
String userCode = checkNull(userInfo.getLoginCode());
String userName = checkNull(userInfo.getUserName());
String siteDescr = checkNull(userInfo.getSiteDescr());
BaseLogger.log("3", null, null, "ReqForQuotationIC in siteCodeFromUserInfo:: "+siteCode);
BaseLogger.log("3", null, null, "ReqForQuotationIC in userCodeFromUserInfo:: "+userCode);
BaseLogger.log("3", null, null, "ReqForQuotationIC in userName:: "+userName);
BaseLogger.log("3", null, null, "ReqForQuotationIC in siteDescr:: "+siteDescr);
con = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"); // To get user details after login
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
// start creating xml
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition ptrFlag:: "+ptrFlag);
BaseLogger.log("3", null, null, "ReqForQuotationIC currentFormNo "+currentFormNo);
switch (currentFormNo) {
case 1:
{
valueXmlString.append("<Detail1>");
if ("itm_default".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm_default case 1");
// Set tran_date to current date
SimpleDateFormat dtFormat = new SimpleDateFormat(getApplDateFormat());
String currDate = dtFormat.format(Calendar.getInstance().getTime());
valueXmlString.append("<tran_date>").append("<![CDATA[" + currDate + "]]>").append("</tran_date>\r\n");
// Set req_date to current date
valueXmlString.append("<req_date>").append("<![CDATA[" + currDate + "]]>").append("</req_date>\r\n");
// Set site_code to logged in user's site code
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<quot_type>").append("<![CDATA[C]]>").append("</quot_type>");
// Set sales_pers to logged in user's code
valueXmlString.append("<sales_pers>").append("<![CDATA[" + userCode + "]]>").append("</sales_pers>\r\n");
// Set sp_name to logged in user's name
valueXmlString.append("<sp_name>").append("<![CDATA[" + userName + "]]>").append("</sp_name>\r\n");
// Set site_descr to logged in user's site description
valueXmlString.append("<site_descr>") .append("<![CDATA[" + siteDescr + "]]>").append("</site_descr>\r\n");
}
if ("cust_code".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in item change case 1 cust_code condition");
String custName = "", addr1 = "", addr2="", addr3="";
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in case 1 cust_code:: "+custCode);
String custDetilsSql = "select cust_name, addr1 , addr2 , addr3 from customer where cust_code = ?";
PreparedStatement custDetailsPs = con.prepareStatement(custDetilsSql);
custDetailsPs.setString(1, custCode);
ResultSet custDetailsRs = custDetailsPs.executeQuery();
while(custDetailsRs.next()) {
custName = custDetailsRs.getString("cust_name");
addr1 = custDetailsRs.getString("addr1");
addr2 = custDetailsRs.getString("addr2");
addr3 = custDetailsRs.getString("addr3");
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in case 1 custName:: "+custName);
valueXmlString.append("<cust_name>").append("<![CDATA["+custName+"]]>").append("</cust_name>\r\n");
valueXmlString.append("<addr1>").append("<![CDATA["+addr1+"]]>").append("</addr1>\r\n");
valueXmlString.append("<addr2>").append("<![CDATA["+addr2+"]]>").append("</addr2>\r\n");
valueXmlString.append("<addr3>").append("<![CDATA["+addr3+"]]>").append("</addr3>\r\n");
}
if ("item_ser".equalsIgnoreCase(currentColumn.trim()))
{
String itemSerDescr = "";
String itemSerForIC = checkNull(genericUtility.getColumnValue("item_ser", dom, "1"));
BaseLogger.log("0", null, userId, "case 1::: item_ser");
System.out.println("case 1---------itemSerForIC05M------[" + itemSerForIC + "]");
if(itemSerForIC != null && itemSerForIC.trim().length() > 0)
{
String[] itemSerArr = itemSerForIC.split(",");
String itemSerSql = "select descr from itemser where item_ser = ?";
try (PreparedStatement itemSerPs = con.prepareStatement(itemSerSql))
{
for(String itemSer : itemSerArr)
{
itemSerPs.setString(1, itemSer.trim());
try (ResultSet itemSerRs = itemSerPs.executeQuery())
{
if(itemSerRs.next())
{
if(itemSerDescr.length() > 0)
{
itemSerDescr += ", ";
}
itemSerDescr += checkNull(itemSerRs.getString("descr"));
}
}
}
}
}
setNodeValue(dom, "descr", itemSerDescr);
BaseLogger.log("0", null, userId, "case 1::: item_ser descr::"+itemSerDescr);
valueXmlString.append("<descr>").append("<![CDATA["+itemSerDescr+"]]>").append("</descr>\r\n");
}
if ("sales_pers".equalsIgnoreCase(currentColumn.trim())) {
String salesPersCode = checkNull(genericUtility.getColumnValue("sales_pers", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in itemchange case 1 sales_pers:: " + salesPersCode);
String sp_name = "";
if (salesPersCode != null && salesPersCode.trim().length() > 0) {
String sp_nameSql = "select SP_NAME from SALES_PERS where SALES_PERS = ?";
PreparedStatement sp_namePs = con.prepareStatement(sp_nameSql);
sp_namePs.setString(1, salesPersCode);
ResultSet sp_nameRs = sp_namePs.executeQuery();
if (sp_nameRs.next()) {
sp_name = checkNull(sp_nameRs.getString("SP_NAME"));
}
sp_nameRs.close();
sp_namePs.close();
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in itemchange case 1 sp_name:: " + sp_name);
valueXmlString.append("<sp_name>").append("<![CDATA[" + sp_name + "]]>").append("</sp_name>\r\n");
}
if ("site_code".equalsIgnoreCase(currentColumn.trim()))
{
String sitecode = checkNull(genericUtility.getColumnValue("site_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in itemchange case 1 site_code:: " + sitecode);
String site_descr = "";
if (sitecode != null && sitecode.trim().length() > 0)
{
String siteSql = "select descr from site where site_code = ?";
PreparedStatement site_descrPs = con.prepareStatement(siteSql);
site_descrPs.setString(1, sitecode);
ResultSet site_descrRs = site_descrPs.executeQuery();
if (site_descrRs.next())
{
site_descr = checkNull(site_descrRs.getString("DESCR"));
}
site_descrRs.close();
site_descrPs.close();
}
BaseLogger.log("3", null, null, "ReqForQuotationIC site_descr:: " + site_descr);
valueXmlString.append("<site_descr>") .append("<![CDATA[" + site_descr + "]]>").append("</site_descr>\r\n");
}
valueXmlString.append("</Detail1>");
break;
}
case 2:
{
valueXmlString.append("<Detail2>");
if ("itm_default".equalsIgnoreCase(currentColumn.trim())) {
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default ");
//Management rate block[Start]
String finEntityQuery = "select fin_entity from site where site_code = ?";
psFinEntity = con.prepareStatement(finEntityQuery);
psFinEntity.setString(1, siteCode);
rs = psFinEntity.executeQuery();
if(rs.next()) {
finEntity = checkNull(rs.getString("fin_entity"));
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default finEntity:: "+finEntity);
rs.close();
psFinEntity.close();
// Now, use finEntity to fetch VAR_VALUE from finparm
String varValueQuery = "select VAR_VALUE from finparm where ADDL_VALUE = ?";
PreparedStatement psVarValue = con.prepareStatement(varValueQuery);
psVarValue.setString(1, finEntity);
ResultSet rsVarValue = psVarValue.executeQuery();
String varValue = null;
if (rsVarValue.next()) {
varValue = checkNull(rsVarValue.getString("VAR_VALUE"));
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default varValue:: " + varValue);
// Clean up the result set and prepared statement for the varValue query
rsVarValue.close();
psVarValue.close();
// Finally, use varValue to fetch the rate from pricelist
String rateQuery = "select rate from pricelist where price_list = ?";
PreparedStatement psRate = con.prepareStatement(rateQuery);
psRate.setString(1, varValue);
ResultSet rsRate = psRate.executeQuery();
int MngmntAprvRate = 0;
if (rsRate.next()) {
MngmntAprvRate = rsRate.getInt("rate");
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default rate:: " + rate);
// Clean up the result set and prepared statement for the rate query
rsRate.close();
psRate.close();
String priceSql =
"SELECT TRIM(fp.var_name) AS var_name, pl.rate " +
"FROM finparm fp " +
"JOIN site s ON TRIM(s.fin_entity) = TRIM(fp.ADDL_VALUE) " +
"JOIN pricelist pl ON TRIM(pl.price_list) = TRIM(fp.VAR_VALUE) " +
"WHERE TRIM(s.site_code) = ? " +
"AND TRIM(fp.VAR_NAME) IN ('RFQ_PTS','RFQ_PTD')";
PreparedStatement psPrice = con.prepareStatement(priceSql);
psPrice.setString(1, siteCode);
ResultSet rsPrice = psPrice.executeQuery();
BigDecimal pts = null;
BigDecimal ptd = null;
BigDecimal PriceRate = null;
while (rsPrice.next()) {
String varName = checkNull(rsPrice.getString("VAR_NAME"));
PriceRate = rsPrice.getBigDecimal("rate");
if ("RFQ_PTS".equals(varName)) {
pts = PriceRate;
} else if ("RFQ_PTD".equals(varName)) {
ptd = PriceRate;
}
}
//PTR calculation start
String siteCustomerQuery =
"SELECT PRICE_LIST FROM SITE_CUSTOMER " +
"WHERE SITE_CODE = ? AND CUST_CODE = ?";
psSiteCustomer = con.prepareStatement(siteCustomerQuery);
psSiteCustomer.setString(1, siteCode);
psSiteCustomer.setString(2, custCode);
rs = psSiteCustomer.executeQuery();
if (rs.next()) {
priceList = rs.getString("PRICE_LIST");
}
rs.close();
psSiteCustomer.close();
// Step 2: If not found in SITE_CUSTOMER, fetch from CUSTOMER
if (priceList == null || priceList.trim().isEmpty()) {
String customerQuery =
"SELECT PRICE_LIST FROM CUSTOMER WHERE CUST_CODE = ?";
psCustomer = con.prepareStatement(customerQuery);
psCustomer.setString(1, custCode);
rs = psCustomer.executeQuery();
if (rs.next()) {
priceList = rs.getString("PRICE_LIST");
}
rs.close();
psCustomer.close();
}
// Step 3: Fetch RATE from PRICELIST table
if (priceList != null && !priceList.trim().isEmpty()) {
String priceListQuery =
"SELECT RATE FROM PRICELIST WHERE PRICE_LIST = ?";
psPriceList = con.prepareStatement(priceListQuery);
psPriceList.setString(1, priceList);
rs = psPriceList.executeQuery();
if (rs.next()) {
rate = rs.getInt("RATE");
}
rs.close();
psPriceList.close();
}
//PTR calculation end
valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n");
valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n");
valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n");
valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n");
valueXmlString.append("<qty_quot>").append("<![CDATA[0]]>").append("</qty_quot>\r\n");
//Management rate block[End]
}
if ("itm_defaultedit".equalsIgnoreCase(currentColumn.trim())) {
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
String ptrFlagForEdit = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
String rateQuot = checkNull(genericUtility.getColumnValue("rate_quot", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default edit ptrFlagForEdit::"+ptrFlagForEdit);
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default edit rateQuot::"+rateQuot);
if(ptrFlagForEdit.equalsIgnoreCase("Y")) {
valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA["+rateQuot+"]]>").append("</rate_quot>\r\n");
}
// Set sp_name to logged in user's name
valueXmlString.append("<sp_name>").append("<![CDATA[" + userName + "]]>").append("</sp_name>\r\n");
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default ");
//Management rate block[Start]
String finEntityQuery = "select fin_entity from site where site_code = ?";
psFinEntity = con.prepareStatement(finEntityQuery);
psFinEntity.setString(1, siteCode);
rs = psFinEntity.executeQuery();
if(rs.next()) {
finEntity = checkNull(rs.getString("fin_entity"));
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default finEntity:: "+finEntity);
rs.close();
psFinEntity.close();
// Now, use finEntity to fetch VAR_VALUE from finparm
String varValueQuery = "select VAR_VALUE from finparm where ADDL_VALUE = ?";
PreparedStatement psVarValue = con.prepareStatement(varValueQuery);
psVarValue.setString(1, finEntity);
ResultSet rsVarValue = psVarValue.executeQuery();
String varValue = null;
if (rsVarValue.next()) {
varValue = checkNull(rsVarValue.getString("VAR_VALUE"));
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default varValue:: " + varValue);
// Clean up the result set and prepared statement for the varValue query
rsVarValue.close();
psVarValue.close();
// Finally, use varValue to fetch the rate from pricelist
String rateQuery = "select rate from pricelist where price_list = ?";
PreparedStatement psRate = con.prepareStatement(rateQuery);
psRate.setString(1, varValue);
ResultSet rsRate = psRate.executeQuery();
int MngmntAprvRate = 0;
if (rsRate.next()) {
MngmntAprvRate = rsRate.getInt("rate");
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default rate:: " + rate);
// Clean up the result set and prepared statement for the rate query
rsRate.close();
psRate.close();
String priceSql =
"SELECT TRIM(fp.var_name) AS var_name, pl.rate " +
"FROM finparm fp " +
"JOIN site s ON TRIM(s.fin_entity) = TRIM(fp.ADDL_VALUE) " +
"JOIN pricelist pl ON TRIM(pl.price_list) = TRIM(fp.VAR_VALUE) " +
"WHERE TRIM(s.site_code) = ? " +
"AND TRIM(fp.VAR_NAME) IN ('RFQ_PTS','RFQ_PTD')";
PreparedStatement psPrice = con.prepareStatement(priceSql);
psPrice.setString(1, siteCode);
ResultSet rsPrice = psPrice.executeQuery();
BigDecimal pts = null;
BigDecimal ptd = null;
BigDecimal PriceRate = null;
while (rsPrice.next()) {
String varName = checkNull(rsPrice.getString("VAR_NAME"));
PriceRate = rsPrice.getBigDecimal("rate");
if ("RFQ_PTS".equals(varName)) {
pts = PriceRate;
} else if ("RFQ_PTD".equals(varName)) {
ptd = PriceRate;
}
}
//PTR calculation start
String siteCustomerQuery =
"SELECT PRICE_LIST FROM SITE_CUSTOMER " +
"WHERE SITE_CODE = ? AND CUST_CODE = ?";
psSiteCustomer = con.prepareStatement(siteCustomerQuery);
psSiteCustomer.setString(1, siteCode);
psSiteCustomer.setString(2, custCode);
rs = psSiteCustomer.executeQuery();
if (rs.next()) {
priceList = rs.getString("PRICE_LIST");
}
rs.close();
psSiteCustomer.close();
// Step 2: If not found in SITE_CUSTOMER, fetch from CUSTOMER
if (priceList == null || priceList.trim().isEmpty()) {
String customerQuery =
"SELECT PRICE_LIST FROM CUSTOMER WHERE CUST_CODE = ?";
psCustomer = con.prepareStatement(customerQuery);
psCustomer.setString(1, custCode);
rs = psCustomer.executeQuery();
if (rs.next()) {
priceList = rs.getString("PRICE_LIST");
}
rs.close();
psCustomer.close();
}
// Step 3: Fetch RATE from PRICELIST table
if (priceList != null && !priceList.trim().isEmpty()) {
String priceListQuery =
"SELECT RATE FROM PRICELIST WHERE PRICE_LIST = ?";
psPriceList = con.prepareStatement(priceListQuery);
psPriceList.setString(1, priceList);
rs = psPriceList.executeQuery();
if (rs.next()) {
rate = rs.getInt("RATE");
}
rs.close();
psPriceList.close();
}
//PTR calculation end
valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n");
valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n");
valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n");
valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n");
valueXmlString.append("<ptr_flag>").append("<![CDATA["+ptrFlagForEdit+"]]>").append("</ptr_flag>\r\n");
//Management rate block[End]
}
if ("qty_quot".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", getUserInfo(), null, "In qty_quot condition for case 2 item change");
String rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
int qty = 0;
BigDecimal rateQuotDecimal = BigDecimal.ZERO;
BigDecimal value = BigDecimal.ZERO;
try {
qty = (qtyStr != null && qtyStr.trim().length() > 0) ? Integer.parseInt(qtyStr.trim()) : 0;
rateQuotDecimal = (rateQuotStr != null && rateQuotStr.trim().length() > 0)
? new BigDecimal(rateQuotStr.trim())
: BigDecimal.ZERO;
value = rateQuotDecimal.multiply(new BigDecimal(qty));
BaseLogger.log("3", null, null,
"qty:: " + qty + " rateQuot:: " + rateQuotDecimal + " value:: " + value);
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing values: " + e.getMessage());
}
valueXmlString.append("<value protect='1'><![CDATA[" + value + "]]></value>\r\n");
setNodeValue(dom, "value", value.toString()); // Added In 1389
}
if ("item_code".equalsIgnoreCase(currentColumn.trim())) {
String itemDescr = "";
String unit = "";
String packCode = "";
BaseLogger.log("3", null, null, "ReqForQuotationIC in item_code ");
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String itemDescrSql = "select descr,unit,pack_code from item where item_code = ?";
PreparedStatement itemDescrPs = con.prepareStatement(itemDescrSql);
itemDescrPs.setString(1, itemCode);
ResultSet itemDescrRs = itemDescrPs.executeQuery();
while(itemDescrRs.next()) {
itemDescr = checkNull(itemDescrRs.getString("descr"));
unit = checkNull(itemDescrRs.getString("unit"));
packCode = checkNull(itemDescrRs.getString("pack_code"));
}
valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>\r\n");
valueXmlString.append("<unit protect='1'>").append("<![CDATA["+unit+"]]>").append("</unit>\r\n");
valueXmlString.append("<pack_code protect='1'>").append("<![CDATA["+packCode+"]]>").append("</pack_code>\r\n");
}
//Made changes if PTR_FLAG is "Y" then for Value field calculation used PTR field value instead of RATE_QUOT[10-APR]
if ("ptr_flag".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flag ");
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
String rateStr = checkNull(genericUtility.getColumnValue("ptr", dom));
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
String rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
int qty = 0;
BigDecimal rateQuotDecimal = BigDecimal.ZERO;
BigDecimal value = BigDecimal.ZERO;
BaseLogger.log("3", null, null, "ReqForQuotationWiz in qty_quot condition qtyStr:: " + qtyStr);
BaseLogger.log("3", null, null,
"ReqForQuotationWiz in qty_quot condition rateQuotStr:: " + rateQuotStr);
try {
qty = (qtyStr != null && qtyStr.trim().length() > 0)
? Integer.parseInt(qtyStr.trim())
: 0;
rateQuotDecimal = (rateStr != null && rateStr.trim().length() > 0)
? new BigDecimal(rateStr.trim())
: BigDecimal.ZERO;
value = rateQuotDecimal.multiply(new BigDecimal(qty));
BaseLogger.log("3", null, null,
"qty:: " + qty + " rateQuot:: " + rateQuotDecimal + " value:: " + value);
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing values: " + e.getMessage());
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition:: "+ptrFlag);
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition siteCode:: "+siteCode);
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition custCode:: "+custCode);
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition ptr:: "+rateStr);
if(ptrFlag.equalsIgnoreCase("Y")) {
BaseLogger.log("3", getUserInfo(), null, "Final RATE : " + rate);
valueXmlString.append("<value protect='1'>").append("<![CDATA["+value+"]]>").append("</value>\r\n");
valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA["+rateStr+"]]>").append("</rate_quot>\r\n");
}else if(ptrFlag.equalsIgnoreCase("N")) {
valueXmlString.append("<value protect='1'>").append("<![CDATA[]]>").append("</value>\r\n");
valueXmlString.append("<rate_quot protect='0'>").append("<![CDATA[]]>").append("</rate_quot>\r\n");
}
}
if ("rate_quot".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", null, null, "ReqForQuotationIC in rate_quot ::");
String rateQuot = checkNull(genericUtility.getColumnValue("rate_quot", dom));
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String rateApprv = checkNull(genericUtility.getColumnValue("rate_apprv", dom));
String ratePtr = checkNull(genericUtility.getColumnValue("ptr", dom));
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
String rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
int qty = 0;
BigDecimal rateQuotDecimal = BigDecimal.ZERO;
BigDecimal value = BigDecimal.ZERO;
BaseLogger.log("3", null, null, "ReqForQuotationWiz in qty_quot condition qtyStr:: " + qtyStr);
BaseLogger.log("3", null, null,
"ReqForQuotationWiz in qty_quot condition rateQuotStr:: " + rateQuotStr);
try {
qty = (qtyStr != null && qtyStr.trim().length() > 0)
? Integer.parseInt(qtyStr.trim())
: 0;
rateQuotDecimal = (rateQuotStr != null && rateQuotStr.trim().length() > 0)
? new BigDecimal(rateQuotStr.trim())
: BigDecimal.ZERO;
value = rateQuotDecimal.multiply(new BigDecimal(qty));
BaseLogger.log("3", null, null,
"qty:: " + qty + " rateQuot:: " + rateQuotDecimal + " value:: " + value);
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing values: " + e.getMessage());
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr+" itemCode::"+itemCode);
BaseLogger.log("3", null, null, "ReqForQuotationIC in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr+" itemCode::"+itemCode);
if (!rateQuot.isEmpty() && !rateApprv.isEmpty()) {
BigDecimal rateApprvVal = new BigDecimal(rateApprv);
BigDecimal rateQuotVal = new BigDecimal(rateQuot);
BigDecimal ratePtrVal = new BigDecimal(ratePtr);
// added condition when ptr and rate_quot is same direct approval without management
if (ratePtrVal.compareTo(rateQuotVal) == 0) {
BaseLogger.log("3", null, null, "in ratePtrVal == rateQuotVal condition");
String detail1Xml = "<Detail1><mgmnt_apprv><![CDATA[N]]></mgmnt_apprv><wf_status><![CDATA[A]]></wf_status></Detail1>";
int pos = valueXmlString.indexOf("</header>");
if (pos != -1) {
pos += "</header>".length(); // move after </header>
valueXmlString.insert(pos, detail1Xml);
}
BaseLogger.log("3", null, null,
"in rateApprvVal greater condition updatedXml ::" + valueXmlString);
}
if (rateApprvVal.compareTo(rateQuotVal) > 0) {
BaseLogger.log("3", null, null, "in rateApprvVal greater condition");
BaseLogger.log("3", null, null, "in rateApprvVal greater condition valueXmlString::"+ valueXmlString);
String detail1Xml = "<Detail1><mgmnt_apprv><![CDATA[Y]]></mgmnt_apprv><wf_status><![CDATA[P]]></wf_status></Detail1>";
int pos = valueXmlString.indexOf("</header>");
if (pos != -1) {
pos += "</header>".length(); // move after </header>
valueXmlString.insert(pos, detail1Xml);
}
BaseLogger.log("3", null, null, "in rateApprvVal greater condition updatedXml ::"+valueXmlString);
}
if (rateQuotVal.compareTo(rateApprvVal) > 0) {
BaseLogger.log("3", null, null, "in rateQuotVal greater condition");
BaseLogger.log("3", null, null, "in rateQuotVal greater condition valueXmlString::"+ valueXmlString);
String detail1Xml = "<Detail1><mgmnt_apprv><![CDATA[]]></mgmnt_apprv><wf_status><![CDATA[]]></wf_status></Detail1>";
int pos = valueXmlString.indexOf("</header>");
if (pos != -1) {
pos += "</header>".length(); // move after </header>
valueXmlString.insert(pos, detail1Xml);
}
BaseLogger.log("3", null, null, "in rateApprvVal greater condition updatedXml ::"+valueXmlString);
}
}
//Calculating Revised PTR,PTD and PTS [Start]
PreparedStatement resvisedRatePstmt =null;
ResultSet resvisedRateRs = null;
try {
String resvisedRateSql = "select PHY_ATTRIB_13,PHY_ATTRIB_14,PHY_ATTRIB_15 from item where item_code = ?";
resvisedRatePstmt = con.prepareStatement(resvisedRateSql);
resvisedRatePstmt.setString(1, itemCode);
resvisedRateRs = resvisedRatePstmt.executeQuery();
while (resvisedRateRs.next()) {
String distMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_13"));
String stockMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_14"));
String retailMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_15"));
BigDecimal distMargin = BigDecimal.ZERO;
BigDecimal stockMargin = BigDecimal.ZERO;
BigDecimal retailMargin = BigDecimal.ZERO;
try {
distMargin = (distMarginStr != null && distMarginStr.trim().length() > 0) ? new BigDecimal(distMarginStr.trim()) : BigDecimal.ZERO;
stockMargin = (stockMarginStr != null && stockMarginStr.trim().length() > 0) ? new BigDecimal(stockMarginStr.trim()) : BigDecimal.ZERO;
retailMargin = (retailMarginStr != null && retailMarginStr.trim().length() > 0) ? new BigDecimal(retailMarginStr.trim()) : BigDecimal.ZERO;
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing margin values");
}
BigDecimal rateBD = new BigDecimal(rateQuot);
BigDecimal hundred = new BigDecimal(100);
// BigDecimal retailMarginBD = new BigDecimal(retailMargin);
// BigDecimal stockMarginBD = new BigDecimal(stockMargin);
// BigDecimal distMarginBD = new BigDecimal(distMargin);
BaseLogger.log("3", null, null, "distMargin::" + distMargin + " stockMargin::" + stockMargin + " revisedPtd:: " + retailMargin + "rate:: " + rate + "]");
BigDecimal revisedPtr = rateBD.divide(hundred.multiply(hundred.subtract(retailMargin)), 6, RoundingMode.HALF_UP);
BigDecimal revisedPts = rateBD.divide(hundred.multiply(hundred.subtract(stockMargin)), 6, RoundingMode.HALF_UP);
BigDecimal revisedPtd = rateBD.divide(hundred.multiply(hundred.subtract(distMargin)), 6, RoundingMode.HALF_UP);
BaseLogger.log("3", null, null, "revisedPtr::" + revisedPtr + " revisedPts::" + revisedPts + " revisedPtd::" + revisedPtd);
BaseLogger.log("3", null, null, "revisedPtr::" + revisedPtr + " revisedPts::" + revisedPts + " revisedPtd:: " + revisedPtd + "]");
valueXmlString.append("<revised_ptr>").append("<![CDATA[" + revisedPtr + "]]>").append("</revised_ptr>\r\n");
valueXmlString.append("<revised_pts>").append("<![CDATA[" + revisedPts + "]]>").append("</revised_pts>\r\n");
valueXmlString.append("<revised_ptd>").append("<![CDATA[" + revisedPtd + "]]>").append("</revised_ptd>\r\n");
valueXmlString.append("<value>").append("<![CDATA[" + value + "]]>").append("</value>\r\n");
}
} catch (Exception e) {
BaseLogger.log("3", null, null, "Exception 1002. [" + E12GenericUtility.getStackTrace(e) + "]");
} finally {
// Ensure you close the ResultSet and PreparedStatement afterwards to prevent memory leaks!
resvisedRateRs.close();
resvisedRatePstmt.close();
}
//Calculating Revised PTR,PTD and PTS [End]
}
valueXmlString.append("</Detail2>\r\n");
break;
}
}
BaseLogger.log("3", null, null, "in rateApprvVal greater condition reStr>>>>> "+reStr);
valueXmlString.append("</Root>\r\n");
} catch (Exception e) {
BaseLogger.log("3", getUserInfo(), null, "Exception :ReqForQuotationIC :itemChanged(Document,String):" + e.getMessage() + ":");
e.printStackTrace();
} finally {
closeResources(rs, psSiteCustomer, conn);
closeResources(rs, psCustomer, conn);
closeResources(rs, psPriceList, conn);
closeResources(rs, psPriceList, con);
}
BaseLogger.log("3", getUserInfo(), null, "ReqForQuotationIC valueXmlString::"+valueXmlString.toString());
return valueXmlString.toString();
}
private void closeResources(ResultSet rs, PreparedStatement pstmt, Connection conn) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (pstmt != null) {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
private String checkNull(String input) {
if (input == null) {
input = "";
} else {
input = input.trim();
}
return input;
}
private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception
{
Node tempNode = dom.getElementsByTagName( nodeName ).item(0);
if( tempNode != null )
{
if( tempNode.getFirstChild() == null )
{
CDATASection cDataSection = dom.createCDATASection( nodeVal );
tempNode.appendChild( cDataSection );
}
else
{
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
public static boolean isDateInvalid(String validUptoStr)
{
try
{
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yy");
LocalDate validDate = LocalDate.parse(validUptoStr, formatter);
LocalDate currentDate = LocalDate.now();
if(validDate.isBefore(currentDate))
{
return true;
}
}
catch(Exception e)
{
BaseLogger.log("3", null, null, "Exception in date validation [" + e + "]");
}
return false;
}
}
...@@ -28,6 +28,7 @@ import java.util.Calendar; ...@@ -28,6 +28,7 @@ import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
...@@ -207,6 +208,44 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -207,6 +208,44 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
} }
if( childNodeName.equalsIgnoreCase("quot_type") )
{
String customerCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
String quotationtype = checkNull(genericUtility.getColumnValue("quot_type", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC quotationtype wfValData case 1 [" + quotationtype + "]");
if (quotationtype.equalsIgnoreCase("G"))
{
String quotationtypeSql = "select count(group_code) as customergroupcount from customer where group_code= ?";
PreparedStatement quotationtypePs = connectionObject.prepareStatement(quotationtypeSql);
quotationtypePs.setString(1, customerCode);
ResultSet quotationtypeRs = quotationtypePs.executeQuery();
while(quotationtypeRs.next())
{
int customergroupcount = quotationtypeRs.getInt("customergroupcount");
BaseLogger.log("3", null, null, "ReqForQuotationIC group_count wfValData case 1 quotationtypeRs::[" + customergroupcount + "]");
if(customergroupcount<=1)
{
errCode="INVCG";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(quotationtypeRs != null)
{
quotationtypeRs.close();
quotationtypeRs = null;
}
if(quotationtypePs != null)
{
quotationtypePs.close();
quotationtypePs = null;
}
}
}
if( childNodeName.equalsIgnoreCase("site_code") ) if( childNodeName.equalsIgnoreCase("site_code") )
{ {
String siteCode = checkNull(genericUtility.getColumnValue("site_code", dom)); String siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
...@@ -366,10 +405,13 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -366,10 +405,13 @@ public class ReqForQuotationWiz extends ValidatorEJB{
{ {
String[] itemSerArr = null; String[] itemSerArr = null;
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom)); String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
String itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom1)); String itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom1));
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 1 itemSer:[" + itemSer + "]"); BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 2 itemSer:[" + itemSer + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 2 ptrFlag:[" + ptrFlag + "]");
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 1 [" + itemCode + "]"); BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 2 [" + itemCode + "]");
if(itemSer != null && itemSer.trim().length() > 0) if(itemSer != null && itemSer.trim().length() > 0)
{ {
...@@ -410,7 +452,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -410,7 +452,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
while(checkItemCodeRs.next()) { while(checkItemCodeRs.next()) {
int itemCodeCont = checkItemCodeRs.getInt("itemCodeCount"); int itemCodeCont = checkItemCodeRs.getInt("itemCodeCount");
BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 1 itemCodeCont::[" + itemCodeCont + "]"); BaseLogger.log("3", null, null, "ReqForQuotationWiz itemCode wfValData case 1 itemCodeCont::[" + itemCodeCont + "]");
if(itemCodeCont<=0) { if(itemCodeCont<=0 && !ptrFlag.equalsIgnoreCase("Y")) {
errCode="STKVALITNE"; errCode="STKVALITNE";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
...@@ -432,6 +474,40 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -432,6 +474,40 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
/*
* if( childNodeName.equalsIgnoreCase("rate_quot") ) { String phyAttrVal = "";
* String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
* String quotedRate = checkNull(genericUtility.getColumnValue("rate_quot",
* dom)); BaseLogger.log("3", null, null,
* "ReqForQuotationIC in condition itemCode wfValData quotedRate::: [" +
* quotedRate + "]");
*
* BaseLogger.log("3", null, null,
* "ReqForQuotationIC in condition itemCode wfValData itemCode::: [" + itemCode
* + "]"); String phyAttrValSql =
* "select PHY_ATTRIB_19 from item where item_code = ?"; PreparedStatement
* phyAttrValPs = connectionObject.prepareStatement(phyAttrValSql);
* phyAttrValPs.setString(1, itemCode); ResultSet phyAttrValRs =
* phyAttrValPs.executeQuery(); while(phyAttrValRs.next()) { phyAttrVal =
* checkNull(phyAttrValRs.getString("PHY_ATTRIB_19")); } BaseLogger.log("3",
* null, null,
* "ReqForQuotationIC in condition itemCode wfValData phyAttrVal::: [" +
* phyAttrVal + "]"); if(phyAttrVal.equalsIgnoreCase("SRNA")) {
* errCode="INEFSR"; errList.add(errCode);
* errFields.add(childNodeName.toLowerCase()); //errString =
* getErrorString("rate_quot", "INEFSR", userId); BaseLogger.log("3", null,
* null, "ReqForQuotationIC in PHY_ATTRIB_19 details null errString:: [" +
* errString + "]");
*
*
* }
*
* if(phyAttrValPs != null) { phyAttrValPs.close(); phyAttrValPs = null; }
* if(phyAttrValRs != null) { phyAttrValRs.close(); phyAttrValRs = null; }
*
* }
*/
//Removed the validation from Quoted Quantity as it can be zero //Removed the validation from Quoted Quantity as it can be zero
/* /*
* if( childNodeName.equalsIgnoreCase("qty_quot") ) { int qty = 0; String * if( childNodeName.equalsIgnoreCase("qty_quot") ) { int qty = 0; String
...@@ -448,6 +524,10 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -448,6 +524,10 @@ public class ReqForQuotationWiz extends ValidatorEJB{
* "ReqForQuotationWiz in qty_quot < 0 errString:: [" + errString + "]"); break; * "ReqForQuotationWiz in qty_quot < 0 errString:: [" + errString + "]"); break;
* } } * } }
*/ */
//Comment out the rate_quot validation block as this case handled by JS[Start]
/*
if( childNodeName.equalsIgnoreCase("rate_quot") ) if( childNodeName.equalsIgnoreCase("rate_quot") )
{ {
int quotedRate = 0; int quotedRate = 0;
...@@ -455,7 +535,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -455,7 +535,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{
BaseLogger.log("3", null, null, "ReqForQuotationWiz rate_quot wfValData case 2 [" + rateQuot + "]"); BaseLogger.log("3", null, null, "ReqForQuotationWiz rate_quot wfValData case 2 [" + rateQuot + "]");
if(rateQuot != null && rateQuot.trim().length() > 0) if(rateQuot != null && rateQuot.trim().length() > 0)
{ {
quotedRate = Integer.parseInt(rateQuot); double quotedRateDouble = Double.parseDouble(rateQuot);
quotedRate = (int) quotedRateDouble;
// quotedRate = Integer.parseInt(rateQuot);
} }
...@@ -490,8 +572,42 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -490,8 +572,42 @@ public class ReqForQuotationWiz extends ValidatorEJB{
BaseLogger.log("3", null, null, "ReqForQuotationWiz in competitor details null errString:: [" + errString + "]"); BaseLogger.log("3", null, null, "ReqForQuotationWiz in competitor details null errString:: [" + errString + "]");
} }
}
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String phyAttrVal = "";
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition itemCode wfValData itemCode::: [" + itemCode + "]");
String phyAttrValSql = "select PHY_ATTRIB_19 from item where item_code = ?";
PreparedStatement phyAttrValPs = connectionObject.prepareStatement(phyAttrValSql);
phyAttrValPs.setString(1, itemCode);
ResultSet phyAttrValRs = phyAttrValPs.executeQuery();
while(phyAttrValRs.next()) {
phyAttrVal = checkNull(phyAttrValRs.getString("PHY_ATTRIB_19"));
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in condition itemCode wfValData phyAttrVal::: [" + phyAttrVal + "]");
if(phyAttrVal.equalsIgnoreCase("SRNA")) {
errString = getErrorString("rate_quot", "INVQR", userId);
BaseLogger.log("3", null, null, "ReqForQuotationIC in PHY_ATTRIB_19 details null errString:: [" + errString + "]");
break;
}
if(phyAttrValPs != null)
{
phyAttrValPs.close();
phyAttrValPs = null;
}
if(phyAttrValRs != null)
{
phyAttrValRs.close();
phyAttrValRs = null;
} }
} }
*/
//Comment out the rate_quot validation block as this case handled by JS[End]
//Added changes on 25-March-26 by Ajit [Start] //Added changes on 25-March-26 by Ajit [Start]
if( childNodeName.equalsIgnoreCase("unit") ) if( childNodeName.equalsIgnoreCase("unit") )
{ {
...@@ -792,7 +908,6 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -792,7 +908,6 @@ public class ReqForQuotationWiz extends ValidatorEJB{
return returnStr; return returnStr;
} }
private String defaultDataWiz( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName ) throws RemoteException,ITMException private String defaultDataWiz( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName ) throws RemoteException,ITMException
{ {
ResultSet rs = null; ResultSet rs = null;
...@@ -815,6 +930,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -815,6 +930,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{
int currentFormNo = 0; int currentFormNo = 0;
List<String> itemCodeList = new ArrayList<>(); List<String> itemCodeList = new ArrayList<>();
E12GenericUtility genericUtility = new ibase.utility.E12GenericUtility(); E12GenericUtility genericUtility = new ibase.utility.E12GenericUtility();
String phy13 = "";
String phy14 = "";
String phy15 = "";
try try
{ {
...@@ -824,6 +942,8 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -824,6 +942,8 @@ public class ReqForQuotationWiz extends ValidatorEJB{
UserInfoBean userInfo = getUserInfo(); UserInfoBean userInfo = getUserInfo();
String siteCode = checkNull(userInfo.getSiteCode()); String siteCode = checkNull(userInfo.getSiteCode());
String userName = checkNull(userInfo.getUserName());
String siteDescr = checkNull(userInfo.getSiteDescr());
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ); userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
BaseLogger.log("0", null,userId,"case 1---------itemDefault------gsb start"); BaseLogger.log("0", null,userId,"case 1---------itemDefault------gsb start");
BaseLogger.log("0", null,userId,"defaultDataWiz siteCode: "+siteCode); BaseLogger.log("0", null,userId,"defaultDataWiz siteCode: "+siteCode);
...@@ -856,9 +976,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -856,9 +976,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{
if( currentColumn.equalsIgnoreCase( "itm_default" )) if( currentColumn.equalsIgnoreCase( "itm_default" ))
{ {
BaseLogger.log("0", null,userId,"case 1---------itemDefault------gsb-----16"); BaseLogger.log("0", null,userId,"case 1---------itemDefault------gsb-----16--19-April");
valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"qc_resentry_wiz\" selected=\"N\">\r\n" ); valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n" ); valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n" );
valueXmlString.append( "<tran_id/>" ); valueXmlString.append( "<tran_id/>" );
valueXmlString.append("<tran_date protect = '1'>").append("<![CDATA[" + currDate + "]]>").append("</tran_date>"); valueXmlString.append("<tran_date protect = '1'>").append("<![CDATA[" + currDate + "]]>").append("</tran_date>");
...@@ -868,6 +988,10 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -868,6 +988,10 @@ public class ReqForQuotationWiz extends ValidatorEJB{
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>"); valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
// Set sales_pers to logged in user's code // Set sales_pers to logged in user's code
valueXmlString.append("<sales_pers>").append("<![CDATA[" + userId + "]]>").append("</sales_pers>"); valueXmlString.append("<sales_pers>").append("<![CDATA[" + userId + "]]>").append("</sales_pers>");
// Set spname to logged in user's name
valueXmlString.append("<spname>").append("<![CDATA[" + userName + "]]>").append("</spname>");
// Set site_code to logged in user's site description
valueXmlString.append("<site_descr>") .append("<![CDATA[" + siteDescr + "]]>").append("</site_descr>\r\n");
valueXmlString.append("<quot_type>").append("<![CDATA[C]]>").append("</quot_type>"); valueXmlString.append("<quot_type>").append("<![CDATA[C]]>").append("</quot_type>");
valueXmlString.append("</Detail"+objContext+">"); valueXmlString.append("</Detail"+objContext+">");
...@@ -910,7 +1034,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -910,7 +1034,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
} }
BaseLogger.log("0", null, userId, "case 1::: item_ser"); BaseLogger.log("0", null, userId, "case 1::: item_ser");
valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"qc_resentry_wiz\" selected=\"N\">\r\n" ); valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n" ); valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n" );
valueXmlString.append("<descr><![CDATA[" + itemSerDescr + "]]></descr>\n"); valueXmlString.append("<descr><![CDATA[" + itemSerDescr + "]]></descr>\n");
valueXmlString.append("</Detail"+objContext+">"); valueXmlString.append("</Detail"+objContext+">");
...@@ -939,7 +1063,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -939,7 +1063,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
addr3 = custNameRs.getString("addr3"); addr3 = custNameRs.getString("addr3");
} }
valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"qc_resentry_wiz\" selected=\"N\">\r\n" ); valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n" ); valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n" );
valueXmlString.append("<cust_name>").append("<![CDATA[" + custName + "]]>").append("</cust_name>"); valueXmlString.append("<cust_name>").append("<![CDATA[" + custName + "]]>").append("</cust_name>");
valueXmlString.append("<addr1>").append("<![CDATA[" + addr1 + "]]>").append("</addr1>"); valueXmlString.append("<addr1>").append("<![CDATA[" + addr1 + "]]>").append("</addr1>");
...@@ -959,6 +1083,63 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -959,6 +1083,63 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
} }
if (currentColumn.equalsIgnoreCase("sales_pers")) {
String salesPersCode = checkNull(genericUtility.getColumnValue("sales_pers", dom, "1"));
BaseLogger.log("0", null, userId, "case 1---------sales_pers itemchange------[" + salesPersCode + "]");
String spName = "";
if (salesPersCode != null && salesPersCode.trim().length() > 0) {
String spNameSql = "select SP_NAME from SALES_PERS where SALES_PERS = ?";
PreparedStatement spNamePs = conn.prepareStatement(spNameSql);
spNamePs.setString(1, salesPersCode);
ResultSet spNameRs = spNamePs.executeQuery();
if (spNameRs.next()) {
spName = checkNull(spNameRs.getString("SP_NAME"));
}
if (spNameRs != null) {
spNameRs.close();
spNameRs = null;
}
if (spNamePs != null) {
spNamePs.close();
spNamePs = null;
}
}
BaseLogger.log("0", null, userId, "case 1---------spName------[" + spName + "]");
valueXmlString.append("<Detail" + objContext + " domID='" + 1 + "' objContext = '" + currentFormNo + "' objName=\"rfq_wiz\" selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n");
valueXmlString.append("<spname>").append("<![CDATA[" + spName + "]]>").append("</spname>");
valueXmlString.append("</Detail" + objContext + ">");
}
if (currentColumn.equalsIgnoreCase("site_code"))
{
String sitecode = checkNull(genericUtility.getColumnValue("site_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in itemchange case 1 site_code:: " + sitecode);
String site_descr = "";
if (sitecode != null && sitecode.trim().length() > 0)
{
String siteSql = "select descr from site where site_code = ?";
PreparedStatement site_descrPs = conn.prepareStatement(siteSql);
site_descrPs.setString(1, sitecode);
ResultSet site_descrRs = site_descrPs.executeQuery();
if (site_descrRs.next())
{
site_descr = checkNull(site_descrRs.getString("DESCR"));
}
if (site_descrRs != null) {
site_descrRs.close();
site_descrRs = null;
}
if (site_descrPs != null) {
site_descrPs.close();
site_descrPs = null;
}
}
BaseLogger.log("3", null, null, "ReqForQuotationIC site_descr:: " + site_descr);
valueXmlString.append("<Detail" + objContext + " domID='" + 1 + "' objContext = '" + currentFormNo + "' objName=\"rfq_wiz\" selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id\"/>\r\n");
valueXmlString.append("<site_descr>") .append("<![CDATA[" + site_descr + "]]>").append("</site_descr>\r\n");
valueXmlString.append("</Detail" + objContext + ">");
}
break; break;
...@@ -966,11 +1147,11 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -966,11 +1147,11 @@ public class ReqForQuotationWiz extends ValidatorEJB{
if ("itm_default".equalsIgnoreCase(currentColumn.trim())) { if ("itm_default".equalsIgnoreCase(currentColumn.trim())) {
int domId = 0; int domId = 0;
int lineNo = 0; int lineNo = 0;
String setSrPtrAll = checkNull(genericUtility.getColumnValue("set_sr_ptr_all", dom1, "1"));
BaseLogger.log("3", null, null, "ReqForQuotationWiz in itm default setSrPtrAll:: " + setSrPtrAll);
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
String itemSer = checkNull(genericUtility.getColumnValue("item_ser",dom1,"1")); String itemSer = checkNull(genericUtility.getColumnValue("item_ser",dom1,"1"));
String setSrPtrAll = checkNull(genericUtility.getColumnValue("set_sr_ptr_all",dom1,"1"));
BaseLogger.log("3", null, null, "ReqForQuotationWiz in itm default setSrPtrAll:: "+setSrPtrAll);
BaseLogger.log("3", null, null, "ReqForQuotationWiz in itm default "); BaseLogger.log("3", null, null, "ReqForQuotationWiz in itm default ");
//Management rate block[Start] //Management rate block[Start]
String finEntityQuery = "select fin_entity from site where site_code = ?"; String finEntityQuery = "select fin_entity from site where site_code = ?";
...@@ -1160,6 +1341,36 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1160,6 +1341,36 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
Collections.sort(itemCodeList); Collections.sort(itemCodeList);
//Remove the item from itemCodeList if the value is "SRNA"[Start]
String phyAttrValSql = "select PHY_ATTRIB_19 from item where item_code = ?";
PreparedStatement phyAttrValPs = conn.prepareStatement(phyAttrValSql);
Iterator<String> iterator = itemCodeList.iterator();
while (iterator.hasNext()) {
String itemCode = iterator.next();
phyAttrValPs.setString(1, itemCode);
ResultSet phyAttrValRs = phyAttrValPs.executeQuery();
String phyAttrVal = "";
if (phyAttrValRs.next()) {
phyAttrVal = checkNull(phyAttrValRs.getString("PHY_ATTRIB_19"));
}
// ✅ Remove if PHY_ATTRIB_19 = 'SRNA'
if ("SRNA".equalsIgnoreCase(phyAttrVal)) {
iterator.remove();
}
phyAttrValRs.close();
}
phyAttrValPs.close();
//Remove the item from itemCodeList if the value is "SRNA"[End]
for (String itemCode : itemCodeList) for (String itemCode : itemCodeList)
{ {
domId++; domId++;
...@@ -1173,15 +1384,52 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1173,15 +1384,52 @@ public class ReqForQuotationWiz extends ValidatorEJB{
PreparedStatement itemDescrPs = conn.prepareStatement(itemDescrSql); PreparedStatement itemDescrPs = conn.prepareStatement(itemDescrSql);
itemDescrPs.setString(1, itemCode); itemDescrPs.setString(1, itemCode);
ResultSet itemDescrRs = itemDescrPs.executeQuery(); ResultSet itemDescrRs = itemDescrPs.executeQuery();
while(itemDescrRs.next()) { while (itemDescrRs.next())
{
itemDescr = checkNull(itemDescrRs.getString("descr")); itemDescr = checkNull(itemDescrRs.getString("descr"));
unit = checkNull(itemDescrRs.getString("unit")); unit = checkNull(itemDescrRs.getString("unit"));
packCode = checkNull(itemDescrRs.getString("pack_code")); packCode = checkNull(itemDescrRs.getString("pack_code"));
} }
//Added By Saburi
String phySql = "SELECT PHY_ATTRIB_13, PHY_ATTRIB_14, PHY_ATTRIB_15 FROM ITEM WHERE ITEM_CODE = ?";
PreparedStatement phyPs = conn.prepareStatement(phySql);
phyPs.setString(1, itemCode);
ResultSet phyRs = phyPs.executeQuery();
if (phyRs.next())
{
phy13 = checkNull(phyRs.getString("PHY_ATTRIB_13"));
phy14 = checkNull(phyRs.getString("PHY_ATTRIB_14"));
phy15 = checkNull(phyRs.getString("PHY_ATTRIB_15"));
}
phyRs.close();
phyPs.close();
BaseLogger.log("3", null, null, "phy_attrib_13 Value "+ phy13 );
BaseLogger.log("3", null, null, "phy_attrib_14 Value "+ phy14 );
BaseLogger.log("3", null, null, "phy_attrib_15 Value "+ phy15 );
BaseLogger.log("3", null, null, "removed the line no from the itmdefault case 08-April " );
BaseLogger.log("3", null, null, "removed the line no from the itmdefault case " ); //Made changes if set_sr_ptr_all value in header is Y then by default select all the line items in detail screen [10-APR]
if (setSrPtrAll.trim().equalsIgnoreCase("Y"))
{
BaseLogger.log("3", null, null,"Value set as 0" );
valueXmlString.append( "<Detail"+ objContext+" domID='"+domId +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"Y\">\r\n" );
valueXmlString.append( "<attribute selected=\"Y\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n" );
valueXmlString.append( "<tran_id/>" );
valueXmlString.append("<line_no><![CDATA[").append(lineNo).append("]]></line_no>");
valueXmlString.append("<item_code><![CDATA[").append(itemCode).append("]]></item_code>");
valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n");
valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n");
valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n");
valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n");
valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA[" + rate + "]]>").append("</rate_quot>");
valueXmlString.append("<ptr_flag>").append("<![CDATA[Y]]>").append("</ptr_flag>");
}
else
{
valueXmlString.append( "<Detail"+ objContext+" domID='"+domId +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" ); valueXmlString.append( "<Detail"+ objContext+" domID='"+domId +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n" ); valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n" );
valueXmlString.append( "<tran_id/>" ); valueXmlString.append( "<tran_id/>" );
...@@ -1191,10 +1439,6 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1191,10 +1439,6 @@ public class ReqForQuotationWiz extends ValidatorEJB{
valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n"); valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n");
valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n"); valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n");
valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n"); valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n");
if(setSrPtrAll.trim().equalsIgnoreCase("Y")) {
valueXmlString.append("<rate_quot>").append("<![CDATA["+rate+"]]>").append("</rate_quot>");
}else {
valueXmlString.append("<rate_quot>").append("<![CDATA[]]>").append("</rate_quot>"); valueXmlString.append("<rate_quot>").append("<![CDATA[]]>").append("</rate_quot>");
} }
...@@ -1203,10 +1447,14 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1203,10 +1447,14 @@ public class ReqForQuotationWiz extends ValidatorEJB{
valueXmlString.append("<competitor_name>").append("<![CDATA[]]>").append("</competitor_name>"); valueXmlString.append("<competitor_name>").append("<![CDATA[]]>").append("</competitor_name>");
valueXmlString.append("<competitor_item>").append("<![CDATA[]]>").append("</competitor_item>"); valueXmlString.append("<competitor_item>").append("<![CDATA[]]>").append("</competitor_item>");
valueXmlString.append("<remarks>").append("<![CDATA[]]>").append("</remarks>"); valueXmlString.append("<remarks>").append("<![CDATA[]]>").append("</remarks>");
valueXmlString.append("<pack_code protect='1'>").append("<![CDATA["+packCode+"]]>").append("</pack_code>");
valueXmlString.append("<unit protect='1'>").append("<![CDATA["+unit+"]]>").append("</unit>");
valueXmlString.append("<spec_instr>").append("<![CDATA[]]>").append("</spec_instr>"); valueXmlString.append("<spec_instr>").append("<![CDATA[]]>").append("</spec_instr>");
valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>"); valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>");
valueXmlString.append("<pack_code protect='1'>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<unit protect='1'>").append("<![CDATA[" + unit + "]]>").append("</unit>");
valueXmlString.append("<value protect='1'>").append("<![CDATA[]]>").append("</value>");
valueXmlString.append("<phy_attrib_13><![CDATA[" + phy13 + "]]></phy_attrib_13>\r\n");
valueXmlString.append("<phy_attrib_14><![CDATA[" + phy14 + "]]></phy_attrib_14>\r\n");
valueXmlString.append("<phy_attrib_15><![CDATA[" + phy15 + "]]></phy_attrib_15>\r\n");
valueXmlString.append("</Detail"+objContext+">"); valueXmlString.append("</Detail"+objContext+">");
...@@ -1217,6 +1465,42 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1217,6 +1465,42 @@ public class ReqForQuotationWiz extends ValidatorEJB{
//Management rate block[End] //Management rate block[End]
}
// Added by Saburi - 06/04/26 : Fetch PHY_ATTRIB_13,14,15 on item selection
if ("item_code".equalsIgnoreCase(currentColumn.trim())) {
String itemDescr = "";
BaseLogger.log("3", null, null, "ReqForQuotationIC in item_code 1072");
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String itemDescrSql = "SELECT DESCR FROM ITEM WHERE ITEM_CODE = ?";
PreparedStatement itemDescrPs = conn.prepareStatement(itemDescrSql);
itemDescrPs.setString(1, itemCode);
ResultSet itemDescrRs = itemDescrPs.executeQuery();
while(itemDescrRs.next())
{
itemDescr = itemDescrRs.getString("descr");
}
valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>\r\n");
String phySql = "SELECT PHY_ATTRIB_13, PHY_ATTRIB_14, PHY_ATTRIB_15 FROM ITEM WHERE ITEM_CODE = ?";
PreparedStatement phyPs = conn.prepareStatement(phySql);
phyPs.setString(1, itemCode);
ResultSet phyRs = phyPs.executeQuery();
if (phyRs.next())
{
phy13 = checkNull(phyRs.getString("PHY_ATTRIB_13"));
phy14 = checkNull(phyRs.getString("PHY_ATTRIB_14"));
phy15 = checkNull(phyRs.getString("PHY_ATTRIB_15"));
}
phyRs.close();
phyPs.close();
valueXmlString.append("<phy_attrib_13><![CDATA[" + phy13 + "]]></phy_attrib_13>\r\n");
valueXmlString.append("<phy_attrib_14><![CDATA[" + phy14 + "]]></phy_attrib_14>\r\n");
valueXmlString.append("<phy_attrib_15><![CDATA[" + phy15 + "]]></phy_attrib_15>\r\n");
} }
if ("ptr_flag".equalsIgnoreCase(currentColumn.trim())) { if ("ptr_flag".equalsIgnoreCase(currentColumn.trim())) {
String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom)); String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
...@@ -1231,9 +1515,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1231,9 +1515,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
if(ptrFlag.equalsIgnoreCase("Y")) { if(ptrFlag.equalsIgnoreCase("Y")) {
String rateStr = checkNull(genericUtility.getColumnValue("ptr", dom)); String rateStr = checkNull(genericUtility.getColumnValue("ptr", dom));
BaseLogger.log("3", getUserInfo(), null, "Final RATE : " + rate); valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<Detail"+ objContext+" domID='"+ 1 +"' objContext = '"+currentFormNo+"' objName=\"qc_resentry_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n" ); valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n" );
valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA["+rateStr+"]]>").append("</rate_quot>\r\n"); valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA["+rateStr+"]]>").append("</rate_quot>\r\n");
valueXmlString.append("</Detail"+objContext+">"); valueXmlString.append("</Detail"+objContext+">");
...@@ -1248,28 +1530,91 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1248,28 +1530,91 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
} }
if ("qty_quot".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", getUserInfo(), null, "In qty_quot condition for case 2 item change10");
String rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
BaseLogger.log("3", getUserInfo(), null, "In qty_quot condition for case 2 item change rateQuotStr::"+rateQuotStr);
BaseLogger.log("3", getUserInfo(), null, "In qty_quot condition for case 2 item change qtyStr::"+qtyStr);
int qty = 0;
BigDecimal rateQuotDecimal = BigDecimal.ZERO;
BigDecimal value = BigDecimal.ZERO;
try {
qty = (qtyStr != null && qtyStr.trim().length() > 0) ? Integer.parseInt(qtyStr.trim()) : 0;
rateQuotDecimal = (rateQuotStr != null && rateQuotStr.trim().length() > 0)
? new BigDecimal(rateQuotStr.trim())
: BigDecimal.ZERO;
value = rateQuotDecimal.multiply(new BigDecimal(qty));
BaseLogger.log("3", null, null,
"qty:: " + qty + " rateQuot:: " + rateQuotDecimal + " value:: " + value);
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing values: " + e.getMessage());
}
String domId = checkNull(genericUtility.getColumnValue("domid", dom));
BaseLogger.log("3", null, null, "domId::>>" + domId);
String domIDStr = checkNull(getDomID(dom, "" + currentFormNo));
System.out.println("domID in actual itemchanged>>>>" + domIDStr);
valueXmlString.append( "<Detail"+ objContext+" domID='"+1+"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" );
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n" );
// Comment out the rate_quot validation block as this case handled by JS
valueXmlString.append("<value protect='1'><![CDATA[" + value + "]]></value>\r\n");
setNodeValue(dom, "value", value.toString()); // Added In 1389
valueXmlString.append("</Detail" + objContext + ">");
BaseLogger.log("3", null, null, "Item change valueXmlString::"+valueXmlString.toString());
}
if ("rate_quot".equalsIgnoreCase(currentColumn.trim())) { if ("rate_quot".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", null, null, "ReqForQuotationWiz in rate_quot ::"); BaseLogger.log("3", null, null, "ReqForQuotationWiz in rate_quot ::");
String rateQuot = genericUtility.getColumnValue("rate_quot", dom); String rateQuot = genericUtility.getColumnValue("rate_quot", dom);
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom)); String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String rateApprv = checkNull(genericUtility.getColumnValue("rate_apprv", dom)); String rateApprv = checkNull(genericUtility.getColumnValue("rate_apprv", dom));
String ratePtr = checkNull(genericUtility.getColumnValue("ptr", dom)); String ratePtr = checkNull(genericUtility.getColumnValue("ptr", dom));
String quantity = checkNull(genericUtility.getColumnValue("qty_quot", dom));
int rateQuotInt = 0; //Comment out the rate_quot validation block as this case handled by JS[Start]
int quantityInt = 0;
int values = 0; String rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot",
dom)); String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot",
dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr+" quantity::"+quantity);
int qty = 0;
BigDecimal rateQuotDecimal = BigDecimal.ZERO;
BigDecimal value = BigDecimal.ZERO;
BaseLogger.log("3", null, null, "ReqForQuotationWiz qtyStr:: " + qtyStr);
BaseLogger.log("3", null, null, "ReqForQuotationWiz rateQuotStr:: " + rateQuotStr);
try { try {
rateQuotInt = (rateQuot != null && rateQuot.trim().length() > 0) ? Integer.parseInt(rateQuot.trim()) : 0; qty = (qtyStr != null && qtyStr.trim().length() > 0)
quantityInt = (quantity != null && quantity.trim().length() > 0) ? Integer.parseInt(quantity.trim()) : 0; ? Integer.parseInt(qtyStr.trim())
values = rateQuotInt*quantityInt; : 0;
rateQuotDecimal = (rateQuotStr != null && rateQuotStr.trim().length() > 0)
? new BigDecimal(rateQuotStr.trim())
: BigDecimal.ZERO;
value = rateQuotDecimal.multiply(new BigDecimal(qty));
BaseLogger.log("3", null, null,
"qty:: " + qty + " rateQuot:: " + rateQuotDecimal + " value:: " + value);
} catch (Exception e) { } catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing String to Int values:: "+e.getMessage()); BaseLogger.log("3", null, null, "Error parsing values: " + e.getMessage());
} }
BaseLogger.log("3", null, null, "values:: "+values);
//Comment out the rate_quot validation block as this case handled by JS[End]
BaseLogger.log("3", null, null, "ReqForQuotationIC in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr+" itemCode::"+itemCode);
BaseLogger.log("3", null, null, "ReqForQuotationWiz in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr);
if (!rateQuot.isEmpty() && !rateApprv.isEmpty()) { if (!rateQuot.isEmpty() && !rateApprv.isEmpty()) {
BigDecimal rateApprvVal = new BigDecimal(rateApprv); BigDecimal rateApprvVal = new BigDecimal(rateApprv);
...@@ -1329,14 +1674,14 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1329,14 +1674,14 @@ public class ReqForQuotationWiz extends ValidatorEJB{
String stockMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_14")); String stockMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_14"));
String retailMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_15")); String retailMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_15"));
int distMargin = 0; BigDecimal distMargin = BigDecimal.ZERO;
int stockMargin = 0; BigDecimal stockMargin = BigDecimal.ZERO;
int retailMargin = 0; BigDecimal retailMargin = BigDecimal.ZERO;
try { try {
distMargin = (distMarginStr != null && distMarginStr.trim().length() > 0) ? Integer.parseInt(distMarginStr.trim()) : 0; distMargin = (distMarginStr != null && distMarginStr.trim().length() > 0) ? new BigDecimal(distMarginStr.trim()) : BigDecimal.ZERO;
stockMargin = (stockMarginStr != null && stockMarginStr.trim().length() > 0) ? Integer.parseInt(stockMarginStr.trim()) : 0; stockMargin = (stockMarginStr != null && stockMarginStr.trim().length() > 0) ? new BigDecimal(stockMarginStr.trim()) : BigDecimal.ZERO;
retailMargin = (retailMarginStr != null && retailMarginStr.trim().length() > 0) ? Integer.parseInt(retailMarginStr.trim()) : 0; retailMargin = (retailMarginStr != null && retailMarginStr.trim().length() > 0) ? new BigDecimal(retailMarginStr.trim()) : BigDecimal.ZERO;
} catch (Exception e) { } catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing margin values"); BaseLogger.log("3", null, null, "Error parsing margin values");
} }
...@@ -1344,24 +1689,45 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1344,24 +1689,45 @@ public class ReqForQuotationWiz extends ValidatorEJB{
BigDecimal rateBD = new BigDecimal(rateQuot); BigDecimal rateBD = new BigDecimal(rateQuot);
BigDecimal hundred = new BigDecimal(100); BigDecimal hundred = new BigDecimal(100);
BigDecimal retailMarginBD = new BigDecimal(retailMargin); // BigDecimal retailMarginBD = new BigDecimal(retailMargin);
BigDecimal stockMarginBD = new BigDecimal(stockMargin); // BigDecimal stockMarginBD = new BigDecimal(stockMargin);
BigDecimal distMarginBD = new BigDecimal(distMargin); // BigDecimal distMarginBD = new BigDecimal(distMargin);
BaseLogger.log("3", null, null, "distMargin::" + distMargin + " stockMargin::" + stockMargin + " revisedPtd:: " + retailMargin + "rate:: " + rate + "]"); BaseLogger.log("3", null, null, "distMargin::" + distMargin + " stockMargin::" + stockMargin + " revisedPtd:: " + retailMargin + "rate:: " + rate + "]");
BigDecimal revisedPtr = rateBD.divide(hundred.multiply(hundred.subtract(retailMarginBD)), 6, RoundingMode.HALF_UP); BigDecimal revisedPtr = rateBD.divide(hundred.multiply(hundred.subtract(retailMargin)), 6, RoundingMode.HALF_UP);
BigDecimal revisedPts = rateBD.divide(hundred.multiply(hundred.subtract(stockMarginBD)), 6, RoundingMode.HALF_UP); BigDecimal revisedPts = rateBD.divide(hundred.multiply(hundred.subtract(stockMargin)), 6, RoundingMode.HALF_UP);
BigDecimal revisedPtd = rateBD.divide(hundred.multiply(hundred.subtract(distMarginBD)), 6, RoundingMode.HALF_UP); BigDecimal revisedPtd = rateBD.divide(hundred.multiply(hundred.subtract(distMargin)), 6, RoundingMode.HALF_UP);
BaseLogger.log("3", null, null, "revisedPtr::" + revisedPtr + " revisedPts::" + revisedPts + " revisedPtd::" + revisedPtd); BaseLogger.log("3", null, null, "revisedPtr::" + revisedPtr + " revisedPts::" + revisedPts + " revisedPtd::" + revisedPtd);
BaseLogger.log("3", null, null, "revisedPtr::" + revisedPtr + " revisedPts::" + revisedPts + " revisedPtd:: " + revisedPtd + "]"); BaseLogger.log("3", null, null, "revisedPtr::" + revisedPtr + " revisedPts::" + revisedPts + " revisedPtd:: " + revisedPtd + "]");
valueXmlString.append("<revised_ptr>").append("<![CDATA[" + revisedPtr + "]]>").append("</revised_ptr>\r\n"); String domId = checkNull(genericUtility.getColumnValue("domid", dom));
valueXmlString.append("<revised_pts>").append("<![CDATA[" + revisedPts + "]]>").append("</revised_pts>\r\n");
valueXmlString.append("<revised_ptd>").append("<![CDATA[" + revisedPtd + "]]>").append("</revised_ptd>\r\n"); BaseLogger.log("3", null, null, "domId::>>"+domId);
valueXmlString.append("<value>").append("<![CDATA[" + values + "]]>").append("</value>\r\n"); String domIDStr=checkNull(getDomID(dom, ""+currentFormNo));
System.out.println("domID in actual itemchanged>>>>"+domIDStr);
valueXmlString.append("<Detail" + objContext + " domID='" + domId + "' objContext='" + currentFormNo + "' objName=\"rfq_wiz\" selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n");
valueXmlString.append("<revised_ptr><![CDATA[" + revisedPtr + "]]></revised_ptr>\r\n");
setNodeValue(dom, "revised_ptr", revisedPtr.toString()); // Added In 1389
valueXmlString.append("<revised_pts><![CDATA[" + revisedPts + "]]></revised_pts>\r\n");
setNodeValue(dom, "revised_pts", revisedPts.toString()); // Added In 1389
valueXmlString.append("<revised_ptd><![CDATA[" + revisedPtd + "]]></revised_ptd>\r\n");
setNodeValue(dom, "revised_ptd", revisedPtd.toString()); // Added In 1389
//Comment out the rate_quot validation block as this case handled by JS
valueXmlString.append("<value protect='1'><![CDATA[" + value + "]]></value>\r\n");
setNodeValue(dom, "value", value.toString()); // Added In 1389
valueXmlString.append("</Detail" + objContext + ">");
} }
...@@ -1387,7 +1753,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1387,7 +1753,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
}//end try itemchange }//end try itemchange
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :StrgBrandactwiz :defaultDataWiz(Document,String):" + e.getMessage() + ":" ); BaseLogger.log("3", null, null, "Exception 1746. [" + E12GenericUtility.getStackTrace(e) + "]");
valueXmlString = valueXmlString.append( genericUtility.createErrorString( e ) ); valueXmlString = valueXmlString.append( genericUtility.createErrorString( e ) );
}//end catch itemchange }//end catch itemchange
finally finally
...@@ -1422,6 +1788,20 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1422,6 +1788,20 @@ public class ReqForQuotationWiz extends ValidatorEJB{
return valueXmlString.toString(); return valueXmlString.toString();
} }
private static void setNodeValue(Document dom, String nodeName, String nodeVal) throws Exception {
Node tempNode = dom.getElementsByTagName(nodeName).item(0);
if (tempNode != null) {
if (tempNode.getFirstChild() == null) {
CDATASection cDataSection = dom.createCDATASection(nodeVal);
tempNode.appendChild(cDataSection);
} else {
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
private String getDomID(Document dom2,String objContext) private String getDomID(Document dom2,String objContext)
{ {
Node elementName = null, parentNode = null; Node elementName = null, parentNode = null;
......
...@@ -4,89 +4,76 @@ rfq_wiz.globalObjName = 'rfq_wiz'; ...@@ -4,89 +4,76 @@ rfq_wiz.globalObjName = 'rfq_wiz';
//alert("zzz Inside rfq_wiz js file loaded successfully!") //alert("zzz Inside rfq_wiz js file loaded successfully!")
console.log("Inside rfq_wiz js file loaded successfully!"); console.log("Inside rfq_wiz js file loaded successfully!");
function wfValData(hdrFormXml, currFormXml, objContext, action, objName, allFormXmlData) function wfValData(hdrFormXml, currFormXml, objContext, action, objName, allFormXmlData) {
{
//alert('zzz inside wfValData function'); //alert('zzz inside wfValData function');
console.log('inside wfValData function in js file'); console.log('inside wfValData function in js file');
return true; return true;
} }
function valData(objContext, action, objName, currentFormData, objFormName) function valData(objContext, action, objName, currentFormData, objFormName) {
{
//alert('zzz inside valData function'); //alert('zzz inside valData function');
console.log('inside valData function in js file'); console.log('inside valData function in js file');
return true; return true;
} }
//called in offline mode //called in offline mode
function localWfValData(hdrFormXml, currFormXml, objContext, action, objName, allFormXmlData) function localWfValData(hdrFormXml, currFormXml, objContext, action, objName, allFormXmlData) {
{
//alert('zzz inside localWfValData function'); //alert('zzz inside localWfValData function');
var isValidWfData = true; var isValidWfData = true;
console.log('inside localWfValData function in js file **************************'); console.log('inside localWfValData function in js file **************************');
return isValidWfData; return isValidWfData;
} }
function localValData(objContext, action, objName, currentFormData, objFormName) function localValData(objContext, action, objName, currentFormData, objFormName) {
{
//alert('zzz inside localValData function'); //alert('zzz inside localValData function');
var isValidData = true; var isValidData = true;
console.log('objName is'+objName); console.log('objName is' + objName);
console.log('objFormName is'+objFormName); console.log('objFormName is' + objFormName);
console.log('objContext is'+objContext); console.log('objContext is' + objContext);
console.log('action is'+action); console.log('action is' + action);
console.log('inside localValData function in js file **************************'+currentFormData); console.log('inside localValData function in js file **************************' + currentFormData);
var currentFormData=currentFormData; var currentFormData = currentFormData;
var action=action; var action = action;
var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>"); var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
if(currentFormData != null && currentFormData.trim().length > 0) if (currentFormData != null && currentFormData.trim().length > 0) {
{ console.log("cureentform data is not null" + currentFormData);
console.log("cureentform data is not null"+currentFormData);
if(xmlVersion == 0) if (xmlVersion == 0) {
{
//console.log("inside if"); //console.log("inside if");
currentFormData = currentFormData; currentFormData = currentFormData;
} }
else else {
{
//console.log("inside else"); //console.log("inside else");
currentFormData = "<Root>"+currentFormData+"</Root>"; currentFormData = "<Root>" + currentFormData + "</Root>";
} }
} }
else else {
{
console.log("null currentformdata"); console.log("null currentformdata");
} }
if (window.DOMParser) if (window.DOMParser) {
{
//alert("inside window.DOMParser"); //alert("inside window.DOMParser");
parser=new DOMParser(); parser = new DOMParser();
try try {
{ if (currentFormData != null && currentFormData.trim().length > 0) {
if(currentFormData != null && currentFormData.trim().length > 0) xmlDoc = parser.parseFromString(currentFormData, "text/xml");
{
xmlDoc = parser.parseFromString(currentFormData,"text/xml");
//console.log("xmlDoc =["+xmlDoc+"]"); //console.log("xmlDoc =["+xmlDoc+"]");
} }
} }
catch(ex) catch (ex) {
{
alert("Exception occurs while parsing xml data"); alert("Exception occurs while parsing xml data");
} }
} }
else // Internet Explorer else // Internet Explorer
{ {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false; xmlDoc.async = false;
xmlDoc.loadXML(txt); xmlDoc.loadXML(txt);
} }
if(xmlDoc != null ) if (xmlDoc != null) {
{
if (objName === 'rfq_wiz') { if (objName === 'rfq_wiz') {
if (objContext === '2') { if (objContext === '2') {
...@@ -94,7 +81,7 @@ function localValData(objContext, action, objName, currentFormData, objFormName) ...@@ -94,7 +81,7 @@ function localValData(objContext, action, objName, currentFormData, objFormName)
console.log("Form Name :: [" + objName + "]"); console.log("Form Name :: [" + objName + "]");
console.log("Object Context :: [" + objContext + "]"); console.log("Object Context :: [" + objContext + "]");
var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext); var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext);
console.log("Total Detail Elements Found :: [" + detailElement.length + "]"); console.log("Total Detail Elements Found :: [" + detailElement.length + "]");
for (var i = 0; i < detailElement.length; i++) { for (var i = 0; i < detailElement.length; i++) {
...@@ -112,6 +99,8 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext); ...@@ -112,6 +99,8 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext);
var competitorRate = ""; var competitorRate = "";
var competitorName = ""; var competitorName = "";
var competitorItem = ""; var competitorItem = "";
var ptrFlag = "";
// rate_quot // rate_quot
if (detail.getElementsByTagName("rate_quot")[0] != null && if (detail.getElementsByTagName("rate_quot")[0] != null &&
...@@ -141,10 +130,17 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext); ...@@ -141,10 +130,17 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext);
competitorItem = detail.getElementsByTagName("competitor_item")[0].childNodes[0].nodeValue; competitorItem = detail.getElementsByTagName("competitor_item")[0].childNodes[0].nodeValue;
} }
if (detail.getElementsByTagName("ptr_flag")[0] != null &&
detail.getElementsByTagName("ptr_flag")[0].childNodes[0] != null) {
ptrFlag = detail.getElementsByTagName("ptr_flag")[0].childNodes[0].nodeValue;
}
console.log("rate_quot :: [" + rateQuot + "]"); console.log("rate_quot :: [" + rateQuot + "]");
console.log("competitor_rate :: [" + competitorRate + "]"); console.log("competitor_rate :: [" + competitorRate + "]");
console.log("competitor_name :: [" + competitorName + "]"); console.log("competitor_name :: [" + competitorName + "]");
console.log("competitor_item :: [" + competitorItem + "]"); console.log("competitor_item :: [" + competitorItem + "]");
console.log("ptrFlag :: [" + ptrFlag + "]");
// ===== Existing rate validation ===== // ===== Existing rate validation =====
if (rateQuot == null) { if (rateQuot == null) {
...@@ -165,7 +161,7 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext); ...@@ -165,7 +161,7 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext);
} }
// ===== NEW VALIDATION ===== // ===== NEW VALIDATION =====
if (Number(rateQuot) > 0) { if (Number(rateQuot) > 0 && ptrFlag == "N" || ptrFlag.trim().length == 0) {
if ( if (
competitorRate == null || competitorRate.trim().length == 0 || competitorRate == null || competitorRate.trim().length == 0 ||
...@@ -180,35 +176,31 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext); ...@@ -180,35 +176,31 @@ var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext);
} }
console.log(" Valid row :: [" + i + "]"); console.log(" Valid row :: [" + i + "]");
} else { } else {
console.log("Skipping row [" + i + "] as updateFlag is D (Deleted)"); console.log("Skipping row [" + i + "] as updateFlag is D (Deleted)");
} }
} }
console.log("=== RFQ_WIZ VALIDATION END ==="); console.log("=== RFQ_WIZ VALIDATION END ===");
} }
} }
} }
return isValidData; return isValidData;
} }
function localAutoNumberChange(editorObjName, currentFormNo, offlineRefVal, freeFormDataMap, fldName, fldValue, maxDomValue , isDoneSucess) function localAutoNumberChange(editorObjName, currentFormNo, offlineRefVal, freeFormDataMap, fldName, fldValue, maxDomValue, isDoneSucess) {
{
//alert('zzz inside localAutoNumberChange function'); //alert('zzz inside localAutoNumberChange function');
console.log('inside localAutoNumberChange function in js file **************************'); console.log('inside localAutoNumberChange function in js file **************************');
var checkitemchangeData = 1; var checkitemchangeData = 1;
console.log("Testing editorObjName ["+editorObjName+"] currentFormNo ["+currentFormNo+"] offlineRefVal ["+offlineRefVal+"] fldName ["+fldName+"] freeFormDataMap ["+freeFormDataMap+"] fldValue ["+fldValue+"] maxDomValue ["+maxDomValue+"] isDoneSucess ["+isDoneSucess+"]"); console.log("Testing editorObjName [" + editorObjName + "] currentFormNo [" + currentFormNo + "] offlineRefVal [" + offlineRefVal + "] fldName [" + fldName + "] freeFormDataMap [" + freeFormDataMap + "] fldValue [" + fldValue + "] maxDomValue [" + maxDomValue + "] isDoneSucess [" + isDoneSucess + "]");
if( maxDomValue != "" && maxDomValue.length > 0 ) if (maxDomValue != "" && maxDomValue.length > 0) {
{ console.log("Testing maxDomValue [" + maxDomValue + "]");
console.log("Testing maxDomValue ["+maxDomValue+"]"); if (isDoneSucess) {
if( isDoneSucess ) checkitemchangeData = parseInt(maxDomValue) + 1;
{
checkitemchangeData = parseInt(maxDomValue)+1;
} }
else else {
{ checkitemchangeData = parseInt(maxDomValue) - 1;
checkitemchangeData = parseInt(maxDomValue)-1;
} }
} }
/*if( fldValue != "" && fldValue.length > 0 ) /*if( fldValue != "" && fldValue.length > 0 )
...@@ -223,155 +215,112 @@ function localAutoNumberChange(editorObjName, currentFormNo, offlineRefVal, free ...@@ -223,155 +215,112 @@ function localAutoNumberChange(editorObjName, currentFormNo, offlineRefVal, free
checkitemchangeData = parseInt(fldValue)-1; checkitemchangeData = parseInt(fldValue)-1;
} }
}*/ }*/
console.log("Testing final fldValue ["+fldValue+"] checkitemchangeData ["+checkitemchangeData+"]"); console.log("Testing final fldValue [" + fldValue + "] checkitemchangeData [" + checkitemchangeData + "]");
return checkitemchangeData; return checkitemchangeData;
} }
function localItemChange(objContext, action, objName, currentFormData, fieldName, domId, objFormName, fieldValue, parentFormNo, parentDomID, buttonId, prevValue, itemCode, allFormDetaildata, dataModelJson) { function localItemChange(objContext, action, objName, currentFormData, fieldName, domId, objFormName, fieldValue, parentFormNo, parentDomID, buttonId, prevValue, itemCode, allFormDetaildata, dataModelJson) {
//alert('zzz inside localItemChange function'); //alert('zzz inside localItemChange function');
console.log("inside localItemChange"+objFormName +"action::"+action + "domId:::"+domId + "fieldName:::"+fieldName); console.log("inside localItemChange" + objFormName + "action::" + action + "domId:::" + domId + "fieldName:::" + fieldName);
var isItemchangeData = ""; var isItemchangeData = "";
var retString = ""; var retString = "";
// var orderMap = new Map(); // var orderMap = new Map();
var domArr = []; var domArr = [];
var orderArr = []; var orderArr = [];
console.log("dataModelJson::"+dataModelJson); console.log("dataModelJson::" + dataModelJson);
console.log('inside localItemChange function in js file **************************'); console.log('inside localItemChange function in js file **************************');
var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>"); var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
//console.log("xmlVersion is : "+xmlVersion) //console.log("xmlVersion is : "+xmlVersion)
if(currentFormData != null && currentFormData.trim().length > 0) if (currentFormData != null && currentFormData.trim().length > 0) {
{ console.log("cureentform data is not null" + currentFormData);
console.log("cureentform data is not null"+currentFormData);
if(xmlVersion == 0) if (xmlVersion == 0) {
{
//console.log("inside if"); //console.log("inside if");
currentFormData = currentFormData; currentFormData = currentFormData;
} }
else else {
{
//console.log("inside else"); //console.log("inside else");
currentFormData = "<Root>"+currentFormData+"</Root>"; currentFormData = "<Root>" + currentFormData + "</Root>";
} }
} }
else else {
{
console.log("null currentformdata"); console.log("null currentformdata");
} }
if (window.DOMParser) if (window.DOMParser) {
{
//alert("inside window.DOMParser"); //alert("inside window.DOMParser");
parser=new DOMParser(); parser = new DOMParser();
try try {
{ if (currentFormData != null && currentFormData.trim().length > 0) {
if(currentFormData != null && currentFormData.trim().length > 0) xmlDoc = parser.parseFromString(currentFormData, "text/xml");
{
xmlDoc = parser.parseFromString(currentFormData,"text/xml");
//console.log("xmlDoc =["+xmlDoc+"]"); //console.log("xmlDoc =["+xmlDoc+"]");
} }
} }
catch(ex) catch (ex) {
{
alert("Exception occurs while parsing xml data"); alert("Exception occurs while parsing xml data");
} }
} }
else // Internet Explorer else // Internet Explorer
{ {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false; xmlDoc.async = false;
xmlDoc.loadXML(txt); xmlDoc.loadXML(txt);
} }
if(xmlDoc != null ) if (xmlDoc != null) {
{
if(objContext == 3)
{
// console.log("in place action is"+action +"::"+ objContext);
if(action == 'itemchange' && fieldName == 'deselect')
{
// console.log("in place cureentform data is ::"+currentFormData);
var orderVisit = "";
var orderDomId = "";
var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
for (var i = 0; i < detailElement.length; i++)
{
var detail = detailElement[i];
var attributeVal = detail.getAttribute("selected");
// console.log("attributeVal is"+attributeVal);
//console.log("inside detailElement"+detail);
if( detail.getElementsByTagName("order_of_visit")[0] != null && detail.getElementsByTagName("order_of_visit")[0].childNodes[0] != null && attributeVal != null && attributeVal == 'Y')
{
orderVisit = detail.getElementsByTagName("order_of_visit")[0].childNodes[0].nodeValue;
// console.log("order_of_visit is:"+orderVisit);
orderDomId = detail.getAttribute("domID");
// console.log("orderDomId is:"+orderDomId);
/*orderMap.set(orderVisit, orderDomId);
console.log("map is:"+orderMap);*/
domArr.push(orderDomId);
orderArr.push(orderVisit);
}
}
var visitNo = 1;
retString = "<Root><Detail3>";
/*orderMap.forEach(function (item, key, mapObj) {
console.log(item.toString());
if(item.toString() != domId)
{
retString = retString + "<Detail2_SEP1_"+item.toString() +"_SEP1_order_of_visit><![CDATA["+ visitNo +"]]></Detail2_SEP1_"+item.toString() +"_SEP1_order_of_visit>"
visitNo++
}
}); */ if (objContext == 2) {
if (fieldName === 'quot_qty') {
console.log("In quot_qty condition" );
for(var i = 0; i < domArr.length; i++) var quantity = 0;
{ var rateQuot = 0;
if(domArr[i] != domId) var value = 0;
{
retString = retString + "<Detail3_SEP1_"+ domArr[i] +"_SEP1_order_of_visit><![CDATA["+ visitNo +"]]></Detail3_SEP1_"+ domArr[i] +"_SEP1_order_of_visit>" var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext);
visitNo++
} for (var i = 0; i < detailElement.length; i++) {
}
retString = retString + "</Detail3></Root>";
console.log("outside map::::"+retString);
}
isItemchangeData = retString;
}
else if(objContext == 1)
{
if( fieldName === 'activity_code' || fieldName === 'event_date')
{
//console.log("fieldName is"+fieldName);
var activityType="";
var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
for (var i = 0; i < detailElement.length; i++)
{
var detail = detailElement[i]; var detail = detailElement[i];
//console.log("inside detailElement"+detail);
if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null ) // Get quantity
{ if (detail.getElementsByTagName("quot_qty")[0] != null &&
activityType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue; detail.getElementsByTagName("quot_qty")[0].childNodes[0] != null) {
console.log("activity type is:"+activityType);
quantity = detail.getElementsByTagName("quot_qty")[0].childNodes[0].nodeValue;
console.log("quantity is: " + quantity);
} }
// Get rate
if (detail.getElementsByTagName("rate_quot")[0] != null &&
detail.getElementsByTagName("rate_quot")[0].childNodes[0] != null) {
rateQuot = detail.getElementsByTagName("rate_quot")[0].childNodes[0].nodeValue;
console.log("rateQuot is: " + rateQuot);
} }
if( activityType == 'NFW' || activityType == 'LEAVE')
{ // Convert and multiply
//console.log("inside if:"); var qtyNum = Number(quantity);
document.getElementById(buttonId).setAttribute("style", "opacity: 0.7; pointer-events :none;"); var rateNum = Number(rateQuot);
if (!isNaN(qtyNum) && !isNaN(rateNum)) {
value = qtyNum * rateNum;
} else {
value = 0;
} }
else
{ console.log("Calculated value :: " + value);
console.log("inside else:");
document.getElementById(buttonId).removeAttribute("style"); // Pass value into XML
itemChangeStr = "<Detail2><value protect='1' visible='1'>" + value + "</value></Detail2>";
} }
} }
} }
} }
return isItemchangeData; return itemChangeStr;
} }
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