added freelancer invoice template (#254)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user