cashbook issues fixes

This commit is contained in:
venbatechnologies@gmail.com 2018-05-15 13:10:39 +05:30
parent db3212b9a9
commit 2079a7598b
7 changed files with 262 additions and 73 deletions

View File

@ -129,6 +129,7 @@ class cashbook extends BaseController
{
$data['dropdownvalues'] = $this->cashbook_model->getAccounTypes();
$data['getsupplier'] = $this->cashbook_model->getsupplier();
//print_r($data['dropdownvalues']);die();
$this->global['pageTitle'] = 'Siddharth : Cash Book: Add New Income Expense ';
$this->loadViews("addnewIncomeExpense", $this->global, $data , NULL);
@ -305,6 +306,7 @@ class cashbook extends BaseController
$date = date_create($date);//,'Y-m-d');
$date = date_format($date,'Y-m-d');
$towhome = $this->input->post('towhome');
$supplier = $this->input->post('supplier');
$gsttoggle = $this->input->post('gsttoggle');
$invoiceno = null;
@ -359,7 +361,7 @@ class cashbook extends BaseController
}
$balance=$totalbankamount-$totalamount;
$created_by = $this->session->userdata('userId');
$addincomexpense = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome,'invoice_no'=>$invoiceno,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$totalamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'cashtype'=>$option,'bankid'=>$bankid,'totalbankamount'=>$totalbankamount,'balance'=>$balance,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'amounttype'=>$amounttype);
$addincomexpense = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome,'Supplier_id'=>$supplier,'invoice_no'=>$invoiceno,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$totalamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'cashtype'=>$option,'bankid'=>$bankid,'totalbankamount'=>$totalbankamount,'balance'=>$balance,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'amounttype'=>$amounttype);
//print_r($addincomexpense);
//die();
if($balance=='0')
@ -613,6 +615,7 @@ class cashbook extends BaseController
//$data['deletefile'] = $this->cashbook-model->deletefile($cash);
$data['dropdownvalues'] = $this->cashbook_model->getAccounTypes();
$data['getsupplier'] = $this->cashbook_model->getsupplier();
//print_r( $data['DepDetails']);die();
$this->global['pageTitle'] = 'Siddharth : Edit Cashbook';
$this->loadViews("editincomeexpenses", $this->global,$data, NULL);
@ -659,6 +662,7 @@ class cashbook extends BaseController
$accountcode1 = $this->input->post('accode');
//echo $accountcode1;die();
$towhome1 = $this->input->post('towhome');
$supplier = $this->input->post('supplier');
$Invoiceno1 = $this->input->post('Invoiceno');
$merchant1 = $this->input->post('merchant');
$Merchantgst1 = $this->input->post('Merchantgst');
@ -707,7 +711,7 @@ class cashbook extends BaseController
}
$updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$date,'towhom'=>$towhome1,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'description'=>$description1,'document'=>$document);
$updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$date,'towhom'=>$towhome1,'Supplier_id'=>$supplier,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'description'=>$description1,'document'=>$document);
$res = $this->cashbook_model->updatedepartment($updateaccount,$id1);
//print_r($updateaccount);die();
$cashbookamount=$this->cashbook_model->cashbookamount($bankid);

View File

