Commit 91f95c9f authored by smanohar's avatar smanohar

Many changes done recently in PB incorporated

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@212210 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e1aacaec
......@@ -538,7 +538,7 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
String ls_grade= "",ls_trantype = "",ls_cctr_code__cr= "",ls_channel_partner = "", ls_tran_type = "", ls_cust_code= "", ls_site_code = "", ls_crdt = "",ls_item_code = "", ls_unit = "", ls_hdr = "", ls_det = "";
String ls_dis_link = "", ls_site_code_dlv = "", ls_loc_code_git = "", ls_tran_stat = "", ls_online_acct = "", ls_edioption = "", ls_ledg_post_conf = "" , ls_invoice_id = "", ls_acctmethod = "" ,ls_sretinvqty = "", ls_var_value = "", ls_reas_code = "";
String ls_conf_drcr_opt = "", ls_conf_jv_opt = "", ls_comm_calc_on_off = "",ls_desp_id = "" ,ls_desp_line_no = "", ls_full_ret = "", ls_lot_no = "", ls_lot_sl = "", ls_sitecodedlv = "",ls_quar_lockcode = "", gs_run_mode = "";
String chgUser = "", chgTerm = "",lc_no_art = "",mline_no = "";
String chgUser = "", chgTerm = "",lc_no_art = "",mline_no = "",gitUpdate ="N";
int mcount = 0, mmin_shelf_life = 0 ,mdays = 0 , mcount1 = 0, ll_min_shelf_life =0, ll_count = 0, ll_counter = 0 , ll_sret_count = 0, ll_invtrace_count =0,ll_row =0, ll_line_no_inv = 0, ll_invamd_count = 0, ll_line_no = 0;
Timestamp currDate = null, mtran_date = null;
......@@ -546,7 +546,7 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
double mquantity = 0, mset_qty = 0, mtot_stk = 0, mrate = 0, lc_physicalqty = 0, lc_qty = 0, lc_qty1 = 0;
double lc_rate = 0, lc_gross_wt = 0, lc_net_wt = 0, lc_tare_wt = 0, lc_invqty_lot = 0, lc_srqty_lot = 0, lc_srqty_prev = 0, lc_srqty = 0;
int li_restr_days = 0, li_cnt = 0, ll_line_no__invtrace = 0, mnet_amt = 0, meff_amt = 0, mret_ref_netamt = 0;
int li_restr_days = 0, li_cnt = 0, ll_line_no__invtrace = 0, mnet_amt = 0, meff_amt = 0, mret_ref_netamt = 0,updCount =0;
StockUpdate stockUpdate = new StockUpdate();
......@@ -560,12 +560,15 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
InvHoldGen invHoldGen = new InvHoldGen();
//Added by wasim
boolean isError = false;
Timestamp sysDate = null;
Timestamp sysDate = null, invDate = null;
ResultSet rsDetail = null;
PreparedStatement pstmtDetail = null;
String errMessage = "";
int detCnt = 0;
int detCnt = 0, ll_points = 0, returnPoints = 0;
String strOpenOrder= "", reasCodeHdr = "",saleOrder = "",sordLineNo = "",expLev = "",tranidCrn = "",lineType = "", stateCodeDlv= "", countCodeDlv = "", siteCode= "";
boolean bOpenOrder = false;
double srAmount = 0, crnAmount = 0;
try
{
System.out.println("------------------- Inside confirmSalesReturn --------------- ");
......@@ -636,8 +639,9 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
rs = pstmt.executeQuery();
if(rs.next())
*/
sql = "select b.reas_code, b.quantity, b.rate, a.eff_date, b.invoice_id , b.item_code, a.cust_code ,b.line_no__inv, b.full_ret ,b.line_no__invtrace, b.line_no, a.ret_opt, b.lot_no, b.lot_sl " +
" from sreturn a,sreturndet b where a.tran_id = b.tran_id and a.tran_id = ? ";
sql = "select b.reas_code, b.quantity, b.rate, a.eff_date, b.invoice_id , b.item_code, a.cust_code ,b.line_no__inv, "
+ " b.full_ret ,b.line_no__invtrace, b.line_no, a.ret_opt, b.lot_no, b.lot_sl, a.channel_partner "
+ " from sreturn a,sreturndet b where a.tran_id = b.tran_id and a.tran_id = ? ";
pstmtDetail = conn.prepareStatement(sql);
pstmtDetail.setString(1,msalereturn );
rsDetail = pstmtDetail.executeQuery();
......@@ -658,6 +662,12 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
ls_ret_opt = checkNullAndTrim(rsDetail.getString(12));
ls_lot_no = checkNull(rsDetail.getString(13));
ls_lot_sl = checkNull(rsDetail.getString(14));
gitUpdate = checkNull(rsDetail.getString("channel_partner")); // 10-oct-2019 manoharan to update GIT stock based on channel_partner flag in header
if (gitUpdate == null || gitUpdate.trim().length() == 0)
{
gitUpdate = "N";
}
/*}
if (rs != null)
{
......@@ -915,10 +925,13 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
if(li_cnt > 0)
{
sql = "select quantity from sreturndet where tran_id = ? and line_no__inv = ? ";
// 23-jul-2019 manoharan get the quantity of the line_no instead of invoice_trace.line_no to take case in return is not against invoice
//sql = "select quantity from sreturndet where tran_id = ? and line_no__inv = ? ";
sql = "select quantity from sreturndet where tran_id = ? and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,msalereturn );
pstmt.setInt(2,ll_line_no_inv );
//pstmt.setInt(2,ll_line_no_inv );
pstmt.setInt(2,ll_line_no );
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -993,7 +1006,7 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
}
//Added by wasim on 19-MAY-2017 for while loop instead of if loop [END]
sql = "Select site_code, item_ser, tran_date, invoice_id, eff_date , cust_code, ret_opt, tran_type, case when site_code__dlv is null then site_code else site_code__dlv end from sreturn where tran_id = ?";
sql = "Select site_code, item_ser, tran_date, invoice_id, eff_date , cust_code, ret_opt, tran_type, case when site_code__dlv is null then site_code else site_code__dlv end,read_code from sreturn where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,msalereturn );
rs = pstmt.executeQuery();
......@@ -1008,6 +1021,7 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
ls_ret_opt = rs.getString(7);
ls_trantype = rs.getString(8);
ls_sitecodedlv = rs.getString(9);
reasCodeHdr = rs.getString("read_code"); //
}
if (rs != null)
{
......@@ -1238,6 +1252,13 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
pstmt = null;
}
ls_sretinvqty = distCommon.getDisparams("999999","SRET_INV_QTY",conn) ;
// 11-mar-2019 manoharan whether to open the order based on reason code
strOpenOrder = distCommon.getDisparams("999999","SRET_OPEN_ORD_REASON",conn) ;
// end 11-mar-2019 manoharan whether to open the order based on reason code
if (reasCodeHdr.trim().equals(strOpenOrder.trim()))
{
bOpenOrder = true;
}
//Changed by wasim on 19-MAY-2017 for changing prepared statements for while loop [START]
/*sql = "Select line_no, item_code, quantity__stduom, ret_rep_flag, unit__std, loc_code, lot_no, lot_sl, mfg_date, exp_date, site_code__mfg, cost_rate, reas_code, pack_code, full_ret, physical_qty, no_art, line_no__inv, line_no__invtrace , gross_weight, tare_weight, net_weight From sreturndet where tran_id = ? Order by line_no";
......@@ -1544,8 +1565,11 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
{
return merrcode;
}
if("Y".equalsIgnoreCase(ls_channel_partner) && "E".equalsIgnoreCase(ls_dis_link))
// 01-mar-2019 manoharan transit entry in case of automatic transaction also done as suggested by KB
// 10-oct-2019 manoharan to update GIT stock based on channel_partner flag in header
//if("Y".equalsIgnoreCase(ls_channel_partner) && "E".equalsIgnoreCase(ls_dis_link))
if("Y".equalsIgnoreCase(gitUpdate) && ("E".equalsIgnoreCase(ls_dis_link) || "A".equalsIgnoreCase(ls_dis_link) ))
{
stockUpd.put("inv_stat",ls_tran_stat);
stockUpd.put("loc_code",ls_loc_code_git);
......@@ -1557,6 +1581,144 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
return merrcode;
}
}
if (bOpenOrder) {
sql = "select SORD_NO,SORD_LINE_NO, EXP_LEV from invoice_trace "
+ " where invoice_id = ? and line_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, minvoice_id);
pstmt.setInt(2, ll_line_no__invtrace);
rs = pstmt.executeQuery();
if (rs.next()) {
saleOrder = rs.getString("SORD_NO");
sordLineNo = rs.getString("SORD_LINE_NO");
expLev = rs.getString("EXP_LEV");
}
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
sql = "update sorditem set qty_desp = qty_desp - ?, status = 'P' "
+ " where sale_order = ? and line_no = ? and exp_lev = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, mquantity);
pstmt.setString(2, saleOrder);
pstmt.setString(3, sordLineNo);
pstmt.setString(4, expLev);
updCount = pstmt.executeUpdate();
sql = "update sorddet set status = 'P' where sale_order = ? and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder);
pstmt.setString(2, sordLineNo);
updCount = pstmt.executeUpdate();
}
// end 17-Mar-2018 manoharan in case of full return to reduce despatch quantity
// 11-nov-2019 manoharan in case of value/quantity replacement scheme or point based scheme to reduce the
// used_free_qty = ?, used_free_value
if (minvoice_id != null && minvoice_id.trim().length() > 0 && ll_line_no_inv != 0 && ll_line_no__invtrace != 0)
{
returnPoints = 0;
sql = "select a.line_type, a.SORD_NO, b.tran_date "
+ " from invoice_trace a, invoice b "
+ " where a.invoice_id = b.invoice_id "
+ " and a.invoice_id = ? "
+ " and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,ls_invoice_id );
pstmt.setInt(2,ll_line_no__invtrace );
rs = pstmt.executeQuery();
if(rs.next())
{
lineType = rs.getString("line_type");
saleOrder = rs.getString("SORD_NO");
invDate = rs.getTimestamp("tran_date");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (lineType == null)
{
lineType = "";
}
if("P".equals(lineType.trim()))
{
// Point based scheme given free get the point from
sql = "select state_code__dlv,count_code__dlv,site_code from sorder where sale_order = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,ls_invoice_id );
pstmt.setInt(2,ll_line_no__invtrace );
rs = pstmt.executeQuery();
if(rs.next())
{
stateCodeDlv = rs.getString("state_code__dlv");
countCodeDlv = rs.getString("count_code__dlv");
siteCode = rs.getString("site_code");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
//cnt= 0;
sql = "select required_points from SCH_OFFER_ITEMS where SCHEME_CODE in (select a.scheme_code from scheme_applicability a,scheme_applicability_det b "
+ " where a.scheme_code= b.scheme_code and ? between a.app_from and a.valid_upto "
+ " and (b.site_code= ? or b.state_code = ? or b.count_code= ?) and PROD_SCH = 'Y') and item_code = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,invDate );
pstmt.setString(2,siteCode );
pstmt.setString(3,stateCodeDlv );
pstmt.setString(4,countCodeDlv );
pstmt.setString(5,mitem_code );
rs = pstmt.executeQuery();
if(rs.next())
{
ll_points = rs.getInt(1);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
returnPoints = (int) mquantity * ll_points;
sql = "UPDATE SCHEME_BALANCE SET USED_FREE_VALUE = USED_FREE_VALUE - ? "
+ " WHERE CUST_CODE = ? AND ITEM_CODE= 'X' AND ? between EFF_FROM and VALID_UPTO";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, returnPoints);
pstmt.setString(2, ls_cust_code);
pstmt.setTimestamp(3, invDate);
updCount = pstmt.executeUpdate();
}
}
// end 11-nov-2019 manoharan in case of value/quantity replacement scheme or point based scheme to reduce the
}//END tran type R (Sales return) by wasim on 19-MAY-2017
else //Added by wasim on 19-05-2017 else part for Replace (ID)
{
......@@ -1816,7 +1978,11 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
return merrcode;
}
if("Y".equalsIgnoreCase(ls_channel_partner) && "E".equalsIgnoreCase(ls_dis_link))
// 01-mar-2019 manoharan transit entry in case of automatic transaction also done as suggested by KB
// 10-oct-2019 manoharan to update GIT stock based on channel_partner flag in header
//if("Y".equalsIgnoreCase(ls_channel_partner) && "E".equalsIgnoreCase(ls_dis_link))
if("Y".equalsIgnoreCase(gitUpdate) && ("E".equalsIgnoreCase(ls_dis_link) || "A".equalsIgnoreCase(ls_dis_link) ))
{
stockUpd.put("inv_stat",ls_tran_stat);
stockUpd.put("loc_code",ls_loc_code_git);
......@@ -1829,6 +1995,7 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
}
}
} //End else part for Replaced (ID) by wasim on 19-MAY-2017
}//End while loop for sales return Details
//Added by wasim on 19-MAY-2017 to use while loop instead of if for multiple lines in sales return details [END]
......@@ -1841,6 +2008,17 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
pstmtDetail.close();pstmtDetail = null;
}
//Added by wasim on 19-MAY-2017 to use while loop instead of if for multiple lines in sales return details [END]
// 17-Mar-2018 manoharan in case of full return to reduce despatch quantity
if (bOpenOrder)
{
sql = "update sorder set status = 'P' "
+ " where sale_order = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder);
updCount = pstmt.executeUpdate();
}
// end 17-Mar-2018 manoharan in case of full return to reduce despatch quantity
ls_quar_lockcode = distCommon.getDisparams("999999","QUARNTINE_LOCKCODE",conn) ;
if("NULLFOUND".equalsIgnoreCase(ls_quar_lockcode))
......@@ -1908,7 +2086,8 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
}
}
if("Y".equalsIgnoreCase(ls_channel_partner) && "E".equalsIgnoreCase(ls_dis_link))
//if("Y".equalsIgnoreCase(ls_channel_partner) && "E".equalsIgnoreCase(ls_dis_link))
if("Y".equalsIgnoreCase(gitUpdate) && ("E".equalsIgnoreCase(ls_dis_link) || "A".equalsIgnoreCase(ls_dis_link) ))
{
sql = "Select count(*) From sreturndet Where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
......@@ -1929,9 +2108,10 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
pstmt = null;
}
sql = "Select count(*) From invtrace Where ref_ser = 'S-RET' And ref_id = ? ";
sql = "Select count(*) From invtrace Where ref_ser = 'S-RET' And ref_id = ? and loc_code <> ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,msalereturn );
pstmt.setString(2,ls_loc_code_git );
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -2264,14 +2444,158 @@ public class SalesReturnConfirm extends ActionHandlerEJB implements SalesReturnC
}
else if(!"N".equalsIgnoreCase(ls_var_value.trim()))
{
if(ls_invoice_id == null || ls_invoice_id.trim().length() == 0)
// 05-sep-2019 manoharan to create misc or normal credit note as per detail invoice_id
//without invoice no
sql = "select count(1) "//into :
+ " from sreturn a , sreturndet b "
+ " where a.tran_id = b.tran_id "
+ " and a.tran_id = ? "
+ " and a.ret_opt = 'C' "
+ " and b.invoice_id is null "
+ " and a.tran_id__crn is null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,msalereturn );
rs = pstmt.executeQuery();
if(rs.next())
{
mcount1 = rs.getInt(1);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
// 10-sep-2019 manoharan to check amount of credite note and sales return
sql = "select sum(net_amt) from sreturndet where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,msalereturn );
rs = pstmt.executeQuery();
if(rs.next())
{
srAmount = rs.getDouble(1);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
// end 10-sep-2019 manoharan to check amount of credite note and sales return
// 05-sep-2019 manoharan to create misc or normal credit note as per detail invoice_id
//if(ls_invoice_id == null || ls_invoice_id.trim().length() == 0)
if (mcount1 > 0)
{
merrcode = gbf_auto_crnote_sreturn_misc(currDate, ls_tran_type, ls_site_code, msalereturn, msalereturn, ld_tran_date, ld_tran_date, ls_cust_code,ls_cust_code, "Y", xtraParams, conn);
//merrcode = gbf_auto_crnote_sreturn_misc(ld_today, ls_tran_type, ls_site_code,as_tran_id, as_tran_id, ld_tran_date, ld_tran_date, ls_cust_code, ls_cust_code, 'Y');
if(merrcode != null && merrcode.trim().length() > 0)
{
errorString = vdt.getErrorString("",merrcode,"");
return errorString;
}
sql = "select tran_id from misc_drcr_rcp where sreturn_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,msalereturn );
rs = pstmt.executeQuery();
if(rs.next())
{
tranidCrn = rs.getString("tran_id");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = " select sum(amount) from misc_drcr_rdet where tran_id = ? and net_amt is not null";
pstmt.setString(1,msalereturn );
rs = pstmt.executeQuery();
if(rs.next())
{
crnAmount = rs.getDouble(1);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (Math.abs(crnAmount - srAmount) > 1 )
{
errorString = vdt.getErrorString("","VTSRCRAMT","");
return errorString;
}
// end 10-sep-2019 manoharan to check amount of credite note and sales return
}
else
{
merrcode = gbf_auto_crnote_sreturn(currDate, ls_tran_type, ls_site_code, msalereturn, msalereturn, ld_tran_date, ld_tran_date, ls_cust_code,ls_cust_code, "Y", xtraParams, conn);
if(merrcode != null && merrcode.trim().length() > 0)
{
errorString = vdt.getErrorString("",merrcode,"");
return errorString;
}
sql = "select tran_id from drcr_rcp where sreturn_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,msalereturn );
rs = pstmt.executeQuery();
if(rs.next())
{
tranidCrn = rs.getString("tran_id");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select sum(net_amt) from drcr_rdet where tran_id = ? ";
pstmt.setString(1,msalereturn );
rs = pstmt.executeQuery();
if(rs.next())
{
crnAmount = rs.getDouble(1);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (Math.abs(crnAmount - srAmount) > 1 )
{
errorString = vdt.getErrorString("","VTSRCRAMT","");
return errorString;
}
// end 10-sep-2019 manoharan to check amount of credite note and sales return
}
}
......
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