Commit 68e1fd2f authored by mmhatre's avatar mmhatre

added validation for not allow more than 3 decimal places.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@213444 ce508802-f39f-4f6c-b175-0d175dae99d5
parent def477e7
...@@ -103,6 +103,8 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu ...@@ -103,6 +103,8 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu
String siteCode="",rcpAmtStr="",refSer="",refNo="",prdCode=""; String siteCode="",rcpAmtStr="",refSer="",refNo="",prdCode="";
java.util.Date tranDate = null; java.util.Date tranDate = null;
SimpleDateFormat dateFormat2 = null; SimpleDateFormat dateFormat2 = null;
String chkDec=""; //added by manish mhatre on 02-dec-2019
String unit=""; //added by manish mhatre on 02-dec-2019
try try
{ dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); { dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("@@@@@@@@ wfvaldata called"); System.out.println("@@@@@@@@ wfvaldata called");
...@@ -496,6 +498,7 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu ...@@ -496,6 +498,7 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu
tranId = this.genericUtility.getColumnValue("tran_id", dom); tranId = this.genericUtility.getColumnValue("tran_id", dom);
lineNo = this.genericUtility.getColumnValue("line_no", dom); lineNo = this.genericUtility.getColumnValue("line_no", dom);
quantityStr = this.genericUtility.getColumnValue("quantity", dom); quantityStr = this.genericUtility.getColumnValue("quantity", dom);
unit= this.genericUtility.getColumnValue("unit", dom);
System.out.println("tranId>>>>"+tranId+"]"); System.out.println("tranId>>>>"+tranId+"]");
if(tranId == null || tranId.trim().length() ==0 || "null".equalsIgnoreCase(tranId)) if(tranId == null || tranId.trim().length() ==0 || "null".equalsIgnoreCase(tranId))
{ {
...@@ -568,7 +571,19 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu ...@@ -568,7 +571,19 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
//added by manish mhatre on 02-dec-2019
//start manish
else
{
errCode=disCommon.checkDecimal(quantity, unit, conn);
if(errCode!=null && errCode.trim().length()>0)
{
errCode = "VTUOMDEC3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} //end manish
} }
}else if(childNodeName.equalsIgnoreCase("acct_code__dr")) }else if(childNodeName.equalsIgnoreCase("acct_code__dr"))
{ {
......
...@@ -44,6 +44,7 @@ import java.util.Date; ...@@ -44,6 +44,7 @@ import java.util.Date;
public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,AdjReceiptICLocal public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,AdjReceiptICLocal
{ {
DistCommon distcommon=new DistCommon();
/** /**
* Default constructor. * Default constructor.
*/ */
...@@ -122,6 +123,8 @@ public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,Adj ...@@ -122,6 +123,8 @@ public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,Adj
String transfer="",tranDateStr="",effDate=""; String transfer="",tranDateStr="",effDate="";
String suppCodeMfg="",unitAlt=""; String suppCodeMfg="",unitAlt="";
String packCode="";//Added By Mukesh Chauhan on 11/10/19 String packCode="";//Added By Mukesh Chauhan on 11/10/19
String chkDec="";
String unit="";
int cnt = 0; int cnt = 0;
int cntv = 0,cntLoc=0; int cntv = 0,cntLoc=0;
int cntItmSer = 0,noArt=0; int cntItmSer = 0,noArt=0;
...@@ -633,6 +636,7 @@ public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,Adj ...@@ -633,6 +636,7 @@ public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,Adj
lotNo=checkNull(genericUtility.getColumnValue("lot_no",dom)); lotNo=checkNull(genericUtility.getColumnValue("lot_no",dom));
lotSl=checkNull(genericUtility.getColumnValue("lot_sl",dom)); lotSl=checkNull(genericUtility.getColumnValue("lot_sl",dom));
locCode=checkNull(genericUtility.getColumnValue("loc_code",dom)); locCode=checkNull(genericUtility.getColumnValue("loc_code",dom));
unit=checkNull(genericUtility.getColumnValue("unit",dom)); //added by manish mhatre on 2-dec-2019
if(qty != null && qty.trim().length() > 0) if(qty != null && qty.trim().length() > 0)
{ {
...@@ -650,7 +654,18 @@ public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,Adj ...@@ -650,7 +654,18 @@ public class AdjReceiptIC extends ValidatorEJB implements AdjReceiptICRemote,Adj
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
//added by manish mhatre on 02-dec-2019
//start manish
else
{
errCode=distcommon.checkDecimal(detQty, unit, conn);
if(errCode!=null && errCode.trim().length()>0)
{
errCode = "VTUOMDEC3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} //end manish
} }
else if (childNodeName.equalsIgnoreCase("acct_code__dr")) else if (childNodeName.equalsIgnoreCase("acct_code__dr"))
{ {
......
...@@ -11055,4 +11055,55 @@ public class DistCommon { ...@@ -11055,4 +11055,55 @@ public class DistCommon {
} }
// added by rupali on 30/04/19 for getting rate slab_no wise if ref_no is geting // added by rupali on 30/04/19 for getting rate slab_no wise if ref_no is geting
// blank [end] // blank [end]
//added by manish mhatre on 02-dec-2019
//start manish
public String checkDecimal(double quantity, String unit,Connection conn ) throws ITMException
{
String errCode="";
try {
String[] splitter = String.valueOf(quantity).split("\\.");
splitter[0].length();
int decimalLength = splitter[1].length();
String sql="";
PreparedStatement pstmt = null;
ResultSet rs = null;
int decPlaces=0;
sql="Select dec_opt from uom where unit = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, unit);
rs=pstmt.executeQuery();
if(rs.next())
{
decPlaces=rs.getInt("dec_opt");
}
System.out.println("decimalLength["+decimalLength+"]unit["+unit+"]places["+decPlaces+"]");
if(decPlaces > 0)
{
if (decimalLength > decPlaces)
{
System.out.println("inside if decimal>>>>>>>");
errCode="VTUOMDEC3";
}
}
else if(decimalLength > 3)
{
System.out.println("inside else if decimal>>>>>>");
errCode="VTUOMDEC3";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}catch(Exception e)
{
System.out.println("checkDecimal(double, int)::>>" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return errCode;
}
//end manish
}// class }// class
...@@ -232,7 +232,6 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo ...@@ -232,7 +232,6 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo
int currentFormNo = 0; int currentFormNo = 0;
try { try {
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 09-06-2016 :START //Changes and Commented By Bhushan on 09-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM"); //conn = connDriver.getConnectDB("DriverITM");
...@@ -243,6 +242,10 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo ...@@ -243,6 +242,10 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo
valueXmlString.append(editFlag).append("</editFlag></header>"); valueXmlString.append(editFlag).append("</editFlag></header>");
String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"); String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("loginsitecode.....=" + loginSiteCode); System.out.println("loginsitecode.....=" + loginSiteCode);
String unit="",descr="",shDescr="",udfStr=""; //added by manish mhatre on 9-dec-2019
int decPlaces=0; //added by manish mhatre on 9-dec-2019
double roundTo=0.0D; //added by manish mhatre on 9-dec-2019
String roundToStr="",decPlacesStr=""; //added by manish mhatre on 9-dec-2019
if (objContext != null && objContext.trim().length() > 0) { if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
...@@ -252,22 +255,106 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo ...@@ -252,22 +255,106 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
System.out.println("currentColumn: " + currentColumn); System.out.println("currentColumn: " + currentColumn);
if (currentColumn != null) { if (currentColumn != null) {
if(currentColumn.equalsIgnoreCase("round")){ //added by manish mhatre on 9-dec-2019
//start manish
if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
unit = checkNull(genericUtility.getColumnValue("unit", dom));
descr = checkNull(genericUtility.getColumnValue("descr", dom));
shDescr = checkNull(genericUtility.getColumnValue("sh_descr", dom));
decPlacesStr= genericUtility.getColumnValue("dec_opt", dom);
if(decPlacesStr != null && decPlacesStr.trim().length()>0)
{
decPlaces=Integer.parseInt(decPlacesStr);
}
else
{
decPlaces=0;
}
roundToStr = genericUtility.getColumnValue("round_to", dom);
if(roundToStr != null && roundToStr.trim().length()>0)
{
roundTo=Double.parseDouble(roundToStr);
}
else
{
roundTo=0.0;
}
udfStr = checkNull(genericUtility.getColumnValue("udf_str2", dom));
valueXmlString.append("<unit >").append("<![CDATA[" + unit + "]]>").append("</unit>");
valueXmlString.append("<descr>").append("<![CDATA[" + descr + "]]>").append("</descr>");
valueXmlString.append("<sh_descr>").append("<![CDATA[" + shDescr + "]]>").append("</sh_descr>");
valueXmlString.append("<dec_opt>").append("<![CDATA[" + decPlaces + "]]>").append("</dec_opt>");
valueXmlString.append("<round_to>").append("<![CDATA[" + roundTo + "]]>").append("</round_to>");
valueXmlString.append("<udf_str2>").append("<![CDATA[" + udfStr + "]]>").append("</udf_str2>");
}//end manish
else if(currentColumn.equalsIgnoreCase("round")){
round = genericUtility.getColumnValue("round", dom); round = genericUtility.getColumnValue("round", dom);
round = round == null ? "" : round.trim(); round = round == null ? "" : round.trim();
System.out.println(":::Round :: " + round); System.out.println(":::Round :: " + round);
if(round.equalsIgnoreCase("N") || round.isEmpty()){ if(round.equalsIgnoreCase("N") || round.isEmpty()){
valueXmlString.append("<round_to protect = \"1\"><![CDATA[0]]></round_to>"); valueXmlString.append("<round_to protect = \"1\"><![CDATA[0]]></round_to>");
}else{ }else{
valueXmlString.append("<round_to protect = \"0\"><![CDATA[0]]></round_to>"); valueXmlString.append("<round_to protect = \"0\"><![CDATA[0]]></round_to>");
} }
}
} }
//added by manish mhatre on 9-dec-2019
//start manish
else if(currentColumn.trim().equalsIgnoreCase("dec_opt"))
{
decPlacesStr= E12GenericUtility.checkNull(getColumnValue("dec_opt", dom));
if(decPlacesStr != null && decPlacesStr.trim().length()>0)
{
decPlaces=Integer.parseInt(decPlacesStr);
}
else
{
decPlaces=0;
}
System.out.println("dec>>>>>"+decPlaces);
if(decPlaces == 0)
{
valueXmlString.append("<round_to><![CDATA[0]]></round_to>");
}
else if(decPlaces == 1)
{
valueXmlString.append("<round_to><![CDATA[0.1]]></round_to>");
}
else if(decPlaces == 2)
{
valueXmlString.append("<round_to><![CDATA[0.01]]></round_to>");
}
else if(decPlaces == 3)
{
valueXmlString.append("<round_to><![CDATA[0.001]]></round_to>");
}
else if(decPlaces == 4)
{
valueXmlString.append("<round_to><![CDATA[0.0001]]></round_to>");
}
else if(decPlaces == 5)
{
valueXmlString.append("<round_to><![CDATA[0.00001]]></round_to>");
}
else if(decPlaces == 6)
{
valueXmlString.append("<round_to><![CDATA[0.000001]]></round_to>");
}
else if(decPlaces == 7)
{
valueXmlString.append("<round_to><![CDATA[0.0000001]]></round_to>");
}
} //end manish
}
System.out.println(":::::generated xml" + valueXmlString.toString()); System.out.println(":::::generated xml" + valueXmlString.toString());
valueXmlString.append("</Detail1>\r\n"); valueXmlString.append("</Detail1>\r\n");
} }
...@@ -288,4 +375,12 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo ...@@ -288,4 +375,12 @@ public class UnitOfMeasureIC extends ValidatorEJB implements UnitOfMeasureICRemo
System.out.println("ValueXmlString:::::" + valueXmlString.toString()); System.out.println("ValueXmlString:::::" + valueXmlString.toString());
return valueXmlString.toString(); return valueXmlString.toString();
} }
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
} }
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