@ -1186,30 +1186,51 @@ class report extends BaseController
}
public function cashbook_cumulative_report()
{
$this->global['pageTitle'] = 'Cashbook Cumulative - report ';
$this->global['pageTitle'] = 'Siddharth : Cashbook Cumulative - Report';
$data['datas']=$this->dahsboard_Model->report_cumulative_cashbook();
$this->loadviews("cashbook_cumulative_report",$this->global,$data, NULL);
}
public function cashbook_month_cumulative_report()
{
// public function cashbook_month_cumulative_reported1()
// {
$this->global['pageTitle'] = 'Cashbook Cumulative(Monthwise) - report ';
// $this->global['pageTitle'] = 'Cashbook Cumulative(Monthwise) - report ';
if (date('m') >= 4) {
$yearl = date('Y').'-'.(date('Y')+1);
} else {
$yearl = (date('Y')-1).'-'.date('Y');
}
$ab=$yearl;
$fa=substr($ab,0,-5);
$aa=substr($ab,5,5);
// if (date('m') >= 4) {
// $yearl = date('Y').'-'.(date('Y')+1);
// } else {
// $yearl = (date('Y')-1).'-'.date('Y');
// }
// $ab=$yearl;
// $fa=substr($ab,0,-5);
// $aa=substr($ab,5,5);
$data['datas'] = $this->dahsboard_Model->report_cumulative_month_cashbook();
$this->loadviews("cashbook_cumulative_month_report",$this->global,$data, NULL);
// $data['datas'] = $this->dahsboard_Model->report_cumulative_month_cashbook();
// $this->loadviews("cashbook_cumulative_month_report1",$this->global,$data, NULL);
}
// }
public function cashbook_month_cumulative_report()
{
$this->global['pageTitle'] = 'Siddharth : Cashbook Cumulative(Monthwise) - Report';
if ($this->input->post('btn_submit')) {
$cname = $this->input->post('client_name');
$ab=$this->input->post('financialyear');
$fa=substr($ab,0,-5);
$aa=substr($ab,5,5);
$data['accountname']=$this->dahsboard_Model->accountname();
$data['finyear']=$this->dahsboard_Model->cashbook_finyear();
// $data['spurchse']=$this->dahsboard_Model->rawi_report_consolidate($cname,$fa,$aa);
$data['datas'] = $this->dahsboard_Model->report_cumulative_month_cashbook($cname,$fa,$aa);
}
$data['accountname']=$this->dahsboard_Model->accountname();
$data['finyear']=$this->dahsboard_Model->cashbook_finyear();
$this->loadviews("cashbook_cumulative_month_report",$this->global,$data, NULL);
}
}
?>

View File

