From baa5dd17bd5b9a6c68ff05f0e64c146c91dd51d8 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 21 Aug 2017 18:27:48 +0530 Subject: [PATCH] Cost Center reports has been modified --- application/models/dahsboard_model.php | 42 ++++++++++--------- .../Report_Material_Master_ReceiptValue.php | 2 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 4f39ad39..071f660a 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -331,50 +331,52 @@ group by Dept_Name"; 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 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' then case po.CapitalRange when '0' - then (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)) - else (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate)) + then ifnull((sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)),0) + else ifnull((sum(PO_Line_Item.Quantity * PO_Line_Item.Rate)),0) end 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' -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 + as Util_Amount, case Cost_Center_Budget.BudgetType 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' then case po.CapitalRange when '0' - then (Cost_Center_Budget.BudgetAmount - (sum((PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate))) - else (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) * po.ExchangeRate))),0) + else ifnull((Cost_Center_Budget.BudgetAmount - (sum(PO_Line_Item.Quantity * PO_Line_Item.Rate))),0) end 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' -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 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_DepartmentDetails Dept_Details on Dept_Details.DEPCode= CostCentDept.DEPCode -JOIN T_PurchaseOrder_LineItem PO_Line_Item on PO_Line_Item.CostCenterCode=Cost_Mast.CostCenterCode -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' +WHERE DATE(Cost_Center_Budget.CreatedDate) BETWEEN '2017-04-01' AND '2018-03-31' group by -Cost_Mast.CostCenterCode,Cost_Center_Budget.BudgetType -order by Cost_Mast.CostCenterCode"; +Cost_Center_Budget.CostCenterCode,Cost_Center_Budget.BudgetType +order by Cost_Center_Budget.CostCenterCode"; $query = $this->db->query($sql); return $query->result(); @@ -415,7 +417,7 @@ group by po.SupplierID,pl.MaterialCode"; $sql="select 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 join T_MaterialMaster mat on matv.MaterialCode=mat.MaterialCode group by monthname(matv.CreatedDate),matv.MaterialCode"; diff --git a/application/views/Report_Material_Master_ReceiptValue.php b/application/views/Report_Material_Master_ReceiptValue.php index ef3ee191..f203b1f4 100644 --- a/application/views/Report_Material_Master_ReceiptValue.php +++ b/application/views/Report_Material_Master_ReceiptValue.php @@ -67,7 +67,7 @@ if(!empty($mmr)) MaterialCode?> MaterialName?> UOM?> - Average_Rate?> + Average_Rate?>