From 924026e9f81638a4ca3d207f6aeffa289effa192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 18 Mar 2025 12:30:24 +0100 Subject: [PATCH 1/3] feat: move cost unit from assignment to job profile --- migrations/Version20250318105943.php | 33 +++++++++++++++++++ src/Entity/Assignment.php | 16 --------- src/Entity/JobProfile.php | 15 +++++++++ src/Form/AssignmentType.php | 3 -- src/Form/JobProfileType.php | 5 ++- src/Service/Pdf/InvoiceApprover.php | 21 +++++++----- .../admin/system/job_profile/_form.html.twig | 1 + .../admin/system/job_profile/index.html.twig | 6 ++-- .../administrative/assignment/_form.html.twig | 1 - 9 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 migrations/Version20250318105943.php diff --git a/migrations/Version20250318105943.php b/migrations/Version20250318105943.php new file mode 100644 index 0000000..1ed0f61 --- /dev/null +++ b/migrations/Version20250318105943.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE assignment DROP cost_center'); + $this->addSql('ALTER TABLE job_profile ADD cost_unit VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE job_profile DROP cost_unit'); + $this->addSql('ALTER TABLE assignment ADD cost_center VARCHAR(255) DEFAULT NULL'); + } +} diff --git a/src/Entity/Assignment.php b/src/Entity/Assignment.php index 66733f5..398516e 100644 --- a/src/Entity/Assignment.php +++ b/src/Entity/Assignment.php @@ -43,10 +43,6 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa #[Assert\NotNull(message: 'Bitte gib die Destination an')] private ?Destination $destination = null; - #[ORM\Column(nullable: true)] - #[Assert\NotBlank(message: 'Bitte gib den Konstenträger an')] - private ?string $costCenter = null; - #[ORM\ManyToOne] #[Assert\NotNull(message: 'Bitte gib das Jobprofil an')] private ?JobProfile $jobProfile = null; @@ -198,18 +194,6 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa return $this; } - public function getCostCenter(): ?string - { - return $this->costCenter; - } - - public function setCostCenter(?string $costCenter): static - { - $this->costCenter = $costCenter; - - return $this; - } - public function getJobProfile(): ?JobProfile { return $this->jobProfile; diff --git a/src/Entity/JobProfile.php b/src/Entity/JobProfile.php index 1415103..5ba0657 100644 --- a/src/Entity/JobProfile.php +++ b/src/Entity/JobProfile.php @@ -43,6 +43,9 @@ class JobProfile implements BlameableEntityInterface, TimestampableEntityInterfa #[Assert\NotNull(message: 'Bitte ordne eine Feedback-Vorlage zu')] private ?FeedbackSet $feedbackSet = null; + #[ORM\Column(nullable: true)] + private ?string $costUnit = null; + public function __construct() { $this->uuid = Uuid::v4(); @@ -119,6 +122,18 @@ class JobProfile implements BlameableEntityInterface, TimestampableEntityInterfa return $this; } + public function getCostUnit(): ?string + { + return $this->costUnit; + } + + public function setCostUnit(?string $costUnit): static + { + $this->costUnit = $costUnit; + + return $this; + } + public function isQualified(Teamer $teamer): bool { // Check licenses diff --git a/src/Form/AssignmentType.php b/src/Form/AssignmentType.php index 82017bb..92738ff 100644 --- a/src/Form/AssignmentType.php +++ b/src/Form/AssignmentType.php @@ -58,9 +58,6 @@ class AssignmentType extends AbstractType 'hx-swap' => 'innerHTML', ], ]) - ->add('costCenter', TextType::class, [ - 'label' => 'Kostenträger', - ]) ->add('jobProfile', EntityType::class, [ 'label' => 'Jobprofil', 'class' => JobProfile::class, diff --git a/src/Form/JobProfileType.php b/src/Form/JobProfileType.php index 1838025..569cd2e 100644 --- a/src/Form/JobProfileType.php +++ b/src/Form/JobProfileType.php @@ -52,6 +52,9 @@ class JobProfileType extends AbstractType 'choice_label' => 'name', 'placeholder' => 'Kein Feedback', ]) + ->add('costUnit', TextType::class, [ + 'label' => 'Kostenstelle', + ]) ; } @@ -62,4 +65,4 @@ class JobProfileType extends AbstractType 'anti_xss' => true, ]); } -} \ No newline at end of file +} diff --git a/src/Service/Pdf/InvoiceApprover.php b/src/Service/Pdf/InvoiceApprover.php index 15625af..ec240f6 100644 --- a/src/Service/Pdf/InvoiceApprover.php +++ b/src/Service/Pdf/InvoiceApprover.php @@ -22,26 +22,29 @@ class InvoiceApprover extends AbstractPdfRenderer throw new \InvalidArgumentException('Expected PDF but got '.$invoice->getMimeType()); } + // Load template + $filepath = sprintf('%s/uploads/invoice/%s', $this->config['project_dir'], $originalFilename); + if (false === file_exists($filepath)) { + throw new \InvalidArgumentException('Uploaded document not found at '.$filepath); + } + $pdf = new Pdf(); $pdf->SetAuthor($teamer->getFullName(), true); $pdf->SetCreator($teamer->getFullName(), true); - - // Load template - $filepath = sprintf('%s/uploads/invoice/%s', $this->config['project_dir'], $originalFilename); $pdf->appendPdf($filepath); $pdf->setPage(1); - // Cost unit - if (null !== $costUnit = $assignment->getDestination()->getCostUnit()) { + // Cost unit job profile + if (null !== $costUnit = $assignment->getJobProfile()->getCostUnit()) { $pdf->SetFont('Arial', '', 11); - $pdf->Text(20,20, utf8_decode('Kostenstelle: '.$costUnit)); + $pdf->Text(20,20, utf8_decode('Kostenstelle 1: '.$costUnit)); } - // Cost center - if (null !== $costCenter = $assignment->getCostCenter()) { + // Cost unit destination/hotel + if (null !== $costUnit = $assignment->getDestination()->getCostUnit()) { $pdf->SetFont('Arial', '', 11); - $pdf->Text(20,25, utf8_decode('Kostenträger: '.$costCenter)); + $pdf->Text(20,25, utf8_decode('Kostenstelle 2: '.$costUnit)); } // Approval diff --git a/templates/admin/system/job_profile/_form.html.twig b/templates/admin/system/job_profile/_form.html.twig index fc77261..c3907ca 100644 --- a/templates/admin/system/job_profile/_form.html.twig +++ b/templates/admin/system/job_profile/_form.html.twig @@ -4,6 +4,7 @@ {{ form_row(form.feedbackSet) }} {{ form_row(form.requiredTrainings) }} {{ form_row(form.requiredLicenses) }} + {{ form_row(form.costUnit) }}
From 421b92b5f8b2a2306f2e9df0415dc40e839a0acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 18 Mar 2025 17:09:06 +0100 Subject: [PATCH 2/3] chore: update project dependencies --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 41bae45..f45f0c8 100644 --- a/composer.lock +++ b/composer.lock @@ -2247,16 +2247,16 @@ }, { "name": "nelmio/security-bundle", - "version": "v3.4.2", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/nelmio/NelmioSecurityBundle.git", - "reference": "3c4739628eafe886c001210aa0d97b33f3551599" + "reference": "b1c5e323d71152bc1a61a4f8fbf7d88c6fa3e2e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nelmio/NelmioSecurityBundle/zipball/3c4739628eafe886c001210aa0d97b33f3551599", - "reference": "3c4739628eafe886c001210aa0d97b33f3551599", + "url": "https://api.github.com/repos/nelmio/NelmioSecurityBundle/zipball/b1c5e323d71152bc1a61a4f8fbf7d88c6fa3e2e7", + "reference": "b1c5e323d71152bc1a61a4f8fbf7d88c6fa3e2e7", "shasum": "" }, "require": { @@ -2315,9 +2315,9 @@ ], "support": { "issues": "https://github.com/nelmio/NelmioSecurityBundle/issues", - "source": "https://github.com/nelmio/NelmioSecurityBundle/tree/v3.4.2" + "source": "https://github.com/nelmio/NelmioSecurityBundle/tree/v3.5.1" }, - "time": "2024-09-10T13:22:26+00:00" + "time": "2025-03-13T09:17:16+00:00" }, { "name": "nesbot/carbon", From bd1cd68cffcbb0c95ab9a0937a756bcbbb2c82ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 18 Mar 2025 17:21:12 +0100 Subject: [PATCH 3/3] chore: fix typos --- templates/admin/index.html.twig | 6 +++--- templates/manager/index.html.twig | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/admin/index.html.twig b/templates/admin/index.html.twig index aa75f11..7163d5e 100644 --- a/templates/admin/index.html.twig +++ b/templates/admin/index.html.twig @@ -200,7 +200,7 @@

Überfällige Feedbacks {% if overdueFeedbacksCount > 0 %} - {{ overdueFeedbacksCount }} überfälllig + {{ overdueFeedbacksCount }} überfällig {% endif %}

@@ -235,7 +235,7 @@

Überfällige Honorarverträge {% if overdueContractsCount > 0 %} - {{ overdueContractsCount }} überfälllig + {{ overdueContractsCount }} überfällig {% endif %}

@@ -262,4 +262,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/manager/index.html.twig b/templates/manager/index.html.twig index 513bd74..2ec36aa 100644 --- a/templates/manager/index.html.twig +++ b/templates/manager/index.html.twig @@ -93,7 +93,7 @@

Überfällige Feedbacks {% if overdueFeedbacksCount > 0 %} - {{ overdueFeedbacksCount }} überfälllig + {{ overdueFeedbacksCount }} überfällig {% endif %}