Compare commits

..

No commits in common. "87b14ee3f886712e051ce47ccbbe4abdd02bcceb" and "493d94aaa1c1dc5f3b3f7d690a8c83921aea45ae" have entirely different histories.

2 changed files with 31 additions and 30 deletions

View File

@ -91,18 +91,7 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg, PERMIT
QVector<ATBTariffProduct> product = products.value(); QVector<ATBTariffProduct> product = products.value();
if (product.size() > 0) { if (product.size() > 0) {
ATBTariffProduct const &p = product[0]; ATBTariffProduct const &p = product[0];
QTime const &currentTime = QDateTime::currentDateTime().time(); return p.m_tariff_product_price;
if (p.m_tariff_product_start <= currentTime && currentTime <= p.m_tariff_product_end) {
return p.m_tariff_product_price;
} else {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
<< "ERROR currentTime"
<< currentTime.toString(Qt::ISODate)
<< "INVALID ("
<< p.m_tariff_product_start.toString(Qt::ISODate)
<< p.m_tariff_product_end.toString(Qt::ISODate) << ")";
}
} }
} }
} break; } break;

View File

@ -34,13 +34,13 @@ extern "C" char* strptime(const char* s,
#include "calculator_functions.h" #include "calculator_functions.h"
#include "calculate_price.h" #include "calculate_price.h"
#define SZEGED (0) #define SZEGED (1)
#define SCHOENAU_KOENIGSEE (0) #define SCHOENAU_KOENIGSEE (0)
#define NEUHAUSER_KORNEUBURG (0) #define NEUHAUSER_KORNEUBURG (0)
#define NEUHAUSER_LINSINGER_MASCHINENBAU (0) #define NEUHAUSER_LINSINGER_MASCHINENBAU (0)
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1) #define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
#define NEUHAUSER_BILEXA_GALTUER (0) #define NEUHAUSER_BILEXA_GALTUER (0)
#define NEUHAUSER_KIRCHDORF (0) #define NEUHAUSER_KIRCHDORF (1)
#if NEUHAUSER_KIRCHDORF==1 #if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) { static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -429,12 +429,13 @@ int main() {
QDateTime end2 = QDateTime(); QDateTime end2 = QDateTime();
if (compute_duration_for_parking_ticket(&cfg, start, cost, end2)) { // return value if (compute_duration_for_parking_ticket(&cfg, start, cost, end2)) { // return value
qCritical() << "start" << start.toString(Qt::ISODate) qCritical() << "XXXX start" << start.toString(Qt::ISODate)
<< "offset" << offset << "offset" << offset
<< "cost" << cost << "cost" << cost
<< "end" << end2.toString(Qt::ISODate); << "end" << end2.toString(Qt::ISODate);
if (end != end2) { if (end != end2) {
qCritical() << end.toString(Qt::ISODate) qCritical() << "YYYY"
<< end.toString(Qt::ISODate)
<< end2.toString(Qt::ISODate); << end2.toString(Qt::ISODate);
} }
} }
@ -602,28 +603,39 @@ int main() {
int w = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET_TEEN); int w = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET_TEEN);
qCritical() << "price teen" << w; qCritical() << "price teen" << w;
return 0;
QDateTime s(QDate(2023, 11, 30), QTime()); QDateTime s(QDate(2023, 11, 30), QTime());
QDateTime end; QDateTime end;
struct price_t price; struct price_t price;
#define ADULT 1 #define ADULT 0
//#define TEEN 1 #define TEEN 1
for (int offset = 480; offset < 1200; ++offset) {
QDateTime start = s.addSecs(offset * 60);
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
#if ADULT==1 #if ADULT==1
PERMIT_TYPE::DAY_TICKET_ADULT, for (int offset = 480; offset < 1080; ++offset) {
#elif TEEN==1 QDateTime start = s.addSecs(offset * 60);
PERMIT_TYPE::DAY_TICKET_TEEN,
#endif // qCritical() << QString(Calculator::GetInstance().isParkingAllowed(&cfg, start));
&price);
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
PERMIT_TYPE::DAY_TICKET_ADULT, &price);
qCritical() << "start=" << start.toString(Qt::ISODate) qCritical() << "start=" << start.toString(Qt::ISODate)
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto; << "end" << end.toString(Qt::ISODate) << "price" << price.netto;
} }
#endif
#if TEEN==1
for (int offset = 480; offset < 1080; ++offset) {
QDateTime start = s.addSecs(offset * 60);
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
PERMIT_TYPE::DAY_TICKET_TEEN, &price);
qCritical() << "start=" << start.toString(Qt::ISODate)
<< "end" << end.toString(Qt::ISODate) << "price" << price.netto;
}
#endif
} }
#undef ADULT
#undef TEEN
#endif #endif
#if NEUHAUSER_LINSINGER_MASCHINENBAU==1 #if NEUHAUSER_LINSINGER_MASCHINENBAU==1