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 ...@@ -141,6 +141,8 @@ public class UnpostFin extends ProcessEJB
String tempStr1 = "", tempStr2 = "", tempStr = ""; String tempStr1 = "", tempStr2 = "", tempStr = "";
double payAmount = 0, adjAmtAdv = 0, tempAmount1 = 0, chqAmount = 0; double payAmount = 0, adjAmtAdv = 0, tempAmount1 = 0, chqAmount = 0;
int count = 0; int count = 0;
boolean isError = false;
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null; PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null;
ResultSet rs = null, rs1 = null; ResultSet rs = null, rs1 = null;
...@@ -229,6 +231,16 @@ public class UnpostFin extends ProcessEJB ...@@ -229,6 +231,16 @@ public class UnpostFin extends ProcessEJB
tableName = "receipt"; tableName = "receipt";
pkColName = "tran_id"; 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 + "]"); 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 " ; 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 ...@@ -263,11 +275,48 @@ public class UnpostFin extends ProcessEJB
while (true) 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); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "update drcr_rcp set confirmed = 'N' where tran_id = ? and confirmed = 'Y' "; sql = "update drcr_rcp set confirmed = 'N' where tran_id = ? and confirmed = 'Y' ";
...@@ -280,6 +329,7 @@ public class UnpostFin extends ProcessEJB ...@@ -280,6 +329,7 @@ public class UnpostFin extends ProcessEJB
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update drcr_rcp failed ",errCode, conn); errString = getMsg("Update drcr_rcp failed ",errCode, conn);
break; break;
...@@ -296,6 +346,7 @@ public class UnpostFin extends ProcessEJB ...@@ -296,6 +346,7 @@ public class UnpostFin extends ProcessEJB
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Deleting receivables failed ",errCode, conn); errString = getMsg("Deleting receivables failed ",errCode, conn);
break; break;
...@@ -310,6 +361,7 @@ public class UnpostFin extends ProcessEJB ...@@ -310,6 +361,7 @@ public class UnpostFin extends ProcessEJB
if(count <= 1) if(count <= 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Deleting drcr_racct failed ",errCode, conn); errString = getMsg("Deleting drcr_racct failed ",errCode, conn);
break; break;
...@@ -339,6 +391,7 @@ public class UnpostFin extends ProcessEJB ...@@ -339,6 +391,7 @@ public class UnpostFin extends ProcessEJB
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -369,6 +422,7 @@ public class UnpostFin extends ProcessEJB ...@@ -369,6 +422,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Deleting misc_payables failed ",errCode, conn); errString = getMsg("Deleting misc_payables failed ",errCode, conn);
break; break;
...@@ -387,6 +441,7 @@ public class UnpostFin extends ProcessEJB ...@@ -387,6 +441,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update pay_ibca failed ",errCode, conn); errString = getMsg("Update pay_ibca failed ",errCode, conn);
break; break;
...@@ -410,6 +465,7 @@ public class UnpostFin extends ProcessEJB ...@@ -410,6 +465,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "select ref_ser, ref_no , tot_amt from rcp_ibca_det where tran_id = ? " ; sql = "select ref_ser, ref_no , tot_amt from rcp_ibca_det where tran_id = ? " ;
...@@ -442,6 +498,7 @@ public class UnpostFin extends ProcessEJB ...@@ -442,6 +498,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update receivables failed ",errCode, conn); errString = getMsg("Update receivables failed ",errCode, conn);
break; break;
...@@ -461,6 +518,7 @@ public class UnpostFin extends ProcessEJB ...@@ -461,6 +518,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn); errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break; break;
...@@ -471,6 +529,7 @@ public class UnpostFin extends ProcessEJB ...@@ -471,6 +529,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "update journal set confirmed = 'N' where tran_id = ? and confirmed = 'Y'"; sql = "update journal set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
...@@ -482,6 +541,7 @@ public class UnpostFin extends ProcessEJB ...@@ -482,6 +541,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update journal failed ",errCode, conn); errString = getMsg("Update journal failed ",errCode, conn);
break; break;
...@@ -492,6 +552,7 @@ public class UnpostFin extends ProcessEJB ...@@ -492,6 +552,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "select count(1) as count from vouchadv where tran_id = ? " ; sql = "select count(1) as count from vouchadv where tran_id = ? " ;
...@@ -531,6 +592,7 @@ public class UnpostFin extends ProcessEJB ...@@ -531,6 +592,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn); errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break; break;
...@@ -542,6 +604,7 @@ public class UnpostFin extends ProcessEJB ...@@ -542,6 +604,7 @@ public class UnpostFin extends ProcessEJB
pstmt = null; pstmt = null;
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
} }
...@@ -558,6 +621,7 @@ public class UnpostFin extends ProcessEJB ...@@ -558,6 +621,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn); errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break; break;
...@@ -573,6 +637,7 @@ public class UnpostFin extends ProcessEJB ...@@ -573,6 +637,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn); errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break; break;
...@@ -600,6 +665,7 @@ public class UnpostFin extends ProcessEJB ...@@ -600,6 +665,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update rcp_ibca failed ",errCode, conn); errString = getMsg("Update rcp_ibca failed ",errCode, conn);
break; break;
...@@ -611,6 +677,7 @@ public class UnpostFin extends ProcessEJB ...@@ -611,6 +677,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "select count(1) as count from misc_vouchadv where tran_id = ?"; sql = "select count(1) as count from misc_vouchadv where tran_id = ?";
...@@ -648,6 +715,7 @@ public class UnpostFin extends ProcessEJB ...@@ -648,6 +715,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "MVOUCHADV"; errCode = "MVOUCHADV";
errString = getMsg("Update misc_payables failed ",errCode, conn); errString = getMsg("Update misc_payables failed ",errCode, conn);
break; break;
...@@ -660,6 +728,7 @@ public class UnpostFin extends ProcessEJB ...@@ -660,6 +728,7 @@ public class UnpostFin extends ProcessEJB
} }
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "select vouch_type from misc_voucher where tran_id = ? "; sql = "select vouch_type from misc_voucher where tran_id = ? ";
...@@ -686,6 +755,7 @@ public class UnpostFin extends ProcessEJB ...@@ -686,6 +755,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn); errString = getMsg("Update misc_voucher failed ",errCode, conn);
break; break;
...@@ -705,6 +775,7 @@ public class UnpostFin extends ProcessEJB ...@@ -705,6 +775,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn); errString = getMsg("Update misc_voucher failed ",errCode, conn);
break; break;
...@@ -723,6 +794,7 @@ public class UnpostFin extends ProcessEJB ...@@ -723,6 +794,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn); errString = getMsg("Update misc_voucher failed ",errCode, conn);
break; break;
...@@ -736,6 +808,7 @@ public class UnpostFin extends ProcessEJB ...@@ -736,6 +808,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_voucher failed ",errCode, conn); errString = getMsg("Update misc_voucher failed ",errCode, conn);
break; break;
...@@ -747,6 +820,7 @@ public class UnpostFin extends ProcessEJB ...@@ -747,6 +820,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -758,6 +832,7 @@ public class UnpostFin extends ProcessEJB ...@@ -758,6 +832,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update payr_voucher failed ",errCode, conn); errString = getMsg("Update payr_voucher failed ",errCode, conn);
break; break;
...@@ -783,6 +858,7 @@ public class UnpostFin extends ProcessEJB ...@@ -783,6 +858,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update payr_voucher failed ",errCode, conn); errString = getMsg("Update payr_voucher failed ",errCode, conn);
break; break;
...@@ -794,6 +870,7 @@ public class UnpostFin extends ProcessEJB ...@@ -794,6 +870,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -805,6 +882,7 @@ public class UnpostFin extends ProcessEJB ...@@ -805,6 +882,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_drcr_rcp failed ",errCode, conn); errString = getMsg("Update misc_drcr_rcp failed ",errCode, conn);
break; break;
...@@ -819,6 +897,7 @@ public class UnpostFin extends ProcessEJB ...@@ -819,6 +897,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Delete receivables failed ",errCode, conn); errString = getMsg("Delete receivables failed ",errCode, conn);
break; break;
...@@ -829,6 +908,7 @@ public class UnpostFin extends ProcessEJB ...@@ -829,6 +908,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -840,6 +920,7 @@ public class UnpostFin extends ProcessEJB ...@@ -840,6 +920,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update payment_exp failed ",errCode, conn); errString = getMsg("Update payment_exp failed ",errCode, conn);
break; break;
...@@ -853,6 +934,7 @@ public class UnpostFin extends ProcessEJB ...@@ -853,6 +934,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update banktran_log failed ",errCode, conn); errString = getMsg("Update banktran_log failed ",errCode, conn);
break; break;
...@@ -863,6 +945,7 @@ public class UnpostFin extends ProcessEJB ...@@ -863,6 +945,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -874,6 +957,7 @@ public class UnpostFin extends ProcessEJB ...@@ -874,6 +957,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_payment failed ",errCode, conn); errString = getMsg("Update misc_payment failed ",errCode, conn);
break; break;
...@@ -899,6 +983,7 @@ public class UnpostFin extends ProcessEJB ...@@ -899,6 +983,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_payables failed ",errCode, conn); errString = getMsg("Update misc_payables failed ",errCode, conn);
break; break;
...@@ -911,6 +996,7 @@ public class UnpostFin extends ProcessEJB ...@@ -911,6 +996,7 @@ public class UnpostFin extends ProcessEJB
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -924,6 +1010,7 @@ public class UnpostFin extends ProcessEJB ...@@ -924,6 +1010,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Delete of banktran_log failed ",errCode, conn); errString = getMsg("Delete of banktran_log failed ",errCode, conn);
break; break;
...@@ -934,6 +1021,7 @@ public class UnpostFin extends ProcessEJB ...@@ -934,6 +1021,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "update misc_payment_canc set confirmed = 'N' where tran_id = ? and confirmed = 'Y'"; sql = "update misc_payment_canc set confirmed = 'N' where tran_id = ? and confirmed = 'Y'";
...@@ -944,6 +1032,7 @@ public class UnpostFin extends ProcessEJB ...@@ -944,6 +1032,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_payment_canc failed ",errCode, conn); errString = getMsg("Update misc_payment_canc failed ",errCode, conn);
break; break;
...@@ -970,6 +1059,7 @@ public class UnpostFin extends ProcessEJB ...@@ -970,6 +1059,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_payables failed ",errCode, conn); errString = getMsg("Update misc_payables failed ",errCode, conn);
break; break;
...@@ -981,6 +1071,7 @@ public class UnpostFin extends ProcessEJB ...@@ -981,6 +1071,7 @@ public class UnpostFin extends ProcessEJB
pstmt = null; pstmt = null;
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "delete from banktran_log where tran_ser = ? and tran_no = ? "; sql = "delete from banktran_log where tran_ser = ? and tran_no = ? ";
...@@ -993,6 +1084,7 @@ public class UnpostFin extends ProcessEJB ...@@ -993,6 +1084,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Delete of banktran_log failed ",errCode, conn); errString = getMsg("Delete of banktran_log failed ",errCode, conn);
break; break;
...@@ -1004,6 +1096,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1004,6 +1096,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -1015,6 +1108,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1015,6 +1108,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_receipt failed ",errCode, conn); errString = getMsg("Update misc_receipt failed ",errCode, conn);
break; break;
...@@ -1028,6 +1122,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1028,6 +1122,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_receipt failed ",errCode, conn); errString = getMsg("Update misc_receipt failed ",errCode, conn);
break; break;
...@@ -1038,6 +1133,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1038,6 +1133,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -1049,6 +1145,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1049,6 +1145,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update misc_receipt failed ",errCode, conn); errString = getMsg("Update misc_receipt failed ",errCode, conn);
break; break;
...@@ -1075,6 +1172,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1075,6 +1172,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update receivables failed ",errCode, conn); errString = getMsg("Update receivables failed ",errCode, conn);
break; break;
...@@ -1086,6 +1184,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1086,6 +1184,7 @@ public class UnpostFin extends ProcessEJB
pstmt = null; pstmt = null;
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -1099,6 +1198,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1099,6 +1198,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update banktran_log failed ",errCode, conn); errString = getMsg("Update banktran_log failed ",errCode, conn);
break; break;
...@@ -1109,6 +1209,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1109,6 +1209,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
sql = "update fundtransfer set status = 'E' where tran_id = ? and status = 'C'"; sql = "update fundtransfer set status = 'E' where tran_id = ? and status = 'C'";
...@@ -1119,6 +1220,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1119,6 +1220,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update fundtransfer failed ",errCode, conn); errString = getMsg("Update fundtransfer failed ",errCode, conn);
break; break;
...@@ -1133,6 +1235,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1133,6 +1235,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update banktran_log failed ",errCode, conn); errString = getMsg("Update banktran_log failed ",errCode, conn);
break; break;
...@@ -1145,11 +1248,13 @@ public class UnpostFin extends ProcessEJB ...@@ -1145,11 +1248,13 @@ public class UnpostFin extends ProcessEJB
errString = updRecAdj(refId, conn); errString = updRecAdj(refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
// end 23-08-04 manoharan // end 23-08-04 manoharan
...@@ -1161,6 +1266,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1161,6 +1266,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update invoice failed ",errCode, conn); errString = getMsg("Update invoice failed ",errCode, conn);
break; break;
...@@ -1174,6 +1280,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1174,6 +1280,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Delete invacct failed ",errCode, conn); errString = getMsg("Delete invacct failed ",errCode, conn);
break; break;
...@@ -1188,6 +1295,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1188,6 +1295,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Delete invacct failed ",errCode, conn); errString = getMsg("Delete invacct failed ",errCode, conn);
break; break;
...@@ -1199,6 +1307,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1199,6 +1307,7 @@ public class UnpostFin extends ProcessEJB
errString = unPost(refSer, refId, conn); errString = unPost(refSer, refId, conn);
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
isError = true;
break; break;
} }
...@@ -1225,6 +1334,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1225,6 +1334,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DSNR00"; errCode = "DSNR00";
errString = getMsg("Update of receipt failed ",errCode, conn); errString = getMsg("Update of receipt failed ",errCode, conn);
break; break;
...@@ -1277,6 +1387,7 @@ public class UnpostFin extends ProcessEJB ...@@ -1277,6 +1387,7 @@ public class UnpostFin extends ProcessEJB
pstmtUpd = null; pstmtUpd = null;
if(count != 1) if(count != 1)
{ {
isError = true;
errCode = "DS000NR"; errCode = "DS000NR";
errString = getMsg("Update receivables failed ",errCode, conn); errString = getMsg("Update receivables failed ",errCode, conn);
break; break;
...@@ -1289,13 +1400,14 @@ public class UnpostFin extends ProcessEJB ...@@ -1289,13 +1400,14 @@ public class UnpostFin extends ProcessEJB
} }
else else
{ {
isError = true;
errCode = "SORRY"; errCode = "SORRY";
errString = getMsg("Transation series unposting not implemented ",errCode, conn); errString = getMsg("Transation series unposting not implemented ",errCode, conn);
break; break;
} }
break; break;
} }
if (errString == null || errString.trim().length() == 0) if ((errString == null || errString.trim().length() == 0) && !isError)
{ {
conn.commit(); conn.commit();
} }
...@@ -1316,7 +1428,13 @@ public class UnpostFin extends ProcessEJB ...@@ -1316,7 +1428,13 @@ public class UnpostFin extends ProcessEJB
} }
catch(Exception exception) catch(Exception exception)
{ {
isError = true;
exception.printStackTrace(); exception.printStackTrace();
errCode = "EXCEPTION";
try {
errString = getMsg("Unposting Exception",errCode, conn);
}
catch (Exception t) {}
throw new ITMException(exception); throw new ITMException(exception);
} }
finally finally
...@@ -2359,5 +2477,304 @@ public class UnpostFin extends ProcessEJB ...@@ -2359,5 +2477,304 @@ public class UnpostFin extends ProcessEJB
} }
return retVal; 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