65 lines
2.5 KiB
C
65 lines
2.5 KiB
C
|
#ifndef TARIFF_PRODUCT_H_INCLUDED
|
||
|
#define TARIFF_PRODUCT_H_INCLUDED
|
||
|
|
||
|
#include <QString>
|
||
|
#include <QDateTime>
|
||
|
#include <QDebug>
|
||
|
#include <QDebugStateSaver>
|
||
|
|
||
|
#include "tariff_permit_type.h"
|
||
|
|
||
|
struct ATBTariffProduct {
|
||
|
PermitType m_tariff_product_id;
|
||
|
uint32_t m_tariff_product_price;
|
||
|
QString m_tariff_product_name;
|
||
|
QTime m_tariff_product_start;
|
||
|
QTime m_tariff_product_end;
|
||
|
int m_tariff_product_from_in_minutes_from_start;
|
||
|
int m_tariff_product_to_in_minutes_from_start;
|
||
|
|
||
|
explicit ATBTariffProduct() = default;
|
||
|
|
||
|
QTime const &getTimeStart() const { return m_tariff_product_start; }
|
||
|
QTime const &getTimeEnd() const { return m_tariff_product_end; }
|
||
|
|
||
|
bool computeQTimeStart(QTime const &t) {
|
||
|
if (m_tariff_product_from_in_minutes_from_start != -1) {
|
||
|
m_tariff_product_start = t.addSecs(m_tariff_product_from_in_minutes_from_start * 60);
|
||
|
return m_tariff_product_start.isValid();
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
bool computeQTimeEnd(QTime const &t) {
|
||
|
if (m_tariff_product_to_in_minutes_from_start != -1) {
|
||
|
m_tariff_product_end = t.addSecs(m_tariff_product_from_in_minutes_from_start * 60);
|
||
|
return m_tariff_product_end.isValid();
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
bool computeQTimes(QTime const &t) {
|
||
|
if (!t.isNull() && t.isValid()) {
|
||
|
return computeQTimeStart(t) && computeQTimeEnd(t);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
friend QDebug operator<<(QDebug debug, ATBTariffProduct const &product) {
|
||
|
QDebugStateSaver saver(debug);
|
||
|
|
||
|
debug.nospace()
|
||
|
<< " m_tariff_product_id: " << QString(product.m_tariff_product_id) << "\n"
|
||
|
<< " m_tariff_product_name: " << product.m_tariff_product_name << "\n"
|
||
|
<< " m_tariff_product_price: " << product.m_tariff_product_price << "\n"
|
||
|
<< " m_tariff_product_start: " << product.m_tariff_product_start << "\n"
|
||
|
<< " m_tariff_product_end: " << product.m_tariff_product_end << "\n"
|
||
|
<< "m_tariff_product_from_in_minutes_from_start: " << product.m_tariff_product_from_in_minutes_from_start << "\n"
|
||
|
<< " m_tariff_product_to_in_minutes_from_start: " << product.m_tariff_product_to_in_minutes_from_start << "\n";
|
||
|
|
||
|
return debug;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
#endif // TARIFF_PRODUCT_H_INCLUDED
|