Allow to recalculate rates via bulk edit (#1768)

This commit is contained in:
Kevin Papst
2020-06-05 12:25:56 +02:00
committed by GitHub
parent da5563960b
commit ae6beff5d8
6 changed files with 45 additions and 10 deletions

View File

@@ -330,14 +330,21 @@ abstract class TimesheetAbstractController extends AbstractController
$timesheet->setExported($dto->isExported()); $timesheet->setExported($dto->isExported());
$execute = true; $execute = true;
} }
// setting both values allows to erase wrong
if (null !== $dto->getHourlyRate()) { if ($dto->isRecalculateRates()) {
$timesheet->setFixedRate(null); $timesheet->setFixedRate(null);
$timesheet->setHourlyRate($dto->getHourlyRate()); $timesheet->setHourlyRate(null);
$timesheet->setInternalRate(null);
$execute = true; $execute = true;
} elseif (null !== $dto->getFixedRate()) { } elseif (null !== $dto->getFixedRate()) {
$timesheet->setFixedRate($dto->getFixedRate()); $timesheet->setFixedRate($dto->getFixedRate());
$timesheet->setHourlyRate(null); $timesheet->setHourlyRate(null);
$timesheet->setInternalRate(null);
$execute = true;
} elseif (null !== $dto->getHourlyRate()) {
$timesheet->setFixedRate(null);
$timesheet->setInternalRate(null);
$timesheet->setHourlyRate($dto->getHourlyRate());
$execute = true; $execute = true;
} }
} }

View File

@@ -198,12 +198,16 @@ class TimesheetMultiUpdate extends AbstractType
if ($options['include_rate']) { if ($options['include_rate']) {
$builder $builder
->add('recalculateRates', YesNoType::class, [
'label' => 'label.recalculate_rates',
])
->add('fixedRate', FixedRateType::class, [ ->add('fixedRate', FixedRateType::class, [
'currency' => $currency, 'currency' => $currency,
]) ])
->add('hourlyRate', HourlyRateType::class, [ ->add('hourlyRate', HourlyRateType::class, [
'currency' => $currency, 'currency' => $currency,
]); ])
;
} }
$builder->add('entities', HiddenType::class, [ $builder->add('entities', HiddenType::class, [

View File

@@ -29,6 +29,10 @@ class TimesheetMultiUpdateDTO extends MultiUpdateTableDTO
* @var bool * @var bool
*/ */
private $replaceTags = false; private $replaceTags = false;
/**
* @var bool
*/
private $recalculateRates = false;
/** /**
* @var Customer|null * @var Customer|null
*/ */
@@ -50,13 +54,13 @@ class TimesheetMultiUpdateDTO extends MultiUpdateTableDTO
*/ */
private $exported = null; private $exported = null;
/** /**
* @var float * @var float|null
*/ */
private $fixedRate; private $fixedRate = null;
/** /**
* @var float * @var float|null
*/ */
private $hourlyRate; private $hourlyRate = null;
public function getCustomer(): ?Customer public function getCustomer(): ?Customer
{ {
@@ -133,6 +137,18 @@ class TimesheetMultiUpdateDTO extends MultiUpdateTableDTO
return $this; return $this;
} }
public function isRecalculateRates(): bool
{
return $this->recalculateRates;
}
public function setRecalculateRates(bool $recalculateRates): TimesheetMultiUpdateDTO
{
$this->recalculateRates = $recalculateRates;
return $this;
}
public function isReplaceTags(): bool public function isReplaceTags(): bool
{ {
return $this->replaceTags; return $this->replaceTags;

View File

@@ -278,10 +278,10 @@ mpdf-->
{% set entryRateInternal = '–' %} {% set entryRateInternal = '–' %}
{% endif %} {% endif %}
{% if showInternalRate %} {% if showInternalRate %}
<td class="cost">{{ entryRate }}</td>
{% endif %}
<td class="cost">{{ entryRateInternal }}</td> <td class="cost">{{ entryRateInternal }}</td>
{% endif %} {% endif %}
<td class="cost">{{ entryRate }}</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
<tr class="summary"> <tr class="summary">

View File

@@ -304,6 +304,10 @@
<source>help.rate_internal</source> <source>help.rate_internal</source>
<target>Interner Verrechnungswert (wenn dieser nicht angegeben ist, wird der normale Satz verwendet)</target> <target>Interner Verrechnungswert (wenn dieser nicht angegeben ist, wird der normale Satz verwendet)</target>
</trans-unit> </trans-unit>
<trans-unit id="label.recalculate_rates">
<source>label.recalculate_rates</source>
<target>Preise neu berechnen</target>
</trans-unit>
<trans-unit id="label.language"> <trans-unit id="label.language">
<source>label.language</source> <source>label.language</source>
<target>Sprache</target> <target>Sprache</target>

View File

@@ -304,6 +304,10 @@
<source>help.rate_internal</source> <source>help.rate_internal</source>
<target>Internal costs (if this is not specified, the normal rate is used)</target> <target>Internal costs (if this is not specified, the normal rate is used)</target>
</trans-unit> </trans-unit>
<trans-unit id="label.recalculate_rates">
<source>label.recalculate_rates</source>
<target>Recalculate rates</target>
</trans-unit>
<trans-unit id="label.language"> <trans-unit id="label.language">
<source>label.language</source> <source>label.language</source>
<target>Language</target> <target>Language</target>