added internal rates (#1591)

This commit is contained in:
Kevin Papst
2020-04-08 14:50:15 +02:00
committed by GitHub
parent 82c713031e
commit 68d703d1e3
128 changed files with 4044 additions and 1571 deletions

View File

@@ -57,6 +57,11 @@ abstract class AbstractMergedCalculator extends AbstractCalculator
$invoiceItem->setAmount($invoiceItem->getAmount() + $amount);
$invoiceItem->setUser($entry->getUser());
$invoiceItem->setRate($invoiceItem->getRate() + $entry->getRate());
if (method_exists($entry, 'getInternalRate')) {
$invoiceItem->setInternalRate($invoiceItem->getInternalRate() + $entry->getInternalRate());
} else {
$invoiceItem->setInternalRate($invoiceItem->getInternalRate() + $entry->getRate());
}
$invoiceItem->setDuration($duration);
if (null !== $entry->getFixedRate()) {

View File

@@ -53,17 +53,11 @@ abstract class AbstractSumInvoiceCalculator extends AbstractMergedCalculator imp
return array_values($invoiceItems);
}
/**
* @deprecated since 1.9 - use mergeSumInvoiceItem() instead
*/
protected function mergeSumTimesheet(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
{
}
protected function mergeSumInvoiceItem(InvoiceItem $invoiceItem, InvoiceItemInterface $entry)
{
@trigger_error('mergeSumTimesheet() is deprecated and will be removed with 2.0', E_USER_DEPRECATED);
$this->mergeSumTimesheet($invoiceItem, $entry);
if (method_exists($this, 'mergeSumTimesheet')) {
@trigger_error('mergeSumTimesheet() is deprecated and will be removed with 2.0 - use mergeSumInvoiceItem() instead', E_USER_DEPRECATED);
$this->mergeSumTimesheet($invoiceItem, $entry);
}
}
}

View File

@@ -30,6 +30,7 @@ class InvoiceItemDefaultHydrator implements InvoiceItemHydrator
$formatter = $this->model->getFormatter();
$rate = $item->getRate();
$internalRate = $item->getInternalRate();
$appliedRate = $item->getHourlyRate();
$amount = $formatter->getFormattedDuration($item->getDuration());
$description = $item->getDescription();
@@ -65,6 +66,9 @@ class InvoiceItemDefaultHydrator implements InvoiceItemHydrator
'entry.rate' => $formatter->getFormattedMoney($appliedRate, $currency),
'entry.rate_nc' => $formatter->getFormattedMoney($appliedRate, null),
'entry.rate_plain' => $appliedRate,
'entry.rate_internal' => $formatter->getFormattedMoney($internalRate, $currency),
'entry.rate_internal_nc' => $formatter->getFormattedMoney($internalRate, null),
'entry.rate_internal_plain' => $internalRate,
'entry.total' => $formatter->getFormattedMoney($rate, $currency),
'entry.total_nc' => $formatter->getFormattedMoney($rate, null),
'entry.total_plain' => $rate,

View File

@@ -30,6 +30,10 @@ final class InvoiceItem
* @var float
*/
private $rate = 0.00;
/**
* @var float
*/
private $rateInternal = 0.00;
/**
* @var float
*/
@@ -152,6 +156,18 @@ final class InvoiceItem
return $this;
}
public function getInternalRate(): float
{
return $this->rateInternal;
}
public function setInternalRate(float $rateInternal): InvoiceItem
{
$this->rateInternal = $rateInternal;
return $this;
}
public function getAmount(): float
{
return $this->amount;

View File

@@ -14,6 +14,9 @@ use App\Entity\MetaTableTypeInterface;
use App\Entity\Project;
use App\Entity\User;
/**
* @method float|null getInternalRate()
*/
interface InvoiceItemInterface
{
public function getActivity(): ?Activity;
@@ -26,6 +29,11 @@ interface InvoiceItemInterface
public function getRate(): float;
// will be activated with 2.0
/*
public function getInternalRate(): ?float;
*/
public function getUser(): ?User;
public function getBegin(): ?\DateTime;

View File

@@ -25,14 +25,14 @@ final class ConfigurableNumberGenerator implements NumberGeneratorInterface
*/
private $repository;
/**
* @var string
* @var SystemConfiguration
*/
private $format;
private $configuration;
public function __construct(InvoiceRepository $repository, SystemConfiguration $configuration)
{
$this->repository = $repository;
$this->format = $configuration->find('invoice.number_format');
$this->configuration = $configuration;
}
/**
@@ -56,9 +56,8 @@ final class ConfigurableNumberGenerator implements NumberGeneratorInterface
*/
public function getInvoiceNumber(): string
{
$format = $this->format;
$format = $this->configuration->find('invoice.number_format');
$invoiceDate = $this->model->getInvoiceDate();
$timestamp = $invoiceDate->getTimestamp();
$result = $format;
preg_match_all('/{[^}]*?}/', $format, $matches);