Configurable rate rounding (#5734)

* added invoice hydration of the issuer object
* added "rate calculator" mode
* new config to select rounding mode
* replace static calls with dependency injection
This commit is contained in:
Kevin Papst
2025-12-16 16:47:46 +01:00
committed by GitHub
parent 07ac6c308f
commit 595b5f4b25
43 changed files with 876 additions and 411 deletions

View File

@@ -13,13 +13,18 @@ use App\Entity\RateInterface;
use App\Entity\Timesheet;
use App\Entity\UserPreference;
use App\Repository\TimesheetRepository;
use App\Timesheet\RateCalculator\RateCalculatorMode;
/**
* Implementation to calculate the rate for a timesheet record.
*/
final class RateService implements RateServiceInterface
{
public function __construct(private array $rates, private TimesheetRepository $repository)
public function __construct(
private readonly array $rates,
private readonly TimesheetRepository $repository,
private readonly RateCalculatorMode $calculatorMode
)
{
}
@@ -79,8 +84,8 @@ final class RateService implements RateServiceInterface
$totalInternalRate = 0;
if (null !== $record->getDuration()) {
$totalRate = Util::calculateRate($factoredHourlyRate, $record->getDuration());
$totalInternalRate = Util::calculateRate($factoredInternalRate, $record->getDuration());
$totalRate = $this->calculatorMode->calculateRate($factoredHourlyRate, $record->getDuration());
$totalInternalRate = $this->calculatorMode->calculateRate($factoredInternalRate, $record->getDuration());
}
return new Rate($totalRate, $totalInternalRate, $factoredHourlyRate, null);