Compare commits
3 Commits
f7af631de6
...
631378deeb
Author | SHA1 | Date | |
---|---|---|---|
631378deeb | |||
9d713c894d | |||
38eca50d83 |
@ -674,13 +674,24 @@ Ticket Calculator::private_GetDurationFromCost(Configuration *cfg,
|
||||
|
||||
// Check prepaid
|
||||
if (!prepaid) {
|
||||
if ((current.time() < worktime_from) || (current.time() > worktime_to)) {
|
||||
qDebug() << "[STOP] * Ticket is not valid * ";
|
||||
if (current.time() < worktime_from) {
|
||||
qDebug() << "[STOP] TICKET IS NOT VALID: "
|
||||
<< QString("%1 (current) < %2 (start)")
|
||||
.arg(current.toString(Qt::ISODate)
|
||||
.arg(worktime_from.toString(Qt::ISODate)));
|
||||
return Ticket();
|
||||
} else
|
||||
if (current.time() > worktime_to) {
|
||||
qDebug() << "[STOP] TICKET IS NOT VALID: "
|
||||
<< QString("%1 (current) > %2 (end)")
|
||||
.arg(current.toString(Qt::ISODate)
|
||||
.arg(worktime_to.toString(Qt::ISODate)));
|
||||
return Ticket();
|
||||
}
|
||||
} else {
|
||||
qDebug() << "* PREPAID MODE ACTIVE *";
|
||||
if (current.time() < worktime_from) {
|
||||
qDebug() << "*** PREPAID *** Current time is before time range start, fast-forward to start"
|
||||
<< worktime_from.toString(Qt::ISODate);
|
||||
current.setTime(worktime_from);
|
||||
end = current;
|
||||
} else if(current.time() > lastWorktimeTo) {
|
||||
@ -696,10 +707,16 @@ Ticket Calculator::private_GetDurationFromCost(Configuration *cfg,
|
||||
if (!IsYearPeriodActive(cfg, current)) {
|
||||
return Ticket();
|
||||
}
|
||||
if(durationMinutesNetto > maxParkingTimeMinutes) {
|
||||
durationMinutesNetto = maxParkingTimeMinutes;
|
||||
break;
|
||||
}
|
||||
// if(durationMinutesNetto >= maxParkingTimeMinutes) {
|
||||
// might be useful for overpayment
|
||||
// durationMinutesNetto = maxParkingTimeMinutes;
|
||||
// int durationMinutesBrutto = start.secsTo(end) / 60;
|
||||
//
|
||||
// return
|
||||
// Ticket(start, end, durationMinutesNetto,
|
||||
// durationMinutesBrutto, cost, Ticket::s[INVALID_PRICE]);
|
||||
//
|
||||
// }
|
||||
if(current.time() >= lastWorktimeTo) {
|
||||
// Go to next day if minutes not spent
|
||||
if (carryOverNotSet) {
|
||||
@ -715,7 +732,16 @@ Ticket Calculator::private_GetDurationFromCost(Configuration *cfg,
|
||||
moneyLeft -= price;
|
||||
moneyLeft = std::round(moneyLeft * 1000.0) / 1000.0;
|
||||
current = current.addSecs(60);
|
||||
|
||||
//qCritical() << "moneyLeft" << moneyLeft
|
||||
// << "durationMinutesNetto" << durationMinutesNetto
|
||||
// << "current" << current.toString(Qt::ISODate);
|
||||
|
||||
if(durationMinutesNetto <= maxParkingTimeMinutes) {
|
||||
// stop updating of end-date if parking time is
|
||||
// overshot
|
||||
end = current;
|
||||
}
|
||||
} else break;
|
||||
}
|
||||
} // while(durationMinutes > 0) {
|
||||
|
@ -37,8 +37,8 @@ extern "C" char* strptime(const char* s,
|
||||
#define SCHOENAU_KOENIGSEE (0)
|
||||
#define NEUHAUSER_KORNEUBURG (0)
|
||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1)
|
||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||
#define NEUHAUSER_BILEXA_GALTUER (1)
|
||||
|
||||
|
||||
int main() {
|
||||
@ -146,6 +146,7 @@ int main() {
|
||||
qCritical() << "start=" << start.toString(Qt::ISODate)
|
||||
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
|
||||
}
|
||||
|
||||
for (int offset = 480; offset < 1080; ++offset) {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
||||
@ -184,15 +185,15 @@ int main() {
|
||||
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid);
|
||||
//qCritical() << "";
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "end" << end.toString(Qt::ISODate)
|
||||
// << "duration" << marken[duration]
|
||||
// << "cost" << cost;
|
||||
|
||||
std::string d = Calculator::GetInstance().GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
<< "cost" << cost
|
||||
<< "until" << d.c_str() << start.secsTo(QDateTime::fromString(d.c_str(), Qt::ISODate)) / 60;
|
||||
<< "end" << end.toString(Qt::ISODate)
|
||||
<< "duration" << marken[duration]
|
||||
<< "cost" << cost;
|
||||
|
||||
//std::string d = Calculator::GetInstance().GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "cost" << cost
|
||||
// << "until" << d.c_str() << start.secsTo(QDateTime::fromString(d.c_str(), Qt::ISODate)) / 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -254,7 +255,7 @@ int main() {
|
||||
int pop_min_price;
|
||||
int pop_max_price;
|
||||
|
||||
for (int t=2; t < 3; ++t) {
|
||||
for (int t=1; t < 2; ++t) {
|
||||
//for (int t=6; t < 7; t+=20) {
|
||||
switch (t) {
|
||||
case 1: {
|
||||
@ -305,11 +306,14 @@ int main() {
|
||||
qCritical() << " pop_max_time: " << pop_max_time;
|
||||
qCritical() << " pop_min_price: " << pop_min_price;
|
||||
qCritical() << " pop_max_price: " << pop_max_price;
|
||||
qCritical() << "pop_daily_card_price: " << cfg.getPaymentOptions().pop_daily_card_price;
|
||||
|
||||
{
|
||||
// zone 1 (lila)
|
||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
||||
QDateTime end;
|
||||
int cnt = 1;
|
||||
#if 0
|
||||
for (int duration = 15; duration <= pop_max_time; duration += 5) {
|
||||
for (int offset = 480; offset < 1080; ++offset) {
|
||||
QDateTime start = s.addSecs(offset * 60);
|
||||
@ -317,19 +321,34 @@ int main() {
|
||||
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration);
|
||||
// Q_ASSERT(cost == duration*2.5);
|
||||
qCritical() << "";
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
//qCritical() << "";
|
||||
qCritical() << cnt << "start" << start.toString(Qt::ISODate)
|
||||
<< "end" << end.toString(Qt::ISODate)
|
||||
<< "duration" << duration
|
||||
<< "cost" << cost;
|
||||
|
||||
std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg,
|
||||
3,
|
||||
start.toString(Qt::ISODate).toStdString().c_str(),
|
||||
cost, false, true);
|
||||
//Q_ASSERT(cost == duration*2.5);
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
qCritical() << cnt << "start" << start.toString(Qt::ISODate)
|
||||
<< "cost" << cost
|
||||
<< "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
#else
|
||||
QDateTime start = s.addSecs(480 * 60); // 8:00:00
|
||||
double cost = 2000;
|
||||
std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg,
|
||||
3,
|
||||
start.toString(Qt::ISODate).toStdString().c_str(),
|
||||
cost, false, true);
|
||||
qCritical() << cnt << "start" << start.toString(Qt::ISODate)
|
||||
<< "cost" << cost
|
||||
<< "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user