<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\CalculationsRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Post;
use App\Controller\CalculationsController;
#[ORM\Entity(repositoryClass: CalculationsRepository::class)]
#[ApiResource(
operations: [
new Get(),
new Post(),
new Delete(),
new GetCollection(),
new Put(),
new Post(
name: 'clear_calculations',
uriTemplate: '/calculations/clear',
controller: CalculationsController::class
)
],
normalizationContext: ['groups' => ['calculations:read']],
denormalizationContext: ['groups' => ['calculations:write', 'agreements:read', 'agreements:write']],
order: ['date' => 'ASC']
)]
#[ApiFilter(SearchFilter::class, properties: ['agreement.id' => 'exact'])]
class Calculations
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
private ?int $id = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(nullable: true)]
private ?float $initialBalance = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(nullable: true)]
private ?float $coming = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(nullable: true)]
private ?float $discharge = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(nullable: true)]
private ?float $finalBalance = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $movementDocument = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\ManyToOne(inversedBy: 'calculations')]
private ?Agreements $agreement = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $agreementType = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $typeMutualSettlements = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $oragnazationName = null;
#[Groups(['calculations:read', 'calculations:write', 'agreements:read', 'agreements:write'])]
#[ORM\ManyToOne(inversedBy: 'calculations')]
private ?Orders $orders = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getInitialBalance(): ?float
{
return $this->initialBalance;
}
public function setInitialBalance(?float $initialBalance): self
{
$this->initialBalance = $initialBalance;
return $this;
}
public function getComing(): ?float
{
return $this->coming;
}
public function setComing(?float $coming): self
{
$this->coming = $coming;
return $this;
}
public function getDischarge(): ?float
{
return $this->discharge;
}
public function setDischarge(?float $discharge): self
{
$this->discharge = $discharge;
return $this;
}
public function getFinalBalance(): ?float
{
return $this->finalBalance;
}
public function setFinalBalance(?float $finalBalance): self
{
$this->finalBalance = $finalBalance;
return $this;
}
public function getMovementDocument(): ?string
{
return $this->movementDocument;
}
public function setMovementDocument(?string $movementDocument): self
{
$this->movementDocument = $movementDocument;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getAgreement(): ?Agreements
{
return $this->agreement;
}
public function setAgreement(?Agreements $agreement): self
{
$this->agreement = $agreement;
return $this;
}
public function getAgreementType(): ?string
{
return $this->agreementType;
}
public function setAgreementType(?string $agreementType): self
{
$this->agreementType = $agreementType;
return $this;
}
public function getTypeMutualSettlements(): ?string
{
return $this->typeMutualSettlements;
}
public function setTypeMutualSettlements(?string $typeMutualSettlements): self
{
$this->typeMutualSettlements = $typeMutualSettlements;
return $this;
}
public function getOragnazationName(): ?string
{
return $this->oragnazationName;
}
public function setOragnazationName(?string $oragnazationName): self
{
$this->oragnazationName = $oragnazationName;
return $this;
}
public function getOrders(): ?Orders
{
return $this->orders;
}
public function setOrders(?Orders $orders): self
{
$this->orders = $orders;
return $this;
}
}