get_minimal_parkingtime(): const Configuration parameter.

Cast of const pointer necessary.

get_maximal_parkingtime(): const Configuration parameter.
This commit is contained in:
Gerhard Hoffmann 2024-04-30 14:08:08 +02:00
parent f93cf11d23
commit 1dd81d4a56

View File

@ -14,7 +14,7 @@ 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, int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
PERMIT_TYPE permitType, PERMIT_TYPE permitType,
int paymentOptionIndex) { int paymentOptionIndex) {
int minTime = 0; int minTime = 0;
@ -33,14 +33,14 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg,
// 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(paymentOptionIndex); Calculator::GetInstance().ResetTimeSteps(paymentOptionIndex);
Calculator::GetInstance().GetTimeSteps(cfg, paymentOptionIndex); Calculator::GetInstance().GetTimeSteps((Configuration *)cfg, paymentOptionIndex);
minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time); minTime = qRound(cfg->getPaymentOptions(paymentOptionIndex).pop_min_time);
} }
return minTime; return minTime;
} }
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
PERMIT_TYPE permitType, PERMIT_TYPE permitType,
int paymentOptionIndex) { int paymentOptionIndex) {
int maxTime = 0; int maxTime = 0;
@ -59,6 +59,7 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg,
} }
return maxTime; return maxTime;
} }
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
@ -156,6 +157,28 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
return product_price; return product_price;
} }
} break; } break;
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
std::optional<QVector<ATBTariffProduct>> products = cfg->getTariffProductForProductId(permitType);
if (products) {
int product_price = 0;
QVector<ATBTariffProduct> product = products.value();
if (product.size() > 0) {
if (productStart && productEnd) {
int pop_min_time = get_minimal_parkingtime(cfg); // in minutes
int pop_max_time = get_maximal_parkingtime(cfg); // in minutes
if (pop_max_time >= pop_min_time) {
*productStart = start;
*productEnd = start.addSecs(pop_max_time*60);
product_price = product[0].getProductPrice();
}
}
}
return product_price;
}
} break;
default: default:
break; break;
} }