Cost Center reports has been modified

This commit is contained in:
gandhimathi 2017-08-21 18:27:48 +05:30
parent efe79aed89
commit baa5dd17bd
2 changed files with 23 additions and 21 deletions

View File

@ -331,50 +331,52 @@ group by Dept_Name";
function report_ccr(){ function report_ccr(){
$sql="SELECT Cost_Mast.CostCenterCode as Cost_Center_Code, CostCenterName as Cost_Center_Name,Dept_Details.DepartmentName as Dept_Name,Cost_Center_Budget.BudgetType,Cost_Center_Budget.BudgetYear, $sql="SELECT Cost_Center_Budget.CostCenterCode as Cost_Center_Code, CostCenterName as Cost_Center_Name,Dept_Details.DepartmentName as Dept_Name,Cost_Center_Budget.BudgetType as BudgetType,Cost_Center_Budget.BudgetYear as BudgetYear,
case Cost_Center_Budget.BudgetType case Cost_Center_Budget.BudgetType
when 'IMPORT' when 'IMPORT'
then (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)) then ifnull((sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)),0)
when 'CAPITAL' when 'CAPITAL'
then then
case po.CapitalRange case po.CapitalRange
when '0' when '0'
then (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)) then ifnull((sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)),0)
else (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate)) else ifnull((sum(PO_Line_Item.Quantity * PO_Line_Item.Rate)),0)
end end
when 'SERVICE' when 'SERVICE'
then (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate)) then ifnull((sum(PO_Line_Item.Quantity * PO_Line_Item.Rate)),0)
when 'REVENUE' when 'REVENUE'
then (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate) - (T_Rev_Tax.AfterDiscount)) then ifnull((sum(PO_Line_Item.Quantity * PO_Line_Item.Rate) - sum(T_Rev_Tax.AfterDiscount)),0)
end end
as Util_Amount, as Util_Amount,
case Cost_Center_Budget.BudgetType case Cost_Center_Budget.BudgetType
when 'IMPORT' when 'IMPORT'
then (Cost_Center_Budget.BudgetAmount - (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate))) then ifnull((Cost_Center_Budget.BudgetAmount - (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate))),0)
when 'CAPITAL' when 'CAPITAL'
then then
case po.CapitalRange case po.CapitalRange
when '0' when '0'
then (Cost_Center_Budget.BudgetAmount - (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate))) then ifnull((Cost_Center_Budget.BudgetAmount - (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate))),0)
else (Cost_Center_Budget.BudgetAmount - (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate))) else ifnull((Cost_Center_Budget.BudgetAmount - (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate))),0)
end end
when 'SERVICE' when 'SERVICE'
then (Cost_Center_Budget.BudgetAmount - (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate))) then ifnull((Cost_Center_Budget.BudgetAmount - (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate))),0)
when 'REVENUE' when 'REVENUE'
then (Cost_Center_Budget.BudgetAmount - (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate) - (T_Rev_Tax.AfterDiscount))) then ifnull((Cost_Center_Budget.BudgetAmount - (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate) - sum(T_Rev_Tax.AfterDiscount))),0)
end end
as Avlbl_Amt as Avlbl_Amt
from T_CostCenter_Master Cost_Mast from T_CostCenter_Budget Cost_Center_Budget
left join T_PurchaseOrder_LineItem PO_Line_Item on Cost_Center_Budget.CostCenterCode=PO_Line_Item.CostCenterCode
left JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.Status !='ST030'
left JOIN T_Revenue_Tax T_Rev_Tax on PO_Line_Item.LineItemNo=T_Rev_Tax.LineItemNo
JOIN T_CostCenter_Master Cost_Mast on Cost_Center_Budget.CostCenterCode=Cost_Mast.CostCenterCode
JOIN T_CostCenter_Departments CostCentDept on CostCentDept.CostCenterCode=Cost_Mast.CostCenterCode JOIN T_CostCenter_Departments CostCentDept on CostCentDept.CostCenterCode=Cost_Mast.CostCenterCode
JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode= CostCentDept.DEPCode JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode= CostCentDept.DEPCode
JOIN T_PurchaseOrder_LineItem PO_Line_Item on PO_Line_Item.CostCenterCode=Cost_Mast.CostCenterCode WHERE DATE(Cost_Center_Budget.CreatedDate) BETWEEN '2017-04-01' AND '2018-03-31'
JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO
JOIN T_Revenue_Tax T_Rev_Tax on PO_Line_Item.LineItemNo=T_Rev_Tax.LineItemNo
JOIN T_CostCenter_Budget Cost_Center_Budget on Cost_Center_Budget.CostCenterCode=Cost_Mast.CostCenterCode
WHERE DATE(po.CreatedDate) BETWEEN '2017-04-01' AND '2018-03-31'
group by group by
Cost_Mast.CostCenterCode,Cost_Center_Budget.BudgetType Cost_Center_Budget.CostCenterCode,Cost_Center_Budget.BudgetType
order by Cost_Mast.CostCenterCode"; order by Cost_Center_Budget.CostCenterCode";
$query = $this->db->query($sql); $query = $this->db->query($sql);
return $query->result(); return $query->result();
@ -415,7 +417,7 @@ group by po.SupplierID,pl.MaterialCode";
$sql="select $sql="select
DATE_FORMAT(IF(matv.CreatedDate = '0000-00-00', NOW(), matv.CreatedDate), '%b-%Y') AS Month, DATE_FORMAT(IF(matv.CreatedDate = '0000-00-00', NOW(), matv.CreatedDate), '%b-%Y') AS Month,
matv.MaterialCode,mat.MaterialName,mat.UOM,AVG(matv.Rate) as Average_Rate matv.MaterialCode,mat.MaterialName,mat.UOM,ROUND(AVG(matv.Rate),2) as Average_Rate
from T_MaterialItem_PO matv from T_MaterialItem_PO matv
join T_MaterialMaster mat on matv.MaterialCode=mat.MaterialCode join T_MaterialMaster mat on matv.MaterialCode=mat.MaterialCode
group by monthname(matv.CreatedDate),matv.MaterialCode"; group by monthname(matv.CreatedDate),matv.MaterialCode";

View File

@ -67,7 +67,7 @@ if(!empty($mmr))
<td><span><?php echo $rel->MaterialCode?></span></td> <td><span><?php echo $rel->MaterialCode?></span></td>
<td><span><?php echo $rel->MaterialName?></span></td> <td><span><?php echo $rel->MaterialName?></span></td>
<td><span><?php echo $rel->UOM?></span></td> <td><span><?php echo $rel->UOM?></span></td>
<td><span><?php echo $rel->Average_Rate?></span></td> <td align="right"><span><?php echo $rel->Average_Rate?></span></td>