Release 2.0.17 (#3992)
* prevent empty title for select options * removed css for unused sweetalert * fix isWeekend() check with DateTimeInterface * reset timesheet rates on "create copy" * wrap long names in multi-selects - fix #4001 * rename profile menus * show all possible links in user profile dropdown * check if plugin is compatible before displaying the buy link
This commit is contained in:
@@ -17,29 +17,20 @@ final class RateResetCalculator implements CalculatorInterface
|
||||
public function calculate(Timesheet $record, array $changeset): void
|
||||
{
|
||||
// check if the rate was changed manually
|
||||
$changedRate = false;
|
||||
foreach (['hourlyRate', 'fixedRate', 'internalRate', 'rate'] as $field) {
|
||||
if (\array_key_exists($field, $changeset)) {
|
||||
$changedRate = true;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if no manual rate changed was applied:
|
||||
// check if a field changed, that is relevant for the rate calculation: if one was changed =>
|
||||
// check if a field changed, that is relevant for the rate calculation
|
||||
// reset all rates, because most users do not even see their rates and would not be able
|
||||
// to fix or empty the rate, even if they knew that the changed project has another base rate
|
||||
if (!$changedRate) {
|
||||
foreach (['project', 'activity', 'user'] as $field) {
|
||||
if (\array_key_exists($field, $changeset)) {
|
||||
// this has room for minor improvements: entries with a manual rate might be changed
|
||||
$record->setRate(0.00);
|
||||
$record->setInternalRate(null);
|
||||
$record->setHourlyRate(null);
|
||||
$record->setFixedRate(null);
|
||||
$record->setBillableMode(Timesheet::BILLABLE_AUTOMATIC);
|
||||
break;
|
||||
}
|
||||
// to change the rate, even if they knew that the changed project has another base rate
|
||||
foreach (['project', 'activity', 'user'] as $field) {
|
||||
if (\array_key_exists($field, $changeset)) {
|
||||
$record->resetRates();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user