feat: move cost unit from assignment to job profile

This commit is contained in:
Björn Fromme
2025-03-18 12:30:24 +01:00
parent 3d85949ade
commit 924026e9f8
9 changed files with 69 additions and 32 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250318105943 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}
-16
View File
@@ -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;
+15
View File
@@ -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
-3
View File
@@ -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,
+3
View File
@@ -52,6 +52,9 @@ class JobProfileType extends AbstractType
'choice_label' => 'name',
'placeholder' => 'Kein Feedback',
])
->add('costUnit', TextType::class, [
'label' => 'Kostenstelle',
])
;
}
+12 -9
View File
@@ -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
@@ -4,6 +4,7 @@
{{ form_row(form.feedbackSet) }}
{{ form_row(form.requiredTrainings) }}
{{ form_row(form.requiredLicenses) }}
{{ form_row(form.costUnit) }}
</div>
<div class="flex items-center space-x-2">
<button type="submit" class="btn">
@@ -27,7 +27,9 @@
{% for jobProfile in jobProfiles %}
<tr>
<td>
<a href="{{ path('app_admin_system_job_profile_edit', { 'id': jobProfile.id }) }}">
{{ jobProfile.name }}
</a>
</td>
<td>
<ul>
@@ -34,7 +34,6 @@
<div class="grid grid-cols-1 gap-y-4">
{{ form_row(form.contact) }}
{{ form_row(form.remarks) }}
{{ form_row(form.costCenter) }}
</div>
</div>
</div>