Added an page for editing order informations

This commit is contained in:
Jan Böhmer 2019-08-30 14:25:05 +02:00
parent 1776cd9a77
commit 8c6342bffe
14 changed files with 504 additions and 12 deletions

View file

@ -128,8 +128,8 @@ class Part extends AttachmentContainingDBElement
/**
* @var Orderdetail[]
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part")
*
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ColumnSecurity(prefix="orderdetails", type="object")
*/
protected $orderdetails;
@ -279,6 +279,7 @@ class Part extends AttachmentContainingDBElement
{
parent::__construct();
$this->partLots = new ArrayCollection();
$this->orderdetails = new ArrayCollection();
}
/**
@ -510,6 +511,19 @@ class Part extends AttachmentContainingDBElement
return $this->orderdetails;
}
public function addOrderdetail(Orderdetail $orderdetail) : Part
{
$orderdetail->setPart($this);
$this->orderdetails->add($orderdetail);
return $this;
}
public function removeOrderdetail(Orderdetail $orderdetail) : Part
{
$this->orderdetails->removeElement($orderdetail);
return $this;
}
/**
* Get all devices which uses this part.
*

View file

@ -86,7 +86,7 @@ class Currency extends StructuralDBElement
* @param string $iso_code
* @return Currency
*/
public function setIsoCode(string $iso_code): Currency
public function setIsoCode(?string $iso_code): Currency
{
$this->iso_code = $iso_code;
return $this;

View file

@ -65,9 +65,12 @@ use App\Entity\Base\DBElement;
use App\Entity\Base\TimestampTrait;
use App\Entity\Parts\Part;
use App\Entity\Parts\Supplier;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Exception;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -85,6 +88,7 @@ class Orderdetail extends DBElement
* @var Part
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="orderdetails")
* @ORM\JoinColumn(name="part_id", referencedColumnName="id")
* @Assert\NotNull()
*/
protected $part;
@ -96,7 +100,8 @@ class Orderdetail extends DBElement
protected $supplier;
/**
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail")
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
*/
protected $pricedetails;
@ -119,6 +124,11 @@ class Orderdetail extends DBElement
*/
protected $supplier_product_url = "";
public function __construct()
{
$this->pricedetails = new ArrayCollection();
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
@ -205,11 +215,34 @@ class Orderdetail extends DBElement
*
* @throws Exception if there was an error
*/
public function getPricedetails(): PersistentCollection
public function getPricedetails(): Collection
{
return $this->pricedetails;
}
/**
* Adds an pricedetail to this orderdetail
* @param Pricedetail $pricedetail The pricedetail to add
* @return Orderdetail
*/
public function addPricedetail(Pricedetail $pricedetail) : Orderdetail
{
$pricedetail->setOrderdetail($this);
$this->pricedetails->add($pricedetail);
return $this;
}
/**
* Removes an pricedetail from this orderdetail
* @param Pricedetail $pricedetail
* @return Orderdetail
*/
public function removePricedetail(Pricedetail $pricedetail) : Orderdetail
{
$this->pricedetails->removeElement($pricedetail);
return $this;
}
/**
* Get the price for a specific quantity.
* @param int $quantity this is the quantity to choose the correct pricedetails
@ -264,6 +297,15 @@ class Orderdetail extends DBElement
*
*********************************************************************************/
/**
* Sets a new part with which this orderdetail is associated
* @param Part $part
*/
public function setPart(Part $part)
{
$this->part = $part;
}
/**
* Sets the new supplier associated with this orderdetail.
* @param Supplier $new_supplier
@ -310,6 +352,11 @@ class Orderdetail extends DBElement
*/
public function setSupplierProductUrl(string $new_url)
{
//Only change the internal URL if it is not the auto generated one
if ($new_url == $this->supplier->getAutoProductUrl($this->getSupplierPartNr())) {
return $this;
}
$this->supplier_product_url = $new_url;
return $this;

View file

@ -85,6 +85,7 @@ class Pricedetail extends DBElement
* @var Orderdetail
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
* @ORM\JoinColumn(name="orderdetails_id", referencedColumnName="id")
* @Assert\NotNull()
*/
protected $orderdetail;
@ -93,7 +94,7 @@ class Pricedetail extends DBElement
* @ORM\Column(type="decimal", precision=11, scale=5)
* @Assert\Positive()
*/
protected $price;
protected $price = 0.0;
/**
* @var ?Currency The currency used for the current price information.
@ -109,19 +110,19 @@ class Pricedetail extends DBElement
* @ORM\Column(type="integer")
* @Assert\Positive()
*/
protected $price_related_quantity;
protected $price_related_quantity = 1;
/**
* @var int
* @ORM\Column(type="integer")
*/
protected $min_discount_quantity;
protected $min_discount_quantity = 1;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
protected $manual_input;
protected $manual_input = true;
/********************************************************************************
@ -212,6 +213,17 @@ class Pricedetail extends DBElement
*
*********************************************************************************/
/**
* Sets the orderdetail to which this pricedetail belongs to.
* @param Orderdetail $orderdetail
* @return $this
*/
public function setOrderdetail(Orderdetail $orderdetail)
{
$this->orderdetail = $orderdetail;
return $this;
}
/**
* Sets the currency associated with the price informations.
* Set to null, to use the global base currency.