Take into account new payment method 'Unified' to call new tariff-calculator.

This commit is contained in:
Gerhard Hoffmann 2024-09-27 14:20:20 +02:00
parent dbccdba9fe
commit fd99c20bd9

View File

@ -338,7 +338,9 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
switch(permitType) {
case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281)
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
if (paymentMethodId == PaymentMethod::Progressive
|| paymentMethodId == PaymentMethod::Steps
|| paymentMethodId == PaymentMethod::Unified) {
//maxPrice = Utilities::getMaximalParkingPrice(cfg, paymentMethodId);
ATBPaymentOption const &po = cfg->getPaymentOptions(paymentOptionIndex);
maxPrice = po.pop_max_price; // maxTime is given in minutes
@ -518,6 +520,9 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
case PaymentMethod::Steps:
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Steps";
break;
case PaymentMethod::Unified:
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Unified";
break;
case PaymentMethod::Undefined:
qCritical() << __LINE__ << "compute_next_timestep() paymentMethodId: Undefined";
break;
@ -528,6 +533,8 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
if ((paymentMethodId == PaymentMethod::Steps) ||
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
(paymentMethodId == PaymentMethod::Progressive) ||
// unified tariff: starting with Bad Neuenahr (249), Tariff for Zone5
(paymentMethodId == PaymentMethod::Unified) ||
// degressive tariff: e.g. Fuchs Technik (500)
(paymentMethodId == PaymentMethod::Degressive))
{
@ -960,6 +967,19 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
return calcState.set(CalcState::State::ABOVE_MAX_PARKING_TIME);
}
}
} else
if (tariff->getPaymentOptions(0).pop_payment_method_id == PaymentMethod::Unified) {
std::pair<CalcState, std::optional<int>> p =
Calculator::GetInstance().ComputeCostFromDuration(tariff, start_parking_time, end_parking_time, netto_parking_time);
CalcState const cs = p.first;
if ((cs.getStatus() == CalcState::State::SUCCESS || cs.getStatus() == CalcState::State::SUCCESS_MAXPRICE)) {
if (p.second.has_value()) {
cost = p.second.value();
}
} else {
return cs;
}
} else {
cost = Calculator::GetInstance().GetCostFromDuration(
tariff,