Compare commits
No commits in common. "5a55ad6ef04b99ea7c4f0be8020950d9cbc76826" and "28f0ea9fcea27c3dc367671d92e96a2323c6fcef" have entirely different histories.
5a55ad6ef0
...
28f0ea9fce
@ -131,51 +131,16 @@ std::optional<ATBTariffPrepaid> getPrepaid(Configuration const *cfg, QDateTime c
|
|||||||
std::optional<ATBTariffPrepaid> value = std::nullopt;
|
std::optional<ATBTariffPrepaid> value = std::nullopt;
|
||||||
|
|
||||||
int weekDay = dt.date().dayOfWeek();
|
int weekDay = dt.date().dayOfWeek();
|
||||||
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << dt.toString(Qt::ISODate) << weekDay;
|
|
||||||
|
|
||||||
ATBTime inputTime(dt.time());
|
ATBTime inputTime(dt.time());
|
||||||
QDate d; // check if a special date is configured in tariff-file for this day
|
|
||||||
auto const &prepaidRange = cfg->TariffPrepaids.equal_range(weekDay);
|
auto const &prepaidRange = cfg->TariffPrepaids.equal_range(weekDay);
|
||||||
|
|
||||||
for (auto i = prepaidRange.first; i != prepaidRange.second; ++i) {
|
for (auto i = prepaidRange.first; i != prepaidRange.second; ++i) {
|
||||||
ATBTariffPrepaid const &prepaid = i->second;
|
ATBTariffPrepaid const &prepaid = i->second;
|
||||||
if (!prepaid.m_date.isNull() && prepaid.m_date.isValid() && prepaid.m_date == dt.date()) {
|
|
||||||
d = dt.date();
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "found special day" << d.toString(Qt::ISODate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!d.isNull() && d.isValid()) {
|
|
||||||
for (auto i = prepaidRange.first; i != prepaidRange.second; ++i) {
|
|
||||||
ATBTariffPrepaid const &prepaid = i->second;
|
|
||||||
if (!prepaid.m_date.isNull() && prepaid.m_date.isValid() && prepaid.m_date == d) {
|
|
||||||
TimeRange const &prepaidTimeRange = prepaid.m_range;
|
TimeRange const &prepaidTimeRange = prepaid.m_range;
|
||||||
if (inputTime >= prepaidTimeRange.m_start && inputTime < prepaidTimeRange.m_end) {
|
if (inputTime >= prepaidTimeRange.m_start && inputTime < prepaidTimeRange.m_end) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << prepaidTimeRange.m_start.toString(Qt::ISODate);
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << prepaidTimeRange.m_end.toString(Qt::ISODate);
|
|
||||||
value = value.value_or(i->second);
|
value = value.value_or(i->second);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "no special day" << dt.date().toString(Qt::ISODate);
|
|
||||||
for (auto i = prepaidRange.first; i != prepaidRange.second; ++i) {
|
|
||||||
ATBTariffPrepaid const &prepaid = i->second;
|
|
||||||
if (prepaid.m_date.isNull() || !prepaid.m_date.isValid()) {
|
|
||||||
qCritical() << __func__ << ":" << __LINE__ << "default";
|
|
||||||
TimeRange const &prepaidTimeRange = prepaid.m_range;
|
|
||||||
if (inputTime >= prepaidTimeRange.m_start && inputTime < prepaidTimeRange.m_end) {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << prepaidTimeRange.m_start.toString(Qt::ISODate);
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << prepaidTimeRange.m_end.toString(Qt::ISODate);
|
|
||||||
value = value.value_or(i->second);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -196,22 +161,8 @@ std::optional<ATBTariffCarryOver> getCarryOver(Configuration const *cfg, QDateTi
|
|||||||
|
|
||||||
ATBTime inputTime(dt.time());
|
ATBTime inputTime(dt.time());
|
||||||
auto const &carryOverRange = cfg->TariffCarryOvers.equal_range(weekDay);
|
auto const &carryOverRange = cfg->TariffCarryOvers.equal_range(weekDay);
|
||||||
|
|
||||||
QDate d; // check if a special date is configured in tariff-file for this day
|
|
||||||
for (auto i = carryOverRange.first; i != carryOverRange.second; ++i) {
|
for (auto i = carryOverRange.first; i != carryOverRange.second; ++i) {
|
||||||
ATBTariffCarryOver const &carryOver = i->second;
|
ATBTariffCarryOver const &carryOver = i->second;
|
||||||
if (!carryOver.m_date.isNull() && carryOver.m_date.isValid() && carryOver.m_date == dt.date()) {
|
|
||||||
d = dt.date();
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "found special day" << d.toString(Qt::ISODate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!d.isNull() && d.isValid()) {
|
|
||||||
for (auto i = carryOverRange.first; i != carryOverRange.second; ++i) {
|
|
||||||
ATBTariffCarryOver const &carryOver = i->second;
|
|
||||||
|
|
||||||
if (!carryOver.m_date.isNull() && carryOver.m_date.isValid() && carryOver.m_date == d) {
|
|
||||||
TimeRange const &carryOverTimeRange = carryOver.m_range;
|
TimeRange const &carryOverTimeRange = carryOver.m_range;
|
||||||
if (inputTime >= carryOverTimeRange.m_start && inputTime < carryOverTimeRange.m_end) {
|
if (inputTime >= carryOverTimeRange.m_start && inputTime < carryOverTimeRange.m_end) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << carryOverTimeRange.m_start.toString(Qt::ISODate);
|
// qCritical() << __func__ << ":" << __LINE__ << carryOverTimeRange.m_start.toString(Qt::ISODate);
|
||||||
@ -220,23 +171,6 @@ std::optional<ATBTariffCarryOver> getCarryOver(Configuration const *cfg, QDateTi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "no special day" << dt.date().toString(Qt::ISODate);
|
|
||||||
for (auto i = carryOverRange.first; i != carryOverRange.second; ++i) {
|
|
||||||
ATBTariffCarryOver const &carryOver = i->second;
|
|
||||||
if (carryOver.m_date.isNull() || !carryOver.m_date.isValid()) {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "default";
|
|
||||||
TimeRange const &carryOverTimeRange = carryOver.m_range;
|
|
||||||
if (inputTime >= carryOverTimeRange.m_start && inputTime < carryOverTimeRange.m_end) {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << carryOverTimeRange.m_start.toString(Qt::ISODate);
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << carryOverTimeRange.m_end.toString(Qt::ISODate);
|
|
||||||
value = value.value_or(carryOver);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -252,52 +186,16 @@ std::optional<ATBTariffService> getService(Configuration const *cfg, QDateTime c
|
|||||||
std::optional<ATBTariffService> value = std::nullopt;
|
std::optional<ATBTariffService> value = std::nullopt;
|
||||||
|
|
||||||
int weekDay = dt.date().dayOfWeek();
|
int weekDay = dt.date().dayOfWeek();
|
||||||
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << dt.toString(Qt::ISODate) << weekDay;
|
|
||||||
|
|
||||||
ATBTime inputTime(dt.time());
|
ATBTime inputTime(dt.time());
|
||||||
auto const &serviceRange = cfg->TariffServices.equal_range(weekDay);
|
auto const &serviceRange = cfg->TariffServices.equal_range(weekDay);
|
||||||
|
|
||||||
QDate d; // check if a special date is configured in tariff-file for this day
|
|
||||||
for (auto i = serviceRange.first; i != serviceRange.second; ++i) {
|
for (auto i = serviceRange.first; i != serviceRange.second; ++i) {
|
||||||
ATBTariffService const &service = i->second;
|
ATBTariffService const &service = i->second;
|
||||||
if (!service.m_date.isNull() && service.m_date.isValid() && service.m_date == dt.date()) {
|
|
||||||
d = dt.date();
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "found special day" << d.toString(Qt::ISODate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!d.isNull() && d.isValid()) {
|
|
||||||
for (auto i = serviceRange.first; i != serviceRange.second; ++i) {
|
|
||||||
ATBTariffService const &service = i->second;
|
|
||||||
|
|
||||||
if (!service.m_date.isNull() && service.m_date.isValid() && service.m_date == d) {
|
|
||||||
TimeRange const &serviceTimeRange = service.m_range;
|
TimeRange const &serviceTimeRange = service.m_range;
|
||||||
if (inputTime >= serviceTimeRange.m_start && inputTime < serviceTimeRange.m_end) {
|
if (inputTime >= serviceTimeRange.m_start && inputTime < serviceTimeRange.m_end) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << serviceTimeRange.m_start.toString(Qt::ISODate);
|
value = value.value_or(i->second);
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << serviceTimeRange.m_end.toString(Qt::ISODate);
|
|
||||||
value = value.value_or(service);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "no special day" << dt.date().toString(Qt::ISODate);
|
|
||||||
for (auto i = serviceRange.first; i != serviceRange.second; ++i) {
|
|
||||||
ATBTariffService const &service = i->second;
|
|
||||||
if (service.m_date.isNull() || !service.m_date.isValid()) {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "default";
|
|
||||||
TimeRange const &serviceTimeRange = service.m_range;
|
|
||||||
if (inputTime >= serviceTimeRange.m_start && inputTime < serviceTimeRange.m_end) {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << serviceTimeRange.m_start.toString(Qt::ISODate);
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << serviceTimeRange.m_end.toString(Qt::ISODate);
|
|
||||||
value = value.value_or(service);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -312,50 +210,29 @@ std::optional<ATBTariffOutOfService> getOutOfService(Configuration const *cfg, Q
|
|||||||
std::optional<ATBTariffOutOfService> value = std::nullopt;
|
std::optional<ATBTariffOutOfService> value = std::nullopt;
|
||||||
|
|
||||||
int weekDay = dt.date().dayOfWeek();
|
int weekDay = dt.date().dayOfWeek();
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << dt.toString(Qt::ISODate) << weekDay;
|
|
||||||
|
|
||||||
ATBTime inputTime(dt.time());
|
ATBTime inputTime(dt.time());
|
||||||
QDate date;
|
QDate date;
|
||||||
|
|
||||||
auto const &outOfServiceRange = cfg->TariffOutOfServices.equal_range(weekDay);
|
auto const &outOfServiceRange = cfg->TariffOutOfServices.equal_range(weekDay);
|
||||||
|
|
||||||
QDate d; // check if a special date is configured in tariff-file for this day
|
|
||||||
for (auto i = outOfServiceRange.first; i != outOfServiceRange.second; ++i) {
|
for (auto i = outOfServiceRange.first; i != outOfServiceRange.second; ++i) {
|
||||||
ATBTariffOutOfService const &outOfService = i->second;
|
ATBTariffOutOfService const &outOfService = i->second;
|
||||||
if (!outOfService.m_date.isNull() && outOfService.m_date.isValid() && outOfService.m_date == dt.date()) {
|
TimeRange const &outOfServiceTimeRange = outOfService.m_range;
|
||||||
d = dt.date();
|
if (outOfService.m_date == dt.date()) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "found special day" << d.toString(Qt::ISODate);
|
date = dt.date();
|
||||||
break;
|
if (inputTime >= outOfServiceTimeRange.m_start && inputTime < outOfServiceTimeRange.m_end) {
|
||||||
|
value = value.value_or(i->second);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d.isNull() && d.isValid()) {
|
if (date.isNull() || !date.isValid()) {
|
||||||
for (auto i = outOfServiceRange.first; i != outOfServiceRange.second; ++i) {
|
for (auto i = outOfServiceRange.first; i != outOfServiceRange.second; ++i) {
|
||||||
ATBTariffOutOfService const &outOfService = i->second;
|
ATBTariffOutOfService const &outOfService = i->second;
|
||||||
|
|
||||||
if (!outOfService.m_date.isNull() && outOfService.m_date.isValid() && outOfService.m_date == d) {
|
|
||||||
TimeRange const &outOfServiceTimeRange = outOfService.m_range;
|
TimeRange const &outOfServiceTimeRange = outOfService.m_range;
|
||||||
if (inputTime >= outOfServiceTimeRange.m_start && inputTime < outOfServiceTimeRange.m_end) {
|
if (inputTime >= outOfServiceTimeRange.m_start && inputTime < outOfServiceTimeRange.m_end) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << outOfServiceTimeRange.m_start.toString(Qt::ISODate);
|
value = value.value_or(i->second);
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << outOfServiceTimeRange.m_end.toString(Qt::ISODate);
|
return value;
|
||||||
value = value.value_or(outOfService);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "no special day" << dt.date().toString(Qt::ISODate);
|
|
||||||
for (auto i = outOfServiceRange.first; i != outOfServiceRange.second; ++i) {
|
|
||||||
ATBTariffOutOfService const &outOfService = i->second;
|
|
||||||
if (outOfService.m_date.isNull() || !outOfService.m_date.isValid()) {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "default";
|
|
||||||
TimeRange const &outOfServiceTimeRange = outOfService.m_range;
|
|
||||||
if (inputTime >= outOfServiceTimeRange.m_start && inputTime < outOfServiceTimeRange.m_end) {
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << outOfServiceTimeRange.m_start.toString(Qt::ISODate);
|
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << outOfServiceTimeRange.m_end.toString(Qt::ISODate);
|
|
||||||
value = value.value_or(outOfService);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -554,9 +431,10 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
|||||||
.arg(netto_parking_time_in_minutes)
|
.arg(netto_parking_time_in_minutes)
|
||||||
.arg(free_parking_time_in_minutes);
|
.arg(free_parking_time_in_minutes);
|
||||||
|
|
||||||
if (std::optional<ATBTariffCarryOver> co = getCarryOver(cfg, dt)) {
|
if (std::optional<ATBTariffCarryOver> co = getCarryOver(cfg, inputDate.addSecs(brutto_parking_time_in_minutes * 60))) {
|
||||||
TimeRange const &carryOverTimeRange = co.value().m_range;
|
TimeRange const &carryOverTimeRange = co.value().m_range;
|
||||||
free_parking_time_in_minutes += carryOverTimeRange.m_duration;
|
free_parking_time_in_minutes += carryOverTimeRange.m_duration;
|
||||||
|
}
|
||||||
|
|
||||||
brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
|
brutto_parking_time_in_minutes = free_parking_time_in_minutes + netto_parking_time_in_minutes;
|
||||||
dt = inputDate.addSecs(brutto_parking_time_in_minutes * 60);
|
dt = inputDate.addSecs(brutto_parking_time_in_minutes * 60);
|
||||||
@ -568,7 +446,6 @@ Calculator::ComputeDurationFromCost(Configuration *cfg,
|
|||||||
.arg(brutto_parking_time_in_minutes)
|
.arg(brutto_parking_time_in_minutes)
|
||||||
.arg(netto_parking_time_in_minutes)
|
.arg(netto_parking_time_in_minutes)
|
||||||
.arg(free_parking_time_in_minutes);
|
.arg(free_parking_time_in_minutes);
|
||||||
}
|
|
||||||
|
|
||||||
if (std::optional<ATBTariffService> serv = getService(cfg, dt)) {
|
if (std::optional<ATBTariffService> serv = getService(cfg, dt)) {
|
||||||
TimeRange const &serviceTimeRange = serv.value().m_range;
|
TimeRange const &serviceTimeRange = serv.value().m_range;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user