added freelancer invoice template (#254)

This commit is contained in:
Kevin Papst
2018-09-02 21:29:49 +02:00
committed by GitHub
parent ee4df36735
commit a636faa4ab
41 changed files with 1105 additions and 145 deletions

View File

@@ -58,4 +58,18 @@ interface CalculatorInterface
* @return string
*/
public function getCurrency(): string;
/**
* Returns the percentage for the value-added tax (VAT) calculation.
*
* @return float
*/
public function getVat(): ?float;
/**
* Returns the total amount of worked time in seconds.
*
* @return int
*/
public function getTimeWorked(): int;
}

View File

@@ -62,7 +62,7 @@ class DefaultCalculator implements CalculatorInterface
/**
* @return float
*/
public function getVat()
public function getVat(): ?float
{
return $this->model->getTemplate()->getVat();
}
@@ -97,4 +97,19 @@ class DefaultCalculator implements CalculatorInterface
{
return $this->model->getCustomer()->getCurrency();
}
/**
* Returns the total amount of worked time in seconds.
*
* @return int
*/
public function getTimeWorked(): int
{
$time = 0;
foreach ($this->model->getEntries() as $entry) {
$time += $entry->getDuration();
}
return $time;
}
}

View File

@@ -27,11 +27,16 @@ class ShortInvoiceCalculator extends DefaultCalculator
foreach ($this->model->getEntries() as $entry) {
$timesheet->setRate($timesheet->getRate() + $entry->getRate());
$timesheet->setDuration($timesheet->getDuration() + $entry->getDuration());
$timesheet->setBegin($entry->getBegin());
if (null === $timesheet->getActivity()) {
$timesheet->setActivity($entry->getActivity());
$timesheet->setEnd($entry->getEnd());
}
$timesheet->setBegin($entry->getBegin());
}
if (null !== $this->model->getQuery()->getActivity()) {
$timesheet->setDescription($this->model->getQuery()->getActivity()->getName());
} elseif (null !== $this->model->getQuery()->getProject()) {
$timesheet->setDescription($this->model->getQuery()->getProject()->getName());
}
return [$timesheet];