mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
refactor due status
This commit is contained in:
@ -15,6 +15,7 @@ class Invoice extends Model
|
||||
const STATUS_OVERDUE = 'OVERDUE';
|
||||
const STATUS_COMPLETED = 'COMPLETED';
|
||||
|
||||
const STATUS_DUE = 'DUE';
|
||||
const STATUS_UNPAID = 'UNPAID';
|
||||
const STATUS_PARTIALLY_PAID = 'PARTIALLY_PAID';
|
||||
const STATUS_PAID = 'PAID';
|
||||
@ -189,6 +190,14 @@ class Invoice extends Model
|
||||
return $query->where('invoices.paid_status', $status);
|
||||
}
|
||||
|
||||
public function scopeWhereDueStatus($query, $status)
|
||||
{
|
||||
return $query->whereIn('invoices.paid_status', [
|
||||
self::STATUS_UNPAID,
|
||||
self::STATUS_PARTIALLY_PAID
|
||||
]);
|
||||
}
|
||||
|
||||
public function scopeWhereInvoiceNumber($query, $invoiceNumber)
|
||||
{
|
||||
return $query->where('invoices.invoice_number', 'LIKE', '%'.$invoiceNumber.'%');
|
||||
@ -232,6 +241,8 @@ class Invoice extends Model
|
||||
$filters->get('status') == self::STATUS_PAID
|
||||
) {
|
||||
$query->wherePaidStatus($filters->get('status'));
|
||||
} elseif ($filters->get('status') == self::STATUS_DUE) {
|
||||
$query->whereDueStatus($filters->get('status'));
|
||||
} else {
|
||||
$query->whereStatus($filters->get('status'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user