|
|
|
|
@ -429,543 +429,131 @@ function clearedcreditbalance(){
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function debitbankstatemet(){
|
|
|
|
|
|
|
|
|
|
$this->db->select('pom.PONO,pom.TotalOrderValue,pom.PODate,sd.SupplierName,sd.SupplierID,
|
|
|
|
|
bm.Balancetopay,bm.Amountpaid');
|
|
|
|
|
$this->db->from ('T_PurchaseOrder_Master pom');
|
|
|
|
|
$this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO','left');
|
|
|
|
|
$this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left');
|
|
|
|
|
$this->db->where('pom.Status','ST027');
|
|
|
|
|
$this->db->or_where('pom.Status','ST056');
|
|
|
|
|
$this->db->where('pom.Paymentstatus !=','ST070');
|
|
|
|
|
$this->db->group_by('pom.PONO');
|
|
|
|
|
$query = $this->db->get();
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// function debitbankstatemet($Supplierid,$fdate,$tdate){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $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,sd.SupplierID as 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,
|
|
|
|
|
// round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
|
|
|
// round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),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 and br.IsActive = 1
|
|
|
|
|
// where im.IGRStatus = 'ST027' and id.BankStatus!='ST070'";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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 id.IGRItemNo";
|
|
|
|
|
// //echo $sql;
|
|
|
|
|
// $query = $this->db->query($sql);
|
|
|
|
|
// return $query->result();
|
|
|
|
|
// }
|
|
|
|
|
// function debitbankstatemet1(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $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,sd.SupplierID as 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,
|
|
|
|
|
// round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
|
|
|
// round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
|
|
|
// (id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),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 !='ST070'";
|
|
|
|
|
|
|
|
|
|
// $sql.=" group by id.IGRItemNo";
|
|
|
|
|
// //echo $sql;
|
|
|
|
|
// $query = $this->db->query($sql);
|
|
|
|
|
// 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;
|
|
|
|
|
// $status='ST057';
|
|
|
|
|
// //echo $tdate;
|
|
|
|
|
// //die();
|
|
|
|
|
// // +rt.SGST/100+rt.IGST/100))
|
|
|
|
|
// //$Supplierid;
|
|
|
|
|
// $this->db->distinct();
|
|
|
|
|
// $this->db->select('igr.PONO,igrli.IGRItemNo,igr.IGRNO,supp.SupplierName,igrli.CreatedDate,BR.Balancetopay,BR.Amountpaid,pom.Status,igrli.QuantityAsPerInvoice ,poli.Rate,(igrli.QuantityAsPerInvoice * poli.Rate) as total,((igrli.QuantityAsPerInvoice * poli.Rate)+(rt.FreightValue)-(rt.DiscountValue))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.CGST/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.SGST as rtsgst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.IGST as rtigst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.IGST as stigst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.SGST as stsgst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.CGST /100)) as finalamount');
|
|
|
|
|
|
|
|
|
|
// $this->db->from ('T_IGR_Details igrli');
|
|
|
|
|
// $this->db->join('T_IGR_Master igr','igrli.IGRNO = igr.IGRNO','left');
|
|
|
|
|
// $this->db->join('T_PurchaseOrder_LineItem poli','igr.PONO= poli.PONO and igrli.MaterialCode=poli.MaterialCode');
|
|
|
|
|
// $this->db->join('T_PurchaseOrder_Master pom','poli.PONO =pom.PONO');
|
|
|
|
|
// $this->db->join('T_SupplierDetailsN supp','pom.SupplierID =supp.SupplierID');
|
|
|
|
|
// $this->db->join('T_Revenue_Tax rt','poli.LineItemNo=rt.LineItemNo','left');
|
|
|
|
|
// $this->db->join('T_Service_Tax st','poli.LineItemNo=st.LineItemNo','left');
|
|
|
|
|
// $this->db->join ('T_Bankporeport BR','igrli.IGRItemNo = BR.IGRLineItemNo','left');
|
|
|
|
|
// if ($fdate and $tdate != ''){
|
|
|
|
|
// $fromdate= date("Y-m-d",strtotime($fdate));
|
|
|
|
|
// $todate=date("Y-m-d",strtotime($tdate));
|
|
|
|
|
// $date = "date(igr.CreatedDate) >= '".$fromdate."'
|
|
|
|
|
// and date(igr.CreatedDate) <= '".$todate."'";
|
|
|
|
|
// $this->db->where($date);
|
|
|
|
|
// }
|
|
|
|
|
// if ($Supplierid != ''){
|
|
|
|
|
// $this->db->where('supp.SupplierID',$Supplierid);
|
|
|
|
|
// }
|
|
|
|
|
// $this->db->where_in('igr.IGRStatus','ST027');
|
|
|
|
|
// //$this->db->where_in('pom.Status',[ST044,ST056]);
|
|
|
|
|
// $this->db->where('igrli.BankStatus !=','ST070');
|
|
|
|
|
// $this->db->group_by('igrli.IGRItemNo');
|
|
|
|
|
// $query = $this->db->get();
|
|
|
|
|
// return $query->result();
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
function suppliertotal()
|
|
|
|
|
{
|
|
|
|
|
$sql="select sd.SupplierName as SupplierName,sd.SupplierID,im.CreatedDate,
|
|
|
|
|
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,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),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,
|
|
|
|
|
|
|
|
|
|
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.SupplierID";
|
|
|
|
|
//echo $sql;
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function suppliertotalfilter($fa,$aa,$m,$fdate,$tdate)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql="select sd.SupplierName as SupplierName,sd.SupplierID,im.MaterialRcvdDate,
|
|
|
|
|
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,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
|
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
|
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),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,
|
|
|
|
|
|
|
|
|
|
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 ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
//$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')";
|
|
|
|
|
|
|
|
|
|
$status= array('ST027','ST056');
|
|
|
|
|
$this->db->select('pom.PONO,sum(pom.TotalOrderValue) as TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate');
|
|
|
|
|
$this->db->from ('T_PurchaseOrder_Master pom');
|
|
|
|
|
$this->db->join('T_IGR_Master im','pom.PONO=im.PONO','left');
|
|
|
|
|
$this->db->join('T_SupplierDetailsN sd','pom.SupplierID=sd.SupplierID','left');
|
|
|
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
|
|
|
$this->db->where('pom.Paymentstatus',NO_PAIDIGR);
|
|
|
|
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
$year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
|
|
|
$this->db->where($year);
|
|
|
|
|
}
|
|
|
|
|
if ($m!= ''){
|
|
|
|
|
|
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
|
|
|
$sql.="and monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
|
$month="monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
|
$this->db->where($month);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($fdate and $tdate != ''){
|
|
|
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
|
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
|
|
|
|
|
|
$sql.="and date(im.MaterialRcvdDate) >= '".$fromd."'
|
|
|
|
|
and date(im.MaterialRcvdDate) <= '".$tod."'";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql.="group by sd.SupplierName";
|
|
|
|
|
//echo $sql;
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
if($fdate!='' && $tdate!='')
|
|
|
|
|
{
|
|
|
|
|
$this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
|
|
|
}
|
|
|
|
|
// $this->db->group_by(array("sd.SupplierID", "pom.PONO"));
|
|
|
|
|
$this->db->group_by('sd.SupplierID','pom.PONO');
|
|
|
|
|
//$this->db->group_by('pom.PONO');
|
|
|
|
|
$query = $this->db->get();
|
|
|
|
|
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function amountunpaid($supplierid,$fa,$aa,$m,$fdate,$tdate)
|
|
|
|
|
function amountunpaid($supplierid1,$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,im.DeliveryChellanDate,im.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,bu.FilePath as poFilePath ,bu.BillNo,inward.FilePath as iwFpath, sd.SupplierID,im.DeliveryChellanOrInvoiceNo,DATEDIFF(CURDATE(),id.CreatedDate)as days,
|
|
|
|
|
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
|
|
|
|
|
left join T_Inwardgateregister_fileupload inward on inward.IGRNO =im.IGRNO
|
|
|
|
|
left join T_PurchaseOrder_BillUpload bu on bu.PONO=pm.PONO
|
|
|
|
|
where im.IGRStatus = 'ST027' and id.BankStatus ='ST072' and sd.SupplierID='".$supplierid."'";
|
|
|
|
|
$status= array('ST027','ST056');
|
|
|
|
|
$this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate,
|
|
|
|
|
im.IGRNO');
|
|
|
|
|
$this->db->from('T_PurchaseOrder_Master pom');
|
|
|
|
|
//$this->db->join('T_PurchaseOrder_BillUpload bu','pom.PONO=bu.PONO','left');,inward.FilePath as iwFpath,bu.FilePath as poFilePath
|
|
|
|
|
$this->db->join('T_IGR_Master im','im.PONO = pom.PONO','left');
|
|
|
|
|
$this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left');
|
|
|
|
|
// $this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left');
|
|
|
|
|
|
|
|
|
|
//$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =im.IGRNO','left');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
|
|
|
$this->db->where('pom.Paymentstatus ',NO_PAIDIGR);
|
|
|
|
|
$this->db->where('sd.SupplierID',$supplierid1);
|
|
|
|
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
//$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')";
|
|
|
|
|
|
|
|
|
|
$year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
|
|
|
$this->db->where($year);
|
|
|
|
|
}
|
|
|
|
|
if ($m!= ''){
|
|
|
|
|
|
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
|
|
|
$sql.="and monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
|
$month="monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
|
$this->db->where($month);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if($fdate!='' && $tdate!='')
|
|
|
|
|
{
|
|
|
|
|
$this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($fdate and $tdate != ''){
|
|
|
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
|
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
|
|
|
|
|
|
$sql.="and date(im.MaterialRcvdDate) >= '".$fromd."'
|
|
|
|
|
and date(im.MaterialRcvdDate) <= '".$tod."'";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$sql.="group by id.IGRItemNo";
|
|
|
|
|
//echo $sql;
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
//$this->db->group_by('pom.PONO');
|
|
|
|
|
$query = $this->db->get();
|
|
|
|
|
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,im.DeliveryChellanDate,im.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID,im.DeliveryChellanOrInvoiceNo,DATEDIFF(CURDATE(),id.CreatedDate)as days,
|
|
|
|
|
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,
|
|
|
|
|
$status= array('ST027','ST056');
|
|
|
|
|
$this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate,
|
|
|
|
|
im.IGRNO');
|
|
|
|
|
$this->db->from ('T_PurchaseOrder_Master pom');
|
|
|
|
|
//$this->db->join('T_PurchaseOrder_BillUpload bu','pom.PONO=bu.PONO','left');
|
|
|
|
|
$this->db->join('T_IGR_Master im','im.PONO=pom.PONO','left');
|
|
|
|
|
$this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left');
|
|
|
|
|
//$this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left');
|
|
|
|
|
|
|
|
|
|
//$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =im.IGRNO','left'); inward.FilePath as iwFpath,bu.FilePath as poFilePath,im.IGRNO
|
|
|
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
|
|
|
$this->db->where('pom.Paymentstatus',NO_PAIDIGR);
|
|
|
|
|
$this->db->where('sd.SupplierID',$sd);
|
|
|
|
|
|
|
|
|
|
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 ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
//$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 ($fa and $aa != ''){
|
|
|
|
|
$year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
|
|
|
$this->db->where($year);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($m!= ''){
|
|
|
|
|
|
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
|
|
|
$sql.="and monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
|
$month="monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
|
$this->db->where($month);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if($fdate!='' && $tdate!='')
|
|
|
|
|
{
|
|
|
|
|
$this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($fdate and $tdate != ''){
|
|
|
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
|
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
|
|
|
|
|
|
$sql.="and date(im.MaterialRcvdDate) >= '".$fromd."'
|
|
|
|
|
and date(im.MaterialRcvdDate) <= '".$tod."'";
|
|
|
|
|
|
|
|
|
|
// $this->db->group_by('pom.PONO');
|
|
|
|
|
$query = $this->db->get();
|
|
|
|
|
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql.="group by id.IGRItemNo";
|
|
|
|
|
//echo $sql;
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function bankinvoice($Customer,$fdate,$tdate)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_name,ic.client_id,BI.balancetoreceived,BI.amountreceived');
|
|
|
|
|
$this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_name,ic.client_id,BI.balancetoreceived,BI.amountreceived');
|
|
|
|
|
$this->db->from ('ip_invoice_amounts iva');
|
|
|
|
|
$this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id');
|
|
|
|
|
$this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left');
|
|
|
|
|
@ -989,6 +577,36 @@ $sql.="group by id.IGRItemNo";
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function debitbankstatemet($Supplierid,$fdate,$tdate)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$status= array('ST027','ST056');
|
|
|
|
|
$this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate,
|
|
|
|
|
bm.Balancetopay,bm.Amountpaid,im.IGRNO');
|
|
|
|
|
$this->db->from ('T_PurchaseOrder_Master pom');
|
|
|
|
|
$this->db->join('T_IGR_Master im','im.PONO=pom.PONO','left');
|
|
|
|
|
$this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left');
|
|
|
|
|
$this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left');
|
|
|
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
|
|
|
$this->db->where('pom.Paymentstatus !=','ST070');
|
|
|
|
|
if ($Supplierid != ''){
|
|
|
|
|
$this->db->where('sd.SupplierID',$Supplierid);
|
|
|
|
|
}
|
|
|
|
|
if($fdate and $tdate != ''){
|
|
|
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
|
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
|
|
|
$date = "date(im.CreatedDate) >= '".$fromdate."'
|
|
|
|
|
and date(im.CreatedDate) <= '".$todate."'";
|
|
|
|
|
$this->db->WHERE($date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->db->group_by('pom.PONO');
|
|
|
|
|
$query = $this->db->get();
|
|
|
|
|
|
|
|
|
|
return $query->result();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function receivedamount($Customer,$fdate,$tdate)
|
|
|
|
|
{
|
|
|
|
|
// $status='ST065';
|
|
|
|
|
@ -1063,7 +681,7 @@ function receiptdata()
|
|
|
|
|
{
|
|
|
|
|
$this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.Totalpoamount,bm.Podate,bm.BankDate,
|
|
|
|
|
bm.Balancetopay,bm.Amountpaid,bm.IGRNO,bm.IGRLineItemNo,br.Balancetocleared,br.Clearbalance,
|
|
|
|
|
inward.FilePath as igrfile,bu.FilePath pofile');
|
|
|
|
|
inward.FilePath as igrfile,bu.FilePath as pofile');
|
|
|
|
|
$this->db->from ('T_Bankmappingpo bm');
|
|
|
|
|
// $this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo');
|
|
|
|
|
$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =bm.IGRNO','left');
|
|
|
|
|
@ -1872,15 +1490,11 @@ function receiptdata()
|
|
|
|
|
$this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.SupplierID,sum(bm.Totalpoamount)as Totalpoamount,
|
|
|
|
|
bm.Balancetopay,sum(bm.Amountpaid) as Amountpaid,bm.Podate,bm.IGRLineItemNo,bm.BankDate');
|
|
|
|
|
$this->db->from ('T_Bankmappingpo bm');
|
|
|
|
|
//$this->db->join('T_bankreport br','br.ID=bm.mid');
|
|
|
|
|
//$this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo');
|
|
|
|
|
//$this->db->where('igr.BankStatus !=',ST072);
|
|
|
|
|
$this->db->where('bm.IsActive',1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
|
|
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
|
|
|
$year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')";
|
|
|
|
|
$this->db->where($year);
|
|
|
|
|
}
|
|
|
|
|
|