mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-13 11:54:32 +02:00
Started to move doctrine annotations to attributes (rector automated)
This commit is contained in:
parent
bb1285c35c
commit
0bc4699cdc
73 changed files with 483 additions and 604 deletions
|
@ -37,14 +37,12 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
|
||||
/**
|
||||
* This entity describes a currency that can be used for price information.
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="currencies", indexes={
|
||||
* @ORM\Index(name="currency_idx_name", columns={"name"}),
|
||||
* @ORM\Index(name="currency_idx_parent_name", columns={"parent_id", "name"}),
|
||||
* })
|
||||
*/
|
||||
#[UniqueEntity('iso_code')]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'currencies')]
|
||||
#[ORM\Index(name: 'currency_idx_name', columns: ['name'])]
|
||||
#[ORM\Index(name: 'currency_idx_parent_name', columns: ['parent_id', 'name'])]
|
||||
class Currency extends AbstractStructuralDBElement
|
||||
{
|
||||
public const PRICE_SCALE = 5;
|
||||
|
@ -52,53 +50,52 @@ class Currency extends AbstractStructuralDBElement
|
|||
/**
|
||||
* @var BigDecimal|null The exchange rate between this currency and the base currency
|
||||
* (how many base units the current currency is worth)
|
||||
* @ORM\Column(type="big_decimal", precision=11, scale=5, nullable=true)
|
||||
* @BigDecimalPositive()
|
||||
*/
|
||||
#[ORM\Column(type: 'big_decimal', precision: 11, scale: 5, nullable: true)]
|
||||
protected ?BigDecimal $exchange_rate = null;
|
||||
|
||||
/**
|
||||
* @var string the 3-letter ISO code of the currency
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
#[Assert\Currency]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
protected string $iso_code = "";
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Currency", mappedBy="parent", cascade={"persist"})
|
||||
* @ORM\OrderBy({"name" = "ASC"})
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'Currency', mappedBy: 'parent', cascade: ['persist'])]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Currency", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'children')]
|
||||
#[ORM\JoinColumn(name: 'parent_id')]
|
||||
protected ?AbstractStructuralDBElement $parent;
|
||||
|
||||
/**
|
||||
* @var Collection<int, CurrencyAttachment>
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @ORM\OrderBy({"name" = "ASC"})
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Attachments\CurrencyAttachment', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, CurrencyParameter>
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\Parameters\CurrencyParameter', mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['group' => 'ASC', 'name' => 'ASC'])]
|
||||
protected Collection $parameters;
|
||||
|
||||
/** @var Collection<int, Pricedetail>
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Pricedetail", mappedBy="currency")
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: 'App\Entity\PriceInformations\Pricedetail', mappedBy: 'currency')]
|
||||
protected Collection $pricedetails;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->attachments = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->parameters = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->pricedetails = new ArrayCollection();
|
||||
parent::__construct();
|
||||
}
|
||||
|
|
|
@ -39,63 +39,59 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
|
||||
/**
|
||||
* Class Orderdetail.
|
||||
*
|
||||
* @ORM\Table("`orderdetails`", indexes={
|
||||
* @ORM\Index(name="orderdetails_supplier_part_nr", columns={"supplierpartnr"}),
|
||||
* })
|
||||
* @ORM\Entity()
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
#[UniqueEntity(['supplierpartnr', 'supplier', 'part'])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
#[ORM\Table('`orderdetails`')]
|
||||
#[ORM\Index(name: 'orderdetails_supplier_part_nr', columns: ['supplierpartnr'])]
|
||||
class Orderdetail extends AbstractDBElement implements TimeStampableInterface, NamedElementInterface
|
||||
{
|
||||
use TimestampTrait;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @ORM\OrderBy({"min_discount_quantity" = "ASC"})
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\OneToMany(targetEntity: 'Pricedetail', mappedBy: 'orderdetail', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['min_discount_quantity' => 'ASC'])]
|
||||
protected Collection $pricedetails;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
protected string $supplierpartnr = '';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
protected bool $obsolete = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
#[Assert\Url]
|
||||
#[Groups(['full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
protected string $supplier_product_url = '';
|
||||
|
||||
/**
|
||||
* @var Part|null
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="orderdetails")
|
||||
* @ORM\JoinColumn(name="part_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Part', inversedBy: 'orderdetails')]
|
||||
#[ORM\JoinColumn(name: 'part_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?Part $part = null;
|
||||
|
||||
/**
|
||||
* @var Supplier|null
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="orderdetails")
|
||||
* @ORM\JoinColumn(name="id_supplier", referencedColumnName="id")
|
||||
*/
|
||||
#[Assert\NotNull(message: 'validator.orderdetail.supplier_must_not_be_null')]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'App\Entity\Parts\Supplier', inversedBy: 'orderdetails')]
|
||||
#[ORM\JoinColumn(name: 'id_supplier')]
|
||||
protected ?Supplier $supplier = null;
|
||||
|
||||
public function __construct()
|
||||
|
@ -119,10 +115,9 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
|
||||
/**
|
||||
* Helper for updating the timestamp. It is automatically called by doctrine before persisting.
|
||||
*
|
||||
* @ORM\PrePersist
|
||||
* @ORM\PreUpdate
|
||||
*/
|
||||
#[ORM\PrePersist]
|
||||
#[ORM\PreUpdate]
|
||||
public function updateTimestamps(): void
|
||||
{
|
||||
$this->lastModified = new DateTime('now');
|
||||
|
|
|
@ -37,15 +37,13 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
|
||||
/**
|
||||
* Class Pricedetail.
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table("`pricedetails`", indexes={
|
||||
* @ORM\Index(name="pricedetails_idx_min_discount", columns={"min_discount_quantity"}),
|
||||
* @ORM\Index(name="pricedetails_idx_min_discount_price_qty", columns={"min_discount_quantity", "price_related_quantity"}),
|
||||
* })
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
#[UniqueEntity(fields: ['min_discount_quantity', 'orderdetail'])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
#[ORM\Table('`pricedetails`')]
|
||||
#[ORM\Index(name: 'pricedetails_idx_min_discount', columns: ['min_discount_quantity'])]
|
||||
#[ORM\Index(name: 'pricedetails_idx_min_discount_price_qty', columns: ['min_discount_quantity', 'price_related_quantity'])]
|
||||
class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
||||
{
|
||||
use TimestampTrait;
|
||||
|
@ -54,50 +52,50 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
|
||||
/**
|
||||
* @var BigDecimal The price related to the detail. (Given in the selected currency)
|
||||
* @ORM\Column(type="big_decimal", precision=11, scale=5)
|
||||
* @BigDecimalPositive()
|
||||
*/
|
||||
#[Groups(['extended', 'full'])]
|
||||
#[ORM\Column(type: 'big_decimal', precision: 11, scale: 5)]
|
||||
protected BigDecimal $price;
|
||||
|
||||
/**
|
||||
* @var ?Currency The currency used for the current price information.
|
||||
* If this is null, the global base unit is assumed.
|
||||
* @ORM\ManyToOne(targetEntity="Currency", inversedBy="pricedetails")
|
||||
* @ORM\JoinColumn(name="id_currency", referencedColumnName="id", nullable=true)
|
||||
* @Selectable()
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Currency', inversedBy: 'pricedetails')]
|
||||
#[ORM\JoinColumn(name: 'id_currency')]
|
||||
protected ?Currency $currency = null;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
* @ORM\Column(type="float")
|
||||
*/
|
||||
#[Assert\Positive]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
|
||||
protected float $price_related_quantity = 1.0;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
* @ORM\Column(type="float")
|
||||
*/
|
||||
#[Assert\Positive]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
|
||||
protected float $min_discount_quantity = 1.0;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
protected bool $manual_input = true;
|
||||
|
||||
/**
|
||||
* @var Orderdetail|null
|
||||
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
|
||||
* @ORM\JoinColumn(name="orderdetails_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[ORM\ManyToOne(targetEntity: 'Orderdetail', inversedBy: 'pricedetails')]
|
||||
#[ORM\JoinColumn(name: 'orderdetails_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?Orderdetail $orderdetail = null;
|
||||
|
||||
public function __construct()
|
||||
|
@ -115,10 +113,9 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
|
||||
/**
|
||||
* Helper for updating the timestamp. It is automatically called by doctrine before persisting.
|
||||
*
|
||||
* @ORM\PrePersist
|
||||
* @ORM\PreUpdate
|
||||
*/
|
||||
#[ORM\PrePersist]
|
||||
#[ORM\PreUpdate]
|
||||
public function updateTimestamps(): void
|
||||
{
|
||||
$this->lastModified = new DateTime('now');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue