support multiple invoice repositories (#1084)

This commit is contained in:
Kevin Papst
2019-09-04 22:50:53 +02:00
committed by GitHub
parent 3f27ab1e44
commit 3ea05cb705
29 changed files with 323 additions and 144 deletions

View File

@@ -9,25 +9,25 @@
namespace App\Invoice\Calculator;
use App\Entity\Timesheet;
use App\Invoice\CalculatorInterface;
use App\Invoice\InvoiceItem;
use App\Invoice\InvoiceItemInterface;
/**
* A calculator that sums up the timesheet records by activity.
* A calculator that sums up the invoice item records by activity.
*/
class ActivityInvoiceCalculator extends AbstractSumInvoiceCalculator implements CalculatorInterface
{
protected function calculateSumIdentifier(Timesheet $timesheet): string
protected function calculateSumIdentifier(InvoiceItemInterface $invoiceItem): string
{
if (null === $timesheet->getActivity()->getId()) {
if (null === $invoiceItem->getActivity()->getId()) {
throw new \Exception('Cannot handle un-persisted activities');
}
return (string) $timesheet->getActivity()->getId();
return (string) $invoiceItem->getActivity()->getId();
}
protected function mergeSumTimesheet(InvoiceItem $invoiceItem, Timesheet $entry)
protected function mergeSumTimesheet(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
{
$invoiceItem->setActivity($entry->getActivity());
$invoiceItem->setDescription($entry->getActivity()->getName());