Commit fb764f05 authored by manohar's avatar manohar

wipPost new method added for workorder issue inventory accounting


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95656 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8c71892e
...@@ -23,6 +23,7 @@ import org.w3c.dom.*; ...@@ -23,6 +23,7 @@ import org.w3c.dom.*;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon; import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.mfg.MfgCommon;
public class InvAcct public class InvAcct
{ {
...@@ -2643,6 +2644,345 @@ public class InvAcct ...@@ -2643,6 +2644,345 @@ public class InvAcct
return errString; return errString;
} }
// End of Code added by mahesh // End of Code added by mahesh
public String wipPost(String tranId, String tranSer,Connection conn)throws ITMException
{
// Function to pass accounting entries for WIP
//
// 28/09/00 manoharan added coin diff. checking
FinCommon finCommon = null;
GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmtUpd = null;
ResultSet rs = null, rs1 = null;
java.sql.Timestamp tranDate = null, effDate = null;
String sql = "", errString = "", errCode = "", siteCode = "", itemSer = "", currCode = "",remarks = "", acctType = "", currCodeBase = "";
String invOnline = "",vouchOnLine = "", invAcct = "", finEntity = "",itemCode = "",tranType="",analysis="", workOrder = "";
String acctCodeInv = "", cctrCodeInv = "", locCode = "", lotNo = "", lotSl = "", stkOpt = "",acctCodeWp = "", cctrCodeWp = "";
double exchRate = 0,quantity = 0,rate = 0, amount = 0, totAmt = 0 ;
HashMap tempMap = null, glTraceMap = null;
int foundRow = 0;
ArrayList wipList = null;
try
{
finCommon = new FinCommon();
MfgCommon mfgCommon = new MfgCommon();
genericUtility = GenericUtility.getInstance();
itmDBAccessEJB = new ITMDBAccessEJB();
invOnline = finCommon.getFinparams("999999", "INV_ACCT_WISS", conn);
if ("NULLFOUND".equals(invOnline))
{
errCode = "VTFINPARM";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
if (!"Y".equals(invOnline) && !"N".equals(invOnline))
{
errCode = "VTFINPARM";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
if (!"Y".equals(invOnline))
{
return "";
}
// Selecting the Header Information and WIP A/c Code
sql = "select i.work_order, i.tran_date, i.eff_date, i.site_code, w.acct_code__wp,w.cctr_code__wp,s.fin_entity, f.curr_code "
+ " from workorder_iss i, workorder w, site s, finent f "
+ " where w.work_order = i.work_order "
+ " and s.site_code = i.site_code "
+ " and f.fin_entity = s.fin_entity "
+ " and i.tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
workOrder = rs.getString("work_order");
tranDate = rs.getTimestamp("tran_date");
effDate = rs.getTimestamp("eff_date");
siteCode = rs.getString("site_code");
acctCodeWp = rs.getString("acct_code__wp");
cctrCodeWp = rs.getString("cctr_code__wp");
finEntity = rs.getString("fin_entity");
currCode = rs.getString("curr_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// If ACCT Code is NULL/SPACE Then Exit
if (acctCodeWp == null || "null".equals(acctCodeWp) || acctCodeWp.trim().length() == 0 )
{
errCode = "VTACCTWP";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
if (cctrCodeWp == null || "null".equals(cctrCodeWp) || cctrCodeWp.trim().length() == 0 )
{
cctrCodeWp = " " ;
}
// Financial Entity for the Site
if (finEntity == null || "null".equals(finEntity) || finEntity.trim().length() == 0 )
{
errCode = "VMFINENT";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
// Currency Code for the Site
if (currCode == null || "null".equals(currCode) || currCode.trim().length() == 0 )
{
errCode = "VTCURFIN";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
sql = "select item_code, loc_code, lot_no, lot_sl, "
+ " (case when quantity is null then 0 else quantity end) + (case when potency_adj is null then 0 else potency_adj end) as quantity , rate "
+ " from workorder_issdet "
+ " where tran_id = ? and rate <> 0 ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranId);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
itemCode = rs1.getString("item_code");
locCode = rs1.getString("loc_code");
lotNo = rs1.getString("lot_no");
lotSl = rs1.getString("lot_sl");
quantity = rs1.getDouble("quantity");
rate = rs1.getDouble("rate");
/// amish 14-08-05 check the stock option if non stock the do not post
stkOpt = mfgCommon.chkStkOpt(siteCode,itemCode,conn);
if ("0".equals(stkOpt))
{
continue;
}
// end by amish 14-08-05
sql = "select acct_code__inv, cctr_code__inv"
+ " from stock "
+ " where item_code = ? "
+ " and site_code = ? "
+ " and loc_code = ? "
+ " and lot_no = ? "
+ " and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, locCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if(rs.next())
{
acctCodeInv = rs.getString("acct_code__inv");
cctrCodeInv = rs.getString("cctr_code__inv");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (acctCodeInv == null || "null".equals(acctCodeInv) || acctCodeInv.trim().length() == 0 )
{
errCode = "VTACCTINV";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
break;
}
if (cctrCodeInv == null || "null".equals(cctrCodeInv) || cctrCodeInv.trim().length() == 0 )
{
cctrCodeInv = " " ;
}
amount = quantity * rate ;
foundRow = findExistingIndex(wipList,acctCodeInv, cctrCodeInv);
if (foundRow > -1)
{
tempMap = (HashMap) wipList.get(foundRow);
totAmt = (double) Double.parseDouble( "" + tempMap.get("amount"));
tempMap.put("amount", totAmt + amount );
wipList.set(foundRow, tempMap);
}
else
{
tempMap = new HashMap();
tempMap.put("acct_code", acctCodeInv);
tempMap.put("cctr_code", cctrCodeInv);
tempMap.put("amount", amount);
wipList.add(tempMap);
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if (errString != null && errString.trim().length() > 0 )
{
return errString;
}
// Crediting Inventory Account
amount = 0;
totAmt = 0;
for(int ctr = 0 ; ctr < wipList.size() ; ctr++)
{
//RcpDetMap = new HashMap();
tempMap = (HashMap)wipList.get(ctr);
acctCodeInv = (String)tempMap.get( "acct_code");
cctrCodeInv = (String)tempMap.get("cctr_code");
amount = (double) Double.parseDouble( "" + tempMap.get("amount"));
glTraceMap = null;
glTraceMap = new HashMap();
glTraceMap.put("tran_date", tranDate);
glTraceMap.put("eff_date", effDate);
glTraceMap.put("fin_entity", finEntity);
glTraceMap.put("site_code",siteCode);
glTraceMap.put("sundry_type","O" );
glTraceMap.put("sundry_code", "");
glTraceMap.put("acct_code",acctCodeInv);
glTraceMap.put("cctr_code",cctrCodeInv);
glTraceMap.put("emp_code","");
glTraceMap.put("anal_code","");
glTraceMap.put("curr_code", currCode);
glTraceMap.put("exch_rate", exchRate);
if (amount > 0 )
{
glTraceMap.put("dr_amt",0);
glTraceMap.put("cr_amt",amount);
}
else
{
glTraceMap.put("dr_amt", -1 * amount);
glTraceMap.put("cr_amt", 0);
}
glTraceMap.put("ref_type","I");
glTraceMap.put("ref_ser",tranSer);
glTraceMap.put("ref_id", tranId);
glTraceMap.put("remarks", remarks);
errString = finCommon.glTraceUpdate(glTraceMap,conn);
if(errString != null && errString.trim().length() > 0)
{
break;
}
totAmt = totAmt + amount;
}
if (errString != null && errString.trim().length() > 0 )
{
return errString;
}
//
// Debiting WIP Account
//
glTraceMap = null;
glTraceMap = new HashMap();
glTraceMap.put("tran_date", tranDate);
glTraceMap.put("eff_date", effDate);
glTraceMap.put("fin_entity", finEntity);
glTraceMap.put("site_code",siteCode);
glTraceMap.put("sundry_type","O" );
glTraceMap.put("sundry_code", "");
glTraceMap.put("acct_code",acctCodeWp);
glTraceMap.put("cctr_code",cctrCodeWp);
glTraceMap.put("emp_code","");
glTraceMap.put("anal_code","");
glTraceMap.put("curr_code", currCode);
glTraceMap.put("exch_rate", exchRate);
if (totAmt > 0 )
{
glTraceMap.put("dr_amt",totAmt);
glTraceMap.put("cr_amt",0);
}
else
{
glTraceMap.put("dr_amt", 0);
glTraceMap.put("cr_amt", -1 * totAmt);
}
glTraceMap.put("ref_type","I");
glTraceMap.put("ref_ser",tranSer);
glTraceMap.put("ref_id", tranId);
glTraceMap.put("remarks", remarks);
errString = finCommon.glTraceUpdate(glTraceMap,conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
//--------------------
// 28/09/00 manoharan check coin diff.
errString = finCommon.checkGlTranDrCr(tranSer,tranId,conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
}//try
catch(Exception exception)
{
exception.printStackTrace();
throw new ITMException(exception);
}
finally
{
try
{
if (rs != null)
{
rs.close(); rs = null;
}
if (pstmt != null)
{
pstmt.close(); pstmt = null;
}
if (rs1 != null)
{
rs1.close(); rs1 = null;
}
if (pstmt1 != null)
{
pstmt1.close(); pstmt1 = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return (errString);
}
private int findExistingIndex(ArrayList detList, String acctCode, String cctrCode)throws RemoteException,ITMException
{
int findIndex = -1;
HashMap detMap = null;
String acctCodeMap = null, cctrCodeMap = null;
double exchRateMap = 0;
try
{
for(int ctr=0 ; ctr < detList.size() ; ctr++)
{
detMap = (HashMap) detList.get(ctr);
acctCodeMap = (String) detMap.get("acct_code");
cctrCodeMap = (String) detMap.get("cctr_code");
if (acctCodeMap.trim().equalsIgnoreCase(acctCode.trim()) && cctrCodeMap.trim().equalsIgnoreCase(cctrCode.trim()))
{
findIndex = ctr;
break;
}
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
System.out.println("Exception : "+e);
e.printStackTrace();
throw new ITMException(e);
}
return findIndex;
}
} }
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