added short invoice calculator and timesheet invoice template #104 (#105)

This commit is contained in:
Kevin Papst
2018-01-23 22:30:41 +01:00
committed by GitHub
parent 50b5e93a10
commit 7f5b5ac254
10 changed files with 215 additions and 5 deletions

View File

@@ -0,0 +1,43 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Invoice;
use App\Entity\Timesheet;
/**
* A calculator that sums up all timesheet records from the model and returns only one
* entry for a compact invoice version.
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ShortInvoiceCalculator extends DefaultCalculator
{
/**
* @return Timesheet[]
*/
public function getEntries()
{
$timesheet = new Timesheet();
foreach ($this->model->getEntries() as $entry) {
$timesheet->setDuration($timesheet->getDuration() + $entry->getDuration());
if ($timesheet->getActivity() === null) {
$timesheet->setActivity($entry->getActivity());
$timesheet->setEnd($entry->getEnd());
}
$timesheet->setBegin($entry->getBegin());
}
return [$timesheet];
}
}