It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In RegisterIt looks like you're new here. If you want to get involved, click one of these buttons!
Hi there,
Here is a fix for Income by client showing 0. Navigate to
application/helpers/functions_helper.php
and locate
function income_by_client($id, $interval=null)
Replace code with this one
function income_by_client($id, $interval=null) { global $db; switch ($interval) { case 'this_month': $query = "SELECT client_id AS clientID, SUM(CASE WHEN invoice_status = 'Paid' THEN amount_paid ELSE 0 End) - SUM(CASE WHEN invoice_status = 'Refunded' THEN amount_due ELSE 0 End) AS TotalPaid FROM {$db->tables['invoices']} WHERE MONTH(date_paid) = MONTH(CURRENT_TIMESTAMP) AND YEAR(date_paid) = YEAR(CURRENT_TIMESTAMP) AND client_id={$id}"; return $db->get_row($query)->TotalPaid; break; case 'last_month': $query = "SELECT client_id AS clientID, SUM(CASE WHEN invoice_status = 'Paid' THEN amount_paid ELSE 0 End) - SUM(CASE WHEN invoice_status = 'Refunded' THEN amount_due ELSE 0 End) AS TotalPaid FROM {$db->tables['invoices']} WHERE MONTH(date_paid) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH ) AND YEAR(date_paid) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH ) AND client_id={$id}"; return $db->get_row($query)->TotalPaid; break; case 'latest_three_months': $query = "SELECT client_id AS clientID, SUM(CASE WHEN invoice_status = 'Paid' THEN amount_paid ELSE 0 End) - SUM(CASE WHEN invoice_status = 'Refunded' THEN amount_due ELSE 0 End) AS TotalPaid FROM {$db->tables['invoices']} WHERE date_paid >= last_day(NOW()) + INTERVAL 1 DAY - INTERVAL 3 MONTH AND client_id={$id}"; return $db->get_row($query)->TotalPaid; break; case 'this_year': $query = "SELECT client_id AS clientID, SUM(CASE WHEN invoice_status = 'Paid' THEN amount_paid ELSE 0 End) - SUM(CASE WHEN invoice_status = 'Refunded' THEN amount_due ELSE 0 End) AS TotalPaid FROM {$db->tables['invoices']} WHERE YEAR(date_paid) = YEAR(CURRENT_TIMESTAMP) AND client_id={$id}"; return $db->get_row($query)->TotalPaid; break; case 'last_year': $query = "SELECT client_id AS clientID, SUM(CASE WHEN invoice_status = 'Paid' THEN amount_paid ELSE 0 End) - SUM(CASE WHEN invoice_status = 'Refunded' THEN amount_due ELSE 0 End) AS TotalPaid FROM {$db->tables['invoices']} WHERE YEAR(date_paid) = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 YEAR)) AND client_id={$id}"; return $db->get_row($query)->TotalPaid; break; case 'all_dates': $query = "SELECT client_id AS clientID, SUM(CASE WHEN invoice_status = 'Paid' THEN amount_paid ELSE 0 End) - SUM(CASE WHEN invoice_status = 'Refunded' THEN amount_due ELSE 0 End) AS TotalPaid FROM {$db->tables['invoices']} WHERE YEAR(date_paid) IS NOT NULL AND client_id={$id}"; return $db->get_row($query)->TotalPaid; break; default: $query = "SELECT client_id AS clientID, SUM(CASE WHEN invoice_status = 'Paid' THEN amount_paid ELSE 0 End) - SUM(CASE WHEN invoice_status = 'Refunded' THEN amount_due ELSE 0 End) AS TotalPaid FROM {$db->tables['invoices']} WHERE MONTH(date_paid) = MONTH(CURRENT_TIMESTAMP) AND YEAR(date_paid) = YEAR(CURRENT_TIMESTAMP) AND client_id={$id}"; return $db->get_row($query)->TotalPaid; break; } }
Then open application/libraries/M_manager.php and locate public function credit_note_invoice( $invoice_number )
Update last lines to look like this:
'invoice_status' => 'Refunded', 'date_paid' => $invoice->date_paid, 'sent' => 'no',
If you have already generated credit note, don't worry. Open phpmyadmin, go to oc_invoices, find the refunded invoice and set the appropriate date so that it does not show null.
Feel free to contact me if you need help.
Thanks
Eric