<?php
declare(strict_types=1);

namespace CronJobs;

use App\Core\Database;
use App\Core\Logger;

/**
 * Monthly: runs depreciation for all active assets.
 * Runs on the 1st of each month.
 */
class MonthlyDepreciationJob
{
    private Database $db;
    public function __construct(Database $db) { $this->db = $db; }

    public function shouldRun(): bool
    {
        return (int) date('j') === 1;
    }

    public function run(): array
    {
        $month = date('Y-m');

        $count = \App\Modules\Inventory\Services\DepreciationService::runMonthlyDepreciation($month);

        Logger::info("Monthly depreciation for {$month}: {$count} asset(s) processed");

        return [
            'period_month'     => $month,
            'assets_processed' => $count,
        ];
    }
}
