Compare commits
No commits in common. "master" and "2.3.99-24" have entirely different histories.
@ -37,7 +37,7 @@ struct ATBTariffCarryOver {
|
||||
if (coif == "always") {
|
||||
m_carryOverIf = ApplyCarryOver::ALWAYS;
|
||||
} else {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << coif;
|
||||
qCritical() << "ERROR unknown carry over application" << coif;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,22 +65,13 @@ struct ATBTariffCarryOver {
|
||||
int minutes = 0;
|
||||
QString end = m_range.m_end.toString(Qt::ISODate);
|
||||
if (end == "24:00:00") {
|
||||
// note: this did not work
|
||||
// QDateTime t(dt.addDays(1));
|
||||
// t.setTime(QTime(0,0,0));
|
||||
// dt: 2024-10-27T00:00:00 EEST, but t: 2024-10-28T00:00:00 EET (!)
|
||||
// so the difference is 1500 instead of 1440
|
||||
// reason: change from summer to winter time
|
||||
|
||||
// compute minutes directly
|
||||
if (dt.time().isValid()) {
|
||||
minutes = 1440 - (dt.time().hour() * 60 + dt.time().minute());
|
||||
}
|
||||
QDateTime t = dt.addDays(1);
|
||||
t.setTime(QTime(0,0,0));
|
||||
minutes = dt.secsTo(t) / 60;
|
||||
} else {
|
||||
QTime t(QTime::fromString(end, Qt::ISODate));
|
||||
if (t.isValid() && dt.time().isValid()) {
|
||||
minutes = (t.hour() * 60 + t.minute()) - (dt.time().hour() * 60 + dt.time().minute());
|
||||
}
|
||||
QDateTime t(dt);
|
||||
t.setTime(QTime::fromString(end, Qt::ISODate));
|
||||
minutes = dt.secsTo(t) / 60;
|
||||
}
|
||||
|
||||
if (minutes < 0 || minutes > m_range.m_duration) {
|
||||
|
@ -38,7 +38,7 @@ struct ATBTariffPrepaid {
|
||||
if (ppif == "always") {
|
||||
m_prepaidIf = ApplyPrepaid::ALWAYS;
|
||||
} else {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "ERROR unknown carry over application" << ppif;
|
||||
qCritical() << "ERROR unknown carry over application" << ppif;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,14 +396,16 @@ int CALCULATE_LIBRARY_API get_zone_nr(int zone)
|
||||
if(zone > -1) return zone;
|
||||
else
|
||||
{
|
||||
QFile zone("/mnt/system_data/zone_nr");
|
||||
QFile zone("/etc/zone_nr");
|
||||
if (zone.exists()) {
|
||||
QFileInfo finfo(zone);
|
||||
if (finfo.size() <= 4) { // decimal 000\n
|
||||
if (zone.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&zone);
|
||||
return in.readLine(100).toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -780,7 +782,7 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
double maxMin = tariff->getPaymentOptions(paymentOptionIndex).pop_max_time;
|
||||
|
||||
// DEBUG
|
||||
qCritical() << __func__ << ":" << __LINE__ << endl
|
||||
qCritical() << "compute_price_for_parking_ticket() " << endl
|
||||
<< " paymentOptionIndex: " << paymentOptionIndex << endl
|
||||
<< " start_parking_time: " << start_parking_time << endl
|
||||
<< " netto_parking_time: " << netto_parking_time << endl
|
||||
@ -912,12 +914,10 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
|
||||
if (carryOver == 1) {
|
||||
QTime carryOverStart = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_start;
|
||||
QTime carryOverEnd = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].static_end;
|
||||
int carryOverDuration = tariff->TariffCarryOverOptions.find(pop_carry_over_option_id)->second.carryover[weekDay].duration;
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart:" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << " carryOverEnd:" << carryOverEnd.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration:" << carryOverDuration;
|
||||
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "carryOverDuration" << carryOverDuration;
|
||||
|
||||
// handle carry over
|
||||
int minutesUntilCarryOver = effectiveStartTime.time().secsTo(carryOverStart) / 60;
|
||||
@ -944,20 +944,11 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
||||
} else
|
||||
if (end_parking_time.time() == carryOverStart) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart:" << carryOverStart.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << " carryOverStart" << carryOverStart.toString(Qt::ISODate);
|
||||
ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
|
||||
if (po.pop_apply_carry_over_to_ticket_endtime) {
|
||||
end_parking_time = end_parking_time.addSecs(carryOverDuration * 60);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "adapted end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
||||
}
|
||||
} else
|
||||
if (end_parking_time.time() == carryOverEnd) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
||||
qCritical() << __func__ << ":" << __LINE__ << " carryOverEnd:" << carryOverEnd.toString(Qt::ISODate);
|
||||
ATBPaymentOption const &po = tariff->getPaymentOptions(paymentOptionIndex);
|
||||
if (po.pop_apply_carry_over_to_ticket_endtime == false) {
|
||||
end_parking_time = end_parking_time.addSecs(-carryOverDuration * 60);
|
||||
qCritical() << __func__ << ":" << __LINE__ << "adapted end-parking-time:" << end_parking_time.toString(Qt::ISODate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -379,8 +379,7 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_accumulate_prices = cfg->getPaymentOptions(paymentOptionIndex).pop_accumulate_prices;
|
||||
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price =
|
||||
cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
|
||||
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
||||
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_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
|
||||
@ -453,50 +452,13 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
||||
netto_parking_time_in_minutes = 0;
|
||||
brutto_parking_time_in_minutes = 0;
|
||||
free_parking_time_in_minutes = 0;
|
||||
int nettoParktimeForCost = 0;
|
||||
|
||||
if (priceNettoParktime.contains(int(cost))) {
|
||||
nettoParktimeForCost = priceNettoParktime[int(cost)];
|
||||
int const nettoParktimeForCost = priceNettoParktime[int(cost)];
|
||||
qCritical() << __func__ << ":" << __LINE__ << QString("cost=%1 nettoParkTimeForCost=%2").
|
||||
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;
|
||||
while (++cnt < 20 && netto_parking_time_in_minutes < nettoParktimeForCost) {
|
||||
while (++cnt < 10 && netto_parking_time_in_minutes < nettoParktimeForCost) {
|
||||
// qCritical() << __func__ << ":" << __LINE__ << "cnt [" << cnt;
|
||||
|
||||
brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
|
||||
@ -950,8 +912,7 @@ Calculator::GetDurationFromCost(Configuration* cfg,
|
||||
}
|
||||
|
||||
int const pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
|
||||
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price
|
||||
= cfg->getPaymentOptions(paymentOptionIndex).pop_max_price_save;
|
||||
int const pop_max_price = cfg->getPaymentOptions(paymentOptionIndex).pop_max_price;
|
||||
//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_allow_overpay = cfg->getPaymentOptions(paymentOptionIndex).pop_allow_overpay;
|
||||
@ -3623,9 +3584,7 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep;
|
||||
}
|
||||
|
||||
// allow some tolerance when searching for [timeStep == pun_duration]:
|
||||
// this might happen when crossing minute boundaries
|
||||
if (std::abs(timeStep - pun_duration) < 4) {
|
||||
if (timeStep == pun_duration) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price;
|
||||
return price;
|
||||
}
|
||||
|
@ -171,9 +171,8 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
if (!d.isNull() && d.isValid()) {
|
||||
TariffPrepaid.m_date = d;
|
||||
}
|
||||
if (!prepaidIf.isNull() && !prepaidIf.trimmed().isEmpty()) {
|
||||
TariffPrepaid.setPrepaidIf(prepaidIf);
|
||||
}
|
||||
|
||||
qCritical() << TariffPrepaid;
|
||||
|
||||
cfg.TariffPrepaids.insert(std::pair<int, ATBTariffPrepaid>(weekDay, TariffPrepaid));
|
||||
@ -259,7 +258,7 @@ ATBWeekDay parseWeekDay(Configuration &cfg,
|
||||
if (!d.isNull() && d.isValid()) {
|
||||
TariffCarryOver.m_date = d;
|
||||
}
|
||||
if (!carryOverIf.isNull() && !carryOverIf.trimmed().isEmpty()) {
|
||||
if (!carryOverIf.isEmpty()) {
|
||||
TariffCarryOver.setCarryOverIf(carryOverIf);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user