GetCostFromDuration(): don't use condiftion PaymentMethod::Steps,

but the multimap YearPeriod, which must be empty.
This commit is contained in:
Gerhard Hoffmann 2023-11-23 09:39:26 +01:00
parent 574161ff76
commit 80e228b498

View File

@ -350,30 +350,28 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
/// <inheritdoc/>
///
uint32_t Calculator::GetCostFromDuration(Configuration const* cfg,
uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
QDateTime const &start,
quint64 timeStepInMinutes,
uint8_t paymentMethod) {
quint64 timeStepInMinutes) const {
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
// special days, nonstop.
if (paymentMethod == PaymentMethod::Steps
if (cfg->YearPeriod.size() == 0
&& cfg->SpecialDays.size() == 0
&& cfg->SpecialDaysWorktime.size() == 0) {
QDateTime const end = start.addSecs(timeStepInMinutes*60);
return GetCostFromDuration(cfg, start, end, paymentMethod);
return GetCostFromDuration(cfg, start, end);
}
return 0;
}
uint32_t Calculator::GetCostFromDuration(Configuration const* cfg,
uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
QDateTime const &start,
QDateTime const &end,
uint8_t paymentMethod) {
if (paymentMethod == PaymentMethod::Steps
QDateTime const &end) const {
if (cfg->YearPeriod.size() == 0
&& cfg->SpecialDays.size() == 0
&& cfg->SpecialDaysWorktime.size() == 0) {
int const timeStepInMinutes = start.secsTo(end) / 60;
return GetPriceForTimeStep(cfg, paymentMethod, timeStepInMinutes);
return GetPriceForTimeStep(cfg, timeStepInMinutes);
}
return 0;
}
@ -386,12 +384,12 @@ uint32_t Calculator::GetCostFromDuration(Configuration const* cfg,
/// <inheritdoc/>
double Calculator::GetCostFromDuration(Configuration* cfg, uint8_t payment_option, const QDateTime start_datetime, QDateTime & end_datetime, double durationMin, bool nextDay, bool prepaid)
{
// condition for 'PaymentMethod::Steps' (e.g. 332/Schoenau):
if (cfg->SpecialDays.size() == 0
if (cfg->YearPeriod.size() == 0
&& cfg->SpecialDays.size() == 0
&& cfg->SpecialDaysWorktime.size() == 0)
{
end_datetime = start_datetime.addSecs(durationMin*60);
return GetCostFromDuration(cfg, start_datetime, end_datetime, PaymentMethod::Steps);
return GetCostFromDuration(cfg, start_datetime, end_datetime);
}
// Get input date