Use of permitType in several places
This commit is contained in:
parent
003b7e8e8a
commit
b0ecef0361
@ -34,6 +34,8 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
|||||||
int paymentOptionIndex) {
|
int paymentOptionIndex) {
|
||||||
int minTime = 0;
|
int minTime = 0;
|
||||||
|
|
||||||
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
|
|
||||||
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(paymentOptionIndex).pop_min_time;
|
minTime = cfg->getPaymentOptions(paymentOptionIndex).pop_min_time;
|
||||||
@ -58,6 +60,8 @@ int CALCULATE_LIBRARY_API get_minimal_parkingtime(Configuration const *cfg,
|
|||||||
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
||||||
PERMIT_TYPE permitType,
|
PERMIT_TYPE permitType,
|
||||||
int paymentOptionIndex) {
|
int paymentOptionIndex) {
|
||||||
|
|
||||||
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
int maxTime = 0;
|
int maxTime = 0;
|
||||||
|
|
||||||
switch(permitType) {
|
switch(permitType) {
|
||||||
@ -71,10 +75,10 @@ int CALCULATE_LIBRARY_API get_maximal_parkingtime(Configuration const *cfg,
|
|||||||
case PERMIT_TYPE::DAY_TICKET_CHILD: {
|
case PERMIT_TYPE::DAY_TICKET_CHILD: {
|
||||||
} break;
|
} break;
|
||||||
default: ;
|
default: ;
|
||||||
|
maxTime = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
return maxTime;
|
return maxTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
||||||
@ -82,6 +86,7 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
|||||||
int paymentOptionIndex,
|
int paymentOptionIndex,
|
||||||
QDateTime const &start) {
|
QDateTime const &start) {
|
||||||
int minPrice = -1;
|
int minPrice = -1;
|
||||||
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
|
|
||||||
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)
|
||||||
@ -96,7 +101,8 @@ int CALCULATE_LIBRARY_API get_minimal_parkingprice(Configuration *cfg,
|
|||||||
case PERMIT_TYPE::DAY_TICKET: {
|
case PERMIT_TYPE::DAY_TICKET: {
|
||||||
minPrice = compute_product_price(cfg, permitType, start);
|
minPrice = compute_product_price(cfg, permitType, start);
|
||||||
} break;
|
} break;
|
||||||
default: ;
|
default:
|
||||||
|
minPrice = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||||
}
|
}
|
||||||
|
|
||||||
return minPrice;
|
return minPrice;
|
||||||
@ -214,7 +220,14 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
|||||||
|
|
||||||
} break;
|
} break;
|
||||||
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
|
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW: {
|
||||||
qCritical() << "TODO: SHORT_TERM_PARKING_PKW";
|
PermitType p(permitType);
|
||||||
|
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||||
|
if (paymentOption.has_value()) {
|
||||||
|
ATBPaymentOption option = paymentOption.value();
|
||||||
|
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||||
|
qCritical() << "SHORT_TERM_PARKING_PKW: daily ticket price" << pop_daily_card_price;
|
||||||
|
return pop_daily_card_price;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
|
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS: {
|
||||||
qCritical() << "TODO: SHORT_TERM_PARKING_BUS";
|
qCritical() << "TODO: SHORT_TERM_PARKING_BUS";
|
||||||
@ -223,15 +236,34 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
|||||||
qCritical() << "TODO: SHORT_TERM_PARKING_CAMPER";
|
qCritical() << "TODO: SHORT_TERM_PARKING_CAMPER";
|
||||||
} break;
|
} break;
|
||||||
case PERMIT_TYPE::DAY_TICKET_PKW: {
|
case PERMIT_TYPE::DAY_TICKET_PKW: {
|
||||||
int const pop_daily_card_price = cfg->getPaymentOptions().pop_daily_card_price;
|
PermitType p(permitType);
|
||||||
qCritical() << "DAY_TICKET_PKW: daily ticket price" << pop_daily_card_price;
|
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||||
return pop_daily_card_price;
|
if (paymentOption.has_value()) {
|
||||||
|
ATBPaymentOption option = paymentOption.value();
|
||||||
|
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||||
|
qCritical() << "DAY_TICKET_PKW: daily ticket price" << pop_daily_card_price;
|
||||||
|
return pop_daily_card_price;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case PERMIT_TYPE::DAY_TICKET_BUS: {
|
case PERMIT_TYPE::DAY_TICKET_BUS: {
|
||||||
qCritical() << "TODO: DAY_TICKET_BUS";
|
PermitType p(permitType);
|
||||||
|
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||||
|
if (paymentOption.has_value()) {
|
||||||
|
ATBPaymentOption option = paymentOption.value();
|
||||||
|
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||||
|
qCritical() << "DAY_TICKET_BUS: daily ticket price" << pop_daily_card_price;
|
||||||
|
return pop_daily_card_price;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case PERMIT_TYPE::DAY_TICKET_CAMPER: {
|
case PERMIT_TYPE::DAY_TICKET_CAMPER: {
|
||||||
qCritical() << "TODO: DAY_TICKET_CAMPER";
|
PermitType p(permitType);
|
||||||
|
std::optional<ATBPaymentOption> const paymentOption = cfg->getPaymentOptionForKey(p.get());
|
||||||
|
if (paymentOption.has_value()) {
|
||||||
|
ATBPaymentOption option = paymentOption.value();
|
||||||
|
int const pop_daily_card_price = option.pop_daily_card_price;
|
||||||
|
qCritical() << "DAY_TICKET_CAMPER: daily ticket price" << pop_daily_card_price;
|
||||||
|
return pop_daily_card_price;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -246,6 +278,8 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
|||||||
int maxPrice = -1;
|
int maxPrice = -1;
|
||||||
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
|
||||||
|
paymentOptionIndex = cfg->getPaymentOptionIndex(permitType);
|
||||||
|
|
||||||
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)
|
||||||
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
if (paymentMethodId == PaymentMethod::Progressive || paymentMethodId == PaymentMethod::Steps) {
|
||||||
@ -269,6 +303,18 @@ int CALCULATE_LIBRARY_API get_maximal_parkingprice(Configuration *cfg,
|
|||||||
break;
|
break;
|
||||||
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
case PERMIT_TYPE::DAY_TICKET_CHILD:
|
||||||
break;
|
break;
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_BUS:
|
||||||
|
break;
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_CAMPER:
|
||||||
|
break;
|
||||||
|
case PERMIT_TYPE::DAY_TICKET_PKW:
|
||||||
|
break;
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_BUS:
|
||||||
|
break;
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_PKW:
|
||||||
|
break;
|
||||||
|
case PERMIT_TYPE::SHORT_TERM_PARKING_CAMPER:
|
||||||
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,11 +405,22 @@ void CALCULATE_LIBRARY_API free_tariff(parking_tariff_t *tariff) {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// UpDown 1 -> up; 0 -> down
|
// UpDown 1 -> up; 0 -> down
|
||||||
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes, int UpDown)
|
int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int currentTimeMinutes,
|
||||||
|
int UpDown, PermitType const &permitType)
|
||||||
{
|
{
|
||||||
|
|
||||||
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
qCritical() << " compute_next_timestep() currentTimeMinutes: " << currentTimeMinutes;
|
||||||
qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
|
qCritical() << " compute_next_timestep() up/down (1=up, 0=down): " << UpDown;
|
||||||
|
|
||||||
|
std::optional<ATBPaymentOption> paymentOption = tariff->getPaymentOptionForKey(permitType.get());
|
||||||
|
if (!paymentOption.has_value()) {
|
||||||
|
return currentTimeMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType);
|
||||||
|
qCritical() << " compute_next_timestep() payment option index: " << paymentOptionIndex;
|
||||||
|
|
||||||
|
|
||||||
Configuration const *cfg = tariff;
|
Configuration const *cfg = tariff;
|
||||||
|
|
||||||
// compute payment method id (e.g. Linear=3, Steps=4)
|
// compute payment method id (e.g. Linear=3, Steps=4)
|
||||||
@ -392,7 +449,9 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
// progressive tariff: e.g. Neuhauser, Kirchdorf (743)
|
||||||
(paymentMethodId == PaymentMethod::Progressive))
|
(paymentMethodId == PaymentMethod::Progressive))
|
||||||
{
|
{
|
||||||
QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff);
|
// int paymentOptionIndex = 1;
|
||||||
|
|
||||||
|
QList<int> &stepList = Calculator::GetInstance().GetTimeSteps(tariff, paymentOptionIndex);
|
||||||
int const size = stepList.size();
|
int const size = stepList.size();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
qCritical() << "compute_next_timestep() *ERROR empty step-list*";
|
qCritical() << "compute_next_timestep() *ERROR empty step-list*";
|
||||||
@ -482,12 +541,16 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu
|
|||||||
// this is currently not used
|
// this is currently not used
|
||||||
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||||
parking_tariff_t *tariff,
|
parking_tariff_t *tariff,
|
||||||
time_t start_parking_time, // in minutes
|
time_t start_parking_time, // in minutes
|
||||||
time_t end_parking_time, // netto time in minutes
|
time_t end_parking_time, // netto time in minutes
|
||||||
struct price_t *price) {
|
struct price_t *price,
|
||||||
|
PermitType permitType) { // permitType maps to product
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_min_time;
|
|
||||||
double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_max_time;
|
int const paymentOptionIndex = tariff->getPaymentOptionIndex(permitType.get());
|
||||||
|
|
||||||
|
double minMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_time;
|
||||||
|
double maxMin = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_max_time;
|
||||||
|
|
||||||
if (minMin < 0 || maxMin < 0 || maxMin < minMin) {
|
if (minMin < 0 || maxMin < 0 || maxMin < minMin) {
|
||||||
calcState.setDesc(QString("minMin=%1, maxMin=%2").arg(minMin).arg(maxMin));
|
calcState.setDesc(QString("minMin=%1, maxMin=%2").arg(minMin).arg(maxMin));
|
||||||
@ -520,13 +583,13 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
if (start.isValid()) {
|
if (start.isValid()) {
|
||||||
double cost = Calculator::GetInstance().GetCostFromDuration(
|
double cost = Calculator::GetInstance().GetCostFromDuration(
|
||||||
tariff,
|
tariff,
|
||||||
tariff->getPaymentOptions().pop_payment_method_id,
|
tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
duration, false, true);
|
duration, false, true);
|
||||||
double minCost = tariff->PaymentOption.find(tariff->getPaymentOptions().pop_payment_method_id)->second.pop_min_price;
|
double minCost = tariff->PaymentOption.find(tariff->getPaymentOptions(paymentOptionIndex).pop_payment_method_id)->second.pop_min_price;
|
||||||
if (cost < minCost) {
|
if (cost < minCost) {
|
||||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost).arg(cost));
|
calcState.setDesc(QString("line=%1 minCost=%2, cost=%3").arg(__LINE__).arg(minCost).arg(cost));
|
||||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
||||||
}
|
}
|
||||||
price->units = cost;
|
price->units = cost;
|
||||||
@ -544,6 +607,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
int netto_parking_time,
|
int netto_parking_time,
|
||||||
QDateTime &end_parking_time,
|
QDateTime &end_parking_time,
|
||||||
struct price_t *price,
|
struct price_t *price,
|
||||||
|
PermitType /* permitType */,
|
||||||
bool prepaid)
|
bool prepaid)
|
||||||
{
|
{
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
@ -609,7 +673,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
double minCost = tariff->getPaymentOptions(paymentOptionIndex).pop_min_price;
|
||||||
if (cost < minCost) {
|
if (cost < minCost) {
|
||||||
calcState.setDesc(QString("minCost=%1, cost=%2").arg(minCost).arg(cost));
|
calcState.setDesc(QString("line=%1 minCost=%2, cost=%3").arg(__LINE__).arg(minCost).arg(cost));
|
||||||
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
return calcState.set(CalcState::State::BELOW_MIN_PARKING_PRICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,7 +696,8 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
parking_tariff_t *tariff,
|
parking_tariff_t *tariff,
|
||||||
time_t start_parking_time,
|
time_t start_parking_time,
|
||||||
double price,
|
double price,
|
||||||
QString &duration) {
|
QString &duration,
|
||||||
|
PermitType permitType) {
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
QDate const d(1970, 1, 1);
|
QDate const d(1970, 1, 1);
|
||||||
QTime const t(0, 0, 0);
|
QTime const t(0, 0, 0);
|
||||||
@ -666,7 +731,8 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
parking_tariff_t *tariff,
|
parking_tariff_t *tariff,
|
||||||
QDateTime const &start_parking_time,
|
QDateTime const &start_parking_time,
|
||||||
double price,
|
double price,
|
||||||
QDateTime &ticketEndTime)
|
QDateTime &ticketEndTime,
|
||||||
|
PermitType permitType)
|
||||||
{
|
{
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
if (start_parking_time.isValid()) {
|
if (start_parking_time.isValid()) {
|
||||||
@ -754,7 +820,10 @@ CalcState CALCULATE_LIBRARY_API compute_duration_for_parking_ticket(
|
|||||||
return calcState.set(CalcState::State::SUCCESS);
|
return calcState.set(CalcState::State::SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff, QDateTime const &start_parking_time, QDateTime &ticketEndTime)
|
CalcState CALCULATE_LIBRARY_API compute_duration_for_daily_ticket(parking_tariff_t *tariff,
|
||||||
|
QDateTime const &start_parking_time,
|
||||||
|
QDateTime &ticketEndTime,
|
||||||
|
PermitType PermitType)
|
||||||
{
|
{
|
||||||
CalcState calcState;
|
CalcState calcState;
|
||||||
if (start_parking_time.isValid()) {
|
if (start_parking_time.isValid()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user