Commit 7191cf8a authored by pchavan's avatar pchavan

To update scheme_balance from nature type.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191930 ce508802-f39f-4f6c-b175-0d175dae99d5
parent db75bef6
...@@ -1286,13 +1286,14 @@ public class PostOrderActivity { ...@@ -1286,13 +1286,14 @@ public class PostOrderActivity {
rs=null; rs=null;
pstmt.close(); pstmt.close();
pstmt=null; pstmt=null;
sql=" select a.sord_line_no, a.sord_no, a.item_code, " sql=" select a.sord_line_no, a.sord_no, a.item_code,a.line_type, "
+ " sum(a.quantity__stduom) as quantity, sum(a.quantity__stduom * a.rate__stduom) as effNetAmt, b.item_code__parent " + " sum(a.quantity__stduom) as quantity, sum(a.quantity__stduom * a.rate__stduom) as effNetAmt, b.item_code__parent "
+ " from invoice_trace a, item b " + " from invoice_trace a, item b "
+ " where a.item_code = b.item_code " + " where a.item_code = b.item_code "
+ " and b.item_code__parent is not null " // 06-Dec-16 manoharan unnecessary all items are considered + " and b.item_code__parent is not null " // 06-Dec-16 manoharan unnecessary all items are considered
+ " and a.invoice_id = ? " + " and a.invoice_id = ? "
+ " group by a.sord_no, a.sord_line_no, a.item_code, a.item_code__ord, b.item_code__parent " +" and a.line_type not in ('I','V') " // Added By PriyankaC on 09OCt2018.
+ " group by a.sord_no, a.sord_line_no, a.item_code, a.item_code__ord, b.item_code__parent, a.line_type "
+ " order by a.sord_no, a.sord_line_no "; + " order by a.sord_no, a.sord_line_no ";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,invoiceId); pstmt.setString(1,invoiceId);
...@@ -1329,7 +1330,7 @@ public class PostOrderActivity { ...@@ -1329,7 +1330,7 @@ public class PostOrderActivity {
} }
} }
sql=" select a.order_type, a.site_code, a.state_code__dlv, b.nature, a.count_code__dlv, a.order_date,a.price_list " sql=" select a.order_type, a.site_code, a.state_code__dlv, b.nature, a.count_code__dlv, a.price_list "
+ " from sorder a,sorddet b " + " from sorder a,sorddet b "
+ " where a.sale_order = b.sale_order " + " where a.sale_order = b.sale_order "
+ " and b.sale_order= ? " + " and b.sale_order= ? "
...@@ -2866,6 +2867,18 @@ public class PostOrderActivity { ...@@ -2866,6 +2867,18 @@ public class PostOrderActivity {
throw new ITMException(e); throw new ITMException(e);
} }
return errString; return errString;
}
private String checkNullAndTrim(String inputVal)
{
if ( inputVal == null )
{
inputVal = "";
}
else
{
inputVal = inputVal.trim();
}
return inputVal;
} }
private String checkNull(String str) private String checkNull(String str)
{ {
...@@ -4486,4 +4499,316 @@ public class PostOrderActivity { ...@@ -4486,4 +4499,316 @@ public class PostOrderActivity {
return connCP; return connCP;
} }
// Added By PriyankaC update scheme_balance as per the nature [Start] 09OCt2018.
public String updateSchemBalance(String invoiceId,String xtraParams,Connection conn) throws ITMException, Exception
{
String retString="",sql="";
PreparedStatement pstmt=null,pstmt1=null;
ResultSet rs=null,rs1=null;
String itemCdParent="",itemCode="";
int cntItem=0;
String sordNo="",soLineNo="",custCode="";
Timestamp tranDate=null,effFrom=null,validUpto=null,sysdate=null ,orderDate = null;
double rate=0,quantity=0;
double totChargeQty=0,totFreeQty=quantity,totBonusQty=0,totSampleQty=0,effNetAmt=0;
int cntSchTrace=0;
String orderType="",siteCode="",stateDlv="",nature="",countCodeDlv="",priceList="",schemeCode="",chgUser="",chgTerm="";
int rowUpdate=0;
String stdSoPL="";
PreparedStatement pstmt9=null,pstmt90=null ,pstmt8 = null;
ResultSet rs8=null,rs9=null;
//double quentityschm =0,freeValue=0, rateschm=0 ,freequentity = 0 ,balValBfr = 0 ,balQtyBfr = 0 ,balQutAfr =0 ,balValAfr = 0 ,RembalVAl =0,RembalQty =0 ,balFreeVal = 0 ,balFreeQty=0;
String tranId = "" ,tranIdbal = "", invLineType = ""; // Added By PriyankaC on 7OCt2018.
int update = 0 ,invLineNo= 0; // Added By PriyankaC on 7OCt2018.
String sordNoschm = "",lotNoschm = "" , priceListschm ="",itemCodeschm ="" ,rtlSchmRateBase="",mrpPriceList = "" , errString = ""; // Added By PriyankaC2018
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
Date currentDateval = new Date();
sysdate=new Timestamp(currentDateval.getTime());
chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId"));
sql="select tran_date, cust_code from invoice "
+ " where invoice_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,invoiceId);
rs=pstmt.executeQuery();
if(rs.next())
{
tranDate=rs.getTimestamp("tran_date");
custCode=rs.getString("cust_code");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
sql = "select a.sord_line_no, a.sord_no, a.item_code,sum( a.quantity__stduom )as quantity, "
//+" (a.quantity__stduom * a.rate__stduom) as effNetAmt,"
// + " b.item_code__parent , "
+" case when trim(a.line_type) in ('I' , 'V') then a.line_type else '0' end as inv_line_type from invoice_trace a, item b "
+" where a.item_code = b.item_code and (b.item_code__parent is not null or a.line_type in ('I','V')) "
+" and a.invoice_id = ? group by a.sord_no, a.sord_line_no, a.item_code, a.item_code__ord, "
// + "b.item_code__parent ,a.quantity__stduom,"
+ "a.rate__stduom, "
+" case when trim(a.line_type) in ('I' , 'V') then a.line_type else '0' end order by a.sord_no, a.sord_line_no ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,invoiceId);
rs=pstmt.executeQuery();
int count =0 ;
while(rs.next())
{
System.out.println("count loop : " +count);
count++;
double quentityschm =0,freeValue=0, rateschm=0 ,freequentity = 0 ,balValBfr = 0 ,balQtyBfr = 0 ,balQutAfr =0 ,balValAfr = 0 ,RembalVAl =0,RembalQty =0 ,balFreeVal = 0 ,balFreeQty=0;
// itemCdParent=checkNullAndTrim(rs.getString("item_code__parent"));
itemCode=checkNullAndTrim(rs.getString("item_code"));
sordNo=checkNullAndTrim(rs.getString("sord_no"));
soLineNo=checkNull(rs.getString("sord_line_no"));
quantity=rs.getDouble("quantity");
// effNetAmt=rs.getDouble("effNetAmt");
invLineType=checkNullAndTrim(rs.getString("inv_line_type"));
sql=" select a.order_type, a.site_code, a.state_code__dlv, b.nature, a.count_code__dlv, a.order_date,a.price_list "
+ " from sorder a,sorddet b "
+ " where a.sale_order = b.sale_order "
+ " and b.sale_order= ? "
+ " and b.line_no= ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1,sordNo);
pstmt1.setString(2,soLineNo);
rs1=pstmt1.executeQuery();
if(rs1.next())
{
orderType=checkNullAndTrim(rs1.getString("order_type"));
orderDate= (rs1.getTimestamp("order_date"));
siteCode=checkNullAndTrim(rs1.getString("site_code"));
stateDlv=checkNullAndTrim(rs1.getString("state_code__dlv"));
nature=checkNullAndTrim(rs1.getString("nature"));
countCodeDlv=checkNullAndTrim(rs1.getString("count_code__dlv"));
priceList=checkNullAndTrim(rs1.getString("price_list"));
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
// = checkScheme(itemCdParent,orderType, custCode,siteCode,stateDlv,countCodeDlv,tranDate,conn);
// String temp=checkNullAndTrim(schemeCode);
System.out.println("schemeCode:::::::::::::::::"+schemeCode);
System.out.println("Nature Type:::::::::::::::::"+nature);
if("V".equalsIgnoreCase(nature) || "I".equalsIgnoreCase(nature))
{
sql = "select tran_id ,used_free_value ,used_free_qty,balance_free_value,balance_free_qty,scheme_code from scheme_balance where cust_code = ? and Item_code = ? and ? >= EFF_FROM and ? <= VALID_UPTO for update nowait ";
pstmt9=conn.prepareStatement(sql);
pstmt9.setString(1,custCode);
if("I".equalsIgnoreCase(nature))
{
pstmt9.setString(2,itemCode);
}
else
{
pstmt9.setString(2,"X");
}
pstmt9.setTimestamp(3,orderDate);
pstmt9.setTimestamp(4,orderDate);
rs8=pstmt9.executeQuery();
if(rs8.next())
{
tranIdbal = checkNullAndTrim(rs8.getString("tran_id"));
balValBfr = rs8.getDouble("used_free_value");
balQtyBfr = rs8.getDouble("used_free_qty");
schemeCode = checkNullAndTrim(rs8.getString("scheme_code"));
balFreeVal = rs8.getDouble("balance_free_value");
balFreeQty = rs8.getDouble("balance_free_qty");
}
rs8.close();
rs8=null;
pstmt9.close();
pstmt9=null;
rtlSchmRateBase = checkNullAndTrim(distCommon.getDisparams("999999", "RETL_SCHM_RATE_BASE", conn));
quentityschm = 0;
freeValue=0 ;
rateschm=0 ;
freequentity = 0;
sql = "update scheme_balance set used_free_qty = ?, used_free_value = ? where cust_code = ? and Item_code = ? and ? >= EFF_FROM and ? <= VALID_UPTO ";
pstmt9=conn.prepareStatement(sql);
sql = " Insert into FREE_BALANCE_TRACE (tran_id, bal_qty_before, bal_qty_after ,val_bal_before ,val_bal_after ,sale_order , invoice_id , tran_id__bal ,cust_code , line_no__sord ,item_code , used_qty, used_amount, scheme_code,line_no_invoicetrace) "
+" values (?, ?, ?, ?,?,?, ?,?,?,?,?, ?,?,?,?)" ;
pstmt90 = conn.prepareStatement(sql);
sql=" select a.sord_no,a.lot_no , b.price_list ,a.item_code ,a.quantity__stduom ,a.rate__stduom, a.inv_line_no "
+ " "
+ " from invoice_trace a , sorder b "
+ " where "
+ "a.sord_line_no = ? and "
+ " a.sord_no = b.sale_order "
+ " and a.invoice_id = ? order by a.inv_line_no ";
pstmt8=conn.prepareStatement(sql);
pstmt8.setString(1,soLineNo);
pstmt8.setString(2,invoiceId);
rs8=pstmt8.executeQuery();
while(rs8.next())
{
sordNoschm=checkNullAndTrim(rs8.getString("sord_no"));
quentityschm=rs8.getDouble("quantity__stduom");
System.out.println("quentityschm :" +quentityschm);
lotNoschm=checkNullAndTrim(rs8.getString("lot_no"));
priceListschm=checkNullAndTrim(rs8.getString("price_list"));
rateschm = rs8.getDouble("rate__stduom") ;
itemCodeschm=checkNullAndTrim(rs8.getString("item_code"));
invLineNo = rs8.getInt("inv_line_no");
double schmUsedval= 0, schmUsedqut = 0;
if("V".equalsIgnoreCase(nature))
{
if("M".equalsIgnoreCase(rtlSchmRateBase))
{
mrpPriceList = checkNullAndTrim(distCommon.getDisparams("999999", "MRP", conn));
priceListschm= mrpPriceList;
rateschm = distCommon.pickRate(priceListschm, sdf.format(sysdate), itemCodeschm, lotNoschm, "B", conn);
if(rateschm < 0)
{
rateschm = 0;
}
}
else
{
if(rateschm < 0)
{
rateschm = 0;
}
}
schmUsedqut = 0;
schmUsedval = quentityschm * rateschm ;
RembalVAl = balFreeVal - balValBfr;
System.out.println("RembalVAl : balFreeVal " +RembalVAl +" : " +balValBfr);
if(schmUsedval > RembalVAl)
{
errString = itmDBAccessEJB.getErrorString("","VTFREEQTY1","","",conn);
break;
}
}
else if("I".equalsIgnoreCase(nature))
{
schmUsedval= 0;
schmUsedqut = quentityschm;
RembalQty = balFreeQty - balQtyBfr;
if(quentityschm > RembalQty)
{
errString = itmDBAccessEJB.getErrorString("","VTFREEQTY1","","",conn);
break;
}
}
balQutAfr = schmUsedqut + balQtyBfr ;
balValAfr = schmUsedval + balValBfr ;
System.out.println("balQtyBfr1 : : schmUsedval" +balQtyBfr +" :" +schmUsedval +" "+balQutAfr);
System.out.println("balValBfr 1: : schmUsedval" +balValBfr +" :" +schmUsedval +" "+" "+balQutAfr);
//System.out.println("balQutAfr : balValAfr " +balQutAfr +" : " +balValAfr);
pstmt9.setDouble(1,balQutAfr);
pstmt9.setDouble(2,balValAfr);
pstmt9.setString(3,custCode);
if("V".equalsIgnoreCase(nature))
{
pstmt9.setString(4,"X");
}
else
{
pstmt9.setString(4,itemCode);
}
pstmt9.setTimestamp(5,orderDate);
pstmt9.setTimestamp(6,orderDate);
update = pstmt9.executeUpdate();
pstmt9.clearParameters();
System.out.println("Update Successfully");
// Generate tran id and insert sql FREE_BALANCE_TRACE..
tranId = generateTranId("t_free_balance_trace",siteCode,conn);
System.out.println("tranId :" +tranId);
pstmt90.setString(1,tranId);
pstmt90.setDouble(2,balQtyBfr);
pstmt90.setDouble(3,balQutAfr);
pstmt90.setDouble(4,balValBfr);
pstmt90.setDouble(5,balValAfr);
pstmt90.setString(6,sordNo);
pstmt90.setString(7,invoiceId);
pstmt90.setString(8,tranIdbal);
pstmt90.setString(9,custCode);
pstmt90.setString(10,soLineNo);
pstmt90.setString(11,itemCodeschm);
pstmt90.setDouble(12,quantity);
pstmt90.setDouble(13,freeValue);
pstmt90.setString(14,schemeCode);
pstmt90.setInt(15,invLineNo);
update = pstmt90.executeUpdate();
pstmt90.clearParameters();
balValBfr = schmUsedval + balValBfr ;
balQtyBfr = schmUsedqut + balQtyBfr ;
System.out.println("No recore Insert FREE_BALANCE_TRACE ::- ["+update+"]");
System.out.println("balQtyBfr2 : : schmUsedval" +balQtyBfr +" :" +schmUsedval);
System.out.println("balValBfr 2: : schmUsedval" +balValBfr +" :" +schmUsedval);
}
if (rs8 != null)
{
rs8.close();
rs9=null;
}
if (pstmt9 != null)
{
pstmt9.close();
pstmt9=null;
}
if (pstmt90 != null)
{
pstmt90.close();
pstmt90=null;
}
}
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}catch(Exception e)
{
System.out.println("Exception :conf ::" + e.getMessage() + ":");
e.printStackTrace();
retString=e.toString();
}
return retString;
}
// Added By PriyankaC update scheme_balance as per the nature [END].
} }
...@@ -1274,6 +1274,12 @@ public class PostOrderProcess extends ProcessEJB implements PostOrderProcessLoca ...@@ -1274,6 +1274,12 @@ public class PostOrderProcess extends ProcessEJB implements PostOrderProcessLoca
System.out.println("@@@@@ crPolicy["+crPolicy+"]lc_check_amt["+lc_check_amt+"]lsStatus["+lsStatus+"]"); System.out.println("@@@@@ crPolicy["+crPolicy+"]lc_check_amt["+lc_check_amt+"]lsStatus["+lsStatus+"]");
*/ */
errString=postordact.prdSchemeTraceUpd(invoiceId,xtraParams,conn); errString=postordact.prdSchemeTraceUpd(invoiceId,xtraParams,conn);
//PriyankaC on 9oct2018 [START]
if( errString == null || errString.trim().length() == 0 )
{
errString = postordact.updateSchemBalance(invoiceId,xtraParams,conn);
}
//PriyankaC on 9oct2018 [END]
if( errString == null || errString.trim().length() == 0 ) if( errString == null || errString.trim().length() == 0 )
{ {
//gbf_scheme_history //gbf_scheme_history
......
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