Commit 3cdaa903 authored by caluka's avatar caluka

CAL_CRIT_ITEMSER disparam match with salesperson itemseries for opening value


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101012 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a00a8fd3
......@@ -57,8 +57,12 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
static java.sql.Timestamp prdtoDateTmstmp =null,prdFromoDateTmstmp=null;
static String custCodeStatic="";
static String countryCode="";
static String selectedInvList ="";
static String itemSerHeaderSplit="";
static String orderTypeHeader="";
static int graceTransitDays=0;
boolean isItemSer = false;
UtilMethods utlmethd=new UtilMethods();
public String wfValData() throws RemoteException,ITMException
{
return "";
......@@ -112,7 +116,6 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
......@@ -195,6 +198,15 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName :"+childNodeName);
if (childNodeName.equalsIgnoreCase("edit_status"))
{
editSatus = this.genericUtility.getColumnValue("edit_status", dom);
if("V".equalsIgnoreCase(editSatus))
{
System.out.println("validation stop");
break;
}
}
if (childNodeName.equalsIgnoreCase("cust_code"))
{
custCode = this.genericUtility.getColumnValue("cust_code", dom);
......@@ -827,76 +839,81 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength Detail2:::::::::"+parentNodeListLength);
stmtDateStr = this.genericUtility.getColumnValue("stmt_date",dom2);
editSatus = this.genericUtility.getColumnValue("edit_status", dom2);
System.out.println("editSatus>>>>>case 2>>>"+editSatus);
if(!"V".equalsIgnoreCase(editSatus))
{
Timestamp stmtDate = Timestamp.valueOf(genericUtility.getValidDateString(stmtDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
transitGraceDaysStr = dist.getDisparams("999999","GRACE_DAYS_TRINV",conn);
transitGraceDaysStr = dist.getDisparams("999999", "GRACE_DAYS_TRINV", conn);
System.out.println("transitGraceDays.." + transitGraceDaysStr);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode1 = parentNodeList.item(selectedRow);
childNodeList = parentNode1.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength::: " + childNodeListLength + "\n");
isInvList = true;
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode1 = childNodeList.item(childRow);
childNodeName = childNode1.getNodeName();
System.out.println("childNodeName :" + childNodeName);
if (childNodeName.equals("invoice_id"))
parentNode1 = parentNodeList.item(selectedRow);
childNodeList = parentNode1.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength::: " + childNodeListLength + "\n");
isInvList = true;
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
if (childNode1.getFirstChild() != null)
{
invoiceId = childNode1.getFirstChild().getNodeValue();
}
System.out.println("invoiceId :" + invoiceId);
if (isInvList == false && !errInvList.contains(invoiceId))
childNode1 = childNodeList.item(childRow);
childNodeName = childNode1.getNodeName();
System.out.println("childNodeName :" + childNodeName);
if (childNodeName.equals("invoice_id"))
{
System.out.println("Add invoiceId>>>>>>>" + invoiceId);
errInvList.add(invoiceId.trim());
if (childNode1.getFirstChild() != null)
{
invoiceId = childNode1.getFirstChild().getNodeValue();
}
System.out.println("invoiceId :" + invoiceId);
if (isInvList == false && !errInvList.contains(invoiceId))
{
System.out.println("Add invoiceId>>>>>>>" + invoiceId);
errInvList.add(invoiceId.trim());
}
}
}
if (childNodeName.equals("dlv_flg"))
{
if (childNode1.getFirstChild() != null)
if (childNodeName.equals("dlv_flg"))
{
dlvFlg = childNode1.getFirstChild().getNodeValue();
}
System.out.println("dlvFlg :" + dlvFlg);
if (childNode1.getFirstChild() != null)
{
dlvFlg = childNode1.getFirstChild().getNodeValue();
}
System.out.println("dlvFlg :" + dlvFlg);
}
if (childNodeName.equals("invoice_date"))
{
if (childNode1.getFirstChild() != null)
{
invoiceDateStr = childNode1.getFirstChild().getNodeValue();
}
System.out.println("invoiceDateStr :" + invoiceDateStr);
if(invoiceDateStr !=null && invoiceDateStr.trim().length()>0)
if (childNodeName.equals("invoice_date"))
{
validUptoDate = Timestamp.valueOf(genericUtility.getValidDateString(invoiceDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if (("NULLFOUND".equalsIgnoreCase(transitGraceDaysStr) || transitGraceDaysStr == null || transitGraceDaysStr.trim().length() == 0) && "N".equalsIgnoreCase(dlvFlg))
if (childNode1.getFirstChild() != null)
{
errCode = "VTGRCDAYS";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
} else if ("N".equalsIgnoreCase(dlvFlg))
invoiceDateStr = childNode1.getFirstChild().getNodeValue();
}
System.out.println("invoiceDateStr :" + invoiceDateStr);
if (invoiceDateStr != null && invoiceDateStr.trim().length() > 0)
{
transitGraceDays = Integer.parseInt(transitGraceDaysStr);
graceTransitDays = Integer.parseInt(transitGraceDaysStr);
regDateNew = utilMethod.RelativeDate(stmtDate, -transitGraceDays);
if (validUptoDate.before(regDateNew))
validUptoDate = Timestamp.valueOf(genericUtility.getValidDateString(invoiceDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if (("NULLFOUND".equalsIgnoreCase(transitGraceDaysStr) || transitGraceDaysStr == null || transitGraceDaysStr.trim().length() == 0) && "N".equalsIgnoreCase(dlvFlg))
{
errCode = "VTINVOCDT";
errCode = "VTGRCDAYS";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
isInvList = false;
} else if ("N".equalsIgnoreCase(dlvFlg))
{
transitGraceDays = Integer.parseInt(transitGraceDaysStr);
graceTransitDays = Integer.parseInt(transitGraceDaysStr);
regDateNew = utilMethod.RelativeDate(stmtDate, -transitGraceDays);
if (validUptoDate.before(regDateNew))
{
errCode = "VTINVOCDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
isInvList = false;
}
}
}
}
}
}
}
......@@ -906,7 +923,6 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
parentNodeList = dom2.getElementsByTagName("Detail3");
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength Detail3:::::::::"+parentNodeListLength);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode1 = parentNodeList.item(selectedRow);
......@@ -1322,7 +1338,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
String descr = "", locTypeItem = "",tranIdLastHd="",tranDateHd="",tranIdNew="",tranCode="",tranName="",lrNo="",stockMode="";
String itemCodeLast ="" , unitLast = "",descrLast="",custName="",itemSerName="",spCode ="",itemSerLast="";
String sretSiteCode = "",sretLocCode = "",sretLotNo="",sretLotSl="",retRepFlag="",selQuery="",invStat="",periodDt="",tranDateStr="";
String selectedInvList ="",transitInvList="";
//String selectedInvList ="",transitInvList="";
String transitInvList="";
String invoiceIdDom="";
String locality_code="",locTypeLast="";
String childNodeName = "",lineNoStrDom="",lineNoStr="",stockDlvFlg="",dlvFlagStock="";
......@@ -1337,6 +1354,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
String confirmed="",status="",errString="",empCode="",positionCode="",empName="";
String positionDescr="",resultItemSer="",opStock="";
String reStr="",invoiceMonths="";
String calCriItemSerStr="",salesItemSer="";
double opStockLast=0.0,sales=0.0,transitQty=0.0,salesLast=0.0,receiptLast=0.0,clStockLast=0.0,returnLast=0.0,rateLast=0.0,salesQty=0.0,clStock=0.0;
double netAmt=0.0,opStkItem=0.0,retQty = 0.0,rcpQty=0.0,rate=0.0,adjQty=0.0,adhocQty=0.0,totRcpQtyAll=0.0;
double sretQty = 0.0,replQty=0.0,rcpQtyBon=0.0,primarySales=0.0,transitQtyAll=0.0;
......@@ -1366,6 +1384,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
double quantityStd=0.0,rateStd=0.0,salesOrg=0.0;
double opValue=0.0,salesValue=0.0,clValue=0.0,openingValue=0.0,salesValueCal=0.0;
double grossSecondaryRateCal=0.0,grosSalesValueCal=0.0,opStockQty=0.0;
double calRate=0.0;
double grossOpeningValue=0.0;
int netValue=0,decimalNumber=0;
int lineNoCustSt=0,currentFormNo = 0,varValue=0,domID3=0,sreturnCnt=0;
int lineNoItmCnt=0,itemResLen=0,itemPos=0,itmDetCnt=0,domID2=0;
......@@ -1429,7 +1449,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDate = sdf2.format(currentDate.getTime());
dbSysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
UtilMethods utlmethd=new UtilMethods();
//UtilMethods utlmethd=new UtilMethods();
columnValue = genericUtility.getColumnValue(currentColumn, dom);
if(objContext != null && objContext.trim().length() > 0)
currentFormNo = Integer.parseInt(objContext);
......@@ -1462,7 +1482,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
pstmt1.close();
pstmt1 = null;
System.out.println("countryCode@@@@@>>>"+countryCode);
// Added By Chandrashekar - Suggested by Prajyot - Start
String sqlFirstDefData = " SELECT CS.POS_CODE,CS.EMP_CODE,CS.CUST_CODE CUST_CODE, C.CUST_NAME CUST_NAME, C.CUST_TYPE CUST_TYPE, C.ORDER_TYPE ORDER_TYPE, CS.SITE_CODE SITE_CODE," +
" CS.FROM_DATE FROM_DATE, CS.TO_DATE TO_DATE, CS.ITEM_SER ITEM_SER, CS.STMT_DATE STMT_DATE, CS.PRD_CODE PRD_CODE,CS.TRAN_DATE TRAN_DATE,CS.TRAN_ID__LAST TRAN_ID__LAST,C.STAN_CODE STAN_CODE " +
......@@ -3314,7 +3334,6 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("transitInvList :"+transitInvList);
/*------------------------------------------------------*/
......@@ -3343,8 +3362,38 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("fromdate (case 3) :"+fromdate);
todate = genericUtility.getColumnValue("to_date",dom1);
System.out.println("todate (case 3):"+todate);
loginEmpCode = genericUtility.getColumnValue("emp_code",dom1);
System.out.println("loginEmpCode (case 3):"+loginEmpCode);
//Start added by chandrashekar on 29-mar-2016
calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn);
System.out.println("calCriItemSerStr.." + calCriItemSerStr);
if (("NULLFOUND".equalsIgnoreCase(calCriItemSerStr) || calCriItemSerStr == null || calCriItemSerStr.trim().length() == 0) )
{
isItemSer=false;
}else
{
sql= "select item_ser from sales_pers where sales_pers=?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, loginEmpCode );
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
salesItemSer=checkNull(rs1.getString("item_ser")).trim();
System.out.println("salesItemSer >>> :"+salesItemSer);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if(calCriItemSerStr.trim().equalsIgnoreCase(salesItemSer.trim()))
{
isItemSer=true;
}
}
System.out.println("isItemSer@@@@@@@>>>>"+isItemSer);
//End added by chandrashekar on 29-mar-2016
editFlag = (editFlag != null) ? editFlag : genericUtility.getColumnValue("edit_status", dom1);
System.out.println("editFlag case 3>>>>"+editFlag);
......@@ -3450,6 +3499,8 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
currentTranId=tranIdNew;
itemSerHd=getItemSerList(itemSerHd,conn);
itemSerHeaderSplit=itemSerHd;
orderTypeHeader=orderType;
System.out.println("Retrive Item Details data from previous month or current month which is exist in CUST_STOK_DET !!!!!!!!!!!!!");
/*sql= "select item_code,unit,op_stock ,sales,purc_rcp,cl_stock,purc_ret,rate,line_no,transit_qty,item_ser ,purc_rcp__repl ,purc_rcp__free,purc_ret__repl,purc_ret__free,transit_qty__repl,transit_qty__free ,loc_type " +
" from cust_stock_det where tran_id=? ";*/
......@@ -4024,6 +4075,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
isPreviusItem=isExistItem(itemMap.get("itemCode@"+itemDomId),tranIdLast,conn);
openingValue=0;
calRate=0.0;
valueXmlString.append( "<Detail3 dbID='' domID='"+itmDetCnt+"' objContext='"+currentFormNo+"' selected='Y'>\r\n" );
/* if(tranIdLast.trim().length() == 0 && tranIdNew.trim().length() > 0 )
......@@ -4099,9 +4151,18 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
valueXmlString.append("<sret_vale>").append("<![CDATA["+getRequiredDecimal(Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString()),3)+"]]>").append("</sret_vale>");
valueXmlString.append("<pur_value>").append("<![CDATA["+getRequiredDecimal(Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString()),3)+"]]>").append("</pur_value>");
//valueXmlString.append("<pur_value>").append("<![CDATA["+(long)Math.round(Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString()))+"]]>").append("</pur_value>");
openingValue=getRequiredDcml((Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString()))*(Double.parseDouble(itemMap.get("oldRate@"+itemDomId).toString())),3);
System.out.println("net secondary salesopeningValue>>>>>>"+openingValue);
System.out.println("isItemSer>>>>>>>"+isItemSer);
if(isItemSer)
{
calRate=getOpeningRate(orderTypeHeader,itemSerHeaderSplit,selectedInvList,(Double.parseDouble(itemMap.get("mquantRcp@"+itemDomId).toString())),itemMap.get("itemCode@"+itemDomId),prdtoDateTmstmp,prdFromoDateTmstmp,custCodeStatic,conn);
System.out.println("isItemSer calRate"+calRate);
openingValue=getRequiredDcml((Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString()))*(calRate),3);
System.out.println("isItemSer salesopeningValue>>>>>>"+openingValue);
}else
{
openingValue=getRequiredDcml((Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString()))*(Double.parseDouble(itemMap.get("oldRate@"+itemDomId).toString())),3);
System.out.println("net secondary salesopeningValue>>>>>>"+openingValue);
}
salesValueCal=openingValue+Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString())
+ Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString())
- Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString());
......@@ -4127,7 +4188,18 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("repl value>>>>>>"+Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString()));
System.out.println("free value>>>>>>"+Double.parseDouble(itemMap.get("freeValue@"+itemDomId).toString()));
System.out.println("sret value>>>>>>"+Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString()));
grosSalesValueCal= getRequiredDcml(Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString())*Double.parseDouble(itemMap.get("oldRateOrg@"+itemDomId).toString()),3)
if(isItemSer)
{
grossOpeningValue=getRequiredDcml((Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString()))*(calRate),3);
System.out.println("CAL_CRIT_ITEMSER true grossOpeningValue>>>>>>"+grossOpeningValue);
}else
{
grossOpeningValue=getRequiredDcml(Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString())*Double.parseDouble(itemMap.get("oldRateOrg@"+itemDomId).toString()),3);
System.out.println(" CAL_CRIT_ITEMSER false grossOpeningValue>>>>>>"+grossOpeningValue);
}
//grosSalesValueCal= getRequiredDcml(Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString())*Double.parseDouble(itemMap.get("oldRateOrg@"+itemDomId).toString()),3)
grosSalesValueCal= grossOpeningValue
+Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString())
+Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString())
+Double.parseDouble(itemMap.get("freeValue@"+itemDomId).toString())
......@@ -4167,6 +4239,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
if(currentColumn.trim().equals("cl_stock"))
{
rateOld=0.0;rateOrgOld=0.0;
calRate=0.0;
System.out.println("in cl stock !!!!!!!!!!!!");
clStockInp = genericUtility.getColumnValue("cl_stock",dom);
......@@ -4336,6 +4409,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("formulaValue@@@@@@>>>"+formulaValue);
//System.out.println("countryCode>>>>>"+countryCode);
//System.out.println("itemSerHd>>>>>"+itemSer1);
System.out.println("isItemSer>>>>>"+isItemSer);
if(!isItemSer)
{
invoiceMonths = dist.getDisparams("999999","INVOICE_MONTHS",conn);
System.out.println("invoiceMonths.." + invoiceMonths);
if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0) )
......@@ -4448,6 +4524,11 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
closingValue=getRequiredDcml(closingValue,3);
}
}else
{
calRate=getOpeningRate(orderTypeHeader,itemSerHeaderSplit,selectedInvList,rcpQtmDom,itemCode1,prdtoDateTmstmp,prdFromoDateTmstmp,custCodeStatic,conn);
closingValue=clStock*calRate;
}
if(clStock>0)
{
closingRate=closingValue/clStock;
......@@ -4457,7 +4538,6 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
}
closingRate=getRequiredDcml(closingRate,3);
System.out.println("closingRate@@@@@@@@@"+closingRate);
grossSecondaryQty=opStkDom+rcpQtmDom+rcpReplQtmDom+rcpFreeQtmDom-retQtyDom-clStock;
System.out.println("grossSecondaryQty>>>>>>"+grossSecondaryQty);
//End Added by chandrashekar on 08-dec-2015
......@@ -4487,15 +4567,27 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
closingValue=closingRate*clStock;
System.out.println("closingValue>>>>>>>"+closingValue);*/
//grossClosingValue=grossClosingRate*clStock;
if(!isItemSer)
{
netSecondarySalesValue=(opStkDom*rateOld)+rcpValue+replValue-retValue-closingValue;
}else
{
netSecondarySalesValue=(opStkDom*calRate)+rcpValue+replValue-retValue-closingValue;
}
netSecondarySalesValue=getRequiredDcml(netSecondarySalesValue,3);
System.out.println("netSecondarySalesValue>>>>>>>"+netSecondarySalesValue);
/*secondaryQty=opStkDom+rcpQtmDom+rcpReplQtmDom-retQtyDom-clStock;
System.out.println("secondaryQty>>>>"+secondaryQty);
netSecondaryRate=netSecondarySalesValue/secondaryQty;
System.out.println("netSecondaryRate>>>"+netSecondaryRate);*/
if(!isItemSer)
{
grossSecondarySalesValue=(opStkDom*rateOrgOld)+rcpValue+replValue+rcpFreeValue-retValue-closingValue;
grossSecondarySalesValue=(opStkDom*rateOrgOld)+rcpValue+replValue+rcpFreeValue-retValue-closingValue;
}else
{
grossSecondarySalesValue=(opStkDom*calRate)+rcpValue+replValue+rcpFreeValue-retValue-closingValue;
}
grossSecondarySalesValue=getRequiredDcml(grossSecondarySalesValue,3);
System.out.println("rcpFreeValue>>>>"+rcpFreeValue);
System.out.println("grossSecondarySalesValue>>>>"+grossSecondarySalesValue);
......@@ -4553,9 +4645,13 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
{
valueXmlString.append("<sales_value>").append("<![CDATA[" + getRequiredDcml(netSecondarySalesValue,3) + "]]>").append("</sales_value>");
}
if(!Double.isNaN(opStkDom*rateOld))
if(!Double.isNaN(opStkDom*rateOld) && !isItemSer)
{
valueXmlString.append("<op_value>").append("<![CDATA[" + getRequiredDcml((opStkDom*rateOld),3) + "]]>").append("</op_value>");
}else if(!Double.isNaN(opStkDom*calRate) && isItemSer)
{
valueXmlString.append("<op_value>").append("<![CDATA[" + getRequiredDcml((opStkDom*calRate),3) + "]]>").append("</op_value>");
}
valueXmlString.append("</Detail3>\r\n");
......@@ -8679,4 +8775,108 @@ private double GetFreeQty(String custCode,String itemCode,String itemSer,String
// TODO Auto-generated method stub
return finalValue;
}
private double getOpeningRate(String orderType,String itemSerHeaderSplit,String selectedInvList ,double rcpQtyDom,String itemCode, Timestamp prdtoDateTmstmp,Timestamp prdFromoDateTmstmp, String custCode, Connection conn) throws ITMException
{
String invoiceMonths="",sql="";
String sysDatetemp="",priceList="";
int invoiceMonthsPrevious=0;
Timestamp thirdMonthDay=null;
double openingRate=0.0,rateStd=0.0;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null;
try
{
Date currentDate = new Date();
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDatetemp = sdf2.format(currentDate.getTime());
if(rcpQtyDom > 0)
{
sql = " SELECT itrace.RATE__STDUOM as RATE__STDUOM FROM" +
" invoice invoice,invoice_trace itrace " +
" where invoice.invoice_id=itrace.invoice_id AND invoice.cust_code = ? " +
" and invoice.inv_type=? and itrace.item_ser__prom in("+itemSerHeaderSplit+") "+
" AND itrace.RATE__STDUOM>0.001 "+
" and itrace.item_code = ? " +
"and itrace.invoice_id in("+selectedInvList+") ORDER BY invoice.tran_date DESC " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode );
pstmt.setString(2, orderType );
pstmt.setString(3, itemCode );
rs = pstmt.executeQuery( );
if( rs.next() )
{
openingRate = rs.getDouble("RATE__STDUOM" );
System.out.println("openingRate>>>>>> :"+openingRate);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
invoiceMonths = dist.getDisparams("999999", "INVOICE_MONTHS", conn);
System.out.println("invoiceMonths>>>>.." + invoiceMonths);
if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0))
{
invoiceMonthsPrevious = -3;
} else
{
invoiceMonthsPrevious = Integer.parseInt(invoiceMonths);
}
System.out.println("invoiceMonthsPrevious>>>>>" + invoiceMonthsPrevious);
thirdMonthDay = utlmethd.AddMonths(prdFromoDateTmstmp, invoiceMonthsPrevious);
System.out.println("thirdMonthDay from method>>>>>>" + thirdMonthDay);
sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,inv.tran_date " +
"FROM invoice_trace itrc,invoice inv WHERE itrc.item_code=? " +
"and itrc.invoice_id=inv.invoice_id and inv.tran_date>=? " +
"and inv.tran_date<=? AND itrc.rate__stduom >0.001 and inv.cust_code=? " +
" ORDER BY inv.tran_date DESC";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setTimestamp(2, thirdMonthDay);
pstmt.setTimestamp(3, prdtoDateTmstmp);
pstmt.setString(4, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
openingRate = rs.getDouble("rate__stduom");
System.out.println("openingRate>>>>>> :" + openingRate);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (openingRate == 0)
{
sql = "select price_list from customer where cust_code =? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, custCodeStatic);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
priceList = checkNull(rs1.getString("price_list"));
System.out.println("priceList edit :" + priceList);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
openingRate = discmn.pickRate(priceList, sysDatetemp, itemCode, conn);
}
}
}catch(Exception exception)
{
exception.printStackTrace();
//System.out.println("Exception ::" + exception.getMessage());
throw new ITMException( exception );
}
System.out.println("return openingRate>>>>"+openingRate);
return openingRate;
}
}
\ No newline at end of file
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