Commit 0e8f1c27 authored by prane's avatar prane

gimatex issue in stock rate

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@204055 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1e17ea6f
...@@ -967,10 +967,161 @@ public class StockUpdate ...@@ -967,10 +967,161 @@ public class StockUpdate
this.grossRate = totalGrossValue / (oldQty + Math.abs(this.qtyStduom)); this.grossRate = totalGrossValue / (oldQty + Math.abs(this.qtyStduom));
} }
} }
//Pavan Rane 25Jul19 Start [Migrated code from pb DI78GIM001]
else if (stkOpt.equalsIgnoreCase("2") && count > 0 )
{
sql = "Select (Case when (sum(Case When quantity IS NULL Then 0 Else quantity End)) is null Then 0 else (sum(Case When quantity IS NULL Then 0 Else quantity End)) end),"
+" (case when (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) is null Then 0 else (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) end),"
+" (case when sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) is null then 0 else sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) end )"
+" from stock,location,invstat"
+" where stock.loc_code =location.loc_code"
+" and location.inv_stat = invstat.inv_stat"
+" and invstat.stat_type <> 'S'"
+" and stock.item_code = '"+this.itemCode+"'"
+" and stock.site_code ='"+this.siteCode+"'"
+" and stock.grade = '"+this.grade+"'"
+" and stock.lot_no = '"+this.lotNo+"' ";
}//end of tranType =R System.out.println("Query Fired :::- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
oldQty=rs.getDouble(1);
oldvalue = rs.getDouble(2);
oldGrossValue =rs.getDouble(3);
}
pstmt.close(); pstmt = null;
rs.close(); rs= null;
System.out.println("oldQty::["+oldQty+"]::oldvalue::["+oldvalue+"]::oldGrossValue::["+oldGrossValue+"]");
newValue = Math.abs(this.qtyStduom) * this.rate;
newGrossValue = Math.abs(this.qtyStduom) * this.grossRate;
totalValue = oldvalue + newValue;
totalGrossValue = oldGrossValue + newGrossValue ;
if((oldQty + Math.abs(this.qtyStduom)) != 0)
{
this.rate = (totalValue)/(oldQty+Math.abs(this.qtyStduom));
this.grossRate = totalGrossValue / (oldQty + Math.abs(qtyStduom));
}
System.out.println("rate::["+this.rate+"]:::gross rate::["+this.grossRate+"]");
}
//}//end of tranType =R
}
else
{
if (stkOpt.equalsIgnoreCase("1") || stockValuation.equalsIgnoreCase("M"))
{
sql = "Select (Case when (sum(Case When quantity IS NULL Then 0 Else quantity End)) is null Then 0 else (sum(Case When quantity IS NULL Then 0 Else quantity End)) end),"
+" (case when (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) is null Then 0 else (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) end),"
+" (case when sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) is null then 0 else sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) end )"
+" from stock,location,invstat"
+" where stock.loc_code =location.loc_code"
+" and location.inv_stat = invstat.inv_stat"
+" and invstat.stat_type <> 'S' "
+" and stock.item_code = '"+this.itemCode+"'"
+" and stock.site_code = '"+this.siteCode+"'"
+" and stock.grade = '"+this.grade+"'" ;
System.out.println("Query Fired :::- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
oldQty=rs.getDouble(1);
oldvalue = rs.getDouble(2);
oldGrossValue =rs.getDouble(3);
}
System.out.println("oldQty::["+oldQty+"]::oldvalue::["+oldvalue+"]::oldGrossValue::["+oldGrossValue+"]");
rs.close(); rs = null;
pstmt.close(); pstmt =null;
newValue = Math.abs(this.qtyStduom) * this.rate;
newGrossValue = Math.abs(this.qtyStduom) * this.grossRate;
totalValue = oldvalue + newValue;
totalGrossValue = oldGrossValue + newGrossValue ;
if((oldQty + Math.abs(this.qtyStduom)) != 0)
{
this.rate = (totalValue)/(oldQty+Math.abs(this.qtyStduom));
this.grossRate = totalGrossValue / (oldQty + Math.abs(qtyStduom));
}
System.out.println("rate::["+this.rate+"]:::gross rate::["+this.grossRate+"]");
}
else if(stockValuation.equalsIgnoreCase("C"))
{
sql = "Select (Case when (sum(Case When quantity IS NULL Then 0 Else quantity End)) is null Then 0 else (sum(Case When quantity IS NULL Then 0 Else quantity End)) end),"
+" (case when (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) is null Then 0 else (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) end),"
+" (case when sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) is null then 0 else sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) end )"
+" from stock,location,invstat"
+" where stock.loc_code = location.loc_code"
+" and location.inv_stat = invstat.inv_stat"
+" and invstat.stat_type <> 'S' "
+" and stock.item_code = '"+this.itemCode+"'"
+" and stock.site_code = '"+this.siteCode+"'"
+" and stock.grade = '"+this.grade+"'"
+" And stock.cctr_code__inv = '"+this.cctrCodeInv+"'";
System.out.println("Query :::- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
oldQty=rs.getDouble(1);
oldvalue = rs.getDouble(2);
oldGrossValue =rs.getDouble(3);
}
pstmt.close();
rs.close();
System.out.println("oldQty::["+oldQty+"]::oldvalue::["+oldvalue+"]::oldGrossValue::["+oldGrossValue+"]");
newValue = Math.abs(this.qtyStduom) * this.rate;
newGrossValue = Math.abs(this.qtyStduom) * this.grossRate;
totalValue = oldvalue + newValue;
totalGrossValue = oldGrossValue + newGrossValue ;
if((oldQty + Math.abs(this.qtyStduom))!= 0)
{
this.rate = totalValue / (oldQty + Math.abs(this.qtyStduom));
this.grossRate = totalGrossValue / (oldQty + Math.abs(this.qtyStduom));
}
}
else if (stkOpt.equalsIgnoreCase("2") && count > 0 )
{
sql = "Select (Case when (sum(Case When quantity IS NULL Then 0 Else quantity End)) is null Then 0 else (sum(Case When quantity IS NULL Then 0 Else quantity End)) end),"
+" (case when (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) is null Then 0 else (sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When rate IS NULL Then 0 Else rate End ))) end),"
+" (case when sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) is null then 0 else sum((Case When quantity IS NULL Then 0 Else quantity End ) * (Case When gross_rate IS NULL Then 0 Else gross_rate End )) end )"
+" from stock,location,invstat"
+" where stock.loc_code =location.loc_code"
+" and location.inv_stat = invstat.inv_stat"
+" and invstat.stat_type <> 'S' "
+" and stock.item_code = '"+this.itemCode+"'"
+" and stock.site_code = '"+this.siteCode+"'"
+" and stock.grade = '"+this.grade+"'"
+" and stock.lot_no = '"+this.lotNo+"' ";
System.out.println("Query Fired :::- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
oldQty=rs.getDouble(1);
oldvalue = rs.getDouble(2);
oldGrossValue =rs.getDouble(3);
}
pstmt.close(); pstmt = null;
rs.close(); rs= null;
System.out.println("oldQty::["+oldQty+"]::oldvalue::["+oldvalue+"]::oldGrossValue::["+oldGrossValue+"]");
newValue = Math.abs(this.qtyStduom) * this.rate;
newGrossValue = Math.abs(this.qtyStduom) * this.grossRate;
totalValue = oldvalue + newValue;
totalGrossValue = oldGrossValue + newGrossValue ;
if((oldQty + Math.abs(this.qtyStduom)) != 0)
{
this.rate = (totalValue)/(oldQty+Math.abs(this.qtyStduom));
this.grossRate = totalGrossValue / (oldQty + Math.abs(qtyStduom));
}
System.out.println("rate::["+this.rate+"]:::gross rate::["+this.grossRate+"]");
}
}
//Pavan Rane 25Jul19 end
if(this.tranType.equalsIgnoreCase("I")){ if(this.tranType.equalsIgnoreCase("I")){
mstkQty = (mstkQty - meffQty); mstkQty = (mstkQty - meffQty);
if (count > 0) if (count > 0)
...@@ -1911,6 +2062,22 @@ public class StockUpdate ...@@ -1911,6 +2062,22 @@ public class StockUpdate
pstmt.close();pstmt=null; pstmt.close();pstmt=null;
} }
//Changed by wasim on 16-03-2015 to close Prepared Statement/Result Set [END] //Changed by wasim on 16-03-2015 to close Prepared Statement/Result Set [END]
}else if (stkOpt.equalsIgnoreCase("2"))
{
sql = " update stock set rate = (case when '"+this.rate+"' is null then 0 else '"+this.rate+"' end) ,"
+" gross_rate = (case when '"+this.grossRate+"' is null then 0 else '"+this.grossRate+"' end) "
+" where item_code ='"+this.itemCode+"'"
+" and site_code ='"+this.siteCode+"'"
+" and grade = '"+this.grade+"'"
+" And lot_no = '"+this.lotNo+"'";
System.out.println("Query :::- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
//Changed by wasim on 16-03-2015 to close Prepared Statement/Result Set [START]
if(pstmt!=null)
{
pstmt.close();pstmt=null;
}
} }
} }
sql = "select count(*) from stockvalue " sql = "select count(*) from stockvalue "
......
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