Compare commits
9 Commits
2d53224feb
...
5be5798681
Author | SHA1 | Date | |
---|---|---|---|
5be5798681 | |||
1a24bc4572 | |||
068575f8e8 | |||
e121cef17e | |||
bdaea1106c | |||
bc17213597 | |||
64b2b4bd85 | |||
8737508839 | |||
02f0500eac |
@ -79,12 +79,12 @@ namespace Utilities {
|
|||||||
double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
|
double CalculatePricePerUnit(double pra_price, double durationUnit = -1);
|
||||||
|
|
||||||
QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId);
|
QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId);
|
||||||
QTime SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator it);
|
QTime SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
|
||||||
QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId);
|
QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId);
|
||||||
QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator it);
|
QTime SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it);
|
||||||
QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
QTime WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
|
||||||
QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
QTime WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
|
||||||
int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr);
|
int WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr);
|
||||||
// PaymentRate GetPaymentRate(Configuration const *cfg, );
|
// PaymentRate GetPaymentRate(Configuration const *cfg, );
|
||||||
bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId);
|
bool isCarryOverSet(Configuration const *cfg, PaymentMethod paymentMethodId);
|
||||||
bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId);
|
bool isCarryOverNotSet(Configuration const *cfg, PaymentMethod paymentMethodId);
|
||||||
@ -100,4 +100,5 @@ namespace Utilities {
|
|||||||
uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
|
uint32_t computeWeekDaysPrice(Configuration const *cfg, PaymentMethod id);
|
||||||
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
|
double computeWeekDaysDurationUnit(Configuration const *cfg, PaymentMethod id);
|
||||||
QStringList dumpBusinessHours(uint64_t businessHours);
|
QStringList dumpBusinessHours(uint64_t businessHours);
|
||||||
|
uint32_t getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/include/rapidjson
|
|||||||
#Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE"
|
#Version is set in yocto recipe with "EXTRA_QMAKEVARS_PRE"
|
||||||
#VERSION=1.0.0
|
#VERSION=1.0.0
|
||||||
|
|
||||||
|
# 04.06.2024: Fix for Szeged: read price for daily ticket directly from entry
|
||||||
|
# PaymentOptions in tariff-file if it is not given as part of a
|
||||||
|
# Json-Product-Array in tariff-file.
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
win32 {
|
win32 {
|
||||||
QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
|
QMAKE_CXXFLAGS += -DCALCULATE_LIBRARY_EXPORTS
|
||||||
|
@ -163,6 +163,17 @@ int CALCULATE_LIBRARY_API compute_product_price(Configuration const *cfg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return product_price;
|
return product_price;
|
||||||
|
} else {
|
||||||
|
// SZEGED
|
||||||
|
int const pop_daily_card_price = cfg->getPaymentOptions().pop_daily_card_price;
|
||||||
|
|
||||||
|
qDebug() << QString("(%1:%2) no products defined in tariff-file").arg(__func__).arg(__LINE__);
|
||||||
|
qDebug() << QString("(%1:%2) pop_daily_card_price=%3").arg(__func__).arg(__LINE__).arg(pop_daily_card_price);
|
||||||
|
|
||||||
|
// static const PaymentMethod paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
|
// return Utilities::getDailyTicketCardPrice(cfg, paymentMethodId);
|
||||||
|
|
||||||
|
return pop_daily_card_price;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
|
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
|
||||||
@ -542,7 +553,8 @@ CalcState CALCULATE_LIBRARY_API compute_price_for_parking_ticket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
qCritical() << " -> calculated cost (price->netto) = " << cost;
|
qCritical() << " end_parking_time: " << end_parking_time;
|
||||||
|
qCritical() << " -> calculated cost (netto): " << cost;
|
||||||
|
|
||||||
price->brutto = price->vat = price->vat_percentage = 0;
|
price->brutto = price->vat = price->vat_percentage = 0;
|
||||||
price->units = cost;
|
price->units = cost;
|
||||||
|
@ -628,12 +628,19 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
|
|||||||
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg);
|
||||||
if (paymentMethodId == PaymentMethod::Steps) {
|
if (paymentMethodId == PaymentMethod::Steps) {
|
||||||
uint64_t const businessHours = cfg->getPaymentOptions(paymentOptionIndex).pop_business_hours;
|
uint64_t const businessHours = cfg->getPaymentOptions(paymentOptionIndex).pop_business_hours;
|
||||||
|
|
||||||
if (cfg->isDayIncluded(businessHours, start)) {
|
if (cfg->isDayIncluded(businessHours, start)) {
|
||||||
if (businessHours == BusinessHours::NO_RESTRICTION_24_7) {
|
if (businessHours == BusinessHours::NO_RESTRICTION_24_7) {
|
||||||
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
|
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
|
||||||
QTime(0, 0, 0), QTime(23, 59, 59));
|
QTime(0, 0, 0), QTime(23, 59, 59));
|
||||||
}
|
}
|
||||||
|
|
||||||
int const weekdayId = start.date().dayOfWeek();
|
int const weekdayId = start.date().dayOfWeek();
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER
|
||||||
|
// << "weekdayId" << weekdayId
|
||||||
|
// << "count" << cfg->WeekDaysWorktime.count(weekdayId);
|
||||||
|
|
||||||
if (cfg->WeekDaysWorktime.count(weekdayId) > 0) {
|
if (cfg->WeekDaysWorktime.count(weekdayId) > 0) {
|
||||||
using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
|
using WTIterator = std::multimap<int, ATBWeekDaysWorktime>::const_iterator;
|
||||||
std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
|
std::pair<WTIterator, WTIterator> p = cfg->WeekDaysWorktime.equal_range(weekdayId);
|
||||||
@ -670,28 +677,59 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
int const pop_carry_over = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over;
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER
|
||||||
|
// << "paymentOptionIndex" << paymentOptionIndex
|
||||||
|
// << "pop_carry_over" << pop_carry_over;
|
||||||
|
|
||||||
if (pop_carry_over == 1) {
|
if (pop_carry_over == 1) {
|
||||||
qCritical() << DBG_HEADER
|
// qCritical() << DBG_HEADER
|
||||||
<< "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
|
// << "NO. CHECK IF PARKING IS ALLOWED WITH CARRY-OVER ...";
|
||||||
|
|
||||||
int const pop_carry_over_start_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_start_time_range;
|
int const pop_carry_over_start_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_start_time_range;
|
||||||
int const pop_carry_over_end_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_end_time_range;
|
int const pop_carry_over_end_time_range = cfg->getPaymentOptions(paymentOptionIndex).pop_carry_over_end_time_range;
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER
|
||||||
|
// << "pop_carry_over_start_time_range" << pop_carry_over_start_time_range
|
||||||
|
// << "pop_carry_over_end_time_range" << pop_carry_over_end_time_range;
|
||||||
|
|
||||||
|
if ((int)cfg->TimeRange.count(pop_carry_over_start_time_range) <= 0 &&
|
||||||
|
(int)cfg->TimeRange.count(pop_carry_over_end_time_range) <= 0) {
|
||||||
|
|
||||||
|
qCritical() << DBG_HEADER << "PARKING_ALLOWED. startTime" << startTime.toString(Qt::ISODate);
|
||||||
|
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED", startTime);
|
||||||
|
|
||||||
|
} else
|
||||||
|
// search entry in time-range-field of tariff-file
|
||||||
if (cfg->TimeRange.count(pop_carry_over_start_time_range) == 1 &&
|
if (cfg->TimeRange.count(pop_carry_over_start_time_range) == 1 &&
|
||||||
cfg->TimeRange.count(pop_carry_over_end_time_range) == 1) {
|
cfg->TimeRange.count(pop_carry_over_end_time_range) == 1) {
|
||||||
|
|
||||||
ATBTimeRange s = cfg->TimeRange.find(pop_carry_over_start_time_range)->second;
|
ATBTimeRange s = cfg->TimeRange.find(pop_carry_over_start_time_range)->second;
|
||||||
ATBTimeRange e = cfg->TimeRange.find(pop_carry_over_end_time_range)->second;
|
ATBTimeRange e = cfg->TimeRange.find(pop_carry_over_end_time_range)->second;
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER
|
||||||
|
// << "startTime" << startTime.toString(Qt::ISODate);
|
||||||
|
|
||||||
if (startTime >= s.getTimeFrom() && startTime <= s.getTimeUntil()) {
|
if (startTime >= s.getTimeFrom() && startTime <= s.getTimeUntil()) {
|
||||||
|
|
||||||
QDateTime sd = start;
|
QDateTime sd = start;
|
||||||
sd.setTime(s.getTimeUntil());
|
sd.setTime(s.getTimeUntil());
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER << "jumpFrom" << sd.toString(Qt::ISODate);
|
||||||
|
|
||||||
QDateTime ed = start.addDays(1);
|
QDateTime ed = start.addDays(1);
|
||||||
ed.setTime(e.getTimeFrom());
|
ed.setTime(e.getTimeFrom());
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER << "to" << ed.toString(Qt::ISODate);
|
||||||
|
|
||||||
int const jumpSecs = sd.secsTo(ed);
|
int const jumpSecs = sd.secsTo(ed);
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER << "jumpSecs" << jumpSecs;
|
||||||
|
|
||||||
QDateTime const end = start.addSecs(netto_parking_time*60 + jumpSecs);
|
QDateTime const end = start.addSecs(netto_parking_time*60 + jumpSecs);
|
||||||
|
|
||||||
|
// qCritical() << DBG_HEADER << "new end" << end.toString(Qt::ISODate);
|
||||||
|
|
||||||
if (end.time() <= e.getTimeUntil()) {
|
if (end.time() <= e.getTimeUntil()) {
|
||||||
|
|
||||||
qCritical() << DBG_HEADER
|
qCritical() << DBG_HEADER
|
||||||
@ -701,13 +739,13 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
|
|||||||
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
|
return CalcState(CalcState::State::SUCCESS, "PARKING_ALLOWED",
|
||||||
startTime, end.time());
|
startTime, end.time());
|
||||||
} else {
|
} else {
|
||||||
errorStr = QString("endTime %1 exceeds [%2, %3))")
|
errorStr = QString("endTime %1 outside [%2, %3))")
|
||||||
.arg(end.toString(Qt::ISODate))
|
.arg(end.toString(Qt::ISODate))
|
||||||
.arg(sd.toString(Qt::ISODate))
|
.arg(sd.toString(Qt::ISODate))
|
||||||
.arg(ed.toString(Qt::ISODate));
|
.arg(ed.toString(Qt::ISODate));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errorStr = QString("startTime %1 exceeds [%2, %3))")
|
errorStr = QString("startTime %1 outside [%2, %3))")
|
||||||
.arg(startTime.toString(Qt::ISODate))
|
.arg(startTime.toString(Qt::ISODate))
|
||||||
.arg(s.getTimeFrom().toString(Qt::ISODate))
|
.arg(s.getTimeFrom().toString(Qt::ISODate))
|
||||||
.arg(s.getTimeUntil().toString(Qt::ISODate));
|
.arg(s.getTimeUntil().toString(Qt::ISODate));
|
||||||
@ -730,6 +768,8 @@ CalcState Calculator::isParkingAllowedForWeekDay(Configuration const *cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCritical() << DBG_HEADER << "errorStr" << errorStr;
|
||||||
|
|
||||||
return CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME, errorStr,
|
return CalcState(CalcState::State::OUTSIDE_ALLOWED_PARKING_TIME, errorStr,
|
||||||
QTime(), QTime());
|
QTime(), QTime());
|
||||||
}
|
}
|
||||||
@ -2007,6 +2047,9 @@ Calculator::GetDailyTicketPrice(Configuration* cfg,
|
|||||||
if (dailyTickets) {
|
if (dailyTickets) {
|
||||||
QVector<ATBDailyTicket> const tickets = dailyTickets.value();
|
QVector<ATBDailyTicket> const tickets = dailyTickets.value();
|
||||||
switch (permitType) {
|
switch (permitType) {
|
||||||
|
case PERMIT_TYPE::TWENTY_FOUR_HOURS_TICKET: {
|
||||||
|
// TODO
|
||||||
|
} break;
|
||||||
case PERMIT_TYPE::FOOD_STAMP: {
|
case PERMIT_TYPE::FOOD_STAMP: {
|
||||||
// TODO
|
// TODO
|
||||||
} break;
|
} break;
|
||||||
|
@ -334,11 +334,11 @@ QTime Utilities::SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDa
|
|||||||
return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_from.c_str(), Qt::ISODate);
|
return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_from.c_str(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTime Utilities::SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator it) {
|
QTime Utilities::SpecialDaysWorkTimeFrom(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
|
||||||
return QTime::fromString(it->second.pedwt_time_from.c_str(), Qt::ISODate);
|
return QTime::fromString(it->second.pedwt_time_from.c_str(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTime Utilities::SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator it) {
|
QTime Utilities::SpecialDaysWorkTimeUntil(Configuration::SpecialDaysWorktimeType::const_iterator const &it) {
|
||||||
return QTime::fromString(it->second.pedwt_time_to.c_str(), Qt::ISODate);
|
return QTime::fromString(it->second.pedwt_time_to.c_str(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,15 +346,15 @@ QTime Utilities::SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialD
|
|||||||
return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_to.c_str(), Qt::ISODate);
|
return QTime::fromString(cfg->SpecialDaysWorktime.find(specialDayId)->second.pedwt_time_to.c_str(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
|
QTime Utilities::WeekDaysWorkTimeFrom(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
|
||||||
return QTime::fromString(itr->second.pwd_time_from.c_str(), Qt::ISODate);
|
return QTime::fromString(itr->second.pwd_time_from.c_str(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
|
QTime Utilities::WeekDaysWorkTimeUntil(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
|
||||||
return QTime::fromString(itr->second.pwd_time_to.c_str(), Qt::ISODate);
|
return QTime::fromString(itr->second.pwd_time_to.c_str(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator itr) {
|
int Utilities::WeekDayId(std::multimap<int, ATBWeekDaysWorktime>::const_iterator const &itr) {
|
||||||
return itr->second.pwd_period_day_in_week_id;
|
return itr->second.pwd_period_day_in_week_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,6 +406,10 @@ uint32_t Utilities::getMaximalParkingPrice(Configuration const *cfg, PaymentMeth
|
|||||||
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
|
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_max_price, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Utilities::getDailyTicketCardPrice(Configuration const *cfg, PaymentMethod methodId) {
|
||||||
|
return std::max((int)cfg->PaymentOption.find(methodId)->second.pop_daily_card_price, 0);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
|
uint32_t Utilities::getTimeRangeStep(Configuration const *cfg, int step, PaymentMethod methodId) {
|
||||||
if (methodId == PaymentMethod::Progressive) {
|
if (methodId == PaymentMethod::Progressive) {
|
||||||
Configuration::TimeRangeType::const_iterator it = cfg->TimeRange.find(step);
|
Configuration::TimeRangeType::const_iterator it = cfg->TimeRange.find(step);
|
||||||
|
425
main/main.cpp
425
main/main.cpp
@ -28,22 +28,23 @@ extern "C" char* strptime(const char* s,
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QSet>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#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 (0)
|
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
|
||||||
#define NEUHAUSER_BILEXA_GALTUER (0)
|
#define NEUHAUSER_BILEXA_GALTUER (0)
|
||||||
#define NEUHAUSER_KIRCHDORF (0)
|
|
||||||
#define BAD_NEUENAHR_AHRWEILER (0)
|
#define BAD_NEUENAHR_AHRWEILER (0)
|
||||||
#define NEUHAUSER_CHRISTOPH_REISEN (0)
|
#define NEUHAUSER_CHRISTOPH_REISEN (0)
|
||||||
#define NEUHAUSER_PERNEGG_AN_DER_MUR (1)
|
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
|
||||||
|
|
||||||
#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) {
|
||||||
@ -264,6 +265,18 @@ int main() {
|
|||||||
|
|
||||||
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET);
|
price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET);
|
||||||
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price;
|
||||||
|
|
||||||
|
for (int h = 0; h < 24; ++h) {
|
||||||
|
start.setTime(QTime(h, 0, 0));
|
||||||
|
productStart = productEnd = QDateTime();
|
||||||
|
price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd);
|
||||||
|
qCritical() << QString("line=%1 %2 price (%3-%4) :")
|
||||||
|
.arg(__LINE__)
|
||||||
|
.arg(start.time().toString(Qt::ISODate))
|
||||||
|
.arg(productStart.time().toString(Qt::ISODate))
|
||||||
|
.arg(productEnd.time().toString(Qt::ISODate))
|
||||||
|
<< price;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -344,7 +357,7 @@ int main() {
|
|||||||
// 2024-05-05 10:02:30
|
// 2024-05-05 10:02:30
|
||||||
|
|
||||||
struct price_t costs;
|
struct price_t costs;
|
||||||
double const cost[] = {600, 700, 800, 1600, 2400, 3000, 3600};
|
double const cost[] = {600, 700, 800, 1600, 2400, 3200, 4000};
|
||||||
double price1 = 0;
|
double price1 = 0;
|
||||||
double price2 = 0;
|
double price2 = 0;
|
||||||
|
|
||||||
@ -391,7 +404,7 @@ int main() {
|
|||||||
int pop_carry_over;
|
int pop_carry_over;
|
||||||
int pop_carry_over_time_range_id;
|
int pop_carry_over_time_range_id;
|
||||||
|
|
||||||
for (int zone=6; zone < 7; ++zone) {
|
for (int zone=1; zone < 2; ++zone) {
|
||||||
//for (int t=6; t < 7; t+=20) {
|
//for (int t=6; t < 7; t+=20) {
|
||||||
switch (zone) {
|
switch (zone) {
|
||||||
case 1: {
|
case 1: {
|
||||||
@ -1044,9 +1057,179 @@ int main() {
|
|||||||
&cfg,
|
&cfg,
|
||||||
start,
|
start,
|
||||||
timeSteps.at(i));
|
timeSteps.at(i));
|
||||||
qDebug() << "GetCostFromDuration() time: " << timeSteps.at(i)
|
qCritical() << "zone" << zone
|
||||||
<< "(" << timeSteps.at(i)/60 << "h)"
|
<< "GetCostFromDuration() time: " << timeSteps.at(i)
|
||||||
<< "price=" << price;
|
<< "(" << timeSteps.at(i)/60 << "h)"
|
||||||
|
<< "price=" << price;
|
||||||
|
|
||||||
|
switch(timeSteps.at(i)) {
|
||||||
|
case 60:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 300.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 300.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 3) {
|
||||||
|
if (price == 200.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 700.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 500.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 3) {
|
||||||
|
if (price == 400.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1440:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 900.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 600.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 3) {
|
||||||
|
if (price == 500.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2880:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 1800.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 1200.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4320:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 2700.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 1800.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5760:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 3600.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 2400.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 7200:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 4500.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 3000.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 8640:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 5400.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 3600.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 10080:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 6300.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 4200.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 11520:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 7200.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 4800.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 12960:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 8100.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 5400.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 14400:
|
||||||
|
if (zone == 1) {
|
||||||
|
if (price == 9000.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zone == 2) {
|
||||||
|
if (price == 6000.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qCritical() << "ERROR zone" << zone
|
||||||
|
<< "GetCostFromDuration() time: " << timeSteps.at(i)
|
||||||
|
<< "(" << timeSteps.at(i)/60 << "h)"
|
||||||
|
<< "price=" << price;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1427,15 +1610,25 @@ int main() {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSet<uint32_t> const prices{700, 1400, 2100, 2800, 3500, 4200, 4900};
|
||||||
|
|
||||||
for (int i=0; i<timeSteps.size(); ++i) {
|
for (int i=0; i<timeSteps.size(); ++i) {
|
||||||
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
|
||||||
qCritical() << "nextTimeStep" << nextTimeStep;
|
qCritical() << "nextTimeStep" << nextTimeStep;
|
||||||
|
|
||||||
uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i), paymentOptionIndex);
|
uint32_t price = Calculator::GetInstance().GetPriceForTimeStep(&cfg, timeSteps.at(i), paymentOptionIndex);
|
||||||
uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
|
uint32_t duration = Calculator::GetInstance().GetDurationForPrice(&cfg, price);
|
||||||
|
|
||||||
|
if (!prices.contains(price)) {
|
||||||
|
qCritical() << "ERROR nextTimeStep relative to start:"
|
||||||
|
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
||||||
|
<< "(price so far:" << price << ")";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
qCritical() << "nextTimeStep relative to start:"
|
qCritical() << "nextTimeStep relative to start:"
|
||||||
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
<< duration << start.addSecs(duration * 60).toString(Qt::ISODate)
|
||||||
<< "(price so far:" << price << ")";
|
<< "(price so far:" << price << ")";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1470,6 +1663,11 @@ int main() {
|
|||||||
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
||||||
PERMIT_TYPE::DAY_TICKET_ADULT,
|
PERMIT_TYPE::DAY_TICKET_ADULT,
|
||||||
&price);
|
&price);
|
||||||
|
if (price.netto != 800) {
|
||||||
|
qCritical() << "ERROR(ADULT) start=" << start.toString(Qt::ISODate)
|
||||||
|
<< "end" << end.toString(Qt::ISODate) << "price (ADULT)" << price.netto;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
qCritical() << "start=" << start.toString(Qt::ISODate)
|
qCritical() << "start=" << start.toString(Qt::ISODate)
|
||||||
<< "end" << end.toString(Qt::ISODate) << "price (ADULT)" << price.netto;
|
<< "end" << end.toString(Qt::ISODate) << "price (ADULT)" << price.netto;
|
||||||
}
|
}
|
||||||
@ -1479,6 +1677,11 @@ int main() {
|
|||||||
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
CalcState cs = compute_price_for_daily_ticket(&cfg, start, end,
|
||||||
PERMIT_TYPE::DAY_TICKET_TEEN,
|
PERMIT_TYPE::DAY_TICKET_TEEN,
|
||||||
&price);
|
&price);
|
||||||
|
if (price.netto != 400) {
|
||||||
|
qCritical() << "ERROR(TEEN) start=" << start.toString(Qt::ISODate)
|
||||||
|
<< "end" << end.toString(Qt::ISODate) << "price (TEEN)" << price.netto;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
qCritical() << "start=" << start.toString(Qt::ISODate)
|
qCritical() << "start=" << start.toString(Qt::ISODate)
|
||||||
<< "end" << end.toString(Qt::ISODate) << "price (TEEN)" << price.netto;
|
<< "end" << end.toString(Qt::ISODate) << "price (TEEN)" << price.netto;
|
||||||
}
|
}
|
||||||
@ -1501,6 +1704,11 @@ int main() {
|
|||||||
|
|
||||||
if (isParsed) {
|
if (isParsed) {
|
||||||
int const price = compute_product_price(&cfg, PERMIT_TYPE::FOOD_STAMP);
|
int const price = compute_product_price(&cfg, PERMIT_TYPE::FOOD_STAMP);
|
||||||
|
if (price != 300) {
|
||||||
|
qCritical() << "ERROR price food stamp" << price;
|
||||||
|
exit(-1);
|
||||||
|
|
||||||
|
}
|
||||||
qCritical() << "price food stamp" << price;
|
qCritical() << "price food stamp" << price;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1542,6 +1750,170 @@ int main() {
|
|||||||
<< "duration" << duration
|
<< "duration" << duration
|
||||||
<< "cost" << cost;
|
<< "cost" << cost;
|
||||||
|
|
||||||
|
switch(duration) {
|
||||||
|
case 30:
|
||||||
|
if (cost == 60.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 35:
|
||||||
|
if (cost == 70.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 40:
|
||||||
|
if (cost == 80.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 45:
|
||||||
|
if (cost == 90.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 50:
|
||||||
|
if (cost == 100.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 55:
|
||||||
|
if (cost == 110.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 60:
|
||||||
|
if (cost == 120.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 65:
|
||||||
|
if (cost == 130.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 70:
|
||||||
|
if (cost == 140.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 75:
|
||||||
|
if (cost == 150.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 80:
|
||||||
|
if (cost == 160.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 85:
|
||||||
|
if (cost == 170.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
if (cost == 180.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 95:
|
||||||
|
if (cost == 190.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 100:
|
||||||
|
if (cost == 200.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 105:
|
||||||
|
if (cost == 210.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 110:
|
||||||
|
if (cost == 220.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 115:
|
||||||
|
if (cost == 230.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 120:
|
||||||
|
if (cost == 240.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 125:
|
||||||
|
if (cost == 250.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 130:
|
||||||
|
if (cost == 260.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 135:
|
||||||
|
if (cost == 270.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 140:
|
||||||
|
if (cost == 280.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 145:
|
||||||
|
if (cost == 290.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 150:
|
||||||
|
if (cost == 300.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 155:
|
||||||
|
if (cost == 310.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 160:
|
||||||
|
if (cost == 320.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 165:
|
||||||
|
if (cost == 330.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 170:
|
||||||
|
if (cost == 340.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 175:
|
||||||
|
if (cost == 350.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
if (cost == 360.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qCritical() << "ERROR(1) start" << start.toString(Qt::ISODate)
|
||||||
|
<< "end" << end.toString(Qt::ISODate)
|
||||||
|
<< "duration" << duration
|
||||||
|
<< "cost" << cost;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||||
//Q_ASSERT(cost == duration*2.5);
|
//Q_ASSERT(cost == duration*2.5);
|
||||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||||
@ -1558,6 +1930,13 @@ int main() {
|
|||||||
s.setTime(QTime(12, 0, 0));
|
s.setTime(QTime(12, 0, 0));
|
||||||
int duration = 30;
|
int duration = 30;
|
||||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, s, end, duration, nextDay, prePaid);
|
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, s, end, duration, nextDay, prePaid);
|
||||||
|
if (cost != 60.0) {
|
||||||
|
qCritical() << "ERROR(2) start" << s.toString(Qt::ISODate)
|
||||||
|
<< "end" << end.toString(Qt::ISODate)
|
||||||
|
<< "duration" << duration
|
||||||
|
<< "cost" << cost;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
qCritical() << "start" << s.toString(Qt::ISODate)
|
qCritical() << "start" << s.toString(Qt::ISODate)
|
||||||
<< "end" << end.toString(Qt::ISODate)
|
<< "end" << end.toString(Qt::ISODate)
|
||||||
<< "duration" << duration
|
<< "duration" << duration
|
||||||
@ -1578,7 +1957,7 @@ int main() {
|
|||||||
int pop_max_price;
|
int pop_max_price;
|
||||||
int pop_daily_card_price;
|
int pop_daily_card_price;
|
||||||
|
|
||||||
for (int zone=1; zone < 2; ++zone) {
|
for (int zone = 1; zone < 2; ++zone) {
|
||||||
//for (int t=6; t < 7; t+=20) {
|
//for (int t=6; t < 7; t+=20) {
|
||||||
switch (zone) {
|
switch (zone) {
|
||||||
case 1: {
|
case 1: {
|
||||||
@ -1632,6 +2011,10 @@ int main() {
|
|||||||
qCritical() << " pop_max_price: " << pop_max_price;
|
qCritical() << " pop_max_price: " << pop_max_price;
|
||||||
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
||||||
|
|
||||||
|
|
||||||
|
pop_daily_card_price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET);
|
||||||
|
qCritical() << "pop_daily_card_price: " << pop_daily_card_price;
|
||||||
|
|
||||||
if (pop_min_time > pop_max_time) {
|
if (pop_min_time > pop_max_time) {
|
||||||
qCritical() << "ERROR pop_min_time > pop_max_time"
|
qCritical() << "ERROR pop_min_time > pop_max_time"
|
||||||
<< pop_min_time << pop_max_time;
|
<< pop_min_time << pop_max_time;
|
||||||
@ -1778,7 +2161,7 @@ int main() {
|
|||||||
m.insert(115, 499);
|
m.insert(115, 499);
|
||||||
m.insert(120, 520);
|
m.insert(120, 520);
|
||||||
|
|
||||||
m.insert(125, 524);
|
m.insert(125, 542);
|
||||||
m.insert(130, 564);
|
m.insert(130, 564);
|
||||||
m.insert(135, 585);
|
m.insert(135, 585);
|
||||||
m.insert(140, 607);
|
m.insert(140, 607);
|
||||||
@ -2197,17 +2580,19 @@ int main() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start = s.addSecs(offset * 60);
|
// this->getDayTicketPrice(PERMIT_TYPE::DAY_TICKET)
|
||||||
// end = QDateTime();
|
|
||||||
//if (compute_duration_for_daily_ticket(&cfg, start, end)) {
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// qCritical() << "ERROR computing_duration_for_daily_ticket AT"
|
|
||||||
// << "start" << start.toString(Qt::ISODate);
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
++cnt;
|
// start = s.addSecs(offset * 60);
|
||||||
|
// end = QDateTime();
|
||||||
|
// if (compute_duration_for_daily_ticket(&cfg, start, end)) {
|
||||||
|
//
|
||||||
|
// } else {
|
||||||
|
// qCritical() << "ERROR computing_duration_for_daily_ticket AT"
|
||||||
|
// << "start" << start.toString(Qt::ISODate);
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ++cnt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user