<?php

namespace Modules\Vrc\Tests\Unit;

use Modules\Vrc\Services\Technician\ProductivityCalculator;
use PHPUnit\Framework\TestCase;

/** §6.8 productivity/commission math. */
class ProductivityCalculatorTest extends TestCase
{
    public function test_efficiency_and_commission(): void
    {
        // billed 8h, actual 600min=10h, revenue 2000, commission 5%
        $r = ProductivityCalculator::compute(8, 600, 2000, 5);
        $this->assertSame(8.0, $r['billed_hours']);
        $this->assertSame(10.0, $r['actual_hours']);
        $this->assertSame(0.8, $r['efficiency']);
        $this->assertSame(100.0, $r['commission']);
        $this->assertSame(2000.0, $r['billed_revenue']);
    }

    public function test_zero_actual_hours_gives_null_efficiency(): void
    {
        $r = ProductivityCalculator::compute(4, 0, 500, null);
        $this->assertNull($r['efficiency']);
        $this->assertSame(0.0, $r['commission']);
    }

    public function test_no_commission_pct(): void
    {
        $r = ProductivityCalculator::compute(2, 120, 300, null);
        $this->assertSame(2.0, $r['actual_hours']);
        $this->assertSame(1.0, $r['efficiency']);
        $this->assertSame(0.0, $r['commission']);
    }
}
