Commit 4dae5902 authored by prane's avatar prane

added deallocation of sordalloc and same will updates in sorditem and...

added deallocation of sordalloc and same will updates in sorditem and round_adj related changes in invoice

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@199454 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1fa6df8b
...@@ -123,6 +123,7 @@ public class PostOrdDespatchGen ...@@ -123,6 +123,7 @@ public class PostOrdDespatchGen
int lineNoDet = 0; int lineNoDet = 0;
HashMap invAllocTraceMap = null; HashMap invAllocTraceMap = null;
InvAllocTraceBean invBean = null; InvAllocTraceBean invBean = null;
String sqlSord = "";
try { try {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
//System.out.println("process starts---------"); //System.out.println("process starts---------");
...@@ -1988,7 +1989,112 @@ public class PostOrdDespatchGen ...@@ -1988,7 +1989,112 @@ public class PostOrdDespatchGen
{ {
errString = itmDBAccessEJB.getErrorString("VTSTKNOAVL",errString,"","",conn); errString = itmDBAccessEJB.getErrorString("VTSTKNOAVL",errString,"","",conn);
return errString; return errString;
}else //Pavan R 10apr19[to deallocate in sordalloc and sorditem] start
{
double qtyAlloc = 0;
double qtyStduom = (Double)sordDetMap.get("quantity__stduom");
int updateCnt = 0;
sql = "SELECT QTY_ALLOC AS COUNT FROM SORDALLOC "
+"WHERE SALE_ORDER = ? "
+"AND LINE_NO = ? "
+"AND EXP_LEV = ? "
+"AND ITEM_CODE__ORD = ? "
+"AND ITEM_CODE = ? "
+"AND LOT_NO = ? "
+"AND LOT_SL = ? "
+"AND LOC_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,checkNull(sordDetMap.get("sord_no").toString()));
pstmt.setString(2,checkNull(sordDetMap.get("line_no__sord").toString()));
pstmt.setString(3,checkNull(sordDetMap.get("exp_lev").toString()));
pstmt.setString(4,checkNull(sordDetMap.get("item_code__ord").toString()));
pstmt.setString(5,checkNull(sordDetMap.get("item_code").toString()));
pstmt.setString(6,checkNull(sordDetMap.get("lot_no").toString()));
pstmt.setString(7,checkNull(sordDetMap.get("lot_sl").toString()));
pstmt.setString(8,checkNull(sordDetMap.get("loc_code").toString()));
rs = pstmt.executeQuery();
if(rs.next())
{
qtyAlloc = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Postord Length of for loop>>"+lineNumber+"]");
System.out.println("Postord qtyallocation>>"+qtyAlloc);
System.out.println("Postord Qtystduom"+qtyStduom);
if((qtyAlloc >= qtyStduom) && (qtyAlloc > 0))//deallocation
{
if (qtyAlloc - qtyStduom <= 0)
{
sqlSord = "DELETE FROM SORDALLOC WHERE SALE_ORDER = ? "
+"AND LINE_NO = ? "
+"AND EXP_LEV = ? "
+"AND ITEM_CODE__ORD = ? "
+"AND ITEM_CODE = ? "
+"AND LOT_NO = ? "
+"AND LOT_SL = ? "
+"AND LOC_CODE = ? ";
System.out.println("Postord Delete sql sqlSord :"+sqlSord);
pstmt = conn.prepareStatement(sqlSord);
pstmt.setString(1,checkNull(sordDetMap.get("sord_no").toString()));
pstmt.setString(2,checkNull(sordDetMap.get("line_no__sord").toString()));
pstmt.setString(3,checkNull(sordDetMap.get("exp_lev").toString()));
pstmt.setString(4,checkNull(sordDetMap.get("item_code__ord").toString()));
pstmt.setString(5,checkNull(sordDetMap.get("item_code").toString()));
pstmt.setString(6,checkNull(sordDetMap.get("lot_no").toString()));
pstmt.setString(7,checkNull(sordDetMap.get("lot_sl").toString()));
pstmt.setString(8,checkNull(sordDetMap.get("loc_code").toString()));
updateCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Postord Deleted the no of records are : updateCnt :"+updateCnt);
}
else
{
sqlSord = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - ? "
+"WHERE SALE_ORDER = ? "
+"AND LINE_NO = ? "
+"AND EXP_LEV = ? "
+"AND ITEM_CODE__ORD = ? "
+"AND ITEM_CODE = ? "
+"AND LOT_NO = ? "
+"AND LOT_SL = ? "
+"AND LOC_CODE = ? ";
System.out.println("Postord Update sql sqlSord :"+sqlSord);
pstmt = conn.prepareStatement(sqlSord);
pstmt.setDouble(1,qtyStduom);
pstmt.setString(2,checkNull(sordDetMap.get("sord_no").toString()));
pstmt.setString(3,checkNull(sordDetMap.get("line_no__sord").toString()));
pstmt.setString(4,checkNull(sordDetMap.get("exp_lev").toString()));
pstmt.setString(5,checkNull(sordDetMap.get("item_code__ord").toString()));
pstmt.setString(6,checkNull(sordDetMap.get("item_code").toString()));
pstmt.setString(7,checkNull(sordDetMap.get("lot_no").toString()));
pstmt.setString(8,checkNull(sordDetMap.get("lot_sl").toString()));
pstmt.setString(9,checkNull(sordDetMap.get("loc_code").toString()));
updateCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Postord Updated the no of records are : updateCnt :"+updateCnt);
}
sqlSord = "UPDATE SORDITEM SET QTY_ALLOC = QTY_ALLOC - ? "
+"WHERE SALE_ORDER = ? "
+"AND LINE_NO = ? "
+"AND EXP_LEV = ? ";
System.out.println("Postord Update sql sqlSord :"+sqlSord);
pstmt = conn.prepareStatement(sqlSord);
pstmt.setDouble(1,qtyStduom);
pstmt.setString(2,checkNull(sordDetMap.get("sord_no").toString()));
pstmt.setString(3,checkNull(sordDetMap.get("line_no__sord").toString()));
pstmt.setString(4,checkNull(sordDetMap.get("exp_lev").toString()));
updateCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Postord Updated the no of records : updateCnt :"+updateCnt);
}
} }
//Pavan R 10apr19 end
} }
} }
xmlBuff.append("</Header0>"); xmlBuff.append("</Header0>");
......
...@@ -77,7 +77,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -77,7 +77,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
HashMap<String, String> invAcctMap = null; HashMap<String, String> invAcctMap = null;
ArrayList<HashMap<String, String>> invAcctList = new ArrayList<HashMap<String,String>>(); ArrayList<HashMap<String, String>> invAcctList = new ArrayList<HashMap<String,String>>();
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
double totRecoAmt = 0; double totRecoAmt = 0, roundAdj = 0;
try try
{ {
//Added by wasim on 07-JUN-2017 to get GS_MODE from Xtra Params //Added by wasim on 07-JUN-2017 to get GS_MODE from Xtra Params
...@@ -132,84 +132,87 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -132,84 +132,87 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
} }
} }
//Modified by Anjali R. on [29/01/2019][To Update tran_date as todays date in case of ledg_post_conf is "Y"][End] //Modified by Anjali R. on [29/01/2019][To Update tran_date as todays date in case of ledg_post_conf is "Y"][End]
sql="select cust_code,item_ser,net_amt from invoice where invoice_id=?"; sql="select cust_code,item_ser,net_amt, round_adj from invoice where invoice_id=?";
pstmt2= conn.prepareStatement(sql); pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1,invoiceId ); pstmt2.setString(1,invoiceId );
rs2=pstmt2.executeQuery(); rs2=pstmt2.executeQuery();
while(rs2.next()) //while(rs2.next())
if(rs2.next())
{ {
custCode=rs2.getString("cust_code"); custCode=rs2.getString("cust_code");
itemSer=rs2.getString("item_ser"); itemSer=rs2.getString("item_ser");
netamt=rs2.getDouble("net_amt"); netamt=rs2.getDouble("net_amt");
roundAdj=rs2.getDouble("round_adj");
} }
rs2.close();//added by Pavan R 10oct18[to handle open cursor issue] rs2.close();//added by Pavan R 10oct18[to handle open cursor issue]
rs2 = null; pstmt2.close(); pstmt2 = null; rs2 = null; pstmt2.close(); pstmt2 = null;
(roundAdj == 0)
sql="select round, case when round_to is null then 0.001 else round_to end as round_to " +
" from customer where cust_code = ?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1,custCode ) ;
rs2=pstmt2.executeQuery();
if(rs2.next())
{ {
round =rs2.getString("round"); sql="select round, case when round_to is null then 0.001 else round_to end as round_to " +
roundTo =rs2.getDouble("round_to"); " from customer where cust_code = ?";
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
if(round ==null || round.trim().length()==0)
{
sql="select round_inv_to from itemser where item_ser = ?" ;
pstmt2= conn.prepareStatement(sql); pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1,itemSer); pstmt2.setString(1,custCode ) ;
rs2=pstmt2.executeQuery(); rs2=pstmt2.executeQuery();
if(rs2.next()) if(rs2.next())
{ {
roundInvTo =rs2.getString("round_inv_to"); round =rs2.getString("round");
roundTo =rs2.getDouble("round_to");
} }
rs2.close(); rs2.close();
rs2 = null; rs2 = null;
pstmt2.close(); pstmt2.close();
pstmt2 = null; pstmt2 = null;
if(roundInvTo ==null) if(round ==null || round.trim().length()==0)
{ {
retString = "VTRND"; sql="select round_inv_to from itemser where item_ser = ?" ;
return retString; pstmt2= conn.prepareStatement(sql);
pstmt2.setString(1,itemSer);
rs2=pstmt2.executeQuery();
if(rs2.next())
{
roundInvTo =rs2.getString("round_inv_to");
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
if(roundInvTo ==null)
{
retString = "VTRND";
return retString;
}else
{
//netamt= round(netamt,roundTo);
netamtr= Math.round(netamt);
sql="Update invoice set net_amt=?,round_adj=? where invoice_id=?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setDouble(1,netamtr);
pstmt2.setDouble(2,netamtr-netamt);
pstmt2.setString(3,invoiceId);
int count=pstmt2.executeUpdate();
pstmt2.close();//added by Pavan R 10oct18[to handle open cursor issue]
pstmt2 = null;
System.out.println("count++++"+count);
//xmlBuff.append("<round_adj><![CDATA["+(netamt-netAmt)+"]]></round_adj>");
//xmlBuff.append("<net_amt><![CDATA["+netamt+"]]></net_amt>");
}
}else }else
{ {
//netamt= round(netamt,roundTo); netamtr=distCommon.getRndamt(netamt,round,roundTo);
netamtr= Math.round(netamt); sql="Update invoice set net_amt=?,round_adj=? where invoice_id=?";
sql="Update invoice set net_amt=?,round_adj=? where invoice_id=?"; pstmt2= conn.prepareStatement(sql);
pstmt2= conn.prepareStatement(sql); pstmt2.setDouble(1,netamtr);
pstmt2.setDouble(1,netamtr); pstmt2.setDouble(2,netamtr-netamt);
pstmt2.setDouble(2,netamtr-netamt); pstmt2.setString(3,invoiceId);
pstmt2.setString(3,invoiceId); int count=pstmt2.executeUpdate();
int count=pstmt2.executeUpdate(); pstmt2.close();//added by Pavan R 10oct18[to handle open cursor issue]
pstmt2.close();//added by Pavan R 10oct18[to handle open cursor issue] pstmt2 = null;
pstmt2 = null; System.out.println("count1++++"+count);
System.out.println("count++++"+count); //xmlBuff.append("<round_adj><![CDATA["+(netamt-netamtr)+"]]></round_adj>");
//xmlBuff.append("<round_adj><![CDATA["+(netamt-netAmt)+"]]></round_adj>");
//xmlBuff.append("<net_amt><![CDATA["+netamt+"]]></net_amt>"); //xmlBuff.append("<net_amt><![CDATA["+netamt+"]]></net_amt>");
} }
}else
{
netamtr=distCommon.getRndamt(netamt,round,roundTo);
sql="Update invoice set net_amt=?,round_adj=? where invoice_id=?";
pstmt2= conn.prepareStatement(sql);
pstmt2.setDouble(1,netamtr);
pstmt2.setDouble(2,netamtr-netamt);
pstmt2.setString(3,invoiceId);
int count=pstmt2.executeUpdate();
pstmt2.close();//added by Pavan R 10oct18[to handle open cursor issue]
pstmt2 = null;
System.out.println("count1++++"+count);
//xmlBuff.append("<round_adj><![CDATA["+(netamt-netamtr)+"]]></round_adj>");
//xmlBuff.append("<net_amt><![CDATA["+netamt+"]]></net_amt>");
} }
///End of round code ///End of round code
/** /**
...@@ -931,7 +934,8 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -931,7 +934,8 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
pstmt2.setString(1,invoiceId ); pstmt2.setString(1,invoiceId );
rs2=pstmt2.executeQuery(); rs2=pstmt2.executeQuery();
while(rs2.next()) //while(rs2.next())
if(rs2.next())
{ {
ln_amount_radj=(rs2.getDouble("round_adj")); ln_amount_radj=(rs2.getDouble("round_adj"));
System.out.println("ln_amount_radj+++++++"+ln_amount_radj); System.out.println("ln_amount_radj+++++++"+ln_amount_radj);
......
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