Added GTIN fields and others to DB

This commit is contained in:
Jan Böhmer 2026-02-08 14:17:58 +01:00
parent c2a51e57b7
commit 7fd7697c02
7 changed files with 225 additions and 1 deletions

View file

@ -97,7 +97,7 @@ use function in_array;
#[DiscriminatorMap(typeProperty: '_type', mapping: self::API_DISCRIMINATOR_MAP)]
abstract class Attachment extends AbstractNamedDBElement
{
private const ORM_DISCRIMINATOR_MAP = ['Part' => PartAttachment::class, 'PartCustomState' => PartCustomStateAttachment::class, 'Device' => ProjectAttachment::class,
final public const ORM_DISCRIMINATOR_MAP = ['Part' => PartAttachment::class, 'PartCustomState' => PartCustomStateAttachment::class, 'Device' => ProjectAttachment::class,
'AttachmentType' => AttachmentTypeAttachment::class,
'Category' => CategoryAttachment::class, 'Footprint' => FootprintAttachment::class, 'Manufacturer' => ManufacturerAttachment::class,
'Currency' => CurrencyAttachment::class, 'Group' => GroupAttachment::class, 'MeasurementUnit' => MeasurementUnitAttachment::class,

View file

@ -134,6 +134,12 @@ class AttachmentType extends AbstractStructuralDBElement
#[ORM\OneToMany(mappedBy: 'attachment_type', targetEntity: Attachment::class)]
protected Collection $attachments_with_type;
/**
* @var array|null A list of allowed targets where this attachment type can be assigned to.
*/
#[ORM\Column(type: Types::SIMPLE_ARRAY, nullable: true)]
protected ?array $allowed_targets = null;
#[Groups(['attachment_type:read'])]
protected ?\DateTimeImmutable $addedDate = null;
#[Groups(['attachment_type:read'])]

View file

@ -80,6 +80,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[ORM\Index(columns: ['datetime_added', 'name', 'last_modified', 'id', 'needs_review'], name: 'parts_idx_datet_name_last_id_needs')]
#[ORM\Index(columns: ['name'], name: 'parts_idx_name')]
#[ORM\Index(columns: ['ipn'], name: 'parts_idx_ipn')]
#[ORM\Index(columns: ['gtin'], name: 'parts_idx_gtin')]
#[ApiResource(
operations: [
new Get(normalizationContext: [

View file

@ -171,6 +171,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
#[Length(max: 255)]
protected ?string $user_barcode = null;
/**
* @var \DateTimeImmutable|null The date when the last stocktake was performed for this part lot. Set to null, if no stocktake was performed yet.
*/
#[Groups(['extended', 'full', 'import', 'part_lot:read', 'part_lot:write'])]
#[ORM\Column( type: Types::DATETIME_IMMUTABLE, nullable: true)]
#[Year2038BugWorkaround]
protected ?\DateTimeImmutable $last_stocktake_at = null;
public function __clone()
{
if ($this->id) {
@ -391,6 +399,26 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
return $this;
}
/**
* Returns the date when the last stocktake was performed for this part lot. Returns null, if no stocktake was performed yet.
* @return \DateTimeImmutable|null
*/
public function getLastStocktakeAt(): ?\DateTimeImmutable
{
return $this->last_stocktake_at;
}
/**
* Sets the date when the last stocktake was performed for this part lot. Set to null, if no stocktake was performed yet.
* @param \DateTimeImmutable|null $last_stocktake_at
* @return $this
*/
public function setLastStocktakeAt(?\DateTimeImmutable $last_stocktake_at): self
{
$this->last_stocktake_at = $last_stocktake_at;
return $this;
}
#[Assert\Callback]

View file

@ -84,6 +84,14 @@ trait AdvancedPropertyTrait
#[ORM\JoinColumn(name: 'id_part_custom_state')]
protected ?PartCustomState $partCustomState = null;
/**
* @var string|null The GTIN (Global Trade Item Number) of the part, for example a UPC or EAN code
*/
#[Groups(['extended', 'full', 'import', 'part:read', 'part:write'])]
#[ORM\Column(type: Types::STRING, nullable: true)]
#[Length(max: 14)]
protected ?string $gtin = null;
/**
* Checks if this part is marked, for that it needs further review.
*/
@ -211,4 +219,26 @@ trait AdvancedPropertyTrait
return $this;
}
/**
* Gets the GTIN (Global Trade Item Number) of the part, for example a UPC or EAN code.
* Returns null if no GTIN is set.
*/
public function getGtin(): ?string
{
return $this->gtin;
}
/**
* Sets the GTIN (Global Trade Item Number) of the part, for example a UPC or EAN code.
*
* @param string|null $gtin The new GTIN of the part
*
* @return $this
*/
public function setGtin(?string $gtin): self
{
$this->gtin = $gtin;
return $this;
}
}

View file

@ -121,6 +121,13 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
#[Groups(['pricedetail:read:standalone', 'pricedetail:write'])]
protected ?Orderdetail $orderdetail = null;
/**
* @var bool|null Whether the price includes VAT or not. Null means, that it is not specified, if the price includes VAT or not.
*/
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
#[Groups(['extended', 'full', 'import', 'pricedetail:read', 'pricedetail:write'])]
protected ?bool $include_vat = null;
public function __construct()
{
$this->price = BigDecimal::zero()->toScale(self::PRICE_PRECISION);
@ -360,4 +367,26 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
return $this;
}
/**
* Returns whether the price includes VAT or not. Null means, that it is not specified, if the price includes VAT or not.
* @return bool|null
*/
public function getIncludeVat(): ?bool
{
return $this->include_vat;
}
/**
* Sets whether the price includes VAT or not. Null means, that it is not specified, if the price includes VAT or not.
* @param bool|null $include_vat
* @return $this
*/
public function setIncludeVat(?bool $include_vat): self
{
$this->include_vat = $include_vat;
return $this;
}
}