diff --git a/src/Controller/AdminPages/AttachmentTypeController.php b/src/Controller/AdminPages/AttachmentTypeController.php index 3e18a23a..54d9bec1 100644 --- a/src/Controller/AdminPages/AttachmentTypeController.php +++ b/src/Controller/AdminPages/AttachmentTypeController.php @@ -32,8 +32,7 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; - +use App\Entity\Attachments\AttachmentType; use App\Form\BaseEntityAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index c15ad50b..f8051d57 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -31,9 +31,8 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; -use App\Entity\NamedDBElement; -use App\Entity\StructuralDBElement; +use App\Entity\Base\NamedDBElement; +use App\Entity\Base\StructuralDBElement; use App\Form\BaseEntityAdminForm; use App\Form\ImportType; use App\Services\EntityExporter; diff --git a/src/Controller/AdminPages/CategoryController.php b/src/Controller/AdminPages/CategoryController.php index 053ab3ef..dcb08e93 100644 --- a/src/Controller/AdminPages/CategoryController.php +++ b/src/Controller/AdminPages/CategoryController.php @@ -32,8 +32,8 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; -use App\Entity\Category; +use App\Entity\Attachments\AttachmentType; +use App\Entity\Parts\Category; use App\Form\BaseEntityAdminForm; use App\Form\CategoryAdminForm; use App\Services\EntityExporter; diff --git a/src/Controller/AdminPages/DeviceController.php b/src/Controller/AdminPages/DeviceController.php index 2f0d5173..963d0862 100644 --- a/src/Controller/AdminPages/DeviceController.php +++ b/src/Controller/AdminPages/DeviceController.php @@ -32,9 +32,9 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; +use App\Entity\Attachments\AttachmentType; -use App\Entity\Device; +use App\Entity\Devices\Device; use App\Form\BaseEntityAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; diff --git a/src/Controller/AdminPages/FootprintController.php b/src/Controller/AdminPages/FootprintController.php index 02373a6d..28c764d0 100644 --- a/src/Controller/AdminPages/FootprintController.php +++ b/src/Controller/AdminPages/FootprintController.php @@ -32,9 +32,9 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; +use App\Entity\Attachments\AttachmentType; -use App\Entity\Footprint; +use App\Entity\Parts\Footprint; use App\Form\BaseEntityAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; diff --git a/src/Controller/AdminPages/ManufacturerController.php b/src/Controller/AdminPages/ManufacturerController.php index 45845840..e2520161 100644 --- a/src/Controller/AdminPages/ManufacturerController.php +++ b/src/Controller/AdminPages/ManufacturerController.php @@ -32,10 +32,10 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; +use App\Entity\Attachments\AttachmentType; -use App\Entity\Manufacturer; -use App\Entity\Supplier; +use App\Entity\Parts\Manufacturer; +use App\Entity\Parts\Supplier; use App\Form\BaseEntityAdminForm; use App\Form\CompanyForm; use App\Services\EntityExporter; diff --git a/src/Controller/AdminPages/StorelocationController.php b/src/Controller/AdminPages/StorelocationController.php index f1891c05..d5f1ab4b 100644 --- a/src/Controller/AdminPages/StorelocationController.php +++ b/src/Controller/AdminPages/StorelocationController.php @@ -31,9 +31,9 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; +use App\Entity\Attachments\AttachmentType; -use App\Entity\Storelocation; +use App\Entity\Parts\Storelocation; use App\Form\BaseEntityAdminForm; use App\Form\StorelocationAdminForm; use App\Services\EntityExporter; diff --git a/src/Controller/AdminPages/SupplierController.php b/src/Controller/AdminPages/SupplierController.php index 1f1cd012..d3da9c5d 100644 --- a/src/Controller/AdminPages/SupplierController.php +++ b/src/Controller/AdminPages/SupplierController.php @@ -32,9 +32,9 @@ namespace App\Controller\AdminPages; -use App\Entity\AttachmentType; +use App\Entity\Attachments\AttachmentType; -use App\Entity\Supplier; +use App\Entity\Parts\Supplier; use App\Form\BaseEntityAdminForm; use App\Form\CompanyForm; use App\Services\EntityExporter; diff --git a/src/Controller/AttachmentFileController.php b/src/Controller/AttachmentFileController.php index eb19eb2f..c7b17bbc 100644 --- a/src/Controller/AttachmentFileController.php +++ b/src/Controller/AttachmentFileController.php @@ -32,7 +32,7 @@ namespace App\Controller; -use App\Entity\Attachment; +use App\Entity\Attachments\Attachment; use App\Services\AttachmentHelper; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\BinaryFileResponse; diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index 8d386c73..645ab323 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -30,8 +30,8 @@ namespace App\Controller; -use App\Entity\Category; -use App\Entity\Part; +use App\Entity\Parts\Category; +use App\Entity\Parts\Part; use App\Form\PartType; use App\Services\AttachmentFilenameService; use App\Services\AttachmentHelper; diff --git a/src/Controller/TreeController.php b/src/Controller/TreeController.php index 50fa3d28..32d5ecb2 100644 --- a/src/Controller/TreeController.php +++ b/src/Controller/TreeController.php @@ -29,12 +29,12 @@ namespace App\Controller; -use App\Entity\Category; +use App\Entity\Parts\Category; use App\Entity\Device; -use App\Entity\Footprint; -use App\Entity\Manufacturer; -use App\Entity\Storelocation; -use App\Entity\Supplier; +use App\Entity\Parts\Footprint; +use App\Entity\Parts\Manufacturer; +use App\Entity\Parts\Storelocation; +use App\Entity\Parts\Supplier; use App\Helpers\TreeViewNode; use App\Services\ToolsTreeBuilder; use App\Services\TreeBuilder; diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index e8fda1be..2a728a19 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -29,9 +29,9 @@ namespace App\Controller; -use App\Entity\AttachmentType; -use App\Entity\Footprint; -use App\Entity\User; +use App\Entity\Attachments\AttachmentType; +use App\Entity\Parts\Footprint; +use App\Entity\UserSystem\User; use App\Form\BaseEntityAdminForm; use App\Form\UserAdminForm; use App\Form\UserSettingsType; diff --git a/src/Entity/Attachment.php b/src/Entity/Attachments/Attachment.php similarity index 98% rename from src/Entity/Attachment.php rename to src/Entity/Attachments/Attachment.php index ae3b86cc..7a16767c 100644 --- a/src/Entity/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -21,8 +21,10 @@ declare(strict_types=1); * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -namespace App\Entity; +namespace App\Entity\Attachments; +use App\Entity\Base\DBElement; +use App\Entity\Base\NamedDBElement; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Intl\Exception\NotImplementedException; diff --git a/src/Entity/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php similarity index 72% rename from src/Entity/AttachmentContainingDBElement.php rename to src/Entity/Attachments/AttachmentContainingDBElement.php index d5cd50da..8160e9c7 100644 --- a/src/Entity/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -1,4 +1,33 @@ getID(); + } + + /** + * @return string + */ + public function getUnit(): string + { + return $this->unit; + } + + /** + * @param string $unit + * @return MeasurementUnit + */ + public function setUnit(string $unit): MeasurementUnit + { + $this->unit = $unit; + return $this; + } + + /** + * @return bool + */ + public function isInteger(): bool + { + return $this->isInteger; + } + + /** + * @param bool $isInteger + * @return MeasurementUnit + */ + public function setIsInteger(bool $isInteger): MeasurementUnit + { + $this->isInteger = $isInteger; + return $this; + } + + /** + * @return bool + */ + public function isUsesSIPrefixes(): bool + { + return $this->usesSIPrefixes; + } + + /** + * @param bool $usesSIPrefixes + * @return MeasurementUnit + */ + public function setUsesSIPrefixes(bool $usesSIPrefixes): MeasurementUnit + { + $this->usesSIPrefixes = $usesSIPrefixes; + return $this; + } + + + +} \ No newline at end of file diff --git a/src/Entity/Part.php b/src/Entity/Parts/Part.php similarity index 92% rename from src/Entity/Part.php rename to src/Entity/Parts/Part.php index 91c338aa..0fc81501 100644 --- a/src/Entity/Part.php +++ b/src/Entity/Parts/Part.php @@ -1,4 +1,33 @@ getID(); + } +} \ No newline at end of file diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php new file mode 100644 index 00000000..d58d64de --- /dev/null +++ b/src/Entity/Parts/Storelocation.php @@ -0,0 +1,228 @@ +is_full; + } + + /** + * When this property is set, only one part (but many instock) is allowed to be stored in this store location. + * + * @return bool + */ + public function isOnlySinglePart(): bool + { + return $this->only_single_part; + } + + /** + * @param bool $only_single_part + * @return Storelocation + */ + public function setOnlySinglePart(bool $only_single_part): Storelocation + { + $this->only_single_part = $only_single_part; + return $this; + } + + /** + * When this property is set, it is only possible to increase the instock of parts, that are already stored here. + * + * @return bool + */ + public function isLimitToExistingParts(): bool + { + return $this->limit_to_existing_parts; + } + + /** + * @param bool $limit_to_existing_parts + * @return Storelocation + */ + public function setLimitToExistingParts(bool $limit_to_existing_parts): Storelocation + { + $this->limit_to_existing_parts = $limit_to_existing_parts; + return $this; + } + + /** + * @return MeasurementUnit|null + */ + public function getStorageType(): ?MeasurementUnit + { + return $this->storage_type; + } + + /** + * @param MeasurementUnit|null $storage_type + * @return Storelocation + */ + public function setStorageType(?MeasurementUnit $storage_type): Storelocation + { + $this->storage_type = $storage_type; + return $this; + } + + + + /******************************************************************************** + * + * Setters + * + *********************************************************************************/ + + /** + * Change the "is full" attribute of this storelocation. + * + * "is_full" = true means that there is no more space in this storelocation. + * This attribute is only for information, it has no effect. + * + * @param bool $new_is_full * true means that the storelocation is full + * * false means that the storelocation isn't full + * @return Storelocation + */ + public function setIsFull(bool $new_is_full): Storelocation + { + $this->is_full = $new_is_full; + + return $this; + } + + /** + * Returns the ID as an string, defined by the element class. + * This should have a form like P000014, for a part with ID 14. + * + * @return string The ID as a string; + */ + public function getIDString(): string + { + return 'L'.sprintf('%06d', $this->getID()); + } +} diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php new file mode 100644 index 00000000..14a3cf1c --- /dev/null +++ b/src/Entity/Parts/Supplier.php @@ -0,0 +1,155 @@ +default_currency; + } + + /** + * @param ?Currency $default_currency + * @return Supplier + */ + public function setDefaultCurrency(?Currency $default_currency) : Supplier + { + $this->default_currency = $default_currency; + return $this; + } + + /** + * @return ?float + */ + public function getShippingCosts() : ?float + { + return $this->shipping_costs; + } + + /** + * @param ?float $shipping_costs + * @return Supplier + */ + public function setShippingCosts(?float $shipping_costs) : Supplier + { + $this->shipping_costs = $shipping_costs; + return $this; + } + + + /** + * Returns the ID as an string, defined by the element class. + * This should have a form like P000014, for a part with ID 14. + * + * @return string The ID as a string; + */ + public function getIDString(): string + { + return 'L'.sprintf('%06d', $this->getID()); + } +} diff --git a/src/Entity/PartsContainingDBElement.php b/src/Entity/PartsContainingDBElement.php deleted file mode 100644 index 7ec54b6a..00000000 --- a/src/Entity/PartsContainingDBElement.php +++ /dev/null @@ -1,36 +0,0 @@ -iso_code; + } + + /** + * @param string $iso_code + * @return Currency + */ + public function setIsoCode(string $iso_code): Currency + { + $this->iso_code = $iso_code; + return $this; + } + + /** + * Returns the inverse exchange rate (how many of the current currency the base unit is worth) + * @return float|null + */ + public function getInverseExchangeRate(): ?float + { + $tmp = $this->getExchangeRate(); + + if ($tmp == null) { + return null; + } + + return 1 / $tmp; + } + + /** + * Returns The exchange rate between this currency and the base currency + * (how many base units the current currency is worth) + * @return float|null + */ + public function getExchangeRate(): ?float + { + return $this->exchange_rate; + } + + /** + * @param float|null $exchange_rate + * @return Currency + */ + public function setExchangeRate(?float $exchange_rate): Currency + { + $this->exchange_rate = $exchange_rate; + return $this; + } + + + /** + * Returns the ID as an string, defined by the element class. + * This should have a form like P000014, for a part with ID 14. + * + * @return string The ID as a string; + * + */ + public function getIDString(): string + { + return 'C' . $this->getID(); + } +} \ No newline at end of file diff --git a/src/Entity/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php similarity index 85% rename from src/Entity/Orderdetail.php rename to src/Entity/PriceInformations/Orderdetail.php index cf07b58b..f03bf416 100644 --- a/src/Entity/Orderdetail.php +++ b/src/Entity/PriceInformations/Orderdetail.php @@ -1,4 +1,33 @@ orderdetail; } + /** + * Returns the price associated with this pricedetail. + * It is given in current currency and for the price related quantity. + * @return float + */ public function getPrice() : float { return (float) $this->price; } /** - * Get the price for a single unit. + * Get the price for a single unit in the currency associated with this price detail. * * @param int $multiplier The returned price (float or string) will be multiplied * with this multiplier. @@ -114,9 +161,7 @@ class Pricedetail extends DBElement */ public function getPricePerUnit(int $multiplier = 1) : float { - $price = ($this->price * $multiplier) / $this->price_related_quantity; - - return $price; + return ($this->price * $multiplier) / $this->price_related_quantity; } /** @@ -126,7 +171,7 @@ class Pricedetail extends DBElement * * @return int the price related quantity * - * @see Pricedetails::setPriceRelatedQuantity() + * @see Pricedetail::setPriceRelatedQuantity() */ public function getPriceRelatedQuantity(): int { @@ -141,19 +186,40 @@ class Pricedetail extends DBElement * * @return int the minimum discount quantity * - * @see Pricedetails::setMinDiscountQuantity() + * @see Pricedetail::setMinDiscountQuantity() */ public function getMinDiscountQuantity(): int { return $this->min_discount_quantity; } + /** + * Returns the currency associated with this price information. + * Returns null, if no specific currency is selected and the global base currency should be assumed. + * @return Currency|null + */ + public function getCurrency(): ?Currency + { + return $this->currency; + } + /******************************************************************************** * * Setters * *********************************************************************************/ + /** + * Sets the currency associated with the price informations. + * Set to null, to use the global base currency. + * @param Currency|null $currency + * @return Pricedetail + */ + public function setCurrency(?Currency $currency): Pricedetail + { + $this->currency = $currency; + } + /** * Set the price. * @@ -165,9 +231,9 @@ class Pricedetail extends DBElement * * @return self */ - public function setPrice(float $new_price): self + public function setPrice(float $new_price): Pricedetail { - Assert::natural($new_price, 'The new price must be positive! Got %s!'); + //Assert::natural($new_price, 'The new price must be positive! Got %s!'); $this->price = $new_price; @@ -189,8 +255,8 @@ class Pricedetail extends DBElement */ public function setPriceRelatedQuantity(int $new_price_related_quantity): self { - Assert::greaterThan($new_price_related_quantity, 0, - 'The new price related quantity must be greater zero! Got %s.'); + //Assert::greaterThan($new_price_related_quantity, 0, + // 'The new price related quantity must be greater zero! Got %s.'); $this->price_related_quantity = $new_price_related_quantity; @@ -218,8 +284,8 @@ class Pricedetail extends DBElement */ public function setMinDiscountQuantity(int $new_min_discount_quantity): self { - Assert::greaterThan($new_min_discount_quantity, 0, - 'The new minimum discount quantity must be greater zero! Got %s.'); + //Assert::greaterThan($new_min_discount_quantity, 0, + // 'The new minimum discount quantity must be greater zero! Got %s.'); $this->min_discount_quantity = $new_min_discount_quantity; diff --git a/src/Entity/Storelocation.php b/src/Entity/Storelocation.php deleted file mode 100644 index ae90cc24..00000000 --- a/src/Entity/Storelocation.php +++ /dev/null @@ -1,121 +0,0 @@ -is_full; - } - - /******************************************************************************** - * - * Setters - * - *********************************************************************************/ - - /** - * Change the "is full" attribute of this storelocation. - * - * "is_full" = true means that there is no more space in this storelocation. - * This attribute is only for information, it has no effect. - * - * @param bool $new_is_full * true means that the storelocation is full - * * false means that the storelocation isn't full - * - * @throws Exception if there was an error - */ - public function setIsFull(bool $new_is_full): self - { - $this->is_full = $new_is_full; - - return $this; - } - - /** - * Returns the ID as an string, defined by the element class. - * This should have a form like P000014, for a part with ID 14. - * - * @return string The ID as a string; - */ - public function getIDString(): string - { - return 'L'.sprintf('%06d', $this->getID()); - } -} diff --git a/src/Entity/Supplier.php b/src/Entity/Supplier.php deleted file mode 100644 index 6ff303a3..00000000 --- a/src/Entity/Supplier.php +++ /dev/null @@ -1,102 +0,0 @@ - 0) '. - 'AND ((devices.order_only_missing_parts = false) '. - 'OR (parts.instock - device_parts.quantity * devices.order_quantity < parts.mininstock)))) '. - 'AND (parts.order_orderdetails_id IS NOT NULL) '. - 'AND (orderdetails.id_supplier = ?)'; - - $query_data = $this->database->query($query, array($this->getID())); - - - - return (int) $query_data[0]['count']; */ - - //TODO - throw new \Exception('Not implemented yet!'); - } - - /** - * Returns the ID as an string, defined by the element class. - * This should have a form like P000014, for a part with ID 14. - * - * @return string The ID as a string; - */ - public function getIDString(): string - { - return 'L'.sprintf('%06d', $this->getID()); - } -} diff --git a/src/Entity/Group.php b/src/Entity/UserSystem/Group.php similarity index 95% rename from src/Entity/Group.php rename to src/Entity/UserSystem/Group.php index 723d2aba..c8525004 100644 --- a/src/Entity/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -1,8 +1,9 @@