Commit abb07375 authored by Mohammed Dohadwala's avatar Mohammed Dohadwala

Added validation to prevent negative quantity and rate in RFQ (IC & Wiz)

parent 47d87bf2
...@@ -447,6 +447,18 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -447,6 +447,18 @@ public class ReqForQuotationIC extends ValidatorEJB {
} }
} }
// Mohammed.D 21-04-2026 added validition to check for negetive quantity value
if(childNodeName.equalsIgnoreCase("qty_quot"))
{
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
int qtyVal = (qtyStr == null || qtyStr.trim().length() == 0) ? 0 : Integer.parseInt(qtyStr.trim());
if(qtyVal < 0)
{
errString = getErrorString("qty_quot", "VTQTYN", userId);
break;
}
}
if( childNodeName.equalsIgnoreCase("rate_quot") ) if( childNodeName.equalsIgnoreCase("rate_quot") )
{ {
String phyAttrVal = ""; String phyAttrVal = "";
...@@ -657,6 +669,10 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -657,6 +669,10 @@ public class ReqForQuotationIC extends ValidatorEJB {
String priceList = ""; String priceList = "";
int rate= 0; int rate= 0;
String finEntity = ""; String finEntity = "";
double updatedDistMargin = 0, updatedStkMargin=0, updatedRetMargin=0;
String phy13 = "";
String phy14 = "";
String phy15 = "";
List<String> itemCodeList = new ArrayList<>(); List<String> itemCodeList = new ArrayList<>();
try { try {
...@@ -825,7 +841,8 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -825,7 +841,8 @@ public class ReqForQuotationIC extends ValidatorEJB {
case 2: case 2:
{ {
valueXmlString.append("<Detail2>"); valueXmlString.append("<Detail2>");
if ("itm_default".equalsIgnoreCase(currentColumn.trim())) { if ("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default "); BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default ");
//Management rate block[Start] //Management rate block[Start]
...@@ -957,13 +974,51 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -957,13 +974,51 @@ public class ReqForQuotationIC extends ValidatorEJB {
rs.close(); rs.close();
psPriceList.close(); psPriceList.close();
} }
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String phySql = "SELECT PHY_ATTRIB_13, PHY_ATTRIB_14, PHY_ATTRIB_15 FROM ITEM WHERE ITEM_CODE = ?";
PreparedStatement phyPs = con.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 (phy13.equalsIgnoreCase(""))
{
valueXmlString.append("<phy_attrib_13><![CDATA[0]]></phy_attrib_13>\r\n");
}
else
{
valueXmlString.append("<phy_attrib_13><![CDATA[" + phy13 + "]]></phy_attrib_13>\r\n");
}
if (phy14.equalsIgnoreCase(""))
{
valueXmlString.append("<phy_attrib_14><![CDATA[0]]></phy_attrib_14>\r\n");
}
else
{
valueXmlString.append("<phy_attrib_14><![CDATA[" + phy14 + "]]></phy_attrib_14>\r\n");
}
if (phy15.equalsIgnoreCase(""))
{
valueXmlString.append("<phy_attrib_15><![CDATA[0]]></phy_attrib_15>\r\n");
}
else
{
valueXmlString.append("<phy_attrib_15><![CDATA[" + phy15 + "]]></phy_attrib_15>\r\n");
}
//PTR calculation end //PTR calculation end
valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n"); valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n");
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");
...@@ -972,17 +1027,43 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -972,17 +1027,43 @@ public class ReqForQuotationIC extends ValidatorEJB {
//Management rate block[End] //Management rate block[End]
} }
if ("itm_defaultedit".equalsIgnoreCase(currentColumn.trim())) { if ("itm_defaultedit".equalsIgnoreCase(currentColumn.trim()))
{
BaseLogger.log("3", null, null, "==== EDIT MODE TRIGGERED ====");
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
String ptrFlagForEdit = checkNull(genericUtility.getColumnValue("ptr_flag", dom)); String ptrFlagForEdit = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
String rateQuot = checkNull(genericUtility.getColumnValue("rate_quot", dom)); String rateQuot = checkNull(genericUtility.getColumnValue("rate_quot", dom));
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String unit = checkNull(genericUtility.getColumnValue("unit", dom));
String packCode = checkNull(genericUtility.getColumnValue("pack_code", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default edit itemCode::"+itemCode);
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default edit ptrFlagForEdit::"+ptrFlagForEdit); BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default edit ptrFlagForEdit::"+ptrFlagForEdit);
BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default edit rateQuot::"+rateQuot); BaseLogger.log("3", null, null, "ReqForQuotationIC in itm default edit rateQuot::"+rateQuot);
String phySql = "SELECT PHY_ATTRIB_13, PHY_ATTRIB_14, PHY_ATTRIB_15 FROM ITEM WHERE ITEM_CODE = ?";
PreparedStatement phyPs = con.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"));
}
if(ptrFlagForEdit.equalsIgnoreCase("Y")) { phyRs.close();
valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA["+rateQuot+"]]>").append("</rate_quot>\r\n"); 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(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 // Set sp_name to logged in user's name
valueXmlString.append("<sp_name>").append("<![CDATA[" + userName + "]]>").append("</sp_name>\r\n"); valueXmlString.append("<sp_name>").append("<![CDATA[" + userName + "]]>").append("</sp_name>\r\n");
...@@ -1109,24 +1190,87 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -1109,24 +1190,87 @@ public class ReqForQuotationIC extends ValidatorEJB {
rs = psPriceList.executeQuery(); rs = psPriceList.executeQuery();
if (rs.next()) { if (rs.next()) { }
rate = rs.getInt("RATE");
}
rs.close(); rs.close();
psPriceList.close(); psPriceList.close();
} }
//PTR calculation end //PTR calculation end
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");
valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n"); valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n");
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");
valueXmlString.append("<ptr_flag>").append("<![CDATA["+ptrFlagForEdit+"]]>").append("</ptr_flag>\r\n");
//Added By Saburi - 16Apr2026 for calculation of PTR,PTS,PTD
if (rateQuot != null && !rateQuot.trim().isEmpty() && phy13 != null && !phy13.trim().isEmpty() && phy14 != null && !phy14.trim().isEmpty() && phy15 != null && !phy15.trim().isEmpty())
{
try
{
BigDecimal specialRate = new BigDecimal(rateQuot);
BigDecimal hundred = new BigDecimal("100");
BigDecimal distMargin = new BigDecimal(phy13);
BigDecimal stockMargin = new BigDecimal(phy14);
BigDecimal retMargin = new BigDecimal(phy15);
BigDecimal revisedPTR = specialRate.multiply(hundred.subtract(retMargin)).divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPTS = specialRate.multiply(hundred.subtract(stockMargin)).divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPTD = specialRate.multiply(hundred.subtract(distMargin)).divide(hundred, 2, RoundingMode.HALF_UP);
BaseLogger.log("3", null, null, "Revised PTR:>>>>> " + revisedPTR);
BaseLogger.log("3", null, null, "Revised PTS:>>>>> " + revisedPTS);
BaseLogger.log("3", null, null, "Revised PTD:>>>>> " + revisedPTD);
valueXmlString.append("<revised_ptr><![CDATA[").append(revisedPTR).append("]]></revised_ptr>\r\n");
valueXmlString.append("<revised_pts><![CDATA[").append(revisedPTS).append("]]></revised_pts>\r\n");
valueXmlString.append("<revised_ptd><![CDATA[").append(revisedPTD).append("]]></revised_ptd>\r\n");
BaseLogger.log("3", null, null, "✅ Edit Mode Calculation Done PTR=" + revisedPTR);
}
catch (Exception e)
{
BaseLogger.log("3", null, null, "❌ Calculation Error: " + e.getMessage());
}
}
//Management rate block[End] //Management rate block[End]
} }
if ("item_code".equalsIgnoreCase(currentColumn.trim())) { 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 itemDescr = "";
String unit = ""; String unit = "";
String packCode = ""; String packCode = "";
...@@ -1141,71 +1285,209 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -1141,71 +1285,209 @@ public class ReqForQuotationIC extends ValidatorEJB {
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-14APR
valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>\r\n"); valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>\r\n");
valueXmlString.append("<unit protect='1'>").append("<![CDATA["+unit+"]]>").append("</unit>\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"); valueXmlString.append("<pack_code protect='1'>").append("<![CDATA["+packCode+"]]>").append("</pack_code>\r\n");
}
String phySql = "SELECT PHY_ATTRIB_13, PHY_ATTRIB_14, PHY_ATTRIB_15 FROM ITEM WHERE ITEM_CODE = ?";
if ("ptr_flag".equalsIgnoreCase(currentColumn.trim())) { PreparedStatement phyPs = con.prepareStatement(phySql);
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flag "); phyPs.setString(1, itemCode);
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); ResultSet phyRs = phyPs.executeQuery();
String rateStr = checkNull(genericUtility.getColumnValue("ptr", dom));
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, "ReqForQuotationIC in ptr_flat condition:: "+ptrFlag); valueXmlString.append("<phy_attrib_13><![CDATA[" + phy13 + "]]></phy_attrib_13>\r\n");
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition siteCode:: "+siteCode); valueXmlString.append("<phy_attrib_14><![CDATA[" + phy14 + "]]></phy_attrib_14>\r\n");
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition custCode:: "+custCode); valueXmlString.append("<phy_attrib_15><![CDATA[" + phy15 + "]]></phy_attrib_15>\r\n");
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flat condition ptr:: "+rateStr); }
//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));
String itemCode = checkNull(genericUtility.getColumnValue("item_code", 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));
}
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")) { if(ptrFlag.equalsIgnoreCase("Y"))
{
BaseLogger.log("3", getUserInfo(), null, "Final RATE : " + rate); 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"); valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA["+rateStr+"]]>").append("</rate_quot>\r\n");
//Added By Saburi - 15Apr2026 for calculation pts,ptr,ptd
updatedDistMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_13", dom));
updatedStkMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_14", dom));
updatedRetMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_15", dom));
BaseLogger.log("3", null, null, "updatedDistMargin [" + updatedDistMargin + "]");
BaseLogger.log("3", null, null, "updatedStkMargin [" + updatedStkMargin + "]");
BaseLogger.log("3", null, null, "updatedRetMargin [" + updatedRetMargin + "]");
if (rateStr == null || rateStr.trim().isEmpty())
}else if(ptrFlag.equalsIgnoreCase("N")) { {
throw new Exception("Special Rate values are not defined for item: " + itemCode);
}
if ( updatedDistMargin == 0 || updatedStkMargin == 0 || updatedRetMargin == 0 )
{
valueXmlString.append("<phy_attrib_13><![CDATA[0]]></phy_attrib_13>\r\n");
valueXmlString.append("<phy_attrib_14><![CDATA[0]]></phy_attrib_14>\r\n");
valueXmlString.append("<phy_attrib_15><![CDATA[0]]></phy_attrib_15>\r\n");
}
BigDecimal specialRate = new BigDecimal(rateStr);
BigDecimal hundred = new BigDecimal("100");
BigDecimal distMargin = new BigDecimal(updatedDistMargin);
BigDecimal stockMargin = new BigDecimal(updatedStkMargin);
BigDecimal retMargin = new BigDecimal(updatedRetMargin);
// ✅ Correct calculation
BigDecimal revisedPTR = specialRate.multiply(hundred.subtract(retMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPTS = specialRate.multiply(hundred.subtract(stockMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPTD = specialRate.multiply(hundred.subtract(distMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
// ✅ Correct logs
BaseLogger.log("3", null, null, "FINAL revisedPTR [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTS [" + revisedPTS + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTD [" + revisedPTD + "]");
// ✅ Correct XML mapping
valueXmlString.append("<revised_ptr><![CDATA[").append(revisedPTR).append("]]></revised_ptr>\r\n");
valueXmlString.append("<revised_pts><![CDATA[").append(revisedPTS).append("]]></revised_pts>\r\n");
valueXmlString.append("<revised_ptd><![CDATA[").append(revisedPTD).append("]]></revised_ptd>\r\n");
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));
valueXmlString.append("<value>").append("<![CDATA[" + value + "]]>").append("</value>\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"); valueXmlString.append("<rate_quot protect='0'>").append("<![CDATA[]]>").append("</rate_quot>\r\n");
valueXmlString.append("<revised_ptr>").append("<![CDATA[]]>").append("</revised_ptr>\r\n");
valueXmlString.append("<revised_pts>").append("<![CDATA[]]>").append("</revised_pts>\r\n");
valueXmlString.append("<revised_ptd>").append("<![CDATA[]]>").append("</revised_ptd>\r\n");
valueXmlString.append("<value>").append("<![CDATA[]]>").append("</value>\r\n");
} }
} }
if ("rate_quot".equalsIgnoreCase(currentColumn.trim())) { if ("rate_quot".equalsIgnoreCase(currentColumn.trim()))
BaseLogger.log("3", null, null, "ReqForQuotationIC in rate_quot ::"); {
BaseLogger.log("3", null, null, "ReqForQuotationIC in rate_quot 1287::");
String rateQuot = checkNull(genericUtility.getColumnValue("rate_quot", dom)); String rateQuot = checkNull(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 qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom)); String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
String rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
int qty = 0; int qty = 0;
int rateQuotInt = 0; BigDecimal rateQuotDecimal = BigDecimal.ZERO;
int value = 0; 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 qtyStr:: " + qtyStr);
BaseLogger.log("3", null, null, try
"ReqForQuotationWiz in qty_quot condition rateQuotStr:: " + rateQuotStr); {
try { String quotedRate = checkNull(genericUtility.getColumnValue("rate_quot", dom));
updatedDistMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_13", dom));
updatedStkMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_14", dom));
updatedRetMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_15", dom));
BaseLogger.log("3", null, null, "updatedDistMargin [" + updatedDistMargin + "]");
BaseLogger.log("3", null, null, "updatedStkMargin [" + updatedStkMargin + "]");
BaseLogger.log("3", null, null, "updatedRetMargin [" + updatedRetMargin + "]");
if (quotedRate == null || quotedRate.trim().isEmpty())
{
throw new Exception("Special Rate values are not defined for item: " + itemCode);
}
if (updatedDistMargin == 0 ||updatedStkMargin == 0 || updatedRetMargin == 0 )
{
valueXmlString.append("<phy_attrib_13><![CDATA[0]]></phy_attrib_13>\r\n");
valueXmlString.append("<phy_attrib_14><![CDATA[0]]></phy_attrib_14>\r\n");
valueXmlString.append("<phy_attrib_15><![CDATA[0]]></phy_attrib_15>\r\n");
}
BigDecimal specialRate = new BigDecimal(quotedRate);
BigDecimal hundred = new BigDecimal("100");
BigDecimal distMargin = new BigDecimal(updatedDistMargin);
BigDecimal stockMargin = new BigDecimal(updatedStkMargin);
BigDecimal retMargin = new BigDecimal(updatedRetMargin);
// ✅ Correct Calculations as per requirement
BigDecimal revisedPTR = specialRate.multiply(hundred.subtract(retMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPTS = specialRate.multiply(hundred.subtract(stockMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPTD = specialRate.multiply(hundred.subtract(distMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
BaseLogger.log("3", null, null, "FINAL revisedPTR@@@@ [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTS @@@@@[" + revisedPTS + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTD@@@@ [" + revisedPTD + "]");
qty = (qtyStr != null && qtyStr.trim().length() > 0) ? Integer.parseInt(qtyStr.trim()) : 0; qty = (qtyStr != null && qtyStr.trim().length() > 0) ? Integer.parseInt(qtyStr.trim()) : 0;
rateQuotInt = (rateQuotStr != null && rateQuotStr.trim().length() > 0) rateQuotDecimal = (quotedRate != null && quotedRate.trim().length() > 0) ? new BigDecimal(quotedRate.trim()) : BigDecimal.ZERO;
? Integer.parseInt(rateQuotStr.trim()) value = rateQuotDecimal.multiply(new BigDecimal(qty));
: 0;
value = qty*rateQuotInt; valueXmlString.append("<value><![CDATA[").append(value).append("]]></value>\r\n");
valueXmlString.append("<revised_ptr><![CDATA[").append(revisedPTR).append("]]></revised_ptr>\r\n");
BaseLogger.log("3", null, null, "ReqForQuotationWiz in qty:: " + qty + " rateQuotInt::" valueXmlString.append("<revised_pts><![CDATA[").append(revisedPTS).append("]]></revised_pts>\r\n");
+ rateQuotInt + " value::" + value); valueXmlString.append("<revised_ptd><![CDATA[").append(revisedPTD).append("]]></revised_ptd>\r\n");
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing margin values"); 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);
BaseLogger.log("3", null, null, "ReqForQuotationIC in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr+" itemCode::"+itemCode);
if (!rateQuot.isEmpty() && !rateApprv.isEmpty()) { if (!rateQuot.isEmpty() && !rateApprv.isEmpty())
{
BigDecimal rateApprvVal = new BigDecimal(rateApprv); BigDecimal rateApprvVal = new BigDecimal(rateApprv);
BigDecimal rateQuotVal = new BigDecimal(rateQuot); BigDecimal rateQuotVal = new BigDecimal(rateQuot);
BigDecimal ratePtrVal = new BigDecimal(ratePtr); BigDecimal ratePtrVal = new BigDecimal(ratePtr);
// added condition when ptr and rate_quot is same direct approval without management // added condition when ptr and rate_quot is same direct approval without management
if (ratePtrVal.compareTo(rateQuotVal) == 0)
if (ratePtrVal.compareTo(rateQuotVal) == 0) { {
BaseLogger.log("3", null, null, "in ratePtrVal == rateQuotVal condition"); 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>"; String detail1Xml = "<Detail1><mgmnt_apprv><![CDATA[N]]></mgmnt_apprv><wf_status><![CDATA[A]]></wf_status></Detail1>";
...@@ -1220,7 +1502,8 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -1220,7 +1502,8 @@ public class ReqForQuotationIC extends ValidatorEJB {
"in rateApprvVal greater condition updatedXml ::" + valueXmlString); "in rateApprvVal greater condition updatedXml ::" + valueXmlString);
} }
if (rateApprvVal.compareTo(rateQuotVal) > 0) { if (rateApprvVal.compareTo(rateQuotVal) > 0)
{
BaseLogger.log("3", null, null, "in rateApprvVal greater condition"); BaseLogger.log("3", null, null, "in rateApprvVal greater condition");
BaseLogger.log("3", null, null, "in rateApprvVal greater condition valueXmlString::"+ valueXmlString); BaseLogger.log("3", null, null, "in rateApprvVal greater condition valueXmlString::"+ valueXmlString);
...@@ -1232,15 +1515,10 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -1232,15 +1515,10 @@ public class ReqForQuotationIC extends ValidatorEJB {
pos += "</header>".length(); // move after </header> pos += "</header>".length(); // move after </header>
valueXmlString.insert(pos, detail1Xml); valueXmlString.insert(pos, detail1Xml);
} }
BaseLogger.log("3", null, null, "in rateApprvVal greater condition updatedXml ::"+valueXmlString); BaseLogger.log("3", null, null, "in rateApprvVal greater condition updatedXml ::"+valueXmlString);
} }
if (rateQuotVal.compareTo(rateApprvVal) > 0)
{
if (rateQuotVal.compareTo(rateApprvVal) > 0) {
BaseLogger.log("3", null, null, "in rateQuotVal greater condition"); BaseLogger.log("3", null, null, "in rateQuotVal greater condition");
BaseLogger.log("3", null, null, "in rateQuotVal greater condition valueXmlString::"+ valueXmlString); BaseLogger.log("3", null, null, "in rateQuotVal greater condition valueXmlString::"+ valueXmlString);
...@@ -1254,75 +1532,8 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -1254,75 +1532,8 @@ public class ReqForQuotationIC extends ValidatorEJB {
} }
BaseLogger.log("3", null, null, "in rateApprvVal greater condition updatedXml ::"+valueXmlString); 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"); valueXmlString.append("</Detail2>\r\n");
break; break;
...@@ -1417,4 +1628,20 @@ public class ReqForQuotationIC extends ValidatorEJB { ...@@ -1417,4 +1628,20 @@ public class ReqForQuotationIC extends ValidatorEJB {
return false; return false;
} }
}
\ No newline at end of file private double parseDoubleSafe(String value)
{
try
{
if(value != null && value.trim().length() > 0)
{
return Double.parseDouble(value);
}
}
catch(Exception e)
{
BaseLogger.log("3", null, null, "Error parsing value: " + value);
}
return 0.0;
}
}
...@@ -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;
...@@ -404,10 +405,13 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -404,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)
{ {
...@@ -448,7 +452,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -448,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());
...@@ -468,7 +472,64 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -468,7 +472,64 @@ public class ReqForQuotationWiz extends ValidatorEJB{
checkItemCodePs = null; checkItemCodePs = null;
} }
} }
if(childNodeName.equalsIgnoreCase("qty_quot"))
{
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
double qtyVal = (qtyStr == null || qtyStr.trim().length() == 0) ? 0 : Double.parseDouble(qtyStr.trim());
if(qtyVal < 0)
{
errCode = "VTQTYN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if(childNodeName.equalsIgnoreCase("rate_quot"))
{
String rateStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
double rateVal = (rateStr == null || rateStr.trim().length() == 0) ? 0 : Double.parseDouble(rateStr.trim());
if(rateVal < 0)
{
errCode = "VTRATENEG";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
/*
* 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
/* /*
...@@ -486,6 +547,10 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -486,6 +547,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;
...@@ -563,6 +628,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -563,6 +628,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{
phyAttrValRs = null; 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") )
{ {
...@@ -822,9 +890,23 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -822,9 +890,23 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
System.out.println ( "returning from QCResultEntryWizIC default_Itemchanged" ); System.out.println ( "returning from QCResultEntryWizIC default_Itemchanged" );
return errString; return errString;
} }
private double parseDoubleSafe(String value)
{
try
{
if(value != null && value.trim().length() > 0)
{
return Double.parseDouble(value);
}
}
catch(Exception e)
{
BaseLogger.log("3", null, null, "Error parsing value: " + value);
}
return 0.0;
}
// public String itemChanged( Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException // public String itemChanged( Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
...@@ -863,7 +945,6 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -863,7 +945,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;
...@@ -886,6 +967,14 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -886,6 +967,14 @@ 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 = "";
// Added by Gagan B. on 14-APR-26: for shwoing revised PTR,PTS,PTD
double updatedDistMargin = 0;
double updatedStkMargin = 0;
double updatedRetMargin = 0;
String revisedPTR="", revisedPTD="", revisedPTS="";
try try
{ {
...@@ -929,7 +1018,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -929,7 +1018,7 @@ 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=\"rfq_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" );
...@@ -1294,6 +1383,36 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1294,6 +1383,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++;
...@@ -1314,25 +1433,54 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1314,25 +1433,54 @@ public class ReqForQuotationWiz extends ValidatorEJB{
packCode = checkNull(itemDescrRs.getString("pack_code")); packCode = checkNull(itemDescrRs.getString("pack_code"));
} }
//Added By Saburi
BaseLogger.log("3", null, null, "removed the line no from the itmdefault case " ); String phySql = "SELECT PHY_ATTRIB_13, PHY_ATTRIB_14, PHY_ATTRIB_15 FROM ITEM WHERE ITEM_CODE = ?";
PreparedStatement phyPs = conn.prepareStatement(phySql);
valueXmlString.append( "<Detail"+ objContext+" domID='"+domId +"' objContext = '"+currentFormNo+"' objName=\"rfq_wiz\" selected=\"N\">\r\n" ); phyPs.setString(1, itemCode);
valueXmlString.append( "<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"tran_id:line_no\"/>\r\n" ); ResultSet phyRs = phyPs.executeQuery();
valueXmlString.append( "<tran_id/>" ); if (phyRs.next())
valueXmlString.append("<line_no><![CDATA[").append(lineNo).append("]]></line_no>"); {
valueXmlString.append("<item_code><![CDATA[").append(itemCode).append("]]></item_code>"); phy13 = checkNull(phyRs.getString("PHY_ATTRIB_13"));
valueXmlString.append("<rate_apprv>").append("<![CDATA["+MngmntAprvRate+"]]>").append("</rate_apprv>\r\n"); phy14 = checkNull(phyRs.getString("PHY_ATTRIB_14"));
valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n"); phy15 = checkNull(phyRs.getString("PHY_ATTRIB_15"));
valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n"); }
valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n"); 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 " );
//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")) if (setSrPtrAll.trim().equalsIgnoreCase("Y"))
{ {
valueXmlString.append("<rate_quot>").append("<![CDATA[" + rate + "]]>").append("</rate_quot>"); 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 else
{ {
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( "<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>").append("<![CDATA[]]>").append("</rate_quot>"); valueXmlString.append("<rate_quot>").append("<![CDATA[]]>").append("</rate_quot>");
} }
...@@ -1341,80 +1489,341 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1341,80 +1489,341 @@ 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>").append("<![CDATA[]]>").append("</pack_code>");
valueXmlString.append("<unit>").append("<![CDATA[]]>").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("<pack_code protect='1'>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<unit protect='1'>").append("<![CDATA[" + unit + "]]>").append("</unit>"); valueXmlString.append("<unit protect='1'>").append("<![CDATA[" + unit + "]]>").append("</unit>");
valueXmlString.append("<value protect='1'>").append("<![CDATA[]]>").append("</value>");
if (phy13.equalsIgnoreCase(""))
{
BaseLogger.log("3", null, null, "phy_attrib_13 if block phy13>>>>>>>>>> "+ phy13 );
valueXmlString.append("<phy_attrib_13><![CDATA[0]]></phy_attrib_13>\r\n");
}
else
{
valueXmlString.append("<phy_attrib_13><![CDATA[" + phy13 + "]]></phy_attrib_13>\r\n");
}
if (phy14.equalsIgnoreCase(""))
{
BaseLogger.log("3", null, null, "phy_attrib_13 if AJIT block phy13>>>>>>>>>> "+ phy13 );
valueXmlString.append("<phy_attrib_14><![CDATA[0]]></phy_attrib_14>\r\n");
}
else
{
valueXmlString.append("<phy_attrib_14><![CDATA[" + phy14 + "]]></phy_attrib_14>\r\n");
}
if (phy15.equalsIgnoreCase(""))
{
valueXmlString.append("<phy_attrib_15><![CDATA[0]]></phy_attrib_15>\r\n");
}
else
{
valueXmlString.append("<phy_attrib_15><![CDATA[" + phy15 + "]]></phy_attrib_15>\r\n");
}
BaseLogger.log("3", null, null, "phy_attrib_15 phy13>>>>>>>>>> "+ phy13 );
// Added by Gagan B. on 14-APR-26: for shwoing revised PTR,PTS,PTD -- START
valueXmlString.append("<revised_pts><![CDATA[]]></revised_pts>\r\n");
valueXmlString.append("<revised_ptd><![CDATA[]]></revised_ptd>\r\n");
valueXmlString.append("<revised_ptr><![CDATA[]]></revised_ptr>\r\n");
// Added by Gagan B. on 14-APR-26: for shwoing revised PTR,PTS,PTD -- END
valueXmlString.append("</Detail"+objContext+">"); valueXmlString.append("</Detail"+objContext+">");
} }
//PTR calculation end //PTR calculation end
// Added by Gagan B. on 14-APR-26: for shwoing revised PTR,PTS,PTD -- START
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String quotedRate = checkNull(genericUtility.getColumnValue("rate_quot", dom));
BaseLogger.log("3", null, null, "quotedRate [" + quotedRate + "]");
updatedDistMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_13", dom));
updatedStkMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_14", dom));
updatedRetMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_15", dom));
BaseLogger.log("3", null, null, "updatedDistMargin [" + updatedDistMargin + "]");
BaseLogger.log("3", null, null, "updatedStkMargin [" + updatedStkMargin + "]");
BaseLogger.log("3", null, null, "updatedRetMargin [" + updatedRetMargin + "]");
if (quotedRate == null || quotedRate.trim().isEmpty())
{
throw new Exception("Special Rate values are not defined for item: " + itemCode);
}
double specialRate = Double.parseDouble(quotedRate);
if (Math.abs(updatedDistMargin) < 0.0001 && Math.abs(updatedStkMargin) < 0.0001 && Math.abs(updatedRetMargin) < 0.0001)
{
BaseLogger.log("3", null, null, "Inside IF block - all margins are zero 1520");
valueXmlString.append("<phy_attrib_13><![CDATA[0]]></phy_attrib_13>\r\n");
valueXmlString.append("<phy_attrib_14><![CDATA[0]]></phy_attrib_14>\r\n");
valueXmlString.append("<phy_attrib_15><![CDATA[0]]></phy_attrib_15>\r\n");
}
double revisedDist = updatedDistMargin;
double revisedStock = updatedStkMargin;
double revisedRet = updatedRetMargin;
double calcPTS = (specialRate / 100) * (100 - revisedStock);
double calcPTD = (specialRate / 100) * (100 - revisedDist);
double calcPTR = (specialRate / 100) * (100 - revisedRet);
revisedPTS = String.format("%.2f", calcPTS);
revisedPTD = String.format("%.2f", calcPTD);
revisedPTR = String.format("%.2f", calcPTR);
BaseLogger.log("3", null, null, "FINAL revisedPTR [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTS [" + revisedPTS + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTD [" + revisedPTD + "]");
//Management rate block[End] //Management rate block[End]
} }
if ("ptr_flag".equalsIgnoreCase(currentColumn.trim())) { // Added by Saburi - 06/04/26 : Fetch PHY_ATTRIB_13,14,15 on item selection
String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom)); 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"));
}
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flag "); phyRs.close();
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); 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()))
{
String ptrFlag = checkNull(genericUtility.getColumnValue("ptr_flag", dom));
String rateStr = checkNull(genericUtility.getColumnValue("ptr", dom));
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
BaseLogger.log("3", null, null, "ReqForQuotationIC in ptr_flag ");
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
String itemCode = checkNull(genericUtility.getColumnValue("item_code", 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 rateStr:: " + rateStr);
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, "ReqForQuotationWiz in ptr_flat condition:: "+ptrFlag);
BaseLogger.log("3", null, null, "ReqForQuotationWiz in ptr_flat condition siteCode:: "+siteCode);
BaseLogger.log("3", null, null, "ReqForQuotationWiz in ptr_flat condition custCode:: "+custCode);
if(ptrFlag.equalsIgnoreCase("Y")) {
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" );
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");
updatedDistMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_13", dom));
updatedStkMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_14", dom));
updatedRetMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_15", dom));
BaseLogger.log("3", null, null, "updatedDistMargin [" + updatedDistMargin + "]");
BaseLogger.log("3", null, null, "updatedStkMargin [" + updatedStkMargin + "]");
BaseLogger.log("3", null, null, "updatedRetMargin [" + updatedRetMargin + "]");
if (rateStr == null || rateStr.trim().isEmpty())
{
throw new Exception("Special Rate values are not defined for item: " + itemCode);
}
if (Math.abs(updatedDistMargin) < 0.0001 && Math.abs(updatedStkMargin) < 0.0001 && Math.abs(updatedRetMargin) < 0.0001)
{
BaseLogger.log("3", null, null, "Inside IF block - all margins are zero 1630");
valueXmlString.append("<phy_attrib_13><![CDATA[0]]></phy_attrib_13>\r\n");
valueXmlString.append("<phy_attrib_14><![CDATA[0]]></phy_attrib_14>\r\n");
valueXmlString.append("<phy_attrib_15><![CDATA[0]]></phy_attrib_15>\r\n");
}
BigDecimal specialRate = new BigDecimal(rateStr);
BigDecimal hundred = new BigDecimal("100");
BigDecimal distMargin = new BigDecimal(updatedDistMargin);
BigDecimal stockMargin = new BigDecimal(updatedStkMargin);
BigDecimal retMargin = new BigDecimal(updatedRetMargin);
// ✅ Correct calculation
BigDecimal revisedPtr = specialRate.multiply(hundred.subtract(retMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPts = specialRate.multiply(hundred.subtract(stockMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
BigDecimal revisedPtd = specialRate.multiply(hundred.subtract(distMargin))
.divide(hundred, 2, RoundingMode.HALF_UP);
// ✅ Correct logs
BaseLogger.log("3", null, null, "FINAL revisedPTR [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTS [" + revisedPTS + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTD [" + revisedPTD + "]");
// ✅ Correct XML mapping
valueXmlString.append("<revised_ptr><![CDATA[").append(revisedPtr).append("]]></revised_ptr>\r\n");
valueXmlString.append("<revised_pts><![CDATA[").append(revisedPts).append("]]></revised_pts>\r\n");
valueXmlString.append("<revised_ptd><![CDATA[").append(revisedPtd).append("]]></revised_ptd>\r\n");
valueXmlString.append("</Detail"+objContext+">");
}else if(ptrFlag.equalsIgnoreCase("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:line_no\"/>\r\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");
valueXmlString.append("<revised_ptr>").append("<![CDATA[]]>").append("</revised_ptr>\r\n");
valueXmlString.append("<revised_pts>").append("<![CDATA[]]>").append("</revised_pts>\r\n");
valueXmlString.append("<revised_ptd>").append("<![CDATA[]]>").append("</revised_ptd>\r\n");
valueXmlString.append("</Detail"+objContext+">");
}
}
if ("qty_quot".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", getUserInfo(), null, "In qty_quot condition for case 2 item change10");
BaseLogger.log("3", null, null, "ReqForQuotationWiz in ptr_flat condition:: "+ptrFlag); String rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz in ptr_flat condition siteCode:: "+siteCode); String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz in ptr_flat condition custCode:: "+custCode); 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);
if(ptrFlag.equalsIgnoreCase("Y")) { int qty = 0;
String rateStr = checkNull(genericUtility.getColumnValue("ptr", dom)); BigDecimal rateQuotDecimal = BigDecimal.ZERO;
BigDecimal value = BigDecimal.ZERO;
BaseLogger.log("3", getUserInfo(), null, "Final RATE : " + rate); try {
qty = (qtyStr != null && qtyStr.trim().length() > 0) ? Integer.parseInt(qtyStr.trim()) : 0;
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" );
valueXmlString.append("<rate_quot protect='1'>").append("<![CDATA["+rateStr+"]]>").append("</rate_quot>\r\n");
valueXmlString.append("</Detail"+objContext+">");
rateQuotDecimal = (rateQuotStr != null && rateQuotStr.trim().length() > 0)
}else if(ptrFlag.equalsIgnoreCase("N")) { ? new BigDecimal(rateQuotStr.trim())
: BigDecimal.ZERO;
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" );
valueXmlString.append("<rate_quot protect='0'>").append("<![CDATA[]]>").append("</rate_quot>\r\n");
valueXmlString.append("</Detail"+objContext+">");
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 rateQuotStr = checkNull(genericUtility.getColumnValue("rate_quot", dom));
String qtyStr = checkNull(genericUtility.getColumnValue("qty_quot", dom)); // Saburi - 14Apr2026
String quotedRate = checkNull(genericUtility.getColumnValue("rate_quot", dom));
int qty = 0; BaseLogger.log("3", null, null, "quotedRate 1738[" + quotedRate + "]");
int rateQuotInt = 0; updatedDistMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_13", dom));
int value = 0; updatedStkMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_14", dom));
BaseLogger.log("3", null, null, "ReqForQuotationWiz in qty_quot condition qtyStr:: " + qtyStr); updatedRetMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_15", dom));
BaseLogger.log("3", null, null, BaseLogger.log("3", null, null, "updatedDistMargin [" + updatedDistMargin + "]");
"ReqForQuotationWiz in qty_quot condition rateQuotStr:: " + rateQuotStr); BaseLogger.log("3", null, null, "updatedStkMargin [" + updatedStkMargin + "]");
try { BaseLogger.log("3", null, null, "updatedRetMargin [" + updatedRetMargin + "]");
qty = (qtyStr != null && qtyStr.trim().length() > 0) ? Integer.parseInt(qtyStr.trim()) : 0; if (quotedRate == null || quotedRate.trim().isEmpty())
rateQuotInt = (rateQuotStr != null && rateQuotStr.trim().length() > 0) {
? Integer.parseInt(rateQuotStr.trim()) throw new Exception("Special Rate values are not defined for item: " + itemCode);
: 0; }
value = qty*rateQuotInt; double specialRate = Double.parseDouble(quotedRate);
if (Math.abs(updatedDistMargin) < 0.0001 &&
BaseLogger.log("3", null, null, "ReqForQuotationWiz in qty:: " + qty + " rateQuotInt::" Math.abs(updatedStkMargin) < 0.0001 &&
+ rateQuotInt + " value::" + value); Math.abs(updatedRetMargin) < 0.0001)
} catch (Exception e) { {
BaseLogger.log("3", null, null, "Error parsing margin values"); BaseLogger.log("3", null, null, "Inside IF block - all margins are zero 1742");
}
valueXmlString.append("<phy_attrib_13><![CDATA[0]]></phy_attrib_13>\r\n");
valueXmlString.append("<phy_attrib_14><![CDATA[0]]></phy_attrib_14>\r\n");
valueXmlString.append("<phy_attrib_15><![CDATA[0]]></phy_attrib_15>\r\n");
}
double revisedDist = updatedDistMargin;
double revisedStock = updatedStkMargin;
double revisedRet = updatedRetMargin;
double calcPTS = (specialRate / 100) * (100 - revisedStock);
double calcPTD = (specialRate / 100) * (100 - revisedDist);
double calcPTR = (specialRate / 100) * (100 - revisedRet);
revisedPTS = String.format("%.2f", calcPTS);
revisedPTD = String.format("%.2f", calcPTD);
revisedPTR = String.format("%.2f", calcPTR);
BaseLogger.log("3", null, null, "FINAL revisedPTR gsb [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTS gsb [" + revisedPTS + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTD gsb [" + revisedPTD + "]");
// Saburi -- END
//Comment out the rate_quot validation block as this case handled by JS[Start]
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;
BaseLogger.log("3", null, null, "ReqForQuotationWiz qtyStr:: " + qtyStr);
BaseLogger.log("3", null, null, "ReqForQuotationWiz 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());
}
//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, "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); BaseLogger.log("3", null, null, "ReqForQuotationWiz in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr);
...@@ -1462,8 +1871,27 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1462,8 +1871,27 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
// Added by Gagan B. on 14-APR-26: for shwoing revised PTR,PTS,PTD -- START
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");
valueXmlString.append("<revised_ptr protect='1'><![CDATA[" + revisedPTR + "]]></revised_ptr>\r\n");
valueXmlString.append("<revised_pts protect='1'><![CDATA[" + revisedPTS + "]]></revised_pts>\r\n");
valueXmlString.append("<revised_ptd protect='1'><![CDATA[" + revisedPTD + "]]></revised_ptd>\r\n");
setNodeValue(dom, "value", value.toString());
setNodeValue(dom, "revised_ptr", revisedPTR);
setNodeValue(dom, "revised_pts", revisedPTS);
setNodeValue(dom, "revised_ptd", revisedPTD);
valueXmlString.append("</Detail" + objContext + ">");
// Added by Gagan B. on 14-APR-26: for shwoing revised PTR,PTS,PTD -- END
} }
/*
//Calculating Revised PTR,PTD and PTS [Start] //Calculating Revised PTR,PTD and PTS [Start]
PreparedStatement resvisedRatePstmt =null; PreparedStatement resvisedRatePstmt =null;
ResultSet resvisedRateRs = null; ResultSet resvisedRateRs = null;
...@@ -1509,15 +1937,27 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1509,15 +1937,27 @@ public class ReqForQuotationWiz extends ValidatorEJB{
String domId = checkNull(genericUtility.getColumnValue("domid", dom)); String domId = checkNull(genericUtility.getColumnValue("domid", dom));
BaseLogger.log("3", null, null, "domId::>>"+domId); 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='" + 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("<revised_ptr><![CDATA[" + revisedPtr + "]]></revised_ptr>\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"); 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"); valueXmlString.append("<revised_ptd><![CDATA[" + revisedPtd + "]]></revised_ptd>\r\n");
valueXmlString.append("<value><![CDATA[" + value + "]]></value>\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 + ">"); valueXmlString.append("</Detail" + objContext + ">");
} }
...@@ -1532,6 +1972,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1532,6 +1972,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
//Calculating Revised PTR,PTD and PTS [End] //Calculating Revised PTR,PTD and PTS [End]
*/
} }
...@@ -1545,7 +1986,7 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1545,7 +1986,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
...@@ -1580,6 +2021,20 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1580,6 +2021,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;
...@@ -1679,4 +2134,4 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1679,4 +2134,4 @@ public class ReqForQuotationWiz extends ValidatorEJB{
} }
return msgType; return msgType;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment