Fix: do not divide by durationUnit when calling recursively GetCostFromDuration()

This commit is contained in:
Gerhard Hoffmann 2024-01-08 15:48:10 +01:00
parent 68ba6808fa
commit e050a8a82a

View File

@ -491,7 +491,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
{ {
LOG_DEBUG("- No workday found, trying to find next available day"); LOG_DEBUG("- No workday found, trying to find next available day");
inputDate = inputDate.addDays(1); inputDate = inputDate.addDays(1);
return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid) / durationUnit; return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid);
} }
worktime_from = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_from.c_str()); worktime_from = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_from.c_str());
worktime_to = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_to.c_str()); worktime_to = QTime::fromString(cfg->WeekDaysWorktime.find(weekdayId)->second.pwd_time_to.c_str());
@ -504,7 +504,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
{ {
inputDate = inputDate.addDays(1); inputDate = inputDate.addDays(1);
inputDate.setTime(worktime_from); inputDate.setTime(worktime_from);
return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid) / durationUnit; return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid);
} }
// If overtime flag is set // If overtime flag is set
@ -534,7 +534,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
{ {
LOG_DEBUG(" *** PREPAID *** Current time is past the time range end, searching for next available day"); LOG_DEBUG(" *** PREPAID *** Current time is past the time range end, searching for next available day");
inputDate = inputDate.addDays(1); inputDate = inputDate.addDays(1);
return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid) / durationUnit; return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, durationMin, true, prepaid);
} }
} }
@ -586,7 +586,7 @@ double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_optio
LOG_DEBUG("Reached end of worktime, searching for the next working day"); LOG_DEBUG("Reached end of worktime, searching for the next working day");
inputDate = inputDate.addDays(1); inputDate = inputDate.addDays(1);
overtime = true; overtime = true;
return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, total_duration_min) / durationUnit; return GetCostFromDuration(cfg, payment_option, inputDate, end_datetime, total_duration_min);
} }
// Increment input date minutes for each monetary unit // Increment input date minutes for each monetary unit