Commit 486b5795 authored by SABURI PATEKAR's avatar SABURI PATEKAR

In case of Quotation Team, not updating revised ptr, pts, ptd and margin.

parent 768aecd4
......@@ -25,14 +25,12 @@ import org.xml.sax.InputSource;
import ibase.ejb.CommonDBAccessEJB;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.XML2DBEJB;
import ibase.webitm.utility.GenericWorkflowClass;
import ibase.webitm.utility.ITMException;
public class ReqForQuotationAprv extends ValidatorEJB {
......@@ -112,7 +110,8 @@ public class ReqForQuotationAprv extends ValidatorEJB {
XML2DBEJB xml2dbObj = new XML2DBEJB();
Boolean tranFlag = false;
String processRequestResult = "";
String updatedDistMargin = "", updatedStkMargin="", updatedRetMargin="";
double updatedDistMargin = 0, updatedRetMargin=0;
double updatedStkMargin=0;
String revisedPTR="", revisedPTD="", revisedPTS="";
try {
......@@ -142,13 +141,23 @@ public class ReqForQuotationAprv extends ValidatorEJB {
BaseLogger.log("3", null, null, "objName[" + objName + "]");
//Added by Saburi - 11/04/2026
if (roleCodeSign.equalsIgnoreCase("VHB_QUOT"))
BaseLogger.log("3", null, null, "FINAL VHB_MNGMNT signStatus [" + signStatus + "]");
if ("R".equalsIgnoreCase(signStatus))
{
String updateWfStatusSql = "update SALES_QUOT_REQ set WF_STATUS = 'A' where tran_id = ?";
updateWfStatusPstmt = conn.prepareStatement(updateWfStatusSql);
updateWfStatusPstmt.setString(1, tranID);
int updateWfStatusCount = updateWfStatusPstmt.executeUpdate();
System.out.println("updateWfStatusCount::::::0 =[" + updateWfStatusCount + "]");
BaseLogger.log("3", null, null, "Reject Case → forcing margins to 0");
updatedDistMargin = 0.0;
updatedStkMargin = 0.0;
updatedRetMargin = 0.0;
}
if (roleCodeSign.equalsIgnoreCase("VHB_QUOT") && signStatus.equalsIgnoreCase("S"))
{
//Commented by Ajit: Fixed the issue where my special rate was lower than the management rate during quotation approval by the team.
// String updateWfStatusSql = "update SALES_QUOT_REQ set WF_STATUS = 'A' where tran_id = ?";
// updateWfStatusPstmt = conn.prepareStatement(updateWfStatusSql);
// updateWfStatusPstmt.setString(1, tranID);
// int updateWfStatusCount = updateWfStatusPstmt.executeUpdate();
// System.out.println("updateWfStatusCount::::::0 =[" + updateWfStatusCount + "]");
// Added by Gagan B. on 31-MAR-26: for fetching updated Special Rate from OST -- START
Document detailDom = null;
......@@ -162,62 +171,68 @@ public class ReqForQuotationAprv extends ValidatorEJB {
if (updatedRateFetchRS.next())
{
String transInfoXML = updatedRateFetchRS.getString(1)== null ? "" :updatedRateFetchRS.getString(1);
BaseLogger.log("3", null, null, "transInfoXML 160[" + transInfoXML + "]");
if (transInfoXML != null && transInfoXML.trim().length() > 0)
{
detailDom = genericUtility.parseString(transInfoXML);
BaseLogger.log("3", null, null, "detailDom 165[" + detailDom + "]");
}
itemCode = genericUtility.getColumnValue("item_code", detailDom);
updatedDistMargin = genericUtility.getColumnValue("phy_attrib_13", detailDom);
updatedStkMargin = genericUtility.getColumnValue("phy_attrib_14", detailDom);
updatedRetMargin = genericUtility.getColumnValue("phy_attrib_15", detailDom);
String transInfoXML = updatedRateFetchRS.getString(1)== null ? "" :updatedRateFetchRS.getString(1);
BaseLogger.log("3", null, null, "transInfoXML 160[" + transInfoXML + "]");
BaseLogger.log("3", null, null, "updatedDistMargin [" + updatedDistMargin + "]");
BaseLogger.log("3", null, null, "updatedStkMargin [" + updatedStkMargin + "]");
BaseLogger.log("3", null, null, "updatedRetMargin [" + updatedRetMargin + "]");
if (transInfoXML != null && transInfoXML.trim().length() > 0)
{
detailDom = genericUtility.parseString(transInfoXML);
BaseLogger.log("3", null, null, "detailDom 165[" + detailDom + "]");
}
String specialRateStr = genericUtility.getColumnValue("rate_quot", detailDom);
double specialRate = Double.parseDouble(specialRateStr);
itemCode = genericUtility.getColumnValue("item_code", detailDom);
updatedDistMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_13", detailDom));
updatedStkMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_14", detailDom));
updatedRetMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_15", detailDom));
double revisedDist = Double.parseDouble(updatedDistMargin);
double revisedStock = Double.parseDouble(updatedStkMargin);
double revisedRet = Double.parseDouble(updatedRetMargin);
String specialRateStr = genericUtility.getColumnValue("rate_quot", detailDom);
if (specialRateStr == null || specialRateStr.trim().isEmpty())
{
throw new Exception("Special Rate values are not defined for item: " + itemCode);
}
double specialRate = Double.parseDouble(specialRateStr);
double calcPTS = (specialRate / 100) * (100 - revisedStock);
double calcPTD = (specialRate / 100) * (100 - revisedDist);
double calcPTR = (specialRate / 100) * (100 - revisedRet);
if (updatedDistMargin == 0 || updatedStkMargin == 0 || updatedRetMargin == 0)
{
throw new Exception("Margin values are not defined for item: " + itemCode);
}
revisedPTS = String.format("%.2f", calcPTS);
revisedPTD = String.format("%.2f", calcPTD);
revisedPTR = String.format("%.2f", calcPTR);
double revisedDist = updatedDistMargin;
double revisedStock = updatedStkMargin;
double revisedRet = updatedRetMargin;
BaseLogger.log("3", null, null, "FINAL revisedPTR [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTS [" + revisedPTS + "]");
BaseLogger.log("3", null, null, "FINAL revisedPTD [" + revisedPTD + "]");
String updateRevisedValue = "UPDATE SALES_QUOT_REQ_DET SET REVISED_PTS=?, REVISED_PTR=?, REVISED_PTD=? WHERE ITEM_CODE=?";
PreparedStatement updatePstmt = conn.prepareStatement(updateRevisedValue);
double calcPTS = (specialRate / 100) * (100 - revisedStock);
double calcPTD = (specialRate / 100) * (100 - revisedDist);
double calcPTR = (specialRate / 100) * (100 - revisedRet);
updatePstmt.setString(1, checkNull(revisedPTS));
updatePstmt.setString(2, checkNull(revisedPTR));
updatePstmt.setString(3, checkNull(revisedPTD));
updatePstmt.setString(4, itemCode);
revisedPTS = String.format("%.2f", calcPTS);
revisedPTD = String.format("%.2f", calcPTD);
revisedPTR = String.format("%.2f", calcPTR);
int updateCnt = updatePstmt.executeUpdate();
BaseLogger.log("3", null, null, "ReqForQuotationApr FINAL revisedPTR [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "ReqForQuotationApr FINAL revisedPTS [" + revisedPTS + "]");
BaseLogger.log("3", null, null, "ReqForQuotationApr FINAL revisedPTD [" + revisedPTD + "]");
BaseLogger.log("3", null, null, "ITEM updated for updateRevisedValue 211[" + itemCode + "] Count: " + updateCnt);
// String updateRevisedValue = "UPDATE SALES_QUOT_REQ_DET SET REVISED_PTS=?, REVISED_PTR=?, REVISED_PTD=? WHERE ITEM_CODE=? AND TRAN_ID=?";
// PreparedStatement updatePstmt = conn.prepareStatement(updateRevisedValue);
if (updatePstmt != null)
{
updatePstmt.close();
updatePstmt = null;
}
// updatePstmt.setString(1, checkNull(revisedPTS));
// updatePstmt.setString(2, checkNull(revisedPTR));
// updatePstmt.setString(3, checkNull(revisedPTD));
// updatePstmt.setString(4, itemCode);
// updatePstmt.setString(5, tranID);
// int updateCnt = updatePstmt.executeUpdate();
// BaseLogger.log("3", null, null, "ITEM updated for updateRevisedValue 211[" + itemCode + "] Count: " + updateCnt);
// if (updatePstmt != null)
// {
// updatePstmt.close();
// updatePstmt = null;
// }
}
}
if (roleCodeSign.equalsIgnoreCase("VHB_MNGMNT") && signStatus.equalsIgnoreCase("S"))
{
String updateWfStatusSql = "update SALES_QUOT_REQ set WF_STATUS = 'A' where tran_id = ?";
......@@ -230,41 +245,51 @@ public class ReqForQuotationAprv extends ValidatorEJB {
Document detailDom = null;
PreparedStatement updatedRateFetchPSTMT = null;
ResultSet updatedRateFetchRS = null;
String updatedRateFetchSQL = "SELECT OST.TRANS_INFO_XML.getClobval() FROM OBJ_SIGN_TRANS OST where REF_ID = ? AND REF_SER = ? AND LINE_NO = '2'";
updatedRateFetchPSTMT = conn.prepareStatement(updatedRateFetchSQL);
updatedRateFetchPSTMT.setString(1, tranID);
updatedRateFetchPSTMT.setString(2, refSer);
updatedRateFetchRS = updatedRateFetchPSTMT.executeQuery();
if (updatedRateFetchRS.next())
{
String transInfoXML = updatedRateFetchRS.getString(1)== null ? "" :updatedRateFetchRS.getString(1);
BaseLogger.log("3", null, null, "transInfoXML[" + transInfoXML + "]");
if (transInfoXML != null && transInfoXML.trim().length() > 0)
{
detailDom = genericUtility.parseString(transInfoXML);
}
String transInfoXML = updatedRateFetchRS.getString(1) == null ? "" : updatedRateFetchRS.getString(1);
BaseLogger.log("3", null, null, "transInfoXML[" + transInfoXML + "]");
if (transInfoXML != null && transInfoXML.trim().length() > 0)
{
detailDom = genericUtility.parseString(transInfoXML);
}
// Fetching Updated Management Approved Rate
updatedRate = genericUtility.getColumnValue("rate_quot", detailDom);
BaseLogger.log("3", null, null, "uppdatedRate VHB_MNGMNT[" + updatedRate + "]");
updatedRate = genericUtility.getColumnValue("rate_quot", detailDom);
BaseLogger.log("3", null, null, "uppdatedRate VHB_MNGMNT[" + updatedRate + "]");
//Added by Saburi-11/04/2026
itemCode = genericUtility.getColumnValue("item_code", detailDom);
updatedDistMargin = genericUtility.getColumnValue("phy_attrib_13", detailDom);
updatedStkMargin = genericUtility.getColumnValue("phy_attrib_14", detailDom);
updatedRetMargin = genericUtility.getColumnValue("phy_attrib_15", detailDom);
itemCode = genericUtility.getColumnValue("item_code", detailDom);
updatedDistMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_13", detailDom));
updatedStkMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_14", detailDom));
updatedRetMargin = parseDoubleSafe(genericUtility.getColumnValue("phy_attrib_15", detailDom));
BaseLogger.log("3", null, null, "VHB_MNGMNT updatedDistMargin [" + updatedDistMargin + "]");
BaseLogger.log("3", null, null, "VHB_MNGMNT updatedStkMargin [" + updatedStkMargin + "]");
BaseLogger.log("3", null, null, "VHB_MNGMNT updatedRetMargin [" + updatedRetMargin + "]");
String specialRateStr = genericUtility.getColumnValue("rate_quot", detailDom);
if (specialRateStr == null || specialRateStr.trim().isEmpty())
{
throw new Exception("Special Rate values are not defined for item: " + itemCode);
}
double specialRate = Double.parseDouble(specialRateStr);
double revisedDist = Double.parseDouble(updatedDistMargin);
double revisedStock = Double.parseDouble(updatedStkMargin);
double revisedRet = Double.parseDouble(updatedRetMargin);
if (updatedDistMargin == 0 || updatedStkMargin == 0 || updatedRetMargin == 0 )
{
throw new Exception("Margin values are not defined for item: " + itemCode);
}
double revisedDist = updatedDistMargin;
double revisedStock = updatedStkMargin;
double revisedRet = updatedRetMargin;
double calcPTS = (specialRate / 100) * (100 - revisedStock);
double calcPTD = (specialRate / 100) * (100 - revisedDist);
......@@ -277,45 +302,43 @@ public class ReqForQuotationAprv extends ValidatorEJB {
BaseLogger.log("3", null, null, "FINAL VHB_MNGMNT revisedPTR [" + revisedPTR + "]");
BaseLogger.log("3", null, null, "FINAL VHB_MNGMNT revisedPTS [" + revisedPTS + "]");
BaseLogger.log("3", null, null, "FINAL VHB_MNGMNT revisedPTD [" + revisedPTD + "]");
String updateRevisedValue = "UPDATE SALES_QUOT_REQ_DET SET REVISED_PTS=?, REVISED_PTR=?, REVISED_PTD=? WHERE ITEM_CODE=?";
PreparedStatement updatePstmt = conn.prepareStatement(updateRevisedValue);
updatePstmt.setString(1, checkNull(revisedPTS));
updatePstmt.setString(2, checkNull(revisedPTR));
updatePstmt.setString(3, checkNull(revisedPTD));
updatePstmt.setString(4, itemCode);
String updateRevisedValue = "UPDATE SALES_QUOT_REQ_DET SET REVISED_PTS=?, REVISED_PTR=?, REVISED_PTD=? WHERE ITEM_CODE=? AND TRAN_ID=?";
PreparedStatement updatePstmt = conn.prepareStatement(updateRevisedValue);
int updateCnt = updatePstmt.executeUpdate();
updatePstmt.setString(1, checkNull(revisedPTS));
updatePstmt.setString(2, checkNull(revisedPTR));
updatePstmt.setString(3, checkNull(revisedPTD));
updatePstmt.setString(4, itemCode);
updatePstmt.setString(5, tranID);
BaseLogger.log("3", null, null, "ITEM updated for VHB_MNGMNT updateRevisedValue [" + itemCode + "] Count: " + updateCnt);
int updateCnt = updatePstmt.executeUpdate();
BaseLogger.log("3", null, null, "ITEM updated for VHB_MNGMNT updateRevisedValue [" + itemCode + "] Count: " + updateCnt);
if (updatePstmt != null)
{
updatePstmt.close();
updatePstmt = null;
}
String updateItemSql = "UPDATE ITEM SET PHY_ATTRIB_13 = ?, PHY_ATTRIB_14 = ?, PHY_ATTRIB_15 = ? WHERE ITEM_CODE = ?";
PreparedStatement updateItemPstmt = conn.prepareStatement(updateItemSql);
if (updatePstmt != null)
{
updatePstmt.close();
updatePstmt = null;
}
updateItemPstmt.setString(1, checkNull(updatedDistMargin)); // PHY_ATTRIB_13
updateItemPstmt.setString(2, checkNull(updatedStkMargin)); // PHY_ATTRIB_14
updateItemPstmt.setString(3, checkNull(updatedRetMargin)); // PHY_ATTRIB_15
updateItemPstmt.setString(4, itemCode);
String updateItemSql = "UPDATE ITEM SET PHY_ATTRIB_13 = ?, PHY_ATTRIB_14 = ?, PHY_ATTRIB_15 = ? WHERE ITEM_CODE = ?";
PreparedStatement updateItemPstmt = conn.prepareStatement(updateItemSql);
int updateCount = updateItemPstmt.executeUpdate();
updateItemPstmt.setString(1, String.valueOf(updatedDistMargin));
updateItemPstmt.setString(2, String.valueOf(updatedStkMargin));
updateItemPstmt.setString(3, String.valueOf(updatedRetMargin));
updateItemPstmt.setString(4, itemCode);
BaseLogger.log("3", null, null, "ITEM updated for itemCode VHB_MNGMNT[" + itemCode + "] Count: " + updateCount);
int updateCount = updateItemPstmt.executeUpdate();
BaseLogger.log("3", null, null, "ITEM updated for itemCode VHB_MNGMNT[" + itemCode + "] Count: " + updateCount);
if (updateItemPstmt != null)
{
updateItemPstmt.close();
updateItemPstmt = null;
}
if (updateItemPstmt != null)
{
updateItemPstmt.close();
updateItemPstmt = null;
}
}
}
System.out.println("enterprises::::: =[" + enterprises1 + "]" + " tran_id::" + tranID);
userInfo = commonDBAccessEJB.createUserInfo(empCode);
System.out.println("signStatus::" + signStatus + " enterprises::::: =[" + enterprises1 + "]"
......@@ -487,9 +510,15 @@ public class ReqForQuotationAprv extends ValidatorEJB {
}
if (roleCodeSign.equalsIgnoreCase("VHB_MNGMNT")) {
double rateDouble = Double.parseDouble(updatedRate);
rate = (int) rateDouble;
if (roleCodeSign.equalsIgnoreCase("VHB_MNGMNT") || roleCodeSign.equalsIgnoreCase("VHB_QUOT"))
{
BaseLogger.log("3", null, null, "ITEM updated for updatedRate VHB_MNGMNT[" + updatedRate + "]");
if(updatedRate.trim().length() > 0)
{
BaseLogger.log("3", null, null, "Inside the updatedRate VHB_MNGMNT[" + updatedRate + "]");
double rateDouble = Double.parseDouble(updatedRate);
rate = (int) rateDouble;
}
}
BigDecimal rateBD = new BigDecimal(rate);
......@@ -706,9 +735,9 @@ public class ReqForQuotationAprv extends ValidatorEJB {
String updateItemSql = "UPDATE ITEM SET PHY_ATTRIB_13 = ?, PHY_ATTRIB_14 = ?, PHY_ATTRIB_15 = ? WHERE ITEM_CODE = ?";
PreparedStatement updateItemPstmt = conn.prepareStatement(updateItemSql);
updateItemPstmt.setString(1, checkNull(updatedDistMargin)); // PHY_ATTRIB_13
updateItemPstmt.setString(2, checkNull(updatedStkMargin)); // PHY_ATTRIB_14
updateItemPstmt.setString(3, checkNull(updatedRetMargin)); // PHY_ATTRIB_15
updateItemPstmt.setString(1, String.valueOf(updatedDistMargin));
updateItemPstmt.setString(2, String.valueOf(updatedStkMargin));
updateItemPstmt.setString(3, String.valueOf(updatedRetMargin));
updateItemPstmt.setString(4, itemCode);
int updateCount = updateItemPstmt.executeUpdate();
......@@ -720,6 +749,25 @@ public class ReqForQuotationAprv extends ValidatorEJB {
updateItemPstmt.close();
updateItemPstmt = null;
}
// Added by Saburi - 20Apr2026
String updateRevisedValue = "UPDATE SALES_QUOT_REQ_DET SET REVISED_PTS=?, REVISED_PTR=?, REVISED_PTD=? WHERE ITEM_CODE=? AND TRAN_ID=?";
PreparedStatement updatePstmt = conn.prepareStatement(updateRevisedValue);
updatePstmt.setString(1, checkNull(revisedPTS));
updatePstmt.setString(2, checkNull(revisedPTR));
updatePstmt.setString(3, checkNull(revisedPTD));
updatePstmt.setString(4, itemCode);
updatePstmt.setString(5, tranID);
int updateCnt = updatePstmt.executeUpdate();
BaseLogger.log("3", null, null, "ITEM updated for updateRevisedValue 765>>>>>[" + itemCode
+ "] Count: " + updateCnt);
if (updatePstmt != null) {
updatePstmt.close();
updatePstmt = null;
}
}
} else {
BaseLogger.log("3", null, null, "Sales Quotation Generation Failed: ");
......@@ -756,6 +804,22 @@ public class ReqForQuotationAprv extends ValidatorEJB {
return retString;
}
private double parseDoubleSafe(String value)
{
try
{
if (value != null && value.trim().length() > 0)
{
return Double.parseDouble(value.trim());
}
}
catch (Exception e)
{
BaseLogger.log("3", null, null, "Invalid number: " + value);
}
return 0.0;
}
public static String formatDateTime(LocalDate tranDate, LocalTime tranTime) {
LocalDateTime tranDateTime = LocalDateTime.of(tranDate, tranTime);
......
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