Commit fb1924e0 authored by smanohar's avatar smanohar

Unpost of purchase receipt incorporated

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@215441 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f0502528
......@@ -141,6 +141,8 @@ public class UnpostFin extends ProcessEJB
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;
......@@ -229,6 +231,16 @@ public class UnpostFin extends ProcessEJB
tableName = "receipt";
pkColName = "tran_id";
}
else if("P-RCP".equals(refSer)) // 17-jan-2020 purchase receipt added by manoharan
{
tableName = "porcp";
pkColName = "tran_id";
}
else if("S-DSP".equals(refSer)) // 17-jan-2020 purchase receipt added by manoharan
{
tableName = "despatch";
pkColName = "desp_id";
}
System.out.println("Before loop refSer["+ refSer + "]");
sql = "select " + pkColName + " as tran_id from " + tableName + " where " + pkColName + " >= ? and " + pkColName + " <= ? and confirmed = 'Y' order by 1 " ;
......@@ -263,11 +275,48 @@ public class UnpostFin extends ProcessEJB
while (true)
{
if("CRNRCP".equals(refSer) || "DRNRCP".equals(refSer)) // credit note (invoice)
// 1. unpost the gl posting
// 2. unpost stock
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
errString = unPostStock(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
if("P-RCP".equals(refSer)) // Purchase receipt
{
// 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;
}
}
else if("CRNRCP".equals(refSer) || "DRNRCP".equals(refSer)) // credit note (invoice)
{
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "update drcr_rcp set confirmed = 'N' where tran_id = ? and confirmed = 'Y' ";
......@@ -280,6 +329,7 @@ public class UnpostFin extends ProcessEJB
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update drcr_rcp failed ",errCode, conn);
break;
......@@ -296,6 +346,7 @@ public class UnpostFin extends ProcessEJB
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Deleting receivables failed ",errCode, conn);
break;
......@@ -310,6 +361,7 @@ public class UnpostFin extends ProcessEJB
if(count <= 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Deleting drcr_racct failed ",errCode, conn);
break;
......@@ -339,6 +391,7 @@ public class UnpostFin extends ProcessEJB
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -369,6 +422,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Deleting misc_payables failed ",errCode, conn);
break;
......@@ -387,6 +441,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update pay_ibca failed ",errCode, conn);
break;
......@@ -410,6 +465,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "select ref_ser, ref_no , tot_amt from rcp_ibca_det where tran_id = ? " ;
......@@ -442,6 +498,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update receivables failed ",errCode, conn);
break;
......@@ -461,6 +518,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break;
......@@ -471,6 +529,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "update journal set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
......@@ -482,6 +541,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update journal failed ",errCode, conn);
break;
......@@ -492,6 +552,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "select count(1) as count from vouchadv where tran_id = ? " ;
......@@ -531,6 +592,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break;
......@@ -542,6 +604,7 @@ public class UnpostFin extends ProcessEJB
pstmt = null;
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
}
......@@ -558,6 +621,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break;
......@@ -573,6 +637,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break;
......@@ -600,6 +665,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break;
......@@ -611,6 +677,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "select count(1) as count from misc_vouchadv where tran_id = ?";
......@@ -648,6 +715,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "MVOUCHADV";
errString = getMsg("Update misc_payables failed ",errCode, conn);
break;
......@@ -660,6 +728,7 @@ public class UnpostFin extends ProcessEJB
}
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "select vouch_type from misc_voucher where tran_id = ? ";
......@@ -686,6 +755,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn);
break;
......@@ -705,6 +775,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn);
break;
......@@ -723,6 +794,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn);
break;
......@@ -736,6 +808,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn);
break;
......@@ -747,6 +820,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -758,6 +832,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update payr_voucher failed ",errCode, conn);
break;
......@@ -783,6 +858,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update payr_voucher failed ",errCode, conn);
break;
......@@ -794,6 +870,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -805,6 +882,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_drcr_rcp failed ",errCode, conn);
break;
......@@ -819,6 +897,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Delete receivables failed ",errCode, conn);
break;
......@@ -829,6 +908,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -840,6 +920,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update payment_exp failed ",errCode, conn);
break;
......@@ -853,6 +934,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update banktran_log failed ",errCode, conn);
break;
......@@ -863,6 +945,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -874,6 +957,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_payment failed ",errCode, conn);
break;
......@@ -899,6 +983,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_payables failed ",errCode, conn);
break;
......@@ -911,6 +996,7 @@ public class UnpostFin extends ProcessEJB
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -924,6 +1010,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Delete of banktran_log failed ",errCode, conn);
break;
......@@ -934,6 +1021,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "update misc_payment_canc set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
......@@ -944,6 +1032,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_payment_canc failed ",errCode, conn);
break;
......@@ -970,6 +1059,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_payables failed ",errCode, conn);
break;
......@@ -981,6 +1071,7 @@ public class UnpostFin extends ProcessEJB
pstmt = null;
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "delete from banktran_log where tran_ser = ? and tran_no = ? ";
......@@ -993,6 +1084,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Delete of banktran_log failed ",errCode, conn);
break;
......@@ -1004,6 +1096,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -1015,6 +1108,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_receipt failed ",errCode, conn);
break;
......@@ -1028,6 +1122,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_receipt failed ",errCode, conn);
break;
......@@ -1038,6 +1133,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -1049,6 +1145,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update misc_receipt failed ",errCode, conn);
break;
......@@ -1075,6 +1172,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update receivables failed ",errCode, conn);
break;
......@@ -1086,6 +1184,7 @@ public class UnpostFin extends ProcessEJB
pstmt = null;
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -1099,6 +1198,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update banktran_log failed ",errCode, conn);
break;
......@@ -1109,6 +1209,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
sql = "update fundtransfer set status = 'E' where tran_id = ? and status = 'C'";
......@@ -1119,6 +1220,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update fundtransfer failed ",errCode, conn);
break;
......@@ -1133,6 +1235,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update banktran_log failed ",errCode, conn);
break;
......@@ -1145,11 +1248,13 @@ public class UnpostFin extends ProcessEJB
errString = updRecAdj(refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
// end 23-08-04 manoharan
......@@ -1161,6 +1266,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update invoice failed ",errCode, conn);
break;
......@@ -1174,6 +1280,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Delete invacct failed ",errCode, conn);
break;
......@@ -1188,6 +1295,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Delete invacct failed ",errCode, conn);
break;
......@@ -1199,6 +1307,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 )
{
isError = true;
break;
}
......@@ -1225,6 +1334,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DSNR00";
errString = getMsg("Update of receipt failed ",errCode, conn);
break;
......@@ -1277,6 +1387,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null;
if(count != 1)
{
isError = true;
errCode = "DS000NR";
errString = getMsg("Update receivables failed ",errCode, conn);
break;
......@@ -1289,13 +1400,14 @@ public class UnpostFin extends ProcessEJB
}
else
{
isError = true;
errCode = "SORRY";
errString = getMsg("Transation series unposting not implemented ",errCode, conn);
break;
}
break;
}
if (errString == null || errString.trim().length() == 0)
if ((errString == null || errString.trim().length() == 0) && !isError)
{
conn.commit();
}
......@@ -1316,7 +1428,13 @@ public class UnpostFin extends ProcessEJB
}
catch(Exception exception)
{
isError = true;
exception.printStackTrace();
errCode = "EXCEPTION";
try {
errString = getMsg("Unposting Exception",errCode, conn);
}
catch (Exception t) {}
throw new ITMException(exception);
}
finally
......@@ -2359,5 +2477,304 @@ public class UnpostFin extends ProcessEJB
}
return retVal;
}
private String unPostStock(String refSer, String refId, Connection conn) throws ITMException
{
String errCode = "", siteCode = "", itemCode = "", locCode = "", lotNo = "", lotSl = "", porder = "", lineNoOrd = "", lineNoRcp = "";
String sql = "", errString = "";
double quantity = 0;
int count = 0;
boolean isError = false;
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null;
ResultSet rs = null, rs1 = null;
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 = ? " ;
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())
{
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;
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;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sql = "delete from invtrace where ref_ser = ? and ref_id = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
count = pstmtUpd.executeUpdate();
if (count <= 0)
{
errCode = "DS000NR";
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)
{
errCode = "DS000NR";
errString = getMsg("Update purchase receipt failed ",errCode, conn);
isError = true;
return errString;
}
}
else if ("S-DSP".equals(refSer.trim()))
{
// 1. update sorditem reduce the qty_desp and status P
// 2. update sorddet set status P
// 3. update stock with -1 * eff_qty
// 4. stock to be allocated against the despatch
// 5. update despatch/despatchdet status with ' ' (single space)
// 6. update despatch confirmed as N
sql = "select site_code, item_code, loc_code, lot_no, lot_sl, eff_qty, ref_line "
+ " from invtrace where ref_ser = ? and ref_id = ? " ;
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())
{
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;
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;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sql = "delete from invtrace where ref_ser = ? and ref_id = ? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1, refSer);
pstmtUpd.setString(2, refId);
count = pstmtUpd.executeUpdate();
if (count <= 0)
{
errCode = "DS000NR";
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)
{
errCode = "DS000NR";
errString = getMsg("Update purchase receipt failed ",errCode, conn);
isError = true;
return errString;
}
}
}
catch(Exception exception)
{
exception.printStackTrace();
isError = true;
errCode = "DS000NR";
try
{
errString = getMsg("Update purchase receipt failed ",errCode, conn);
}
catch (Exception t) {}
throw new ITMException(exception);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if (pstmtUpd != null)
{
pstmtUpd.close();
pstmtUpd = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
System.out.println("Return string from UnPostStock ["+errString + "]");
return (errString);
}
}
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