Commit 05734f43 authored by msalla's avatar msalla

unpost salesreturn and sales despatch and porcp

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@215713 ce508802-f39f-4f6c-b175-0d175dae99d5
parent db54cb99
......@@ -20,7 +20,11 @@ import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import org.w3c.dom.Document;
import com.itextpdf.text.log.SysoCounter;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.InvAllocTraceBean;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.mfg.MfgCommon;
import java.util.*;
......@@ -28,7 +32,7 @@ import java.sql.*;
public class UnpostFin extends ProcessEJB
{
FinCommon finCommon = new FinCommon();
DistCommon distCommon = new DistCommon();
E12GenericUtility genericUtility = new E12GenericUtility();
......@@ -88,7 +92,7 @@ public class UnpostFin extends ProcessEJB
refIdFr = genericUtility.getColumnValue("ref_id__fr",headerDom);
refIdTo = genericUtility.getColumnValue("ref_id__to",headerDom);
errString = unPost(refSer, refIdFr, refIdTo , conn);
if (errString.indexOf("PRCSUCES") == -1 )
{
isError = true;
......@@ -135,15 +139,15 @@ public class UnpostFin extends ProcessEJB
public String unPost(String refSer, String refIdFr, String refIdTo , Connection conn) throws ITMException, Exception
{
String errCode = "", errString = "", paySer = "", paymentNo = "", refSerAdv = "", refNoAdv = "", vouchType = "", siteCode = "", tranSer = "";
String tableName = "", pkColName = "", sql = "", errMsg = "", refId = "";
String tempStr1 = "", tempStr2 = "", tempStr = "";
double payAmount = 0, adjAmtAdv = 0, tempAmount1 = 0, chqAmount = 0;
int count = 0;
boolean isError = false;
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null;
ResultSet rs = null, rs1 = null;
ArrayList<String> tranList = new ArrayList<String>();
......@@ -236,14 +240,19 @@ public class UnpostFin extends ProcessEJB
tableName = "porcp";
pkColName = "tran_id";
}
else if("S-DSP".equals(refSer)) // 17-jan-2020 purchase receipt added by manoharan
else if("S-DSP".equals(refSer)) // 17-jan-2020 sale order despatch added by manoharan
{
tableName = "despatch";
pkColName = "desp_id";
}
System.out.println("Before loop refSer["+ refSer + "]");
else if("S-RET".equals(refSer)) // 20-jan-2020 salesreturn added by monika salla
{
tableName = "sreturn";
pkColName = "tran_id";
}
System.out.println("Before loop refSer["+ refSer + "] REF_ID ["+pkColName+" ] TABLE NAME[ "+tableName);
sql = "select " + pkColName + " as tran_id from " + tableName + " where " + pkColName + " >= ? and " + pkColName + " <= ? and confirmed = 'Y' order by 1 " ;
if("F-XFR".equals(refSer)) // fundtransfer
{
sql = "select " + pkColName + " as tran_id from " + tableName + " where " + pkColName + " >= ? and " + pkColName + " <= ? and status = 'C' order by 1 " ;
......@@ -256,6 +265,8 @@ public class UnpostFin extends ProcessEJB
{
tranList.add(rs.getString("tran_id"));
}
System.out.println("sql--->>[ "+sql);
rs.close();
rs = null;
pstmt.close();
......@@ -265,7 +276,7 @@ public class UnpostFin extends ProcessEJB
errCode = "VTNOREC";
errString = getMsg("No transaction in the range selected for unposting",errCode, conn);
return errString;
}
for(int tranCtr = 0; tranCtr<tranList.size(); tranCtr++)
{
......@@ -283,7 +294,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
errString = unPostStock(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
......@@ -294,14 +305,43 @@ public class UnpostFin extends ProcessEJB
{
// Assumed that in case voucher/payment doen which are undone through finance unpost option
// 3. update transaction as unconfirmed
sql = "update porcp set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update drcr_rcp failed ",errCode, conn);
break;
}
}
//added by monika salla 0n 20 jan 2020 -in case of despatch which are undone through finance unpost option
else if("S-DSP".equals(refSer)) // Purchase receipt
{
//ADD
System.out.println("inside salesdespatch");
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
//END
sql = "update despatch set confirmed = 'N' where DESP_ID = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
System.out.println("count in despatch "+count);
if(count != 1)
{
isError = true;
......@@ -310,7 +350,38 @@ public class UnpostFin extends ProcessEJB
break;
}
}
}
//added by monika salla 0n 20 jan 2020 -in case of sales return which are undone through finance unpost option
else if("S-RET".equals(refSer)) // Purchase receipt
{
System.out.println("inside salesreturn");
//ADD
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}//END
sql = "update sreturn set confirmed = 'N',tran_id__crn=null where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
System.out.println("count in salesreturn "+count);
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update drcr_rcp failed ",errCode, conn);
break;
}
}
//end
else if("CRNRCP".equals(refSer) || "DRNRCP".equals(refSer)) // credit note (invoice)
{
errString = unPost(refSer, refId, conn);
......@@ -320,13 +391,13 @@ public class UnpostFin extends ProcessEJB
break;
}
sql = "update drcr_rcp set confirmed = 'N' where tran_id = ? and confirmed = 'Y' ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
isError = true;
......@@ -334,16 +405,16 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update drcr_rcp failed ",errCode, conn);
break;
}
sql = "delete from receivables where tran_ser = ? and ref_no = ? and adj_amt = 0 ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
isError = true;
......@@ -352,13 +423,13 @@ public class UnpostFin extends ProcessEJB
break;
}
sql = "delete from drcr_racct where tran_id = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count <= 1)
{
isError = true;
......@@ -386,9 +457,9 @@ public class UnpostFin extends ProcessEJB
// errCode = 'Unpost option only for Receipt type'
// exit
//end if
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
......@@ -433,7 +504,7 @@ public class UnpostFin extends ProcessEJB
pstmt.close();
pstmt = null;
sql = "update pay_ibca set confirmed = 'N' where tran_id = ?";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -449,7 +520,7 @@ public class UnpostFin extends ProcessEJB
}
else if("R-IBCA".equals(refSer))
{
sql = "select tran_ser from rcp_ibca where tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId);
......@@ -477,7 +548,7 @@ public class UnpostFin extends ProcessEJB
tempStr1 = rs.getString("ref_ser");
tempStr2 = rs.getString("ref_no");
tempAmount1 = rs.getDouble("tot_amt");
if("R".equals(tempStr))
{
sql = "delete from receivables where tran_ser = ? and ref_no = ?";
......@@ -508,9 +579,9 @@ public class UnpostFin extends ProcessEJB
rs = null;
pstmt.close();
pstmt = null;
sql = "update rcp_ibca set confirmed = 'N' where tran_id = ?";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -533,7 +604,7 @@ public class UnpostFin extends ProcessEJB
break;
}
sql = "update journal set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -582,7 +653,7 @@ public class UnpostFin extends ProcessEJB
refNoAdv = rs.getString("ref_no");
adjAmtAdv = rs.getDouble("adj_amt");
sql = "update misc_payables set adj_amt = adj_amt - ? where tran_ser = ? and ref_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, adjAmtAdv);
pstmtUpd.setString(2, refSerAdv);
......@@ -608,12 +679,12 @@ public class UnpostFin extends ProcessEJB
break;
}
}
sql = "update voucher set confirmed = 'N', "
+ " net_amt = net_amt - (case when rnd_amt is null then 0 else rnd_amt end), "
+ " net_amt__bc = (net_amt - (case when rnd_amt is null then 0 else rnd_amt end))*exch_rate, "
+ " rnd_amt = 0 where tran_id = ? and confirmed = 'Y' ";
+ " net_amt = net_amt - (case when rnd_amt is null then 0 else rnd_amt end), "
+ " net_amt__bc = (net_amt - (case when rnd_amt is null then 0 else rnd_amt end))*exch_rate, "
+ " rnd_amt = 0 where tran_id = ? and confirmed = 'Y' ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -628,7 +699,7 @@ public class UnpostFin extends ProcessEJB
}
sql = "delete from misc_payables where tran_ser = ? and ref_no = ? and adj_amt = 0 ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
......@@ -657,7 +728,7 @@ public class UnpostFin extends ProcessEJB
if (!"A".equals(vouchType ))
{
sql = "delete from vouchdet where tran_id = ( select tran_id from voucher where tran_id = ? and vouch_type <> 'A') ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -703,9 +774,9 @@ public class UnpostFin extends ProcessEJB
refSerAdv = rs.getString("ref_ser");
refNoAdv = rs.getString("ref_no");
adjAmtAdv = rs.getDouble("adj_amt");
sql = "update misc_payables set adj_amt = adj_amt - ? where tran_ser = ? and ref_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, adjAmtAdv);
pstmtUpd.setString(2, refSerAdv);
......@@ -743,11 +814,11 @@ public class UnpostFin extends ProcessEJB
rs = null;
pstmt.close();
pstmt = null;
sql = "update misc_voucher set confirmed = 'N', net_amt = net_amt - rnd_amt, "
+ " net_amt__bc = (net_amt - rnd_amt)*exch_rate, rnd_amt = 0 "
+ " where tran_id = ? and confirmed = 'Y' ";
+ " net_amt__bc = (net_amt - rnd_amt)*exch_rate, rnd_amt = 0 "
+ " where tran_id = ? and confirmed = 'Y' ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -799,7 +870,7 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update misc_voucher failed ",errCode, conn);
break;
}
sql = "delete from misc_vouchacct where tran_id = ?";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
......@@ -813,7 +884,7 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update misc_voucher failed ",errCode, conn);
break;
}
}
else if ( "P-VOUC".equals(refSer)) // payroll voucher
{
......@@ -823,7 +894,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
sql = "update payr_voucher set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
......@@ -863,7 +934,7 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update payr_voucher failed ",errCode, conn);
break;
}
}
else if("MDRCRC".equals(refSer) || "MDRCRD".equals(refSer)) // misc credit / debit note
{
......@@ -873,7 +944,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
sql = "update misc_drcr_rcp set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
......@@ -887,7 +958,7 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update misc_drcr_rcp failed ",errCode, conn);
break;
}
sql = "delete from receivables where tran_ser = ? and ref_no = ? and adj_amt = 0 ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
......@@ -911,7 +982,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
sql = "update payment_exp set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
......@@ -948,7 +1019,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
sql = "update misc_payment set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
......@@ -993,13 +1064,13 @@ public class UnpostFin extends ProcessEJB
rs = null;
pstmt.close();
pstmt = null;
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "delete from banktran_log where tran_ser = ? and tran_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
......@@ -1047,9 +1118,9 @@ public class UnpostFin extends ProcessEJB
paySer = rs.getString("tran_ser");
paymentNo = rs.getString("vouch_no");
payAmount = rs.getDouble("pay_amt");
sql = "update misc_payables set adj_amt = adj_amt + ? where tran_ser = ? and ref_no = ? " ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, payAmount);
pstmtUpd.setString(2, paySer);
......@@ -1075,7 +1146,7 @@ public class UnpostFin extends ProcessEJB
break;
}
sql = "delete from banktran_log where tran_ser = ? and tran_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
......@@ -1099,7 +1170,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
sql = "update misc_receipt set confirmed = 'N' where tran_id = ? and confirmed = 'Y' ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
......@@ -1136,7 +1207,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
sql = "update rcpdishnr set confirmed = 'N' where tran_id = ? and confirmed = 'Y' ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
......@@ -1160,9 +1231,9 @@ public class UnpostFin extends ProcessEJB
paySer = rs.getString("ref_ser");
paymentNo = rs.getString("ref_no");
payAmount = rs.getDouble("rcp_amt");
sql = "update receivables set adj_amt = adj_amt + ? where tran_ser = ? and ref_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, payAmount);
pstmtUpd.setString(2, paySer);
......@@ -1187,9 +1258,9 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
sql = "delete from banktran_log where tran_ser = ? and tran_no = ?" ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
......@@ -1226,7 +1297,7 @@ public class UnpostFin extends ProcessEJB
break;
}
sql = "delete from banktran_log where tran_ser = ? and tran_no = ?" ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
......@@ -1272,7 +1343,7 @@ public class UnpostFin extends ProcessEJB
break;
}
sql = "delete from invacct where invoice_id = ?" ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -1286,7 +1357,7 @@ public class UnpostFin extends ProcessEJB
break;
}
sql = "delete from receivables where tran_ser = ? and ref_no = ? and adj_amt = 0" ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
......@@ -1310,7 +1381,7 @@ public class UnpostFin extends ProcessEJB
isError = true;
break;
}
// added by shiri 20/02/06 - to unpost receivables JV
sql = "select chq_amt from receipt where tran_id = ?";
pstmt = conn.prepareStatement(sql);
......@@ -1324,9 +1395,9 @@ public class UnpostFin extends ProcessEJB
rs = null;
pstmt.close();
pstmt = null;
sql = "update receipt set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -1339,28 +1410,28 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update of receipt failed ",errCode, conn);
break;
}
sql = "delete from receivables where tran_ser = 'R-ADV' and ref_no = ?";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
sql = "delete from banktran_log where tran_ser = ? and tran_no = ?";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
// amish 27-03-06 delete from rcpacct
// amish 27-03-06 delete from rcpacct
sql = "delete from rcpacct where tran_id = ? "
+ " and ( acct_code in (select acct_code__adv from receipt where tran_id = rcpacct.tran_id ) or "
+ " acct_code in (select acct_code__ar from rcpdet where tran_id = rcpacct.tran_id ) ) ";
+ " and ( acct_code in (select acct_code__adv from receipt where tran_id = rcpacct.tran_id ) or "
+ " acct_code in (select acct_code__ar from rcpdet where tran_id = rcpacct.tran_id ) ) ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
......@@ -1377,7 +1448,7 @@ public class UnpostFin extends ProcessEJB
paymentNo = rs.getString("ref_no");
payAmount = rs.getDouble("rcp_amt");
sql = "update receivables set adj_amt = adj_amt - ? where tran_ser = ? and ref_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, payAmount);
pstmtUpd.setString(2, paySer);
......@@ -1420,11 +1491,11 @@ public class UnpostFin extends ProcessEJB
System.out.println("Error string after loop ["+errString + "]");
if (errString == null || errString.trim().length() == 0)
{
errCode = "PRCSUCES";
errString = getMsg("Unposting completed",errCode, conn);
}
}
catch(Exception exception)
{
......@@ -1476,14 +1547,14 @@ public class UnpostFin extends ProcessEJB
{
genericUtility = null;
}
}
System.out.println("Return string from UnPost(1) ["+errString + "]");
return errString ;
}
private String unPost(String refSer, String refId, Connection conn) throws ITMException
{
String errCode = "", errString = "", acctPrd = "", prdCode = "", siteCode = "", acctCode = "", sundryType = "", sundryCode= "";
String cctrCode = "", entryBatchNo = "", postType = "", tranIdTrace = "",acctCodeCoinDiff = "", sql = "";
String cctrCodeCoinDiff = "", ledgPostCoinDiff = "", postStat = "", cctrCodeUpd = "", cctrCodesundryBal = "";
......@@ -1492,7 +1563,7 @@ public class UnpostFin extends ProcessEJB
double tempAmount1 = 0, tempAmount2 = 0;
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null;
ResultSet rs = null, rs1 = null;
try
{
......@@ -1551,20 +1622,20 @@ public class UnpostFin extends ProcessEJB
}
// END OF SHEETAL - 4/3/02
// end 04-11-04 manoharan moved from inside loop
refSer = refSer.trim();
glTraceCnt = 0;
totalDrAmount = 0;
totalCrAmount = 0;
sql = "select gltrace.tran_id as tran_id, gltrace.acct_prd as acct_prd, gltrace.prd_code as prd_code, gltrace.site_code as site_code, gltrace.acct_code as acct_code, "
+ " gltrace.cctr_code as cctr_code, gltrace.sundry_type as sundry_type, gltrace.sundry_code as sundry_code, gltrace.dr_amt as dr_amt, "
+ " gltrace.cr_amt as cr_amt, gltrace.exch_rate as exch_rate, gltrace.entry_batch_no as entry_batch_no, "
+ " (case when accounts.ledg_post is null then 'D' else accounts.ledg_post end) as ledg_post, "
+ " (case when gltrace.post_stat is null then 'N' else gltrace.post_stat end) as post_stat "
+ " from gltrace, accounts "
+ " where gltrace.acct_code = accounts.acct_code "
+ " and ref_ser = ? "
+ " and ref_id = ? " ;
+ " gltrace.cctr_code as cctr_code, gltrace.sundry_type as sundry_type, gltrace.sundry_code as sundry_code, gltrace.dr_amt as dr_amt, "
+ " gltrace.cr_amt as cr_amt, gltrace.exch_rate as exch_rate, gltrace.entry_batch_no as entry_batch_no, "
+ " (case when accounts.ledg_post is null then 'D' else accounts.ledg_post end) as ledg_post, "
+ " (case when gltrace.post_stat is null then 'N' else gltrace.post_stat end) as post_stat "
+ " from gltrace, accounts "
+ " where gltrace.acct_code = accounts.acct_code "
+ " and ref_ser = ? "
+ " and ref_id = ? " ;
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, refSer);
......@@ -1586,28 +1657,28 @@ public class UnpostFin extends ProcessEJB
entryBatchNo = rs1.getString("entry_batch_no");
postType = rs1.getString("ledg_post");
postStat = rs1.getString("post_stat");
totalDrAmount = totalDrAmount + (drAmount * exchRate) ;
totalCrAmount = totalCrAmount + (crAmount * exchRate) ;
totalDrAmount = getReqDecimal(totalDrAmount, 3) ;
totalCrAmount = getReqDecimal(totalCrAmount, 3) ;
glTraceCnt++;
if (drAmount != 0 || crAmount != 0)
{
if(entryBatchNo == null || "null".equals(entryBatchNo))
{
entryBatchNo = "";
}
drAmountBase = drAmount * exchRate ;
crAmountBase = crAmount * exchRate ;
if (!"O".equals(sundryType))
{
if (!"Y".equals(cctrCodeUpd))
{
cctrCodesundryBal = " ";
......@@ -1616,21 +1687,21 @@ public class UnpostFin extends ProcessEJB
{
cctrCodesundryBal = cctrCode;
}
// undo sundrybal
sql = "update sundrybal "
+ " set dr_amt = dr_amt - ?, "
+" cr_amt = cr_amt - ?, "
+ " dr_amt__base = dr_amt__base - ?, "
+ " cr_amt__base = cr_amt__base - ? "
+ " where acct_prd = ? "
+ " where acct_prd = ? "
+ " and prd_code in (?, 'zzzzzz') "
+ " and site_code = ? "
+ " and sundry_type = ? "
+ " and sundry_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? " ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, drAmount);
pstmtUpd.setDouble(2, crAmount);
......@@ -1648,11 +1719,11 @@ public class UnpostFin extends ProcessEJB
pstmtUpd.close();
pstmtUpd = null;
if(count != 2)
{
{
errCode = "DS000NR1";
errString = getMsg("Insert Into SUNDRYBAL Failed For Period :[" +prdCode +"]",errCode, conn);
break;
}
}
}
if ("Y".equals(postStat ))
{
......@@ -1761,35 +1832,35 @@ public class UnpostFin extends ProcessEJB
// consider entry_batch_no for summary type posting
//
if("S-INV".equals(refSer) || "D-ISS".equals(refSer)
|| "D-RCP".equals(refSer) || "S-DSP".equals(refSer)
|| "P-RCP".equals(refSer) || "C-ISS".equals(refSer)
|| "W-ISS".equals(refSer) || "W-RCP".equals(refSer)
|| "ADJISS".equals(refSer) || "ADJRCP".equals(refSer)
|| "VOUCH".equals(refSer) || "CRNRCP".equals(refSer)
|| "DRNRCP".equals(refSer) || "MDRCRC".equals(refSer)
|| "MDRCRD".equals(refSer) || "P-VOUC".equals(refSer)
|| "RCP".equals(refSer) || "R-DIS".equals(refSer)
|| "M-RCP".equals(refSer) || "M-PAY".equals(refSer)
|| "MPCANC".equals(refSer) || "E-PAY".equals(refSer)
|| "S-RET".equals(refSer) || "P-RET".equals(refSer)
|| "M-VOUC".equals(refSer) || "P-IBCA".equals(refSer)
|| "R-IBCA".equals(refSer) )
|| "D-RCP".equals(refSer) || "S-DSP".equals(refSer)
|| "P-RCP".equals(refSer) || "C-ISS".equals(refSer)
|| "W-ISS".equals(refSer) || "W-RCP".equals(refSer)
|| "ADJISS".equals(refSer) || "ADJRCP".equals(refSer)
|| "VOUCH".equals(refSer) || "CRNRCP".equals(refSer)
|| "DRNRCP".equals(refSer) || "MDRCRC".equals(refSer)
|| "MDRCRD".equals(refSer) || "P-VOUC".equals(refSer)
|| "RCP".equals(refSer) || "R-DIS".equals(refSer)
|| "M-RCP".equals(refSer) || "M-PAY".equals(refSer)
|| "MPCANC".equals(refSer) || "E-PAY".equals(refSer)
|| "S-RET".equals(refSer) || "P-RET".equals(refSer)
|| "M-VOUC".equals(refSer) || "P-IBCA".equals(refSer)
|| "R-IBCA".equals(refSer) )
{
entryBatchNo = refSer.trim() + prdCode.trim();
entryBatchNo = refSer.trim() + prdCode.trim();
}
else
{
entryBatchNo = " " ;
}
sql = "select count(1) as count from gltran "
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? "
+ " and ref_ser = ? "
+ " and tran_id__trace = ? ";
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? "
+ " and ref_ser = ? "
+ " and tran_id__trace = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
......@@ -1817,14 +1888,14 @@ public class UnpostFin extends ProcessEJB
else if (count == 1)
{
sql = "update gltran set dr_amt = dr_amt - ?, "
+ " cr_amt = cr_amt - ? "
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? "
+ " and ref_ser = ? "
+ " and tran_id__trace = ? " ;
+ " cr_amt = cr_amt - ? "
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? "
+ " and ref_ser = ? "
+ " and tran_id__trace = ? " ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, drAmountBase);
......@@ -1848,14 +1919,14 @@ public class UnpostFin extends ProcessEJB
}
//////////////////////////////////////////////////////////////////////////////////
sql = "select dr_amt, cr_amt from gltran "
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? "
+ " and ref_ser = ? "
+ " and tran_id__trace = ? " ;
//where tran_id = :ls_var1 ;
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? "
+ " and ref_ser = ? "
+ " and tran_id__trace = ? " ;
//where tran_id = :ls_var1 ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
......@@ -1874,7 +1945,7 @@ public class UnpostFin extends ProcessEJB
rs = null;
pstmt.close();
pstmt = null;
if (tempAmount1 < 0 || tempAmount2 < 0 )
{
errCode = "wrong amount";
......@@ -1891,14 +1962,14 @@ public class UnpostFin extends ProcessEJB
}
// undo acctbal
sql = "update acctbal set dr_amt = dr_amt - ?, "
+ " cr_amt = cr_amt - ?, "
+ " dr_amt__base = dr_amt__base - ?, "
+ " cr_amt__base = cr_amt__base - ? "
+ " where acct_prd = ? "
+ " and prd_code in (?, 'zzzzzz') "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? ";
+ " cr_amt = cr_amt - ?, "
+ " dr_amt__base = dr_amt__base - ?, "
+ " cr_amt__base = cr_amt__base - ? "
+ " where acct_prd = ? "
+ " and prd_code in (?, 'zzzzzz') "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, drAmount);
......@@ -1913,7 +1984,7 @@ public class UnpostFin extends ProcessEJB
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if ( count != 2)
{
errCode = "DS000NR1B";
......@@ -1928,14 +1999,14 @@ public class UnpostFin extends ProcessEJB
rs1 = null;
pstmt1.close();
pstmt1 = null;
if (errString != null && errString.trim().length() > 0 )
{
return errString;
}
totalDrAmount = getReqDecimal(totalDrAmount, 2) ;
totalCrAmount = getReqDecimal(totalCrAmount, 2) ;
if (totalDrAmount != totalCrAmount)
{
String coinDiffLimit = finCommon.getFinparams("999999", "COIN_DIFF_LIMIT", conn);
......@@ -1965,38 +2036,38 @@ public class UnpostFin extends ProcessEJB
drAmountBase = diffAmount;
crAmountBase = 0;
}
sql = "update acctbal set dr_amt = dr_amt - ?,"
+ " cr_amt = cr_amt - ?, "
+ " dr_amt__base = dr_amt__base - ?, "
+ " cr_amt__base = cr_amt__base - ? "
+ " where acct_prd = ? "
+ " and prd_code in (?, 'zzzzzz') "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? ";
+ " cr_amt = cr_amt - ?, "
+ " dr_amt__base = dr_amt__base - ?, "
+ " cr_amt__base = cr_amt__base - ? "
+ " where acct_prd = ? "
+ " and prd_code in (?, 'zzzzzz') "
+ " and site_code = ? "
+ " and acct_code = ? "
+ " and cctr_code = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, drAmount);
pstmtUpd.setDouble(2, crAmount);
pstmtUpd.setDouble(3, drAmountBase);
pstmtUpd.setDouble(4, crAmountBase);
pstmtUpd.setString(5, acctPrd);
pstmtUpd.setString(6, prdCode);
pstmtUpd.setString(7, siteCode);
pstmtUpd.setString(8, acctCodeCoinDiff);
pstmtUpd.setString(9, cctrCodeCoinDiff);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if ( count != 2)
{
errCode = "DS000NR1C";
errString = getMsg("Invalid count for update of acctbal [" +acctCodeCoinDiff +"]",errCode, conn);
return errString;
}
if("S-INV".equals(refSer) || "D-ISS".equals(refSer)
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, drAmount);
pstmtUpd.setDouble(2, crAmount);
pstmtUpd.setDouble(3, drAmountBase);
pstmtUpd.setDouble(4, crAmountBase);
pstmtUpd.setString(5, acctPrd);
pstmtUpd.setString(6, prdCode);
pstmtUpd.setString(7, siteCode);
pstmtUpd.setString(8, acctCodeCoinDiff);
pstmtUpd.setString(9, cctrCodeCoinDiff);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if ( count != 2)
{
errCode = "DS000NR1C";
errString = getMsg("Invalid count for update of acctbal [" +acctCodeCoinDiff +"]",errCode, conn);
return errString;
}
if("S-INV".equals(refSer) || "D-ISS".equals(refSer)
|| "D-RCP".equals(refSer) || "S-DSP".equals(refSer)
|| "P-RCP".equals(refSer) || "C-ISS".equals(refSer)
|| "W-ISS".equals(refSer) || "W-RCP".equals(refSer)
......@@ -2010,16 +2081,16 @@ public class UnpostFin extends ProcessEJB
|| "S-RET".equals(refSer) || "P-RET".equals(refSer)
|| "M-VOUC".equals(refSer) || "P-IBCA".equals(refSer)
|| "R-IBCA".equals(refSer) )
{
entryBatchNo = refSer.trim() + prdCode.trim();
}
else
{
entryBatchNo = " " ;
}
if("S".equals(ledgPostCoinDiff))
{
sql = "update gltran set dr_amt = dr_amt - ?, "
{
entryBatchNo = refSer.trim() + prdCode.trim();
}
else
{
entryBatchNo = " " ;
}
if("S".equals(ledgPostCoinDiff))
{
sql = "update gltran set dr_amt = dr_amt - ?, "
+ " cr_amt = cr_amt - ? "
+ " where acct_prd = ? "
+ " and prd_code = ? "
......@@ -2029,51 +2100,51 @@ public class UnpostFin extends ProcessEJB
+ " and ref_ser = ? "
+ " and tran_id__trace = ? " ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, drAmount);
pstmtUpd.setDouble(2, crAmount);
pstmtUpd.setString(3, acctPrd);
pstmtUpd.setString(4, prdCode);
pstmtUpd.setString(5, siteCode);
pstmtUpd.setString(6, acctCodeCoinDiff);
pstmtUpd.setString(7, cctrCodeCoinDiff);
pstmtUpd.setString(8, refSer);
pstmtUpd.setString(9, entryBatchNo);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
errCode = "DS000NR1D";
errString = getMsg("Error updating gltran [" +refSer +"]",errCode, conn);
return errString;
}
}
else
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, drAmount);
pstmtUpd.setDouble(2, crAmount);
pstmtUpd.setString(3, acctPrd);
pstmtUpd.setString(4, prdCode);
pstmtUpd.setString(5, siteCode);
pstmtUpd.setString(6, acctCodeCoinDiff);
pstmtUpd.setString(7, cctrCodeCoinDiff);
pstmtUpd.setString(8, refSer);
pstmtUpd.setString(9, entryBatchNo);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
// in case there is a difference in total debit/credit in gltrace
// as there is no corresponding row in gltrace table during posting
// the following logic is used, the same is repeated here
// get the entry_batch_no using a cursor as done during posting
sql = "select gltrace.entry_batch_no as entry_batch_no from gltrace, finent "
errCode = "DS000NR1D";
errString = getMsg("Error updating gltran [" +refSer +"]",errCode, conn);
return errString;
}
}
else
{
// in case there is a difference in total debit/credit in gltrace
// as there is no corresponding row in gltrace table during posting
// the following logic is used, the same is repeated here
// get the entry_batch_no using a cursor as done during posting
sql = "select gltrace.entry_batch_no as entry_batch_no from gltrace, finent "
+ " where gltrace.fin_entity = finent.fin_entity "
+ " and gltrace.ref_ser = ? "
+ " and gltrace.ref_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refId);
rs = pstmt.executeQuery();
if(rs.next())
{
entryBatchNo = rs.getString("entry_batch_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select count(1) as count from gltran "
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refId);
rs = pstmt.executeQuery();
if(rs.next())
{
entryBatchNo = rs.getString("entry_batch_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select count(1) as count from gltran "
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
......@@ -2082,35 +2153,35 @@ public class UnpostFin extends ProcessEJB
+ " and ref_ser = ? "
+ " and ref_id = ? "
+ " and tran_id__trace = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, acctCodeCoinDiff);
pstmt.setString(5, cctrCodeCoinDiff);
pstmt.setString(6, refSer);
pstmt.setString(7, refId);
pstmt.setString(8, entryBatchNo);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("count");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (count > 1 )
{
// multiple records found for summ. updation
errCode = "VTGLTRAN1";
errString = getMsg("Duplicate records for coin difference updation were found in gltran [" +refSer +"]",errCode, conn);
return errString;
}
else if (count == 1)
{
sql = "delete from gltran "
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, acctCodeCoinDiff);
pstmt.setString(5, cctrCodeCoinDiff);
pstmt.setString(6, refSer);
pstmt.setString(7, refId);
pstmt.setString(8, entryBatchNo);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("count");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (count > 1 )
{
// multiple records found for summ. updation
errCode = "VTGLTRAN1";
errString = getMsg("Duplicate records for coin difference updation were found in gltran [" +refSer +"]",errCode, conn);
return errString;
}
else if (count == 1)
{
sql = "delete from gltran "
+ " where acct_prd = ? "
+ " and prd_code = ? "
+ " and site_code = ? "
......@@ -2120,26 +2191,26 @@ public class UnpostFin extends ProcessEJB
+ " and ref_id = ? "
+ " and tran_id__trace = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, acctPrd);
pstmtUpd.setString(2, prdCode);
pstmtUpd.setString(3, siteCode);
pstmtUpd.setString(4, acctCodeCoinDiff);
pstmtUpd.setString(5, cctrCodeCoinDiff);
pstmtUpd.setString(6, refSer);
pstmtUpd.setString(7, refId);
pstmtUpd.setString(8, entryBatchNo);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
errCode = "DS000NR1D";
errString = getMsg("Error deleting gltran [" +refSer +"]",errCode, conn);
return errString;
}
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, acctPrd);
pstmtUpd.setString(2, prdCode);
pstmtUpd.setString(3, siteCode);
pstmtUpd.setString(4, acctCodeCoinDiff);
pstmtUpd.setString(5, cctrCodeCoinDiff);
pstmtUpd.setString(6, refSer);
pstmtUpd.setString(7, refId);
pstmtUpd.setString(8, entryBatchNo);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
errCode = "DS000NR1D";
errString = getMsg("Error deleting gltran [" +refSer +"]",errCode, conn);
return errString;
}
}
}
}
sql = "delete from gltrace where ref_ser = ? and ref_id = ? ";
......@@ -2155,7 +2226,7 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Error deleting gltrace [" +refSer +"]",errCode, conn);
return errString;
}
}
catch(Exception exception)
{
......@@ -2191,7 +2262,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd.close();
pstmtUpd = null;
}
}
catch(Exception e)
{
......@@ -2214,7 +2285,7 @@ public class UnpostFin extends ProcessEJB
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null;
ResultSet rs = null, rs1 = null;
int count = 0;
try
{
//// Changed By Surender : 17/05/2001 as per MR Kandarp Inst.
......@@ -2238,9 +2309,9 @@ public class UnpostFin extends ProcessEJB
//end if
////
sql = " SELECT tran_id, ref_ser, ref_no, tot_amt, adj_amt, ref_ser_adj, ref_no_adj, net_amt, tran_id__rcv "
+ " FROM receivables_adj "
+ " WHERE ((ref_ser = 'S-INV' AND ref_no = ?) OR (ref_ser_adj = 'S-INV' AND ref_no_adj = ?)) " ;
+ " FROM receivables_adj "
+ " WHERE ((ref_ser = 'S-INV' AND ref_no = ?) OR (ref_ser_adj = 'S-INV' AND ref_no_adj = ?)) " ;
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, invoiceId);
pstmt1.setString(2, invoiceId);
......@@ -2271,32 +2342,32 @@ public class UnpostFin extends ProcessEJB
rs = null;
pstmt.close();
pstmt = null;
// if recTotal = (adjAmount + recAdj) then
// status = 'A'
// else
status = "P";
status = "P";
// end if
statDate = (Timestamp) Calendar.getInstance().getTime();
sql = "update receivables "
+" set adj_amt = adj_amt - ?, "
+ " status = ?, "
+ " stat_date = ? "
+ " where tran_ser = ? "
+ " ref_no = ? " ;
+" set adj_amt = adj_amt - ?, "
+ " status = ?, "
+ " stat_date = ? "
+ " where tran_ser = ? "
+ " ref_no = ? " ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, adjAmount);
pstmtUpd.setString(2, status);
pstmtUpd.setTimestamp(3, statDate);
pstmtUpd.setString(4, refSer);
pstmtUpd.setString(5, refNO);
count = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
if(count != 1)
{
errCode = "DS000NR";
......@@ -2307,7 +2378,7 @@ public class UnpostFin extends ProcessEJB
if ("R-ADV".equals(refSer))
{
sql = "select fin_entity, site_code, cust_code, acct_code, cctr_code,curr_code, exch_rate "
+ " from receivables where tran_ser = ? and ref_no = ? " ;
+ " from receivables where tran_ser = ? and ref_no = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
......@@ -2329,7 +2400,7 @@ public class UnpostFin extends ProcessEJB
pstmt = null;
sql = "select tran_date,eff_date "
+ " from invoice where invoice_id = ? " ;
+ " from invoice where invoice_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceId);
......@@ -2343,7 +2414,7 @@ public class UnpostFin extends ProcessEJB
rs = null;
pstmt.close();
pstmt = null;
sundryBalMap = new HashMap();
sundryBalMap.put("tran_date",new Timestamp(tranDate.getTime()));
sundryBalMap.put("eff_date",new Timestamp(effDate.getTime()));
......@@ -2415,11 +2486,11 @@ public class UnpostFin extends ProcessEJB
e.printStackTrace();
}
}
return errString;
}
private String getMsg(String trace,String Code,Connection conn) throws ITMException, Exception
{
String mainStr ="";
......@@ -2447,9 +2518,9 @@ public class UnpostFin extends ProcessEJB
mainStr= begPart + trace + " </message><description>";
mainStr= mainStr+endDesc;
begPart = null;
*/
*/
itmDBAccessEJB = null;
}
catch(Exception e)
......@@ -2482,69 +2553,72 @@ public class UnpostFin extends ProcessEJB
String errCode = "", siteCode = "", itemCode = "", locCode = "", lotNo = "", lotSl = "", porder = "", lineNoOrd = "", lineNoRcp = "";
String sql = "", errString = "";
double quantity = 0;
int count = 0;
int count = 0, lineNo = 0;
boolean isError = false;
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null, pstmt2 = null, pstmt3= null, pstmt4= null;
ResultSet rs = null, rs1 = null;
String sorder=null,lineNoSord=null,explevel=null,retrepflag=null;
HashMap strAllocate = new HashMap();
InvAllocTraceBean invBean = new InvAllocTraceBean();
try
{
if ("P-RCP".equals(refSer.trim()))
{
sql = "select site_code, item_code, loc_code, lot_no, lot_sl, eff_qty, ref_line "
+ " from invtrace where ref_ser = ? and ref_id = ? and loc_code in('INTR','GIT') " ;
+ " from invtrace where ref_ser = ? and ref_id = ? ";//and loc_code in('INTR','GIT') " ;
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, refSer);
pstmt1.setString(2, refId);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
siteCode = rs1.getString("site_code");
itemCode = rs1.getString("item_code");
locCode = rs1.getString("loc_code");
lotNo = rs1.getString("lot_no");
lotSl = rs1.getString("lot_sl");
quantity = rs1.getDouble("eff_qty");
lineNoRcp = rs1.getString("site_code");
sql = "select purc_order, line_no__ord from porcpdet "
+ " where tran_id = ? and line_no = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
lineNoRcp = rs1.getString("ref_line");
if (quantity > 0)
{
porder = rs.getString("purc_order");
lineNoOrd = rs.getString("line_no__ord");
sql = "update porddet set dlv_qty = dlv_qty - ? "
+ " where purc_order = ? and line_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, porder);
pstmtUpd.setString(3, lineNoOrd);
count = pstmtUpd.executeUpdate();
if (count != 1)
sql = "select purc_order, line_no__ord from porcpdet "
+ " where tran_id = ? and line_no = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
errCode = "DS000NR";
errString = getMsg("Update purchase order detail failed ",errCode, conn);
break;
porder = rs.getString("purc_order");
lineNoOrd = rs.getString("line_no__ord");
sql = "update porddet set dlv_qty = dlv_qty - ? "
+ " where purc_order = ? and line_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, porder);
pstmtUpd.setString(3, lineNoOrd);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update purchase order detail failed ",errCode, conn);
break;
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "update stock set quantity = quantity - ? "
+ " where item_code = ? "
+ " and site_code = ? "
......@@ -2558,14 +2632,14 @@ public class UnpostFin extends ProcessEJB
pstmtUpd.setString(4, locCode);
pstmtUpd.setString(5, lotNo);
pstmtUpd.setString(6, lotSl);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update stock order detail failed ",errCode, conn);
break;
}
}
rs1.close();
......@@ -2577,7 +2651,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
count = pstmtUpd.executeUpdate();
if (count <= 0)
{
......@@ -2585,14 +2659,14 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Deleting invtrace failed ",errCode, conn);
isError = true;
return errString;
}
sql = " update porcp set qc_reqd = 'N' where tran_id = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
......@@ -2600,7 +2674,7 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update purchase receipt failed ",errCode, conn);
isError = true;
return errString;
}
}
else if ("S-DSP".equals(refSer.trim()))
......@@ -2611,60 +2685,323 @@ public class UnpostFin extends ProcessEJB
// 4. stock to be allocated against the despatch
// 5. update despatch/despatchdet status with ' ' (single space)
// 6. update despatch confirmed as N
System.out.println("inside unpost save sale despatch: ref ser[ "+refSer+"] refId ["+refId);
sql = "select site_code, item_code, loc_code, lot_no, lot_sl, eff_qty, ref_line "
+ " from invtrace where ref_ser = ? and ref_id = ? " ;
+ " from invtrace where ref_ser = ? and ref_id = ? " ;
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, refSer);
pstmt1.setString(2, refId);
rs1 = pstmt1.executeQuery();
System.out.println("sql---"+sql);
while(rs1.next())
{
System.out.println("sql11---"+sql);
siteCode = rs1.getString("site_code");
itemCode = rs1.getString("item_code");
locCode = rs1.getString("loc_code");
lotNo = rs1.getString("lot_no");
lotSl = rs1.getString("lot_sl");
quantity = rs1.getDouble("eff_qty");
lineNoRcp = rs1.getString("site_code");
sql = "select purc_order, line_no__ord from porcpdet "
+ " where tran_id = ? and line_no = ? " ;
lineNoRcp = rs1.getString("ref_line");
//select --sale order--no---
System.out.println(" Despatch details ref ser1 sitecode ["+siteCode+" ] item_code["+itemCode+"] loc_code"+locCode+" ]quantity"+quantity+" ]lineNoRcp"+lineNoRcp);
sql = "select sord_no,line_no__sord ,exp_lev from despatchdet where desp_id= ? and line_no=?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
porder = rs.getString("purc_order");
lineNoOrd = rs.getString("line_no__ord");
sorder = rs.getString("sord_no");
lineNoSord = rs.getString("line_no__sord");
explevel = rs.getString("exp_lev");//end
//added by monika
//(1)update qty_desptch,status
System.out.println("eff qty :"+quantity+ " sql");
if(quantity<0)
{
sql = "update sorditem set qty_desp = qty_desp + ? ,status= ? "
+ " where sale_order = ? and line_no=? and exp_lev=?";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, "P");
pstmtUpd.setString(3, sorder);
pstmtUpd.setString(4, lineNoSord);
pstmtUpd.setString(5, explevel);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update purchase order detail failed ",errCode, conn);
break;
}
//end
//(2)update sorddet set status
sql = "update sorddet set status='P' where sale_order = ? and line_no=?";
pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1,sorder);
pstmt2.setString(2, lineNoSord);
count = pstmt2.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update purchase order detail failed ",errCode, conn);
break;
}
pstmt2.close();
pstmt2=null;//end
}
//(3)update stock set quantity with eff_qty
// sql = "update stock set quantity =(-1) * ? where item_code = ? "
sql = "update stock set quantity =quantity - ? where item_code = ? "
+ " and site_code = ? "
+ " and loc_code = ? "
+ " and lot_no = ? "
+ " and lot_sl = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, itemCode);
pstmtUpd.setString(3, siteCode);
pstmtUpd.setString(4, locCode);
pstmtUpd.setString(5, lotNo);
pstmtUpd.setString(6, lotSl);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update stock order detail failed ",errCode, conn);
break;
}
pstmtUpd.close();
pstmtUpd=null;//end
//update invalocate trace
if(quantity<0)
{
strAllocate = null;
strAllocate = new HashMap();
strAllocate.put("ref_id",refId);
strAllocate.put("ref_line",lineNoRcp.substring(lineNoRcp.length()-3));
strAllocate.put("site_code",siteCode);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(-1 * quantity));
strAllocate.put("chg_win","W_DESPATCH");
strAllocate.put("ref_ser","S-DSP");
String logMsg= refId +" "+explevel+" "+lineNoRcp.substring(lineNoRcp.length()-3) + " "+"Allocation of stock from DespatchPos";
strAllocate.put("alloc_ref",logMsg);
errString = invBean.updateInvallocTrace(strAllocate,conn);
sql ="UPDATE SORDITEM SET QTY_ALLOC = QTY_ALLOC - ? "
+"WHERE SALE_ORDER = ? "
+"AND LINE_NO = ? "
+"AND EXP_LEV = ? ";
System.out.println("Update sql :"+sql);
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1,quantity);
pstmtUpd.setString(2,sorder);
pstmtUpd.setString(3,lineNoSord);
pstmtUpd.setString(4,explevel);
count = pstmtUpd.executeUpdate();
System.out.println("Updated the no of records : updateCnt :"+count);
// pstmt.clearParameters();
sql = "update porddet set dlv_qty = dlv_qty - ? "
pstmtUpd.close();
pstmtUpd=null;
}
//end
//update despatch /despatchdet
sql="update despatch set status = ? where desp_id= ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1," ");
pstmtUpd.setString(2, refId);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update purchase order detail failed ",errCode, conn);
break;
}
pstmtUpd.close();
pstmtUpd=null;//end
sql = "update despatchdet set status = ? where desp_id= ? and line_no=? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, " ");
pstmtUpd.setString(2, refId);
pstmtUpd.setString(3, lineNoRcp);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update purchase order detail failed ",errCode, conn);
break;
}
pstmtUpd.close();
pstmtUpd=null;//end
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
pstmt1.close();
pstmt1=null;
rs1.close();
rs1=null;
} // to check for sreturn--
/* 1. select invtrace and update stock with -1 * eff_qty
2. if ret_repl_flag in detail is P then allocate stock
3. update sreturn confirmed = 'N', tran_id__crn = null*/
//start
else if ("S-RET".equals(refSer.trim()))
{
sql = "select site_code, item_code, loc_code, lot_no, lot_sl, eff_qty, ref_line "
+ " from invtrace where ref_ser = ? and ref_id = ? ";//and loc_code in('INTR','GIT') " ;
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, refSer);
pstmt1.setString(2, refId);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
siteCode = rs1.getString("site_code");
itemCode = rs1.getString("item_code");
locCode = rs1.getString("loc_code");
lotNo = rs1.getString("lot_no");
lotSl = rs1.getString("lot_sl");
quantity = rs1.getDouble("eff_qty");
lineNoRcp = rs1.getString("ref_line");
System.out.println(" Despatch details ref ser1 sitecode ["+siteCode+" ] item_code["+itemCode+"] loc_code"+locCode+" ]quantity"+quantity+" ]lineNoRcp"+lineNoRcp);
//(1)update stock set quantity with eff_qty
//sql = "update stock set quantity =quantity - ? where item_code = ? "
sql = "update stock set quantity =quantity - ? where item_code = ? "
+ " and site_code = ? "
+ " and loc_code = ? "
+ " and lot_no = ? "
+ " and lot_sl = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, itemCode);
pstmtUpd.setString(3, siteCode);
pstmtUpd.setString(4, locCode);
pstmtUpd.setString(5, lotNo);
pstmtUpd.setString(6, lotSl);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update stock order detail failed ",errCode, conn);
break;
}
pstmtUpd.close();//end
pstmtUpd=null;
lineNo = Integer.parseInt(lineNoRcp.trim());
sql = "select ret_rep_flag from sreturndet where tran_id = ? and line_no = ? " ;
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
pstmtUpd.setInt(2, lineNo);
rs = pstmtUpd.executeQuery();
if(rs.next())
{
retrepflag = rs.getString("ret_rep_flag");
}
rs.close();
rs = null;
System.out.println("retrepflag1 ["+retrepflag);
if(quantity<0 && "P".equals(retrepflag))
{
strAllocate = null;
strAllocate = new HashMap();
System.out.println("retrepflag1 ["+retrepflag);
strAllocate.put("ref_id",refId);
strAllocate.put("ref_line",lineNoRcp.substring(lineNoRcp.length()-3));
strAllocate.put("site_code",siteCode);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(-1 * quantity));
strAllocate.put("chg_win","w_salesreturn_retn");
strAllocate.put("ref_ser","S-RET");
String logMsg= refId +" "+explevel+" "+lineNoRcp.substring(lineNoRcp.length()-3) + " "+"Allocation of stock from UnpostFin";
strAllocate.put("alloc_ref",logMsg);
errString = invBean.updateInvallocTrace(strAllocate,conn);
}
}
pstmt1.close();
pstmt1=null;
rs1.close();
rs1=null;
}
//end [MONIKA SALLA]
/* sql = "update porddet set dlv_qty = dlv_qty - ? "
+ " where purc_order = ? and line_no = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, porder);
pstmtUpd.setString(3, lineNoOrd);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update purchase order detail failed ",errCode, conn);
break;
}
pstmtUpd=null;
pstmtUpd.close();
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "update stock set quantity = quantity - ? "
pstmt = null;*/
/* sql = "update stock set quantity = quantity - ? "
+ " where item_code = ? "
+ " and site_code = ? "
+ " and loc_code = ? "
......@@ -2677,16 +3014,17 @@ public class UnpostFin extends ProcessEJB
pstmtUpd.setString(4, locCode);
pstmtUpd.setString(5, lotNo);
pstmtUpd.setString(6, lotSl);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
errCode = "DS000NR";
errString = getMsg("Update stock order detail failed ",errCode, conn);
break;
}
}
}*/
/*}
rs1.close();
rs1 = null;
pstmt1.close();
......@@ -2696,7 +3034,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
count = pstmtUpd.executeUpdate();
if (count <= 0)
{
......@@ -2704,14 +3042,14 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Deleting invtrace failed ",errCode, conn);
isError = true;
return errString;
}
sql = " update porcp set qc_reqd = 'N' where tran_id = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refId);
count = pstmtUpd.executeUpdate();
if (count != 1)
{
......@@ -2719,9 +3057,9 @@ public class UnpostFin extends ProcessEJB
errString = getMsg("Update purchase receipt failed ",errCode, conn);
isError = true;
return errString;
}
}
}*/
//}
}
......@@ -2732,7 +3070,7 @@ public class UnpostFin extends ProcessEJB
errCode = "DS000NR";
try
{
errString = getMsg("Update purchase receipt failed ",errCode, conn);
errString = getMsg("Update purchase receipt failed ",errCode, conn);
}
catch (Exception t) {}
throw new ITMException(exception);
......@@ -2766,7 +3104,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd.close();
pstmtUpd = null;
}
}
catch(Exception e)
{
......@@ -2777,4 +3115,4 @@ public class UnpostFin extends ProcessEJB
return (errString);
}
}
}
\ 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