mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-13 11:54:32 +02:00
Use imports instead of FQNs
This commit is contained in:
parent
f63b6d7207
commit
5629215ce4
179 changed files with 792 additions and 597 deletions
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\PriceInformations;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use App\Entity\Attachments\CurrencyAttachment;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\Parameters\CurrencyParameter;
|
||||
|
@ -60,7 +61,7 @@ class Currency extends AbstractStructuralDBElement
|
|||
*/
|
||||
#[Assert\Currency]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
#[ORM\Column(type: Types::STRING)]
|
||||
protected string $iso_code = "";
|
||||
|
||||
#[ORM\OneToMany(targetEntity: 'Currency', mappedBy: 'parent', cascade: ['persist'])]
|
||||
|
@ -75,27 +76,27 @@ class Currency extends AbstractStructuralDBElement
|
|||
* @var Collection<int, CurrencyAttachment>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\CurrencyAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: CurrencyAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
protected Collection $attachments;
|
||||
|
||||
/** @var Collection<int, CurrencyParameter>
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[ORM\OneToMany(targetEntity: \App\Entity\Parameters\CurrencyParameter::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OneToMany(targetEntity: CurrencyParameter::class, 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::class, mappedBy: 'currency')]
|
||||
#[ORM\OneToMany(targetEntity: Pricedetail::class, 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->children = new ArrayCollection();
|
||||
$this->attachments = new ArrayCollection();
|
||||
$this->parameters = new ArrayCollection();
|
||||
$this->pricedetails = new ArrayCollection();
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -129,7 +130,7 @@ class Currency extends AbstractStructuralDBElement
|
|||
{
|
||||
$tmp = $this->getExchangeRate();
|
||||
|
||||
if (!$tmp instanceof \Brick\Math\BigDecimal || $tmp->isZero()) {
|
||||
if (!$tmp instanceof BigDecimal || $tmp->isZero()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -153,7 +154,7 @@ class Currency extends AbstractStructuralDBElement
|
|||
*/
|
||||
public function setExchangeRate(?BigDecimal $exchange_rate): self
|
||||
{
|
||||
if (!$exchange_rate instanceof \Brick\Math\BigDecimal) {
|
||||
if (!$exchange_rate instanceof BigDecimal) {
|
||||
$this->exchange_rate = null;
|
||||
}
|
||||
$tmp = $exchange_rate->toScale(self::PRICE_SCALE, RoundingMode::HALF_UP);
|
||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\PriceInformations;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Base\TimestampTrait;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
|
@ -59,14 +60,14 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
* @var string
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
#[ORM\Column(type: Types::STRING)]
|
||||
protected string $supplierpartnr = '';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
#[ORM\Column(type: Types::BOOLEAN)]
|
||||
protected bool $obsolete = false;
|
||||
|
||||
/**
|
||||
|
@ -74,14 +75,14 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
*/
|
||||
#[Assert\Url]
|
||||
#[Groups(['full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)]
|
||||
#[ORM\Column(type: Types::STRING)]
|
||||
protected string $supplier_product_url = '';
|
||||
|
||||
/**
|
||||
* @var Part|null
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Part::class, inversedBy: 'orderdetails')]
|
||||
#[ORM\ManyToOne(targetEntity: Part::class, inversedBy: 'orderdetails')]
|
||||
#[ORM\JoinColumn(name: 'part_id', nullable: false, onDelete: 'CASCADE')]
|
||||
protected ?Part $part = null;
|
||||
|
||||
|
@ -90,7 +91,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
*/
|
||||
#[Assert\NotNull(message: 'validator.orderdetail.supplier_must_not_be_null')]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: \App\Entity\Parts\Supplier::class, inversedBy: 'orderdetails')]
|
||||
#[ORM\ManyToOne(targetEntity: Supplier::class, inversedBy: 'orderdetails')]
|
||||
#[ORM\JoinColumn(name: 'id_supplier')]
|
||||
protected ?Supplier $supplier = null;
|
||||
|
||||
|
@ -194,7 +195,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
|||
return $this->supplier_product_url;
|
||||
}
|
||||
|
||||
if (!$this->getSupplier() instanceof \App\Entity\Parts\Supplier) {
|
||||
if (!$this->getSupplier() instanceof Supplier) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\PriceInformations;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Base\TimestampTrait;
|
||||
use App\Entity\Contracts\TimeStampableInterface;
|
||||
|
@ -73,7 +74,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
*/
|
||||
#[Assert\Positive]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
|
||||
#[ORM\Column(type: Types::FLOAT)]
|
||||
protected float $price_related_quantity = 1.0;
|
||||
|
||||
/**
|
||||
|
@ -81,13 +82,13 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
*/
|
||||
#[Assert\Positive]
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
|
||||
#[ORM\Column(type: Types::FLOAT)]
|
||||
protected float $min_discount_quantity = 1.0;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
#[ORM\Column(type: Types::BOOLEAN)]
|
||||
protected bool $manual_input = true;
|
||||
|
||||
/**
|
||||
|
@ -166,7 +167,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
*
|
||||
* @return BigDecimal the price as a bcmath string
|
||||
*/
|
||||
public function getPricePerUnit(float|string|\Brick\Math\BigDecimal $multiplier = 1.0): BigDecimal
|
||||
public function getPricePerUnit(float|string|BigDecimal $multiplier = 1.0): BigDecimal
|
||||
{
|
||||
$tmp = BigDecimal::of($multiplier);
|
||||
$tmp = $tmp->multipliedBy($this->price);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue