added invoice archive & configurable invoice numbers (#1541)
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
namespace App\Invoice\Calculator;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use App\Export\ExportItemInterface;
|
||||
use App\Invoice\InvoiceItem;
|
||||
use App\Invoice\InvoiceItemInterface;
|
||||
use App\Invoice\InvoiceItemWithAmountInterface;
|
||||
@@ -42,13 +41,8 @@ abstract class AbstractMergedCalculator extends AbstractCalculator
|
||||
$amount = $entry->getAmount();
|
||||
}
|
||||
|
||||
$type = Timesheet::TYPE_TIMESHEET;
|
||||
$category = Timesheet::CATEGORY_WORK;
|
||||
|
||||
if ($entry instanceof ExportItemInterface) {
|
||||
$type = $entry->getType();
|
||||
$category = $entry->getCategory();
|
||||
}
|
||||
$type = $entry->getType();
|
||||
$category = $entry->getCategory();
|
||||
|
||||
if (null !== $invoiceItem->getType() && $type !== $invoiceItem->getType()) {
|
||||
$type = self::TYPE_MIXED;
|
||||
|
||||
@@ -47,14 +47,23 @@ abstract class AbstractSumInvoiceCalculator extends AbstractMergedCalculator imp
|
||||
}
|
||||
$invoiceItem = $invoiceItems[$id];
|
||||
$this->mergeInvoiceItems($invoiceItem, $entry);
|
||||
$this->mergeSumTimesheet($invoiceItem, $entry);
|
||||
$this->mergeSumInvoiceItem($invoiceItem, $entry);
|
||||
}
|
||||
|
||||
return array_values($invoiceItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.9 - use mergeSumInvoiceItem() instead
|
||||
*/
|
||||
protected function mergeSumTimesheet(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
|
||||
{
|
||||
// allows to set values per calculator after merging the timesheet
|
||||
}
|
||||
|
||||
protected function mergeSumInvoiceItem(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
|
||||
{
|
||||
@trigger_error('mergeSumTimesheet() is deprecated and will be removed with 2.0', E_USER_DEPRECATED);
|
||||
|
||||
$this->mergeSumTimesheet($invoiceItem, $entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,19 +21,18 @@ class ActivityInvoiceCalculator extends AbstractSumInvoiceCalculator implements
|
||||
protected function calculateSumIdentifier(InvoiceItemInterface $invoiceItem): string
|
||||
{
|
||||
if (null === $invoiceItem->getActivity()) {
|
||||
throw new \Exception('Cannot work with invoice items that do not have an activity');
|
||||
}
|
||||
|
||||
if (null === $invoiceItem->getActivity()->getId()) {
|
||||
throw new \Exception('Cannot handle un-persisted activities');
|
||||
return '__NULL__';
|
||||
}
|
||||
|
||||
return (string) $invoiceItem->getActivity()->getId();
|
||||
}
|
||||
|
||||
protected function mergeSumTimesheet(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
|
||||
protected function mergeSumInvoiceItem(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
|
||||
{
|
||||
$invoiceItem->setActivity($entry->getActivity());
|
||||
if (null === $entry->getActivity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$invoiceItem->setDescription($entry->getActivity()->getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class ProjectInvoiceCalculator extends AbstractSumInvoiceCalculator implements C
|
||||
return (string) $invoiceItem->getProject()->getId();
|
||||
}
|
||||
|
||||
protected function mergeSumTimesheet(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
|
||||
protected function mergeSumInvoiceItem(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
|
||||
{
|
||||
$invoiceItem->setProject($entry->getProject());
|
||||
$invoiceItem->setDescription($entry->getProject()->getName());
|
||||
|
||||
Reference in New Issue
Block a user