Made order and pricedetails timestampable.

Further the migration fixes the typos in attachment table names and filled empty timestamps with the current date.
This commit is contained in:
Jan Böhmer 2019-08-29 13:06:04 +02:00
parent d79f580b30
commit 1776cd9a77
6 changed files with 115 additions and 28 deletions

View file

@ -33,7 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* Class Attachment.
*
* @ORM\Entity
* @ORM\Table(name="`attachements`")
* @ORM\Table(name="`attachments`")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="class_name", type="string")
* @ORM\DiscriminatorMap({"PartDB\Part" = "PartAttachment", "Part" = "PartAttachment"})

View file

@ -61,7 +61,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class AttachmentType.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table(name="`attachement_types`")
* @ORM\Table(name="`attachment_types`")
*/
class AttachmentType extends StructuralDBElement
{

View file

@ -243,6 +243,12 @@ class Part extends AttachmentContainingDBElement
*/
protected $manufacturer_product_number = '';
/**
* @var string
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $manufacturing_status;
/**
* @var bool Determines if this part entry needs review (for example, because it is work in progress)
* @ORM\Column(type="boolean")

View file

@ -62,20 +62,25 @@ declare(strict_types=1);
namespace App\Entity\PriceInformations;
use App\Entity\Base\DBElement;
use App\Entity\Base\TimestampTrait;
use App\Entity\Parts\Part;
use App\Entity\Parts\Supplier;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Exception;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Orderdetail.
*
* @ORM\Table("`orderdetails`")
* @ORM\Entity()
* @ORM\HasLifecycleCallbacks()
*/
class Orderdetail extends DBElement
{
use TimestampTrait;
/**
* @var Part
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="orderdetails")
@ -99,25 +104,20 @@ class Orderdetail extends DBElement
* @var string
* @ORM\Column(type="string")
*/
protected $supplierpartnr;
protected $supplierpartnr = "";
/**
* @var bool
* @ORM\Column(type="boolean")
*/
protected $obsolete;
protected $obsolete = false;
/**
* @var string
* @ORM\Column(type="string")
* @Assert\Url()
*/
protected $supplier_product_url;
/**
* @var \DateTime The date when this element was created.
* @ORM\Column(type="datetimetz", name="datetime_added")
*/
protected $addedDate;
protected $supplier_product_url = "";
/**
* Returns the ID as an string, defined by the element class.
@ -151,7 +151,7 @@ class Orderdetail extends DBElement
*
* @return Supplier the supplier of this orderdetails
*/
public function getSupplier(): Supplier
public function getSupplier(): ?Supplier
{
return $this->supplier;
}
@ -180,17 +180,6 @@ class Orderdetail extends DBElement
return (bool) $this->obsolete;
}
/**
* Returns the date/time when the element was created.
* Returns null if the element was not yet saved to DB yet.
*
* @return \DateTime|null The creation time of the part.
*/
public function getAddedDate(): ?\DateTime
{
return $this->addedDate;
}
/**
* Get the link to the website of the article on the suppliers website.
*

View file

@ -62,6 +62,7 @@ declare(strict_types=1);
namespace App\Entity\PriceInformations;
use App\Entity\Base\DBElement;
use App\Entity\Base\TimestampTrait;
use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
@ -72,10 +73,14 @@ use Symfony\Component\Validator\Constraints as Assert;
*
* @ORM\Entity()
* @ORM\Table("`pricedetails`")
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity(fields={"orderdetail", "min_discount_quantity"})
*/
class Pricedetail extends DBElement
{
use TimestampTrait;
/**
* @var Orderdetail
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
@ -118,10 +123,6 @@ class Pricedetail extends DBElement
*/
protected $manual_input;
/**
* @ORM\Column(type="datetimetz")
*/
protected $last_modified;
/********************************************************************************
*
@ -303,6 +304,6 @@ class Pricedetail extends DBElement
*/
public function getIDString(): string
{
return 'PD'.sprintf('%06d', $this->getID());
return 'PD' . sprintf('%06d', $this->getID());
}
}