Commits

Jesse Terry committed b031655

Client balance no longer includes quote amounts. Fixes #14

Comments (0)

Files changed (1)

application/modules_core/clients/models/mdl_clients.php

 		SQL_CALC_FOUND_ROWS
 		mcb_clients.*,
 		mcb_clients.client_id as join_client_id,
-		(SELECT SUM(invoice_total) FROM mcb_invoice_amounts WHERE invoice_id IN (SELECT invoice_id FROM mcb_invoices WHERE client_id = join_client_id)) AS client_total_invoice,
-		IFNULL((SELECT SUM(payment_amount) FROM mcb_payments JOIN mcb_invoices ON mcb_invoices.invoice_id = mcb_payments.invoice_id WHERE mcb_invoices.client_id = mcb_clients.client_id), 0.00) AS client_total_payment,
+		(SELECT SUM(invoice_total) FROM mcb_invoice_amounts WHERE invoice_id IN (SELECT invoice_id FROM mcb_invoices WHERE client_id = join_client_id AND invoice_is_quote = 0)) AS client_total_invoice,
+		IFNULL((SELECT SUM(payment_amount) FROM mcb_payments JOIN mcb_invoices ON mcb_invoices.invoice_id = mcb_payments.invoice_id WHERE mcb_invoices.client_id = mcb_clients.client_id AND invoice_is_quote = 0), 0.00) AS client_total_payment,
 		(SELECT ROUND(client_total_invoice - client_total_payment, 2)) AS client_total_balance";
 
 		$this->primary_key = 'mcb_clients.client_id';