48d1904d03
- 5 permissions commercial.suppliers.* (view/manage/accounting.view/accounting.manage/archive) dans CommercialModule::permissions() - 3 sources RBAC synchronisées (règle n°8) : sidebar.php (/suppliers + suppliers.view), personas.ts (user-full), SeedE2ECommand.php (miroir back) - Assignation par rôle dans RbacSeeder::MATRIX (§ 2.9, idempotent) : Bureau view+manage, Compta view+accounting.view+accounting.manage, Commerciale view+manage, Usine aucune, archive Admin seul - Sécurité des référentiels (tva_modes/payment_delays/payment_types/banks) élargie : view client OR view fournisseur
113 lines
3.5 KiB
PHP
113 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Module\Commercial\Domain\Entity;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Get;
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
use App\Module\Commercial\Infrastructure\Doctrine\DoctrineTvaModeRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
|
|
/**
|
|
* Mode de TVA applique a un client (France ventes, Export, Intracom) :
|
|
* referentiel statique seede par la migration M1 (Version20260601000000) et
|
|
* re-seede en dev/test par CommercialReferentialFixtures.
|
|
*
|
|
* Lecture seule au M1 (HP-M2-2) : seules GetCollection et Get sont exposees
|
|
* (ERP-56), sous la permission commercial.clients.view (elargie aux roles
|
|
* fournisseurs au M2 via commercial.suppliers.view, ERP-90) ; aucune ecriture
|
|
* declaree -> POST/PATCH/DELETE renvoient 405.
|
|
*
|
|
* Referentiel statique : pas de Timestampable/Blamable (whiteliste dans
|
|
* EntitiesAreTimestampableBlamableTest::EXCLUDED, comme CategoryType). Le
|
|
* groupe `client:read:accounting` permet d'embarquer le mode dans la reponse
|
|
* d'un Client (onglet Comptabilite) au lieu d'un IRI.
|
|
*/
|
|
#[ApiResource(
|
|
operations: [
|
|
new GetCollection(
|
|
security: "is_granted('commercial.clients.view') or is_granted('commercial.suppliers.view')",
|
|
normalizationContext: ['groups' => ['tva_mode:read']],
|
|
// Tri par defaut spec M1 § 4.7 : position ASC puis label ASC
|
|
// (ordre des selecteurs comptables) — provider Doctrine par defaut.
|
|
order: ['position' => 'ASC', 'label' => 'ASC'],
|
|
// ERP-72 : pagination serveur sur toute collection autonome. Le
|
|
// toggle client est desactive globalement, on l'active ici pour
|
|
// permettre ?pagination=false (alimenter un <MalioSelect> entier).
|
|
paginationClientEnabled: true,
|
|
),
|
|
new Get(
|
|
security: "is_granted('commercial.clients.view') or is_granted('commercial.suppliers.view')",
|
|
normalizationContext: ['groups' => ['tva_mode:read']],
|
|
),
|
|
],
|
|
security: "is_granted('commercial.clients.view') or is_granted('commercial.suppliers.view')",
|
|
)]
|
|
#[ORM\Entity(repositoryClass: DoctrineTvaModeRepository::class)]
|
|
#[ORM\Table(name: 'tva_mode')]
|
|
#[ORM\UniqueConstraint(name: 'uq_tva_mode_code', columns: ['code'])]
|
|
class TvaMode
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
#[Groups(['tva_mode:read', 'client:read:accounting'])]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 30)]
|
|
#[Groups(['tva_mode:read', 'client:read:accounting'])]
|
|
private ?string $code = null;
|
|
|
|
#[ORM\Column(length: 120)]
|
|
#[Groups(['tva_mode:read', 'client:read:accounting'])]
|
|
private ?string $label = null;
|
|
|
|
#[ORM\Column(options: ['default' => 0])]
|
|
#[Groups(['tva_mode:read'])]
|
|
private int $position = 0;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getCode(): ?string
|
|
{
|
|
return $this->code;
|
|
}
|
|
|
|
public function setCode(string $code): static
|
|
{
|
|
$this->code = $code;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getLabel(): ?string
|
|
{
|
|
return $this->label;
|
|
}
|
|
|
|
public function setLabel(string $label): static
|
|
{
|
|
$this->label = $label;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPosition(): int
|
|
{
|
|
return $this->position;
|
|
}
|
|
|
|
public function setPosition(int $position): static
|
|
{
|
|
$this->position = $position;
|
|
|
|
return $this;
|
|
}
|
|
}
|