diversen nav opmerkingen
This commit is contained in:
@@ -27,16 +27,25 @@ class Invoices_model extends MY_Model {
|
||||
public function getOutstandingPerProject( $projectID )
|
||||
{
|
||||
$this->sql = "
|
||||
SELECT (own_revenue + other_revenue) - SUM(INV.invoiceamount) AS outstanding
|
||||
FROM invoices INV
|
||||
JOIN projects PRJ
|
||||
ON PRJ.id = INV.project_id
|
||||
JOIN offers OFF
|
||||
ON PRJ.id = OFF.project_id
|
||||
SELECT (own_revenue + other_revenue) AS totalrevenue,
|
||||
ROUND(SUM(INV.invoiceamount * ((100 + vatrate) / 100)), 0) AS totalinvoiced,
|
||||
SUM(payed) AS payed
|
||||
FROM invoices INV
|
||||
JOIN projects PRJ
|
||||
ON PRJ.id = INV.project_id
|
||||
JOIN vats VTS
|
||||
ON VTS.id = INV.vat_id
|
||||
JOIN offers OFF
|
||||
ON PRJ.id = OFF.project_id
|
||||
LEFT JOIN (
|
||||
SELECT SUM(paymentamount) payed, invoice_id
|
||||
FROM payments
|
||||
) PAY
|
||||
ON INV.id = PAY.invoice_id
|
||||
WHERE PRJ.id = {$projectID} ";
|
||||
|
||||
$invoiced = $this->get_query_row( 'outstanding' );
|
||||
$invoiceDetails = $this->get_query_row();
|
||||
|
||||
return $invoiced;
|
||||
return $invoiceDetails;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user