Skip to content

Commit

Permalink
Do not require a funding ID for administrative departments
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtronics committed Feb 12, 2025
1 parent 87afe05 commit 7368404
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Entity/PaymentOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ class PaymentOrder implements DBElementInterface, TimestampedElementInterface, \
new Assert\Regex(pattern: PaymentOrder::FUNDING_ID_STURA_FSRKOM),
new Assert\Regex(PaymentOrder::FUNDING_ID_REGEX_LEGACY),
], groups: ['backend'], includeInternalMessages: false)]
//Regex expressions consider empty string as valid, so we need to add a seperate check for frontend
#[Assert\AtLeastOneOf([
new Assert\NotBlank(),
//Allow empty string, for administrative departments
new Assert\Expression("value == '' and (this.getDepartment() !== null and this.getDepartment().getType().value === 'misc') ")
], groups: ['frontend'], message: 'FSRe und Referate müssen eine Mittelfreigabenummer angeben!', includeInternalMessages: false)]
#[Groups('csv_export')]
#[SerializedName("Mittelfreigabe")]
private string $funding_id = '';
Expand Down
1 change: 1 addition & 0 deletions src/Form/PaymentOrderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder->add('funding_id', TextType::class, [
'label' => 'payment_order.funding_id.label',
'empty_data' => '',
'required' => false, //Administrative structures does not require a funding id
'attr' => [
'placeholder' => 'payment_order.funding_id.placeholder',
],
Expand Down

0 comments on commit 7368404

Please sign in to comment.