Make more fiields importable

This commit is contained in:
Jan Böhmer 2023-03-13 00:52:22 +01:00
parent 4437f206af
commit 820be46ed3
10 changed files with 35 additions and 29 deletions

View file

@ -57,56 +57,56 @@ class Category extends AbstractPartsContainingDBElement
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected string $partname_hint = '';
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected string $partname_regex = '';
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected bool $disable_footprints = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected bool $disable_manufacturers = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected bool $disable_autodatasheets = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected bool $disable_properties = false;
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected string $default_description = '';
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected string $default_comment = '';
/**

View file

@ -49,7 +49,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* or m (for meters).
* @ORM\Column(type="string", name="unit", nullable=true)
* @Assert\Length(max=10)
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected ?string $unit = null;
@ -57,7 +57,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* @var bool Determines if the amount value associated with this unit should be treated as integer.
* Set to false, to measure continuous sizes likes masses or lengths.
* @ORM\Column(type="boolean", name="is_integer")
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected bool $is_integer = false;
@ -66,7 +66,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
* Useful for sizes like meters. For this the unit must be set
* @ORM\Column(type="boolean", name="use_si_prefix")
* @Assert\Expression("this.isUseSIPrefix() == false or this.getUnit() != null", message="validator.measurement_unit.use_si_prefix_needs_unit")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected bool $use_si_prefix = false;

View file

@ -53,14 +53,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
/**
* @var string A short description about this lot, shown in table
* @ORM\Column(type="text")
* @Groups({"simple", "extended", "full"})
* @Groups({"simple", "extended", "full", "import"})
*/
protected string $description = '';
/**
* @var string a comment stored with this lot
* @ORM\Column(type="text")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected string $comment = '';
@ -68,7 +68,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
* @var ?DateTime Set a time until when the lot must be used.
* Set to null, if the lot can be used indefinitely.
* @ORM\Column(type="datetime", name="expiration_date", nullable=true)
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected ?DateTime $expiration_date = null;
@ -77,14 +77,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
* @ORM\ManyToOne(targetEntity="Storelocation")
* @ORM\JoinColumn(name="id_store_location", referencedColumnName="id", nullable=true)
* @Selectable()
* @Groups({"simple", "extended", "full"})
* @Groups({"simple", "extended", "full", "import"})
*/
protected ?Storelocation $storage_location = null;
/**
* @var bool If this is set to true, the instock amount is marked as not known
* @ORM\Column(type="boolean")
* @Groups({"simple", "extended", "full"})
* @Groups({"simple", "extended", "full", "import"})
*/
protected bool $instock_unknown = false;
@ -92,14 +92,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
* @var float For continuous sizes (length, volume, etc.) the instock is saved here.
* @ORM\Column(type="float")
* @Assert\PositiveOrZero()
* @Groups({"simple", "extended", "full"})
* @Groups({"simple", "extended", "full", "import"})
*/
protected float $amount = 0.0;
/**
* @var bool determines if this lot was manually marked for refilling
* @ORM\Column(type="boolean")
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected bool $needs_refill = false;

View file

@ -58,7 +58,7 @@ trait AdvancedPropertyTrait
* @var string The internal part number of the part
* @ORM\Column(type="string", length=100, nullable=true, unique=true)
* @Assert\Length(max="100")
* @Groups({"extended", "full", "ipn"})
* @Groups({"extended", "full", "import"})
*/
protected ?string $ipn = null;

View file

@ -71,22 +71,24 @@ class Storelocation extends AbstractPartsContainingDBElement
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected bool $is_full = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected bool $only_single_part = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"full", "import"})
*/
protected bool $limit_to_existing_parts = false;
/**
* @var Collection<int, StorelocationAttachment>
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)

View file

@ -31,6 +31,7 @@ use App\Validator\Constraints\Selectable;
use Brick\Math\BigDecimal;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -74,6 +75,7 @@ class Supplier extends AbstractCompany
/**
* @var BigDecimal|null the shipping costs that have to be paid, when ordering via this supplier
* @ORM\Column(name="shipping_costs", nullable=true, type="big_decimal", precision=11, scale=5)
* @Groups({"extended", "full", "import"})
* @BigDecimalPositiveOrZero()
*/
protected ?BigDecimal $shipping_costs = null;

View file

@ -61,7 +61,7 @@ class Currency extends AbstractStructuralDBElement
* @var string the 3-letter ISO code of the currency
* @ORM\Column(type="string")
* @Assert\Currency()
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected string $iso_code = "";

View file

@ -55,20 +55,21 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ORM\OrderBy({"min_discount_quantity" = "ASC"})
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected $pricedetails;
/**
* @var string
* @ORM\Column(type="string")
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected string $supplierpartnr = '';
/**
* @var bool
* @ORM\Column(type="boolean")
* @Groups({"extended", "full", "import"})
*/
protected bool $obsolete = false;
@ -76,7 +77,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @var string
* @ORM\Column(type="string")
* @Assert\Url()
* @Groups({"full"})
* @Groups({"full", "import"})
*/
protected string $supplier_product_url = '';
@ -93,7 +94,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @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"})
* @Groups({"extended", "full", "import"})
*/
protected ?Supplier $supplier = null;

View file

@ -66,7 +66,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* @ORM\ManyToOne(targetEntity="Currency", inversedBy="pricedetails")
* @ORM\JoinColumn(name="id_currency", referencedColumnName="id", nullable=true)
* @Selectable()
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected ?Currency $currency = null;
@ -74,7 +74,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* @var float
* @ORM\Column(type="float")
* @Assert\Positive()
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected float $price_related_quantity = 1.0;
@ -82,7 +82,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* @var float
* @ORM\Column(type="float")
* @Assert\Positive()
* @Groups({"extended", "full"})
* @Groups({"extended", "full", "import"})
*/
protected float $min_discount_quantity = 1.0;

View file

@ -34,6 +34,7 @@ class PartNormalizer implements NormalizerInterface, DenormalizerInterface, Cach
'notes' => 'comment',
'quantity' => 'instock',
'amount' => 'instock',
'mpn' => 'manufacturer_product_number',
];
private ObjectNormalizer $normalizer;