- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees) - Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue) - Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts - Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs - Remove legacy and dead CSV employee import/export code - Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation - Add comprehensive Pest unit, integration, and feature test coverage
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\Entities;
|
|
|
|
use Carbon\CarbonImmutable;
|
|
use Carbon\CarbonInterface;
|
|
use Domain\Models\ValueObjects\Email;
|
|
use Domain\Models\ValueObjects\Entities\ShopperId;
|
|
use Domain\Models\ValueObjects\Matricule;
|
|
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
use Domain\Models\ValueObjects\ShopperServiceCode;
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
|
use Shared\DDD\Entity;
|
|
|
|
/** @implements \Shared\DDD\Entity<\Domain\Models\ValueObjects\Entities\ShopperId> */
|
|
final readonly class Shopper implements Entity
|
|
{
|
|
public function __construct(
|
|
private readonly ShopperId $id,
|
|
public readonly Email $email,
|
|
public readonly Matricule $matricule,
|
|
public readonly string $nom,
|
|
public readonly string $prenom,
|
|
public readonly CarbonInterface $startDate,
|
|
public readonly ?CarbonInterface $endDate,
|
|
public readonly ShopperEstablishmentCode $etablissement,
|
|
public readonly ShopperSiteCode $site,
|
|
public readonly ShopperServiceCode $service
|
|
) {
|
|
if (trim($nom) === '') {
|
|
throw new \DomainException('nom cannot be empty');
|
|
}
|
|
if (trim($prenom) === '') {
|
|
throw new \DomainException('prenom cannot be empty');
|
|
}
|
|
}
|
|
|
|
#[\Override]
|
|
public function id(): ShopperId
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
return $this->endDate === null || $this->endDate->greaterThan(CarbonImmutable::now());
|
|
}
|
|
}
|