Commit 115e33fd authored by pgole's avatar pgole

Updated EJB FOR CUST STOCK changes for proper sale order generation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104049 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3f54ed1b
......@@ -244,17 +244,24 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
prevScheme= "" ,itemStru = "" , sqlNew = "" , mitCode = "",mitFlg = "" ,sqlin = "" ,sqlinner = "" , mslabOn = "",packCode = "",plistDisc = "",
mpriceList= "",listType = "",mstanCode = "",typeTaxclass = "",mstanCodeSite = "",mtaxClass = "",mtaxChap = "",mtaxEnv = "",itemserProm = "" ,
mgenTrans = "",morderDtDtr = "",msetLine = "" ,oldInvoiceItemSer = "" , InvoiceItemSer= "" ,locType = "" , itemSerDesc = "",lineNoo = "",
remarks = "" ,termId = "" ,crTerm = "" ,cctrcodeSal = "" , xmlString = "",tempSplitCode = "",splitCode = "";
remarks = "" ,termId = "" ,SplitCodeNew = "" ,crTerm = "" ,cctrcodeSal = "" , xmlString = "",tempSplitCode = "",splitCode = "",splitCodeIn="";
String[] acctcodeSal= null;
HashMap tempMap = null;
HashMap custStockSoGen = null;
HashMap NewCustStockMap = new HashMap();
HashMap custStockSoGenNew = new HashMap();
HashMap NewCustStockNewMap = new HashMap();
HashMap NewCustStockSoGen = new HashMap();
ArrayList custStockSoGenList = new ArrayList();
ArrayList custStockSoGenListNew = new ArrayList();
ArrayList NewCustStockSoGenList = new ArrayList();
ArrayList NewCustStockMapList = new ArrayList();
//ArrayList NewCustStockSoGenList = new ArrayList();
ArrayList tempList = null;
ArrayList temp1List = new ArrayList();
Timestamp morderDt = null ;
......@@ -655,6 +662,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
rsDet = pstmtDet.executeQuery();
while(rsDet.next())
{
mitemCd = checkNull(rsDet.getString("item_code"));
mlocType = checkNull(rsDet.getString("loc_type"));
lineNo = rsDet.getString("line_no");
......@@ -667,6 +675,24 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
custStockSoGen = new HashMap();
SplitCodeNew = invoiceItemSer + "@" + mlocType.trim();
System.out.println("SplitCodeNew First >>>"+SplitCodeNew);
System.out.println("custStockSoGenList before["+custStockSoGenList+"]\n");
System.out.println("NewCustStockMap before "+NewCustStockMap+"]\n");
if (NewCustStockMap.containsKey(SplitCodeNew))
{
custStockSoGenList = (ArrayList) NewCustStockMap.get(SplitCodeNew);
System.out.println("@@@@@ NewCustStockMap in if....."+tempList);
} else
{
custStockSoGenList = new ArrayList();
System.out.println("@@@@@ NewCustStockMap in else....."+tempList);
}
System.out.println("custStockSoGenList After["+custStockSoGenList+"]\n");
mvarValue = "";
if("P".equalsIgnoreCase(asType))
{
......@@ -943,6 +969,12 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
System.out.println("lsOrderType "+lsOrderType);
if(mlocType != null && invoiceItemSer != null)
{
SplitCodeNew = invoiceItemSer.trim() + "@" + mlocType.trim();
}
custStockSoGen.put("order_type", lsOrderType);
custStockSoGen.put("invoice_item_ser", invoiceItemSer);
custStockSoGen.put("loc_type", mlocType);
......@@ -1348,6 +1380,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
sql = "select count(item_code) from bomdet where bom_code = ? and item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mitCode);
pstmt.setString(2, mitemCd);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -1579,202 +1612,234 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
}
custStockSoGenList.add(custStockSoGen);
System.out.println("custStockSoGenList.size() inside"+custStockSoGenList.size());
System.out.println("SplitCodeNew >>>"+SplitCodeNew);
System.out.println("Inside templist size");
if (NewCustStockMap.containsKey(SplitCodeNew))
{
NewCustStockMap.put(SplitCodeNew, custStockSoGenList);
} else
{
NewCustStockMap.put(SplitCodeNew, custStockSoGenList);
}
System.out.println("NewCustStockMap nEW["+ NewCustStockMap.size()+"]");
}
rsDet.close();rsDet = null;
pstmtDet.close();pstmtDet = null;
System.out.println("custStockSoGenList outside loop"+custStockSoGenList.size());
System.out.println("NewCustStockMap["+NewCustStockMap.toString()+"]");
System.out.println("custStockSoGenListNew["+NewCustStockMap.size()+"]");
System.out.println("custStockSoGenList before remove row"+custStockSoGenList.toString());
//for(int m = 0 ;m < custStockSoGenList.size(); m++ )
for(int m = custStockSoGenList.size()-1 ; m >= 0 ; m-- )
{
System.out.println("Inside for loop ["+custStockSoGenList.size() + "] M ["+ m + "]");
custStockSoGen = new HashMap();
custStockSoGen = (HashMap) custStockSoGenList.get(m);
mclStock = (Double) custStockSoGen.get("cl_stock");
integralQty = (Double) custStockSoGen.get("integral_qty");
System.out.println("Inside mclStock["+mclStock +"]");
System.out.println("Inside integralQty["+integralQty + "]" );
if("P".equalsIgnoreCase(asType))
{
if(mclStock < 0 )
{
custStockSoGenList.remove(m);
}
}
else
{
if(mclStock <= integralQty/2)
{
custStockSoGenList.remove(m);
}
}
System.out.println("custStockSoGenList size after remove row"+custStockSoGenList.size());
System.out.println("custStockSoGenList after remove row"+custStockSoGenList.toString());
}
System.out.println("custStockSoGenList.size() IN 222222"+custStockSoGenList.size());
if(!"P".equalsIgnoreCase(asType))
{
System.out.println("Inside ***********"+custStockSoGenList.size());
if(custStockSoGenList.size() > 0)
if(NewCustStockMap.size() > 0)
{
System.out.println("Inside #######"+custStockSoGenList.size());
for(k = 1 ; k< schdtList.size() ; k++)
for(k = 1 ; k< schdtList.size(); k++)
{
System.out.println("Inside^^^^^^^^"+custStockSoGenList.size()+"K:"+k);
for(int p = 0 ;p < custStockSoGenList.size() ; p++)
Iterator it = NewCustStockMap.entrySet().iterator();
while(it.hasNext())
{
System.out.println("INSIDE IF FOR FOR P LOOP");
custStockSoGen = new HashMap();
custStockSoGen = (HashMap) custStockSoGenList.get(p);
NewCustStockSoGenList = new ArrayList();
Map.Entry pairs = (Map.Entry)it.next();
splitCodeIn = (String) pairs.getKey();
System.out.println("splitCode>>>["+splitCodeIn +"]");
int itemIndex = splitCodeIn.indexOf('@');
NewCustStockSoGen = custStockSoGen;
System.out.println("temp1List before["+temp1List+"]\n");
mitemCd = (String) custStockSoGen.get("item_code");
minOrderQty = gfGetMinOrderQty(custCode,msiteCd,mitemCd ,conn);
if(minOrderQty > 0)
temp1List = (ArrayList) NewCustStockMap.get(splitCodeIn);
System.out.println("temp1List from key>>>>[" + temp1List.size() + "]"+"["+temp1List+"]");
for(int p = 0 ;p < temp1List.size() ; p++)
{
demandQty = (Double) custStockSoGen.get("demand_qty");
clStockOrg = (Double) custStockSoGen.get("cl_stock__org");
NewCustStockSoGen = new HashMap();
System.out.println("INSIDE IF FOR FOR P LOOP");
custStockSoGen = new HashMap();
custStockSoGen = (HashMap) temp1List.get(p);
System.out.println("demandQty:::["+demandQty+"]clStockOrg:::["+clStockOrg+"]");
//NewCustStockSoGen = custStockSoGen;
mitemCd = (String) custStockSoGen.get("item_code");
String mitemSr = (String) custStockSoGen.get("item_ser");
String mLocType = (String) custStockSoGen.get("loc_type");
if(demandQty < minOrderQty)
{
continue;
}
}
integralQty= (Double) custStockSoGen.get("integral_qty");
mclStock= (Double) custStockSoGen.get("cl_stock");
System.out.println("integralQty:::["+integralQty+"] mclStock:::["+mclStock+"]schpercList.get(k)["+schpercList.get(k)+"]");
if( mclStock > integralQty)
{
mclStock = mclStock * schpercList.get(k) / 100 ;
minOrderQty = gfGetMinOrderQty(custCode,msiteCd,mitemCd ,conn);
System.out.println("mclStock:::::::["+mclStock+"]");
if (integralQty > 0)
if(minOrderQty > 0)
{
sql = "Select mod(?,?) from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, mclStock);
pstmt.setDouble(2, integralQty);
rs = pstmt.executeQuery();
if(rs.next())
demandQty = (Double) custStockSoGen.get("demand_qty");
clStockOrg = (Double) custStockSoGen.get("cl_stock__org");
System.out.println("demandQty:::["+demandQty+"]clStockOrg:::["+clStockOrg+"]");
if(demandQty < minOrderQty)
{
mmodqty = rs.getDouble(1);
continue;
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("mmodqty:::["+mmodqty+"]");
}
integralQty= (Double) custStockSoGen.get("integral_qty");
mclStock= (Double) custStockSoGen.get("cl_stock");
System.out.println("integralQty:::["+integralQty+"] mclStock:::["+mclStock+"]schpercList.get(k)["+schpercList.get(k)+"]");
if( mclStock > integralQty)
{
mclStock = mclStock * schpercList.get(k) / 100 ;
if(mmodqty > 0)
System.out.println("mclStock:::::::["+mclStock+"]");
if (integralQty > 0)
{
mitFlg = (String) custStockSoGen.get("item_flag");
sql = "Select mod(?,?) from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, mclStock);
pstmt.setDouble(2, integralQty);
rs = pstmt.executeQuery();
if(rs.next())
{
mmodqty = rs.getDouble(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("mitFlg:::["+mitFlg+"]");
System.out.println("mmodqty:::["+mmodqty+"]");
if("I".equalsIgnoreCase(mitFlg))
if(mmodqty > 0)
{
qtyPerc = gfGetQtyPerc(custCode,msiteCd,mitemCd,conn);
lcQty = integralQty * (qtyPerc/100);
mitFlg = (String) custStockSoGen.get("item_flag");
sql = "Select mod(?,?) from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, mclStock);
pstmt.setDouble(2, integralQty);
rs = pstmt.executeQuery();
if(rs.next())
{
mmodqty = rs.getDouble(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("mitFlg:::["+mitFlg+"]");
System.out.println("mmodqty:::["+mmodqty+"]lcQty:::["+lcQty+"]");
if(mmodqty < lcQty)
if("I".equalsIgnoreCase(mitFlg))
{
perc = (mclStock/integralQty) ;
qtyPerc = gfGetQtyPerc(custCode,msiteCd,mitemCd,conn);
lcQty = integralQty * (qtyPerc/100);
sql = "Select mod(?,?) from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, mclStock);
pstmt.setDouble(2, integralQty);
rs = pstmt.executeQuery();
if(rs.next())
{
mmodqty = rs.getDouble(1);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("mmodqty:::["+mmodqty+"]lcQty:::["+lcQty+"]");
if(mmodqty < lcQty)
{
perc = (mclStock/integralQty) ;
}
else
{
perc = (mclStock/integralQty) + 1;
}
}
else
{
perc = (mclStock/integralQty) + 1;
perc = (mclStock/integralQty) ;
}
}
else
{
perc = (mclStock/integralQty) ;
}
mclStock = (perc * integralQty) ;
System.out.println("mclStock["+mclStock+"] integralQty["+integralQty+"] perc["+perc+"] perc * integralQty["+perc * integralQty+"]");
}
else
{
perc = (mclStock/integralQty) ;
}
mclStock = (perc * integralQty) ;
System.out.println("mclStock["+mclStock+"] integralQty["+integralQty+"] perc["+perc+"] perc * integralQty["+perc * integralQty+"]");
lcOrderStock = (Double) custStockSoGen.get("order_stock");
custStockSoGen.put("order_stock", lcOrderStock + mclStock);
System.out.println("lcOrderStock["+lcOrderStock+"] lcOrderStock + mclStock["+lcOrderStock + mclStock+"]");
System.out.println("mclStock["+mclStock+"]");
}
lcOrderStock = (Double) custStockSoGen.get("order_stock");
NewCustStockSoGen.put("order_stock", lcOrderStock + mclStock);
System.out.println("lcOrderStock["+lcOrderStock+"] lcOrderStock + mclStock["+lcOrderStock + mclStock+"]");
System.out.println("mclStock["+mclStock+"]");
NewCustStockSoGenList.add(NewCustStockSoGen);
}
NewCustStockSoGenList.add(custStockSoGen);
NewCustStockNewMap.put(splitCodeIn, NewCustStockSoGenList) ;
}
}
}
if(NewCustStockSoGenList == null || NewCustStockSoGenList.size() == 0)
if(NewCustStockNewMap == null || NewCustStockNewMap.size() == 0)
{
for(int p = 0 ;p < custStockSoGenList.size() ; p++)
System.out.println("IN 2ND LOOP....");
Iterator it = NewCustStockMap.entrySet().iterator();
while(it.hasNext())
{
System.out.println("INSIDE IF FOR second P LOOP");
custStockSoGen = new HashMap();
custStockSoGen = (HashMap) custStockSoGenList.get(p);
NewCustStockSoGen = custStockSoGen;
NewCustStockSoGenList.add(NewCustStockSoGen);
NewCustStockSoGenList = new ArrayList();
Map.Entry pairs = (Map.Entry)it.next();
splitCodeIn = (String) pairs.getKey();
System.out.println("splitCode>>>["+splitCodeIn +"]");
int itemIndex = splitCodeIn.indexOf('@');
System.out.println("temp1List before 2bd loop["+temp1List+"]\n");
temp1List = (ArrayList) NewCustStockMap.get(splitCodeIn);
System.out.println("temp1List from key else>>>>[" + temp1List.size() + "]"+"["+temp1List+"]");
System.out.println("NewCustStockSoGenList new list ["+NewCustStockSoGenList.toString()+"]");
for(int p = 0 ;p < temp1List.size() ; p++)
{
NewCustStockSoGen = new HashMap();
System.out.println("INSIDE IF FOR FOR P LOOP");
custStockSoGen = new HashMap();
custStockSoGen = (HashMap) temp1List.get(p);
NewCustStockSoGenList.add(custStockSoGen);
NewCustStockNewMap.put(splitCodeIn, NewCustStockSoGenList) ;
}
}
}
}
}
System.out.println("NewCustStockSoGenList ["+NewCustStockSoGenList.size()+"]");
//System.out.println("NewCustStockSoGenList ["+NewCustStockSoGenList.toString()+"]");
}
}
System.out.println("NewCustStockSoGenList ["+NewCustStockSoGenList.size()+"]\n["+NewCustStockSoGenList.toString()+"]");
System.out.println("NewCustStockNewMap ["+NewCustStockNewMap.size()+"]\n["+NewCustStockNewMap.toString()+"]");
System.out.println("NewCustStockSoGenList size ["+NewCustStockSoGenList.size()+"]");
System.out.println("NewCustStockSoGenList ["+NewCustStockNewMap.size()+"]\n["+NewCustStockNewMap.toString()+"]");
if(NewCustStockSoGenList.size() > 0)
if(NewCustStockNewMap.size() > 0)
{
schpercTmp = (Double) schpercList.get(0) ;
for(k = 0 ; k < schdtList.size() ; k++)
{
HashMap splitCodeWiseMap = new HashMap();
//tempList = new ArrayList();
System.out.println("INSIDE NewCust K LOOP"+ k);
int q = 0 ;
for( q = 0 ;q < NewCustStockSoGenList.size() ; q++)
Iterator it = NewCustStockNewMap.entrySet().iterator();
while(it.hasNext())
{
Map.Entry pairs = (Map.Entry)it.next();
splitCodeIn = (String) pairs.getKey();
//temp1List = (ArrayList) pairs.getValue();
//System.out.println("temp1List from value>>>["+temp1List +"]");
System.out.println("splitCode>>>["+splitCodeIn +"]");
int itemIndex = splitCodeIn.indexOf('@');
itemSer = splitCodeIn.substring(0, itemIndex);
String locTypeParent = splitCodeIn.substring(itemIndex + 1, splitCodeIn.length());
System.out.println(">>>>>>>>>locTypeParent===" + locTypeParent);
temp1List = (ArrayList) NewCustStockNewMap.get(splitCodeIn);
System.out.println("temp1List from key in 2nd loop>>>>[" + temp1List.size() + "]"+"["+temp1List+"]");
for(int q = 0 ;q < temp1List.size() ; q++)
{
System.out.println("INSIDE NewCust Q LOOP"+ q);
custStockSoGen = new HashMap();
custStockSoGen = (HashMap) NewCustStockSoGenList.get(q);
custStockSoGen = (HashMap) temp1List.get(q);
schdtList = tschdtList ;
schpercList = tschpercList ;
......@@ -2155,14 +2220,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
mclStock = perc * integralQty ;
System.out.println("mclStock mmodqty>>["+mclStock +"]perc["+perc+"]integralQty["+integralQty+"]");
}
/*else
{
if(integralQty != 0)
{
perc = (mclStock / integralQty);
}
}*/
//mclStock = perc * integralQty ;
System.out.println("perc11>>>>>"+perc);
System.out.println("integralQty111>>>>>"+integralQty);
System.out.println("mclStock1>>>>>"+mclStock);
......@@ -2195,12 +2253,11 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
continue;
}
System.out.println("mclStock*****>>>>>"+mclStock);
System.out.println("@@@@@ :Inside else.....");
System.out.println("@@@@@ :Inside locType.trim().....["+locType.trim()+"]itemserProm["+itemserProm+"]");
tempSplitCode = itemserProm + "@" + locType.trim();
tempSplitCode = itemserProm.trim() + "@" + locType.trim();
//splitCodeWiseMap = new HashMap();
......@@ -2215,7 +2272,6 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
} else
{
tempList = new ArrayList();
//tempList.add(custStockSoGen);
System.out.println("@@@@@ tempList in else....."+tempList);
}
......@@ -2224,10 +2280,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
System.out.println("LINE NO PLAN["+lineNo+"][LINE NO SET["+msetLine +"]");
//lineNo = getLineNewNo(lineNo);
System.out.println("lineNo["+lineNo+"]");
System.out.println("lineNo["+lineNo+"]");
tempMap.put("item_code", mitemCd);
tempMap.put("item_ser", itemserProm);
tempMap.put("loc_type", locType);
......@@ -2257,7 +2310,6 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
tempMap.put("tax_chap", mtaxChap);
tempMap.put("tax_class", mtaxClass);
tempMap.put("tax_env", mtaxEnv);
//tempMap.put("tax_amt", mtaxAmt);
tempMap.put("net_amt", mnetAmt);
tempMap.put("ord_amt", mordAmt);
tempMap.put("dsp_date", schdtList.get(k));
......@@ -2270,15 +2322,12 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
System.out.println("Print tempMap{"+ tempMap +"}schdtList.get(k)["+schdtList.get(k)+"]");
System.out.println("sales parson = " + tempMap.size() );
tempList.add(tempMap);
System.out.println("Print Templist["+ tempList + "]");
System.out.println(" Templist["+ tempList.size() + "]");
System.out.println(" splitCodeWiseMap ["+ splitCodeWiseMap + "]");
//for(int r = 0 ; r < tempList.size();r++ )
//{
System.out.println("Inside templist size");
if (splitCodeWiseMap.containsKey(tempSplitCode))
{
......@@ -2287,32 +2336,26 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
{
splitCodeWiseMap.put(tempSplitCode, tempList);
}
//}
System.out.println("Print splitCodeWiseMap"+ splitCodeWiseMap);
System.out.println("Print splitCodeWiseMap>>["+ splitCodeWiseMap.size()+"]");
//}
}
System.out.println("INSIDE splitCodeWiseMap...."+splitCodeWiseMap.toString());
System.out.println("Outside splitCodeWiseMap...."+splitCodeWiseMap.size());
Set setItem = splitCodeWiseMap.entrySet();
System.out.println("setItemsetItem>>"+setItem.size());
System.out.println("setItemsetItem >>"+setItem);
tempList = null;
Iterator itrItem = setItem.iterator();
int cnt2 = 0 ;
System.out.println("tempList before while >>>["+tempList +"] "+itrItem.toString());
}
System.out.println("INSIDE splitCodeWiseMap...."+splitCodeWiseMap.toString());
System.out.println("Outside splitCodeWiseMap...."+splitCodeWiseMap.size());
Set setItem = splitCodeWiseMap.entrySet();
System.out.println("setItemsetItem>>"+setItem.size());
System.out.println("setItemsetItem >>"+setItem);
tempList = null;
Iterator itrItem = setItem.iterator();
int cnt2 = 0 ;
System.out.println("tempList before while >>>["+tempList +"] "+itrItem.toString());
int w = 0 ;
String ordType = "";
while (itrItem.hasNext())
{
if(tempList != null && tempList.size() > 0)
{
System.out.println("tempList111>>>>[" + tempList.size() + "]"+"["+tempList+"]");
}
int w = 0 ;
String ordType = "";
while (itrItem.hasNext())
{
System.out.println("COUNT OF WHILE FOR " + w );
mtotOrdAmt = 0 ;
......@@ -2328,11 +2371,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
int itemIndex = splitCode.indexOf('@');
itemSer = splitCode.substring(0, itemIndex);
//int custIndex = splitCode.indexOf('@');
//String custCd = splitCode.substring(itemIndex + 1, custIndex);
// modify by cpatil on 14-06-12 for splitting start
//int crIndex = splitCode.indexOf('.');
//crTerm = splitCode.substring(custIndex + 1, crIndex);
String locTypeParent = splitCode.substring(itemIndex + 1, splitCode.length());
System.out.println(">>>>>>>>>locTypeParent===" + locTypeParent);
......@@ -2347,9 +2386,7 @@ public class CustStockOrder extends ActionHandlerEJB implements CustStockOrderLo
System.out.println("@@@@@@@ [ splitCode[" + splitCode + "]");
System.out.println("itemSer[" + itemSer + "]");
//System.out.println("custCd[" + custCd + "]");
System.out.println("crTerm[" + crTerm + "]"+mcrterm);
// System.out.println("locTypeParent[" + locTypeParent + "] ] @@@@@@@@");
tempList = (ArrayList) splitCodeWiseMap.get(splitCode);
......
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