Allow to set a global default if new orderdetails should contain VAT or not
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / docker (push) Waiting to run
Docker Image Build (FrankenPHP) / docker (push) Waiting to run
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run

This commit is contained in:
Jan Böhmer 2026-02-10 17:13:54 +01:00
parent 8ac8743792
commit e5231e29f2
5 changed files with 42 additions and 3 deletions

View file

@ -43,6 +43,7 @@ use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
use App\Services\LogSystem\EventCommentNeededHelper; use App\Services\LogSystem\EventCommentNeededHelper;
use App\Services\LogSystem\EventCommentType; use App\Services\LogSystem\EventCommentType;
use App\Settings\MiscSettings\IpnSuggestSettings; use App\Settings\MiscSettings\IpnSuggestSettings;
use App\Settings\SystemSettings\LocalizationSettings;
use Symfony\Bundle\SecurityBundle\Security; use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@ -63,6 +64,7 @@ class PartBaseType extends AbstractType
protected UrlGeneratorInterface $urlGenerator, protected UrlGeneratorInterface $urlGenerator,
protected EventCommentNeededHelper $event_comment_needed_helper, protected EventCommentNeededHelper $event_comment_needed_helper,
protected IpnSuggestSettings $ipnSuggestSettings, protected IpnSuggestSettings $ipnSuggestSettings,
private readonly LocalizationSettings $localizationSettings,
) { ) {
} }
@ -267,6 +269,9 @@ class PartBaseType extends AbstractType
'entity' => $part, 'entity' => $part,
]); ]);
$orderdetailPrototype = new Orderdetail();
$orderdetailPrototype->setPricesIncludesVAT($this->localizationSettings->pricesIncludeTaxByDefault);
//Orderdetails section //Orderdetails section
$builder->add('orderdetails', CollectionType::class, [ $builder->add('orderdetails', CollectionType::class, [
'entry_type' => OrderdetailType::class, 'entry_type' => OrderdetailType::class,
@ -275,7 +280,7 @@ class PartBaseType extends AbstractType
'allow_delete' => true, 'allow_delete' => true,
'label' => false, 'label' => false,
'by_reference' => false, 'by_reference' => false,
'prototype_data' => new Orderdetail(), 'prototype_data' => $orderdetailPrototype,
'entry_options' => [ 'entry_options' => [
'measurement_unit' => $part->getPartUnit(), 'measurement_unit' => $part->getPartUnit(),
], ],

View file

@ -25,6 +25,7 @@ namespace App\Settings\SystemSettings;
use App\Form\Settings\LanguageMenuEntriesType; use App\Form\Settings\LanguageMenuEntriesType;
use App\Form\Type\LocaleSelectType; use App\Form\Type\LocaleSelectType;
use App\Form\Type\TriStateCheckboxType;
use App\Settings\SettingsIcon; use App\Settings\SettingsIcon;
use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
use Jbtronics\SettingsBundle\ParameterTypes\ArrayType; use Jbtronics\SettingsBundle\ParameterTypes\ArrayType;
@ -46,7 +47,7 @@ class LocalizationSettings
#[Assert\Locale()] #[Assert\Locale()]
#[Assert\NotBlank()] #[Assert\NotBlank()]
#[SettingsParameter(label: new TM("settings.system.localization.locale"), formType: LocaleSelectType::class, #[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'; public string $locale = 'en';
#[Assert\Timezone()] #[Assert\Timezone()]
@ -73,4 +74,14 @@ class LocalizationSettings
)] )]
#[Assert\All([new Assert\Locale()])] #[Assert\All([new Assert\Locale()])]
public array $languageMenuEntries = []; 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;
} }

View file

@ -100,6 +100,17 @@
{%- endif -%} {%- endif -%}
{%- endblock tristate_widget %} {%- endblock tristate_widget %}
{% block tristate_row -%}
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('mb-3') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
<div class="{{ block('form_label_class') }}"></div>{#--#}
<div class="{{ block('form_group_class') }}">
{{- form_widget(form) -}}
{{- form_help(form) -}}
{{- form_errors(form) -}}
</div>{#--#}
</div>
{%- endblock tristate_row %}
{%- block choice_widget_collapsed -%} {%- block choice_widget_collapsed -%}
{# Only add the BS5 form-select class if we dont use bootstrap-selectpicker #} {# 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"] %} {# {% if attr["data-controller"] is defined and attr["data-controller"] not in ["elements--selectpicker"] %}

View file

@ -32,7 +32,7 @@
{{ form_row(form.supplierpartnr, {'attr': {'class': 'form-control-sm'}}) }} {{ form_row(form.supplierpartnr, {'attr': {'class': 'form-control-sm'}}) }}
{{ form_row(form.supplier_product_url, {'attr': {'class': 'form-control-sm'}}) }} {{ form_row(form.supplier_product_url, {'attr': {'class': 'form-control-sm'}}) }}
{{ form_widget(form.obsolete) }} {{ form_widget(form.obsolete) }}
{{ form_row(form.pricesIncludesVAT) }} {{ form_widget(form.pricesIncludesVAT) }}
</td> </td>
<td> <td>
<div {{ collection.controller(form.pricedetails, 'pricedetails.edit.delete.confirm') }}> <div {{ collection.controller(form.pricedetails, 'pricedetails.edit.delete.confirm') }}>

View file

@ -12455,5 +12455,17 @@ Buerklin-API Authentication server:
<target>Excl. VAT</target> <target>Excl. VAT</target>
</segment> </segment>
</unit> </unit>
<unit id="WDJ7EeF" name="settings.system.localization.prices_include_tax_by_default">
<segment>
<source>settings.system.localization.prices_include_tax_by_default</source>
<target>Prices include VAT by default</target>
</segment>
</unit>
<unit id="01oGY_r" name="settings.system.localization.prices_include_tax_by_default.description">
<segment>
<source>settings.system.localization.prices_include_tax_by_default.description</source>
<target>The default value for newly created purchase infos, if prices include VAT or not.</target>
</segment>
</unit>
</file> </file>
</xliff> </xliff>