improved invoices with new renderer (#306)
* added docx renderer and demo template * added csv renderer and demo template * added xlsx renderer and demo template * added ods renderer and demo template * added user calculator * added invoice documentation
This commit is contained in:
@@ -44,6 +44,7 @@ class RateCalculator implements CalculatorInterface
|
||||
$fixedRate = $this->findFixedRate($record);
|
||||
if (null !== $fixedRate) {
|
||||
$record->setRate($fixedRate);
|
||||
$record->setFixedRate($fixedRate);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -51,9 +52,11 @@ class RateCalculator implements CalculatorInterface
|
||||
$hourlyRate = $this->findHourlyRate($record);
|
||||
$factor = $this->getRateFactor($record);
|
||||
|
||||
$record->setRate(
|
||||
$this->calculateRate($record->getDuration(), $hourlyRate, $factor)
|
||||
);
|
||||
$hourlyRate = (float) $hourlyRate * $factor;
|
||||
$rate = (float) $hourlyRate * ($record->getDuration() / 3600);
|
||||
|
||||
$record->setHourlyRate($hourlyRate);
|
||||
$record->setRate($rate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,11 +130,6 @@ class RateCalculator implements CalculatorInterface
|
||||
$weekday = $record->getEnd()->format('l');
|
||||
$days = array_map('strtolower', $rateFactor['days']);
|
||||
if (in_array(strtolower($weekday), $days)) {
|
||||
if ($rateFactor['factor'] <= 0) {
|
||||
throw new \InvalidArgumentException(
|
||||
'A rate factor smaller or equals 0 is not allowed, given: ' . $rateFactor['factor']
|
||||
);
|
||||
}
|
||||
$factor += $rateFactor['factor'];
|
||||
}
|
||||
}
|
||||
@@ -142,15 +140,4 @@ class RateCalculator implements CalculatorInterface
|
||||
|
||||
return $factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $duration
|
||||
* @param float $hourlyRate
|
||||
* @param float $factor
|
||||
* @return float
|
||||
*/
|
||||
protected function calculateRate($duration, $hourlyRate, $factor)
|
||||
{
|
||||
return (float) $hourlyRate * ($duration / 3600) * $factor;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user