Commit 1c2158d6 authored by ngadkari's avatar ngadkari

changes to set proper quantity in min_rate_history when scheme is apply

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@205990 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0afc97de
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
package ibase.webitm.ejb.dis.adv; package ibase.webitm.ejb.dis.adv;
import java.io.ByteArrayOutputStream;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.*; import java.util.*;
import java.sql.*; import java.sql.*;
...@@ -18,8 +19,14 @@ import ibase.webitm.ejb.*; ...@@ -18,8 +19,14 @@ import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.system.config.*; import ibase.system.config.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
@Stateless // added for ejb3 @Stateless // added for ejb3
public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLocal, SalesReturnActRemote public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLocal, SalesReturnActRemote
...@@ -1234,8 +1241,7 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -1234,8 +1241,7 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
while(rs.next()) while(rs.next())
{ {
if(qty >0)
{
invoiceId = checkNull(rs.getString("INVOICE_ID")); invoiceId = checkNull(rs.getString("INVOICE_ID"));
invoiceQty =rs.getDouble("QUANTITY"); invoiceQty =rs.getDouble("QUANTITY");
adjQty = rs.getDouble("QTY_ADJ"); adjQty = rs.getDouble("QTY_ADJ");
...@@ -1275,17 +1281,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -1275,17 +1281,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
{ {
lotQty = rs2.getDouble(1); lotQty = rs2.getDouble(1);
domID++; domID++;
valueXmlString.append("<Detail domId='"+(domID)+"' selected=\"Y\">\r\n"); valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n"); valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]>").append("</lot_no>\r\n"); valueXmlString.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]>").append("</lot_no>\r\n");
if(qty > lotQty)
{
valueXmlString.append("<quantity>").append("<![CDATA[").append(lotQty).append("]]>").append("</quantity>\r\n"); valueXmlString.append("<quantity>").append("<![CDATA[").append(lotQty).append("]]>").append("</quantity>\r\n");
}
else {
valueXmlString.append("<quantity>").append("<![CDATA[").append(qty).append("]]>").append("</quantity>\r\n");
}
valueXmlString.append("<invoice_ref>").append("<![CDATA[").append(invoiceId).append("]]>").append("</invoice_ref>\r\n"); valueXmlString.append("<invoice_ref>").append("<![CDATA[").append(invoiceId).append("]]>").append("</invoice_ref>\r\n");
if(invoiceDate != null) if(invoiceDate != null)
{ {
...@@ -1299,11 +1300,7 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -1299,11 +1300,7 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
valueXmlString.append("<invoice_quantity>").append("<![CDATA[").append(lotQty).append("]]>").append("</invoice_quantity>\r\n"); valueXmlString.append("<invoice_quantity>").append("<![CDATA[").append(lotQty).append("]]>").append("</invoice_quantity>\r\n");
valueXmlString.append("<used_quantity>").append("<![CDATA[").append(0.0).append("]]>").append("</used_quantity>\r\n"); valueXmlString.append("<used_quantity>").append("<![CDATA[").append(0.0).append("]]>").append("</used_quantity>\r\n");
valueXmlString.append("</Detail>\r\n"); valueXmlString.append("</Detail>\r\n");
qty=qty-lotQty;
if(qty <= 0)
{
break;
}
} }
pstmt2.close(); pstmt2.close();
...@@ -1320,17 +1317,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -1320,17 +1317,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
System.out.println( "inputQty :: " + inputQty);System.out.println( "qty :: " + qty); System.out.println( "inputQty :: " + inputQty);System.out.println( "qty :: " + qty);
if(inputQty > 0) if(inputQty > 0)
{ {
domID++;
valueXmlString.append("<Detail domId='"+(domID)+"' selected=\"Y\">\r\n"); valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n"); valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]>").append("</lot_no>\r\n"); valueXmlString.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]>").append("</lot_no>\r\n");
if(qty > inputQty)
{
valueXmlString.append("<quantity>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n"); valueXmlString.append("<quantity>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n");
}
else {
valueXmlString.append("<quantity>").append("<![CDATA[").append(qty).append("]]>").append("</quantity>\r\n");
}
valueXmlString.append("<invoice_ref>").append("<![CDATA[").append(invoiceId).append("]]>").append("</invoice_ref>\r\n"); valueXmlString.append("<invoice_ref>").append("<![CDATA[").append(invoiceId).append("]]>").append("</invoice_ref>\r\n");
if(invoiceDate != null) if(invoiceDate != null)
{ {
...@@ -1344,15 +1336,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -1344,15 +1336,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
valueXmlString.append("<invoice_quantity>").append("<![CDATA[").append(invoiceQty).append("]]>").append("</invoice_quantity>\r\n"); valueXmlString.append("<invoice_quantity>").append("<![CDATA[").append(invoiceQty).append("]]>").append("</invoice_quantity>\r\n");
valueXmlString.append("<used_quantity>").append("<![CDATA[").append(adjQty).append("]]>").append("</used_quantity>\r\n"); valueXmlString.append("<used_quantity>").append("<![CDATA[").append(adjQty).append("]]>").append("</used_quantity>\r\n");
valueXmlString.append("</Detail>\r\n"); valueXmlString.append("</Detail>\r\n");
qty=qty-inputQty;
}
}
} }
if(qty <= 0)
{
break;
} }
} }
}//loop end }//loop end
if (pstmt != null) { if (pstmt != null) {
pstmt.close(); pstmt.close();
...@@ -1368,31 +1357,210 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -1368,31 +1357,210 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
valueXmlString.append("</Root>\r\n"); valueXmlString.append("</Root>\r\n");
System.out.println("@@xmlString For Scheme :: "+valueXmlString.toString()); String retXmlString = serializeDom(genericUtility.parseString(valueXmlString.toString()));
Document finalxml = genericUtility.parseString(valueXmlString.toString()); valueXmlString = null;
NodeList detail1NodeList = finalxml.getElementsByTagName("Detail"); System.out.println(" retXmlString 4 ["+ retXmlString +"]");
valueXmlString = new StringBuffer(retXmlString);
System.out.println("@SchemeXml length:"+detail1NodeList.getLength());
for(int nodeCnt = 0;nodeCnt<detail1NodeList.getLength();nodeCnt++) }
catch(Exception e)
{ {
domID1++; e.printStackTrace();
System.out.println("New DomID"+domID1); throw new ITMException(e);
detail1NodeList.item(nodeCnt).getAttributes().getNamedItem("domId").setNodeValue(String.valueOf(domID1)); }
return valueXmlString.toString();
}
//End of Invoicepickbutton method
public String actionHandlerTransform(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams, String selDataStr) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document selDataDom = null;
String retString = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = new ibase.utility.E12GenericUtility().parseString(xmlString);
dom1 = new ibase.utility.E12GenericUtility().parseString(xmlString1);
if(selDataStr != null && selDataStr.length() > 0)
{
selDataDom = new ibase.utility.E12GenericUtility().parseString(selDataStr);
}
} }
System.out.println("actionType:"+actionType+":");
System.out.println(""); if (actionType.equalsIgnoreCase("invoices"))
newDomXml = genericUtility.serializeDom(finalxml); {
System.out.println("XML For Scheme with new domID ["+newDomXml+"]"); retString = invoiceTransform(dom, dom1, objContext, xtraParams, selDataDom);
}
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :SalesReturnAct :actionHandlerTransform(String xmlString):" + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
return newDomXml;
System.out.println("returning String from SalesReturnAct..................");
return retString;
}
private String invoiceTransform(Document dom,Document dom1, String objContext, String xtraParams, Document selDataDom)throws ITMException
{
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null,pstmt2 = null;
ResultSet rs = null,rs2 = null;
String sql = "";
String errCode = "";
String lotNo ="";
String siteCode = "";
String itemCode = "";
String errString = "";
String flag = "";
String invoiceId = "";
String locCode = "";
String lotNoInv = "";
String lotSlInv = "";
String sreturnAdjOpt = "";
String orderByStr = "";
String custCode = "";
String reason = "";
String docKey = "";
String siteCodeMfgFn = "";
String packCodeFn = "";
String chkDate = "";
String quantity = "";
String stkMfgDate = "";
String inputQtyStr = "";
String lotSl ="";
String siteCodeMfg ="",newDomXml="";
String packCode ="";
String unit = "";
java.sql.Date expDate = null;
java.sql.Date mfgDate = null;
int minShelfLife = 0;
int detCnt =0,cnt=0,lotCnt=0;
double totStk =0.0;
double inputQty = 0.0,lotQty=0;
double qty =0;
double qtyStk = 0,invoiceQty=0,adjQty=0,rate=0;
DistCommon distCommon = null;
distCommon = new DistCommon();
E12GenericUtility genericUtility= new E12GenericUtility();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
DecimalFormat df = new DecimalFormat("#########.###");
try
{
conn = getConnection();
quantity = genericUtility.getColumnValue("quantity",dom);
if(quantity != null && quantity.trim().length() > 0)
{
qty = Double.parseDouble(quantity);
}
siteCode = genericUtility.getColumnValue("site_code",dom1);
itemCode = genericUtility.getColumnValue("item_code",dom);
lotNo = genericUtility.getColumnValue("lot_no",dom);
custCode = genericUtility.getColumnValue("cust_code",dom1);
NodeList detailList = selDataDom.getElementsByTagName("Detail");
int noOfDetails = detailList.getLength();
for(int ctr = 0; ctr < noOfDetails; ctr++)
{
if (qty > 0)
{
Node currDetail = detailList.item(ctr);
invoiceId = genericUtility.getColumnValueFromNode("invoice_ref", currDetail);
inputQtyStr = genericUtility.getColumnValueFromNode("quantity", currDetail);
inputQty = inputQtyStr == null || inputQtyStr.trim().length() == 0 ? 0 : Double.parseDouble(inputQtyStr);
System.out.println("inputQty Transform :: " + inputQty);
System.out.println("invoiceId Transform :: " + invoiceId);
valueXmlString.append("<Detail>");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]>").append("</lot_no>\r\n");
if(qty > inputQty)
{
valueXmlString.append("<quantity>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n");
}
else {
valueXmlString.append("<quantity>").append("<![CDATA[").append(qty).append("]]>").append("</quantity>\r\n");
}
valueXmlString.append("<invoice_ref>").append("<![CDATA[").append(invoiceId).append("]]>").append("</invoice_ref>\r\n");
valueXmlString.append("</Detail>");
qty=qty-inputQty;
}//if (icQtyOrd > 0)
}
valueXmlString.append("</Root>");
String retXmlString = serializeDom(genericUtility.parseString(valueXmlString.toString()));
valueXmlString = null;
System.out.println(" retXmlString 5 ["+ retXmlString +"]");
valueXmlString = new StringBuffer(retXmlString);
}
catch(ITMException itme)
{
throw itme;
}
catch(Exception e)
{
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Closing Connection................");
if (pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
throw new ITMException(e);
}
}
System.out.println("Print valueXmlString.toString() \n["+valueXmlString.toString()+"]");
return valueXmlString.toString();
}
private String serializeDom(Node dom) throws Exception
{
String retString = null;
try
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
Transformer serializer = TransformerFactory.newInstance().newTransformer();
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
serializer.transform(new DOMSource(dom), new javax.xml.transform.stream.StreamResult(out));
retString = out.toString();
out.flush();
out.close();
out = null;
}
catch (Exception e)
{
System.out.println("Exception : In : serializeDom :"+e);
e.printStackTrace();
}
return retString;
} }
//End of Invoicepickbutton method
} }
\ 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