From 6bf3960349c0919eb2e6bcf046308edd30ad71b6 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 30 Jan 2024 10:39:24 +0100 Subject: [PATCH] Re-implemented get_minimal_parkingtime() using PERMIT_TYPE-parameter. Implemented get_maximal_parkingtime(), get_minimal_parkingprice() and get_maximal_parkingprice(). --- library/src/calculate_price.cpp | 94 ++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 6 deletions(-) diff --git a/library/src/calculate_price.cpp b/library/src/calculate_price.cpp index 325744d..a385b42 100644 --- a/library/src/calculate_price.cpp +++ b/library/src/calculate_price.cpp @@ -14,12 +14,94 @@ QList CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) { return Calculator::GetInstance().GetTimeSteps(cfg); } -int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg) { - // for each new sell-procedure, recomute the timesteps. implicitly, set - // the minimal parking time. - Calculator::GetInstance().ResetTimeSteps(); - Calculator::GetInstance().GetTimeSteps(cfg); - return qRound(cfg->getPaymentOptions().pop_min_time); +int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType) { + int minTime = 0; + + switch(permitType) { + case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) + minTime = cfg->getPaymentOptions().pop_min_time; + } break; + case PERMIT_TYPE::DAY_TICKET_ADULT: { + } break; + case PERMIT_TYPE::DAY_TICKET_TEEN: { + } break; + case PERMIT_TYPE::DAY_TICKET_CHILD: { + } break; + default: + // for each new sell-procedure, recomute the timesteps. implicitly, set + // the minimal parking time. + Calculator::GetInstance().ResetTimeSteps(); + Calculator::GetInstance().GetTimeSteps(cfg); + minTime = qRound(cfg->getPaymentOptions().pop_min_time); + } + + return minTime; +} + +int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration *cfg, PERMIT_TYPE permitType) { + int maxTime = 0; + + switch(permitType) { + case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) + maxTime = cfg->getPaymentOptions().pop_max_time; + } break; + case PERMIT_TYPE::DAY_TICKET_ADULT: { + } break; + case PERMIT_TYPE::DAY_TICKET_TEEN: { + } break; + case PERMIT_TYPE::DAY_TICKET_CHILD: { + } break; + default: ; + } + + return maxTime; +} + +int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) { + int minPrice = -1; + + switch(permitType) { + case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) + minPrice = cfg->getPaymentOptions().pop_min_price; + } break; + case PERMIT_TYPE::DAY_TICKET_ADULT: { + } break; + case PERMIT_TYPE::DAY_TICKET_TEEN: { + } break; + case PERMIT_TYPE::DAY_TICKET_CHILD: { + } break; + default: ; + } + + return minPrice; +} + +int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg, PERMIT_TYPE permitType) { + int maxPrice = -1; + + switch(permitType) { + case PERMIT_TYPE::SHORT_TERM_PARKING: { // e.g. szeged (customer_281) + int const key = cfg->getPaymentOptions().pop_id; + int const maxTime = cfg->getPaymentOptions().pop_max_time; // maxTime is given in minutes + std::optional> const &pv = cfg->getPaymentRateForKey(key); + if (pv) { + QVector const &paymentRate = pv.value(); + if (paymentRate.size() > 0) { + int const price = paymentRate.at(0).pra_price; // price is given per hour + maxPrice = qRound((maxTime * price) / 60.0f); + } + } + } break; + case PERMIT_TYPE::DAY_TICKET_ADULT: + break; + case PERMIT_TYPE::DAY_TICKET_TEEN: + break; + case PERMIT_TYPE::DAY_TICKET_CHILD: + break; + default: ; + } + + return maxPrice; } int CALCULATE_LIBRARY_API get_zone_nr(int zone)