Added unpaid list status filter

This commit is contained in:
Hillel Coren 2017-02-07 16:26:23 +02:00
parent a56a5e778d
commit f4ca82053e
3 changed files with 9 additions and 1 deletions

View File

@ -179,7 +179,8 @@ if (! defined('APP_NAME')) {
define('INVOICE_STATUS_APPROVED', 4);
define('INVOICE_STATUS_PARTIAL', 5);
define('INVOICE_STATUS_PAID', 6);
define('INVOICE_STATUS_OVERDUE', 7);
define('INVOICE_STATUS_OVERDUE', -1);
define('INVOICE_STATUS_UNPAID', -2);
define('PAYMENT_STATUS_PENDING', 1);
define('PAYMENT_STATUS_VOIDED', 2);

View File

@ -1437,6 +1437,7 @@ class Invoice extends EntityModel implements BalanceAffecting
}
if ($entityType == ENTITY_INVOICE) {
$statuses[INVOICE_STATUS_UNPAID] = trans('texts.unpaid');
$statuses[INVOICE_STATUS_OVERDUE] = trans('texts.overdue');
}

View File

@ -96,6 +96,12 @@ class InvoiceRepository extends BaseRepository
}
$query->orWhere('invoice_status_id', '=', $status);
}
if (in_array(INVOICE_STATUS_UNPAID, $statuses)) {
$query->orWhere(function ($query) use ($statuses) {
$query->where('invoices.balance', '>', 0)
->where('invoices.is_public', '=', true);
});
}
if (in_array(INVOICE_STATUS_OVERDUE, $statuses)) {
$query->orWhere(function ($query) use ($statuses) {
$query->where('invoices.balance', '>', 0)