36 lines
845 B
PHP
36 lines
845 B
PHP
<?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\Calculator;
|
|
|
|
use App\Entity\ExportableItem;
|
|
use App\Invoice\CalculatorInterface;
|
|
|
|
/**
|
|
* A calculator that sums up the invoice item records by user.
|
|
*/
|
|
final class UserInvoiceCalculator extends AbstractSumInvoiceCalculator implements CalculatorInterface
|
|
{
|
|
public function getIdentifiers(ExportableItem $invoiceItem): array
|
|
{
|
|
if (null === $invoiceItem->getUser()?->getId()) {
|
|
throw new \Exception('Cannot handle un-persisted user');
|
|
}
|
|
|
|
return [
|
|
$invoiceItem->getUser()->getId()
|
|
];
|
|
}
|
|
|
|
public function getId(): string
|
|
{
|
|
return 'user';
|
|
}
|
|
}
|