gst report bugs fixes

This commit is contained in:
gandhimathi 2018-06-18 16:58:17 +05:30
parent b187f441bd
commit d5d0c044aa
4 changed files with 330 additions and 56 deletions

View File

@ -1024,10 +1024,13 @@ class report extends BaseController
$m=$this->input->post('month');
$frm = $this->input->post('from_date');
$t = $this->input->post('to_date');
$ab=$this->input->post('financialyear');
$fa=substr($ab,0,-5);
$aa=substr($ab,5,5);
//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['monthly_gst_purchase']=$this->dahsboard_Model->monthly_gst_purchase($m,$frm,$t,$fa,$aa);
$data['monthly_gst_sales']=$this->dahsboard_Model->monthly_gst_sales($m,$frm,$t,$fa,$aa);
}
$data['finyear']=$this->dahsboard_Model->report_finyear();
@ -1043,12 +1046,15 @@ class report extends BaseController
$m=$this->input->get('m');
$frm = $this->input->get('frm');
$t = $this->input->get('t');
$ab=$this->input->get('financialyear');
$fa=substr($ab,0,-5);
$aa=substr($ab,5,5);
// 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);
$data['monthly_gst_purchase']=$this->dahsboard_Model->purchase_gst($m,$frm,$t,$fa,$aa);
$data['monthly_gst_sales']=$this->dahsboard_Model->sales_gst($m,$frm,$t,$fa,$aa);
$this->loadviews("Report_monthly_gst_table",$this->global,$data, NULL);

View File

