support tags in invoices (#2526)
This commit is contained in:
@@ -114,5 +114,11 @@ abstract class AbstractMergedCalculator extends AbstractCalculator
|
||||
if (empty($invoiceItem->getDescription()) && null !== $entry->getActivity()) {
|
||||
$invoiceItem->setDescription($entry->getActivity()->getName());
|
||||
}
|
||||
|
||||
if ($entry instanceof Timesheet) {
|
||||
foreach ($entry->getTagsAsArray() as $tag) {
|
||||
$invoiceItem->addTag($tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class InvoiceItemDefaultHydrator implements InvoiceItemHydrator
|
||||
'entry.description' => $description,
|
||||
'entry.amount' => $amount,
|
||||
'entry.type' => $item->getType(),
|
||||
'entry.tags' => implode(', ', $item->getTags()),
|
||||
'entry.category' => $item->getCategory(),
|
||||
'entry.rate' => $formatter->getFormattedMoney($appliedRate, $currency),
|
||||
'entry.rate_nc' => $formatter->getFormattedMoney($appliedRate, $currency, false),
|
||||
|
||||
@@ -75,6 +75,10 @@ final class InvoiceItem
|
||||
* @var string
|
||||
*/
|
||||
private $category;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $tags = [];
|
||||
|
||||
public function addAdditionalField(string $name, ?string $value): InvoiceItem
|
||||
{
|
||||
@@ -269,4 +273,23 @@ final class InvoiceItem
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTag(string $tag): void
|
||||
{
|
||||
foreach ($this->tags as $t) {
|
||||
if (strcasecmp($tag, $t) === 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->tags[] = $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getTags(): array
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user