Skip to content

Commit 7368404

Browse files
committed
Do not require a funding ID for administrative departments
1 parent 87afe05 commit 7368404

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Entity/PaymentOrder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ class PaymentOrder implements DBElementInterface, TimestampedElementInterface, \
131131
new Assert\Regex(pattern: PaymentOrder::FUNDING_ID_STURA_FSRKOM),
132132
new Assert\Regex(PaymentOrder::FUNDING_ID_REGEX_LEGACY),
133133
], groups: ['backend'], includeInternalMessages: false)]
134+
//Regex expressions consider empty string as valid, so we need to add a seperate check for frontend
135+
#[Assert\AtLeastOneOf([
136+
new Assert\NotBlank(),
137+
//Allow empty string, for administrative departments
138+
new Assert\Expression("value == '' and (this.getDepartment() !== null and this.getDepartment().getType().value === 'misc') ")
139+
], groups: ['frontend'], message: 'FSRe und Referate müssen eine Mittelfreigabenummer angeben!', includeInternalMessages: false)]
134140
#[Groups('csv_export')]
135141
#[SerializedName("Mittelfreigabe")]
136142
private string $funding_id = '';

src/Form/PaymentOrderType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
7070
$builder->add('funding_id', TextType::class, [
7171
'label' => 'payment_order.funding_id.label',
7272
'empty_data' => '',
73+
'required' => false, //Administrative structures does not require a funding id
7374
'attr' => [
7475
'placeholder' => 'payment_order.funding_id.placeholder',
7576
],

0 commit comments

Comments
 (0)