Commit 295a3f52 authored by agaikwad's avatar agaikwad

Request_id-F14CSUN001


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98671 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a7c50a3b
...@@ -11,9 +11,12 @@ import java.rmi.RemoteException; ...@@ -11,9 +11,12 @@ import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
...@@ -66,14 +69,20 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -66,14 +69,20 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
String userId="",siteCode = "",errCode="",itemser="",pricelist="",reasCode="",remarks="",amtOld="",cctrCodeInv="",cctrCodeInvrev=""; String userId="",siteCode = "",errCode="",itemser="",pricelist="",reasCode="",remarks="",amtOld="",cctrCodeInv="",cctrCodeInvrev="";
String tranId = "",keyFlag="",tranDate = "",effDate="",itemCode="",locCode="",lotNo="",lotSl="",quantity="",acctCodeInv="",acctCodeInvrev=""; String tranId = "",keyFlag="",effDate="",itemCode="",locCode="",lotNo="",lotSl="",quantity="",acctCodeInv="",acctCodeInvrev="";
double conquan,getquan = 0; double conquan,getquan = 0;
int cnt=0; int cnt=0;
int cnt1=0;
int currentFormNo=0; int currentFormNo=0;
int childNodeListLength; int childNodeListLength;
String oRate="",tranType="",assetCode="",custCode="",currCode="",taxClass="",taxchat="",taxChap="",acctCdAr="",acctCdMd="",cctrCdAr="",cctrCdMd="",taxEnv=""; String oRate="",tranType="",assetCode="",custCode="",currCode="",taxClass="",taxchat="",taxChap="",acctCdAr="",acctCdMd="",cctrCdAr="",cctrCdMd="",taxEnv="";
String acctCdPl="",acctCdLo="",cctrCdPl="",cctrCdLo=""; String acctCdPl="",acctCdLo="",cctrCdPl="",cctrCdLo="";
double rate =0,saleAmt=0,taxAmt=0; double rate =0,saleAmt=0,taxAmt=0;
String saleamt = "", taxamt ="";
String prdCode="",statFin="";
Timestamp tranDateTs=null;
String tranDateStr = "",siteCodeFor="";
String siteCodlogin="";
String oldRate="",AmtRate="",oldAmtRate=""; String oldRate="",AmtRate="",oldAmtRate="";
double conoldate= 0.0,highval = 0.0,conAmtdate=0.0,conolAmtdate=0.0; double conoldate= 0.0,highval = 0.0,conAmtdate=0.0,conolAmtdate=0.0;
...@@ -86,6 +95,8 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -86,6 +95,8 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
connDriver = null; connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("user ID form XtraParam : "+userId); System.out.println("user ID form XtraParam : "+userId);
siteCodlogin =(genericUtility.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);
...@@ -102,71 +113,90 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -102,71 +113,90 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("tran_date"))
if(childNodeName.equalsIgnoreCase("tran_id")) {
tranDateStr = genericUtility.getColumnValue("tran_date",dom);
tranDateTs = Timestamp.valueOf(genericUtility.getValidDateString(tranDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())+ " 00:00:00.0");
if (tranDateStr == null || tranDateStr.trim().length() == 0 )
{ {
tranId = genericUtility.getColumnValue("tran_id",dom); errCode = "";
errString = getErrorString("tran_date",errCode,userId);
break;
}
siteCode = genericUtility.getColumnValue("site_code", dom);
sql = "select key_flag from transetup where tran_window = ?"; sql = "Select code from period where ? between fr_date and to_date ";
pstmt=conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,"w_asset_sales"); pstmt.setTimestamp(1, tranDateTs);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
keyFlag = rs.getString(1) == null ? "":rs.getString(1); prdCode = rs.getString("code");
System.out.println("Period Code>>>>>>"+prdCode);
} }
pstmt.close();
rs.close(); rs.close();
pstmt = null;
rs = null; rs = null;
pstmt.close();
pstmt = null;
if (prdCode != null && prdCode.trim().length() > 0)
if(keyFlag.equalsIgnoreCase("M"))
{ {
if (tranId == null || tranId.trim().length() == 0) sql = "Select count(1) from period_stat where prd_code = ? "
+ " AND site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode.trim());
pstmt.setString(2, siteCodlogin.trim());
rs = pstmt.executeQuery();
if (rs.next())
{ {
errCode = "STKVALTRNU"; cnt = rs.getInt(1);
errString = getErrorString("tran_id",errCode,userId); System.out.println("Count for prdCode>>>>>>>>>>"+cnt);
break;
} }
else rs.close();
{ rs = null;
pstmt.close();
pstmt = null;
sql = "select count(1) from asset_sales where tran_id = ?"; if (cnt > 0)
pstmt=conn.prepareStatement(sql); {
pstmt.setString(1,tranId); sql = "Select stat_fin from period_stat where prd_code = ? and site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode.trim());
pstmt.setString(2, siteCodlogin.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
cnt = rs.getInt(1); statFin = rs.getString("stat_fin");
System.out.println("Status Fin>>>>>>>"+statFin);
} }
pstmt.close();
rs.close(); rs.close();
pstmt = null;
rs = null; rs = null;
if(cnt > 0) pstmt.close();
pstmt = null;
//if(statFin != null && statFin.equalsIgnoreCase("N"))
if(statFin != null && "N".equalsIgnoreCase(statFin))
{ {
errCode = "STKVALTRNE"; errCode = "VTPRDFIN";
errString = getErrorString("tran_id",errCode,userId); errString = getErrorString("tran_date",errCode,userId);
break; break;
}
} }
} }
} else
else if(childNodeName.equalsIgnoreCase("tran_date"))
{ {
errCode = "VMSTATSND";
tranDate = genericUtility.getColumnValue("tran_date",dom); errString = getErrorString("tran_date",errCode,userId);
if (tranDate == null || tranDate.trim().length() == 0 ) break;
}
}
else
{ {
errCode = ""; errCode = "VMPRDNTDF";
errString = getErrorString("tran_date",errCode,userId); errString = getErrorString("tran_date",errCode,userId);
break; break;
} }
} }
else if(childNodeName.equalsIgnoreCase("tran_type")) else if(childNodeName.equalsIgnoreCase("tran_type"))
{ {
...@@ -187,7 +217,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -187,7 +217,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
if (custCode == null || custCode.trim().length() == 0 ) if (custCode == null || custCode.trim().length() == 0 )
{ {
System.out.println("cust code"); System.out.println("cust code");
errCode = " "; errCode = "VTCUST1";
errString = getErrorString("cust_code",errCode,userId); errString = getErrorString("cust_code",errCode,userId);
break; break;
}else }else
...@@ -223,7 +253,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -223,7 +253,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
currCode = genericUtility.getColumnValue("curr_code",dom); currCode = genericUtility.getColumnValue("curr_code",dom);
if (currCode == null || currCode.trim().length() == 0 ) if (currCode == null || currCode.trim().length() == 0 )
{ {
errCode = " "; errCode = "CURRCODBL";
errString = getErrorString("curr_code",errCode,userId); errString = getErrorString("curr_code",errCode,userId);
break; break;
} }
...@@ -259,7 +289,9 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -259,7 +289,9 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
else if(childNodeName.equalsIgnoreCase("tax_class")) else if(childNodeName.equalsIgnoreCase("tax_class"))
{ {
taxClass = genericUtility.getColumnValue("tax_class",dom); taxClass = checkNull(genericUtility.getColumnValue("tax_class",dom));
if(taxClass != null && taxClass.length()> 0)
{
sql = "select count(1) from taxclass where tax_class = ?"; sql = "select count(1) from taxclass where tax_class = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,taxClass); pstmt.setString(1,taxClass);
...@@ -278,11 +310,14 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -278,11 +310,14 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
errString = getErrorString("tax_class",errCode,userId); errString = getErrorString("tax_class",errCode,userId);
break; break;
} }
}
} }
else if(childNodeName.equalsIgnoreCase("tax_chap")) else if(childNodeName.equalsIgnoreCase("tax_chap"))
{ {
taxChap = genericUtility.getColumnValue("tax_chap",dom); taxChap = checkNull(genericUtility.getColumnValue("tax_chap",dom));
if(taxChap != null && taxChap.length()>0)
{
sql = "select count(1) from taxchap where tax_chap = ?"; sql = "select count(1) from taxchap where tax_chap = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,taxChap); pstmt.setString(1,taxChap);
...@@ -301,13 +336,14 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -301,13 +336,14 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
errString = getErrorString("tax_chap",errCode,userId); errString = getErrorString("tax_chap",errCode,userId);
break; break;
} }
}
} }
else if(childNodeName.equalsIgnoreCase("tax_env")) else if(childNodeName.equalsIgnoreCase("tax_env"))
{ {
taxEnv = genericUtility.getColumnValue("tax_env",dom); taxEnv = checkNull(genericUtility.getColumnValue("tax_env",dom));
if( taxEnv!= null && taxEnv.length() > 0 )
{
sql = "select count(1) from taxenv where tax_env = ?"; sql = "select count(1) from taxenv where tax_env = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,taxEnv); pstmt.setString(1,taxEnv);
...@@ -326,16 +362,18 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -326,16 +362,18 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
errString = getErrorString("tax_env",errCode,userId); errString = getErrorString("tax_env",errCode,userId);
break; break;
} }
}
} }
else if(childNodeName.equalsIgnoreCase("sale_amt")) else if(childNodeName.equalsIgnoreCase("sale_amt"))
{ {
saleamt= checkNull(genericUtility.getColumnValue("sale_amt",dom));
saleAmt = Double.parseDouble(genericUtility.getColumnValue("sale_amt",dom)); System.out.println("Sale AMount"+saleamt);
saleamt=saleamt != null && saleamt.trim().length() > 0 ? saleamt.trim() : "0";
saleAmt= Double.parseDouble(saleamt);
if(saleAmt <= 0) System.out.println("Sale amount parse double "+saleAmt);
if(saleAmt < 0)
{ {
errCode = "VTSLAMT"; errCode = "VTSLAMT";
errString = getErrorString("sale_amt",errCode,userId); // Sale amount can not be less than 0 errString = getErrorString("sale_amt",errCode,userId); // Sale amount can not be less than 0
...@@ -348,16 +386,16 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -348,16 +386,16 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
else if(childNodeName.equalsIgnoreCase("tax_amt")) else if(childNodeName.equalsIgnoreCase("tax_amt"))
{ {
taxamt= checkNull(genericUtility.getColumnValue("tax_amt", dom));
taxAmt = Double.parseDouble(genericUtility.getColumnValue("tax_amt",dom)); System.out.println("TAx Amount is "+taxamt);
taxamt = taxamt !=null && taxamt.trim().length() >0 ?taxamt.trim() : "0";
taxAmt = Double.parseDouble(taxamt);
System.out.println("TAx Amount parse double is "+taxAmt);
if(taxAmt < 0) if(taxAmt < 0)
{ {
errCode = "VTTAXAMT"; errCode = "VTTAXAMT";
errString = getErrorString("tax_amt",errCode,userId); errString = getErrorString("tax_amt",errCode,userId);
break; break;
} }
...@@ -383,18 +421,15 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -383,18 +421,15 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
if(childNodeName.equalsIgnoreCase("asset_code")) if(childNodeName.equalsIgnoreCase("asset_code"))
{ {
assetCode = genericUtility.getColumnValue("asset_code",dom); assetCode = genericUtility.getColumnValue("asset_code",dom);
if (assetCode == null || assetCode.trim().length() == 0 ) if (assetCode == null || assetCode.trim().length() == 0 )
{ {
errCode = " "; errCode = "VTASCODNUL";
errString = getErrorString("asset_code",errCode,userId); errString = getErrorString("asset_code",errCode,userId);
break; break;
}else }else
{ {
sql = "select count(1) from asset_register where asset_code = ? ";
sql = "select count(1) from asset_register where asset_code = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,assetCode); pstmt.setString(1,assetCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -406,9 +441,31 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -406,9 +441,31 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs.close(); rs.close();
pstmt = null; pstmt = null;
rs = null; rs = null;
System.out.println("Blank Asset COde COunt>>>>"+cnt);
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VTASSETCD"; errCode = "VMASSET1";
errString = getErrorString("asset_code",errCode,userId);
break;
}
sql = "select count(1) from asset_register where asset_code = ? and status= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,assetCode);
pstmt.setString(2,"S");
rs = pstmt.executeQuery();
if(rs.next())
{
cnt1 = rs.getInt(1);
}
System.out.println("Sale Asset Status Count>>>>>"+cnt1);
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt1> 0)
{
errCode = "VTASSCODES";
errString = getErrorString("asset_code",errCode,userId); errString = getErrorString("asset_code",errCode,userId);
break; break;
} }
...@@ -474,7 +531,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -474,7 +531,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
if (acctCdAr == null || acctCdAr.trim().length() == 0 ) if (acctCdAr == null || acctCdAr.trim().length() == 0 )
{ {
errCode = " "; errCode = "";
errString = getErrorString("acct_code__ar",errCode,userId); errString = getErrorString("acct_code__ar",errCode,userId);
break; break;
} }
...@@ -497,7 +554,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -497,7 +554,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs = null; rs = null;
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VMACCTR"; errCode = "VMACCTCDX ";
errString = getErrorString("acct_code__ar",errCode,userId); errString = getErrorString("acct_code__ar",errCode,userId);
break; break;
} }
...@@ -514,7 +571,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -514,7 +571,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
if (cctrCdAr == null || cctrCdAr.trim().length() == 0 ) if (cctrCdAr == null || cctrCdAr.trim().length() == 0 )
{ {
errCode = " "; errCode = "";
errString = getErrorString("cctr_code__ar",errCode,userId); errString = getErrorString("cctr_code__ar",errCode,userId);
break; break;
} }
...@@ -537,7 +594,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -537,7 +594,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs = null; rs = null;
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VMCCTR"; errCode = "VMACCTCDX ";
errString = getErrorString("cctr_code__ar",errCode,userId); errString = getErrorString("cctr_code__ar",errCode,userId);
break; break;
} }
...@@ -547,13 +604,13 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -547,13 +604,13 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
} }
} }
else if(childNodeName.equalsIgnoreCase("acct_code__mod")) /*else if(childNodeName.equalsIgnoreCase("acct_code__mod"))
{ {
acctCdMd = genericUtility.getColumnValue("acct_code__mod",dom); acctCdMd = genericUtility.getColumnValue("acct_code__mod",dom);
if (acctCdMd == null || acctCdMd.trim().length() == 0 ) if (acctCdMd == null || acctCdMd.trim().length() == 0 )
{ {
errCode = " "; errCode = "";
errString = getErrorString("acct_code__mod",errCode,userId); errString = getErrorString("acct_code__mod",errCode,userId);
break; break;
} }
...@@ -593,7 +650,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -593,7 +650,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
if (cctrCdMd == null || cctrCdMd.trim().length() == 0 ) if (cctrCdMd == null || cctrCdMd.trim().length() == 0 )
{ {
errCode = " "; errCode = "";
errString = getErrorString("cctr_code__mod",errCode,userId); errString = getErrorString("cctr_code__mod",errCode,userId);
break; break;
} }
...@@ -616,7 +673,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -616,7 +673,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs = null; rs = null;
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VMCCTR"; errCode = "";
errString = getErrorString("cctr_code__mod",errCode,userId); errString = getErrorString("cctr_code__mod",errCode,userId);
break; break;
} }
...@@ -625,7 +682,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -625,7 +682,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
} }
} }*/
// case "acct_code__pl","acct_code__loss" // case "acct_code__pl","acct_code__loss"
...@@ -668,7 +725,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -668,7 +725,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs = null; rs = null;
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VTACCTCDPL"; errCode = "VMACCTCDX";
errString = getErrorString("acct_code__pl",errCode,userId); errString = getErrorString("acct_code__pl",errCode,userId);
break; break;
} }
...@@ -676,7 +733,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -676,7 +733,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
if (acctCdLo == null || acctCdLo.trim().length() == 0 ) if (acctCdLo == null || acctCdLo.trim().length() == 0 )
{ {
errCode = " "; errCode = "";
errString = getErrorString("acct_code__loss",errCode,userId); errString = getErrorString("acct_code__loss",errCode,userId);
break; break;
} }
...@@ -697,7 +754,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -697,7 +754,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs = null; rs = null;
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VTACCTCDLS"; errCode = "VMACCTCDX";
errString = getErrorString("acct_code__loss",errCode,userId); errString = getErrorString("acct_code__loss",errCode,userId);
break; break;
}} }}
...@@ -743,7 +800,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -743,7 +800,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs = null; rs = null;
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VMCCTR"; errCode = "VMACCTCDX";
errString = getErrorString("cctr_code__pl",errCode,userId); errString = getErrorString("cctr_code__pl",errCode,userId);
break; break;
} }
...@@ -772,41 +829,93 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -772,41 +829,93 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
rs = null; rs = null;
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VMCCTR"; errCode = "VMACCTCDX";
errString = getErrorString("cctr_code__loss",errCode,userId); errString = getErrorString("cctr_code__loss",errCode,userId);
break; break;
}} }}
} }
else if (childNodeName.equalsIgnoreCase("tax_class"))
{
taxClass = genericUtility.getColumnValue("tax_class",
dom);
if (taxClass != null && taxClass.length() > 0) {
errCode = isExist("taxclass", "tax_class",
taxClass, conn);
if ("FALSE".equalsIgnoreCase(errCode))
{
errCode = "VTTCLASS1";
errString = getErrorString("cctr_code__loss",errCode,userId);
break;
}
}
}
else if (childNodeName.equalsIgnoreCase("tax_chap")) {
taxChap = genericUtility
.getColumnValue("tax_chap", dom);
if (taxChap != null && taxChap.length() > 0) {
errCode = isExist("taxchap", "tax_chap", taxChap,
conn);
if ("FALSE".equalsIgnoreCase(errCode)) {
errCode = "VTTCHAP1";
errString = getErrorString("cctr_code__loss",errCode,userId);
break;
}
}
}
else if ( childNodeName.equalsIgnoreCase( "tax_env" ) )
{
taxEnv = genericUtility.getColumnValue( "tax_env", dom );
if( taxEnv != null && taxEnv.trim().length() > 0 )
{
sql = " SELECT COUNT(*) FROM taxenv WHERE tax_env = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,taxEnv.trim());
rs = pstmt.executeQuery();
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
if( cnt == 0 )
{
errCode = "INTAXENV";
errString = getErrorString( "tax_env", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
} }
} }
}catch(Exception e) }
catch(Exception e)
{ {
System.out.println("Exception ::"+e);
e.printStackTrace(); e.printStackTrace();
errString=e.getMessage(); throw new ITMException ( e );
throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
if(conn!=null) if(conn != null)
{ {
if(rs != null ) if( rs != null )
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null )pstmt.close(); if( pstmt != null )
pstmt =null; {
pstmt.close();
pstmt = null;
}
conn.close(); conn.close();
} }
conn = null; conn = null;
...@@ -814,14 +923,41 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -814,14 +923,41 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
catch(Exception d) catch(Exception d)
{ {
d.printStackTrace(); d.printStackTrace();
throw new ITMException ( d );
} }
} }
System.out.println("ErrString ::[ "+errString+" ]");
return errString; return errString;
} }
private String isExist(String table, String field, String value,
Connection conn) throws SQLException {
String sql = "", retStr = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
int cnt = 0;
sql = " SELECT COUNT(1) FROM " + table + " WHERE " + field + " = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, value);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0) {
retStr = "TRUE";
}
if (cnt == 0) {
retStr = "FALSE";
}
System.out.println("@@@@ isexist[" + value + "]:::[" + retStr + "]:::["
+ cnt + "]");
return retStr;
}
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
{ {
System.out.println("------------------ itemChanged called------------------"); System.out.println("------------------ itemChanged called------------------");
...@@ -855,10 +991,12 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -855,10 +991,12 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null ;
String sql = "";
String childNodeName = null; String childNodeName = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
String siteCode = "",sql="",sitedesc="",priclit="",ItemSer=""; @SuppressWarnings("unused")
String siteCode = "",sitedesc="",priclit="";
int currentFormNo =0; int currentFormNo =0;
String columnValue="",chgTerm="",chgUser="",priceList="",tranDate="",listType="",oRate="",oldRateS=""; String columnValue="",chgTerm="",chgUser="",priceList="",tranDate="",listType="",oRate="",oldRateS="";
String itemCode="",locCode="",lotNo="",lotsl="",quantity="",itmdesc="",loginSite=""; String itemCode="",locCode="",lotNo="",lotsl="",quantity="",itmdesc="",loginSite="";
...@@ -873,21 +1011,36 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -873,21 +1011,36 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
String acctCodePl="",acctCodeLo="",cctrCodePl="",cctrCodeLo="",acctCodeAr="",cctrCodeAr=""; String acctCodePl="",acctCodeLo="",cctrCodePl="",cctrCodeLo="",acctCodeAr="",cctrCodeAr="";
String custName="",currCode="",acctCodeArLs="",cctrCodeArLs="",saleAmts="",taxAmts="",taxRecos=""; String custName="",currCode="",acctCodeArLs="",cctrCodeArLs="",saleAmts="",taxAmts="",taxRecos="";
double excRate=0,saleAmt,taxAmt = 0,taxReco=0; double excRate=0,saleAmt,taxAmt = 0,taxReco=0;
java.sql.Timestamp procDate2ts = null;
Date pdate = null, cdate = null;
double modVat = 0;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String procDate2d = "";
int cnt = 0;
double exciseAmt = 0;
String currAppdate="";
String userId = "";
int childNodeListLength;
int ctr = 0;
String taxEnv = "", taxChap = "", taxClass = "";
double totalSale=0,totalTax = 0, totalExco=0;
try try
{ {
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver=null; connDriver = null;
if(objContext != null && objContext.trim().length()>0)
if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext.trim()); currentFormNo = Integer.parseInt(objContext.trim());
} }
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>"); valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chg_termr"); valueXmlString.append(editFlag).append("</editFlag> </header>");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chg_user");
System.out.println("-------- currentFormNo : "+currentFormNo); System.out.println("**********ITEMCHANGE FOR CASE" + currentFormNo+ "**************");
switch(currentFormNo) switch(currentFormNo)
{ {
...@@ -895,9 +1048,24 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -895,9 +1048,24 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
do {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn)) {
if (childNode.getFirstChild() != null) {
columnValue = childNode.getFirstChild()
.getNodeValue().trim();
}
}
ctr++;
} while (ctr < childNodeListLength
&& !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '"
+ columnValue + "'");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) ) if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{ {
...@@ -907,31 +1075,10 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -907,31 +1075,10 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
String systemDate = simpleDateFormatObj.format(currentDate.getTime()); String systemDate = simpleDateFormatObj.format(currentDate.getTime());
System.out.println("Now the date is :=> " + systemDate); System.out.println("Now the date is :=> " + systemDate);
valueXmlString.append("<tran_date>").append("<![CDATA[" + systemDate + "]]>").append("</tran_date>"); valueXmlString.append("<tran_date>").append("<![CDATA[" + systemDate + "]]>").append("</tran_date>");
//loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
//loginSite = loginSite == null ? "":loginSite.trim();
//valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
/*sql = "select descr,price_list from site where site_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
sitedesc = rs.getString(1) == null ? "":rs.getString(1);
priclit = rs.getString(2) == null ? "":rs.getString(2);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_descr>").append("<![CDATA[" + sitedesc + "]]>").append("</site_descr>");
valueXmlString.append("<price_list>").append("<![CDATA[" + priclit + "]]>").append("</price_list>");
*/
} }
if((currentColumn.trim().equalsIgnoreCase("cust_code"))) if(childNodeName.equalsIgnoreCase("cust_code"))
{ {
custCode = genericUtility.getColumnValue("cust_code",dom); custCode = genericUtility.getColumnValue("cust_code",dom);
...@@ -988,9 +1135,8 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -988,9 +1135,8 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
valueXmlString.append("<curr_code>").append("<![CDATA[]]>").append("</curr_code>"); valueXmlString.append("<curr_code>").append("<![CDATA[]]>").append("</curr_code>");
} }
} }
if((currentColumn.trim().equalsIgnoreCase("curr_code"))) if(currentColumn.trim().equalsIgnoreCase("curr_code"))
{ {
currCode = genericUtility.getColumnValue("curr_code",dom); currCode = genericUtility.getColumnValue("curr_code",dom);
...@@ -1018,109 +1164,102 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -1018,109 +1164,102 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
valueXmlString.append("<exch_rate>").append("<![CDATA[]]>").append("</exch_rate>"); valueXmlString.append("<exch_rate>").append("<![CDATA[]]>").append("</exch_rate>");
} }
} }
/* if((currentColumn.trim().equalsIgnoreCase("sale_amt"))) valueXmlString.append("</Detail1>");
{ break;
saleAmts = genericUtility.getColumnValue("sale_amt",dom);
taxAmts = genericUtility.getColumnValue("tax_amt",dom);
if(saleAmts == null) case 2:
{ parentNodeList = dom.getElementsByTagName("Detail2");
saleAmt = 0; parentNode = parentNodeList.item(0);
}else childNodeList = parentNode.getChildNodes();
{ ctr = 0;
saleAmt = Double.parseDouble(saleAmts); valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
do {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn)) {
if (childNode.getFirstChild() != null) {
columnValue = childNode.getFirstChild()
.getNodeValue().trim();
} }
if(taxAmts == null)
{
taxAmt = 0;
}else
{
taxAmt = Double.parseDouble(taxAmts);
} }
ctr++;
} while (ctr < childNodeListLength&& !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '"
if(saleAmt > 0) + columnValue + "'");
{ siteCode = checkNull(genericUtility.getColumnValue("site_code",dom1));
double totamt = saleAmt + taxAmt; tranDate = checkNull(genericUtility.getColumnValue("tran_date",dom1));
valueXmlString.append("<total_amt>").append("<![CDATA[" + totamt + "]]>").append("</total_amt>"); SimpleDateFormat simpleDateFormatObj = new SimpleDateFormat(genericUtility.getApplDateFormat());
}else utranDate = simpleDateFormatObj.parse(tranDate);
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{ {
valueXmlString.append("<total_amt>").append("<![CDATA[]]>").append("</total_amt>"); custCode = genericUtility.getColumnValue("cust_code",dom1);
}
sql = "select acct_code__ar,cctr_code__ar from "
+ "customer where cust_code = ?";
}*/ pstmt=conn.prepareStatement(sql);
if(currentColumn.trim().equalsIgnoreCase("sale_amt") || currentColumn.trim().equalsIgnoreCase("tax_amt") || currentColumn.trim().equalsIgnoreCase("excreco_amt") ) pstmt.setString(1,custCode);
rs = pstmt.executeQuery();
if(rs.next())
{ {
saleAmts = genericUtility.getColumnValue("sale_amt",dom); acctCodeArLs = rs.getString(1) == null ? "":rs.getString(1);
taxAmts = genericUtility.getColumnValue("tax_amt",dom); cctrCodeArLs = rs.getString(2) == null ? "":rs.getString(2);
taxRecos = genericUtility.getColumnValue("excreco_amt",dom);
if(saleAmts == null)
{
saleAmt = 0;
}else
{
saleAmt = Double.parseDouble(saleAmts);
} }
pstmt.close();
if(taxAmts == null) rs.close();
pstmt = null;
rs = null;
if(custCode != null && custCode.trim().length()>0 )
{ {
taxAmt = 0; valueXmlString.append("<acct_code__ar>").append("<![CDATA[" + acctCodeArLs + "]]>").append("</acct_code__ar>");
}else valueXmlString.append("<cctr_code__ar>").append("<![CDATA[" + cctrCodeArLs + "]]>").append("</cctr_code__ar>");
}
else
{ {
taxAmt = Double.parseDouble(taxAmts); valueXmlString.append("<acct_code__ar>").append("<![CDATA[]]>").append("</acct_code__ar>");
valueXmlString.append("<cctr_code__ar>").append("<![CDATA[]]>").append("</cctr_code__ar>");
} }
taxChap = genericUtility.getColumnValue("tax_chap",dom1);
taxClass = genericUtility.getColumnValue("tax_class",dom1);
taxEnv = genericUtility.getColumnValue("tax_env",dom1);
if(taxRecos == null) if(taxChap != null && taxChap.trim().length()>0 )
{
taxReco = 0;
}else
{ {
taxReco = Double.parseDouble(taxRecos); valueXmlString.append("<tax_chap>").append("<![CDATA[" + taxChap + "]]>").append("</tax_chap>");
} }
else
{
valueXmlString.append("<tax_chap>").append("<![CDATA[]]>").append("</tax_chap>");
}
if(taxClass != null && taxClass.trim().length()>0 )
{
valueXmlString.append("<tax_class>").append("<![CDATA[" + taxClass + "]]>").append("</tax_class>");
if((saleAmts != null && saleAmts.trim().length()>0) || (taxAmts != null && taxAmts.trim().length()>0) || (taxRecos != null && taxRecos.trim().length()>0)) }
else
{ {
double totchk = saleAmt + taxAmt + taxReco; valueXmlString.append("<tax_class>").append("<![CDATA[]]>").append("</tax_class>");
valueXmlString.append("<total_amt>").append("<![CDATA[" + totchk + "]]>").append("</total_amt>"); }
}else if(taxEnv != null && taxEnv.trim().length()>0 )
{ {
valueXmlString.append("<total_amt>").append("<![CDATA[]]>").append("</total_amt>"); valueXmlString.append("<tax_env>").append("<![CDATA[" + taxEnv + "]]>").append("</tax_env>");
} }
else
{
valueXmlString.append("<tax_env>").append("<![CDATA[]]>").append("</tax_env>");
} }
}
if(currentColumn.trim().equalsIgnoreCase("asset_code"))
valueXmlString.append("</Detail1>");
break;
case 2:
valueXmlString.append("<Detail2>");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
siteCode = checkNull(genericUtility.getColumnValue("site_code",dom1));
tranDate = checkNull(genericUtility.getColumnValue("tran_date",dom1));
SimpleDateFormat simpleDateFormatObj = new SimpleDateFormat(genericUtility.getApplDateFormat());
utranDate = simpleDateFormatObj.parse(tranDate);
if((currentColumn.trim().equalsIgnoreCase("asset_code")))
{ {
asstCode = genericUtility.getColumnValue("asset_code",dom); asstCode = genericUtility.getColumnValue("asset_code",dom);
tranType = genericUtility.getColumnValue("tran_type",dom1); tranType = genericUtility.getColumnValue("tran_type",dom1);
...@@ -1181,10 +1320,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -1181,10 +1320,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
cctrCodeLo = cctrCode; cctrCodeLo = cctrCode;
/*getAcctCctrAr = finCommon.getAcctDetrTtype(itemCode, itemSer, "AR", tranType, conn);
getAcctCctrAr = finCommon.getAcctDetrTtype(itemCode, itemSer, "AR", tranType, conn);
if((getAcctCctrAr.equals(" , ") || getAcctCctrAr.equals(","))) if((getAcctCctrAr.equals(" , ") || getAcctCctrAr.equals(",")))
{ {
...@@ -1198,13 +1334,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -1198,13 +1334,7 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
acctCodeAr = acctCctrAr[0]; acctCodeAr = acctCctrAr[0];
cctrCodeAr = acctCctrAr[1]; cctrCodeAr = acctCctrAr[1];
} }*/
//acct_code__mod cctr_code__mod remain
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>"); valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + descr + "]]>").append("</descr>"); valueXmlString.append("<descr>").append("<![CDATA[" + descr + "]]>").append("</descr>");
valueXmlString.append("<grp_code>").append("<![CDATA[" + grpCode + "]]>").append("</grp_code>"); valueXmlString.append("<grp_code>").append("<![CDATA[" + grpCode + "]]>").append("</grp_code>");
...@@ -1212,10 +1342,11 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -1212,10 +1342,11 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
valueXmlString.append("<cctr_code__pl>").append("<![CDATA[" + cctrCodePl + "]]>").append("</cctr_code__pl>"); valueXmlString.append("<cctr_code__pl>").append("<![CDATA[" + cctrCodePl + "]]>").append("</cctr_code__pl>");
valueXmlString.append("<acct_code__loss>").append("<![CDATA[" + acctCodeLo + "]]>").append("</acct_code__loss>"); valueXmlString.append("<acct_code__loss>").append("<![CDATA[" + acctCodeLo + "]]>").append("</acct_code__loss>");
valueXmlString.append("<cctr_code__loss>").append("<![CDATA[" + cctrCodeLo + "]]>").append("</cctr_code__loss>"); valueXmlString.append("<cctr_code__loss>").append("<![CDATA[" + cctrCodeLo + "]]>").append("</cctr_code__loss>");
valueXmlString.append("<acct_code__ar>").append("<![CDATA[" + acctCodeAr + "]]>").append("</acct_code__ar>"); /*valueXmlString.append("<acct_code__ar>").append("<![CDATA[" + acctCodeAr + "]]>").append("</acct_code__ar>");
valueXmlString.append("<cctr_code__ar>").append("<![CDATA[" + cctrCodeAr + "]]>").append("</cctr_code__ar>"); valueXmlString.append("<cctr_code__ar>").append("<![CDATA[" + cctrCodeAr + "]]>").append("</cctr_code__ar>");*/
}else{ }else
{
valueXmlString.append("<site_code>").append("<![CDATA[]]>").append("</site_code>"); valueXmlString.append("<site_code>").append("<![CDATA[]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[]]>").append("</descr>"); valueXmlString.append("<descr>").append("<![CDATA[]]>").append("</descr>");
...@@ -1224,100 +1355,103 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -1224,100 +1355,103 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
valueXmlString.append("<cctr_code__pl>").append("<![CDATA[]]>").append("</cctr_code__pl>"); valueXmlString.append("<cctr_code__pl>").append("<![CDATA[]]>").append("</cctr_code__pl>");
valueXmlString.append("<acct_code__loss>").append("<![CDATA[]]>").append("</acct_code__loss>"); valueXmlString.append("<acct_code__loss>").append("<![CDATA[]]>").append("</acct_code__loss>");
valueXmlString.append("<cctr_code__loss>").append("<![CDATA[]]>").append("</cctr_code__loss>"); valueXmlString.append("<cctr_code__loss>").append("<![CDATA[]]>").append("</cctr_code__loss>");
valueXmlString.append("<acct_code__ar>").append("<![CDATA[]]>").append("</acct_code__ar>"); /*valueXmlString.append("<acct_code__ar>").append("<![CDATA[]]>").append("</acct_code__ar>");
valueXmlString.append("<cctr_code__ar>").append("<![CDATA[]]>").append("</cctr_code__ar>"); valueXmlString.append("<cctr_code__ar>").append("<![CDATA[]]>").append("</cctr_code__ar>");*/
} }
} }
if(currentColumn.trim().equalsIgnoreCase("sale_amt"))
/* if((currentColumn.trim().equalsIgnoreCase("sale_amt")))
{ {
saleAmts = genericUtility.getColumnValue("sale_amt",dom); saleAmts = genericUtility.getColumnValue("sale_amt",dom);
taxAmts = genericUtility.getColumnValue("tax_amt",dom); //taxAmts = genericUtility.getColumnValue("tax_amt",dom);
taxRecos = genericUtility.getColumnValue("excreco_amt",dom);
if(saleAmts == null ) System.out.println("tax_amt dom"+taxAmts);
System.out.println("excreco_amt"+taxRecos);
if(saleAmts == null)
{ {
System.out.println("sale amount is null:"+saleAmts);
saleAmt = 0; saleAmt = 0;
}else }else
{ {
saleAmt = Double.parseDouble(saleAmts); saleAmt = Double.parseDouble(saleAmts);
System.out.println("Sale amount is not null:"+saleAmt);
} }
if(taxRecos == null)
if(taxAmts == null )
{ {
taxAmt = 0; System.out.println("taxRecos amount is null:"+taxRecos);
taxReco = 0;
}else }else
{ {
taxAmt = Double.parseDouble(taxAmts); System.out.println("taxAmt amount is not null:"+taxReco);
taxReco = Double.parseDouble(taxRecos);
} }
if((saleAmts != null && saleAmts.trim().length()>0))
if(saleAmt > 0)
{ {
double totamt = saleAmt + taxAmt; System.out.println("Sale amount "+saleAmt);
valueXmlString.append("<total_amt>").append("<![CDATA[" + totamt + "]]>").append("</total_amt>"); System.out.println("tax_amt "+taxAmts);
System.out.println("excreco_amt"+taxRecos);
totalSale = saleAmt + taxAmt + taxReco;
System.out.println("total amount "+totalSale);//net_amt
valueXmlString.append("<amount>").append("<![CDATA[" + totalSale + "]]>").append("</amount>");
valueXmlString.append("<net_amt>").append("<![CDATA[" + totalSale + "]]>").append("</net_amt>");
}else }else
{ {
valueXmlString.append("<total_amt>").append("<![CDATA[]]>").append("</total_amt>"); valueXmlString.append("<amount>").append("<![CDATA[]]>").append("</amount>");
valueXmlString.append("<net_amt>").append("<![CDATA[]]>").append("</net_amt>");
} }
}
if(currentColumn.trim().equalsIgnoreCase("excreco_amt") )
}*/
if((currentColumn.trim().equalsIgnoreCase("tax_amt")) || (currentColumn.trim().equalsIgnoreCase("excreco_amt")) || (currentColumn.trim().equalsIgnoreCase("sale_amt")))
{ {
saleAmts = genericUtility.getColumnValue("sale_amt",dom); saleAmts = genericUtility.getColumnValue("sale_amt",dom);
taxAmts = genericUtility.getColumnValue("tax_amt",dom); taxAmts = genericUtility.getColumnValue("tax_amt",dom);
taxRecos = genericUtility.getColumnValue("excreco_amt",dom); taxRecos = genericUtility.getColumnValue("excreco_amt",dom);
System.out.println("tax_amt dom"+taxAmts);
if(saleAmts == null ) System.out.println("excreco_amt"+taxRecos);
if(saleAmts == null)
{ {
System.out.println("sale amount is null:"+saleAmts);
saleAmt = 0; saleAmt = 0;
}else }else
{ {
saleAmt = Double.parseDouble(saleAmts); saleAmt = Double.parseDouble(saleAmts);
System.out.println("Sale amount is not null:"+saleAmt);
} }
if(taxAmts == null)
{
taxAmt = 0;
}else
{
taxAmt = Double.parseDouble(taxAmts);
}
if(taxRecos == null) if(taxRecos == null)
{ {
System.out.println("taxRecos amount is null:"+taxRecos);
taxReco = 0; taxReco = 0;
}else }else
{ {
System.out.println("taxAmt amount is not null:"+taxReco);
taxReco = Double.parseDouble(taxRecos); taxReco = Double.parseDouble(taxRecos);
} }
if((saleAmts != null && saleAmts.trim().length()>0) || (taxAmts != null && taxAmts.trim().length()>0) || (taxRecos != null && taxRecos.trim().length()>0)) if((taxRecos != null && taxRecos.trim().length()>0))
{ {
double totchk = saleAmt + taxAmt + taxReco; System.out.println("Sale amount "+saleAmt);
valueXmlString.append("<total_amt>").append("<![CDATA[" + totchk + "]]>").append("</total_amt>"); System.out.println("tax_amt "+taxAmts);
System.out.println("excreco_amt"+taxRecos);
totalExco = saleAmt + taxAmt + taxReco;
System.out.println("total amount "+totalExco);
valueXmlString.append("<amount>").append("<![CDATA[" + totalExco + "]]>").append("</amount>");
valueXmlString.append("<net_amt>").append("<![CDATA[" + totalExco + "]]>").append("</net_amt>");
}else }else
{ {
valueXmlString.append("<total_amt>").append("<![CDATA[]]>").append("</total_amt>"); valueXmlString.append("<amount>").append("<![CDATA[]]>").append("</amount>");
valueXmlString.append("<net_amt>").append("<![CDATA[]]>").append("</net_amt>");
} }
} }
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
}
}// end switch
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
...@@ -1361,4 +1495,18 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal ...@@ -1361,4 +1495,18 @@ public class AssetSales extends ValidatorEJB implements AssetSalesLocal,AssetSal
} }
return input.trim(); return input.trim();
} }
private java.util.Date addMonths(java.util.Date date, int months)throws Exception, ITMException // added by Kunal on 10/12/12
{
java.util.Date calculatedDate = null;
if (date != null)
{
final GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.MONTH, months);
calculatedDate = new java.util.Date(calendar.getTime().getTime());
}
return calculatedDate;
}
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@Stateless
public class AssetSalesPostSave extends ValidatorEJB implements AssetSalesPostSaveLocal,AssetSalesPostSaveRemote
{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave(String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
NodeList detail2List = null;
String errString = "";
Document dom = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null;
String sql = "";
System.out.println(" Tran id = "+tranId);
double taxAmt=0d,salesamt=0d,exrecoamt=0d;
double amount = 0d,Hdramount= 0d,Detamount = 0d;
int lineNo=0;
GenericUtility genericUtility = null;
try
{
genericUtility = GenericUtility.getInstance();
dom = genericUtility.parseString(domString);
detail2List = dom.getElementsByTagName("Detail2");
tranId = genericUtility.getColumnValueFromNode("tran_id", dom.getElementsByTagName("Detail1").item(0));
System.out.println("@@@@@ postSave called :["+tranId+"]");
System.out.println("@@@@@@@@ detail2List [[[[[[[["+detail2List.getLength()+"]]]]]]]]]]]]]");
pstmt=conn.prepareStatement("select sum(tax_amt),sum(sale_amt),sum(excreco_amt) from asset_sales_det where tran_id = ?");
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
while(rs.next())
{
taxAmt = rs.getDouble(1);
salesamt = rs.getDouble(2);
exrecoamt = rs.getDouble(3);
}
if(rs !=null)
rs.close();
rs = null;
if(pstmt !=null)
pstmt.close();
pstmt = null;
sql = "update asset_sales_hdr set tax_amt = ?,sale_amt = ?, excreco_amt = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, taxAmt);
pstmt.setDouble(2, salesamt);
pstmt.setDouble(3, exrecoamt);
pstmt.setString(4, tranId);
int updCisshdr=pstmt.executeUpdate();
conn.commit();
//pstmt.close();
//pstmt=null;
System.out.println(" updated record in header :: "+updCisshdr);
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
pstmt=conn.prepareStatement("select sum(tax_amt),sum(amount) from asset_sales_det where tran_id = ?");
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
while(rs.next())
{
taxAmt = rs.getDouble(1);
amount = rs.getDouble(2);
}
Hdramount = taxAmt + amount;
if(rs !=null)
rs.close();
rs = null;
if(pstmt !=null)
pstmt.close();
pstmt = null;
sql = "update asset_sales_hdr set total_amt = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, Hdramount);
pstmt.setString(2, tranId);
int updCisshdr1 =pstmt.executeUpdate();
conn.commit();
//pstmt.close();
//pstmt=null;
System.out.println(" updated record in header :: "+updCisshdr1);
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
pstmt=conn.prepareStatement("select tax_amt,amount , line_no from asset_sales_det where tran_id = ?");
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
while(rs.next())
{
taxAmt = rs.getDouble(1);
amount = rs.getDouble(2);
lineNo = rs.getInt(3);
System.out.println("Tax Amount is"+taxAmt);
System.out.println("Amount is"+taxAmt);
System.out.println("Line No is"+taxAmt);
Detamount = taxAmt + amount;
System.out.println("totamtdet>>>>>>>>>>>>>>>>> [" +Detamount +"]" );
sql = "update asset_sales_det set tot_amt = ? where tran_id = ? and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, Detamount);
pstmt.setString(2, tranId);
pstmt.setInt(3,lineNo);
int updCisshdr2 =pstmt.executeUpdate();
System.out.println(" updated record in Detail :: "+updCisshdr2);
}
}
catch(Exception e)
{
System.out.println("Exception.. "+e.getMessage());
e.printStackTrace();
errString=e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if( errString != null && errString.trim().length() > 0 )
{
conn.rollback();
System.out.println("Transaction rollback... ");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
}
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface AssetSalesPostSaveLocal
{
public String postSave(String xmlString,String tranid,String editFlag,String xtraParams,Connection conn) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Remote;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface AssetSalesPostSaveRemote extends ValidatorRemote
{
public String postSave(String xmlString,String tranId,String editflag,String xtraParams,Connection conn) throws RemoteException,ITMException;
}
\ 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