Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
WorkTimeEntry
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isCountable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\WorkTime\Domain\Model;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Domain entity representing a Work Time (Timesheet) entry.
13 *
14 * @package App\Modules\WorkTime\Domain\Model
15 */
16final readonly class WorkTimeEntry
17{
18    /**
19     * @param int         $id              Unique identifier of the entry.
20     * @param string      $subject         Work activity title or description summary.
21     * @param string      $status          Approval status (pending, accepted, rejected).
22     * @param string      $workTimeType    Work time classification code.
23     * @param string      $startDate       Start timestamp.
24     * @param string      $endDate         End timestamp.
25     * @param float       $durationHours   Logged duration in hours.
26     * @param int         $durationMinutes Logged duration in minutes.
27     * @param int|null    $projectId       Optional associated project ID.
28     * @param int|null    $stageId         Optional associated project stage ID.
29     * @param int|null    $taskId          Optional associated project task ID.
30     * @param int|null    $companyId       Optional associated company or partner ID.
31     * @param int|null    $contractId      Optional associated contract ID.
32     * @param int|null    $ticketId        Optional associated ticket ID.
33     * @param int         $owner           Assigned user identifier.
34     * @param bool        $isBillable      Whether the time is billable to the client.
35     * @param float|null  $hourlyRate      Optional hourly billing rate.
36     * @param float|null  $totalAmount     Computed total billing amount.
37     */
38    public function __construct(
39        public int $id,
40        public string $subject,
41        public string $status,
42        public string $workTimeType,
43        public string $startDate,
44        public string $endDate,
45        public float $durationHours,
46        public int $durationMinutes,
47        public ?int $projectId = null,
48        public ?int $stageId = null,
49        public ?int $taskId = null,
50        public ?int $companyId = null,
51        public ?int $contractId = null,
52        public ?int $ticketId = null,
53        public int $owner = 1,
54        public bool $isBillable = true,
55        public ?float $hourlyRate = null,
56        public ?float $totalAmount = null,
57    ) {
58    }
59
60    /**
61     * Checks whether this work time entry has been approved and counts toward project totals.
62     *
63     * @return bool True if accepted or pending, false if rejected.
64     */
65    public function isCountable(): bool
66    {
67        return $this->status !== 'rejected';
68    }
69}