feat: Enhance ServiceClientResource and InvoiceRepository with additional data fields; remove unused SVG icons
This commit is contained in:
@@ -35,6 +35,8 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
|
||||
|
||||
public function createFromOrder(Order $order): Invoice
|
||||
{
|
||||
$maxMonths = $order->orderItems->max(fn($item) => $this->cycleToMonths($item->billing_cycle)) ?? 1;
|
||||
|
||||
$invoice = $this->model->create([
|
||||
'invoice_number' => OrderHelper::generateOrderNumber('INV'),
|
||||
'customer_id' => $order->customer_id,
|
||||
@@ -45,7 +47,7 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
|
||||
'tax' => 0,
|
||||
'total' => $order->total,
|
||||
'status' => InvoiceStatus::UNPAID->value,
|
||||
'due_date' => now()->addDays(3)->toDateString(),
|
||||
'due_date' => now()->addMonths($maxMonths)->toDateString(),
|
||||
]);
|
||||
|
||||
// Create one invoice_item per order_item line
|
||||
|
||||
@@ -18,7 +18,7 @@ class ServiceClientRepository extends BaseApiRepository implements ServiceClient
|
||||
public function getActiveServices(int $limit = 10)
|
||||
{
|
||||
return $this->model
|
||||
->with(['orderItem' => fn($q) => $q->with('product')])
|
||||
->with(['orderItem' => fn($q) => $q->with(['product', 'os.osGroup'])])
|
||||
->orderByRaw("FIELD(status, 'active', 'pending', 'suspended', 'expired', 'cancelled', 'terminated')")
|
||||
->orderBy('started_at', 'desc')
|
||||
->paginate($limit);
|
||||
|
||||
Reference in New Issue
Block a user