added invoice text field to project and activity (#3335)
This commit is contained in:
@@ -174,6 +174,12 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
|
||||
* )
|
||||
*/
|
||||
private $teams;
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="invoice_text", type="text", nullable=true)
|
||||
*/
|
||||
private $invoiceText;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -338,6 +344,16 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
|
||||
return $this->teams;
|
||||
}
|
||||
|
||||
public function getInvoiceText(): ?string
|
||||
{
|
||||
return $this->invoiceText;
|
||||
}
|
||||
|
||||
public function setInvoiceText(?string $invoiceText): void
|
||||
{
|
||||
$this->invoiceText = $invoiceText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -246,6 +246,12 @@ class Project implements EntityWithMetaFields, EntityWithBudget
|
||||
* )
|
||||
*/
|
||||
private $teams;
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(name="invoice_text", type="text", nullable=true)
|
||||
*/
|
||||
private $invoiceText;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -520,6 +526,16 @@ class Project implements EntityWithMetaFields, EntityWithBudget
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getInvoiceText(): ?string
|
||||
{
|
||||
return $this->invoiceText;
|
||||
}
|
||||
|
||||
public function setInvoiceText(?string $invoiceText): void
|
||||
{
|
||||
$this->invoiceText = $invoiceText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,10 @@ class ActivityEditForm extends AbstractType
|
||||
'label' => 'label.description',
|
||||
'required' => false,
|
||||
])
|
||||
->add('invoiceText', TextareaType::class, [
|
||||
'label' => 'label.invoiceText',
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
if ($new || !$isGlobal) {
|
||||
|
||||
@@ -67,6 +67,10 @@ class ProjectEditForm extends AbstractType
|
||||
'label' => 'label.description',
|
||||
'required' => false,
|
||||
])
|
||||
->add('invoiceText', TextareaType::class, [
|
||||
'label' => 'label.invoiceText',
|
||||
'required' => false,
|
||||
])
|
||||
->add('orderNumber', TextType::class, [
|
||||
'label' => 'label.orderNumber',
|
||||
'required' => false,
|
||||
|
||||
@@ -33,7 +33,11 @@ class ActivityInvoiceCalculator extends AbstractSumInvoiceCalculator implements
|
||||
return;
|
||||
}
|
||||
|
||||
$invoiceItem->setDescription($entry->getActivity()->getName());
|
||||
if ($entry->getActivity()->getInvoiceText() !== null) {
|
||||
$invoiceItem->setDescription($entry->getActivity()->getInvoiceText());
|
||||
} else {
|
||||
$invoiceItem->setDescription($entry->getActivity()->getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,8 +29,11 @@ class ProjectInvoiceCalculator extends AbstractSumInvoiceCalculator implements C
|
||||
|
||||
protected function mergeSumInvoiceItem(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
|
||||
{
|
||||
$invoiceItem->setProject($entry->getProject());
|
||||
$invoiceItem->setDescription($entry->getProject()->getName());
|
||||
if ($entry->getProject()->getInvoiceText() !== null) {
|
||||
$invoiceItem->setDescription($entry->getProject()->getInvoiceText());
|
||||
} else {
|
||||
$invoiceItem->setDescription($entry->getProject()->getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
44
src/Migrations/Version20220531145920.php
Normal file
44
src/Migrations/Version20220531145920.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* @version 1.20.2
|
||||
*/
|
||||
final class Version20220531145920 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add invoice text columns to project and activity';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$activities = $schema->getTable('kimai2_activities');
|
||||
$activities->addColumn('invoice_text', 'text', ['notnull' => false, 'default' => null]);
|
||||
|
||||
$projects = $schema->getTable('kimai2_projects');
|
||||
$projects->addColumn('invoice_text', 'text', ['notnull' => false, 'default' => null]);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$activities = $schema->getTable('kimai2_activities');
|
||||
$activities->dropColumn('invoice_text');
|
||||
|
||||
$projects = $schema->getTable('kimai2_projects');
|
||||
$projects->dropColumn('invoice_text');
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,9 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if form.invoiceText is defined %}
|
||||
{{ form_row(form.invoiceText) }}
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.visible) }}
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if form.invoiceText is defined %}
|
||||
{{ form_row(form.invoiceText) }}
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.visible) }}
|
||||
|
||||
@@ -31,6 +31,7 @@ class ActivityTest extends AbstractEntityTest
|
||||
$this->assertNull($sut->getProject());
|
||||
$this->assertNull($sut->getName());
|
||||
$this->assertNull($sut->getComment());
|
||||
$this->assertNull($sut->getInvoiceText());
|
||||
$this->assertTrue($sut->isVisible());
|
||||
$this->assertTrue($sut->isBillable());
|
||||
$this->assertTrue($sut->isGlobal());
|
||||
@@ -66,6 +67,9 @@ class ActivityTest extends AbstractEntityTest
|
||||
$this->assertInstanceOf(Activity::class, $sut->setComment('hello world'));
|
||||
$this->assertEquals('hello world', $sut->getComment());
|
||||
|
||||
$sut->setInvoiceText('very long invoice text comment 12324');
|
||||
self::assertEquals('very long invoice text comment 12324', $sut->getInvoiceText());
|
||||
|
||||
self::assertFalse($sut->hasColor());
|
||||
$sut->setColor('#fffccc');
|
||||
$this->assertEquals('#fffccc', $sut->getColor());
|
||||
|
||||
@@ -35,6 +35,7 @@ class ProjectTest extends AbstractEntityTest
|
||||
self::assertNull($sut->getStart());
|
||||
self::assertNull($sut->getEnd());
|
||||
self::assertNull($sut->getComment());
|
||||
self::assertNull($sut->getInvoiceText());
|
||||
self::assertTrue($sut->isVisible());
|
||||
self::assertTrue($sut->isBillable());
|
||||
self::assertNull($sut->getColor());
|
||||
@@ -86,6 +87,9 @@ class ProjectTest extends AbstractEntityTest
|
||||
self::assertInstanceOf(Project::class, $sut->setComment('a comment'));
|
||||
self::assertEquals('a comment', $sut->getComment());
|
||||
|
||||
$sut->setInvoiceText('very long invoice text comment 12324');
|
||||
self::assertEquals('very long invoice text comment 12324', $sut->getInvoiceText());
|
||||
|
||||
self::assertFalse($sut->hasColor());
|
||||
$sut->setColor('#fffccc');
|
||||
self::assertEquals('#fffccc', $sut->getColor());
|
||||
|
||||
@@ -293,6 +293,10 @@
|
||||
<source>label.description</source>
|
||||
<target>Beschreibung</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="74pEVx1" resname="label.invoiceText">
|
||||
<source>label.invoiceText</source>
|
||||
<target>Rechnungstext</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ysOvPSq" resname="label.name">
|
||||
<source>label.name</source>
|
||||
<target>Name</target>
|
||||
|
||||
@@ -293,6 +293,10 @@
|
||||
<source>label.description</source>
|
||||
<target>Description</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="74pEVx1" resname="label.invoiceText">
|
||||
<source>label.invoiceText</source>
|
||||
<target>Invoice text</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ysOvPSq" resname="label.name">
|
||||
<source>label.name</source>
|
||||
<target>Name</target>
|
||||
|
||||
Reference in New Issue
Block a user