diff --git a/application/config/routes.php b/application/config/routes.php
index a6b6874b..3afe3dcd 100755
--- a/application/config/routes.php
+++ b/application/config/routes.php
@@ -276,6 +276,7 @@ $route['cashbookyearlyexpenses']="report/yearexpenses";
$route['Empperform']="report/per";
$route['cashbookcumulativereport']="report/cashbook_cumulative_report";
$route['cashbookcumulativemonthreport']="report/cashbook_month_cumulative_report";
+$route['Report_monthly_gst'] = "report/monthly_gst";
// Company Information
$route['companyview'] = 'companycontroller/companyview';
diff --git a/application/controllers/report.php b/application/controllers/report.php
index 225e9fef..560df53b 100755
--- a/application/controllers/report.php
+++ b/application/controllers/report.php
@@ -1014,6 +1014,45 @@ class report extends BaseController
$this->loadviews("Report_pending_purchase",$this->global,$data, NULL);
+ }
+ public function monthly_gst()
+ {
+
+ $this->global['pageTitle'] = 'Siddharth : Reports';
+ if ($this->input->post('btn_submit')) {
+
+ $m=$this->input->post('month');
+ $frm = $this->input->post('from_date');
+ $t = $this->input->post('to_date');
+ //print_r($prod);
+
+ $data['monthly_gst_purchase']=$this->dahsboard_Model->monthly_gst_purchase($m,$frm,$t);
+ $data['monthly_gst_sales']=$this->dahsboard_Model->monthly_gst_sales($m,$frm,$t);
+
+ }
+ $data['finyear']=$this->dahsboard_Model->report_finyear();
+ $this->loadviews("Report_monthly_gst",$this->global,$data, NULL);
+ //print_r($data);die();
+ }
+ public function monthly_gst_table()
+ {
+
+ $this->global['pageTitle'] = 'Siddharth : Reports';
+
+
+ $m=$this->input->get('m');
+ $frm = $this->input->get('frm');
+ $t = $this->input->get('t');
+ // print_r($frm);
+ // print_r($t);
+ // print_r($m);die();
+
+ $data['monthly_gst_purchase']=$this->dahsboard_Model->purchase_gst($m,$frm,$t);
+ $data['monthly_gst_sales']=$this->dahsboard_Model->sales_gst($m,$frm,$t);
+
+
+ $this->loadviews("Report_monthly_gst_table",$this->global,$data, NULL);
+ //print_r($data);die();
}
/*******************Performance report start **************/
public function getFinancialStartDate()
diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php
index 7e64c1a9..4fcb14e7 100755
--- a/application/models/dahsboard_model.php
+++ b/application/models/dahsboard_model.php
@@ -2257,7 +2257,220 @@ if ($cname!= ''){
//echo $sql;
return $query->result();
}
+ function monthly_gst_purchase($m,$frm,$t){
+
+ $sql="select g.doc_no,g.date,g.doc_type,g.hsn_code,sum(g.value) as value,sum(g.others) as others,sum(g.sgst) as sgst,sum(g.cgst) as cgst,sum(g.igst) as igst,sum(g.total) as total from
+(SELECT pm.PONO as doc_no,date_format(pm.PODate,'%d-%m-%Y') as date,
+'Purchase' as doc_type,mm.HSNCODE as hsn_code,
+mm.MaterialName as material_name,sd.SupplierName as supplier_name,
+round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value,
+if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate,
+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst,
+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst,
+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst,
+(ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0)
++ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0)
++ifnull(rt.Insurance,0)
+-ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)) as others,
+round((
+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0)
++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0)
++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0))
+,2) as total
+ FROM T_PurchaseOrder_Master pm
+join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
+left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
+left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
+left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
+left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
+where
+pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027'
+group by doc_no,material_name,supplier_name) as g
+left join T_PurchaseOrder_Master p on p.PONO = g.doc_no
+where g.doc_no != 'null' ";
+
+ if ($m!= ''){
+
+ $sql.="and monthname(p.PODate) = '".$m."'";
+
+ }
+
+ if ($frm and $t != ''){
+ // $fromd= date("Y-m-d",strtotime($frm));
+ // $tod=date("Y-m-d",strtotime($t));
+
+ $sql.="and g.date >= '".$frm."'
+ and g.date <= '".$t."'";
+
+ }
+
+
+ //echo $sql;
+ $query = $this->db->query($sql);
+ return $query->result();
+ }
+ public function monthly_gst_sales($m=null,$frm=null,$t=null)
+ {
+
+ $sql = "select ii.invoice_id as invoice_id,ii.invoice_number as invoice_number,date_format(ii.invoice_date_created,'%d-%m-%Y') as dates,
+ sum(ifnull(((sgst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100),0))
+ as sgst,
+ sum(ifnull(((iit.item_quantity * iit.item_price) * cgst.tax_rate_percent)/100,0))
+ as cgst,
+ sum(ifnull((igst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100,0))
+ as igst,
+ sum((ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0)
+ +
+ ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0)
+ +
+ ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0)))
+ as total
+ from ip_invoices ii
+ join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id
+ join ip_invoice_items iit on iit.invoice_id = ii.invoice_id
+ join ip_invoice_item_amounts iia on iia.item_id = iit.item_id
+ join ip_clients ic on ic.client_id = ii.client_id
+ join ip_products ip on ip.product_id = iit.item_product_id
+ left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id
+ left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id
+ left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id
+ where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 ";
+
+
+
+
+ if ($m!= ''){
+
+ $sql.="and monthname(ii.invoice_date_created) = '".$m."'";
+
+ }
+
+ if ($frm and $t != ''){
+ $fromdate= date("Y-m-d",strtotime($frm));
+ $todate=date("Y-m-d",strtotime($t));
+
+ $sql.="and ii.invoice_date_created >= '".$fromdate."'
+ and ii.invoice_date_created <= '".$todate."'";
+
+ }
+ //echo $sql;
+ $query = $this->db->query($sql);
+ return $query->result();
+
+
+ }
+ function sales_gst($m=null,$frm=null,$t=null)
+ {
+
+ $sql = "select ii.invoice_id as invoice_id,ii.client_id as client_id,ip.product_sku as hsn_code,ii.invoice_number as doc_no,date_format(ii.invoice_date_created,'%d-%m-%Y') as date,'Sales' as doc_type,TIME_FORMAT(ii.invoice_time_created,'%l:%i %p') as invoice_time_created,icf.invoice_custom_fieldvalue as vehicle_no,ip.product_description as product_description,concat(ic.client_name,'-',ic.client_surname)as client_name,sum(iit.item_quantity) as item_quantity,sum(iit.item_price) as item_price,sum(iia.item_subtotal) as value,
+ sum(ifnull(((sgst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100),0))
+ as sgst,
+ sum(ifnull(((iit.item_quantity * iit.item_price) * cgst.tax_rate_percent)/100,0))
+ as cgst,
+ sum(ifnull((igst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100,0))
+ as igst,
+ round(sum((iia.item_subtotal + ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0)
+ +
+ ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0)
+ +
+ ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0))),2)
+ as total
+ from ip_invoices ii
+ join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id
+ join ip_invoice_items iit on iit.invoice_id = ii.invoice_id
+ join ip_invoice_item_amounts iia on iia.item_id = iit.item_id
+ join ip_clients ic on ic.client_id = ii.client_id
+ join ip_products ip on ip.product_id = iit.item_product_id
+ left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id
+ left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id
+ left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id
+ where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 ";
+
+
+
+ if ($m!= ''){
+
+ $sql.="and monthname(ii.invoice_date_created) = '".$m."'";
+
+ }
+
+ if ($frm and $t != ''){
+ $fromdate= date("Y-m-d",strtotime($frm));
+ $todate=date("Y-m-d",strtotime($t));
+
+ $sql.="and ii.invoice_date_created >= '".$fromdate."'
+ and ii.invoice_date_created <= '".$todate."'";
+
+ }
+
+
+ // echo $fromdate;
+ //echo $sql;
+ $sql.="group by doc_no,product_description";
+ $query = $this->db->query($sql);
+ return $query->result();
+
+
+ }
+ function purchase_gst($m,$frm,$t){
+
+
+ $sql="SELECT pm.PONO as doc_no,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as date,
+TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time,'Purchase' as doc_type,mm.HSNCODE as hsn_code,
+mm.MaterialName as material_name,sd.SupplierName as supplier_name,
+ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate,
+round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value,
+if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate,
+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst,
+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst,
+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst,
+(ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0)
++ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0)
++ifnull(rt.Insurance,0)
+-ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)) as others,
+round((
+ if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)),
+if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)),
+ifnull(sum(pl.Quantity * pl.Rate),0)))
++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0)
++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0)
++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0)
++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0)
++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0)
++ ifnull(rt.Insurance,0)
+- ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total
+ FROM T_PurchaseOrder_Master pm
+join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO
+left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode
+left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
+left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
+left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
+where
+pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' ";
+
+ if ($m!= ''){
+
+ $sql.="and monthname(pm.PODate) = '".$m."'";
+
+ }
+
+ if ($frm and $t != ''){
+ $fromd= date("Y-m-d",strtotime($frm));
+ $tod=date("Y-m-d",strtotime($t));
+
+ $sql.="and date(pm.PODate) >= '".$fromd."'
+ and date(pm.PODate) <= '".$tod."'";
+
+ }
+
+
+
+$sql.="group by doc_no,material_name,supplier_name";
+//echo $sql;
+ $query = $this->db->query($sql);
+ return $query->result();
+ }
function report_inwardcashbook($cname,$fa,$aa,$m,$frm,$t,$cat){
$sql="select tinex.account_code as AccountCode,date_format(tinex.date,'%d-%m-%Y') as Date,ac.name as AccountName,
diff --git a/application/views/Report_monthly_gst.php b/application/views/Report_monthly_gst.php
new file mode 100644
index 00000000..764cabe6
--- /dev/null
+++ b/application/views/Report_monthly_gst.php
@@ -0,0 +1,352 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Name |
+ Sales () |
+ Purchase () |
+ Net () |
+
+
+
+
+ input->post('month');
+ $frm=$this->input->post('from_date');
+ $t=$this->input->post('to_date');
+ if(!empty($monthly_gst_purchase) and !empty($monthly_gst_sales)){ ?>
+
+
+ | SGST |
+ sgst,2);?> |
+ sgst,2);?> |
+ sgst - $monthly_gst_purchase[0]->sgst;
+ echo round($sgst_net,2);?> |
+
+
+ | CGST |
+ cgst,2);?> |
+ cgst,2);?> |
+ cgst - $monthly_gst_purchase[0]->cgst;
+ echo round($cgst_net,2);?> |
+
+
+ | IGST |
+ igst,2);?> |
+ igst,2);?> |
+ igst - $monthly_gst_purchase[0]->igst;
+ echo round($igst_net,2);?> |
+
+
+ | Total GST |
+ total,2);?> |
+ total,2);?> |
+ total - $monthly_gst_purchase[0]->total;
+ echo round($total_net,2);?> |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/Report_monthly_gst_table.php b/application/views/Report_monthly_gst_table.php
new file mode 100644
index 00000000..5adf49d1
--- /dev/null
+++ b/application/views/Report_monthly_gst_table.php
@@ -0,0 +1,324 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Date |
+ Document Number |
+ Document Type |
+ HSN CODE |
+ Value () |
+ Others () |
+ SGST () |
+ CGST () |
+ IGST () |
+ Total () |
+
+
+
+
+
+
+ | date;?> |
+ doc_no;?> |
+ doc_type;?> |
+ hsn_code;?> |
+ value,2);
+ echo $rel->value;
+ ?> |
+ others,2);
+ echo $rel->others;
+ ?> |
+ sgst,2);
+ echo $rel->sgst;
+ ?> |
+ cgst,2);
+ echo $rel->cgst;
+ ?> |
+ igst,2);
+ echo $rel->igst;
+ ?> |
+ total,2);
+ echo $rel->total;
+ ?> |
+
+
+
+
+
+
+ | date;?> |
+ doc_no;?> |
+ doc_type;?> |
+ hsn_code;?> |
+ value,2);
+ echo round($rel->value,2);
+ ?> |
+ |
+ sgst,2);
+ echo round($rel->sgst,2);
+ ?> |
+ cgst,2);
+ echo round($rel->cgst,2);
+ ?> |
+ igst,2);
+ echo round($rel->igst,2);
+ ?> |
+ total,2);
+ echo round($rel->total,2);
+ ?> |
+
+
+
+
+
+
+
+
+ | Total |
+   |
+   |
+   |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/reportslink.php b/application/views/reportslink.php
index 13b59ec4..6beaf6a6 100755
--- a/application/views/reportslink.php
+++ b/application/views/reportslink.php
@@ -68,6 +68,10 @@
Cashbook Yearly Expenses
-->
+