Added new calc-state: SUCCESS_MAXPRICE.

Return whenever cost (=price) equals max-price.
This commit is contained in:
Gerhard Hoffmann 2024-09-16 16:49:00 +02:00
parent 7a7b10260a
commit 48afbc071c

View File

@ -136,6 +136,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
bool overPaid = false;
bool successMaxPrice = false; // max-price and cost match
int paymentOptionIndex = getPaymentOptionIndex(*cfg, inputDate);
if (paymentOptionIndex == -1) {
@ -273,6 +274,11 @@ Calculator::GetDurationFromCost(Configuration* cfg,
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
if (cost == pop_max_price) {
qCritical() << DBG_HEADER << "SUCCESS MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
successMaxPrice = true;
}
if (cost > pop_max_price) {
qCritical() << DBG_HEADER << "MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
if (pop_allow_overpay == false) {
@ -280,6 +286,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
}
cost = pop_max_price;
overPaid = true;
qCritical() << DBG_HEADER << "OVERPAID, MAX-PARKING-PRICE" << pop_max_price << ", COST" << cost;
// return CalcState::OVERPAID.toStdString();
}
@ -447,6 +454,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), d);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), d);
}
return std::make_pair(d.toString(Qt::ISODate).toStdString(), d);
}
} else {
@ -561,6 +571,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), inputDate);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), inputDate);
}
return std::make_pair(s.toStdString(), inputDate);
} // if ((double)price == cost) {
else {
@ -648,6 +661,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
} else {
QDateTime const dt = start;
@ -698,6 +714,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
@ -796,6 +815,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
}
@ -840,6 +862,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
@ -874,6 +899,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
@ -993,6 +1021,9 @@ Calculator::GetDurationFromCost(Configuration* cfg,
if (overPaid) {
return std::make_pair(CalcState::OVERPAID.toStdString(), end_datetime);
}
if (successMaxPrice) {
return std::make_pair(CalcState::SUCCESS_MAXPRICE.toStdString(), end_datetime);
}
return std::make_pair(end_datetime.toString(Qt::ISODate).toStdString(), end_datetime);
}
}