Added struct ATBTariffPrepaid
This commit is contained in:
parent
bc9645f1fa
commit
8e4f47c7b6
@ -1,10 +1,84 @@
|
||||
#ifndef TARIFF_PREPAID_H_INCLUDED
|
||||
#define TARIFF_PREPAID_H_INCLUDED
|
||||
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
|
||||
#include "atb_time.h"
|
||||
#include "time_range.h"
|
||||
|
||||
enum class ApplyPrepaid {
|
||||
NEVER = 0,
|
||||
MATCH_PREV_DAY = 1,
|
||||
MATCH_NEXT_DAY = 2,
|
||||
ALWAYS = 3
|
||||
};
|
||||
|
||||
struct ATBTariffPrepaid {
|
||||
int m_id;
|
||||
QString m_weekDay;
|
||||
QDate m_date;
|
||||
TimeRange m_range;
|
||||
ApplyPrepaid m_prepaidIf;
|
||||
|
||||
explicit ATBTariffPrepaid()
|
||||
: m_id(-1)
|
||||
, m_prepaidIf(ApplyPrepaid::NEVER) {
|
||||
}
|
||||
|
||||
void setPrepaidIf(QString const &ppif) {
|
||||
if (ppif == "never") {
|
||||
m_prepaidIf = ApplyPrepaid::NEVER;
|
||||
} else
|
||||
if (ppif == "match_prev_day") {
|
||||
m_prepaidIf = ApplyPrepaid::MATCH_PREV_DAY;
|
||||
} else
|
||||
if (ppif == "match_next_day") {
|
||||
m_prepaidIf = ApplyPrepaid::MATCH_NEXT_DAY;
|
||||
} else
|
||||
if (ppif == "always") {
|
||||
m_prepaidIf = ApplyPrepaid::ALWAYS;
|
||||
} else {
|
||||
qCritical() << "ERROR unknown carry over application" << ppif;
|
||||
}
|
||||
}
|
||||
|
||||
ApplyPrepaid prepaidIf() const {
|
||||
return m_prepaidIf;
|
||||
}
|
||||
|
||||
QString prepaidIfStr() const {
|
||||
if (m_prepaidIf == ApplyPrepaid::NEVER) {
|
||||
return "never";
|
||||
}
|
||||
if (m_prepaidIf == ApplyPrepaid::ALWAYS) {
|
||||
return "always";
|
||||
}
|
||||
if (m_prepaidIf == ApplyPrepaid::MATCH_PREV_DAY) {
|
||||
return "match prev day";
|
||||
}
|
||||
if (m_prepaidIf == ApplyPrepaid::MATCH_NEXT_DAY) {
|
||||
return "match next day";
|
||||
}
|
||||
return QString("ERROR unknown prepaid application: %1").arg(static_cast<int>(m_prepaidIf));
|
||||
}
|
||||
|
||||
friend QDebug operator<<(QDebug debug, ATBTariffPrepaid const &pp) {
|
||||
QDebugStateSaver saver(debug);
|
||||
|
||||
debug.nospace()
|
||||
<< "\nTariffPrepaid:\n"
|
||||
<< " week day: " << pp.m_weekDay << "\n"
|
||||
<< " date: " << pp.m_date.toString(Qt::ISODate) << "\n"
|
||||
<< " id: " << pp.m_id << "\n"
|
||||
<< " start: " << pp.m_range.m_start << "\n"
|
||||
<< " end: " << pp.m_range.m_end << "\n"
|
||||
<< " duration: " << pp.m_range.m_duration << "\n"
|
||||
<< " prepaid if: " << pp.prepaidIfStr() << endl;
|
||||
return debug;
|
||||
}
|
||||
};
|
||||
|
||||
// deprecated
|
||||
|
||||
struct ATBPrepaid {
|
||||
int id;
|
||||
|
Loading…
Reference in New Issue
Block a user