Commit dc168ac0 authored by msharma's avatar msharma

DI1HSUN009 Employe Code addition and validation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91558 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c8a5b300
...@@ -13,59 +13,54 @@ import ibase.system.config.*; ...@@ -13,59 +13,54 @@ import ibase.system.config.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3 @Stateless
public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, ChargeBackLocRemote // added for ejb3
{ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal,
ChargeBackLocRemote {
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
String loginSite = ""; String loginSite = "";
/* public void ejbCreate() throws RemoteException, CreateException /*
{ * public void ejbCreate() throws RemoteException, CreateException {
System.out.println("ChargeBackLocEJB is in Process.........."); * System.out.println("ChargeBackLocEJB is in Process.........."); } public
} * void ejbRemove() { } public void ejbActivate() { } public void
public void ejbRemove() * ejbPassivate() { }
{ */
} public String wfValData() throws RemoteException, ITMException {
public void ejbActivate()
{
}
public void ejbPassivate()
{
} */
public String wfValData() throws RemoteException,ITMException
{
return ""; return "";
} }
public String itemChanged() throws RemoteException,ITMException public String itemChanged() throws RemoteException, ITMException {
{
return ""; return "";
} }
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{ public String wfValData(String xmlString, String xmlString1,
String xmlString2, String objContext, String editFlag,
String xtraParams) throws RemoteException, ITMException {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
String errString = null; String errString = null;
System.out.println("Validation Start.........."); System.out.println("Validation Start..........");
try try {
{
dom = parseString(xmlString); dom = parseString(xmlString);
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 ) if (xmlString2.trim().length() > 0) {
{
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
} }
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag,
} xtraParams);
catch(Exception e) } catch (Exception e) {
{ System.out
System.out.println("Exception : AssetRegisterICEJB : wfValData(String xmlString) : ==>\n"+e.getMessage()); .println("Exception : AssetRegisterICEJB : wfValData(String xmlString) : ==>\n"
+ e.getMessage());
} }
return (errString); return (errString);
} }
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{ public String wfValData(Document dom, Document dom1, Document dom2,
String objContext, String editFlag, String xtraParams)
throws RemoteException, ITMException {
String errString = " "; String errString = " ";
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
...@@ -80,6 +75,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -80,6 +75,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
String userId = null; String userId = null;
String custCode = null; String custCode = null;
String itemCode = ""; String itemCode = "";
String empCode = "";
String quantity = ""; String quantity = "";
String saleQty = ""; String saleQty = "";
String saleRetQty = ""; String saleRetQty = "";
...@@ -91,7 +87,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -91,7 +87,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
int currentFormNo = 0; int currentFormNo = 0;
int childNodeListLength; int childNodeListLength;
Connection conn = null; Connection conn = null;
PreparedStatement pStmt=null; PreparedStatement pStmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = null; String sql = null;
String statSal = ""; String statSal = "";
...@@ -101,53 +97,46 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -101,53 +97,46 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
String siteCode = ""; String siteCode = "";
String prdCode = ""; String prdCode = "";
java.sql.Timestamp tranDateTs = null; java.sql.Timestamp tranDateTs = null;
try try {
{ System.out.println("wfValData called");
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"); loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0) {
{
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch(currentFormNo) switch (currentFormNo) {
{ case 1:
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 1 ].........."); System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if ( childNodeName.equalsIgnoreCase( "cust_code" ) ) if (childNodeName.equalsIgnoreCase("cust_code")) {
{ if (childNode.getFirstChild() == null) {
if ( childNode.getFirstChild() == null ) errString = itmDBAccessEJB.getErrorString(
{ "cust_code", "VMCUSTNUL", userId);
errString =itmDBAccessEJB.getErrorString("cust_code","VMCUSTNUL",userId); break;
break ; } else {
} custCode = genericUtility.getColumnValue(
else "cust_code", dom, "1");
{
custCode = genericUtility.getColumnValue( "cust_code", dom, "1" );
sql = " SELECT COUNT(*) FROM customer WHERE cust_code = ? "; sql = " SELECT COUNT(*) FROM customer WHERE cust_code = ? ";
pStmt = conn.prepareStatement( sql ); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,custCode.trim()); pStmt.setString(1, custCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt = rs.getInt( 1 );
} }
if( cnt == 0 ) if (cnt == 0) {
{
errCode = "VMINVCUST"; errCode = "VMINVCUST";
errString = getErrorString( "cust_code", errCode, userId ); errString = getErrorString("cust_code",
break ; errCode, userId);
break;
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -156,122 +145,115 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -156,122 +145,115 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt = null; pStmt = null;
} }
} }
if ( childNodeName.equalsIgnoreCase( "tran_date" ) ) if (childNodeName.equalsIgnoreCase("tran_date")) {
{ tranDate = genericUtility.getColumnValue("tran_date",
tranDate = genericUtility.getColumnValue( "tran_date", dom, "1" ); dom, "1");
tranDateTs = Timestamp.valueOf(genericUtility.getValidDateString(tranDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); tranDateTs = Timestamp.valueOf(genericUtility
.getValidDateString(tranDate,
genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat())
+ " 00:00:00.0");
sql = "Select code from period where ? between fr_date and to_date "; sql = "Select code from period where ? between fr_date and to_date ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setTimestamp(1,tranDateTs); pStmt.setTimestamp(1, tranDateTs);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ prdCode = rs.getString(1);
prdCode = rs.getString( 1 );
} }
rs.close(); rs.close();
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
if( prdCode != null && prdCode.trim().length() > 0 ) if (prdCode != null && prdCode.trim().length() > 0) {
{
sql = "Select count(1) from period_stat where prd_code = ? " sql = "Select count(1) from period_stat where prd_code = ? "
+" AND site_code = ? "; + " AND site_code = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,prdCode.trim()); pStmt.setString(1, prdCode.trim());
pStmt.setString(2,loginSite.trim()); pStmt.setString(2, loginSite.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt = rs.getInt( 1 );
} }
rs.close(); rs.close();
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
if( cnt > 0 ) if (cnt > 0) {
{
sql = "Select stat_sal from period_stat where prd_code = ? and site_code = ? "; sql = "Select stat_sal from period_stat where prd_code = ? and site_code = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,prdCode.trim()); pStmt.setString(1, prdCode.trim());
pStmt.setString(2,loginSite.trim()); pStmt.setString(2, loginSite.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ statSal = rs.getString(1);
statSal = rs.getString( 1 );
} }
rs.close(); rs.close();
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
if( statSal != null && statSal.trim().equalsIgnoreCase("N") ) if (statSal != null
{ && statSal.trim().equalsIgnoreCase("N")) {
errString =itmDBAccessEJB.getErrorString("","VMSTATSNVL",userId); errString = itmDBAccessEJB.getErrorString(
break ; "", "VMSTATSNVL", userId);
} break;
}
else
{
errString =itmDBAccessEJB.getErrorString("","VMSTATSND",userId);
break ;
}
} }
else } else {
{ errString = itmDBAccessEJB.getErrorString("",
errString =itmDBAccessEJB.getErrorString("","VMPRDNTDF",userId); "VMSTATSND", userId);
break ; break;
} }
} else {
errString = itmDBAccessEJB.getErrorString("",
"VMPRDNTDF", userId);
break;
} }
if ( childNodeName.equalsIgnoreCase( "tran_type" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("tran_type","VMTRNTPNUL",userId);
break ;
} }
if (childNodeName.equalsIgnoreCase("tran_type")) {
if (childNode.getFirstChild() == null) {
errString = itmDBAccessEJB.getErrorString(
"tran_type", "VMTRNTPNUL", userId);
break;
} }
if ( childNodeName.equalsIgnoreCase( "type" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("type","VMSDRTPNUL",userId);
break ;
} }
if (childNodeName.equalsIgnoreCase("type")) {
if (childNode.getFirstChild() == null) {
errString = itmDBAccessEJB.getErrorString("type",
"VMSDRTPNUL", userId);
break;
} }
if ( childNodeName.equalsIgnoreCase( "item_ser" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("item_ser","VMITMSRNUL",userId);
break ;
} }
if (childNodeName.equalsIgnoreCase("item_ser")) {
if (childNode.getFirstChild() == null) {
errString = itmDBAccessEJB.getErrorString(
"item_ser", "VMITMSRNUL", userId);
break;
} }
if ( childNodeName.equalsIgnoreCase( "cust_code__credit" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("cust_code__credit","VMCUSTNUL",userId);
break ;
} }
else if (childNodeName.equalsIgnoreCase("cust_code__credit")) {
{ if (childNode.getFirstChild() == null) {
custCode = genericUtility.getColumnValue( "cust_code__credit", dom, "1" ); errString = itmDBAccessEJB.getErrorString(
if( custCode != null && custCode.trim().length() > 0 ) "cust_code__credit", "VMCUSTNUL", userId);
{ break;
} else {
custCode = genericUtility.getColumnValue(
"cust_code__credit", dom, "1");
if (custCode != null
&& custCode.trim().length() > 0) {
sql = " SELECT COUNT(*) FROM customer WHERE cust_code = ? "; sql = " SELECT COUNT(*) FROM customer WHERE cust_code = ? ";
pStmt = conn.prepareStatement( sql ); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,custCode.trim()); pStmt.setString(1, custCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt = rs.getInt( 1 );
} }
if( cnt == 0 ) if (cnt == 0) {
{
errCode = "VMINVCUST"; errCode = "VMINVCUST";
errString = getErrorString( "cust_code__credit", errCode, userId ); errString = getErrorString(
break ; "cust_code__credit", errCode,
userId);
break;
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -280,31 +262,60 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -280,31 +262,60 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
} }
} }
if ( childNodeName.equalsIgnoreCase( "site_code" ) ) // add by akhilesh 01-12 2011 (set employee emp_fname,emp_mname,emp_lname basis of emp_code)
{ if (childNodeName.equalsIgnoreCase("emp_code")) {
if ( childNode.getFirstChild() == null ) if (childNode.getFirstChild() == null) {
{ errString = itmDBAccessEJB.getErrorString(
errString =itmDBAccessEJB.getErrorString("site_code","VMSITENUL",userId); "emp_code", "VMECODENULL", userId);
break ; break;
} else {
empCode = genericUtility.getColumnValue(
"emp_code", dom, "1");
if (empCode != null
&& empCode.trim().length() > 0) {
sql = " SELECT COUNT(1) FROM employee WHERE emp_code = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, empCode.trim());
rs = pStmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
} }
else if (cnt == 0) {
{ errCode = "VMINVECODE";
siteCode = genericUtility.getColumnValue( "site_code", dom, "1" ); errString = getErrorString("emp_code",
if( siteCode != null && siteCode.trim().length() > 0 ) errCode, userId);
{ break;
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
}
}//
if (childNodeName.equalsIgnoreCase("site_code")) {
if (childNode.getFirstChild() == null) {
errString = itmDBAccessEJB.getErrorString(
"site_code", "VMSITENUL", userId);
break;
} else {
siteCode = genericUtility.getColumnValue(
"site_code", dom, "1");
if (siteCode != null
&& siteCode.trim().length() > 0) {
sql = " SELECT COUNT(1) FROM site WHERE site_code = ? "; sql = " SELECT COUNT(1) FROM site WHERE site_code = ? ";
pStmt = conn.prepareStatement( sql ); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,siteCode.trim()); pStmt.setString(1, siteCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt = rs.getInt( 1 );
} }
if( cnt == 0 ) if (cnt == 0) {
{
errCode = "VMINVSITE"; errCode = "VMINVSITE";
errString = getErrorString( "site_code", errCode, userId ); errString = getErrorString("site_code",
break ; errCode, userId);
break;
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -313,31 +324,28 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -313,31 +324,28 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
} }
} }
if ( childNodeName.equalsIgnoreCase( "site_code__cr" ) ) if (childNodeName.equalsIgnoreCase("site_code__cr")) {
{ if (childNode.getFirstChild() == null) {
if ( childNode.getFirstChild() == null ) errString = itmDBAccessEJB.getErrorString(
{ "site_code__cr", "VMSITENUL", userId);
errString =itmDBAccessEJB.getErrorString("site_code__cr","VMSITENUL",userId); break;
break ; } else {
} siteCode = genericUtility.getColumnValue(
else "site_code__cr", dom, "1");
{ if (siteCode != null
siteCode = genericUtility.getColumnValue( "site_code__cr", dom, "1" ); && siteCode.trim().length() > 0) {
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = " SELECT COUNT(1) FROM site WHERE site_code = ? "; sql = " SELECT COUNT(1) FROM site WHERE site_code = ? ";
pStmt = conn.prepareStatement( sql ); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,siteCode.trim()); pStmt.setString(1, siteCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt = rs.getInt( 1 );
} }
if( cnt == 0 ) if (cnt == 0) {
{
errCode = "VMINVSITE"; errCode = "VMINVSITE";
errString = getErrorString( "site_code__cr", errCode, userId ); errString = getErrorString("site_code__cr",
break ; errCode, userId);
break;
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -347,46 +355,42 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -347,46 +355,42 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
} }
} }
//END OF CASE1 // END OF CASE1
break; break;
case 2 : case 2:
System.out.println("VALIDATION FOR DETAIL [ 2 ].........."); System.out.println("VALIDATION FOR DETAIL [ 2 ]..........");
//String update_flag = null; // String update_flag = null;
parentNodeList = dom.getElementsByTagName("Detail2"); parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if ( childNodeName.equalsIgnoreCase( "item_code" ) ) if (childNodeName.equalsIgnoreCase("item_code")) {
{ if (childNode.getFirstChild() == null) {
if ( childNode.getFirstChild() == null ) errString = itmDBAccessEJB.getErrorString(
{ "item_code", "VTITMNUL", userId);
errString =itmDBAccessEJB.getErrorString("item_code","VTITMNUL",userId); break;
break ; } else {
} itemCode = genericUtility.getColumnValue(
else "item_code", dom);
{ if (itemCode != null & itemCode.trim().length() > 0) {
itemCode = genericUtility.getColumnValue( "item_code", dom );
if( itemCode != null & itemCode.trim().length() > 0 )
{
sql = "SELECT count(*) from item" sql = "SELECT count(*) from item"
+" where item_code = ? "; + " where item_code = ? ";
pStmt = conn.prepareStatement( sql ); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,itemCode.trim()); pStmt.setString(1, itemCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt = rs.getInt( 1 ); }
} System.out.println(" COUNT =====> [" + cnt
System.out.println(" COUNT =====> [" + cnt + "]"); + "]");
if( cnt == 0 ) if (cnt == 0) {
{ errString = itmDBAccessEJB.getErrorString(
errString =itmDBAccessEJB.getErrorString("item_code","VTINVITM",userId); "item_code", "VTINVITM", userId);
break ; break;
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -395,186 +399,173 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -395,186 +399,173 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
} }
} }
if ( childNodeName.equalsIgnoreCase( "lot_no" ) ) if (childNodeName.equalsIgnoreCase("lot_no")) {
{ if (childNode.getFirstChild() == null) {
if ( childNode.getFirstChild() == null ) errString = itmDBAccessEJB.getErrorString("lot_no",
{ "VTLOTNUL", userId);
errString =itmDBAccessEJB.getErrorString("lot_no","VTLOTNUL",userId); break;
break ;
}
} }
if ( childNodeName.equalsIgnoreCase( "porder_no" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("porder_no","VTBILNONUL",userId);
break ;
} }
else if (childNodeName.equalsIgnoreCase("porder_no")) {
{ if (childNode.getFirstChild() == null) {
billNo = genericUtility.getColumnValue( "porder_no", dom ); errString = itmDBAccessEJB.getErrorString(
custCode = genericUtility.getColumnValue( "cust_code", dom1 ); "porder_no", "VTBILNONUL", userId);
tranId = genericUtility.getColumnValue( "tran_id", dom1 ); break;
} else {
billNo = genericUtility.getColumnValue("porder_no",
dom);
custCode = genericUtility.getColumnValue(
"cust_code", dom1);
tranId = genericUtility.getColumnValue("tran_id",
dom1);
sql = "Select count(1) from charge_back A, charge_back_det B where" sql = "Select count(1) from charge_back A, charge_back_det B where"
+" A.tran_id = B.tran_id " + " A.tran_id = B.tran_id "
+" and A.cust_code = ? " + " and A.cust_code = ? "
+" and B.porder_no = ? " + " and B.porder_no = ? "
+" and A.tran_id <> '"+tranId+"' "; + " and A.tran_id <> '" + tranId + "' ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode.trim() ); pStmt.setString(1, custCode.trim());
pStmt.setString(2, billNo.trim() ); pStmt.setString(2, billNo.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt = rs.getInt( 1 );
} }
pStmt.close(); pStmt.close();
rs.close(); rs.close();
if( cnt >= 1 ) if (cnt >= 1) {
{ errString = itmDBAccessEJB.getErrorString(
errString =itmDBAccessEJB.getErrorString("porder_no","VTBILNOPST",userId); "porder_no", "VTBILNOPST", userId);
break ; break;
}
}
} }
if ( childNodeName.equalsIgnoreCase( "porder_date" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("porder_date","VTBILDTNUL",userId);
break ;
} }
} }
/* if ( childNodeName.equalsIgnoreCase( "discount_per" ) ) if (childNodeName.equalsIgnoreCase("porder_date")) {
{ if (childNode.getFirstChild() == null) {
if ( childNode.getFirstChild() == null ) errString = itmDBAccessEJB.getErrorString(
{ "porder_date", "VTBILDTNUL", userId);
errString =itmDBAccessEJB.getErrorString("discount_per","VTDISPNUL",userId); break;
break ;
} }
} */
if ( childNodeName.equalsIgnoreCase( "item_ser" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("item_ser","VTITMSRNUL",userId);
break ;
} }
/*
* if ( childNodeName.equalsIgnoreCase( "discount_per" ) ) {
* if ( childNode.getFirstChild() == null ) { errString
* =itmDBAccessEJB
* .getErrorString("discount_per","VTDISPNUL",userId); break
* ; } }
*/
if (childNodeName.equalsIgnoreCase("item_ser")) {
if (childNode.getFirstChild() == null) {
errString = itmDBAccessEJB.getErrorString(
"item_ser", "VTITMSRNUL", userId);
break;
} }
if ( childNodeName.equalsIgnoreCase( "quantity" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("quantity","VTQUANTNUL",userId);
break ;
} }
else if (childNodeName.equalsIgnoreCase("quantity")) {
{ if (childNode.getFirstChild() == null) {
quantity = genericUtility.getColumnValue( "quantity", dom ); errString = itmDBAccessEJB.getErrorString(
saleQty = genericUtility.getColumnValue( "sale_qty", dom ); "quantity", "VTQUANTNUL", userId);
saleRetQty = genericUtility.getColumnValue( "sale_ret_qty", dom ); break;
unconfQty = genericUtility.getColumnValue( "unconf_claimed", dom ); } else {
confQty = genericUtility.getColumnValue( "conf_claimed", dom ); quantity = genericUtility.getColumnValue(
if (quantity == null || "null".equals(quantity)) "quantity", dom);
{ saleQty = genericUtility.getColumnValue("sale_qty",
dom);
saleRetQty = genericUtility.getColumnValue(
"sale_ret_qty", dom);
unconfQty = genericUtility.getColumnValue(
"unconf_claimed", dom);
confQty = genericUtility.getColumnValue(
"conf_claimed", dom);
if (quantity == null || "null".equals(quantity)) {
quantity = "0"; quantity = "0";
} }
if (saleQty == null || "null".equals(saleQty)) if (saleQty == null || "null".equals(saleQty)) {
{
saleQty = "0"; saleQty = "0";
} }
if (saleRetQty == null || "null".equals(saleRetQty)) if (saleRetQty == null || "null".equals(saleRetQty)) {
{
saleRetQty = "0"; saleRetQty = "0";
} }
if (unconfQty == null || "null".equals(unconfQty)) if (unconfQty == null || "null".equals(unconfQty)) {
{
unconfQty = "0"; unconfQty = "0";
} }
if (confQty == null || "null".equals(confQty)) if (confQty == null || "null".equals(confQty)) {
{
confQty = "0"; confQty = "0";
} }
double qtyDbl = Double.parseDouble(quantity); double qtyDbl = Double.parseDouble(quantity);
double saleQtyDbl = Double.parseDouble(saleQty); double saleQtyDbl = Double.parseDouble(saleQty);
double saleRetQtyDbl = Double.parseDouble(saleRetQty); double saleRetQtyDbl = Double
.parseDouble(saleRetQty);
double unconfQtyDbl = Double.parseDouble(unconfQty); double unconfQtyDbl = Double.parseDouble(unconfQty);
double confQtyDbl = Double.parseDouble(confQty); double confQtyDbl = Double.parseDouble(confQty);
// 14/06/10 manoharan to consider lines other than current in which // 14/06/10 manoharan to consider lines other than
// current in which
// the same sales order line is used // the same sales order line is used
// end 14/06/10 manoharan // end 14/06/10 manoharan
if( qtyDbl > ( saleQtyDbl - saleRetQtyDbl - unconfQtyDbl - confQtyDbl ) ) if (qtyDbl > (saleQtyDbl - saleRetQtyDbl
{ - unconfQtyDbl - confQtyDbl)) {
errString =itmDBAccessEJB.getErrorString("quantity","VTINVQUANT",userId); errString = itmDBAccessEJB.getErrorString(
break ; "quantity", "VTINVQUANT", userId);
} break;
} }
} }
if ( childNodeName.equalsIgnoreCase( "rate__contr" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("rate__contr","VTRATCRNUL",userId);
break ;
} }
else if (childNodeName.equalsIgnoreCase("rate__contr")) {
{ if (childNode.getFirstChild() == null) {
String rateSell = genericUtility.getColumnValue( "rate__sell", dom ); errString = itmDBAccessEJB.getErrorString(
String rateContr = childNode.getFirstChild().getNodeValue(); "rate__contr", "VTRATCRNUL", userId);
if( rateSell == null ) break;
} else {
String rateSell = genericUtility.getColumnValue(
"rate__sell", dom);
String rateContr = childNode.getFirstChild()
.getNodeValue();
if (rateSell == null)
rateSell = "0"; rateSell = "0";
if( rateContr == null ) if (rateContr == null)
rateContr = "0"; rateContr = "0";
/*if( Double.parseDouble(rateContr) > Double.parseDouble(rateSell) ) /*
{ * if( Double.parseDouble(rateContr) >
errString =itmDBAccessEJB.getErrorString("rate__contr","EDCSTRTINV",userId); * Double.parseDouble(rateSell) ) { errString
break ; * =itmDBAccessEJB
}*/ * .getErrorString("rate__contr","EDCSTRTINV"
if( Double.parseDouble(rateContr) < 0 ) * ,userId); break ; }
{ */
errString =itmDBAccessEJB.getErrorString("rate__contr","VTSTKBILRT",userId); if (Double.parseDouble(rateContr) < 0) {
break ; errString = itmDBAccessEJB.getErrorString(
"rate__contr", "VTSTKBILRT", userId);
break;
} }
} }
} }
}//END FOR OF CASE2 }// END FOR OF CASE2
break; break;
}//END SWITCH }// END SWITCH
}//END TRY }// END TRY
catch(Exception e) catch (Exception e) {
{ System.out.println("Exception ::" + e);
System.out.println("Exception ::" +e);
e.printStackTrace(); e.printStackTrace();
errCode = "VALEXCEP"; errCode = "VALEXCEP";
errString = getErrorString( "", errCode, userId ); errString = getErrorString("", errCode, userId);
} } finally {
finally try {
{ if (conn != null) {
try if (pStmt != null) {
{
if(conn != null)
{
if( pStmt != null )
{
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
} }
if( rs != null ) if (rs != null) {
{
rs.close(); rs.close();
rs = null; rs = null;
} }
conn.close(); conn.close();
} }
conn = null; conn = null;
} } catch (Exception d) {
catch(Exception d)
{
d.printStackTrace(); d.printStackTrace();
} }
System.out.println(" < AssetRegisterIcEJB > CONNECTION IS CLOSED"); System.out.println(" < AssetRegisterIcEJB > CONNECTION IS CLOSED");
...@@ -582,31 +573,34 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -582,31 +573,34 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
System.out.println("ErrString ::" + errString); System.out.println("ErrString ::" + errString);
return errString; return errString;
}//END OF VALIDATION }// END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException public String itemChanged(String xmlString, String xmlString1,
{ String xmlString2, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException,
ITMException {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
String valueXmlString = null; String valueXmlString = null;
try try {
{
System.out.println("xmlString" + xmlString); System.out.println("xmlString" + xmlString);
dom = parseString(xmlString); dom = parseString(xmlString);
System.out.println("xmlString1" + xmlString1); System.out.println("xmlString1" + xmlString1);
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 ) if (xmlString2.trim().length() > 0) {
{
System.out.println("xmlString2" + xmlString2); System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2 + "</Root>"); dom2 = parseString("<Root>" + xmlString2 + "</Root>");
} }
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams); System.out.println("testing Itemchange");
} valueXmlString = itemChanged(dom, dom1, dom2, objContext,
catch(Exception e) currentColumn, editFlag, xtraParams);
{ System.out.println("valueXmlString----"+valueXmlString);
System.out.println("Exception : [AssetRegisterICEJB][itemChanged] :==>\n"+e.getMessage()); } catch (Exception e) {
System.out
.println("Exception : [AssetRegisterICEJB][itemChanged] :==>\n"
+ e.getMessage());
} }
return valueXmlString; return valueXmlString;
} }
...@@ -649,8 +643,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -649,8 +643,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
String siteDescr = ""; String siteDescr = "";
String currCode = ""; String currCode = "";
double exchRate = 0.0; String empCode="";
String empFname = "";
String empMname = "";
String empLname = "";
String custCdEnd = ""; String custCdEnd = "";
double exchRate = 0.0;
double saleQty = 0.0; double saleQty = 0.0;
double discPerc = 0.0; double discPerc = 0.0;
double saleRetQty = 0.0; double saleRetQty = 0.0;
...@@ -863,7 +861,9 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -863,7 +861,9 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
if( rs.next() ) if( rs.next() )
{ {
custName = rs.getString( "cust_name" ); custName = rs.getString( "cust_name" );
System.out.println("custName-----------"+custName);
} }
rs.close(); rs.close();
rs = null; rs = null;
pStmt.close(); pStmt.close();
...@@ -1091,6 +1091,38 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1091,6 +1091,38 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
valueXmlString.append("<cust_name__credit>").append("<![CDATA[" + ( custName )+ "]]>").append("</cust_name__credit>"); valueXmlString.append("<cust_name__credit>").append("<![CDATA[" + ( custName )+ "]]>").append("</cust_name__credit>");
} }
//add by akhilesh 01-12-2011 item change again of emp_code
if (currentColumn.trim().equals( "emp_code" ))
{
System.out.println("Entered in EmpCode tem Change");
empCode=genericUtility.getColumnValue( "emp_code", dom );
System.out.println("empCode----"+empCode);
if( empCode != null && empCode.trim().length() > 0)
{
sql = "select emp_fname,emp_mname,emp_lname from employee "
+" where emp_code = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString(1,empCode.trim());
rs = pStmt.executeQuery();
if( rs.next() )
{
System.out.println("empFname---"+empFname);
empFname = rs.getString( "emp_fname" );
empMname = rs.getString( "emp_mname" );
empLname = rs.getString( "emp_lname" );
}
valueXmlString.append("<emp_fname>").append("<![CDATA[" + ( empFname )+ "]]>").append("</emp_fname>");
valueXmlString.append("<emp_mname>").append("<![CDATA[" + ( empMname )+ "]]>").append("</emp_mname>");
valueXmlString.append("<emp_lname>").append("<![CDATA[" + ( empLname )+ "]]>").append("</emp_lname>");
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
}
if (currentColumn.trim().equals( "cust_code__end" )) if (currentColumn.trim().equals( "cust_code__end" ))
{ {
custCode = genericUtility.getColumnValue( "cust_code__end", dom ); custCode = genericUtility.getColumnValue( "cust_code__end", dom );
...@@ -1221,7 +1253,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1221,7 +1253,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
valueXmlString.append("<discount_per>").append("<![CDATA["+ discPerc + "]]>").append("</discount_per>"); valueXmlString.append("<discount_per>").append("<![CDATA["+ discPerc + "]]>").append("</discount_per>");
} }
valueXmlString.append("<item_ser>").append("<![CDATA["+ itemSeries != null ? itemSeries : "" + "]]>").append("</item_ser>"); valueXmlString.append("<item_ser>").append("<![CDATA["+ itemSeries != null ? itemSeries : "" + "]]>").append("</item_ser>");
///////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////
// 27/05/10 manoharan bill_no, bill_date and discount to be carried forward // 27/05/10 manoharan bill_no, bill_date and discount to be carried forward
NodeList detail2List = null; NodeList detail2List = null;
Node detailNode = null; Node detailNode = null;
...@@ -1306,7 +1338,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1306,7 +1338,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
} }
///////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////
} }
//if (currentColumn.trim().equals( "itm_defaultedit" )) //if (currentColumn.trim().equals( "itm_defaultedit" ))
if (currentColumn.trim().equals( "lot_no" )) if (currentColumn.trim().equals( "lot_no" ))
...@@ -1622,86 +1654,86 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1622,86 +1654,86 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
} }
} }
return valueXmlString.toString(); return valueXmlString.toString();
}//END OF ITEMCHANGE }// END OF ITEMCHANGE
private String getCurrdateAppFormat() throws Exception,ITMException
{ private String getCurrdateAppFormat() throws Exception, ITMException {
String s = ""; String s = "";
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
try try {
{
java.util.Date date = null; java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis()); Timestamp timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat()); SimpleDateFormat simpledateformat = new SimpleDateFormat(
genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString()); date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0"); timestamp = Timestamp.valueOf(simpledateformat.format(date)
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString(); .toString() + " 00:00:00.0");
} s = (new SimpleDateFormat(genericUtility.getApplDateFormat()))
catch(Exception exception) .format(timestamp).toString();
{ } catch (Exception exception) {
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage()); System.out.println("Exception in getCurrdateAppFormat "
+ exception.getMessage());
throw new ITMException(exception); throw new ITMException(exception);
} }
return s; return s;
} }
private Timestamp getCurrdateTsFormat() throws Exception,ITMException
{ private Timestamp getCurrdateTsFormat() throws Exception, ITMException {
String s = ""; String s = "";
Timestamp timestamp = null; Timestamp timestamp = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
try try {
{
java.util.Date date = null; java.util.Date date = null;
timestamp = new Timestamp(System.currentTimeMillis()); timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat()); SimpleDateFormat simpledateformat = new SimpleDateFormat(
genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString()); date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0"); timestamp = Timestamp.valueOf(simpledateformat.format(date)
} .toString() + " 00:00:00.0");
catch(Exception exception) } catch (Exception exception) {
{ System.out.println("Exception in getCurrdateAppFormat "
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage()); + exception.getMessage());
throw new ITMException(exception); throw new ITMException(exception);
} }
return timestamp; return timestamp;
} }
private String getNodeValue( Node currDet, String fldName, boolean isAttribute )
{ private String getNodeValue(Node currDet, String fldName,
boolean isAttribute) {
String fldValue = null; String fldValue = null;
boolean isFound = false; boolean isFound = false;
NodeList currNodes = currDet.getChildNodes(); NodeList currNodes = currDet.getChildNodes();
int currDetLen = currNodes.getLength(); int currDetLen = currNodes.getLength();
for(int detIdx = 0; detIdx < currDetLen && !isFound ; detIdx++ ) for (int detIdx = 0; detIdx < currDetLen && !isFound; detIdx++) {
{ Node currNode = currNodes.item(detIdx);
Node currNode = currNodes.item( detIdx );
String nodeName = currNode.getNodeName(); String nodeName = currNode.getNodeName();
if( isAttribute == true ) if (isAttribute == true) {
{ if (nodeName.equalsIgnoreCase("attribute")) {
if ( nodeName.equalsIgnoreCase( "attribute" ) ) fldValue = currNode.getAttributes().getNamedItem(fldName)
{ .getNodeValue();
fldValue = currNode.getAttributes().getNamedItem( fldName ).getNodeValue();
isFound = true; isFound = true;
} }
} } else if (currNode.getNodeType() == Node.ELEMENT_NODE
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( fldName ) ) && nodeName.equalsIgnoreCase(fldName)) {
{ fldValue = currNode.getFirstChild() != null ? currNode
fldValue = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : null; .getFirstChild().getNodeValue().trim() : null;
isFound = true; isFound = true;
} }
} }
return fldValue; return fldValue;
} }
private String getItemChgdata( Document dom, Document dom1, Document dom2, Connection conn ) throws RemoteException,ITMException
{ private String getItemChgdata(Document dom, Document dom1, Document dom2,
Connection conn) throws RemoteException, ITMException {
StringBuffer itmChangeString = new StringBuffer(""); StringBuffer itmChangeString = new StringBuffer("");
String sql = ""; String sql = "";
ResultSet rs = null; ResultSet rs = null;
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
String tempQty = "0", tempLotNo = "", tempItemCode = "", tempLineNo; String tempQty = "0", tempLotNo = "", tempItemCode = "", tempLineNo;
double dTempQty = 0; double dTempQty = 0;
try try {
{
String itemDescr = ""; String itemDescr = "";
String itemSer = ""; String itemSer = "";
double discPerc = 0.0; double discPerc = 0.0;
...@@ -1711,71 +1743,77 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1711,71 +1743,77 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
double confQty = 0.0; double confQty = 0.0;
double unconfQty = 0.0; double unconfQty = 0.0;
java.sql.Timestamp tranDateTs = null; java.sql.Timestamp tranDateTs = null;
String itemCode = genericUtility.getColumnValue( "item_code", dom ); String itemCode = genericUtility.getColumnValue("item_code", dom);
String lotNo = genericUtility.getColumnValue( "lot_no", dom ); String lotNo = genericUtility.getColumnValue("lot_no", dom);
String rateSell = genericUtility.getColumnValue( "rate__sell", dom ); String rateSell = genericUtility.getColumnValue("rate__sell", dom);
String discPerStr = genericUtility.getColumnValue( "discount_per", dom ); String discPerStr = genericUtility.getColumnValue("discount_per",
String tranId = genericUtility.getColumnValue( "tran_id", dom ); dom);
String tranDate = genericUtility.getColumnValue( "tran_date", dom1 ); String tranId = genericUtility.getColumnValue("tran_id", dom);
String lineNo = genericUtility.getColumnValue( "line_no", dom ); String tranDate = genericUtility.getColumnValue("tran_date", dom1);
String siteCode = genericUtility.getColumnValue( "site_code", dom1 ); String lineNo = genericUtility.getColumnValue("line_no", dom);
String siteCodeCr = genericUtility.getColumnValue( "site_code__cr", dom1 ); String siteCode = genericUtility.getColumnValue("site_code", dom1);
String custCode = genericUtility.getColumnValue( "cust_code", dom1 ); String siteCodeCr = genericUtility.getColumnValue("site_code__cr",
String custCdEnd = genericUtility.getColumnValue( "cust_code__end", dom1 ); dom1);
String type = genericUtility.getColumnValue( "type", dom1 ); String custCode = genericUtility.getColumnValue("cust_code", dom1);
String priceList = genericUtility.getColumnValue( "price_list", dom1 ); String custCdEnd = genericUtility.getColumnValue("cust_code__end",
System.out.println("tranDate++>"+tranDate); dom1);
tranDateTs = Timestamp.valueOf(genericUtility.getValidDateString(tranDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); String type = genericUtility.getColumnValue("type", dom1);
System.out.println("tranDateTs++>"+tranDateTs); String priceList = genericUtility
if( itemCode != null && itemCode.trim().length() > 0 ) .getColumnValue("price_list", dom1);
{ System.out.println("tranDate++>" + tranDate);
tranDateTs = Timestamp.valueOf(genericUtility.getValidDateString(
tranDate, genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat())
+ " 00:00:00.0");
System.out.println("tranDateTs++>" + tranDateTs);
if (itemCode != null && itemCode.trim().length() > 0) {
sql = "select DESCR, item_ser from item " sql = "select DESCR, item_ser from item "
+"where item_code = ? "; + "where item_code = ? ";
pStmt = conn.prepareStatement( sql ); pStmt = conn.prepareStatement(sql);
pStmt.setString(1,itemCode.trim()); pStmt.setString(1, itemCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ itemDescr = rs.getString("DESCR");
itemDescr = rs.getString( "DESCR" ); itemSer = rs.getString("item_ser");
itemSer = rs.getString( "item_ser" );
} }
rs.close(); rs.close();
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
itmChangeString.append("<item_descr>").append("<![CDATA[" + ( itemDescr )+ "]]>").append("</item_descr>"); itmChangeString.append("<item_descr>")
itmChangeString.append("<item_ser>").append("<![CDATA[" + ( itemSer )+ "]]>").append("</item_ser>"); .append("<![CDATA[" + (itemDescr) + "]]>")
} .append("</item_descr>");
//itmChangeString.append("<item_descr>").append("<![CDATA[" + ( itemDescr )+ "]]>").append("</item_descr>"); itmChangeString.append("<item_ser>")
// itmChangeString.append("<item_ser>").append("<![CDATA[" + ( itemSer )+ "]]>").append("</item_ser>"); .append("<![CDATA[" + (itemSer) + "]]>")
.append("</item_ser>");
if( type != null && custCdEnd != null && itemSer != null && (discPerStr == null || discPerStr.trim().equals("0.0")) ) }
{ // itmChangeString.append("<item_descr>").append("<![CDATA[" + (
if( type.equals("S") ) // itemDescr )+ "]]>").append("</item_descr>");
{ // itmChangeString.append("<item_ser>").append("<![CDATA[" + (
// itemSer )+ "]]>").append("</item_ser>");
if (type != null && custCdEnd != null && itemSer != null
&& (discPerStr == null || discPerStr.trim().equals("0.0"))) {
if (type.equals("S")) {
sql = "select disc_perc from disc_apr_strg where item_ser = ? " sql = "select disc_perc from disc_apr_strg where item_ser = ? "
+" and sc_code = ? " + " and sc_code = ? "
+" and ? between eff_from and valid_upto "; + " and ? between eff_from and valid_upto ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, itemSer.trim() ); pStmt.setString(1, itemSer.trim());
pStmt.setString(2, custCdEnd.trim() ); pStmt.setString(2, custCdEnd.trim());
pStmt.setTimestamp(3, getCurrdateTsFormat() ); pStmt.setTimestamp(3, getCurrdateTsFormat());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
discPerc = rs.getDouble("disc_perc"); discPerc = rs.getDouble("disc_perc");
} }
} } else {
else
{
sql = "select disc_perc from customer_series where item_ser = ? " sql = "select disc_perc from customer_series where item_ser = ? "
+" and cust_code = ? "; + " and cust_code = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, itemSer.trim() ); pStmt.setString(1, itemSer.trim());
pStmt.setString(2, custCdEnd.trim() ); pStmt.setString(2, custCdEnd.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
discPerc = rs.getDouble("disc_perc"); discPerc = rs.getDouble("disc_perc");
} }
} }
...@@ -1783,19 +1821,19 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1783,19 +1821,19 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
itmChangeString.append("<discount_per>").append("<![CDATA["+ discPerc + "]]>").append("</discount_per>"); itmChangeString.append("<discount_per>")
.append("<![CDATA[" + discPerc + "]]>")
.append("</discount_per>");
} }
if( (priceList == null || priceList.trim().length() == 0) && ( siteCodeCr != null ) ) if ((priceList == null || priceList.trim().length() == 0)
{ && (siteCodeCr != null)) {
sql = "select price_list from site_customer " sql = "select price_list from site_customer "
+" where site_code = ? " + " where site_code = ? " + " and cust_code = ? ";
+" and cust_code = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, siteCodeCr.trim() ); pStmt.setString(1, siteCodeCr.trim());
pStmt.setString(2, custCode.trim() ); pStmt.setString(2, custCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
priceList = rs.getString("price_list"); priceList = rs.getString("price_list");
} }
rs.close(); rs.close();
...@@ -1803,14 +1841,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1803,14 +1841,12 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
if( priceList == null ) if (priceList == null) {
{
sql = "Select price_list from customer where cust_code = ? "; sql = "Select price_list from customer where cust_code = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode.trim() ); pStmt.setString(1, custCode.trim());
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
priceList = rs.getString("price_list"); priceList = rs.getString("price_list");
} }
rs.close(); rs.close();
...@@ -1819,113 +1855,60 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1819,113 +1855,60 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt = null; pStmt = null;
} }
} }
/* if( itemCode != null && itemCode.trim().length() > 0 && lotNo != null && lotNo.trim().length() > 0 ) /*
{ * if( itemCode != null && itemCode.trim().length() > 0 && lotNo !=
sql = "Select rate from pricelist where " * null && lotNo.trim().length() > 0 ) { sql =
+" price_list = ? " * "Select rate from pricelist where " +" price_list = ? "
+" and item_code = ? " * +" and item_code = ? " +" and list_type = 'B' "
+" and list_type = 'B' " * +" and lot_no__from <= ? " +" and lot_no__to >= ? "; pStmt =
+" and lot_no__from <= ? " * conn.prepareStatement(sql); pStmt.setString(1, priceList);
+" and lot_no__to >= ? "; * pStmt.setString(2, itemCode); pStmt.setString(3, lotNo);
pStmt = conn.prepareStatement(sql); * pStmt.setString(4, lotNo); rs = pStmt.executeQuery(); if(
pStmt.setString(1, priceList); * rs.next() ) { rate = rs.getDouble("rate"); } rs.close(); rs =
pStmt.setString(2, itemCode); * null; pStmt.close(); pStmt = null; }
pStmt.setString(3, lotNo); */
pStmt.setString(4, lotNo); if (lotNo != null && lotNo.trim().length() > 0) {
rs = pStmt.executeQuery(); /*
if( rs.next() ) * sql = "Select min(eff_cost) as rate from min_rate_history "
{ * +" where item_code = ? " +" and lot_no = ? "
rate = rs.getDouble("rate"); * +" and cust_code = ? " +" and site_code = ?"; pStmt =
} * conn.prepareStatement(sql); pStmt.setString(1, itemCode);
rs.close(); * pStmt.setString(2, lotNo); pStmt.setString(3, custCode);
rs = null; * pStmt.setString(4, siteCode); rs = pStmt.executeQuery(); if(
pStmt.close(); * rs.next() ) { rate = rs.getDouble("rate"); } rs.close(); rs =
pStmt = null; * null; pStmt.close(); pStmt = null;
} */ *
if( lotNo != null && lotNo.trim().length() > 0 ) * if( rate == 0.0 ) { sql = "Select rate from pricelist "
{ * +" where price_list = ?" +" and item_code = ?"
/*sql = "Select min(eff_cost) as rate from min_rate_history " * +" and lot_no__from <= ?" +" and lot_no__to >= ?" +
+" where item_code = ? " * "and eff_from <= ? " + "and valid_upto >= ?"; pStmt =
+" and lot_no = ? " * conn.prepareStatement(sql); pStmt.setString(1, priceList);
+" and cust_code = ? " * pStmt.setString(2, itemCode); pStmt.setString(3, lotNo);
+" and site_code = ?"; * pStmt.setString(4, lotNo); pStmt.setTimestamp(5, tranDateTs);
pStmt = conn.prepareStatement(sql); * pStmt.setTimestamp(6, tranDateTs); rs = pStmt.executeQuery();
pStmt.setString(1, itemCode); * if( rs.next() ) { rate = rs.getDouble("rate"); } rs.close();
pStmt.setString(2, lotNo); * rs = null; pStmt.close(); pStmt = null; }
pStmt.setString(3, custCode); *
pStmt.setString(4, siteCode); * if( rate == 0.0 ) { sql =
rs = pStmt.executeQuery(); * "Select min(b.rate) as rate from invoice a, invoice_trace b "
if( rs.next() ) * +" where a.invoice_id = b.invoice_id "
{ * +" and a.cust_code = ? " +" and a.site_code = ? "
rate = rs.getDouble("rate"); * +" and a.tran_date <= ? " +" and b.item_code = ? "
} * +" and b.lot_no = ? " +" and a.confirmed = 'Y'" ; pStmt =
rs.close(); * conn.prepareStatement(sql); pStmt.setString(1, custCode);
rs = null; * pStmt.setString(2, siteCode); pStmt.setTimestamp(3,
pStmt.close(); * getCurrdateTsFormat()); pStmt.setString(4, itemCode);
pStmt = null; * pStmt.setString(5, lotNo); rs = pStmt.executeQuery(); if(
* rs.next() ) { rate = rs.getDouble("rate"); } rs.close(); rs =
if( rate == 0.0 ) * null; pStmt.close(); pStmt = null; }
{
sql = "Select rate from pricelist "
+" where price_list = ?"
+" and item_code = ?"
+" and lot_no__from <= ?"
+" and lot_no__to >= ?"
+ "and eff_from <= ? "
+ "and valid_upto >= ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, priceList);
pStmt.setString(2, itemCode);
pStmt.setString(3, lotNo);
pStmt.setString(4, lotNo);
pStmt.setTimestamp(5, tranDateTs);
pStmt.setTimestamp(6, tranDateTs);
rs = pStmt.executeQuery();
if( rs.next() )
{
rate = rs.getDouble("rate");
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
if( rate == 0.0 )
{
sql = "Select min(b.rate) as rate from invoice a, invoice_trace b "
+" where a.invoice_id = b.invoice_id "
+" and a.cust_code = ? "
+" and a.site_code = ? "
+" and a.tran_date <= ? "
+" and b.item_code = ? "
+" and b.lot_no = ? "
+" and a.confirmed = 'Y'" ;
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode);
pStmt.setString(2, siteCode);
pStmt.setTimestamp(3, getCurrdateTsFormat());
pStmt.setString(4, itemCode);
pStmt.setString(5, lotNo);
rs = pStmt.executeQuery();
if( rs.next() )
{
rate = rs.getDouble("rate");
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
*/ */
sql = "select sum(b.quantity) as saleQty from invoice a, invoice_trace b " sql = "select sum(b.quantity) as saleQty from invoice a, invoice_trace b "
+" where a.invoice_id = b.invoice_id " + " where a.invoice_id = b.invoice_id "
+" and a.cust_code = ? " + " and a.cust_code = ? "
+" and a.site_code = ? " + " and a.site_code = ? "
+" and a.tran_date <= ? " + " and a.tran_date <= ? "
+" and b.item_code = ? " + " and b.item_code = ? "
+" and b.lot_no = ? " + " and b.lot_no = ? " + " and a.confirmed = 'Y'";
+" and a.confirmed = 'Y'" ;
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode); pStmt.setString(1, custCode);
pStmt.setString(2, siteCode); pStmt.setString(2, siteCode);
...@@ -1933,8 +1916,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1933,8 +1916,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt.setString(4, itemCode); pStmt.setString(4, itemCode);
pStmt.setString(5, lotNo); pStmt.setString(5, lotNo);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
saleQty = rs.getDouble("saleQty"); saleQty = rs.getDouble("saleQty");
} }
rs.close(); rs.close();
...@@ -1942,14 +1924,13 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1942,14 +1924,13 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
sql = "select sum(case when B.ret_rep_flag = 'R' then b.quantity else -b.quantity end) as saleRetQty " sql = "select sum(case when B.ret_rep_flag = 'R' then b.quantity else -b.quantity end) as saleRetQty "
+" from sreturn a, sreturndet b " + " from sreturn a, sreturndet b "
+" where a.tran_id = b.tran_id " + " where a.tran_id = b.tran_id "
+" and a.cust_code = ? " + " and a.cust_code = ? "
+" and a.site_code = ? " + " and a.site_code = ? "
+" and a.tran_date <= ? " + " and a.tran_date <= ? "
+" and b.item_code = ? " + " and b.item_code = ? "
+" and b.lot_no = ? " + " and b.lot_no = ? " + " and a.confirmed = 'Y'";
+" and a.confirmed = 'Y'" ;
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode); pStmt.setString(1, custCode);
pStmt.setString(2, siteCode); pStmt.setString(2, siteCode);
...@@ -1957,8 +1938,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1957,8 +1938,7 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt.setString(4, itemCode); pStmt.setString(4, itemCode);
pStmt.setString(5, lotNo); pStmt.setString(5, lotNo);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
saleRetQty = rs.getDouble("saleRetQty"); saleRetQty = rs.getDouble("saleRetQty");
} }
rs.close(); rs.close();
...@@ -1967,197 +1947,172 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -1967,197 +1947,172 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
pStmt = null; pStmt = null;
sql = "select sum(case when b.quantity is null then 0 else b.quantity end) as confQty " sql = "select sum(case when b.quantity is null then 0 else b.quantity end) as confQty "
+" from charge_back a, charge_back_det b " + " from charge_back a, charge_back_det b "
+" where a.tran_id = b.tran_id " + " where a.tran_id = b.tran_id "
+" and a.cust_code = ? " + " and a.cust_code = ? "
+" and a.site_code = ? " + " and a.site_code = ? "
+" and a.confirmed = 'Y' " + " and a.confirmed = 'Y' "
+" and b.item_code = ? " + " and b.item_code = ? "
+" and b.lot_no = ? "; + " and b.lot_no = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode); pStmt.setString(1, custCode);
pStmt.setString(2, siteCode); pStmt.setString(2, siteCode);
pStmt.setString(3, itemCode); pStmt.setString(3, itemCode);
pStmt.setString(4, lotNo); pStmt.setString(4, lotNo);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
confQty = rs.getDouble("confQty"); confQty = rs.getDouble("confQty");
} }
rs.close(); rs.close();
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
// 14/06/10 manoharan not to consider current transaction, current transaction quantity to be calculated separately // 14/06/10 manoharan not to consider current transaction,
if (tranId == null) // current transaction quantity to be calculated separately
{ if (tranId == null) {
tranId = "@@@"; tranId = "@@@";
} }
sql = "select sum(case when b.quantity is null then 0 else b.quantity end) as unconfQty " sql = "select sum(case when b.quantity is null then 0 else b.quantity end) as unconfQty "
+" from charge_back a, charge_back_det b " + " from charge_back a, charge_back_det b "
+" where a.tran_id = b.tran_id " + " where a.tran_id = b.tran_id "
+" and a.tran_id <> ? " // 14/06/10 manoharan not to consider current transaction quantity + " and a.tran_id <> ? " // 14/06/10 manoharan not to
+" and a.cust_code = ? " // consider current
+" and a.site_code = ? " // transaction quantity
+" and (case when a.confirmed is null then 'N' else a.confirmed end) = 'N' " + " and a.cust_code = ? "
+" and b.item_code = ? " + " and a.site_code = ? "
+" and b.lot_no = ? "; + " and (case when a.confirmed is null then 'N' else a.confirmed end) = 'N' "
+ " and b.item_code = ? " + " and b.lot_no = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId); // 14/06/10 manoharan not to consider current transaction quantity pStmt.setString(1, tranId); // 14/06/10 manoharan not to
// consider current transaction
// quantity
pStmt.setString(2, custCode); pStmt.setString(2, custCode);
pStmt.setString(3, siteCode); pStmt.setString(3, siteCode);
pStmt.setString(4, itemCode); pStmt.setString(4, itemCode);
pStmt.setString(5, lotNo); pStmt.setString(5, lotNo);
rs = pStmt.executeQuery(); rs = pStmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{
unconfQty = rs.getDouble("unconfQty"); unconfQty = rs.getDouble("unconfQty");
} }
rs.close(); rs.close();
rs = null; rs = null;
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
///////////////////////////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////////////////////////
/* /*
// 27/05/10 manoharan bill_no, bill_date and discount to be carried forward * // 27/05/10 manoharan bill_no, bill_date and discount to be
NodeList detail2List = null; * carried forward NodeList detail2List = null; Node detailNode
Node detailNode = null; * = null; NodeList childDetilList = null; Node chidDetailNode =
NodeList childDetilList = null; * null; double curQty = 0; detail2List =
Node chidDetailNode = null; * dom2.getElementsByTagName("Detail2");
double curQty = 0; * System.out.println("manohar unconfirm quantity abefore [" +
detail2List = dom2.getElementsByTagName("Detail2"); * unconfQty + "] detail2List.getLength() [" +
System.out.println("manohar unconfirm quantity abefore [" + unconfQty + "] detail2List.getLength() [" + detail2List.getLength() + "]"); * detail2List.getLength() + "]"); unconfQty = 0; curQty = 0; if
unconfQty = 0; * (detail2List.getLength() > 1) {
curQty = 0; *
if (detail2List.getLength() > 1) * for(int detCtr =0; detCtr < detail2List.getLength(); detCtr++
{ * ) {
*
for(int detCtr =0; detCtr < detail2List.getLength(); detCtr++ ) * detailNode = detail2List.item(detCtr); childDetilList =
{ * detailNode.getChildNodes(); tempQty = "0"; tempLotNo = "";
* tempItemCode = ""; tempLineNo = ""; dTempQty = 0; for(int p
detailNode = detail2List.item(detCtr); * =0; p < childDetilList.getLength(); p++ ) { chidDetailNode =
childDetilList = detailNode.getChildNodes(); * childDetilList.item(p);
tempQty = "0"; * System.out.println("manohar current child node [" +
tempLotNo = ""; * chidDetailNode.getNodeName() + "]");
tempItemCode = ""; * if(chidDetailNode.getNodeName().equalsIgnoreCase("item_code")
tempLineNo = ""; * ) { //System.out.println("discount_per node found >>>>>" +
dTempQty = 0; * chidDetailNode.getNodeName());
for(int p =0; p < childDetilList.getLength(); p++ ) * if(chidDetailNode.getFirstChild() != null ) { tempItemCode =
{ * chidDetailNode.getFirstChild().getNodeValue();
chidDetailNode = childDetilList.item(p); * if(tempItemCode == null || tempItemCode.trim().length() == 0)
System.out.println("manohar current child node [" + chidDetailNode.getNodeName() + "]"); * { tempItemCode = ""; } } }
if(chidDetailNode.getNodeName().equalsIgnoreCase("item_code") ) * if(chidDetailNode.getNodeName().equalsIgnoreCase("lot_no") )
{ * { //System.out.println("discount_per_unit node found >>>>>" +
//System.out.println("discount_per node found >>>>>" + chidDetailNode.getNodeName()); * chidDetailNode.getNodeName());
if(chidDetailNode.getFirstChild() != null ) * if(chidDetailNode.getFirstChild() != null ) { tempLotNo =
{ * chidDetailNode.getFirstChild().getNodeValue(); if(tempLotNo
tempItemCode = chidDetailNode.getFirstChild().getNodeValue(); * == null ) { tempLotNo = ""; } } }
if(tempItemCode == null || tempItemCode.trim().length() == 0) * if(chidDetailNode.getNodeName().equalsIgnoreCase("quantity")
{ * ) { //System.out.println("porder_no node found >>>>>" +
tempItemCode = ""; * chidDetailNode.getNodeName());
} * if(chidDetailNode.getFirstChild() != null ) { tempQty =
} * chidDetailNode.getFirstChild().getNodeValue(); if(tempQty ==
} * null || tempQty.trim().length() == 0) { tempQty = "0"; } } }
if(chidDetailNode.getNodeName().equalsIgnoreCase("lot_no") ) * if(chidDetailNode.getNodeName().equalsIgnoreCase("line_no") )
{ * { //System.out.println("porder_no node found >>>>>" +
//System.out.println("discount_per_unit node found >>>>>" + chidDetailNode.getNodeName()); * chidDetailNode.getNodeName());
if(chidDetailNode.getFirstChild() != null ) * if(chidDetailNode.getFirstChild() != null ) { tempLineNo =
{ * chidDetailNode.getFirstChild().getNodeValue(); if(tempLineNo
tempLotNo = chidDetailNode.getFirstChild().getNodeValue(); * == null || tempLineNo.trim().length() == 0) { tempLineNo =
if(tempLotNo == null ) * "0"; } } }
{ *
tempLotNo = ""; * } // compare the item_code and lot_no if matches add to the
} * current quantity
} * System.out.println("manohar comparing line_no [ " + lineNo +
} * "] item [" + itemCode + "] lot [" + lotNo + "]");
if(chidDetailNode.getNodeName().equalsIgnoreCase("quantity") ) * System.out.println("manohar comparing tempLineNo [ " +
{ * tempLineNo + "] tempItemCode [" + tempItemCode +
//System.out.println("porder_no node found >>>>>" + chidDetailNode.getNodeName()); * "] tempLotNo [" + tempLotNo + "]"); if
if(chidDetailNode.getFirstChild() != null ) * (lotNo.trim().equals(tempLotNo.trim()) &&
{ * itemCode.trim().equals(tempItemCode.trim()) &&
tempQty = chidDetailNode.getFirstChild().getNodeValue(); * !tempLineNo.equals(lineNo) ) { dTempQty =
if(tempQty == null || tempQty.trim().length() == 0) * Double.parseDouble(tempQty); curQty += dTempQty;
{ * System.out.println("manohar line_no [ " + tempLineNo +
tempQty = "0"; * "] item [" + tempItemCode + "] lot [" + tempLotNo +
} * "] qty ["+ dTempQty+ "]"); } // }
} *
} * } unconfQty += curQty;
if(chidDetailNode.getNodeName().equalsIgnoreCase("line_no") ) * System.out.println("manohar unconfirm quantity after [" +
{ * unconfQty + "]");
//System.out.println("porder_no node found >>>>>" + chidDetailNode.getNodeName()); */
if(chidDetailNode.getFirstChild() != null ) // ///////////////////////////////////////////////////////////////////////////////////////////////////
{ /*
tempLineNo = chidDetailNode.getFirstChild().getNodeValue(); * sql = "select ('"+unconfQty+
if(tempLineNo == null || tempLineNo.trim().length() == 0) * "' - (case when b.quantity is null then 0 else b.quantity end)) as unconfQty "
{ * +" from charge_back a, charge_back_det b "
tempLineNo = "0"; * +" where a.tran_id = b.tran_id " +" and b.tran_id = ? "
} * +" and b.line_no = ? " +" and a.cust_code = ? "
} * +" and a.site_code = ? " +
} * " and (case when a.confirmed is null then 'N' else a.confirmed end) = 'N' "
* +" and b.item_code = ? " +" and b.lot_no = ? "; pStmt =
} * conn.prepareStatement(sql); pStmt.setString(1, tranId);
// compare the item_code and lot_no if matches add to the current quantity * pStmt.setString(2, lineNo); pStmt.setString(2, custCode);
System.out.println("manohar comparing line_no [ " + lineNo + "] item [" + itemCode + "] lot [" + lotNo + "]"); * pStmt.setString(3, siteCode); pStmt.setString(4, itemCode);
System.out.println("manohar comparing tempLineNo [ " + tempLineNo + "] tempItemCode [" + tempItemCode + "] tempLotNo [" + tempLotNo + "]"); * pStmt.setString(5, lotNo); rs = pStmt.executeQuery(); if(
if (lotNo.trim().equals(tempLotNo.trim()) && itemCode.trim().equals(tempItemCode.trim()) && !tempLineNo.equals(lineNo) ) * rs.next() ) { unconfQty = rs.getDouble("unconfQty"); }
{ * rs.close(); rs = null; pStmt.close(); pStmt = null;
dTempQty = Double.parseDouble(tempQty);
curQty += dTempQty;
System.out.println("manohar line_no [ " + tempLineNo + "] item [" + tempItemCode + "] lot [" + tempLotNo + "] qty ["+ dTempQty+ "]");
}
//
}
}
unconfQty += curQty;
System.out.println("manohar unconfirm quantity after [" + unconfQty + "]");
*/ */
/////////////////////////////////////////////////////////////////////////////////////////////////////
/* sql = "select ('"+unconfQty+"' - (case when b.quantity is null then 0 else b.quantity end)) as unconfQty "
+" from charge_back a, charge_back_det b "
+" where a.tran_id = b.tran_id "
+" and b.tran_id = ? "
+" and b.line_no = ? "
+" and a.cust_code = ? "
+" and a.site_code = ? "
+" and (case when a.confirmed is null then 'N' else a.confirmed end) = 'N' "
+" and b.item_code = ? "
+" and b.lot_no = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranId);
pStmt.setString(2, lineNo);
pStmt.setString(2, custCode);
pStmt.setString(3, siteCode);
pStmt.setString(4, itemCode);
pStmt.setString(5, lotNo);
rs = pStmt.executeQuery();
if( rs.next() )
{
unconfQty = rs.getDouble("unconfQty");
}
rs.close();
rs = null;
pStmt.close();
pStmt = null; */
rate = getMinRate(dom, dom1, "lot_no", conn); rate = getMinRate(dom, dom1, "lot_no", conn);
//saleRetQty = Math.abs(saleRetQty); // saleRetQty = Math.abs(saleRetQty);
itmChangeString.append("<rate__sell>").append("<![CDATA["+ rate + "]]>").append("</rate__sell>"); itmChangeString.append("<rate__sell>")
itmChangeString.append("<sale_qty>").append("<![CDATA["+ saleQty + "]]>").append("</sale_qty>"); .append("<![CDATA[" + rate + "]]>")
itmChangeString.append("<sale_ret_qty>").append("<![CDATA["+ saleRetQty + "]]>").append("</sale_ret_qty>"); .append("</rate__sell>");
itmChangeString.append("<conf_claimed>").append("<![CDATA["+ getRequiredDecimal(confQty,3) + "]]>").append("</conf_claimed>"); itmChangeString.append("<sale_qty>")
//itmChangeString.append("<unconf_claimed>").append("<![CDATA["+ getRequiredDecimal(unconfQty,3) + "]]>").append("</unconf_claimed>"); .append("<![CDATA[" + saleQty + "]]>")
} .append("</sale_qty>");
} itmChangeString.append("<sale_ret_qty>")
catch(Exception e) .append("<![CDATA[" + saleRetQty + "]]>")
{ .append("</sale_ret_qty>");
System.out.println("Exception :ChargeBackLoc :itemChange(String xmlString2, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":"); itmChangeString
.append("<conf_claimed>")
.append("<![CDATA[" + getRequiredDecimal(confQty, 3)
+ "]]>").append("</conf_claimed>");
// itmChangeString.append("<unconf_claimed>").append("<![CDATA["+
// getRequiredDecimal(unconfQty,3) +
// "]]>").append("</unconf_claimed>");
}
} catch (Exception e) {
System.out
.println("Exception :ChargeBackLoc :itemChange(String xmlString2, String xmlString2, String windowName, String xtraParams):"
+ e.getMessage() + ":");
throw new ITMException(e); throw new ITMException(e);
} }
return itmChangeString.toString(); return itmChangeString.toString();
} }
private String getCalculations( Document dom ) throws RemoteException,ITMException private String getCalculations(Document dom) throws RemoteException,
{ ITMException {
StringBuffer itmChangeString = new StringBuffer(""); StringBuffer itmChangeString = new StringBuffer("");
double rate = 0.0; double rate = 0.0;
double discAmt = 0.0; double discAmt = 0.0;
...@@ -2165,70 +2120,84 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -2165,70 +2120,84 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
double amount = 0.0, endCustRateDbl = 0.0, taxAmtDbl = 0.0; double amount = 0.0, endCustRateDbl = 0.0, taxAmtDbl = 0.0;
double netAmt = 0.0, quantityDbl = 0.0, rateSellDbl = 0.0, discPerDbl = 0.0; double netAmt = 0.0, quantityDbl = 0.0, rateSellDbl = 0.0, discPerDbl = 0.0;
double discPerUnit = 0.0; double discPerUnit = 0.0;
try try {
{ String quantity = genericUtility.getColumnValue("quantity", dom);
String quantity = genericUtility.getColumnValue( "quantity", dom ); String rateSell = genericUtility.getColumnValue("rate__sell", dom);
String rateSell = genericUtility.getColumnValue( "rate__sell", dom ); String discPer = genericUtility.getColumnValue("discount_per", dom);
String discPer = genericUtility.getColumnValue( "discount_per", dom ); String endCustRate = genericUtility.getColumnValue("rate__contr",
String endCustRate = genericUtility.getColumnValue( "rate__contr", dom ); dom);
String taxAmt = genericUtility.getColumnValue( "tax_amt", dom ); String taxAmt = genericUtility.getColumnValue("tax_amt", dom);
if( quantity != null && quantity.trim().length() > 0 ) if (quantity != null && quantity.trim().length() > 0)
quantityDbl = Double.parseDouble(quantity); quantityDbl = Double.parseDouble(quantity);
if( rateSell != null && rateSell.trim().length() > 0 ) if (rateSell != null && rateSell.trim().length() > 0)
rateSellDbl = Double.parseDouble(rateSell); rateSellDbl = Double.parseDouble(rateSell);
if( discPer != null && discPer.trim().length() > 0 ) if (discPer != null && discPer.trim().length() > 0)
discPerDbl = Double.parseDouble(discPer); discPerDbl = Double.parseDouble(discPer);
if( endCustRate != null && endCustRate.trim().length() > 0 ) if (endCustRate != null && endCustRate.trim().length() > 0)
endCustRateDbl = Double.parseDouble(endCustRate); endCustRateDbl = Double.parseDouble(endCustRate);
if( taxAmt != null && taxAmt.trim().length() > 0 ) if (taxAmt != null && taxAmt.trim().length() > 0)
taxAmtDbl = Double.parseDouble(taxAmt); taxAmtDbl = Double.parseDouble(taxAmt);
if( endCustRateDbl <= 0 ) if (endCustRateDbl <= 0) {
{
rate = rateSellDbl; rate = rateSellDbl;
} } else {
else rate = Math.min(endCustRateDbl, rateSellDbl);
{
rate = Math.min( endCustRateDbl, rateSellDbl );
rateDiff = rateSellDbl - endCustRateDbl; rateDiff = rateSellDbl - endCustRateDbl;
} }
discAmt = (quantityDbl * rate * discPerDbl)/ 100; discAmt = (quantityDbl * rate * discPerDbl) / 100;
amount = rateDiff * quantityDbl; amount = rateDiff * quantityDbl;
netAmt = amount + discAmt + taxAmtDbl; netAmt = amount + discAmt + taxAmtDbl;
discPerUnit = (rate * discPerDbl) / 100; discPerUnit = (rate * discPerDbl) / 100;
itmChangeString.append("<discount_amt>").append("<![CDATA["+ getRequiredDecimal(discAmt, 3) + "]]>").append("</discount_amt>"); itmChangeString
itmChangeString.append("<amount>").append("<![CDATA["+ getRequiredDecimal(amount, 3) + "]]>").append("</amount>"); .append("<discount_amt>")
itmChangeString.append("<net_amt>").append("<![CDATA["+ getRequiredDecimal(netAmt, 3) + "]]>").append("</net_amt>"); .append("<![CDATA[" + getRequiredDecimal(discAmt, 3)
itmChangeString.append("<discount_per_unit>").append("<![CDATA["+ getRequiredDecimal(discPerUnit, 3) + "]]>").append("</discount_per_unit>"); + "]]>").append("</discount_amt>");
itmChangeString.append("<rate__diff>").append("<![CDATA["+ getRequiredDecimal(rateDiff, 3) + "]]>").append("</rate__diff>"); itmChangeString
} .append("<amount>")
catch(Exception e) .append("<![CDATA[" + getRequiredDecimal(amount, 3) + "]]>")
{ .append("</amount>");
System.out.println("Exception :ChargeBackLoc :itemChange(String xmlString2, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":"); itmChangeString
.append("<net_amt>")
.append("<![CDATA[" + getRequiredDecimal(netAmt, 3) + "]]>")
.append("</net_amt>");
itmChangeString
.append("<discount_per_unit>")
.append("<![CDATA[" + getRequiredDecimal(discPerUnit, 3)
+ "]]>").append("</discount_per_unit>");
itmChangeString
.append("<rate__diff>")
.append("<![CDATA[" + getRequiredDecimal(rateDiff, 3)
+ "]]>").append("</rate__diff>");
} catch (Exception e) {
System.out
.println("Exception :ChargeBackLoc :itemChange(String xmlString2, String xmlString2, String windowName, String xtraParams):"
+ e.getMessage() + ":");
throw new ITMException(e); throw new ITMException(e);
} }
return itmChangeString.toString(); return itmChangeString.toString();
} }
String getRequiredDecimal(double actVal, int prec)
{ String getRequiredDecimal(double actVal, int prec) {
NumberFormat numberFormat = NumberFormat.getIntegerInstance (); NumberFormat numberFormat = NumberFormat.getIntegerInstance();
Double DoubleValue = new Double (actVal); Double DoubleValue = new Double(actVal);
numberFormat.setMaximumFractionDigits(prec); numberFormat.setMaximumFractionDigits(prec);
String strValue = numberFormat.format(DoubleValue); String strValue = numberFormat.format(DoubleValue);
strValue = strValue.replaceAll(",",""); strValue = strValue.replaceAll(",", "");
//double reqVal = Double.parseDouble(strValue); // double reqVal = Double.parseDouble(strValue);
return strValue; //reqVal; return strValue; // reqVal;
} }
// 20/07/10 manoharan to get the quantity for same lot other than current line
private double getCurTranQty(String curLineNo, String itemCode, String lotNo, Document dom ) throws Exception // 20/07/10 manoharan to get the quantity for same lot other than current
{ // line
private double getCurTranQty(String curLineNo, String itemCode,
String lotNo, Document dom) throws Exception {
String updateFlag = null; String updateFlag = null;
String fldValue = null; String fldValue = null;
String nodeName = null; String nodeName = null;
...@@ -2239,68 +2208,78 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -2239,68 +2208,78 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
int currNodeLen; int currNodeLen;
System.out.println("Checking quantity in current transaction"); System.out.println("Checking quantity in current transaction");
NodeList detailNodes = dom.getElementsByTagName( "Detail2" ); NodeList detailNodes = dom.getElementsByTagName("Detail2");
int detLen = detailNodes.getLength(); int detLen = detailNodes.getLength();
double curTranQty = 0, domQty = 0; double curTranQty = 0, domQty = 0;
try try {
{
for( int detIdx = 0; detIdx < detLen ; detIdx++ ) for (int detIdx = 0; detIdx < detLen; detIdx++) {
{ currDet = detailNodes.item(detIdx);
currDet = detailNodes.item( detIdx ); System.out.println("manohar 10/12/10 got currDet [" + currDet
System.out.println("manohar 10/12/10 got currDet [" + currDet + "]"); + "]");
currNodes = currDet.getChildNodes(); currNodes = currDet.getChildNodes();
currNodeLen = currNodes.getLength(); currNodeLen = currNodes.getLength();
domQty = 0; domQty = 0;
for(int curNodeIdx = 0; curNodeIdx < currNodeLen; curNodeIdx++ ) for (int curNodeIdx = 0; curNodeIdx < currNodeLen; curNodeIdx++) {
{ currNode = currNodes.item(curNodeIdx);
currNode = currNodes.item( curNodeIdx );
nodeName = currNode.getNodeName(); nodeName = currNode.getNodeName();
System.out.println("manohar 10/12/10 got nodeName [" + nodeName + "]"); System.out.println("manohar 10/12/10 got nodeName ["
if ( nodeName.equalsIgnoreCase( "attribute" ) ) + nodeName + "]");
{ if (nodeName.equalsIgnoreCase("attribute")) {
updateFlag = currNode.getAttributes().getNamedItem( "updateFlag" ).getNodeValue(); updateFlag = currNode.getAttributes()
} .getNamedItem("updateFlag").getNodeValue();
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "quantity" ) ) } else if (currNode.getNodeType() == Node.ELEMENT_NODE
{ && nodeName.equalsIgnoreCase("quantity")) {
qtyStr = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : "0"; qtyStr = currNode.getFirstChild() != null ? currNode
} .getFirstChild().getNodeValue().trim() : "0";
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "line_no" ) ) } else if (currNode.getNodeType() == Node.ELEMENT_NODE
{ && nodeName.equalsIgnoreCase("line_no")) {
lineNoStr = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : "0"; lineNoStr = currNode.getFirstChild() != null ? currNode
} .getFirstChild().getNodeValue().trim() : "0";
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "item_code" ) ) } else if (currNode.getNodeType() == Node.ELEMENT_NODE
{ && nodeName.equalsIgnoreCase("item_code")) {
domItemCode = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : ""; domItemCode = currNode.getFirstChild() != null ? currNode
} .getFirstChild().getNodeValue().trim()
else if ( currNode.getNodeType() == Node.ELEMENT_NODE && nodeName.equalsIgnoreCase( "lot_no" ) ) : "";
{ } else if (currNode.getNodeType() == Node.ELEMENT_NODE
domLotNo = currNode.getFirstChild() != null ? currNode.getFirstChild().getNodeValue().trim() : ""; && nodeName.equalsIgnoreCase("lot_no")) {
} domLotNo = currNode.getFirstChild() != null ? currNode
} .getFirstChild().getNodeValue().trim() : "";
System.out.println("manohar updateFlag [" + updateFlag + "] lineNoStr [" + lineNoStr + "] curLineNo [" + curLineNo+ "] domItemCode [" + domItemCode + "] itemCode [ " + itemCode + "] domLotNo [" + domLotNo + "] lotNo [ " + lotNo + "] qtyStr[" + qtyStr + "]"); }
if( !"D".equalsIgnoreCase( updateFlag ) && (!lineNoStr.trim().equals( curLineNo.trim() )) && (domItemCode.trim().equalsIgnoreCase( itemCode.trim() )) && (domLotNo.trim().equalsIgnoreCase( lotNo.trim() ))) }
{ System.out.println("manohar updateFlag [" + updateFlag
System.out.println("manohar found lineNoStr [" + lineNoStr + "] curLineNo [" + curLineNo+ "] domItemCode [" + domItemCode + "] domLotNo [" + domLotNo + "] qtyStr[" + qtyStr + "]"); + "] lineNoStr [" + lineNoStr + "] curLineNo ["
if( qtyStr == null ) + curLineNo + "] domItemCode [" + domItemCode
{ + "] itemCode [ " + itemCode + "] domLotNo ["
+ domLotNo + "] lotNo [ " + lotNo + "] qtyStr["
+ qtyStr + "]");
if (!"D".equalsIgnoreCase(updateFlag)
&& (!lineNoStr.trim().equals(curLineNo.trim()))
&& (domItemCode.trim()
.equalsIgnoreCase(itemCode.trim()))
&& (domLotNo.trim().equalsIgnoreCase(lotNo.trim()))) {
System.out.println("manohar found lineNoStr [" + lineNoStr
+ "] curLineNo [" + curLineNo + "] domItemCode ["
+ domItemCode + "] domLotNo [" + domLotNo
+ "] qtyStr[" + qtyStr + "]");
if (qtyStr == null) {
qtyStr = "0"; qtyStr = "0";
} }
domQty = Double.parseDouble(qtyStr); domQty = Double.parseDouble(qtyStr);
curTranQty += domQty; curTranQty += domQty;
} }
} }
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
return curTranQty; return curTranQty;
} }
// end 20/07/10 manoharan to get the quantity for same lot other than current line
private double getMinRate(Document dom, Document dom1, String currCol, Connection conn) throws Exception // end 20/07/10 manoharan to get the quantity for same lot other than
{ // current line
private double getMinRate(Document dom, Document dom1, String currCol,
Connection conn) throws Exception {
DistCommon distCommon = new DistCommon(); DistCommon distCommon = new DistCommon();
String invoiceId = null, retReplFlag = null, sql = ""; String invoiceId = null, retReplFlag = null, sql = "";
String itemCode = null; String itemCode = null;
...@@ -2326,161 +2305,146 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C ...@@ -2326,161 +2305,146 @@ public class ChargeBackLoc extends ValidatorEJB implements ChargeBackLocLocal, C
String strToken; String strToken;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try {
{
/* /*
invoiceId = genericUtility.getColumnValue("invoice_id",dom1); * invoiceId = genericUtility.getColumnValue("invoice_id",dom1);
System.out.println( "invoiceId :: " + invoiceId ); * System.out.println( "invoiceId :: " + invoiceId ); if (invoiceId
if (invoiceId != null && invoiceId.trim().length() > 0 ) * != null && invoiceId.trim().length() > 0 ) { return sBuff; }
{ * retReplFlag = genericUtility.getColumnValue("ret_rep_flag",dom);
return sBuff; * System.out.println( "retReplFlag :: " + retReplFlag ); if
} * (!"R".equals(retReplFlag) ) { System.out.println( "return 1");
retReplFlag = genericUtility.getColumnValue("ret_rep_flag",dom); * return sBuff; }
System.out.println( "retReplFlag :: " + retReplFlag );
if (!"R".equals(retReplFlag) )
{
System.out.println( "return 1");
return sBuff;
}
*/ */
sNoSchemeHist = distCommon.getDisparams("999999","SCHEME_HIST_NUM",conn); sNoSchemeHist = distCommon.getDisparams("999999",
System.out.println( "sNoSchemeHist :: " + sNoSchemeHist ); "SCHEME_HIST_NUM", conn);
System.out.println("sNoSchemeHist :: " + sNoSchemeHist);
if ( "NULLFOUND".equals( sNoSchemeHist ) ) if ("NULLFOUND".equals(sNoSchemeHist)) {
{
col[0] = "site_code"; col[0] = "site_code";
col[1] = "item_code"; col[1] = "item_code";
col[2] = "lot_no"; col[2] = "lot_no";
noSchemeHist = 1; noSchemeHist = 1;
dynamicCol = false; dynamicCol = false;
} } else {
else
{
int colFound = 0; int colFound = 0;
noSchemeHist = Integer.parseInt( sNoSchemeHist ); noSchemeHist = Integer.parseInt(sNoSchemeHist);
for (int ctr = 1; ctr <= noSchemeHist; ctr++) for (int ctr = 1; ctr <= noSchemeHist; ctr++) {
{ schemeKey = "SCHEME_HIST_KEY" + ctr;
schemeKey = "SCHEME_HIST_KEY" + ctr ; varValue = distCommon.getDisparams("999999", schemeKey,
varValue = distCommon.getDisparams("999999",schemeKey,conn); conn);
System.out.println( "currCol :: " + currCol ); System.out.println("currCol :: " + currCol);
System.out.println( "varValue :: " + varValue ); System.out.println("varValue :: " + varValue);
if (varValue.indexOf(currCol) > -1 ) if (varValue.indexOf(currCol) > -1) {
{
colMatch = true; colMatch = true;
colFound = 1; colFound = 1;
break; break;
} }
} }
if (!colMatch) if (!colMatch) {
{ System.out.println("return 2");
System.out.println( "return 2");
return 0; return 0;
} }
} }
priceList = genericUtility.getColumnValue("price_list",dom1); priceList = genericUtility.getColumnValue("price_list", dom1);
itemCode = genericUtility.getColumnValue("item_code",dom); itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no",dom); lotNo = genericUtility.getColumnValue("lot_no", dom);
tranDate = genericUtility.getColumnValue("tran_date",dom1); tranDate = genericUtility.getColumnValue("tran_date", dom1);
String qtyStdUomStr = genericUtility.getColumnValue("quantity",dom); String qtyStdUomStr = genericUtility
if (qtyStdUomStr == null) .getColumnValue("quantity", dom);
{ if (qtyStdUomStr == null) {
qtyStdUomStr = "0"; qtyStdUomStr = "0";
} }
qtyStdUom = Double.parseDouble(qtyStdUomStr); qtyStdUom = Double.parseDouble(qtyStdUomStr);
for (int ctr = 1; ctr <= noSchemeHist ; ctr++) for (int ctr = 1; ctr <= noSchemeHist; ctr++) {
{
docKey = null; docKey = null;
int colCount = -1; int colCount = -1;
if (dynamicCol) if (dynamicCol) {
{
colCount = -1; colCount = -1;
schemeKey = "SCHEME_HIST_KEY" + ctr ; schemeKey = "SCHEME_HIST_KEY" + ctr;
varValue = distCommon.getDisparams("999999",schemeKey,conn); varValue = distCommon.getDisparams("999999", schemeKey,
if ("NULLFOUND".equals( varValue )) conn);
{ if ("NULLFOUND".equals(varValue)) {
System.out.println( "return 3"); System.out.println("return 3");
return 0; return 0;
} } else {
else
{
varValue = varValue.trim(); varValue = varValue.trim();
while (varValue.trim().length()>0) while (varValue.trim().length() > 0) {
{
colCount++; colCount++;
pos = varValue.indexOf(","); pos = varValue.indexOf(",");
if (pos > -1) if (pos > -1) {
{ strToken = distCommon.getToken(varValue, ",");
strToken = distCommon.getToken( varValue, "," ); col[colCount] = strToken;
col[colCount] = strToken ; varValue = varValue.substring(pos + 1);
varValue = varValue.substring(pos+1); } else {
}
else
{
col[colCount] = varValue; col[colCount] = varValue;
break; break;
} }
} // populate column list } // populate column list
} }
} } else {
else
{
colCount = 2; colCount = 2;
} }
for (int colCtr = 0; colCtr <= colCount; colCtr++) for (int colCtr = 0; colCtr <= colCount; colCtr++) {
{
colName = col[colCtr]; colName = col[colCtr];
if ( "site_code".equalsIgnoreCase(colName.trim()) || "invoice_id".equalsIgnoreCase(colName.trim()) || "cust_code".equalsIgnoreCase(colName.trim()) ) if ("site_code".equalsIgnoreCase(colName.trim())
{ || "invoice_id".equalsIgnoreCase(colName.trim())
docValue = genericUtility.getColumnValue(colName.trim(),dom1); || "cust_code".equalsIgnoreCase(colName.trim())) {
} docValue = genericUtility.getColumnValue(
else colName.trim(), dom1);
{ } else {
docValue = genericUtility.getColumnValue(colName.trim(),dom); docValue = genericUtility.getColumnValue(
} colName.trim(), dom);
if (docKey != null && docKey.trim().length() > 0) }
{ if (docKey != null && docKey.trim().length() > 0) {
docKey = docKey + "," + ( docValue == null || docValue.trim().length() == 0 ? "" : docValue.trim() ); // 13/05/10 manoharan docValue trim() added docKey = docKey
} + ","
else + (docValue == null
{ || docValue.trim().length() == 0 ? ""
: docValue.trim()); // 13/05/10
// manoharan
// docValue trim()
// added
} else {
docKey = docValue; docKey = docValue;
} }
} }
sql = " select eff_cost from min_rate_history where doc_key = ?" ; sql = " select eff_cost from min_rate_history where doc_key = ?";
pstmt= conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,docKey); pstmt.setString(1, docKey);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
minRate = rs.getDouble(1); minRate = rs.getDouble(1);
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
rs = null; rs = null;
if (minRate > 0) if (minRate > 0) {
{
break; break;
} }
} }
if (minRate == 0) if (minRate == 0) {
{ tranDate = tranDate == null ? (genericUtility
tranDate = tranDate == null ? ( genericUtility.getValidDateString( new Timestamp( System.currentTimeMillis() ).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat() ) ).toString() : tranDate; .getValidDateString(
new Timestamp(System.currentTimeMillis())
.toString(), genericUtility
.getDBDateFormat(), genericUtility
.getApplDateFormat())).toString()
: tranDate;
itemCode = itemCode == null ? "" : itemCode; itemCode = itemCode == null ? "" : itemCode;
lotNo = lotNo == null ? "" : lotNo; lotNo = lotNo == null ? "" : lotNo;
minRate = distCommon.pickRate(priceList,tranDate,itemCode,lotNo,"D",qtyStdUom, conn); minRate = distCommon.pickRate(priceList, tranDate, itemCode,
lotNo, "D", qtyStdUom, conn);
} }
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
throw new ITMException( e ); throw new ITMException(e);
} }
return minRate ; return minRate;
} }
} }
\ 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