feat(billing): renewals, coupons, VAT numbering, billing cycles and invoice payment tracking
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
ea9a53f742
commit
25f23d541e
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Repositories\Invoice;
|
||||
|
||||
use App\Support\Billing\BillingDuplicateDetector;
|
||||
use App\Models\Invoice;
|
||||
use App\Repositories\BaseRepository;
|
||||
use App\Repositories\Concerns\FiltersBillingRecords;
|
||||
@@ -63,6 +64,7 @@ class InvoiceRepository extends BaseRepository implements InvoiceRepositoryInter
|
||||
}
|
||||
$model = $this->whereStatus($model, $data['status'] ?? null, ['unpaid' => 1, 'paid' => 2, 'cancel' => 3, 'overdue' => 4, 'refunded' => 5]);
|
||||
$model = $this->whereCreatedBetween($model, $data['date_from'] ?? null, $data['date_to'] ?? null);
|
||||
$model = $this->whereIsDuplicate($model, $data['duplicates'] ?? null, BillingDuplicateDetector::invoices(...));
|
||||
if (isset($data['filter']) && $data['filter'] !== '') {
|
||||
$search = $data['filter'];
|
||||
$model = $model->where(function ($query) use ($search) {
|
||||
@@ -73,6 +75,7 @@ class InvoiceRepository extends BaseRepository implements InvoiceRepositoryInter
|
||||
->orWhere('email', 'like', "%{$search}%");
|
||||
});
|
||||
$this->whereOrderItemNameLike($query, 'order.orderItems', $search);
|
||||
$this->whereContractFileLike($query, 'attachments', $search);
|
||||
});
|
||||
}
|
||||
if (isset($data['relations'])) {
|
||||
@@ -96,6 +99,10 @@ class InvoiceRepository extends BaseRepository implements InvoiceRepositoryInter
|
||||
});
|
||||
}
|
||||
}
|
||||
$model = $this->applySort($model, $data['sort_by'] ?? null, $data['sort_order'] ?? null, [
|
||||
'invoice_number', 'sub_total', 'tax', 'total', 'status', 'created_at', 'due_date', 'paid_at', 'customer', 'outstanding',
|
||||
]);
|
||||
|
||||
if (count($withCount) > 0) {
|
||||
$model = $model->withCount($withCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user