diversen nav opmerkingen

This commit is contained in:
2018-04-21 16:51:01 +02:00
parent 8e3649768b
commit 9187742658
18 changed files with 339 additions and 227 deletions
+17 -8
View File
@@ -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;
}
}