diff --git a/migrations/Version20260208131116.php b/migrations/Version20260208131116.php index d05d3e4c..7ffc47a8 100644 --- a/migrations/Version20260208131116.php +++ b/migrations/Version20260208131116.php @@ -22,7 +22,7 @@ final class Version20260208131116 extends AbstractMultiPlatformMigration $this->addSql('ALTER TABLE part_lots ADD last_stocktake_at DATETIME DEFAULT NULL'); $this->addSql('ALTER TABLE parts ADD gtin VARCHAR(255) DEFAULT NULL'); $this->addSql('CREATE INDEX parts_idx_gtin ON parts (gtin)'); - $this->addSql('ALTER TABLE orderdetails ADD prices_includes_vat TINYINT DEFAULT NULL'); + $this->addSql('ALTER TABLE pricedetails ADD include_vat TINYINT DEFAULT NULL'); } public function mySQLDown(Schema $schema): void @@ -32,7 +32,7 @@ final class Version20260208131116 extends AbstractMultiPlatformMigration $this->addSql('DROP INDEX parts_idx_gtin ON `parts`'); $this->addSql('ALTER TABLE `parts` DROP gtin'); $this->addSql('ALTER TABLE part_lots DROP last_stocktake_at'); - $this->addSql('ALTER TABLE `orderdetails` DROP prices_includes_vat'); + $this->addSql('ALTER TABLE `pricedetails` DROP include_vat'); } public function sqLiteUp(Schema $schema): void @@ -57,7 +57,7 @@ final class Version20260208131116 extends AbstractMultiPlatformMigration $this->addSql('CREATE INDEX IDX_6940A7FE1ECB93AE ON parts (id_manufacturer)'); $this->addSql('CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state)'); $this->addSql('CREATE INDEX parts_idx_gtin ON parts (gtin)'); - $this->addSql('ALTER TABLE orderdetails ADD COLUMN prices_includes_vat BOOLEAN DEFAULT NULL'); + $this->addSql('ALTER TABLE pricedetails ADD COLUMN include_vat BOOLEAN DEFAULT NULL'); } public function sqLiteDown(Schema $schema): void @@ -99,14 +99,15 @@ final class Version20260208131116 extends AbstractMultiPlatformMigration $this->addSql('CREATE INDEX parts_idx_datet_name_last_id_needs ON "parts" (datetime_added, name, last_modified, id, needs_review)'); $this->addSql('CREATE INDEX parts_idx_name ON "parts" (name)'); $this->addSql('CREATE INDEX parts_idx_ipn ON "parts" (ipn)'); - $this->addSql('CREATE TEMPORARY TABLE __temp__orderdetails AS SELECT id, supplierpartnr, obsolete, supplier_product_url, last_modified, datetime_added, part_id, id_supplier FROM "orderdetails"'); - $this->addSql('DROP TABLE "orderdetails"'); - $this->addSql('CREATE TABLE "orderdetails" (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, supplierpartnr VARCHAR(255) NOT NULL, obsolete BOOLEAN NOT NULL, supplier_product_url CLOB NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, part_id INTEGER NOT NULL, id_supplier INTEGER DEFAULT NULL, CONSTRAINT FK_489AFCDC4CE34BEC FOREIGN KEY (part_id) REFERENCES "parts" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_489AFCDCCBF180EB FOREIGN KEY (id_supplier) REFERENCES "suppliers" (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO "orderdetails" (id, supplierpartnr, obsolete, supplier_product_url, last_modified, datetime_added, part_id, id_supplier) SELECT id, supplierpartnr, obsolete, supplier_product_url, last_modified, datetime_added, part_id, id_supplier FROM __temp__orderdetails'); - $this->addSql('DROP TABLE __temp__orderdetails'); - $this->addSql('CREATE INDEX IDX_489AFCDC4CE34BEC ON "orderdetails" (part_id)'); - $this->addSql('CREATE INDEX IDX_489AFCDCCBF180EB ON "orderdetails" (id_supplier)'); - $this->addSql('CREATE INDEX orderdetails_supplier_part_nr ON "orderdetails" (supplierpartnr)'); + $this->addSql('CREATE TEMPORARY TABLE __temp__pricedetails AS SELECT id, price, price_related_quantity, min_discount_quantity, manual_input, last_modified, datetime_added, id_currency, orderdetails_id FROM "pricedetails"'); + $this->addSql('DROP TABLE "pricedetails"'); + $this->addSql('CREATE TABLE "pricedetails" (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, price NUMERIC(11, 5) NOT NULL, price_related_quantity DOUBLE PRECISION NOT NULL, min_discount_quantity DOUBLE PRECISION NOT NULL, manual_input BOOLEAN NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, id_currency INTEGER DEFAULT NULL, orderdetails_id INTEGER NOT NULL, CONSTRAINT FK_C68C4459398D64AA FOREIGN KEY (id_currency) REFERENCES currencies (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_C68C44594A01DDC7 FOREIGN KEY (orderdetails_id) REFERENCES "orderdetails" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('INSERT INTO "pricedetails" (id, price, price_related_quantity, min_discount_quantity, manual_input, last_modified, datetime_added, id_currency, orderdetails_id) SELECT id, price, price_related_quantity, min_discount_quantity, manual_input, last_modified, datetime_added, id_currency, orderdetails_id FROM __temp__pricedetails'); + $this->addSql('DROP TABLE __temp__pricedetails'); + $this->addSql('CREATE INDEX IDX_C68C4459398D64AA ON "pricedetails" (id_currency)'); + $this->addSql('CREATE INDEX IDX_C68C44594A01DDC7 ON "pricedetails" (orderdetails_id)'); + $this->addSql('CREATE INDEX pricedetails_idx_min_discount ON "pricedetails" (min_discount_quantity)'); + $this->addSql('CREATE INDEX pricedetails_idx_min_discount_price_qty ON "pricedetails" (min_discount_quantity, price_related_quantity)'); } public function postgreSQLUp(Schema $schema): void @@ -115,7 +116,7 @@ final class Version20260208131116 extends AbstractMultiPlatformMigration $this->addSql('ALTER TABLE part_lots ADD last_stocktake_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); $this->addSql('ALTER TABLE parts ADD gtin VARCHAR(255) DEFAULT NULL'); $this->addSql('CREATE INDEX parts_idx_gtin ON parts (gtin)'); - $this->addSql('ALTER TABLE orderdetails ADD prices_includes_vat BOOLEAN DEFAULT NULL'); + $this->addSql('ALTER TABLE pricedetails ADD include_vat BOOLEAN DEFAULT NULL'); } public function postgreSQLDown(Schema $schema): void @@ -124,6 +125,6 @@ final class Version20260208131116 extends AbstractMultiPlatformMigration $this->addSql('ALTER TABLE part_lots DROP last_stocktake_at'); $this->addSql('DROP INDEX parts_idx_gtin'); $this->addSql('ALTER TABLE "parts" DROP gtin'); - $this->addSql('ALTER TABLE "orderdetails" DROP prices_includes_vat'); + $this->addSql('ALTER TABLE "pricedetails" DROP include_vat'); } } diff --git a/src/Entity/PriceInformations/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php index 58f69598..9a9a2823 100644 --- a/src/Entity/PriceInformations/Orderdetail.php +++ b/src/Entity/PriceInformations/Orderdetail.php @@ -148,13 +148,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N #[ORM\JoinColumn(name: 'id_supplier')] protected ?Supplier $supplier = null; - /** - * @var bool|null Whether the prices includes VAT or not. Null means, that it is not specified, if the prices includes VAT or not. - */ - #[ORM\Column(type: Types::BOOLEAN, nullable: true)] - #[Groups(['extended', 'full', 'import', 'orderdetail:read', 'orderdetail:write'])] - protected ?bool $prices_includes_vat = null; - public function __construct() { $this->pricedetails = new ArrayCollection(); @@ -397,23 +390,45 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N } /** - * Checks if the prices of this orderdetail include VAT. Null means, that it is not specified, if the prices includes - * VAT or not. + * Checks if the prices of this orderdetail include VAT. This is determined by checking the pricedetails of this + * orderdetail. If there are no pricedetails or if the pricedetails have conflicting values, null is returned. * @return bool|null */ + #[Groups(['orderdetail:read'])] + #[SerializedName('prices_include_vat')] public function getPricesIncludesVAT(): ?bool { - return $this->prices_includes_vat; + $value = null; + //We determine that via the pricedetails + foreach ($this->getPricedetails() as $pricedetail) { + /** @var Pricedetail $pricedetail */ + if ($pricedetail->getIncludesVat() === null) { + return null; // If any pricedetail doesn't specify this, we can't determine it + } + + if ($value === null) { + $value = $pricedetail->getIncludesVat(); // Set initial value + } elseif ($value !== $pricedetail->getIncludesVat()) { + return null; // If there are conflicting values, we can't determine it + } + } + + return $value; } /** - * Sets whether the prices of this orderdetail include VAT. + * Sets whether the prices of this orderdetail include VAT. This is set for all pricedetails of this orderdetail. * @param bool|null $includesVat * @return $this */ + #[Groups(['orderdetail:write'])] + #[SerializedName('prices_include_vat')] public function setPricesIncludesVAT(?bool $includesVat): self { - $this->prices_includes_vat = $includesVat; + foreach ($this->getPricedetails() as $pricedetail) { + /** @var Pricedetail $pricedetail */ + $pricedetail->setIncludesVat($includesVat); + } return $this; } diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 553b07a3..7deb64f9 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -121,7 +121,12 @@ 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(name: "include_vat", type: Types::BOOLEAN, nullable: true)] + #[Groups(['extended', 'full', 'import', 'pricedetail:read', 'pricedetail:write'])] + protected ?bool $includes_vat = null; public function __construct() { @@ -272,7 +277,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface */ public function getIncludesVat(): ?bool { - return $this->orderdetail?->getPricesIncludesVAT(); + return $this->includes_vat; } /******************************************************************************** @@ -371,4 +376,15 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface return $this; } + + /** + * Set whether the price includes VAT or not. Null means, that it is not specified, if the price includes VAT or not. + * @param bool|null $includes_vat + * @return $this + */ + public function setIncludesVat(?bool $includes_vat): self + { + $this->includes_vat = $includes_vat; + return $this; + } } diff --git a/src/Form/Part/PartBaseType.php b/src/Form/Part/PartBaseType.php index 2145db93..902aff40 100644 --- a/src/Form/Part/PartBaseType.php +++ b/src/Form/Part/PartBaseType.php @@ -43,7 +43,6 @@ use App\Services\InfoProviderSystem\DTOs\PartDetailDTO; use App\Services\LogSystem\EventCommentNeededHelper; use App\Services\LogSystem\EventCommentType; use App\Settings\MiscSettings\IpnSuggestSettings; -use App\Settings\SystemSettings\LocalizationSettings; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -64,7 +63,6 @@ class PartBaseType extends AbstractType protected UrlGeneratorInterface $urlGenerator, protected EventCommentNeededHelper $event_comment_needed_helper, protected IpnSuggestSettings $ipnSuggestSettings, - private readonly LocalizationSettings $localizationSettings, ) { } @@ -269,9 +267,6 @@ class PartBaseType extends AbstractType 'entity' => $part, ]); - $orderdetailPrototype = new Orderdetail(); - $orderdetailPrototype->setPricesIncludesVAT($this->localizationSettings->pricesIncludeTaxByDefault); - //Orderdetails section $builder->add('orderdetails', CollectionType::class, [ 'entry_type' => OrderdetailType::class, @@ -280,7 +275,7 @@ class PartBaseType extends AbstractType 'allow_delete' => true, 'label' => false, 'by_reference' => false, - 'prototype_data' => $orderdetailPrototype, + 'prototype_data' => new Orderdetail(), 'entry_options' => [ 'measurement_unit' => $part->getPartUnit(), ], diff --git a/src/Services/InfoProviderSystem/DTOs/PriceDTO.php b/src/Services/InfoProviderSystem/DTOs/PriceDTO.php index cf1f577d..2acf3e57 100644 --- a/src/Services/InfoProviderSystem/DTOs/PriceDTO.php +++ b/src/Services/InfoProviderSystem/DTOs/PriceDTO.php @@ -39,9 +39,7 @@ readonly class PriceDTO public string $price, /** @var string The currency of the used ISO code of this price detail */ public ?string $currency_iso_code, - /** @var bool If the price includes tax - * @deprecated Use the prices_include_vat property of the PurchaseInfoDTO instead, as this property is not reliable if there are multiple prices with different values for includes_tax - */ + /** @var bool If the price includes tax */ public ?bool $includes_tax = true, /** @var float the price related quantity */ public ?float $price_related_quantity = 1.0, diff --git a/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php b/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php index 446d04dc..9ac142ff 100644 --- a/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php +++ b/src/Services/InfoProviderSystem/DTOs/PurchaseInfoDTO.php @@ -29,9 +29,6 @@ namespace App\Services\InfoProviderSystem\DTOs; */ readonly class PurchaseInfoDTO { - /** @var bool|null If the prices contain VAT or not. Null if state is unknown. */ - public ?bool $prices_include_vat; - public function __construct( public string $distributor_name, public string $order_number, @@ -39,7 +36,6 @@ readonly class PurchaseInfoDTO public array $prices, /** @var string|null An url to the product page of the vendor */ public ?string $product_url = null, - ?bool $prices_include_vat = null, ) { //Ensure that the prices are PriceDTO instances @@ -48,17 +44,5 @@ readonly class PurchaseInfoDTO throw new \InvalidArgumentException('The prices array must only contain PriceDTO instances'); } } - - //If no prices_include_vat information is given, try to deduct it from the prices - if ($prices_include_vat === null) { - $vatValues = array_unique(array_map(fn(PriceDTO $price) => $price->includes_tax, $this->prices)); - if (count($vatValues) === 1) { - $this->prices_include_vat = $vatValues[0]; //Use the value of the prices if they are all the same - } else { - $this->prices_include_vat = null; //If there are different values for the prices, we cannot determine if the prices include VAT or not - } - } else { - $this->prices_include_vat = $prices_include_vat; - } } } diff --git a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php index c7c15673..1a93b111 100644 --- a/src/Services/InfoProviderSystem/DTOtoEntityConverter.php +++ b/src/Services/InfoProviderSystem/DTOtoEntityConverter.php @@ -100,6 +100,8 @@ final class DTOtoEntityConverter $entity->setCurrency(null); } + $entity->setIncludesVat($dto->includes_tax); + return $entity; } @@ -116,8 +118,6 @@ final class DTOtoEntityConverter $entity->addPricedetail($this->convertPrice($price)); } - $entity->setPricesIncludesVAT($dto->prices_include_vat); - return $entity; } diff --git a/src/Settings/SystemSettings/LocalizationSettings.php b/src/Settings/SystemSettings/LocalizationSettings.php index d0c3ce75..c6780c6c 100644 --- a/src/Settings/SystemSettings/LocalizationSettings.php +++ b/src/Settings/SystemSettings/LocalizationSettings.php @@ -25,7 +25,6 @@ namespace App\Settings\SystemSettings; use App\Form\Settings\LanguageMenuEntriesType; use App\Form\Type\LocaleSelectType; -use App\Form\Type\TriStateCheckboxType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\ParameterTypes\ArrayType; @@ -47,7 +46,7 @@ class LocalizationSettings #[Assert\Locale()] #[Assert\NotBlank()] #[SettingsParameter(label: new TM("settings.system.localization.locale"), formType: LocaleSelectType::class, - envVar: "string:DEFAULT_LANG", envVarMode: EnvVarMode::OVERWRITE)] + envVar: "string:DEFAULT_LANG", envVarMode: EnvVarMode::OVERWRITE)] public string $locale = 'en'; #[Assert\Timezone()] @@ -74,14 +73,4 @@ class LocalizationSettings )] #[Assert\All([new Assert\Locale()])] public array $languageMenuEntries = []; - - #[SettingsParameter(label: new TM("settings.system.localization.prices_include_tax_by_default"), - description: new TM("settings.system.localization.prices_include_tax_by_default.description"), - formType: TriStateCheckboxType::class - )] - /** - * Indicates whether prices should include tax by default. This is used when creating new pricedetails. - * Null means that the VAT state should be indetermine by default. - */ - public ?bool $pricesIncludeTaxByDefault = null; } diff --git a/templates/form/extended_bootstrap_layout.html.twig b/templates/form/extended_bootstrap_layout.html.twig index ecd7caf0..75e44a15 100644 --- a/templates/form/extended_bootstrap_layout.html.twig +++ b/templates/form/extended_bootstrap_layout.html.twig @@ -100,17 +100,6 @@ {%- endif -%} {%- endblock tristate_widget %} -{% block tristate_row -%} - {#--#} -
{#--#} -
- {{- form_widget(form) -}} - {{- form_help(form) -}} - {{- form_errors(form) -}} -
{#--#} - -{%- endblock tristate_row %} - {%- block choice_widget_collapsed -%} {# Only add the BS5 form-select class if we dont use bootstrap-selectpicker #} {# {% if attr["data-controller"] is defined and attr["data-controller"] not in ["elements--selectpicker"] %} diff --git a/templates/parts/edit/edit_form_styles.html.twig b/templates/parts/edit/edit_form_styles.html.twig index 1856dbff..aa68f38a 100644 --- a/templates/parts/edit/edit_form_styles.html.twig +++ b/templates/parts/edit/edit_form_styles.html.twig @@ -32,7 +32,7 @@ {{ form_row(form.supplierpartnr, {'attr': {'class': 'form-control-sm'}}) }} {{ form_row(form.supplier_product_url, {'attr': {'class': 'form-control-sm'}}) }} {{ form_widget(form.obsolete) }} - {{ form_widget(form.pricesIncludesVAT) }} + {{ form_row(form.pricesIncludesVAT) }}
diff --git a/tests/Entity/PriceSystem/OrderdetailTest.php b/tests/Entity/PriceSystem/OrderdetailTest.php index df86ab34..7eae93aa 100644 --- a/tests/Entity/PriceSystem/OrderdetailTest.php +++ b/tests/Entity/PriceSystem/OrderdetailTest.php @@ -62,17 +62,76 @@ class OrderdetailTest extends TestCase $this->assertSame($price5, $orderdetail->findPriceForQty(10000)); } - public function testGetSetPricesIncludesVAT(): void + public function testGetPricesIncludesVAT(): void { $orderdetail = new Orderdetail(); //By default, the pricesIncludesVAT property should be null for empty orderdetails $this->assertNull($orderdetail->getPricesIncludesVAT()); + $price0 = (new Pricedetail())->setMinDiscountQuantity(0.23); + $price1 = (new Pricedetail())->setMinDiscountQuantity(1); + $price5 = (new Pricedetail())->setMinDiscountQuantity(5.3); + + $orderdetail->addPricedetail($price0)->addPricedetail($price1)->addPricedetail($price5); + + //With empty pricedetails, the pricesIncludesVAT property should still be null + $this->assertNull($orderdetail->getPricesIncludesVAT()); + + //If all of the pricedetails have the same value for includesVAT, the pricesIncludesVAT property should return this value + $price0->setIncludesVAT(true); + $price1->setIncludesVAT(true); + $price5->setIncludesVAT(true); + $this->assertTrue($orderdetail->getPricesIncludesVAT()); + + $price0->setIncludesVAT(false); + $price1->setIncludesVAT(false); + $price5->setIncludesVAT(false); + $this->assertFalse($orderdetail->getPricesIncludesVAT()); + + //If the pricedetails have different values for includesVAT, the pricesIncludesVAT property should return null + $price0->setIncludesVAT(true); + $price1->setIncludesVAT(false); + $price5->setIncludesVAT(true); + $this->assertNull($orderdetail->getPricesIncludesVAT()); + + //If the pricedetails have different values for includesVAT, the pricesIncludesVAT property should return null, even if one of them is null + $price0->setIncludesVAT(null); + $price1->setIncludesVAT(false); + $price5->setIncludesVAT(false); + $this->assertNull($orderdetail->getPricesIncludesVAT()); + } + + public function testSetPricesIncludesVAT(): void + { + $orderdetail = new Orderdetail(); + $price0 = (new Pricedetail())->setMinDiscountQuantity(0.23); + $price1 = (new Pricedetail())->setMinDiscountQuantity(1); + $price5 = (new Pricedetail())->setMinDiscountQuantity(5.3); + + $orderdetail->addPricedetail($price0)->addPricedetail($price1)->addPricedetail($price5); + + $this->assertNull($orderdetail->getPricesIncludesVAT()); + $orderdetail->setPricesIncludesVAT(true); $this->assertTrue($orderdetail->getPricesIncludesVAT()); + //Ensure that the pricesIncludesVAT property is correctly propagated to the pricedetails + foreach ($orderdetail->getPricedetails() as $pricedetail) { + $this->assertTrue($pricedetail->getIncludesVAT()); + } $orderdetail->setPricesIncludesVAT(false); $this->assertFalse($orderdetail->getPricesIncludesVAT()); + //Ensure that the pricesIncludesVAT property is correctly propagated to the pricedetails + foreach ($orderdetail->getPricedetails() as $pricedetail) { + $this->assertFalse($pricedetail->getIncludesVAT()); + } + + $orderdetail->setPricesIncludesVAT(null); + $this->assertNull($orderdetail->getPricesIncludesVAT()); + //Ensure that the pricesIncludesVAT property is correctly propagated to the pricedetails + foreach ($orderdetail->getPricedetails() as $pricedetail) { + $this->assertNull($pricedetail->getIncludesVAT()); + } } } diff --git a/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php index ce7564da..b4dc0dea 100644 --- a/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/BulkSearchResponseDTOTest.php @@ -108,7 +108,6 @@ class BulkSearchResponseDTOTest extends KernelTestCase 'manufacturing_status' => NULL, 'provider_url' => NULL, 'footprint' => NULL, - 'gtin' => NULL, ), 'source_field' => 'mpn', 'source_keyword' => '1234', @@ -130,7 +129,6 @@ class BulkSearchResponseDTOTest extends KernelTestCase 'manufacturing_status' => NULL, 'provider_url' => NULL, 'footprint' => NULL, - 'gtin' => NULL, ), 'source_field' => 'name', 'source_keyword' => '1234', diff --git a/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php b/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php index 1c909e67..14a3c03f 100644 --- a/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php +++ b/tests/Services/InfoProviderSystem/DTOs/PurchaseInfoDTOTest.php @@ -22,7 +22,6 @@ declare(strict_types=1); */ namespace App\Tests\Services\InfoProviderSystem\DTOs; -use App\Services\InfoProviderSystem\DTOs\PriceDTO; use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO; use PHPUnit\Framework\TestCase; @@ -34,40 +33,4 @@ class PurchaseInfoDTOTest extends TestCase $this->expectExceptionMessage('The prices array must only contain PriceDTO instances'); new PurchaseInfoDTO('test', 'test', [new \stdClass()]); } - - public function testPricesIncludesVATHandling(): void - { - $pricesTrue = [ - new PriceDTO(minimum_discount_amount: 1, price: '10.00', currency_iso_code: 'USD', includes_tax: true), - new PriceDTO(minimum_discount_amount: 5, price: '9.00', currency_iso_code: 'USD', includes_tax: true), - ]; - $pricesFalse = [ - new PriceDTO(minimum_discount_amount: 1, price: '10.00', currency_iso_code: 'USD', includes_tax: false), - new PriceDTO(minimum_discount_amount: 5, price: '9.00', currency_iso_code: 'USD', includes_tax: false), - ]; - $pricesMixed = [ - new PriceDTO(minimum_discount_amount: 1, price: '10.00', currency_iso_code: 'USD', includes_tax: true), - new PriceDTO(minimum_discount_amount: 5, price: '9.00', currency_iso_code: 'USD', includes_tax: false), - ]; - $pricesNull = [ - new PriceDTO(minimum_discount_amount: 1, price: '10.00', currency_iso_code: 'USD', includes_tax: null), - new PriceDTO(minimum_discount_amount: 5, price: '9.00', currency_iso_code: 'USD', includes_tax: null), - ]; - - //If the prices_include_vat parameter is given, use it: - $dto = new PurchaseInfoDTO('test', 'test', $pricesMixed, prices_include_vat: true); - $this->assertTrue($dto->prices_include_vat); - $dto = new PurchaseInfoDTO('test', 'test', $pricesMixed, prices_include_vat: false); - $this->assertFalse($dto->prices_include_vat); - - //If the prices_include_vat parameter is not given, try to deduct it from the prices: - $dto = new PurchaseInfoDTO('test', 'test', $pricesTrue); - $this->assertTrue($dto->prices_include_vat); - $dto = new PurchaseInfoDTO('test', 'test', $pricesFalse); - $this->assertFalse($dto->prices_include_vat); - $dto = new PurchaseInfoDTO('test', 'test', $pricesMixed); - $this->assertNull($dto->prices_include_vat); - $dto = new PurchaseInfoDTO('test', 'test', $pricesNull); - $this->assertNull($dto->prices_include_vat); - } } diff --git a/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php b/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php index 45ea9984..54878bbf 100644 --- a/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php +++ b/tests/Services/InfoProviderSystem/DTOtoEntityConverterTest.php @@ -94,12 +94,15 @@ class DTOtoEntityConverterTest extends WebTestCase minimum_discount_amount: 5, price: "10.0", currency_iso_code: 'EUR', + includes_tax: true, ); $entity = $this->service->convertPrice($dto); //For base currencies, the currency field is null $this->assertNull($entity->getCurrency()); + + $this->assertTrue($entity->getIncludesVat()); } public function testConvertPurchaseInfo(): void @@ -114,7 +117,6 @@ class DTOtoEntityConverterTest extends WebTestCase order_number: 'TestOrderNumber', prices: $prices, product_url: 'https://example.com', - prices_include_vat: true, ); $entity = $this->service->convertPurchaseInfo($dto); @@ -122,7 +124,6 @@ class DTOtoEntityConverterTest extends WebTestCase $this->assertSame($dto->distributor_name, $entity->getSupplier()->getName()); $this->assertSame($dto->order_number, $entity->getSupplierPartNr()); $this->assertEquals($dto->product_url, $entity->getSupplierProductUrl()); - $this->assertTrue($dto->prices_include_vat); } public function testConvertFileWithName(): void diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 36fc10d1..a776eb9d 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12455,17 +12455,5 @@ Buerklin-API Authentication server: Excl. VAT - - - settings.system.localization.prices_include_tax_by_default - Prices include VAT by default - - - - - settings.system.localization.prices_include_tax_by_default.description - The default value for newly created purchase infos, if prices include VAT or not. - -