@ -2274,7 +2274,7 @@ if ($cname!= ''){
//echo $sql;
return $query->result();
}
function monthly_gst_purchase($m,$frm,$t){
function monthly_gst_purchase($m,$frm,$t,$fa,$aa){
$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,
@ -2313,20 +2313,25 @@ where g.doc_no != 'null' ";
}
if ($frm and $t != ''){
// $fromd= date("Y-m-d",strtotime($frm));
// $tod=date("Y-m-d",strtotime($t));
$fromd= date("Y-m-d",strtotime($frm));
$tod=date("Y-m-d",strtotime($t));
$sql.="and g.date >= '".$frm."'
and g.date <= '".$t."'";
$sql.="and p.PODate >= '".$fromd."'
and p.PODate <= '".$tod."'";
}
if ($fa and $aa != ''){
$sql.=" and (p.PODate >= '".$fa."-04-01' and p.PODate <= '".$aa."-03-31')";
}
//echo $sql;
//echo $sql;
$query = $this->db->query($sql);
return $query->result();
}
public function monthly_gst_sales($m=null,$frm=null,$t=null)
public function monthly_gst_sales($m=null,$frm=null,$t=null,$fa=null,$aa=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,
@ -2370,13 +2375,18 @@ where g.doc_no != 'null' ";
and ii.invoice_date_created <= '".$todate."'";
}
if ($fa and $aa != ''){
$sql.=" and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31')";
}
//echo $sql;
$query = $this->db->query($sql);
return $query->result();
}
function sales_gst($m=null,$frm=null,$t=null)
function sales_gst($m=null,$frm=null,$t=null,$fa=null,$aa=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,
@ -2419,6 +2429,11 @@ where g.doc_no != 'null' ";
and ii.invoice_date_created <= '".$todate."'";
}
if ($fa and $aa != ''){
$sql.=" and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31')";
}
// echo $fromdate;
@ -2429,7 +2444,7 @@ where g.doc_no != 'null' ";
}
function purchase_gst($m,$frm,$t){
function purchase_gst($m,$frm,$t,$fa,$aa){
$sql="SELECT pm.PONO as doc_no,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as date,
@ -2480,7 +2495,11 @@ pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' ";
and date(pm.PODate) <= '".$tod."'";
}
if ($fa and $aa != ''){
$sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')";
}
$sql.="group by doc_no,material_name,supplier_name";

View File

@ -51,7 +51,12 @@ table.dataTable thead > tr > td.sorting {
<center><h3 class="box-title"><p style="color:#3c8dbc"><b>Report - Monthly GST</b>
<br><br>
<?php
if($this->input->post('financialyear')){
$ab=$this->input->post('financialyear');
echo '('.$ab.')';
echo ' ';
}
if($this->input->post('month')){
$m=$this->input->post('month');
echo '('.$m.')';
@ -73,7 +78,29 @@ table.dataTable thead > tr > td.sorting {
<form method="post" action="<?php echo base_url($this->uri->uri_string()); ?>">
<div class="form-group has-feedback">
<div class="col-md-4">
<div class="col-md-2">
<label for="to_date">
<?php echo 'Year'; ?>
</label>
<div class="input-group">
<select class="form-control" id="financialyear" name="financialyear">
<option value="">Select Year</option>
<?php
foreach($finyear as $item):
{?>
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
<?php } endforeach; ?>
</select>
</div>
</div>
<div class="col-md-3">
<label for="from_date">
<?php echo 'From Date'; ?>
</label>
@ -86,7 +113,7 @@ table.dataTable thead > tr > td.sorting {
</div>
<div class="col-md-4">
<div class="col-md-3">
<label for="to_date">
<?php echo 'To Date'; ?>
</label>
@ -99,7 +126,7 @@ table.dataTable thead > tr > td.sorting {
</div>
<div class="col-md-2">
<label for="to_date">
<label for="month">
<?php echo 'Month'; ?>
</label>
<div class="input-group">
@ -150,6 +177,7 @@ table.dataTable thead > tr > td.sorting {
$m=$this->input->post('month');
$frm=$this->input->post('from_date');
$t=$this->input->post('to_date');
$ab=$this->input->post('financialyear');
if(!empty($monthly_gst_purchase) and !empty($monthly_gst_sales)){ ?>
<tr>
@ -238,7 +266,7 @@ table.dataTable thead > tr > td.sorting {
</table></center>
<div class="col-md-2" style="float: right;">
<form>
<a href="<?= base_url() ?>report/monthly_gst_table?m=<?php echo $m;?>&frm=<?php echo $frm;?>&t=<?php echo $t;?>"><input style="width: 100px; padding: 10px; cursor: pointer; box-shadow: 6px 6px 5px; #999; -webkit-box-shadow: 6px 6px 5px #999; -moz-box-shadow: 6px 6px 5px #999; font-weight: bold; background: #3c8dbc; color: #000; border-radius: 10px; border: 1px solid #999; font-size: 100%;" type="button" value="View details"/></a>
<a href="<?= base_url() ?>report/monthly_gst_table?m=<?php echo $m;?>&frm=<?php echo $frm;?>&t=<?php echo $t;?>&financialyear=<?php echo $ab;?>"><input style="width: 100px; padding: 10px; cursor: pointer; box-shadow: 6px 6px 5px; #999; -webkit-box-shadow: 6px 6px 5px #999; -moz-box-shadow: 6px 6px 5px #999; font-weight: bold; background: #3c8dbc; color: #000; border-radius: 10px; border: 1px solid #999; font-size: 100%;" type="button" value="View details"/></a>
</form>
</div>

View File

@ -38,6 +38,12 @@
<div class="box box-info">
<div class="box-header with-border">
<center><h3 class="box-title"><p style="color:#3c8dbc"><b>Monthly GST Summary Report</b><br><br>
<div>
<br>
<label><input type="radio" name="colorRadio" id="value" onclick="toggleTables('2')" value="tab" checked> Sales</label>
<label><input type="radio" name="colorRadio" id="qty" onclick="toggleTables('1')" value="ta"> Purchase</label>
</div>
</p></h3></center>
</div>
<!-- /.box-header -->
@ -45,8 +51,152 @@
<div class="box-body">
<div>
<div class="box-body" style="display:block" id="a">
<table class="table table-bordered table-hover" id="cc" >
<thead>
<tr>
<th style="text-align:center">Date</th>
<th style="text-align:center">Document Number</th>
<th style="text-align:center">Document Type</th>
<th style="text-align:center">HSN CODE</th>
<th style="text-align:center">Value &nbsp;(&#8377;)</th>
<th style="text-align:center">Others &nbsp;(&#8377;)</th>
<th style="text-align:center">SGST &nbsp;(&#8377;)</th>
<th style="text-align:center">CGST &nbsp;(&#8377;)</th>
<th style="text-align:center">IGST &nbsp;(&#8377;)</th>
<th style="text-align:center">Total &nbsp;(&#8377;)</th>
</tr>
</thead>
<tbody>
<?php
$tot_val = 0;
$tot_oth = 0;
$tot_sgst = 0;
$tot_cgst = 0;
$tot_igst = 0;
$tot_tot = 0;
?>
<?php
if(!empty($monthly_gst_sales)){
foreach($monthly_gst_sales as $rel)
{
?>
<tr>
<td style="text-align:center"><span><?php echo $rel->date;?></span></td>
<td style="text-align:center"><span><?php echo $rel->doc_no;?></span></td>
<td style="text-align:center"><span><?php echo $rel->doc_type;?></span></td>
<td style="text-align:center"><span><?php echo $rel->hsn_code;?></span></td>
<td style="text-align:right"><span><?php
$tot_val= $tot_val + round($rel->value,2);
echo round($rel->value,2);
?></span></td>
<td></td>
<td style="text-align:right"><span><?php
$tot_sgst= $tot_sgst + round($rel->sgst,2);
echo round($rel->sgst,2);
?></span></td>
<td style="text-align:right"><span><?php
$tot_cgst= $tot_cgst + round($rel->cgst,2);
echo round($rel->cgst,2);
?></span></td>
<td style="text-align:right"><span><?php
$tot_igst= $tot_igst + round($rel->igst,2);
echo round($rel->igst,2);
?></span></td>
<td style="text-align:right"><span><?php
$tot_tot= $tot_tot + round($rel->total,2);
echo round($rel->total,2);
?></span></td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot width="100%">
<tr>
<td style="text-align:center;"><strong>Total</strong></td>
<td><strong>&nbsp</strong></td>
<td><strong>&nbsp</strong></td>
<td><strong>&nbsp</strong></td>
<td class="amount" style="text-align:right">
<strong>
<?php
{
echo number_format($tot_val,2,'.','');
}
?>
</strong></td>
<td class="amount" style="text-align:right">
<strong>
<?php
{
echo number_format($tot_oth,2,'.','');
}
?>
</strong></td>
<td class="amount" style="text-align:right">
<strong>
<?php
{
echo number_format($tot_sgst,2,'.','');
}
?>
</strong></td>
<td class="amount" style="text-align:right">
<strong>
<?php
{
echo number_format($tot_cgst,2,'.','');
}
?>
</strong></td>
<td class="amount" style="text-align:right">
<strong>
<?php
{
echo number_format($tot_igst,2,'.','');
}
?>
</strong></td>
<td class="amount" style="text-align:right">
<strong>
<?php
{
echo number_format($tot_tot,2,'.','');
}
?>
</strong></td>
</tr>
</tfoot>
</table>
</div>
<!-- second table -->
<div class="box-body" style="display:none" id="b">
<table class="table table-bordered table-hover" id="cc1" >
<thead>
<tr>
<th style="text-align:center">Date</th>
@ -110,44 +260,9 @@
<?php
}
}
if(!empty($monthly_gst_sales)){
foreach($monthly_gst_sales as $rel)
{
?>
<tr>
<td style="text-align:center"><span><?php echo $rel->date;?></span></td>
<td style="text-align:center"><span><?php echo $rel->doc_no;?></span></td>
<td style="text-align:center"><span><?php echo $rel->doc_type;?></span></td>
<td style="text-align:center"><span><?php echo $rel->hsn_code;?></span></td>
<td style="text-align:right"><span><?php
$tot_val= $tot_val + round($rel->value,2);
echo round($rel->value,2);
?></span></td>
<td></td>
<td style="text-align:right"><span><?php
$tot_sgst= $tot_sgst + round($rel->sgst,2);
echo round($rel->sgst,2);
?></span></td>
<td style="text-align:right"><span><?php
$tot_cgst= $tot_cgst + round($rel->cgst,2);
echo round($rel->cgst,2);
?></span></td>
<td style="text-align:right"><span><?php
$tot_igst= $tot_igst + round($rel->igst,2);
echo round($rel->igst,2);
?></span></td>
<td style="text-align:right"><span><?php
$tot_tot= $tot_tot + round($rel->total,2);
echo round($rel->total,2);
?></span></td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot width="100%">
<tr>
@ -338,6 +453,98 @@ $.fn.dataTable.moment( 'DD-MM-YYYY' );
}
} );
} );
//second table
$(document).ready(function() {
$.fn.dataTable.moment( 'DD-MM-YYYY' );
table = $('#cc1').DataTable( {
"language": {
"emptyTable":"<center> Data Not Found ! </center>"
},
"dom": "<'row'<'col-md-6'l><'col-md-6'Bf>>" +
"<'row'<'col-md-6'><'col-md-6'>>" +
"<'row'<'col-md-12't>><'row'<'col-md-4'i><'col-md-8'p>>",
buttons: [
{
extend: 'excelHtml5',
footer: 'true',
title: $('h3').text(),
exportOptions: {
columns: ':visible'
}
},
'colvis'
],
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
parseFloat(i.replace(/[^0.00-9.00]+/g,"")*1) :
typeof i === 'number' ?
parseFloat(i) : 0;
};
TotalVALUE = api
.column( 4, { search:'applied' } )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 4 ).footer() ).html( TotalVALUE.toFixed(2).bold() );
TotalOTHERS = api
.column( 5, { search:'applied' } )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 5 ).footer() ).html( TotalOTHERS.toFixed(2).bold() );
TotalSGST = api
.column( 6, { search:'applied' } )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 6 ).footer() ).html( TotalSGST.toFixed(2).bold() );
TotalCGST = api
.column( 7, { search:'applied' } )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 7 ).footer() ).html( TotalCGST.toFixed(2).bold() );
TotalIGST = api
.column( 8, { search:'applied' } )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 8 ).footer() ).html( TotalIGST.toFixed(2).bold() );
FinalTotal = api
.column( 9, { search:'applied' } )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 9 ).footer() ).html( FinalTotal.toFixed(2).bold() );
}
} );
} );
$( function() {
@ -386,6 +593,20 @@ $.fn.dataTable.moment( 'DD-MM-YYYY' );
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
function toggleTables(which)
{
if(which == "2") {
document.getElementById('a').style.display = "block";
document.getElementById('b').style.display = "none";
}
if(which == "1") {
document.getElementById('b').style.display = "block";
document.getElementById('a').style.display = "none";
}
}
</script>