get_minimal_parkingtime()

get_maximal_parkingtime()
get_minimal_parkingprice()
get_maximal_parkingprice():
use new parameter paymentOptionIndex.
This commit is contained in:
Gerhard Hoffmann 2024-04-12 14:27:08 +02:00
parent ac76f194e1
commit 4e7fa83507

View File

@ -14,12 +14,14 @@ QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
return Calculator::GetInstance().GetTimeSteps(cfg); return Calculator::GetInstance().GetTimeSteps(cfg);
} }
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType) { int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
PERMIT_TYPE permitType,
int paymentOptionIndex) {
int minTime = 0; int minTime = 0;
switch(permitType) { switch(permitType) {
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
minTime = cfg->getPaymentOptions().pop_min_time; minTime = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
} break; } break;
case PERMIT_TYPE::DAY_TICKET_ADULT: { case PERMIT_TYPE::DAY_TICKET_ADULT: {
} break; } break;
@ -30,20 +32,22 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, PERMIT_TYP
default: default:
// for each new sell-procedure, recomute the timesteps. implicitly, set // for each new sell-procedure, recomute the timesteps. implicitly, set
// the minimal parking time. // the minimal parking time.
Calculator::GetInstance().ResetTimeSteps(); Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex);
Calculator::GetInstance().GetTimeSteps(cfg); Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex);
minTime = qRound(cfg->getPaymentOptions().pop_min_time); minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
} }
return minTime; return minTime;
} }
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType) { int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
PERMIT_TYPE permitType,
int paymentOptionIndex) {
int maxTime = 0; int maxTime = 0;
switch(permitType) { switch(permitType) {
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
maxTime = cfg->getPaymentOptions().pop_max_time; maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
} break; } break;
case PERMIT_TYPE::DAY_TICKET_ADULT: { case PERMIT_TYPE::DAY_TICKET_ADULT: {
} break; } break;
@ -57,12 +61,14 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, PERMIT_TYP
return maxTime; return maxTime;
} }
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) { int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
PERMIT_TYPE permitType,
int paymentOptionIndex) {
int minPrice = -1; int minPrice = -1;
switch(permitType) { switch(permitType) {
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
minPrice = cfg->getPaymentOptions().pop_min_price; minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
} break; } break;
case PERMIT_TYPE::DAY_TICKET_ADULT: { case PERMIT_TYPE::DAY_TICKET_ADULT: {
} break; } break;
@ -119,7 +125,9 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT
return 0; return 0;
} }
int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) { int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
PERMIT_TYPE permitType,
int paymentOptionIndex) {
int maxPrice = -1; int maxPrice = -1;
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg); static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
@ -128,8 +136,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TY
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) { if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId); maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
} else { // PaymentMethod::Linear -> e.g. szeged } else { // PaymentMethod::Linear -> e.g. szeged
int const key = cfg->getPaymentOptions().pop_id; int const key = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes int const maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; // maxTime is given in minutes
std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key); std::optional<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
if (pv) { if (pv) {
QVector<ATBPaymentRate> const &paymentRate = pv.value(); QVector<ATBPaymentRate> const &paymentRate = pv.value();