2024-07-19 13:58:22 +02:00
|
|
|
#ifndef TARIFF_CARRYOVER_H_INCLUDED
|
|
|
|
#define TARIFF_CARRYOVER_H_INCLUDED
|
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
|
2024-09-27 13:40:18 +02:00
|
|
|
#include "time_range.h"
|
|
|
|
|
|
|
|
enum class ApplyCarryOver {
|
|
|
|
NEVER = 0,
|
|
|
|
MATCH_PREV_DAY = 1,
|
|
|
|
MATCH_NEXT_DAY = 2,
|
|
|
|
ALWAYS = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ATBTariffCarryOver {
|
|
|
|
int m_id;
|
|
|
|
QString m_weekDay;
|
|
|
|
TimeRange m_range;
|
|
|
|
QDate m_date;
|
|
|
|
ApplyCarryOver m_carryOverIf;
|
|
|
|
|
|
|
|
explicit ATBTariffCarryOver()
|
|
|
|
: m_id(-1)
|
|
|
|
, m_carryOverIf(ApplyCarryOver::NEVER) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void setCarryOverIf(QString const &coif) {
|
|
|
|
if (coif == "never") {
|
|
|
|
m_carryOverIf = ApplyCarryOver::NEVER;
|
|
|
|
} else
|
|
|
|
if (coif == "match_prev_day") {
|
|
|
|
m_carryOverIf = ApplyCarryOver::MATCH_PREV_DAY;
|
|
|
|
} else
|
|
|
|
if (coif == "match_next_day") {
|
|
|
|
m_carryOverIf = ApplyCarryOver::MATCH_NEXT_DAY;
|
|
|
|
} else
|
|
|
|
if (coif == "always") {
|
|
|
|
m_carryOverIf = ApplyCarryOver::ALWAYS;
|
|
|
|
} else {
|
|
|
|
qCritical() << "ERROR unknown carry over application" << coif;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplyCarryOver carryOverIf() const {
|
|
|
|
return m_carryOverIf;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString carryOverIfStr() const {
|
|
|
|
if (m_carryOverIf == ApplyCarryOver::NEVER) {
|
|
|
|
return "never";
|
|
|
|
}
|
|
|
|
if (m_carryOverIf == ApplyCarryOver::ALWAYS) {
|
|
|
|
return "always";
|
|
|
|
}
|
|
|
|
if (m_carryOverIf == ApplyCarryOver::MATCH_PREV_DAY) {
|
|
|
|
return "match prev day";
|
|
|
|
}
|
|
|
|
if (m_carryOverIf == ApplyCarryOver::MATCH_NEXT_DAY) {
|
|
|
|
return "match next day";
|
|
|
|
}
|
|
|
|
return QString("ERROR unknown carry over application: %1").arg(static_cast<int>(m_carryOverIf));
|
|
|
|
}
|
|
|
|
|
|
|
|
friend QDebug operator<<(QDebug debug, ATBTariffCarryOver const &co) {
|
|
|
|
QDebugStateSaver saver(debug);
|
|
|
|
|
|
|
|
debug.nospace()
|
|
|
|
<< "\nTariffCarryOver:\n"
|
|
|
|
<< " week day: " << co.m_weekDay << "\n"
|
|
|
|
<< " date: " << co.m_date.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " id: " << co.m_id << "\n"
|
|
|
|
<< " start: " << co.m_range.m_start << "\n"
|
|
|
|
<< " end: " << co.m_range.m_end << "\n"
|
|
|
|
<< " duration: " << co.m_range.m_duration << "\n"
|
|
|
|
<< " carry over if: " << co.carryOverIfStr() << endl;
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-07-19 13:58:22 +02:00
|
|
|
struct ATBCarryOver {
|
|
|
|
struct week {
|
|
|
|
int day;
|
|
|
|
bool seemless;
|
|
|
|
bool never;
|
|
|
|
QTime static_start;
|
|
|
|
QTime static_end;
|
2024-07-21 20:58:12 +02:00
|
|
|
int duration;
|
2024-07-19 13:58:22 +02:00
|
|
|
} carryover[8];
|
|
|
|
|
|
|
|
int id;
|
|
|
|
|
2024-09-11 11:35:17 +02:00
|
|
|
explicit ATBCarryOver()
|
|
|
|
: id(-1) {
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 8; ++i) {
|
|
|
|
carryover[i].day = -1;
|
|
|
|
carryover[i].seemless = false;
|
|
|
|
carryover[i].never = false;
|
|
|
|
carryover[i].static_start = QTime(23, 59, 59);
|
|
|
|
carryover[i].static_end = QTime(0, 0, 0);
|
|
|
|
carryover[i].duration = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-19 13:58:22 +02:00
|
|
|
friend QDebug operator<<(QDebug debug, ATBCarryOver const &co) {
|
|
|
|
QDebugStateSaver saver(debug);
|
|
|
|
|
|
|
|
debug.nospace()
|
|
|
|
<< " id:" << co.id << "\n"
|
|
|
|
<< " **** Monday **** \n"
|
|
|
|
<< " day: " << co.carryover[(int)Qt::Monday].day << "\n"
|
|
|
|
<< " static_start: " << co.carryover[(int)Qt::Monday].static_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " static_end: " << co.carryover[(int)Qt::Monday].static_end.toString(Qt::ISODate) << "\n"
|
2024-07-21 20:58:12 +02:00
|
|
|
<< " duration: " << co.carryover[(int)Qt::Monday].duration << "\n"
|
2024-07-19 13:58:22 +02:00
|
|
|
<< " anytime: " << co.carryover[(int)Qt::Monday].seemless << "\n"
|
|
|
|
<< " never: " << co.carryover[(int)Qt::Monday].never << "\n"
|
|
|
|
<< " **** Tuesday **** \n"
|
|
|
|
<< " day: " << co.carryover[(int)Qt::Tuesday].day << "\n"
|
|
|
|
<< " static_start: " << co.carryover[(int)Qt::Tuesday].static_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " static_end: " << co.carryover[(int)Qt::Tuesday].static_end.toString(Qt::ISODate) << "\n"
|
2024-09-11 11:35:17 +02:00
|
|
|
<< " duration: " << co.carryover[(int)Qt::Tuesday].duration << "\n"
|
2024-07-19 13:58:22 +02:00
|
|
|
<< " anytime: " << co.carryover[(int)Qt::Tuesday].seemless << "\n"
|
|
|
|
<< " never: " << co.carryover[(int)Qt::Tuesday].never << "\n"
|
|
|
|
<< " **** Wednesday **** \n"
|
|
|
|
<< " day: " << co.carryover[(int)Qt::Wednesday].day << "\n"
|
|
|
|
<< " static_start: " << co.carryover[(int)Qt::Wednesday].static_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " static_end: " << co.carryover[(int)Qt::Wednesday].static_end.toString(Qt::ISODate) << "\n"
|
2024-09-11 11:35:17 +02:00
|
|
|
<< " duration: " << co.carryover[(int)Qt::Wednesday].duration << "\n"
|
2024-07-19 13:58:22 +02:00
|
|
|
<< " anytime: " << co.carryover[(int)Qt::Wednesday].seemless << "\n"
|
|
|
|
<< " never: " << co.carryover[(int)Qt::Wednesday].never << "\n"
|
|
|
|
<< " **** Thursday **** \n"
|
|
|
|
<< " day: " << co.carryover[(int)Qt::Thursday].day << "\n"
|
|
|
|
<< " static_start: " << co.carryover[(int)Qt::Thursday].static_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " static_end: " << co.carryover[(int)Qt::Thursday].static_end.toString(Qt::ISODate) << "\n"
|
2024-09-11 11:35:17 +02:00
|
|
|
<< " duration: " << co.carryover[(int)Qt::Thursday].duration << "\n"
|
2024-07-19 13:58:22 +02:00
|
|
|
<< " anytime: " << co.carryover[(int)Qt::Thursday].seemless << "\n"
|
|
|
|
<< " never: " << co.carryover[(int)Qt::Thursday].never << "\n"
|
|
|
|
<< " **** Friday **** \n"
|
|
|
|
<< " day: " << co.carryover[(int)Qt::Friday].day << "\n"
|
|
|
|
<< " static_start: " << co.carryover[(int)Qt::Friday].static_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " static_end: " << co.carryover[(int)Qt::Friday].static_end.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " anytime: " << co.carryover[(int)Qt::Friday].seemless << "\n"
|
|
|
|
<< " never: " << co.carryover[(int)Qt::Friday].never << "\n"
|
|
|
|
<< " **** Saturday **** \n"
|
|
|
|
<< " day: " << co.carryover[(int)Qt::Saturday].day << "\n"
|
|
|
|
<< " static_start: " << co.carryover[(int)Qt::Saturday].static_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " static_end: " << co.carryover[(int)Qt::Saturday].static_end.toString(Qt::ISODate) << "\n"
|
2024-09-11 11:35:17 +02:00
|
|
|
<< " duration: " << co.carryover[(int)Qt::Saturday].duration << "\n"
|
2024-07-19 13:58:22 +02:00
|
|
|
<< " anytime: " << co.carryover[(int)Qt::Saturday].seemless << "\n"
|
|
|
|
<< " never: " << co.carryover[(int)Qt::Saturday].never << "\n"
|
|
|
|
<< " **** Sunday **** \n"
|
|
|
|
<< " day: " << co.carryover[(int)Qt::Sunday].day << "\n"
|
|
|
|
<< " static_start: " << co.carryover[(int)Qt::Sunday].static_start.toString(Qt::ISODate) << "\n"
|
|
|
|
<< " static_end: " << co.carryover[(int)Qt::Sunday].static_end.toString(Qt::ISODate) << "\n"
|
2024-09-11 11:35:17 +02:00
|
|
|
<< " duration: " << co.carryover[(int)Qt::Sunday].duration << "\n"
|
2024-07-19 13:58:22 +02:00
|
|
|
<< " anytime: " << co.carryover[(int)Qt::Sunday].seemless << "\n"
|
|
|
|
<< " never: " << co.carryover[(int)Qt::Sunday].never << "\n";
|
|
|
|
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TARIFF_CARRYOVER_H_INCLUDED
|