fix add selling to current festival in api call from dashboard

This commit is contained in:
Tykayn 2025-02-26 14:51:48 +01:00 committed by tykayn
parent 7e120c030b
commit 457cafdaef
10 changed files with 174 additions and 90 deletions

View file

@ -7,58 +7,87 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(
operations: [
new GetCollection(normalizationContext: ['groups' => ['festival:read']]),
new Get(normalizationContext: ['groups' => ['festival:read', 'festival:item:read']]),
new Post(denormalizationContext: ['groups' => ['festival:write']]),
new Put(denormalizationContext: ['groups' => ['festival:write']])
],
paginationEnabled: false
)]
#[ORM\Entity(repositoryClass: FestivalRepository::class)]
class Festival
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['festival:read', 'selling:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['festival:read', 'festival:write', 'selling:read'])]
private ?string $name = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?\DateTimeInterface $date_start = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['festival:read', 'festival:write'])]
private ?\DateTimeInterface $date_end = null;
/**
* @var Collection<int, User>
*/
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'currentFestival')]
#[Groups(['festival:read'])]
private Collection $users;
#[ORM\ManyToOne(inversedBy: 'festivals')]
#[Groups(['festival:read', 'festival:write'])]
private ?User $user = null;
#[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $fraisInscription = null;
#[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $fondDeCaisseAvant = null;
#[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $fondDeCaisseApres = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['festival:read', 'festival:write'])]
private ?\DateTimeInterface $dateCreation = null;
/**
* @var Collection<int, Selling>
*/
#[ORM\OneToMany(targetEntity: Selling::class, mappedBy: 'festival')]
#[Groups(['festival:item:read'])]
private Collection $sellings;
#[ORM\ManyToOne(inversedBy: 'festivals')]
#[Groups(['festival:read', 'festival:write'])]
private ?SerieFestival $serieFestival = null;
#[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?float $chiffreAffaire = null;
#[ORM\Column(nullable: true)]
#[Groups(['festival:read', 'festival:write'])]
private ?int $clientsCount = null;
public function __construct()

View file

@ -5,52 +5,77 @@ namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource(paginationEnabled: false)]
#[ApiResource(
operations: [
new GetCollection(normalizationContext: ['groups' => ['selling:read']]),
new Get(normalizationContext: ['groups' => ['selling:read', 'selling:item:read']]),
new Post(denormalizationContext: ['groups' => ['selling:write']]),
new Put(denormalizationContext: ['groups' => ['selling:write']])
],
paginationEnabled: false
)]
#[ORM\Entity(repositoryClass: SellingRepository::class)]
class Selling
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['selling:read'])]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['selling:read', 'selling:write'])]
private ?string $note = null;
#[ORM\Column]
#[Groups(['selling:read', 'selling:write'])]
private ?float $sum = null;
#[ORM\Column(nullable: true)]
#[Groups(['selling:read', 'selling:write'])]
private ?float $reduction = null;
/**
* @var Collection<int, GroupOfProducts>
*/
#[ORM\ManyToMany(targetEntity: GroupOfProducts::class, mappedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private Collection $groupOfProducts;
/**
* @var Collection<int, Product>
*/
#[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private Collection $products;
#[ORM\ManyToOne(inversedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private ?Festival $festival = null;
#[ORM\Column(length: 255)]
#[Groups(['selling:read', 'selling:write'])]
private ?string $customer_info = null;
#[ORM\Column]
#[Groups(['selling:read', 'selling:write'])]
private ?float $paidByCustomer = null;
#[ORM\ManyToOne(inversedBy: 'sellings')]
#[Groups(['selling:read', 'selling:write'])]
private ?User $owner = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['selling:read', 'selling:write'])]
private ?\DateTimeInterface $date = null;