Compare commits

..

No commits in common. "master" and "kleipeda-experimental" have entirely different histories.

4 changed files with 10 additions and 50 deletions

View File

@ -37,7 +37,7 @@ struct ATBTariffCarryOver {
if (coif == "always") { if (coif == "always") {
m_carryOverIf = ApplyCarryOver::ALWAYS; m_carryOverIf = ApplyCarryOver::ALWAYS;
} else { } else {
qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << coif; qCritical() << "ERROR unknown carry over application" << coif;
} }
} }

View File

@ -38,7 +38,7 @@ struct ATBTariffPrepaid {
if (ppif == "always") { if (ppif == "always") {
m_prepaidIf = ApplyPrepaid::ALWAYS; m_prepaidIf = ApplyPrepaid::ALWAYS;
} else { } else {
qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << ppif; qCritical() << "ERROR unknown carry over application" << ppif;
} }
} }

View File

@ -379,8 +379,7 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id; int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices; int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price; int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay; int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
@ -453,47 +452,10 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
netto_parking_time_in_minutes = 0; netto_parking_time_in_minutes = 0;
brutto_parking_time_in_minutes = 0; brutto_parking_time_in_minutes = 0;
free_parking_time_in_minutes = 0; free_parking_time_in_minutes = 0;
int nettoParktimeForCost = 0;
if (priceNettoParktime.contains(int(cost))) { int const nettoParktimeForCost = priceNettoParktime[int(cost)];
nettoParktimeForCost = priceNettoParktime[int(cost)]; qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 nettoParkTimeForCost=%2").
qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 nettoParkTimeForCost=%2"). arg(cost).arg(nettoParktimeForCost);
arg(cost).arg(nettoParktimeForCost);
} else {
// cannot find netto-parking time for cost (=price)
// this happens for direct coin input and should not happen otherwise
// take the value for the nearest value of cost and mark result as overpaid
QList <int> keys = priceNettoParktime.keys(); // keys (=prices) are sorted in ascending order
QSet<int> s; // make keys unique
for (int k = 0; k < keys.size(); ++k) {
if (keys[k] < cost) {
s << keys[k];
}
}
keys = s.values();
// sort in descending order
std::sort(std::begin(keys), std::end(keys), std::greater<>());
// qCritical() << __func__ << ":" << __LINE__ << "keys=" << keys;
if (!keys.isEmpty()) {
int const maxCost = keys[0];
auto const p = priceNettoParktime.equal_range(maxCost);
for (auto it = p.first; it != p.second; ++it) {
nettoParktimeForCost = std::max(nettoParktimeForCost, it.value());
}
ATBPaymentOption &po = cfg->getPaymentOptions(paymentOptionIndex);
po.pop_max_price = maxCost;
cfg->getPaymentOptions(paymentOptionIndex).pop_max_price = maxCost;
if (pop_allow_overpay) {
overPaid = true;
}
qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 -> maxCost=%2 nettoParkTimeForCost=%3").
arg(cost).arg(maxCost).arg(nettoParktimeForCost);
} else {
qCritical() << __func__ << ":" << __LINE__ << "ERROR empty keys -> check tariff file";
}
}
int cnt = 0; int cnt = 0;
while (++cnt < 20 && netto_parking_time_in_minutes < nettoParktimeForCost) { while (++cnt < 20 && netto_parking_time_in_minutes < nettoParktimeForCost) {
@ -950,8 +912,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
} }
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id; int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
= cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
//int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time; //int const pop_max_time = cfg->getPaymentOptions(paymentOptionIndex).pop_max_time;
int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price; int const pop_min_price = cfg->getPaymentOptions(paymentOptionIndex).pop_min_price;
int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay; int const pop_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;

View File

@ -171,9 +171,8 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
if (!d.isNull() && d.isValid()) { if (!d.isNull() && d.isValid()) {
TariffPrepaid.m_date = d; TariffPrepaid.m_date = d;
} }
if (!prepaidIf.isNull() && !prepaidIf.trimmed().isEmpty()) { TariffPrepaid.setPrepaidIf(prepaidIf);
TariffPrepaid.setPrepaidIf(prepaidIf);
}
qCritical() << TariffPrepaid; qCritical() << TariffPrepaid;
cfg.TariffPrepaids.insert(std::pair<int, ATBTariffPrepaid>(weekDay, TariffPrepaid)); cfg.TariffPrepaids.insert(std::pair<int, ATBTariffPrepaid>(weekDay, TariffPrepaid));
@ -259,7 +258,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
if (!d.isNull() && d.isValid()) { if (!d.isNull() && d.isValid()) {
TariffCarryOver.m_date = d; TariffCarryOver.m_date = d;
} }
if (!carryOverIf.isNull() && !carryOverIf.trimmed().isEmpty()) { if (!carryOverIf.isEmpty()) {
TariffCarryOver.setCarryOverIf(carryOverIf); TariffCarryOver.setCarryOverIf(carryOverIf);
} }