Private GetCostFromDuration() and GetCostFromDuration() helpers:

Use pyament method id (=4) as condition for if(...).
The other condition (tariffIs24_7()) is used in calling functions.
This commit is contained in:
Gerhard Hoffmann 2023-12-12 10:49:51 +01:00
parent 60002404da
commit 67b12f4b33

View File

@ -182,9 +182,8 @@ uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
quint64 timeStepInMinutes) const {
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
// special days, nonstop.
if (cfg->YearPeriod.size() == 0
&& cfg->SpecialDays.size() == 0
&& cfg->SpecialDaysWorktime.size() == 0) {
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
if (paymentMethodId == PaymentMethod::Steps) {
QDateTime const end = start.addSecs(timeStepInMinutes*60);
return GetCostFromDuration(cfg, start, end);
}
@ -194,9 +193,8 @@ uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
QDateTime const &start,
QDateTime const &end) const {
if (cfg->YearPeriod.size() == 0
&& cfg->SpecialDays.size() == 0
&& cfg->SpecialDaysWorktime.size() == 0) {
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
if (paymentMethodId == PaymentMethod::Steps) {
int const timeStepInMinutes = start.secsTo(end) / 60;
return GetPriceForTimeStep(cfg, timeStepInMinutes);
}