re-written exporter for simpler extendability (#1349)

This commit is contained in:
Kevin Papst
2020-01-07 21:20:45 +01:00
committed by GitHub
parent d6798eed1e
commit e57b69973f
20 changed files with 497 additions and 260 deletions

View File

@@ -10,13 +10,16 @@
namespace App\Invoice\Calculator;
use App\Entity\Timesheet;
use App\Export\ExportItemInterface;
use App\Invoice\InvoiceItem;
use App\Invoice\InvoiceItemInterface;
use App\Invoice\InvoiceItemWithAmountInterface;
use App\Invoice\InvoiceItemWithTypeInterface;
abstract class AbstractMergedCalculator extends AbstractCalculator
{
public const TYPE_MIXED = 'mixed';
public const CATEGORY_MIXED = 'mixed';
/**
* @deprecated since 1.3 - will be removed with 2.0
*/
@@ -39,19 +42,19 @@ abstract class AbstractMergedCalculator extends AbstractCalculator
$amount = $entry->getAmount();
}
if ($entry instanceof InvoiceItemWithTypeInterface) {
$type = $entry->getInvoiceType();
$category = $entry->getInvoiceCategory();
} else {
$type = InvoiceItem::TYPE_TIMESHEET;
$category = InvoiceItem::CATEGORY_TIMESHEET_WORK;
$type = Timesheet::TYPE_TIMESHEET;
$category = Timesheet::CATEGORY_WORK;
if ($entry instanceof ExportItemInterface) {
$type = $entry->getType();
$category = $entry->getCategory();
}
if (null !== $invoiceItem->getType() && $type !== $invoiceItem->getType()) {
$type = InvoiceItem::TYPE_MIXED;
$type = self::TYPE_MIXED;
}
if (null !== $invoiceItem->getCategory() && $category !== $invoiceItem->getCategory()) {
$category = InvoiceItem::CATEGORY_MIXED;
$category = self::CATEGORY_MIXED;
}
$invoiceItem->setType($type);

View File

@@ -18,11 +18,6 @@ use App\Entity\User;
*/
final class InvoiceItem
{
public const TYPE_TIMESHEET = 'timesheet';
public const CATEGORY_TIMESHEET_WORK = 'work';
public const TYPE_MIXED = 'mixed';
public const CATEGORY_MIXED = 'mixed';
/**
* @var float
*/

View File

@@ -14,6 +14,9 @@ use App\Entity\MetaTableTypeInterface;
use App\Entity\Project;
use App\Entity\User;
/**
* @deprecated will be removed with 2.0 - use ExportItemInterface instead
*/
interface InvoiceItemInterface
{
public function getActivity(): ?Activity;

View File

@@ -1,17 +0,0 @@
<?php
/*
* 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 App\Invoice;
interface InvoiceItemWithTypeInterface
{
public function getInvoiceType(): string;
public function getInvoiceCategory(): string;
}