Meta-fields for InvoiceTemplate, structured Customer address (#5519)

This commit is contained in:
Kevin Papst
2025-11-02 11:24:17 +01:00
committed by GitHub
parent 76821c24ed
commit cc64acf0f8
72 changed files with 2111 additions and 801 deletions

View File

@@ -34,12 +34,14 @@ class CustomerEditForm extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$isNew = false;
$hasAddress = false;
if (isset($options['data'])) {
/** @var Customer $customer */
$customer = $options['data'];
$isNew = $customer->getId() === null;
$options['currency'] = $customer->getCurrency();
$hasAddress = $customer->getAddress() !== null && $customer->getAddress() !== '';
}
$builder
@@ -69,10 +71,38 @@ class CustomerEditForm extends AbstractType
'label' => 'contact',
'required' => false,
])
->add('address', TextareaType::class, [
;
if ($hasAddress) {
$builder
->add('address', TextareaType::class, [
'label' => 'address',
'help' => 'address_deprecated',
'required' => false,
]);
}
$builder
->add('address_line1', TextType::class, [
'label' => 'address',
'required' => false,
])
->add('address_line2', TextType::class, [
'label' => false,
'required' => false,
])
->add('address_line3', TextType::class, [
'label' => false,
'required' => false,
])
->add('postcode', TextType::class, [
'label' => 'postcode',
'required' => false,
])
->add('city', TextType::class, [
'label' => 'city',
'required' => false,
])
->add('country', CountryType::class, [
'label' => 'country',
])
@@ -117,6 +147,10 @@ class CustomerEditForm extends AbstractType
'help' => 'help.invoiceTemplate_customer',
'required' => false,
])
->add('buyerReference', TextType::class, [
'label' => 'buyerReference',
'required' => false,
])
;
if ($isNew) {

View File

@@ -10,10 +10,12 @@
namespace App\Form;
use App\Entity\InvoiceTemplate;
use App\Form\Type\CustomerType;
use App\Form\Type\InvoiceCalculatorType;
use App\Form\Type\InvoiceNumberGeneratorType;
use App\Form\Type\InvoiceRendererType;
use App\Form\Type\LanguageType;
use App\Form\Type\MetaFieldsCollectionType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
@@ -36,17 +38,6 @@ final class InvoiceTemplateForm extends AbstractType
->add('title', TextType::class, [
'label' => 'title',
])
->add('company', TextType::class, [
'label' => 'company',
])
->add('vatId', TextType::class, [
'label' => 'vat_id',
'required' => false,
])
->add('address', TextareaType::class, [
'label' => 'address',
'required' => false,
])
->add('contact', TextareaType::class, [
'label' => 'contact',
'required' => false,
@@ -70,6 +61,13 @@ final class InvoiceTemplateForm extends AbstractType
->add('calculator', InvoiceCalculatorType::class)
->add('numberGenerator', InvoiceNumberGeneratorType::class)
->add('language', LanguageType::class)
->add('customer', CustomerType::class, [
'required' => true,
'label' => 'sending_company',
'placeholder' => '',
'help' => 'sending_company.help',
])
->add('metaFields', MetaFieldsCollectionType::class)
;
}

View File

@@ -9,7 +9,6 @@
namespace App\Form\MultiUpdate;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
@@ -42,7 +41,12 @@ final class MultiUpdateTable extends AbstractType
return [];
}
return $repository->matching((new Criteria())->where(Criteria::expr()->in('id', explode(',', $ids))));
$temp = explode(',', $ids);
if (\count($temp) === 0) {
return [];
}
return $repository->findBy(['id' => $temp]);
}
)
);

View File

@@ -21,7 +21,6 @@ use App\Form\Type\UserType;
use App\Form\Type\YesNoType;
use App\Repository\CustomerRepository;
use App\Repository\TimesheetRepository;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -253,7 +252,12 @@ final class TimesheetMultiUpdate extends AbstractType
return [];
}
return $this->timesheet->matching((new Criteria())->where(Criteria::expr()->in('id', explode(',', $ids))));
$temp = explode(',', $ids);
if (\count($temp) === 0) {
return [];
}
return $this->timesheet->findBy(['id' => $temp]);
}
)
);

View File

@@ -147,7 +147,7 @@ final class DateRangeType extends AbstractType
}
/**
* @param array{'format': non-empty-string, 'separator': non-empty-string, 'allow_empty': true, 'timezone': non-empty-string} $options
* @param array{'format': non-empty-string, 'separator': non-empty-string, 'allow_empty': true, 'timezone': non-empty-string, 'user': User} $options
*/
public function buildForm(FormBuilderInterface $builder, array $options): void // @phpstan-ignore-line
{