@ -2164,15 +2164,17 @@ if ($cname!= ''){
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,
tinex.type as type,tinex.cashtype as category ,tinex.merchant as Suppliername, tinex.sgst as sgst,
tinex.type as type,tinex.cashtype as category ,tinex.merchant as merchantname,tinex.Supplier_id as Supplierid,sup.SupplierName as Suppliername, tinex.sgst as sgst,
tinex.value_before_gst as Value,tinex.cgst as cgst,tinex.igst as igst,
tinex.total as Total
FROM t_income_expense tinex
join t_accountcode ac on ac.code = tinex.account_code
join T_SupplierDetailsN sup on sup.SupplierID = tinex.Supplier_id
where tinex.gststatus = '1' ";
if ($cname!= ''){
$sql.="and tinex.merchant = '".$cname."'";
// $sql.="and tinex.merchant = '".$cname."'";
$sql.="and sup.SupplierName = '".$cname."'";
}
if ($fa and $aa != ''){
@ -2572,20 +2574,46 @@ function daybeforetotal($yesterday){
$query = $this->db->query($sql,array($yesterday));
return $query->result();
}
function accountname()
{
$sql = "SELECT name from t_accountcode ";
$query = $this->db->query($sql);
return $query->result();
}
function report_cumulative_month_cashbook(){
function cashbook_finyear(){
$sql="SELECT
CASE WHEN MONTH(date)>=4 THEN
concat(YEAR(date), '-',YEAR(date)+1)
ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year
FROM t_income_expense
GROUP BY financial_year";
$query = $this->db->query($sql);
return $query->result();
if (date('m') >= 4) {
$yearl = date('Y').'-'.(date('Y')+1);
} else {
$yearl = (date('Y')-1).'-'.date('Y');
}
//function report_cumulative_month_cashbook(){
function report_cumulative_month_cashbook($cname,$yr1,$yr2){
if ($yr1 == '' && $yr2 == ''){
if (date('m') >= 4) {
$yearl = date('Y').'-'.(date('Y')+1);
} else {
$yearl = (date('Y')-1).'-'.date('Y');
}
$ab=$yearl;
$fa=substr($ab,0,-5);
$aa=substr($ab,5,5);
}
else{
$fa=$yr1;
$aa=$yr2;
}
$ab=$yearl;
$fa=substr($ab,0,-5);
$aa=substr($ab,5,5);
$sql = "SELECT sub.name as name,
$sql = "SELECT sub.name as name,sub.tincyear,
sub.expensetotal as Finyeartotalexpense,
sub.incometotal as Finyeartotalincome,
IF(month = 'Jan', sub.expensetotal, 0) AS 'Janexp',
@ -2613,7 +2641,7 @@ function daybeforetotal($yesterday){
IF(month = 'Nov', sub.incometotal, 0) AS 'Novinc',
IF(month = 'Dec', sub.incometotal, 0) AS 'Decinc'
FROM (
select DATE_FORMAT(tinc1.date, '%b') AS month,ac1.name,
select DATE_FORMAT(tinc1.date, '%b') AS month,year(tinc1.date) as tincyear,ac1.name,
ifnull(case
when tinc1.type = 'PAYMENT'
then sum(tinc1.total)
@ -2624,9 +2652,12 @@ function daybeforetotal($yesterday){
end, '0') as incometotal
FROM t_income_expense tinc1
join t_accountcode ac1 on ac1.code = tinc1.account_code
WHERE (tinc1.date >='".$fa."-04-01' and tinc1.date <= '".$aa."-03-31')
GROUP BY ac1.name ) as sub
GROUP BY name ";
WHERE (tinc1.date >='".$fa."-04-01' and tinc1.date <= '".$aa."-03-31')";
if ($cname!= ''){
$sql.="and ac1.name = '".$cname."'";
}
$sql.= "GROUP BY ac1.name ) as sub
GROUP BY name ";
$query = $this->db->query($sql);
return $query->result();

View File

@ -4,6 +4,7 @@ $(function() {
var t = [];
var ex = [];
var inc = [];
var supp =[];
t= <?php echo json_encode($dropdownvalues)?>;
$.each(t,function(i,item){
if(item.type == 'RECEIPT')
@ -11,6 +12,11 @@ $(function() {
$("#accode").append( $('<option></option>').val(item.code).html(item.name));
}
});
supp = <?php echo json_encode($getsupplier)?>;
$.each(supp,function(s,supp){
$("#supplier").append( $('<option></option>').val(supp.SupplierID).html(supp.SupplierID+' - '+supp.SupplierName));
});
$('#gst').click(function(){
$('#gstarea').toggle();
@ -125,7 +131,7 @@ function loadAccountType(id)
<section class="content">
<div style="text-align:right;">
<a href="<?php base_url() ?>ViewIncomeExpense" class="btn btn-primary" value="Back"/>Back</a>
<a href="<?php echo base_url() ?>ViewIncomeExpense" class="btn btn-primary" value="Back"/>Back</a>
</div>
<br>
<div class="row">
@ -184,6 +190,18 @@ function loadAccountType(id)
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<b><span for="Suppliername">Select Supplier:</span> </b><span style="color:red">*</span></br></br>
<select class="form-control select2 required" id="supplier" name="supplier">
<option value="-1">Select Supplier</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
@ -369,6 +387,7 @@ function validate()
var cgst = $('#CGST').val();
var igst = $('#IGST').val();
var total = $('#totalamount').val();
var supplier = $('#supplier').val();
var errorflag = 0;
@ -391,6 +410,10 @@ function validate()
{
errorflag++;
}
if(supplier == '')
{
errorflag++;
}
if(gstcheck == true)
{

View File

@ -44,8 +44,81 @@ if (date('m') >= 4) {
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<center><h3 class="box-title"><p style="color:#3c8dbc"><b>Cashbook - Cumulative Monthwise Report ( <?php echo $fa.'-'.$aa; ?> )</b></p></h3></center>
<center><h3 class="box-title"><p style="color:#3c8dbc"><b>Cashbook - Cumulative Monthwise Report
<!-- ( <?php echo $fa.'-'.$aa; ?> ) -->
<?php
if($this->input->post('client_name')){
$cl=$this->input->post('client_name');
echo '('.$cl.')';
}
if($this->input->post('financialyear')){
$ab=$this->input->post('financialyear');
echo '('.$ab.')';
}
?></b></p></h3></center>
</div>
<div class="panel-body">
<form method="post" action="<?php echo base_url($this->uri->uri_string()); ?>">
<div class="form-group has-feedback">
<div class="col-md-4">
<label for="client_name">
<?php echo 'Account Name'; ?>
</label>
<div class="input-group">
<select class="form-control" id="client_name" name="client_name">
<option value="">Select Account Name</option>
<?php
foreach($accountname as $item):
{?>
<option value="<?php echo $item->name;?>"><?php echo $item->name ; ?></option>
<?php } endforeach; ?>
</select>
</div>
</div>
<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-2"></div>
<!-- <div class="col-md-2">
<br>
<label><input type="radio" name="colorRadio" id="value" onclick="toggleTables('2')" value="tab" checked> Recepit</label>
<label><input type="radio" name="colorRadio" id="qty" onclick="toggleTables('1')" value="ta" > Payment</label>
</div> -->
<div class="col-md-2 "><br>
<input type="submit" class="btn btn-success" name="btn_submit"
value="View Report">
</div>
</div>
</form>
</div>
<div class="box-body">
<div class = "table-responsive">
<table class="table table-bordered table-hover table-responsive" id="ccmonthwise" style="font-size:14px;">
@ -126,38 +199,38 @@ if (date('m') >= 4) {
<td><?php $timar= $timar + number_format($d->Marinc,2,'.',''); echo number_format($d->Marinc,2,'.',''); ?></td>
<td><?php $timar= $temar + number_format($d->Marexp,2,'.',''); echo number_format($d->Marexp,2,'.',''); ?></td>
</tr>
<?php }
} ?>
<?php } ?>
</tbody>
<tfoot width="100%">
<tr>
<td><?php echo "TOTAL" ?></td>
<td><?php echo number_format($tiapr,2,'.',''); ?></td>
<td><?php echo number_format($teapr,2,'.',''); ?></td>
<td><?php echo number_format($timay,2,'.',''); ?></td>
<td><?php echo number_format($temay,2,'.',''); ?></td>
<td><?php echo number_format($tijun,2,'.',''); ?></td>
<td><?php echo number_format($tejun,2,'.',''); ?></td>
<td><?php echo number_format($tijul,2,'.',''); ?></td>
<td><?php echo number_format($tejul,2,'.',''); ?></td>
<td><?php echo number_format($tiaug,2,'.',''); ?></td>
<td><?php echo number_format($teaug,2,'.',''); ?></td>
<td><?php echo number_format($tisep,2,'.',''); ?></td>
<td><?php echo number_format($tesep,2,'.',''); ?></td>
<td><?php echo number_format($tioct,2,'.',''); ?></td>
<td><?php echo number_format($teoct,2,'.',''); ?></td>
<td><?php echo number_format($tinov,2,'.',''); ?></td>
<td><?php echo number_format($tenov,2,'.',''); ?></td>
<td><?php echo number_format($tidec,2,'.',''); ?></td>
<td><?php echo number_format($tedec,2,'.',''); ?></td>
<td><?php echo number_format($tijan,2,'.',''); ?></td>
<td><?php echo number_format($tejan,2,'.',''); ?></td>
<td><?php echo number_format($tifeb,2,'.',''); ?></td>
<td><?php echo number_format($tifeb,2,'.',''); ?></td>
<td><?php echo number_format($timar,2,'.',''); ?></td>
<td><?php echo number_format($timar,2,'.',''); ?></td>
<td><b><?php echo "TOTAL" ?></b></td>
<td><b><?php echo number_format($tiapr,2,'.',''); ?></b></td>
<td><b><?php echo number_format($teapr,2,'.',''); ?></b></td>
<td><b><?php echo number_format($timay,2,'.',''); ?></b></td>
<td><b><?php echo number_format($temay,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tijun,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tejun,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tijul,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tejul,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tiaug,2,'.',''); ?></b></td>
<td><b><?php echo number_format($teaug,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tisep,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tesep,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tioct,2,'.',''); ?></b></td>
<td><b><?php echo number_format($teoct,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tinov,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tenov,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tidec,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tedec,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tijan,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tejan,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tifeb,2,'.',''); ?></b></td>
<td><b><?php echo number_format($tifeb,2,'.',''); ?></b></td>
<td><b><?php echo number_format($timar,2,'.',''); ?></b></td>
<td><b><?php echo number_format($timar,2,'.',''); ?></b></td>
</tr>
</tfoot>
<?php } ?>
</table>
</div>
</div>

View File

@ -62,26 +62,43 @@
<th style="text-align:center">Payment &nbsp;(<i class="fa fa-rupee "></i>)</th>
</tr>
</thead>
<?php
if(!empty($datas)){
$incdayttl = 0.00;
$expdayttl = 0.00;
$incmthttl = 0.00;
$expmthttl = 0.00;
$incyrttl = 0.00;
$expyrttl = 0.00;
?>
<tbody>
<?php if(!empty($datas)){
<?php
foreach($datas as $d)
{
?>
<tr>
<td><?php echo $d->name; ?></td>
<td><?php if(empty($d->tinc)){ echo '0';}else{echo number_format($d->tinc,2,'.','');} ?></td>
<td><?php if(empty($d->texp)){ echo '0';}else{echo number_format($d->texp,2,'.','');} ?></td>
<td><?php echo number_format($d->minc,2,'.',''); ?></td>
<td><?php echo number_format($d->mexp,2,'.',''); ?></td>
<td><?php echo number_format($d->yinc,2,'.',''); ?></td>
<td><?php echo number_format($d->yexp,2,'.',''); ?></td>
<td><?php if(empty($d->tinc)){ echo '0';}else{$incdayttl = $incdayttl + round($d->tinc); echo number_format($d->tinc,2,'.','');} ?></td>
<td><?php if(empty($d->texp)){ echo '0';}else{$expdayttl = $expdayttl + round($d->texp); echo number_format($d->texp,2,'.','');} ?></td>
<td><?php $incmthttl = $incmthttl + round($d->minc); echo number_format($d->minc,2,'.',''); ?></td>
<td><?php $expmthttl = $expmthttl + round($d->mexp); echo number_format($d->mexp,2,'.',''); ?></td>
<td><?php $incyrttl = $incyrttl + round($d->yinc); echo number_format($d->yinc,2,'.',''); ?></td>
<td><?php $expyrttl = $expyrttl + round($d->yexp); echo number_format($d->yexp,2,'.',''); ?></td>
</tr>
<?php }
} ?>
<?php } ?>
</tbody>
<tfoot width="100%">
<tr>
<td><b><?php echo "TOTAL" ?></b></td>
<td><b><?php echo number_format($incdayttl,2,'.',''); ?></b></td>
<td><b><?php echo number_format($expdayttl,2,'.',''); ?></b></td>
<td><b><?php echo number_format($incmthttl,2,'.',''); ?></b></td>
<td><b><?php echo number_format($expmthttl,2,'.',''); ?></b></td>
<td><b><?php echo number_format($incyrttl,2,'.',''); ?></b></td>
<td><b><?php echo number_format($expyrttl,2,'.',''); ?></b></td>
</tr>
</tfoot>
<?php } ?>
</table>
</div>
</div>

View File

@ -19,6 +19,7 @@ $towhom1='';
$id='';
$file1='';
$document = '';
$supplier='';
//print_r( $DepDetails);
//print_r($dropdownvalues);die();
if(!empty($DepDetails))
@ -56,6 +57,7 @@ if(!empty($DepDetails))
$IGST1=$ded->igst;
$Description1=$ded->description;
$towhom1=$ded->towhom;
$supplier=$ded->Supplier_id;
$balancetoupdate=($bankamount)-($alreadypaid+$alreadyreceived);
//$file1=$ded->document;
//echo $file1;
@ -155,10 +157,11 @@ $('#merchant').autocomplete({
$(function() {
//$('#supplier').select2();
var t = [];
var ex = [];
var inc = [];
var supp = [];
t= <?php echo json_encode($dropdownvalues)?>;
//$("#accode").prepend( $('<option></option>').val('<?php echo $accountcode1?>').html('<?php echo $dropdown?>'));
@ -171,7 +174,14 @@ $(function() {
$('#accode option[value="<?php echo $accountcode1?>"]').prop('selected', true);
supp = <?php echo json_encode($getsupplier)?>;
$.each(supp,function(s,supp){
$("#supplier").append( $('<option></option>').val(supp.SupplierID).html(supp.SupplierID+' - '+supp.SupplierName));
});
$('#supplier option[value="<?php echo $supplier?>"]').prop('selected', true);
var gst = '<?php echo $gst1 ?>';
//alert(gst);
if(gst == '1'){
@ -381,6 +391,16 @@ function loadAccountType(id)
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<b><span for="Suppliername">Select Supplier:</span> </b><span style="color:red">*</span></br></br>
<select class="form-control select2 required" id="supplier" name="supplier">
<option value="-1">Select Supplier</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">