<?php

namespace App\Modules\Billing\Repositories;

use App\Core\Base\BaseRepository;
use App\Models\Invoice;
use Illuminate\Database\Eloquent\Collection;

class InvoiceRepository extends BaseRepository
{
    public function __construct(Invoice $model)
    {
        parent::__construct($model);
    }

    public function getDailyRevenue(string $date): float
    {
        return $this->model->whereDate('invoice_date', $date)
            ->where('status', 'Paid')
            ->sum('total_amount');
    }

    public function getDueInvoices(): Collection
    {
        return $this->model->where('due_amount', '>', 0)->get();
    }
}
