Re-implemented get_minimal_parkingtime() using PERMIT_TYPE-parameter.
Implemented get_maximal_parkingtime(), get_minimal_parkingprice() and get_maximal_parkingprice().
This commit is contained in:
parent
9899fe76fe
commit
6bf3960349
@ -14,12 +14,94 @@ QList<int> CALCULATE_LIBRARY_API get_time_steps(Configuration *cfg) {
|
||||
return Calculator::GetInstance().GetTimeSteps(cfg);
|
||||
}
|
||||
|
||||
int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration *cfg) {
|
||||
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);
|
||||
return qRound(cfg->getPaymentOptions().pop_min_time);
|
||||
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<QVector<ATBPaymentRate>> const &pv = cfg->getPaymentRateForKey(key);
|
||||
if (pv) {
|
||||
QVector<ATBPaymentRate> 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)
|
||||
|
Loading…
Reference in New Issue
Block a user