Commit 6d4ba02f authored by prane's avatar prane

Adjustment Issue - no_art calculation to consider item_lot_packsize, quantity...

Adjustment Issue - no_art calculation to consider item_lot_packsize, quantity / shipper_size to be considered, if not defined to take from packing last to be shipper_size from item


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@200638 ce508802-f39f-4f6c-b175-0d175dae99d5
parent dcbaa4aa
...@@ -20,6 +20,7 @@ import java.sql.Timestamp; ...@@ -20,6 +20,7 @@ import java.sql.Timestamp;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat;
//import org.apache.poi.hssf.record.formula.functions.Round; //import org.apache.poi.hssf.record.formula.functions.Round;
import org.w3c.dom.CDATASection; import org.w3c.dom.CDATASection;
...@@ -921,6 +922,7 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu ...@@ -921,6 +922,7 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu
double amount= 0.0,quantity =0.0,rate =0.0,netWeight =0.0,grossWeight =0.0,tareWeight=0.0,stkQuantity =0.0; double amount= 0.0,quantity =0.0,rate =0.0,netWeight =0.0,grossWeight =0.0,tareWeight=0.0,stkQuantity =0.0;
double shipperQty = 0.0 ,integralQty = 0.0,qtyPerArt =0.0,grossper=0.0,tareper=0.0,netper=0.0; double shipperQty = 0.0 ,integralQty = 0.0,qtyPerArt =0.0,grossper=0.0,tareper=0.0,netper=0.0;
long noArt =0; long noArt =0;
double noOfArt = 0d, shipperSize = 0d, mGrossWeight = 0d, mNetWeight = 0d, mGrosswt = 0d, mNetWt = 0d, mTareWt = 0d;
try try
{ {
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();
...@@ -1127,6 +1129,54 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu ...@@ -1127,6 +1129,54 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu
gbfValAcct(itemCode,siteCode,locCode,lotNo,lotSl,conn,valueXmlString,dom1); gbfValAcct(itemCode,siteCode,locCode,lotNo,lotSl,conn,valueXmlString,dom1);
packCode = checkNull(genericUtility.getColumnValue("pack_code",dom)); packCode = checkNull(genericUtility.getColumnValue("pack_code",dom));
//System.out.println("PavanDOM[ "+genericUtility.serializeDom(dom)+"]\n\n\n");
//Pavan R on may19[no of art to consider from item_lot_packsize, item and if not found then packing master]
sql = "select (case when shipper_size is null then 0 else shipper_size end) as shipper_size, "
+ "(case when gross_weight is null then 0 else gross_weight end) as lc_gross_weigth, "
+ "(case when net_weight is null then 0 else net_weight end) as lc_net_weight "
+ "from item_lot_packsize where item_code = ? "
+ "and ? >= lot_no__from and ? <= lot_no__to";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, lotNo);
pstmt.setString(3, lotNo);
rs = pstmt.executeQuery();
if(rs.next())
{
shipperSize = rs.getDouble("shipper_size");
mGrossWeight= rs.getDouble("lc_gross_weigth");
mNetWeight= rs.getDouble("lc_net_weight");
System.out.println("shipperSize["+shipperSize+"] mGrossWeight["+mGrossWeight+"] mNetWeight["+mNetWeight+"]");
if (shipperSize > 0)
{
double mod = quantity/shipperSize;
noOfArt = getRndamt(mod , "X", 1);
System.out.println("noOfArt["+noOfArt+"]");
valueXmlString.append("<no_art><![CDATA[").append(noOfArt).append("]]></no_art>\r\n");
if(noOfArt > 0)
{
mGrosswt = ((mGrossWeight/shipperSize) * quantity);
mNetWt = ((mNetWeight/shipperSize) * quantity);
//System.out.println("mGrosswt [ "+mGrosswt+" ]");
if(mGrossWeight > 0)
{
valueXmlString.append("<gross_weight ><![CDATA[").append(getRequiredDecimals(mGrosswt,3)).append("]]></gross_weight>\r\n");
valueXmlString.append("<net_weight ><![CDATA[").append(getRequiredDecimals(mNetWt,3)).append("]]></net_weight>\r\n");
mTareWt=mGrosswt - mNetWt;
System.out.println("mGrossWeight > 0 mTareWt [ "+mTareWt+" ]");
valueXmlString.append("<tare_weight ><![CDATA[").append(getRequiredDecimals(mTareWt, 3)).append("]]></tare_weight>\r\n");
}
} //if(noOfArt > 0)
}//if(shipperSize > 0)
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("shipperSize["+shipperSize+"]");
if(shipperSize == 0)
{
//End - Pavan R on may19
noArt=disCommon.getNoArt(siteCode,custCode,itemCode,packCode,quantity,'B',shipperQty,integralQty,conn); noArt=disCommon.getNoArt(siteCode,custCode,itemCode,packCode,quantity,'B',shipperQty,integralQty,conn);
System.out.println("noArt>>>>"+noArt); System.out.println("noArt>>>>"+noArt);
...@@ -1193,7 +1243,7 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu ...@@ -1193,7 +1243,7 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu
valueXmlString.append("<gross_weight><![CDATA[").append(grossWeight).append("]]></gross_weight>\r\n"); valueXmlString.append("<gross_weight><![CDATA[").append(grossWeight).append("]]></gross_weight>\r\n");
valueXmlString.append("<net_weight><![CDATA[").append(netWeight).append("]]></net_weight>\r\n"); valueXmlString.append("<net_weight><![CDATA[").append(netWeight).append("]]></net_weight>\r\n");
valueXmlString.append("<tare_weight><![CDATA[").append(tareWeight).append("]]></tare_weight>\r\n"); valueXmlString.append("<tare_weight><![CDATA[").append(tareWeight).append("]]></tare_weight>\r\n");
}
//rate item change //rate item change
setNodeValue( dom, "rate", rateStr ); setNodeValue( dom, "rate", rateStr );
reStr=itemChanged(dom,dom1, dom2, objContext,"rate",editFlag,xtraParams); reStr=itemChanged(dom,dom1, dom2, objContext,"rate",editFlag,xtraParams);
...@@ -1525,5 +1575,72 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu ...@@ -1525,5 +1575,72 @@ public class AdjIssueIC extends ValidatorEJB implements AdjIssueICLocal, AdjIssu
} }
tempNode = null; tempNode = null;
} }
public double getRndamt(double newQty, String round, double roundTo) {
System.out.println(newQty+"~~~"+round+"~~~"+roundTo);
double lcMultiply = 1;
try {
round = round.toUpperCase();
if (newQty < 0) {
lcMultiply = -1;
newQty = Math.abs(newQty);
} else if (newQty == 0) {
return newQty;
} else if (round.trim().equals("N")) {
return newQty;
} else if (roundTo == 0) {
return newQty;
}
if (round.trim().equals("X")) {
if(newQty == (newQty - (newQty % roundTo)))
{
return newQty;
}
else
{
newQty = ((newQty - (newQty % roundTo)) + roundTo);
}
}
if (round.trim().equals("P")) {
newQty = (newQty - (newQty % roundTo));
}
if (round.trim().equals("R")) {
if ((newQty % roundTo) < (roundTo / 2)) {
newQty = (newQty - (newQty % roundTo));
} else {
newQty = (newQty - (newQty % roundTo) + roundTo);
}
}
System.out.println("newQty[" + newQty + "]");
System.out.println("lcMultiply[" + lcMultiply + "]");
newQty = newQty * lcMultiply;
System.out.println("newQty * lcMultiply[" + newQty + "]");
return newQty;
} catch (Exception e) {
System.out.println("Exception :Conversion Qty ::" + e.getMessage()
+ ":");
}
if (roundTo == 1) {
newQty = getRequiredDecimals(newQty, 0);
} else if (roundTo == .1) {
newQty = getRequiredDecimals(newQty, 1);
} else if (roundTo == .01) {
newQty = getRequiredDecimals(newQty, 2);
} else if (roundTo == .001) {
newQty = getRequiredDecimals(newQty, 3);
} else if (roundTo == .0001) {
newQty = getRequiredDecimals(newQty, 4);
}
return newQty;
}
public double getRequiredDecimals(double actVal, int prec) {
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
Double DoubleValue = new Double(actVal);
numberFormat.setMaximumFractionDigits(3);
String strValue = numberFormat.format(DoubleValue);
strValue = strValue.replaceAll(",", "");
double reqVal = Double.parseDouble(strValue);
return reqVal;
}
} }
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