diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index 77ce2fab..6b0a3df1 100644 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -316,7 +316,7 @@ class cashbook extends BaseController $credit=$sheet->getCell('G'.$x)->getValue(); $balance=$sheet->getCell('H'.$x)->getValue(); - // $IsActive=0; + // $IsActive=0; $filedataupload= array('reportdate'=>$Date1,'valuedate'=>$Date2,'chequeNo'=>$cod,'Narration'=>$narration,'Cod'=> $chqno,'Debit'=>$debit,'Credit'=>$credit,'cbalancetocleared'=>$credit,'Balance'=>$balance,'Bankname'=>$bank,'IsActive'=> $IsActive); @@ -1395,22 +1395,43 @@ class cashbook extends BaseController { $this->global['pageTitle'] = 'Siddharth : Bank Debit Report'; - if ($this->input->post('btn_submit')) - { - $Supplierid = $this->input->post('SupplierName'); - $fdate = $this->input->post('from_date'); - $tdate = $this->input->post('to_date'); - //$data['cash'] = $_GET['sid']; - //$data['bankid'] = $_GET['d']; - $data['bankdepit'] = $this->cashbook_model->debitbankstatemet($Supplierid,$fdate,$tdate); - } - - - $data['getsupplier'] = $this->cashbook_model->getsupplier(); - $this->loadViews("bankamountunpaid",$this->global,$data,NULL); + + $data['bankdepit'] = $this->cashbook_model->suppliertotal(); + // } + $data['finyear']=$this->cashbook_model->report_finyear(); + $data['getsupplier'] = $this->cashbook_model->getsupplier(); + $this->loadViews("bankunpaidsupp",$this->global,$data,NULL); //die(); } + public function supplierwise() + { + $this->global['pageTitle'] = 'Siddharth : Bank Debit Report'; + + $sd=$this->input->post('supplierid'); + if ($this->input->post('btn_submit')) + { + + $ab=$this->input->post('financialyear'); + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); + $m=$this->input->post('month'); + $fdate = $this->input->post('from_date'); + $tdate = $this->input->post('to_date'); + $data['bankdepit'] = $this->cashbook_model->amountunpaidfilter($sd,$fa,$aa,$m,$fdate,$tdate); + } + else + { + $supplierid1 = $_GET['sid']; + $data['bankdepit'] = $this->cashbook_model->amountunpaid($supplierid1); + } + $data['finyear']=$this->cashbook_model->report_finyear(); + // $data['getsupplier'] = $this->cashbook_model->getsupplier(); + $this->loadViews("bankamountunpaid",$this->global,$data,NULL); + //die(); + + + } public function amountreceived() { diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index 399b4a9f..b2cf21f4 100644 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -348,7 +348,7 @@ function clearedcreditbalance(){ function debitbankstatemet($Supplierid,$fdate,$tdate){ - $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,id.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName, + $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate as CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName, round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)), (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst, @@ -422,6 +422,20 @@ $sql.="group by id.IGRItemNo"; return $query->result(); } + function bank_finyear(){ + + $sql="SELECT + CASE WHEN MONTH(MaterialRcvdDate)>=4 + THEN concat(YEAR(MaterialRcvdDate), '-',YEAR(MaterialRcvdDate)+1) + ELSE concat(YEAR(MaterialRcvdDate)-1,'-', YEAR(MaterialRcvdDate)) + END AS financial_year + FROM T_IGR_Master + GROUP BY financial_year"; + $query = $this->db->query($sql); + return $query->result(); + + } + // function debitbankstatemet($Supplierid,$fdate,$tdate) // { // echo $Supplierid; @@ -459,9 +473,10 @@ $sql.="group by id.IGRItemNo"; // return $query->result(); // } - function amountunpaid($Supplierid,$fdate,$tdate) - { - $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,id.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName, + + function suppliertotal() + { + $sql="select sd.SupplierName as SupplierName,sd.SupplierID, round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)), (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst, @@ -480,6 +495,95 @@ round(ifnull(if(POType = 'REVENUE', round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package, +sum(round(( +if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), + (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) +- round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), + (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2)) as total +from T_IGR_Master im +left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode +join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO +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 +left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo +where im.IGRStatus = 'ST027' and id.BankStatus ='ST072'"; + + +if ($Supplierid!= ''){ + + $sql.="and sd.SupplierID = '".$Supplierid."'"; + + } + + + if ($fdate and $tdate != ''){ + $fromd= date("Y-m-d",strtotime($fdate)); + $tod=date("Y-m-d",strtotime($tdate)); + + $sql.="and date(im.CreatedDate) >= '".$fromd."' + and date(im.CreatedDate) <= '".$tod."'"; + + } + + +$sql.="group by sd.SupplierName"; +//echo $sql; + $query = $this->db->query($sql); + return $query->result(); + + } + // function seperatesupplier($supplierid) + + // { + // $this->db->select('pom.PONO,supp.SupplierName,pom.TotalOrderValue'); + // $this->db->from ('T_SupplierDetailsN supp'); + // $this->db->join('T_PurchaseOrder_Master pom','pom.SupplierID=supp.SupplierID'); + // $this->db->where_in('pom.Status',[ST044,ST056]); + // $this->db->where('supp.SupplierID',$supplierid); + // //$this->db->group_by('supp.SupplierName'); + // $query = $this->db->get(); + // return $query->result(); + // } +function amountunpaid($supplierid) + { + + $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID,im.DeliveryChellanOrInvoiceNo, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterSGST), +(id.QuantityAsPerInvoice * pl.Rate)+(st.After_SGST )),0),2) as sgst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterCGST), +(id.QuantityAsPerInvoice * pl.Rate)+(st.After_CGST)),0),2) as cgst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterIGST), +(id.QuantityAsPerInvoice * pl.Rate)+(st.After_IGST)),0),2) as igst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount), +(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue), +(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package, + round(( if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), @@ -509,22 +613,86 @@ 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 left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo -where im.IGRStatus = 'ST027' and id.BankStatus ='ST072' "; +where im.IGRStatus = 'ST027' and id.BankStatus ='ST072' and sd.SupplierID='".$supplierid."'"; +$sql.="group by id.IGRItemNo"; +//echo $sql; + $query = $this->db->query($sql); + return $query->result(); + } + function amountunpaidfilter($sd,$fa,$aa,$m,$fdate,$tdate) + { + + $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID,im.DeliveryChellanOrInvoiceNo, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterSGST), +(id.QuantityAsPerInvoice * pl.Rate)+(st.After_SGST )),0),2) as sgst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterCGST), +(id.QuantityAsPerInvoice * pl.Rate)+(st.After_CGST)),0),2) as cgst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterIGST), +(id.QuantityAsPerInvoice * pl.Rate)+(st.After_IGST)),0),2) as igst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount), +(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue), +(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package, + +round(( +if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), + (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) +- round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), + (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total +from T_IGR_Master im +left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode +join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO +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 +left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo +where im.IGRStatus = 'ST027' and id.BankStatus ='ST072' and sd.SupplierID='".$sd."'"; -if ($Supplierid!= ''){ + + if ($fa and $aa != ''){ - $sql.="and sd.SupplierID = '".$Supplierid."'"; + //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + $sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; } + if ($m!= ''){ + + //$sql.="and monthname(im.CreatedDate) = '".$m."'"; + $sql.="and monthname(im.MaterialRcvdDate) = '".$m."'"; + } if ($fdate and $tdate != ''){ $fromd= date("Y-m-d",strtotime($fdate)); $tod=date("Y-m-d",strtotime($tdate)); - $sql.="and date(im.CreatedDate) >= '".$fromd."' - and date(im.CreatedDate) <= '".$tod."'"; + $sql.="and date(im.MaterialRcvdDate) >= '".$fromd."' + and date(im.MaterialRcvdDate) <= '".$tod."'"; } @@ -533,6 +701,7 @@ $sql.="group by id.IGRItemNo"; //echo $sql; $query = $this->db->query($sql); return $query->result(); + } function bankinvoice($Customer,$fdate,$tdate) { @@ -619,7 +788,7 @@ function receiptdata() $this->db->join ('T_PurchaseOrder_BillUpload bu','bm.PONO=bu.PONO','left'); if($fdate!='' && $tdate!='') { - $this->db->where('bm.Podate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); + $this->db->where('igrm.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); } if($SupplierName!='') { diff --git a/application/views/bankamountpaid.php b/application/views/bankamountpaid.php index bc2d2978..500e75ff 100644 --- a/application/views/bankamountpaid.php +++ b/application/views/bankamountpaid.php @@ -97,6 +97,17 @@ if(!empty($amountpaid))