Commit adadc4b5 authored by caluka's avatar caluka

Closing stock calculation rectify and rund invoice net amount


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@100293 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4b24676a
...@@ -50,7 +50,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -50,7 +50,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon(); ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon();
java.sql.Timestamp prdFrmDateTstmp =null; java.sql.Timestamp prdFrmDateTstmp =null;
java.sql.Timestamp prdtoDateTstmp =null; java.sql.Timestamp prdtoDateTstmp =null;
static java.sql.Timestamp prdtoDateTmstmp =null; static java.sql.Timestamp prdtoDateTmstmp =null,prdFromoDateTmstmp=null;
static String custCodeStatic=""; static String custCodeStatic="";
static String countryCode=""; static String countryCode="";
static int graceTransitDays=0; static int graceTransitDays=0;
...@@ -2775,8 +2775,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2775,8 +2775,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
rs1 = null; rs1 = null;
pstmt1.close(); pstmt1.close();
pstmt1 = null; pstmt1 = null;
System.out.println("netAmt*********>>"+netAmt); System.out.println("netAmt*********>>"+netAmt);
netAmtStr = Double.toString(netAmt); /*netAmtStr = Double.toString(netAmt);
String[] arrStr =netAmtStr.split("\\."); String[] arrStr =netAmtStr.split("\\.");
decimalNumber = Integer.parseInt(arrStr[1]); decimalNumber = Integer.parseInt(arrStr[1]);
System.out.println("decimalNumber>>>"+decimalNumber); System.out.println("decimalNumber>>>"+decimalNumber);
...@@ -2785,12 +2786,28 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -2785,12 +2786,28 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
netAmtFinal=getRequiredDecimal(netAmt,2); netAmtFinal=getRequiredDecimal(netAmt,2);
} }
else else
{
netAmtFinal=arrStr[0];
}*/
netAmtFinal=getRequiredDecimal(netAmt,2);
netAmtStr = netAmtFinal+"";
String[] arrStr =netAmtStr.split("\\.");
decimalNumber = Integer.parseInt(arrStr[1]);
System.out.println("decimalNumber edit mode>>>"+decimalNumber);
/*if(decimalNumber>0)
{
netAmtFinal=getRequiredDecimal(netAmt,2);
}
else
{
netAmtFinal=arrStr[0];
}*/
if(decimalNumber==0)
{ {
netAmtFinal=arrStr[0]; netAmtFinal=arrStr[0];
} }
System.out.println("netValue>>>edit mode>>"+netAmtFinal); System.out.println("netValue>>>edit mode>>"+netAmtFinal);
valueXmlString.append("<Detail2 dbID='' domID='"+invCnt+"' objName=\"cust_stock_gwt\" objContext=\"2\">"); valueXmlString.append("<Detail2 dbID='' domID='"+invCnt+"' objName=\"cust_stock_gwt\" objContext=\"2\">");
valueXmlString.append("<attribute pkNames=\"\" selected=\"Y\" updateFlag=\"E\" status=\"O\" />"); valueXmlString.append("<attribute pkNames=\"\" selected=\"Y\" updateFlag=\"E\" status=\"O\" />");
valueXmlString.append("<tran_id>").append("<![CDATA["+tranIdNew+"]]>").append("</tran_id>"); valueXmlString.append("<tran_id>").append("<![CDATA["+tranIdNew+"]]>").append("</tran_id>");
...@@ -3386,6 +3403,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -3386,6 +3403,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("cmInvoiceList>>>>>>"+cmInvoiceList); System.out.println("cmInvoiceList>>>>>>"+cmInvoiceList);
prdtoDateTmstmp=toDateTstmp; prdtoDateTmstmp=toDateTstmp;
prdFromoDateTmstmp=frmDateTstmp;
/*-------------------------END------------------------------------------------------------------*/ /*-------------------------END------------------------------------------------------------------*/
...@@ -4051,7 +4069,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -4051,7 +4069,7 @@ 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("<sret_vale>").append("<![CDATA["+getRequiredDecimal(Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString()),3)+"]]>").append("</sret_vale>");
valueXmlString.append("<pur_value>").append("<![CDATA["+(long)Math.round(Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString()))+"]]>").append("</pur_value>"); valueXmlString.append("<pur_value>").append("<![CDATA["+(long)Math.round(Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString()))+"]]>").append("</pur_value>");
openingValue=(long)Math.round(Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString()))*(Double.parseDouble(itemMap.get("oldRate@"+itemDomId).toString())); openingValue=(long)Math.round((Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString()))*(Double.parseDouble(itemMap.get("oldRate@"+itemDomId).toString())));
salesValueCal=openingValue+Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString())+Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString())-Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString()); salesValueCal=openingValue+Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString())+Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString())-Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString());
valueXmlString.append("<op_value>").append("<![CDATA["+getRequiredDecimal(openingValue, 2)+"]]>").append("</op_value>"); valueXmlString.append("<op_value>").append("<![CDATA["+getRequiredDecimal(openingValue, 2)+"]]>").append("</op_value>");
valueXmlString.append("<sales_value>").append("<![CDATA["+ getRequiredDecimal(salesValueCal,2)+"]]>").append("</sales_value>"); valueXmlString.append("<sales_value>").append("<![CDATA["+ getRequiredDecimal(salesValueCal,2)+"]]>").append("</sales_value>");
...@@ -4075,7 +4093,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -4075,7 +4093,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
System.out.println("repl value>>>>>>"+Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString())); 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("free value>>>>>>"+Double.parseDouble(itemMap.get("freeValue@"+itemDomId).toString()));
System.out.println("sret value>>>>>>"+Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString())); System.out.println("sret value>>>>>>"+Double.parseDouble(itemMap.get("sretValue@"+itemDomId).toString()));
grosSalesValueCal=Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString())*Double.parseDouble(itemMap.get("oldRateOrg@"+itemDomId).toString()) grosSalesValueCal=(long)Math.round(Double.parseDouble(itemMap.get("mopStk@"+itemDomId).toString())*Double.parseDouble(itemMap.get("oldRateOrg@"+itemDomId).toString()))
+Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString()) +Double.parseDouble(itemMap.get("rcpValue@"+itemDomId).toString())
+Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString()) +Double.parseDouble(itemMap.get("replValue@"+itemDomId).toString())
+Double.parseDouble(itemMap.get("freeValue@"+itemDomId).toString()) +Double.parseDouble(itemMap.get("freeValue@"+itemDomId).toString())
...@@ -4137,6 +4155,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -4137,6 +4155,9 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
secondarySales = Double.parseDouble(genericUtility.getColumnValue("sales",dom)); secondarySales = Double.parseDouble(genericUtility.getColumnValue("sales",dom));
System.out.println("SECONDARYsales :"+secondarySales); System.out.println("SECONDARYsales :"+secondarySales);
String itemSer1 = genericUtility.getColumnValue("item_ser",dom);
rateOld = Double.parseDouble(genericUtility.getColumnValue("rate_old",dom)); rateOld = Double.parseDouble(genericUtility.getColumnValue("rate_old",dom));
rateOrgOld = Double.parseDouble(genericUtility.getColumnValue("rate_org_old",dom)); rateOrgOld = Double.parseDouble(genericUtility.getColumnValue("rate_org_old",dom));
rcpValue = Double.parseDouble(genericUtility.getColumnValue("rcp_value",dom)); rcpValue = Double.parseDouble(genericUtility.getColumnValue("rcp_value",dom));
...@@ -4209,17 +4230,44 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -4209,17 +4230,44 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
//Start Added by chandrashekar on 08-dec-2015 //Start Added by chandrashekar on 08-dec-2015
double qtyValue=0.0; double qtyValue=0.0;
if(cmQuantity1>clStock) /*if(cmQuantity1>clStock)
{ {
//formulaValue=0; //formulaValue=0;
formulaValue=clStock; formulaValue=clStock;
}else }else
{ {
formulaValue=clStock-cmQuantity1; formulaValue=clStock-cmQuantity1;
} }*/
formulaValue=clStock;
System.out.println("formulaValue@@@@@@>>>"+formulaValue);
//System.out.println("countryCode>>>>>"+countryCode);
//System.out.println("itemSerHd>>>>>"+itemSer1);
//thirdMonthDay= utlmethd.AddMonths(prdtoDateTmstmp, -3);
thirdMonthDay= utlmethd.AddMonths(prdFromoDateTmstmp, -3);
System.out.println("thirdMonthDay>>>>>>"+thirdMonthDay);
thirdMonthDay= utlmethd.AddMonths(prdtoDateTmstmp, -3); /* sql = "select b.FR_DATE as FR_DATE,b.TO_DATE as TO_DATE " +
sql = "SELECT fr_date FROM period_tbl WHERE ? between fr_date and to_date"; " from period_appl a,period_tbl b " +
"where a.ref_code=a.prd_tblno and a.prd_tblno=b.prd_tblno " +
"and b.prd_tblno=? " +
"AND case when a.type is null then 'X' else a.type end='S' and " +
"? between b.FR_DATE and b.TO_DATE ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, countryCode+"_"+itemSer1.trim());
pstmt.setTimestamp(2, thirdMonthDay);
rs = pstmt.executeQuery();
if(rs.next())
{
thirdMonthFrDt = rs.getTimestamp("FR_DATE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;*/
/*sql = "SELECT fr_date FROM period_tbl WHERE ? between fr_date and to_date";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,thirdMonthDay); pstmt.setTimestamp(1,thirdMonthDay);
rs = pstmt.executeQuery( ); rs = pstmt.executeQuery( );
...@@ -4230,14 +4278,16 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -4230,14 +4278,16 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;*/
sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,itrc.quantity__stduom as ,itrc.quantity__stduom,inv.tran_date " + sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,itrc.quantity__stduom as ,itrc.quantity__stduom,inv.tran_date " +
"FROM invoice_trace itrc,invoice inv WHERE itrc.item_code=? " + "FROM invoice_trace itrc,invoice inv WHERE itrc.item_code=? " +
"and itrc.invoice_id=inv.invoice_id and inv.tran_date>=? " + "and itrc.invoice_id=inv.invoice_id and inv.tran_date>=? " +
"and inv.tran_date<=? AND itrc.rate__stduom >0 ORDER BY inv.tran_date DESC"; "and inv.tran_date<=? AND itrc.rate__stduom >0 ORDER BY inv.tran_date DESC";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode1); pstmt.setString(1,itemCode1);
pstmt.setTimestamp(2,thirdMonthFrDt); //pstmt.setTimestamp(2,thirdMonthFrDt);
pstmt.setTimestamp(2,thirdMonthDay);
pstmt.setTimestamp(3,prdtoDateTmstmp); pstmt.setTimestamp(3,prdtoDateTmstmp);
rs = pstmt.executeQuery( ); rs = pstmt.executeQuery( );
while( rs.next() ) while( rs.next() )
...@@ -4319,7 +4369,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -4319,7 +4369,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
closingValue=closingRate*clStock; closingValue=closingRate*clStock;
System.out.println("closingValue>>>>>>>"+closingValue);*/ System.out.println("closingValue>>>>>>>"+closingValue);*/
//grossClosingValue=grossClosingRate*clStock; //grossClosingValue=grossClosingRate*clStock;
netSecondarySalesValue=(opStkDom*rateOld)+rcpValue+replValue-retValue-closingValue; netSecondarySalesValue=Math.round(opStkDom*rateOld)+rcpValue+replValue-retValue-closingValue;
System.out.println("netSecondarySalesValue>>>>>>>"+netSecondarySalesValue); System.out.println("netSecondarySalesValue>>>>>>>"+netSecondarySalesValue);
/*secondaryQty=opStkDom+rcpQtmDom+rcpReplQtmDom-retQtyDom-clStock; /*secondaryQty=opStkDom+rcpQtmDom+rcpReplQtmDom-retQtyDom-clStock;
...@@ -4327,7 +4377,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal, ...@@ -4327,7 +4377,7 @@ public class CustStockGWTIC extends ValidatorEJB implements CustStockGWTICLocal,
netSecondaryRate=netSecondarySalesValue/secondaryQty; netSecondaryRate=netSecondarySalesValue/secondaryQty;
System.out.println("netSecondaryRate>>>"+netSecondaryRate);*/ System.out.println("netSecondaryRate>>>"+netSecondaryRate);*/
grossSecondarySalesValue=(opStkDom*rateOrgOld)+rcpValue+replValue+rcpFreeValue-retValue-closingValue; grossSecondarySalesValue=Math.round(opStkDom*rateOrgOld)+rcpValue+replValue+rcpFreeValue-retValue-closingValue;
System.out.println("rcpFreeValue>>>>"+rcpFreeValue); System.out.println("rcpFreeValue>>>>"+rcpFreeValue);
System.out.println("grossSecondarySalesValue>>>>"+grossSecondarySalesValue); System.out.println("grossSecondarySalesValue>>>>"+grossSecondarySalesValue);
System.out.println("grossSecondaryQty>>>>"+grossSecondaryQty); System.out.println("grossSecondaryQty>>>>"+grossSecondaryQty);
......
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