GetCostFromDuration(): use new parameter paymentOptionIndex.

This commit is contained in:
Gerhard Hoffmann 2024-04-19 13:31:01 +02:00
parent 1852f552a3
commit 1ac2ca91c5

View File

@ -4,6 +4,7 @@
#include "tariff_log.h"
#include "tariff_time_range.h"
#include "ticket.h"
#include "tariff_global_defines.h"
#include <sstream>
#include <algorithm>
@ -590,24 +591,26 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
uint32_t Calculator::GetCostFromDuration(Configuration *cfg,
QDateTime const &start,
quint64 timeStepInMinutes) const {
quint64 timeStepInMinutes,
int paymentOptionIndex) const {
// for instance, a tariff as used in Schoenau, Koenigssee: only steps, no
// special days, nonstop.
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
if (paymentMethodId == PaymentMethod::Steps) {
QDateTime const end = start.addSecs(timeStepInMinutes*60);
return GetCostFromDuration(cfg, start, end);
return GetCostFromDuration(cfg, start, end, paymentOptionIndex);
}
return 0;
}
uint32_t Calculator::GetCostFromDuration(Configuration * cfg,
QDateTime const &start,
QDateTime const &end) const {
QDateTime const &end,
int paymentOptionIndex) const {
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
if (paymentMethodId == PaymentMethod::Steps) {
int const timeStepInMinutes = start.secsTo(end) / 60;
return GetPriceForTimeStep(cfg, timeStepInMinutes);
return GetPriceForTimeStep(cfg, timeStepInMinutes, paymentOptionIndex);
}
return 0;
}